bifrost: Honor src swizzle in special math ops
authorChris Forbes <chrisforbes@google.com>
Tue, 28 Jul 2020 19:40:44 +0000 (12:40 -0700)
committerChris Forbes <chrisforbes@google.com>
Tue, 28 Jul 2020 20:45:20 +0000 (13:45 -0700)
Most ops use the common handling in emit_alu in order to convert NIR
sources to bifrost sources, but the "special" math op lowering handrolls
the conversion (due to needing to reference the same source multiple
times).

Unfortunately, that handrolled lowering did not consider that there
might be a non-identity swizzle on the source. In this case we would
reference the wrong component of the source and generate garbage.

Fixes all but two of the remaining failures on G31 in:
  dEQP-GLES2.functional.shaders.operator.exponential.*highp*

The following tests are still broken due to some other issue:
  dEQP-GLES2.functional.shaders.operator.exponential.exp2.highp_float_fragment
  dEQP-GLES2.functional.shaders.operator.exponential.exp2.highp_vec2_fragment

Signed-off-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6108>

src/panfrost/bifrost/bi_special.c

index 4cb9e15163141d521f7f67a834317a1ce21eceab..16e4d2eb892dd76f93720b13e6230856ce29567d 100644 (file)
@@ -58,7 +58,8 @@ bi_emit_fexp2_new(bi_context *ctx, nir_alu_instr *instr)
                         /* 0x3f80000000 = 1.0f as fp32
                          * 24 = shift to multiply by 2^24 */
                         .u64 = (0x3f800000) | (24ull << 32)
-                }
+                },
+                .swizzle = { { instr->src[0].swizzle[0] } }
         };
 
         /* F2I_RTE T, T */
@@ -81,6 +82,7 @@ bi_emit_fexp2_new(bi_context *ctx, nir_alu_instr *instr)
                 .dest_type = nir_type_float32,
                 .src = { f2i.dest, mscale.src[0] },
                 .src_types = { nir_type_int32, nir_type_float32 },
+                .swizzle = { {}, { instr->src[0].swizzle[0] } }
         };
 
         bi_emit(ctx, mscale);
@@ -100,7 +102,8 @@ bi_emit_flog2_new(bi_context *ctx, nir_alu_instr *instr)
                 .dest = bi_make_temp(ctx),
                 .dest_type = nir_type_int32,
                 .src = { pan_src_index(&instr->src[0].src) },
-                .src_types = { nir_type_float32 }
+                .src_types = { nir_type_float32 },
+                .swizzle = { { instr->src[0].swizzle[0] } }
         };
 
         /* I32_TO_F32 m */
@@ -126,7 +129,8 @@ bi_emit_flog2_new(bi_context *ctx, nir_alu_instr *instr)
                 .src_types = { nir_type_float32, nir_type_float32 },
                 .constant = {
                         .u64 = 0xBF800000 /* -1.0 */
-                }
+                },
+                .swizzle = { {}, { instr->src[0].swizzle[0] } }
         };
 
         /* FLOG2_HELP log2(x)/(x-1), x */
@@ -137,6 +141,7 @@ bi_emit_flog2_new(bi_context *ctx, nir_alu_instr *instr)
                 .dest_type = nir_type_float32,
                 .src = { pan_src_index(&instr->src[0].src) },
                 .src_types = { nir_type_float32 },
+                .swizzle = { { instr->src[0].swizzle[0] } }
         };
 
         /* FMA log2(x)/(x - 1), (x - 1), M */