Module: Mesa Branch: main Commit: 03c97b212e8906dbd106edcd8e6f9e7ca71cc01b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=03c97b212e8906dbd106edcd8e6f9e7ca71cc01b
Author: Marek Olšák <[email protected]> Date: Fri Mar 24 19:46:56 2023 -0400 amd/llvm: fix handling of unsupported vec3 loads on gfx6 VMEM loads promoted from vec3 to vec4 didn't trim the vector, thus returning vec4 on gfx6 and vec3 on later generations, which callers don't expect. SMEM loads were adding an extra component on gfx6, causing same issues. Fixes: 82919e2d - amd: lower subdword UBO loads in NIR Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8693 Reviewed-by: Konstantin Seurer <[email protected]> Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22117> --- src/amd/llvm/ac_llvm_build.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index 54a95cd76be..7c7b7f4066c 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -1330,8 +1330,11 @@ static LLVMValueRef ac_build_buffer_load_common(struct ac_llvm_context *ctx, LLV snprintf(name, sizeof(name), "llvm.amdgcn.%s.buffer.load.%s", indexing_kind, type_name); } - return ac_build_intrinsic(ctx, name, type, args, idx, - can_speculate ? AC_ATTR_INVARIANT_LOAD : 0); + LLVMValueRef result = ac_build_intrinsic(ctx, name, type, args, idx, + can_speculate ? AC_ATTR_INVARIANT_LOAD : 0); + if (func > num_channels) + result = ac_trim_vector(ctx, result, num_channels); + return result; } LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc, int num_channels, @@ -1369,8 +1372,6 @@ LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc if (num_channels == 1) return result[0]; - if (num_channels == 3 && !ac_has_vec3_support(ctx->gfx_level, false)) - result[num_channels++] = LLVMGetUndef(channel_type); return ac_build_gather_values(ctx, result, num_channels); }
