summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/spirv/spirv_to_nir.c11
1 files changed, 10 insertions, 1 deletions
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);