pan/midgard: Fix vector->scalar swizzles
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 26 Jul 2019 13:30:16 +0000 (06:30 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 26 Jul 2019 15:37:08 +0000 (08:37 -0700)
The swizzle should be taken on the masked component, rather than
unconditionally X.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/midgard_emit.c

index 3522e77d5b160433be516804d170c261d15cb332..ec90d46ba2177f03ba2458dc27c46e607b8e8dec 100644 (file)
@@ -41,14 +41,15 @@ component_from_mask(unsigned mask)
 }
 
 static unsigned
-vector_to_scalar_source(unsigned u, bool is_int, bool is_full)
+vector_to_scalar_source(unsigned u, bool is_int, bool is_full,
+                unsigned masked_component)
 {
         midgard_vector_alu_src v;
         memcpy(&v, &u, sizeof(v));
 
         /* TODO: Integers */
 
-        unsigned component = v.swizzle & 3;
+        unsigned component = (v.swizzle >> (2*masked_component)) & 3;
         bool upper = false; /* TODO */
 
         midgard_scalar_alu_src s = { 0 };
@@ -91,15 +92,17 @@ vector_to_scalar_alu(midgard_vector_alu v, midgard_instruction *ins)
         bool is_full = v.reg_mode == midgard_reg_mode_32;
         bool is_inline_constant = ins->ssa_args.inline_constant;
 
+        unsigned comp = component_from_mask(ins->mask);
+
         /* The output component is from the mask */
         midgard_scalar_alu s = {
                 .op = v.op,
-                .src1 = vector_to_scalar_source(v.src1, is_int, is_full),
-                .src2 = !is_inline_constant ? vector_to_scalar_source(v.src2, is_int, is_full) : 0,
+                .src1 = vector_to_scalar_source(v.src1, is_int, is_full, comp),
+                .src2 = !is_inline_constant ? vector_to_scalar_source(v.src2, is_int, is_full, comp) : 0,
                 .unknown = 0,
                 .outmod = v.outmod,
                 .output_full = is_full,
-                .output_component = component_from_mask(ins->mask),
+                .output_component = comp
         };
 
         /* Full components are physically spaced out */