radv/ac: Fix shared memory offset calculation
authorAlex Smith <asmith@feralinteractive.com>
Thu, 16 Mar 2017 16:40:07 +0000 (16:40 +0000)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 17 Mar 2017 08:35:48 +0000 (09:35 +0100)
The index passed to get_shared_memory_ptr is an attribute slot index,
i.e. the index of a vec4 within LDS. Therefore this must be scaled by
sizeof(vec4) to give the LDS byte offset.

Fixes: f4e499ec791 ("radv: add initial non-conformant radv vulkan driver")
Signed-off-by: Alex Smith <asmith@feralinteractive.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
CC: <mesa-stable@lists.freedesktop.org>
src/amd/common/ac_nir_to_llvm.c

index 01346c35f7173625e3719c82534240a091ca26be..6e36c192c3cc3d011a13b1adad1f4a416942ec4f 100644 (file)
@@ -297,7 +297,7 @@ static LLVMValueRef get_shared_memory_ptr(struct nir_to_llvm_context *ctx,
        LLVMValueRef ptr;
        int addr_space;
 
-       offset = LLVMConstInt(ctx->i32, idx, false);
+       offset = LLVMConstInt(ctx->i32, idx * 16, false);
 
        ptr = ctx->shared_memory;
        ptr = LLVMBuildGEP(ctx->builder, ptr, &offset, 1, "");