nir: deref only for OpTypePointer
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Wed, 20 Mar 2019 19:20:27 +0000 (19:20 +0000)
committerJuan A. Suarez Romero <jasuarez@igalia.com>
Wed, 20 Mar 2019 19:26:32 +0000 (19:26 +0000)
Fixes dEQP-VK.binding_model.buffer_device_address.* and
dEQP-VK.ssbo.phys.layout* Vulkan CTS tests.

v2: set val->type->stride in the section below (Jason)

v3: restore val->type->type to original place (Jason)

Fixes: d0ba326f238 ("nir/spirv: support physical pointers")
CC: Karol Herbst <kherbst@redhat.com>
CC: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/spirv/spirv_to_nir.c

index 6d6aed287accbf992210d17373188fe5c35e3b25..ce3e0781afc34a9e6b83aaf38b911e0b0b1ce289 100644 (file)
@@ -1319,7 +1319,6 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
        * declaration.
        */
       val = vtn_untyped_value(b, w[1]);
-      struct vtn_type *deref_type = vtn_untyped_value(b, w[3])->type;
 
       SpvStorageClass storage_class = w[2];
 
@@ -1348,19 +1347,13 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
             break;
          case SpvStorageClassWorkgroup:
             val->type->type = b->options->shared_ptr_type;
-            if (b->physical_ptrs)
-               val->type->stride = align(glsl_get_cl_size(deref_type->type), glsl_get_cl_alignment(deref_type->type));
             break;
          case SpvStorageClassCrossWorkgroup:
             val->type->type = b->options->global_ptr_type;
-            if (b->physical_ptrs)
-               val->type->stride = align(glsl_get_cl_size(deref_type->type), glsl_get_cl_alignment(deref_type->type));
             break;
          case SpvStorageClassFunction:
-            if (b->physical_ptrs) {
+            if (b->physical_ptrs)
                val->type->type = b->options->temp_ptr_type;
-               val->type->stride = align(glsl_get_cl_size(deref_type->type), glsl_get_cl_alignment(deref_type->type));
-            }
             break;
          default:
             /* In this case, no variable pointers are allowed so all deref
@@ -1386,6 +1379,19 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
 
          vtn_foreach_decoration(b, val, array_stride_decoration_cb, NULL);
 
+         if (b->physical_ptrs) {
+            switch (storage_class) {
+            case SpvStorageClassFunction:
+            case SpvStorageClassWorkgroup:
+            case SpvStorageClassCrossWorkgroup:
+               val->type->stride = align(glsl_get_cl_size(val->type->deref->type),
+                                         glsl_get_cl_alignment(val->type->deref->type));
+               break;
+            default:
+               break;
+            }
+         }
+
          if (storage_class == SpvStorageClassWorkgroup &&
              b->options->lower_workgroup_access_to_offsets) {
             uint32_t size, align;