pan/bi: Generate TEX_COMPACT instruction
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 21 Apr 2020 17:00:44 +0000 (13:00 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Apr 2020 01:01:17 +0000 (01:01 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4671>

src/panfrost/bifrost/bifrost_compile.c

index 8b7e32f5e8bee3adc76023a02ce3989251dddfde..21211820dfe9f58a4a24fbea359f39e925b2beaf 100644 (file)
@@ -684,7 +684,27 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr)
 static void
 emit_tex_compact(bi_context *ctx, nir_tex_instr *instr)
 {
-        unreachable("stub");
+        bi_instruction tex = {
+                .type = BI_TEX,
+                .op = { .texture = BI_TEX_COMPACT },
+                .dest = bir_dest_index(&instr->dest),
+                .dest_type = instr->dest_type,
+                .src_types = { nir_type_float32, nir_type_float32 },
+                .writemask = instr->dest_type == nir_type_float32 ?
+                        0xFFFF : 0xFF,
+        };
+
+        for (unsigned i = 0; i < instr->num_srcs; ++i) {
+                int index = bir_src_index(&instr->src[i].src);
+                assert (instr->src[i].src_type == nir_tex_src_coord);
+
+                tex.src[0] = index;
+                tex.src[1] = index;
+                tex.swizzle[0][0] = 0;
+                tex.swizzle[1][0] = 1;
+        }
+
+        bi_emit(ctx, tex);
 }
 
 static void