panfrost: Allow passing an explicit UBO index for the sysval UBO
UBO index assignment is a bit special in Vulkan, it's based on the descriptor set layout, which doesn't know about shaders' internal UBOs (our sysval UBOs). Extend the backend compilers so we can place sysval UBOs where we want: after all explicit UBOs. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9517>
This commit is contained in:

committed by
Marge Bot

parent
92d9f090d9
commit
3559efb9bf
@@ -325,6 +325,8 @@ static bi_instr *
|
||||
bi_load_sysval_to(bi_builder *b, bi_index dest, int sysval,
|
||||
unsigned nr_components, unsigned offset)
|
||||
{
|
||||
unsigned sysval_ubo =
|
||||
MAX2(b->shader->inputs->sysval_ubo, b->shader->nir->info.num_ubos);
|
||||
unsigned uniform =
|
||||
pan_lookup_sysval(b->shader->sysval_to_id,
|
||||
&b->shader->info->sysvals,
|
||||
@@ -333,7 +335,7 @@ bi_load_sysval_to(bi_builder *b, bi_index dest, int sysval,
|
||||
|
||||
return bi_load_to(b, nr_components * 32, dest,
|
||||
bi_imm_u32(idx),
|
||||
bi_imm_u32(b->shader->nir->info.num_ubos), BI_SEG_UBO);
|
||||
bi_imm_u32(sysval_ubo), BI_SEG_UBO);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -226,7 +226,10 @@ pan_shader_compile(const struct panfrost_device *dev,
|
||||
info->outputs_written = s->info.outputs_written;
|
||||
|
||||
/* Sysvals have dedicated UBO */
|
||||
info->ubo_count = s->info.num_ubos + (info->sysvals.sysval_count ? 1 : 0);
|
||||
if (info->sysvals.sysval_count)
|
||||
info->ubo_count = MAX2(s->info.num_ubos + 1, inputs->sysval_ubo + 1);
|
||||
else
|
||||
info->ubo_count = s->info.num_ubos;
|
||||
|
||||
info->attribute_count += util_bitcount(s->info.images_used);
|
||||
info->writes_global = s->info.writes_memory;
|
||||
|
@@ -1445,6 +1445,8 @@ emit_sysval_read(compiler_context *ctx, nir_instr *instr,
|
||||
nir_dest nir_dest;
|
||||
|
||||
/* Figure out which uniform this is */
|
||||
unsigned sysval_ubo =
|
||||
MAX2(ctx->inputs->sysval_ubo, ctx->nir->info.num_ubos);
|
||||
int sysval = panfrost_sysval_for_instr(instr, &nir_dest);
|
||||
unsigned dest = nir_dest_index(&nir_dest);
|
||||
unsigned uniform =
|
||||
@@ -1453,7 +1455,7 @@ emit_sysval_read(compiler_context *ctx, nir_instr *instr,
|
||||
/* Emit the read itself -- this is never indirect */
|
||||
midgard_instruction *ins =
|
||||
emit_ubo_read(ctx, instr, dest, (uniform * 16) + offset, NULL, 0,
|
||||
ctx->nir->info.num_ubos);
|
||||
sysval_ubo);
|
||||
|
||||
ins->mask = mask_of(nr_components);
|
||||
}
|
||||
|
@@ -125,6 +125,7 @@ struct panfrost_compile_inputs {
|
||||
float constants[4];
|
||||
uint64_t bifrost_blend_desc;
|
||||
} blend;
|
||||
unsigned sysval_ubo;
|
||||
bool shaderdb;
|
||||
bool no_ubo_to_push;
|
||||
|
||||
|
Reference in New Issue
Block a user