From: Alyssa Rosenzweig Date: Tue, 10 Mar 2020 20:00:56 +0000 (-0400) Subject: pan/midgard: Decontextualize midgard_nir_assign_sysval_body X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c2ff3bb0fea546015755914ac7bdb477c2007da3;p=mesa.git pan/midgard: Decontextualize midgard_nir_assign_sysval_body Now all sysval code should be fairly generic. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index e55a16ad519..cbe045b09a9 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -234,6 +234,13 @@ enum midgard_rt_id { 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; @@ -307,11 +314,6 @@ typedef struct compiler_context { 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; @@ -320,6 +322,8 @@ typedef struct compiler_context { /* 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 */ diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index db69619e0ec..1088e0d3e01 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -374,11 +374,9 @@ sysval_for_instr(nir_instr *instr, nir_dest *dest) } 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; @@ -395,9 +393,10 @@ midgard_nir_assign_sysval_body(compiler_context *ctx, nir_instr *instr) } 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; @@ -1375,7 +1374,7 @@ emit_sysval_read(compiler_context *ctx, nir_instr *instr, signed dest_override, /* 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); @@ -1560,7 +1559,7 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr) 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]; @@ -2778,7 +2777,6 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b 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 */ @@ -2831,11 +2829,11 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b /* 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)