pan/bi: Implement nir_op_vec8 and nir_op_vec16
authorAlyssa Rosenzweig <alyssa@collabora.com>
Wed, 22 Jun 2022 19:42:43 +0000 (15:42 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 1 Sep 2022 21:40:06 +0000 (21:40 +0000)
These are used with OpenCL, particularly with 8-bit types. Luckily, they are
pretty easy to implement with our existing infrastructure. We just need to hit
backspace enough times and we're good to go.

Fixes a subtest of test_basic hiloeo.

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

src/panfrost/bifrost/bifrost_compile.c

index 0c44be3..15a5888 100644 (file)
@@ -2329,29 +2329,21 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr)
         switch (instr->op) {
         case nir_op_vec2:
         case nir_op_vec3:
-        case nir_op_vec4: {
-                bi_index unoffset_srcs[4] = {
-                        srcs > 0 ? bi_src_index(&instr->src[0].src) : bi_null(),
-                        srcs > 1 ? bi_src_index(&instr->src[1].src) : bi_null(),
-                        srcs > 2 ? bi_src_index(&instr->src[2].src) : bi_null(),
-                        srcs > 3 ? bi_src_index(&instr->src[3].src) : bi_null(),
-                };
+        case nir_op_vec4:
+        case nir_op_vec8:
+        case nir_op_vec16: {
+                bi_index unoffset_srcs[16] = { bi_null() };
+                unsigned channels[16] = { 0 };
 
-                unsigned channels[4] = {
-                        instr->src[0].swizzle[0],
-                        instr->src[1].swizzle[0],
-                        srcs > 2 ? instr->src[2].swizzle[0] : 0,
-                        srcs > 3 ? instr->src[3].swizzle[0] : 0,
-                };
+                for (unsigned i = 0; i < srcs; ++i) {
+                        unoffset_srcs[i] = bi_src_index(&instr->src[i].src);
+                        channels[i] = instr->src[i].swizzle[0];
+                }
 
                 bi_make_vec_to(b, dst, unoffset_srcs, channels, srcs, sz);
                 return;
         }
 
-        case nir_op_vec8:
-        case nir_op_vec16:
-                unreachable("should've been lowered");
-
         case nir_op_unpack_32_2x16: {
                 /* Should have been scalarized */
                 assert(comps == 2 && sz == 16);