bifrost,midgard: Allow providing a fixed sysval layout

Vulkan doesn't need nearly as many system values and would like to bake
its layout up-front instead of having it provided by the back-end
compiler.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16276>
This commit is contained in:
Jason Ekstrand 2022-04-28 15:46:00 -05:00 committed by Marge Bot
parent e07a296398
commit f0a47d8602
4 changed files with 43 additions and 13 deletions

View file

@ -4961,7 +4961,10 @@ bifrost_compile_shader_nir(nir_shader *nir,
bifrost_debug = debug_get_option_bifrost_debug();
bi_finalize_nir(nir, inputs->gpu_id, inputs->is_blend);
struct hash_table_u64 *sysval_to_id = panfrost_init_sysvals(&info->sysvals, NULL);
struct hash_table_u64 *sysval_to_id =
panfrost_init_sysvals(&info->sysvals,
inputs->fixed_sysval_layout,
NULL);
info->tls_size = nir->scratch_size;
info->vs.idvs = bi_should_idvs(nir, inputs);

View file

@ -3127,7 +3127,9 @@ midgard_compile_shader_nir(nir_shader *nir,
/* TODO: Bound against what? */
compiler_context *ctx = rzalloc(NULL, compiler_context);
ctx->sysval_to_id = panfrost_init_sysvals(&info->sysvals, ctx);
ctx->sysval_to_id = panfrost_init_sysvals(&info->sysvals,
inputs->fixed_sysval_layout,
ctx);
ctx->inputs = inputs;
ctx->nir = nir;

View file

@ -163,7 +163,9 @@ unsigned
pan_lookup_pushed_ubo(struct panfrost_ubo_push *push, unsigned ubo, unsigned offs);
struct hash_table_u64 *
panfrost_init_sysvals(struct panfrost_sysvals *sysvals, void *memctx);
panfrost_init_sysvals(struct panfrost_sysvals *sysvals,
struct panfrost_sysvals *fixed_sysvals,
void *memctx);
unsigned
pan_lookup_sysval(struct hash_table_u64 *sysval_to_id,
@ -182,6 +184,7 @@ struct panfrost_compile_inputs {
uint64_t bifrost_blend_desc;
} blend;
int fixed_sysval_ubo;
struct panfrost_sysvals *fixed_sysval_layout;
bool shaderdb;
bool no_idvs;
bool no_ubo_to_push;

View file

@ -134,6 +134,17 @@ panfrost_sysval_for_instr(nir_instr *instr, nir_dest *dest)
return sysval;
}
static unsigned
pan_add_sysval(struct hash_table_u64 *sysval_to_id,
struct panfrost_sysvals *sysvals,
int sysval, unsigned id)
{
assert(id < MAX_SYSVAL_COUNT);
_mesa_hash_table_u64_insert(sysval_to_id, sysval, (void *) ((uintptr_t) id + 1));
sysvals->sysvals[id] = sysval;
return id;
}
unsigned
pan_lookup_sysval(struct hash_table_u64 *sysval_to_id,
struct panfrost_sysvals *sysvals,
@ -151,18 +162,29 @@ pan_lookup_sysval(struct hash_table_u64 *sysval_to_id,
}
/* Else assign */
unsigned id = sysvals->sysval_count++;
assert(id < MAX_SYSVAL_COUNT);
_mesa_hash_table_u64_insert(sysval_to_id, sysval, (void *) ((uintptr_t) id + 1));
sysvals->sysvals[id] = sysval;
return id;
return pan_add_sysval(sysval_to_id, sysvals, sysval,
sysvals->sysval_count++);
}
struct hash_table_u64 *
panfrost_init_sysvals(struct panfrost_sysvals *sysvals, void *memctx)
panfrost_init_sysvals(struct panfrost_sysvals *sysvals,
struct panfrost_sysvals *fixed_sysvals,
void *memctx)
{
sysvals->sysval_count = 0;
return _mesa_hash_table_u64_create(memctx);
memset(sysvals, 0, sizeof(*sysvals));
struct hash_table_u64 *sysval_to_id =
_mesa_hash_table_u64_create(memctx);
if (fixed_sysvals) {
for (unsigned i = 0; i < fixed_sysvals->sysval_count; i++) {
if (!fixed_sysvals->sysvals[i])
continue;
pan_add_sysval(sysval_to_id, sysvals,
fixed_sysvals->sysvals[i], i);
}
sysvals->sysval_count = fixed_sysvals->sysval_count;
}
return sysval_to_id;
}