pan/bi: Handle discard_if in NIR->BIR naively
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 1 May 2020 22:24:11 +0000 (18:24 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 4 May 2020 15:08:15 +0000 (11:08 -0400)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4883>

src/panfrost/bifrost/bifrost_compile.c

index e656eeb49cea5ca0c8c443376fc578f5ed5c8a35..2b5b5070dd98952d2274cec5fc8b37b6c07e362b 100644 (file)
@@ -351,6 +351,25 @@ bi_emit_ld_frag_coord(bi_context *ctx, nir_intrinsic_instr *instr)
         bi_emit(ctx, combine);
 }
 
+static void
+bi_emit_discard_if(bi_context *ctx, nir_intrinsic_instr *instr)
+{
+        nir_src cond = instr->src[0];
+        nir_alu_type T = nir_type_uint | nir_src_bit_size(cond);
+
+        bi_instruction discard = {
+                .type = BI_DISCARD,
+                .cond = BI_COND_NE,
+                .src_types = { T, T },
+                .src = {
+                        pan_src_index(&cond),
+                        BIR_INDEX_ZERO
+                },
+        };
+
+        bi_emit(ctx, discard);
+}
+
 static void
 emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr)
 {
@@ -387,6 +406,10 @@ emit_intrinsic(bi_context *ctx, nir_intrinsic_instr *instr)
                 bi_emit_ld_frag_coord(ctx, instr);
                 break;
 
+        case nir_intrinsic_discard_if:
+                bi_emit_discard_if(ctx, instr);
+                break;
+
         case nir_intrinsic_load_ssbo_address:
                 bi_emit_sysval(ctx, &instr->instr, 1, 0);
                 break;