aboutsummaryrefslogtreecommitdiffstats
path: root/src/panfrost/midgard/midgard_compile.c
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-07-24 12:52:27 -0700
committerAlyssa Rosenzweig <[email protected]>2019-07-25 06:37:22 -0700
commite169301bd85644edb97591fae3790e9442ea4721 (patch)
treeed4dd25503ae2d0a3aa7ed2862d0ef73685b65df /src/panfrost/midgard/midgard_compile.c
parenteedd6c1dd0040c0a3573000003730a8a3f2e4b78 (diff)
pan/midgard: Add emit_explicit_constant helper
We generalize the constant emission helper used in fragment writeout as we'll also need it for vertex outputs. Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost/midgard/midgard_compile.c')
-rw-r--r--src/panfrost/midgard/midgard_compile.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 7fa9c4b598f..6cd06bc001f 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -530,6 +530,21 @@ emit_load_const(compiler_context *ctx, nir_load_const_instr *instr)
_mesa_hash_table_u64_insert(ctx->ssa_constants, def.index + 1, v);
}
+/* Normally constants are embedded implicitly, but for I/O and such we have to
+ * explicitly emit a move with the constant source */
+
+static void
+emit_explicit_constant(compiler_context *ctx, unsigned node, unsigned to)
+{
+ void *constant_value = _mesa_hash_table_u64_search(ctx->ssa_constants, node + 1);
+
+ if (constant_value) {
+ midgard_instruction ins = v_mov(SSA_FIXED_REGISTER(REGISTER_CONSTANT), blank_alu_src, to);
+ attach_constants(ctx, &ins, constant_value, node + 1);
+ emit_mir_instruction(ctx, ins);
+ }
+}
+
static unsigned
nir_src_index(compiler_context *ctx, nir_src *src)
{
@@ -2077,16 +2092,7 @@ midgard_opt_pos_propagate(compiler_context *ctx, midgard_block *block)
static void
emit_fragment_epilogue(compiler_context *ctx)
{
- /* Special case: writing out constants requires us to include the move
- * explicitly now, so shove it into r0 */
-
- void *constant_value = _mesa_hash_table_u64_search(ctx->ssa_constants, ctx->fragment_output + 1);
-
- if (constant_value) {
- midgard_instruction ins = v_mov(SSA_FIXED_REGISTER(REGISTER_CONSTANT), blank_alu_src, SSA_FIXED_REGISTER(0));
- attach_constants(ctx, &ins, constant_value, ctx->fragment_output + 1);
- emit_mir_instruction(ctx, ins);
- }
+ emit_explicit_constant(ctx, ctx->fragment_output, SSA_FIXED_REGISTER(0));
/* Perform the actual fragment writeout. We have two writeout/branch
* instructions, forming a loop until writeout is successful as per the