Module: Mesa
Branch: master
Commit: 2df055ab47fdaa56dff740b1c7e27e88d549ea45
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2df055ab47fdaa56dff740b1c7e27e88d549ea45

Author: Jason Ekstrand <[email protected]>
Date:   Wed Jul 29 17:53:30 2020 -0500

spirv: Pass the deref type to storage_class_to_mode for non-forward pointers

Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6479>

---

 src/compiler/spirv/spirv_to_nir.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index c22f2b285df..65366abb9fb 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1524,6 +1524,10 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
                   "OpTypeForwardPointer is only allowed in Vulkan with "
                   "the PhysicalStorageBuffer storage class");
 
+      struct vtn_type *deref_type = NULL;
+      if (opcode == SpvOpTypePointer)
+         deref_type = vtn_get_type(b, w[3]);
+
       if (val->value_type == vtn_value_type_invalid) {
          val->value_type = vtn_value_type_type;
          val->type = rzalloc(b, struct vtn_type);
@@ -1535,7 +1539,18 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
           * values so they need a real glsl_type.
           */
          enum vtn_variable_mode mode = vtn_storage_class_to_mode(
-            b, storage_class, NULL, NULL);
+            b, storage_class, deref_type, NULL);
+
+         /* The deref type should only matter for the UniformConstant storage
+          * class.  In particular, it should never matter for any storage
+          * classes that are allowed in combination with OpTypeForwardPointer.
+          */
+         if (storage_class != SpvStorageClassUniform &&
+             storage_class != SpvStorageClassUniformConstant) {
+            assert(mode == vtn_storage_class_to_mode(b, storage_class,
+                                                     NULL, NULL));
+         }
+
          val->type->type = nir_address_format_to_glsl_type(
             vtn_mode_to_address_format(b, mode));
       } else {
@@ -1551,7 +1566,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
                      "forward declaration of a pointer, OpTypePointer can "
                      "only be used once for a given id.");
 
-         val->type->deref = vtn_get_type(b, w[3]);
+         val->type->deref = deref_type;
 
          /* Only certain storage classes use ArrayStride.  The others (in
           * particular Workgroup) are expected to be laid out by the driver.

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to