[Mesa-dev] [PATCH v3 2/6] spirv: Store the id of the type in vtn_type

Jason Ekstrand jason at jlekstrand.net
Thu Jan 4 01:34:21 UTC 2018


Previously, we were storing a pointer to the vtn_value because we use it
to look up decorations when we create input/output variables.  This
works, but it also may be useful to have the id itself so we may as well
store that instead.
---
 src/compiler/spirv/spirv_to_nir.c  | 2 +-
 src/compiler/spirv/vtn_private.h   | 4 ++--
 src/compiler/spirv/vtn_variables.c | 7 +++++--
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 66ea267..89e9286 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -928,7 +928,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
    struct vtn_value *val = vtn_push_value(b, w[1], vtn_value_type_type);
 
    val->type = rzalloc(b, struct vtn_type);
-   val->type->val = val;
+   val->type->id = w[1];
 
    switch (opcode) {
    case SpvOpTypeVoid:
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 374643a..f27ef8e 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -274,8 +274,8 @@ struct vtn_type {
 
    const struct glsl_type *type;
 
-   /* The value that declares this type.  Used for finding decorations */
-   struct vtn_value *val;
+   /* The SPIR-V id of the given type. */
+   uint32_t id;
 
    /* Specifies the length of complex types.
     *
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index d69b056..2b3b340 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1793,7 +1793,8 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
       vtn_foreach_decoration(b, val, var_is_patch_cb, &var->patch);
       if (glsl_type_is_array(var->type->type) &&
           glsl_type_is_struct(without_array->type)) {
-         vtn_foreach_decoration(b, without_array->val,
+         vtn_foreach_decoration(b, vtn_value(b, without_array->id,
+                                             vtn_value_type_type),
                                 var_is_patch_cb, &var->patch);
       }
 
@@ -1849,7 +1850,9 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
       /* For inputs and outputs, we need to grab locations and builtin
        * information from the interface type.
        */
-      vtn_foreach_decoration(b, interface_type->val, var_decoration_cb, var);
+      vtn_foreach_decoration(b, vtn_value(b, interface_type->id,
+                                          vtn_value_type_type),
+                             var_decoration_cb, var);
       break;
    }
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list