[Mesa-dev] [PATCH 2/3] spirv/vtn: handle variable pointers without offset lowering

Dave Airlie airlied at gmail.com
Wed Jul 4 06:24:42 UTC 2018


From: Dave Airlie <airlied at redhat.com>

---
 src/compiler/spirv/spirv_to_nir.c  | 15 ++++++++-------
 src/compiler/spirv/vtn_variables.c |  3 ++-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index fb4211193fb..f8c11aaf929 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1189,17 +1189,18 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
          val->type->type = glsl_uint_type();
       }
 
-      if (storage_class == SpvStorageClassWorkgroup &&
-          b->options->lower_workgroup_access_to_offsets) {
-         uint32_t size, align;
-         val->type->deref = vtn_type_layout_std430(b, val->type->deref,
-                                                   &size, &align);
-         val->type->length = size;
-         val->type->align = align;
+      if (storage_class == SpvStorageClassWorkgroup) {
          /* These can actually be stored to nir_variables and used as SSA
           * values so they need a real glsl_type.
           */
          val->type->type = glsl_uint_type();
+         if (b->options->lower_workgroup_access_to_offsets) {
+            uint32_t size, align;
+            val->type->deref = vtn_type_layout_std430(b, val->type->deref,
+                                                      &size, &align);
+            val->type->length = size;
+            val->type->align = align;
+         }
       }
       break;
    }
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index b7c9e6f2f70..cfefe804897 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1581,7 +1581,8 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa,
       vtn_assert(ssa->num_components == 2);
       ptr->block_index = nir_channel(&b->nb, ssa, 0);
       ptr->offset = nir_channel(&b->nb, ssa, 1);
-   } else if (ptr->mode == vtn_variable_mode_workgroup ||
+   } else if ((ptr->mode == vtn_variable_mode_workgroup &&
+	       b->options->lower_workgroup_access_to_offsets) ||
               ptr->mode == vtn_variable_mode_push_constant) {
       /* This pointer type needs to have actual storage */
       vtn_assert(ptr_type->type);
-- 
2.17.1



More information about the mesa-dev mailing list