} else if (ctx->stage == MESA_SHADER_FRAGMENT && !ctx->is_blend) {
emit_varying_read(ctx, reg, offset, nr_comp, component, indirect_offset, t | nir_dest_bit_size(instr->dest), is_flat);
} else if (ctx->is_blend) {
- /* For blend shaders, load the input color, which is
- * preloaded to r0 */
+ /* ctx->blend_input will be precoloured to r0, where
+ * the input is preloaded */
- midgard_instruction move = v_mov(SSA_FIXED_REGISTER(0), reg);
- emit_mir_instruction(ctx, move);
- schedule_barrier(ctx);
+ if (ctx->blend_input == ~0)
+ ctx->blend_input = reg;
+ else
+ emit_mir_instruction(ctx, v_mov(ctx->blend_input, reg));
} else if (ctx->stage == MESA_SHADER_VERTEX) {
emit_attr_read(ctx, reg, offset, nr_comp, t);
} else {
ctx->is_blend = is_blend;
ctx->alpha_ref = program->alpha_ref;
ctx->blend_rt = MIDGARD_COLOR_RT0 + blend_rt;
+ ctx->blend_input = ~0;
ctx->quirks = midgard_get_quirks(gpu_id);
/* Start off with a safe cutoff, allowing usage of all 16 work
l->solutions[ins->dest] = (16 * 1) + COMPONENT_W * 4;
}
+ /* Precolour blend input to r0. Note writeout is necessarily at the end
+ * and blend shaders are single-RT only so there is only a single
+ * writeout block, so this cannot conflict with the writeout r0 (there
+ * is no need to have an intermediate move) */
+
+ if (ctx->blend_input != ~0) {
+ assert(ctx->blend_input < ctx->temp_count);
+ l->solutions[ctx->blend_input] = 0;
+ }
+
mir_compute_interference(ctx, l);
*spilled = !lcra_solve(l);
mir_foreach_instr_global(ctx, ins) {
mir_rewrite_index_dst_single(ins, old, new);
}
+
+ /* Implicitly written before the shader */
+ if (ctx->blend_input == old)
+ ctx->blend_input = new;
}
void