bi_load_sysval_to(bi_builder *b, bi_index dest, int sysval,
unsigned nr_components, unsigned offset)
{
- unsigned uniform = pan_lookup_sysval(&b->shader->sysvals, sysval);
+ unsigned uniform =
+ pan_lookup_sysval(b->shader->sysval_to_id, &b->shader->sysvals,
+ sysval);
unsigned idx = (uniform * 16) + offset;
return bi_load_to(b, nr_components * 32, dest,
bifrost_debug = debug_get_option_bifrost_debug();
bi_context *ctx = rzalloc(NULL, bi_context);
- panfrost_init_sysvals(&ctx->sysvals, ctx);
+ ctx->sysval_to_id = panfrost_init_sysvals(&ctx->sysvals, ctx);
ctx->nir = nir;
ctx->stage = nir->info.stage;
gl_shader_stage stage;
struct list_head blocks; /* list of bi_block */
struct panfrost_sysvals sysvals;
+ struct hash_table_u64 *sysval_to_id;
struct panfrost_ubo_push *push;
uint32_t quirks;
unsigned arch;
midgard_instruction *writeout_branch[MIDGARD_NUM_RTS][MIDGARD_MAX_SAMPLE_ITER];
struct panfrost_sysvals sysvals;
+ struct hash_table_u64 *sysval_to_id;
struct panfrost_ubo_push *push;
} compiler_context;
/* Figure out which uniform this is */
int sysval = panfrost_sysval_for_instr(instr, &nir_dest);
unsigned dest = nir_dest_index(&nir_dest);
- unsigned uniform = pan_lookup_sysval(&ctx->sysvals, sysval);
+ unsigned uniform =
+ pan_lookup_sysval(ctx->sysval_to_id, &ctx->sysvals, sysval);
/* Emit the read itself -- this is never indirect */
midgard_instruction *ins =
/* TODO: Bound against what? */
compiler_context *ctx = rzalloc(NULL, compiler_context);
- panfrost_init_sysvals(&ctx->sysvals, ctx);
+ ctx->sysval_to_id = panfrost_init_sysvals(&ctx->sysvals, ctx);
ctx->nir = nir;
ctx->stage = nir->info.stage;
/* The mapping of sysvals to uniforms, the count, and the off-by-one inverse */
unsigned sysvals[MAX_SYSVAL_COUNT];
unsigned sysval_count;
- struct hash_table_u64 *sysval_to_id;
};
/* Technically Midgard could go up to 92 in a pathological case but we don't
unsigned
pan_lookup_pushed_ubo(struct panfrost_ubo_push *push, unsigned ubo, unsigned offs);
-void
-panfrost_init_sysvals(struct panfrost_sysvals *ctx, void *memctx);
+struct hash_table_u64 *
+panfrost_init_sysvals(struct panfrost_sysvals *sysvals, void *memctx);
unsigned
-pan_lookup_sysval(struct panfrost_sysvals *ctx, int sysval);
+pan_lookup_sysval(struct hash_table_u64 *sysval_to_id,
+ struct panfrost_sysvals *sysvals,
+ int sysval);
int
panfrost_sysval_for_instr(nir_instr *instr, nir_dest *dest);
}
unsigned
-pan_lookup_sysval(struct panfrost_sysvals *ctx, int sysval)
+pan_lookup_sysval(struct hash_table_u64 *sysval_to_id,
+ struct panfrost_sysvals *sysvals,
+ int sysval)
{
/* Try to lookup */
- void *cached = _mesa_hash_table_u64_search(ctx->sysval_to_id, sysval);
+ void *cached = _mesa_hash_table_u64_search(sysval_to_id, sysval);
if (cached)
return ((uintptr_t) cached) - 1;
/* Else assign */
- unsigned id = ctx->sysval_count++;
+ unsigned id = sysvals->sysval_count++;
assert(id < MAX_SYSVAL_COUNT);
- _mesa_hash_table_u64_insert(ctx->sysval_to_id, sysval, (void *) ((uintptr_t) id + 1));
- ctx->sysvals[id] = sysval;
+ _mesa_hash_table_u64_insert(sysval_to_id, sysval, (void *) ((uintptr_t) id + 1));
+ sysvals->sysvals[id] = sysval;
return id;
}
-void
-panfrost_init_sysvals(struct panfrost_sysvals *ctx, void *memctx)
+struct hash_table_u64 *
+panfrost_init_sysvals(struct panfrost_sysvals *sysvals, void *memctx)
{
- ctx->sysval_count = 0;
- ctx->sysval_to_id = _mesa_hash_table_u64_create(memctx);
+ sysvals->sysval_count = 0;
+ return _mesa_hash_table_u64_create(memctx);
}