[Mesa-dev] [PATCH 06/16] spirv/nir: tweak nir type when storage class is SpvStorageClassAtomicCounter

Alejandro PiƱeiro apinheiro at igalia.com
Mon Jul 2 14:58:35 UTC 2018


GLSL types differentiates uint from atomic uint. On SPIR-V the type is
uint, and the variable has a specific storage class. So we need to
tweak the type based on the storage class.

Ideally we would like to get the proper type at vtn_handle_type, but
we don't have the storage class at that moment.

We tweak only the nir type, as is the one that really requires it.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
---
 src/compiler/spirv/vtn_variables.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index c56d74d683b..a40c30c8a75 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1643,7 +1643,17 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
       /* For these, we create the variable normally */
       var->var = rzalloc(b->shader, nir_variable);
       var->var->name = ralloc_strdup(var->var, val->name);
-      var->var->type = var->type->type;
+
+      /* Need to tweak the nir type here as at vtn_handle_type we don't have
+       * the access to storage_class, that is the one that points us that is
+       * an atomic uint.
+       */
+      if (glsl_get_base_type(var->type->type) == GLSL_TYPE_UINT &&
+          storage_class == SpvStorageClassAtomicCounter) {
+         var->var->type = glsl_atomic_uint_type();
+      } else {
+         var->var->type = var->type->type;
+      }
       var->var->data.mode = nir_mode;
       var->var->data.location = -1;
       var->var->interface_type = NULL;
-- 
2.14.1



More information about the mesa-dev mailing list