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