vtn: clamp SpvOpImageQuerySize dest to 32 bit

CL image arrays slice is 64 bit for whatever reason...

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16205>
This commit is contained in:
Karol Herbst 2022-04-14 19:14:10 +02:00 committed by Marge Bot
parent c31db58f65
commit 93144175fa
1 changed files with 10 additions and 1 deletions

View File

@ -3563,9 +3563,14 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
if (nir_intrinsic_infos[op].dest_components == 0)
intrin->num_components = dest_components;
unsigned bit_size = glsl_get_bit_size(type->type);
if (opcode == SpvOpImageQuerySize ||
opcode == SpvOpImageQuerySizeLod)
bit_size = MIN2(bit_size, 32);
nir_ssa_dest_init(&intrin->instr, &intrin->dest,
nir_intrinsic_dest_components(intrin),
glsl_get_bit_size(type->type), NULL);
bit_size, NULL);
nir_builder_instr_insert(&b->nb, &intrin->instr);
@ -3573,6 +3578,10 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
if (nir_intrinsic_dest_components(intrin) != dest_components)
result = nir_channels(&b->nb, result, (1 << dest_components) - 1);
if (opcode == SpvOpImageQuerySize ||
opcode == SpvOpImageQuerySizeLod)
result = nir_u2u(&b->nb, result, glsl_get_bit_size(type->type));
if (opcode == SpvOpImageSparseRead) {
struct vtn_ssa_value *dest = vtn_create_ssa_value(b, struct_type->type);
unsigned res_type_size = glsl_get_vector_elements(type->type);