freedreno/ir3: Fix loading half-float immediate vectors
authorNeil Roberts <nroberts@igalia.com>
Sun, 2 Dec 2018 17:15:52 +0000 (18:15 +0100)
committerRob Clark <robdclark@chromium.org>
Mon, 3 Jun 2019 19:44:03 +0000 (12:44 -0700)
Previously the code to load from a constant instruction was always
using the u32 pointer. If the constant is actually a 16-bit source
this would end up with the wrong values because the pointer would be
offset by the wrong size. This fixes it to use the u16 pointer.

Signed-off-by: Rob Clark <robdclark@chromium.org>
src/freedreno/ir3/ir3_compiler_nir.c

index f4192b9..0a97c42 100644 (file)
@@ -1586,10 +1586,19 @@ emit_load_const(struct ir3_context *ctx, nir_load_const_instr *instr)
 {
        struct ir3_instruction **dst = ir3_get_dst_ssa(ctx, &instr->def,
                        instr->def.num_components);
-       type_t type = (instr->def.bit_size < 32) ? TYPE_U16 : TYPE_U32;
 
-       for (int i = 0; i < instr->def.num_components; i++)
-               dst[i] = create_immed_typed(ctx->block, instr->value[i].u32, type);
+       if (instr->def.bit_size < 32) {
+               for (int i = 0; i < instr->def.num_components; i++)
+                       dst[i] = create_immed_typed(ctx->block,
+                                                                               instr->value[i].u16,
+                                                                               TYPE_U16);
+       } else {
+               for (int i = 0; i < instr->def.num_components; i++)
+                       dst[i] = create_immed_typed(ctx->block,
+                                                                               instr->value[i].u32,
+                                                                               TYPE_U32);
+       }
+
 }
 
 static void