pan/bi: Implement store_output for fragment shaders
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 6 Mar 2020 14:26:44 +0000 (09:26 -0500)
committerMarge Bot <eric+marge@anholt.net>
Sat, 7 Mar 2020 00:37:39 +0000 (00:37 +0000)
Corresponds to a BLEND instruction, possibly preceded by an ATEST
instruction.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4097>

src/panfrost/bifrost/bifrost_compile.c
src/panfrost/bifrost/compiler.h

index 6a57adc4e53f0a2c1b2f37d930e23504e51839ab..922591279c53379a01dda67fcd57c0dfb7a723b8 100644 (file)
@@ -88,6 +88,31 @@ bi_emit_ld_vary(bi_context *ctx, nir_intrinsic_instr *instr)
         bi_emit(ctx, ins);
 }
 
+static void
+bi_emit_frag_out(bi_context *ctx, nir_intrinsic_instr *instr)
+{
+        if (!ctx->emitted_atest) {
+                bi_instruction ins = {
+                        .type = BI_ATEST
+                };
+
+                bi_emit(ctx, ins);
+                bi_schedule_barrier(ctx);
+                ctx->emitted_atest = true;
+        }
+
+        bi_instruction blend = {
+                .type = BI_BLEND,
+                .blend_location = nir_intrinsic_base(instr),
+                .src = {
+                        bir_src_index(&instr->src[0])
+                }
+        };
+
+        bi_emit(ctx, blend);
+        bi_schedule_barrier(ctx);
+}
+
 static void
 emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr)
 {
@@ -99,6 +124,13 @@ emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr)
         case nir_intrinsic_load_interpolated_input:
                 bi_emit_ld_vary(ctx, instr);
                 break;
+        case nir_intrinsic_store_output:
+                if (ctx->stage == MESA_SHADER_FRAGMENT)
+                        bi_emit_frag_out(ctx, instr);
+                else {
+                        /* TODO */
+                }
+                break;
         default:
                 /* todo */
                 break;
index 71d1b2400596f557ee59ccd701af0cde213847da..cbd76d5e2d078f679f9b56da460565b1507c4a6a 100644 (file)
@@ -330,6 +330,7 @@ typedef struct {
        bi_block *after_block;
        bi_block *break_block;
        bi_block *continue_block;
+       bool emitted_atest;
 
        /* Stats for shader-db */
        unsigned instruction_count;