agx: generalize preloaded cache

we'll need it for more regs

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28483>
This commit is contained in:
Alyssa Rosenzweig 2024-03-17 16:42:30 -04:00 committed by Marge Bot
parent 61a4414bf6
commit c6839cfd69
2 changed files with 9 additions and 11 deletions

View file

@ -55,29 +55,27 @@ agx_get_compiler_debug(void)
}
static agx_index
agx_cached_preload(agx_context *ctx, agx_index *cache, unsigned base,
enum agx_size size)
agx_cached_preload(agx_context *ctx, unsigned base, enum agx_size size)
{
if (agx_is_null(*cache)) {
if (agx_is_null(ctx->preloaded[base])) {
agx_block *block = agx_start_block(ctx);
agx_builder b = agx_init_builder(ctx, agx_before_block(block));
*cache = agx_preload(&b, agx_register(base, size));
ctx->preloaded[base] = agx_preload(&b, agx_register(base, size));
}
return *cache;
return ctx->preloaded[base];
}
static agx_index
agx_vertex_id(agx_builder *b)
{
return agx_cached_preload(b->shader, &b->shader->vertex_id, 10, AGX_SIZE_32);
return agx_cached_preload(b->shader, 10, AGX_SIZE_32);
}
static agx_index
agx_instance_id(agx_builder *b)
{
return agx_cached_preload(b->shader, &b->shader->instance_id, 12,
AGX_SIZE_32);
return agx_cached_preload(b->shader, 12, AGX_SIZE_32);
}
#define VARYING_NUM_COMPONENTS (VARYING_SLOT_MAX * 4)

View file

@ -478,10 +478,10 @@ typedef struct {
* components, populated by a split. */
struct hash_table_u64 *allocated_vec;
/* During instruction selection, preloaded values,
* or NULL if it hasn't been preloaded
/* During instruction selection, preloaded values or NULL if it hasn't been
* preloaded.
*/
agx_index vertex_id, instance_id;
agx_index preloaded[AGX_NUM_REGS];
/* Beginning of our stack allocation used for spilling, below that is
* NIR-level scratch.