Mesa (master): spirv: Only split blocks

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 22 16:43:34 UTC 2019


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

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed Jan 16 11:52:03 2019 -0600

spirv: Only split blocks

Instead of splitting every per-vertex struct, just split the ones that
are actually blocks.  The reason for the split is so that we have
separate variables for separate locations, qualifiers, and builtin
decorations.  The vulkan spec only allows these on members of blocks.

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>

---

 src/compiler/spirv/vtn_variables.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index b6a5880090..37dfcf1fec 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1626,8 +1626,12 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
    } else {
       if (vtn_var->var) {
          if (vtn_var->var->num_members == 0) {
-            assert(member == -1);
-            apply_var_decoration(b, &vtn_var->var->data, dec);
+            /* We call this function on types as well as variables and not all
+             * struct types get split so we can end up having stray member
+             * decorations; just ignore them.
+             */
+            if (member == -1)
+               apply_var_decoration(b, &vtn_var->var->data, dec);
          } else if (member >= 0) {
             /* Member decorations must come from a type */
             assert(val->value_type == vtn_value_type_type);
@@ -2040,7 +2044,8 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
       var->var->data.mode = nir_mode;
       var->var->data.patch = var->patch;
 
-      if (glsl_type_is_struct(interface_type->type)) {
+      if (interface_type->base_type == vtn_base_type_struct &&
+          interface_type->block) {
          /* It's a struct.  Set it up as per-member. */
          var->var->num_members = glsl_get_length(interface_type->type);
          var->var->members = rzalloc_array(var->var, struct nir_variable_data,




More information about the mesa-commit mailing list