spirv: Store the id of the type in vtn_type
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 3 Jan 2018 16:41:42 +0000 (08:41 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 8 Jan 2018 22:57:44 +0000 (14:57 -0800)
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.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c

index 7a4b52f4fde8d86526cdc759abea93edc00626b6..09aea54ed3913279e56d38cd28c5a18c82c9f0d4 100644 (file)
@@ -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:
index 374643a7a84db702b9853440bb85e3aed29bb32b..f27ef8e3efffc6efceff8e33e767404428287bc5 100644 (file)
@@ -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.
     *
index d69b0562ed6e441363e98ab5c76732b6bb60401d..2b3b3405e4de8c0d77ffb88496729b4a8517b355 100644 (file)
@@ -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;
    }