Mesa (main): vtn: clamp SpvOpImageQuerySize dest to 32 bit

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 29 00:32:07 UTC 2022


Module: Mesa
Branch: main
Commit: 93144175fae626690fe34b9941a600eba8fe8738
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=93144175fae626690fe34b9941a600eba8fe8738

Author: Karol Herbst <kherbst at redhat.com>
Date:   Thu Apr 14 19:14:10 2022 +0200

vtn: clamp SpvOpImageQuerySize dest to 32 bit

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

Signed-off-by: Karol Herbst <kherbst at redhat.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16205>

---

 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);



More information about the mesa-commit mailing list