Mesa (master): ac/llvm: fix invalid IR if image stores are shrinked using the format
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Sep 29 08:13:21 UTC 2020
Module: Mesa
Branch: master
Commit: 1b4d968106daa18a685d9de9769b5984150ab32b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1b4d968106daa18a685d9de9769b5984150ab32b
Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date: Mon Sep 28 09:34:00 2020 +0200
ac/llvm: fix invalid IR if image stores are shrinked using the format
It's not always v4f32 (or v4f16 for 16-bit) when image stores are
shrinked using the format.
This fixes a ton of crashes with RADV_DEBUG=checkir,llvm.
Fixes: e4d75c22beb ("nir/opt_shrink_vectors: shrink image stores using the format")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6882>
---
src/amd/llvm/ac_llvm_build.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index 506ea58ec97..fb4ecbb0007 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -2225,6 +2225,20 @@ 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);
char intr_name[96];
snprintf(intr_name, sizeof(intr_name),
@@ -2234,7 +2248,7 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx, struct ac_image_
name, atomic_subop, a->compare ? ".c" : "",
a->bias ? ".b" : lod_suffix ? ".l" : a->derivs[0] ? ".d" : a->level_zero ? ".lz" : "",
a->min_lod ? ".cl" : "", a->offset ? ".o" : "", dimname,
- atomic ? "i32" : (a->d16 ? "v4f16" : "v4f32"), overload[0], overload[1], overload[2]);
+ data_type_str, overload[0], overload[1], overload[2]);
LLVMTypeRef retty;
if (atomic)
More information about the mesa-commit
mailing list