From 7a8f5eab71aea063b5adb4f82077db337f14f160 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 2 Oct 2020 14:58:15 +0200 Subject: [PATCH] ac/llvm: adjust dmask when image stores are shrinked using the format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It looks like GFX10 doesn't care about dmask if it's greater than the number of components stored but it matters on GFX8-9 (I haven't checked older gens). Fixes: 1b4d968106d ("ac/llvm: fix invalid IR if image stores are shrinked using the format") Signed-off-by: Samuel Pitoiset Reviewed-by: Marek Olšák Part-of: --- src/amd/llvm/ac_llvm_build.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index fb4ecbb0007..e37c3dad588 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -2112,6 +2112,19 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx, struct ac_image_ bool load = a->opcode == ac_image_sample || a->opcode == ac_image_gather4 || a->opcode == ac_image_load || a->opcode == ac_image_load_mip; LLVMTypeRef coord_type = sample ? ctx->f32 : ctx->i32; + uint8_t dmask = a->dmask; + LLVMTypeRef data_type; + char data_type_str[8]; + + if (atomic) { + data_type = ctx->i32; + } else if (a->opcode == ac_image_store || a->opcode == ac_image_store_mip) { + /* Image stores might have been shrinked using the format. */ + data_type = LLVMTypeOf(a->data[0]); + dmask = (1 << ac_get_llvm_num_components(a->data[0])) - 1; + } else { + data_type = a->d16 ? ctx->v4f16 : ctx->v4f32; + } if (atomic || a->opcode == ac_image_store || a->opcode == ac_image_store_mip) { args[num_args++] = a->data[0]; @@ -2120,7 +2133,7 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx, struct ac_image_ } if (!atomic) - args[num_args++] = LLVMConstInt(ctx->i32, a->dmask, false); + args[num_args++] = LLVMConstInt(ctx->i32, dmask, false); if (a->offset) args[num_args++] = ac_to_integer(ctx, a->offset); @@ -2225,18 +2238,6 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx, struct ac_image_ unreachable("invalid dim"); } - LLVMTypeRef data_type; - char data_type_str[8]; - - if (atomic) { - data_type = ctx->i32; - } else if (a->opcode == ac_image_store || a->opcode == ac_image_store_mip) { - /* Image stores might have been shrinked using the format. */ - data_type = LLVMTypeOf(a->data[0]); - } else { - data_type = a->d16 ? ctx->v4f16 : ctx->v4f32; - } - ac_build_type_name_for_intr(data_type, data_type_str, sizeof(data_type_str)); bool lod_suffix = a->lod && (a->opcode == ac_image_sample || a->opcode == ac_image_gather4);