gallivm/nir: fix const loading on big endian systems
authorDave Airlie <airlied@redhat.com>
Sun, 28 Jun 2020 21:40:13 +0000 (07:40 +1000)
committerDave Airlie <airlied@redhat.com>
Sun, 28 Jun 2020 22:51:18 +0000 (08:51 +1000)
The code was expecting the lower 32-bits of the 64-bit to be
what it wanted, don't be implicit, pull the value from the union.

This should fix rendering on big endian systems since NIR was
introduced.

Fixes: 44a6b0107b37 ("gallivm: add nir->llvm translation (v2)")
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5677>

src/gallium/auxiliary/gallivm/lp_bld_nir.c

index 9aa582a0e8a932f1e9695668d9552f58798cae60..f14475e839d96411fc1548f68842f82546b600a0 100644 (file)
@@ -865,7 +865,7 @@ static void visit_load_const(struct lp_build_nir_context *bld_base,
    LLVMValueRef result[NIR_MAX_VEC_COMPONENTS];
    struct lp_build_context *int_bld = get_int_bld(bld_base, true, instr->def.bit_size);
    for (unsigned i = 0; i < instr->def.num_components; i++)
-      result[i] = lp_build_const_int_vec(bld_base->base.gallivm, int_bld->type, instr->value[i].u64);
+      result[i] = lp_build_const_int_vec(bld_base->base.gallivm, int_bld->type, instr->def.bit_size == 32 ? instr->value[i].u32 : instr->value[i].u64);
    assign_ssa_dest(bld_base, &instr->def, result);
 }