Commit c17cabcb authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

midgard: Manually emit fmov/st_vary for constant varyings, resolves #13

parent c4ec082e
......@@ -1374,9 +1374,34 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
if (offset > 0)
offset += 1;
/* Do not emit the varying yet -- instead, just mark down that we need to later */
/* If this varying corresponds to a constant (why?!),
* emit that now since it won't get picked up by
* hoisting (since there is no corresponding move
* emitted otherwise) */
void *constant_value = _mesa_hash_table_u64_search(ctx->ssa_constants, reg + 1);
if (constant_value) {
/* Special case: emit the varying write
* directly to r26 (looks funny in asm but it's
* fine) and emit the store _now_. Possibly
* slightly slower, but this is a really stupid
* special case anyway (why on earth would you
* have a constant varying? Your own fault for
* slightly worse perf :P) */
midgard_instruction ins = v_fmov(SSA_FIXED_REGISTER(REGISTER_CONSTANT), blank_alu_src, SSA_FIXED_REGISTER(26));
attach_constants(ctx, &ins, constant_value, reg + 1);
emit_mir_instruction(ctx, ins);
midgard_instruction st = m_store_vary_32(SSA_FIXED_REGISTER(0), offset);
st.load_store.unknown = 0x1E9E; /* XXX: What is this? */
emit_mir_instruction(ctx, st);
} else {
/* Do not emit the varying yet -- instead, just mark down that we need to later */
_mesa_hash_table_u64_insert(ctx->ssa_varyings, reg + 1, (void *) ((uintptr_t) (offset + 1)));
_mesa_hash_table_u64_insert(ctx->ssa_varyings, reg + 1, (void *) ((uintptr_t) (offset + 1)));
}
} else {
printf("Unknown store\n");
assert(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment