From 93144175fae626690fe34b9941a600eba8fe8738 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Thu, 14 Apr 2022 19:14:10 +0200 Subject: [PATCH] vtn: clamp SpvOpImageQuerySize dest to 32 bit CL image arrays slice is 64 bit for whatever reason... Signed-off-by: Karol Herbst Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/spirv/spirv_to_nir.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index ad7a8d7bfe4..be9e922324c 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -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);