freedreno: Fix loading half-float immediate vectors

Submitted by Neil Roberts on Dec. 3, 2018, 9:44 a.m.

Details

Message ID 20181203094440.13783-2-nroberts@igalia.com
State New
Headers show
Series "freedreno: Add .dir-locals to the common directory" ( rev: 2 ) in Mesa

Not browsing as part of any series.

Commit Message

Neil Roberts Dec. 3, 2018, 9:44 a.m.
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.
---
 src/freedreno/ir3/ir3_compiler_nir.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c
index 445a2b291e9..584c7e83fea 100644
--- a/src/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/freedreno/ir3/ir3_compiler_nir.c
@@ -2525,10 +2525,18 @@  emit_load_const(struct ir3_context *ctx, nir_load_const_instr *instr)
 {
 	struct ir3_instruction **dst = 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.u32[i], 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.u16[i],
+										TYPE_U16);
+	} else {
+		for (int i = 0; i < instr->def.num_components; i++)
+			dst[i] = create_immed_typed(ctx->block,
+										instr->value.u32[i],
+										TYPE_U32);
+	}
 }
 
 static void