[Mesa-dev] [PATCH 03/12] spirv: Use a dereference instead of vtn_variable_resource_index

Jason Ekstrand jason at jlekstrand.net
Thu Oct 19 18:04:05 UTC 2017


This is equivalent and means we don't have resource index code scattered
about.
---
 src/compiler/spirv/vtn_variables.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index a7e6ae0..7bfac46 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1492,11 +1492,9 @@ vtn_pointer_to_ssa(struct vtn_builder *b, struct vtn_pointer *ptr)
    assert(ptr->ptr_type);
    assert(ptr->ptr_type->type);
 
-   if (ptr->offset && ptr->block_index) {
-      return nir_vec2(&b->nb, ptr->block_index, ptr->offset);
-   } else {
-      /* If we don't have an offset or block index, then we must be a pointer
-       * to the variable itself.
+   if (!ptr->offset || !ptr->block_index) {
+      /* If we don't have an offset then we must be a pointer to the variable
+       * itself.
        */
       assert(!ptr->offset && !ptr->block_index);
 
@@ -1506,9 +1504,14 @@ vtn_pointer_to_ssa(struct vtn_builder *b, struct vtn_pointer *ptr)
        */
       assert(ptr->var && ptr->var->type->base_type == vtn_base_type_struct);
 
-      return nir_vec2(&b->nb, vtn_variable_resource_index(b, ptr->var, NULL),
-                              nir_imm_int(&b->nb, 0));
+      struct vtn_access_chain chain = {
+         .length = 0,
+      };
+      ptr = vtn_ssa_offset_pointer_dereference(b, ptr, &chain);
    }
+
+   assert(ptr->offset && ptr->block_index);
+   return nir_vec2(&b->nb, ptr->block_index, ptr->offset);
 }
 
 struct vtn_pointer *
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list