MIDGARD_NUM_RTS,
};
+struct panfrost_sysvals {
+ /* 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;
+};
+
typedef struct compiler_context {
nir_shader *nir;
gl_shader_stage stage;
unsigned quadword_count;
- /* 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;
-
/* Bitmask of valid metadata */
unsigned metadata;
/* Writeout instructions for each render target */
midgard_instruction *writeout_branch[MIDGARD_NUM_RTS];
+
+ struct panfrost_sysvals sysvals;
} compiler_context;
/* Per-block live_in/live_out */
}
static void
-midgard_nir_assign_sysval_body(compiler_context *ctx, nir_instr *instr)
+midgard_nir_assign_sysval_body(struct panfrost_sysvals *ctx, nir_instr *instr)
{
- int sysval;
-
- sysval = sysval_for_instr(instr, NULL);
+ int sysval = sysval_for_instr(instr, NULL);
if (sysval < 0)
return;
}
static void
-midgard_nir_assign_sysvals(compiler_context *ctx, nir_shader *shader)
+midgard_nir_assign_sysvals(struct panfrost_sysvals *ctx, nir_shader *shader)
{
ctx->sysval_count = 0;
+ ctx->sysval_to_id = _mesa_hash_table_u64_create(NULL);
nir_foreach_function(function, shader) {
if (!function->impl) continue;
/* Figure out which uniform this is */
int sysval = sysval_for_instr(instr, &nir_dest);
- void *val = _mesa_hash_table_u64_search(ctx->sysval_to_id, sysval);
+ void *val = _mesa_hash_table_u64_search(ctx->sysvals.sysval_to_id, sysval);
unsigned dest = nir_dest_index(&nir_dest);
reg = nir_dest_index(&instr->dest);
if (is_uniform && !ctx->is_blend) {
- emit_ubo_read(ctx, &instr->instr, reg, (ctx->sysval_count + offset) * 16, indirect_offset, 4, 0);
+ emit_ubo_read(ctx, &instr->instr, reg, (ctx->sysvals.sysval_count + offset) * 16, indirect_offset, 4, 0);
} else if (is_ubo) {
nir_src index = instr->src[0];
ctx->ssa_constants = _mesa_hash_table_u64_create(NULL);
ctx->hash_to_temp = _mesa_hash_table_u64_create(NULL);
- ctx->sysval_to_id = _mesa_hash_table_u64_create(NULL);
/* Record the varying mapping for the command stream's bookkeeping */
/* Assign sysvals and counts, now that we're sure
* (post-optimisation) */
- midgard_nir_assign_sysvals(ctx, nir);
+ midgard_nir_assign_sysvals(&ctx->sysvals, nir);
program->uniform_count = nir->num_uniforms;
- program->sysval_count = ctx->sysval_count;
- memcpy(program->sysvals, ctx->sysvals, sizeof(ctx->sysvals[0]) * ctx->sysval_count);
+ program->sysval_count = ctx->sysvals.sysval_count;
+ memcpy(program->sysvals, ctx->sysvals.sysvals, sizeof(ctx->sysvals.sysvals[0]) * ctx->sysvals.sysval_count);
nir_foreach_function(func, nir) {
if (!func->impl)