pan/mdg: Specialize swizzle to type
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 28 Apr 2020 00:12:55 +0000 (20:12 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Apr 2020 15:35:54 +0000 (15:35 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4793>

src/panfrost/midgard/midgard_print.c

index 58d6cf6727820a8b535df151e66e6e6aff2b18cb..fb0e701d599d357d864debd22e3e06c4a31d728d 100644 (file)
@@ -71,12 +71,18 @@ mir_print_mask(unsigned mask)
 }
 
 static void
-mir_print_swizzle(unsigned *swizzle)
+mir_print_swizzle(unsigned *swizzle, nir_alu_type T)
 {
+        unsigned sz = nir_alu_type_get_type_size(T);
+        unsigned comps = 128 / sz;
+
         printf(".");
 
-        for (unsigned i = 0; i < 16; ++i)
-                putchar(components[swizzle[i]]);
+        for (unsigned i = 0; i < comps; ++i) {
+                unsigned C = swizzle[i];
+                assert(C < comps);
+                putchar(components[C]);
+        }
 }
 
 static const char *
@@ -352,7 +358,7 @@ mir_print_instruction(midgard_instruction *ins)
 
                 if (ins->src[0] != ~0) {
                         pan_print_alu_type(ins->src_types[0], stdout);
-                        mir_print_swizzle(ins->swizzle[0]);
+                        mir_print_swizzle(ins->swizzle[0], ins->src_types[0]);
                 }
         }
         printf(", ");
@@ -366,7 +372,7 @@ mir_print_instruction(midgard_instruction *ins)
 
                 if (ins->src[1] != ~0) {
                         pan_print_alu_type(ins->src_types[1], stdout);
-                        mir_print_swizzle(ins->swizzle[1]);
+                        mir_print_swizzle(ins->swizzle[1], ins->src_types[1]);
                 }
         }
 
@@ -376,7 +382,7 @@ mir_print_instruction(midgard_instruction *ins)
 
                 if (ins->src[c] != ~0) {
                         pan_print_alu_type(ins->src_types[c], stdout);
-                        mir_print_swizzle(ins->swizzle[c]);
+                        mir_print_swizzle(ins->swizzle[c], ins->src_types[c]);
                 }
         }