- nir_instr_rewrite_src(&intr->instr, &intr->src[0],
- nir_src_for_ssa(result));
- intr->num_components = result->num_components;
+ const int logic_op = c->fs_key->logicop_func;
+ if (c->fs_key->msaa && logicop_depends_on_dst_color(logic_op)) {
+ c->msaa_per_sample_output = true;
+
+ nir_src *offset = &intr->src[1];
+ nir_alu_type type = nir_intrinsic_type(intr);
+ for (int i = 0; i < V3D_MAX_SAMPLES; i++) {
+ nir_ssa_def *sample =
+ v3d_nir_emit_logic_op(c, b, frag_color, rt, i);
+
+ v3d_emit_ms_output(c, b, sample, offset, type, rt, i);
+ }
+
+ nir_instr_remove(&intr->instr);
+ } else {
+ nir_ssa_def *result =
+ v3d_nir_emit_logic_op(c, b, frag_color, rt, 0);
+
+ nir_instr_rewrite_src(&intr->instr, &intr->src[0],
+ nir_src_for_ssa(result));
+ intr->num_components = result->num_components;
+ }