ac/llvm: adjust dmask when image stores are shrinked using the format

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: 1b4d968106 ("ac/llvm: fix invalid IR if image stores are shrinked using the format")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6982>
This commit is contained in:
Samuel Pitoiset
2020-10-02 14:58:15 +02:00
parent 961a8d71cd
commit 7a8f5eab71
+14 -13
View File
@@ -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);