radv/ac: Use base in push constant loads.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sat, 28 Jan 2017 00:32:20 +0000 (01:32 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sat, 28 Jan 2017 02:07:39 +0000 (03:07 +0100)
Apparently the source is not an address but an offset, so we actually
need to use the base.

Signed-off-by: Bas Nieuwenhuizen <basni@google.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
CC: <mesa-stable@lists.freedesktop.org>
src/amd/common/ac_nir_to_llvm.c

index 26b87e8782b6c52a1136ea6760c8fb5c821bdd6b..72ae6eb0730ac1209a4882c1d97580581d13fbee 100644 (file)
@@ -1745,9 +1745,12 @@ static LLVMValueRef visit_vulkan_resource_index(struct nir_to_llvm_context *ctx,
 static LLVMValueRef visit_load_push_constant(struct nir_to_llvm_context *ctx,
                                              nir_intrinsic_instr *instr)
 {
-       LLVMValueRef ptr;
+       LLVMValueRef ptr, addr;
+
+       addr = LLVMConstInt(ctx->i32, nir_intrinsic_base(instr), 0);
+       addr = LLVMBuildAdd(ctx->builder, addr, get_src(ctx, instr->src[0]), "");
 
-       ptr = build_gep0(ctx, ctx->push_constants, get_src(ctx, instr->src[0]));
+       ptr = build_gep0(ctx, ctx->push_constants, addr);
        ptr = cast_ptr(ctx, ptr, get_def_type(ctx, &instr->dest.ssa));
 
        return LLVMBuildLoad(ctx->builder, ptr, "");