diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-05-02 16:12:07 -0700 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-05-20 10:53:38 -0700 |
commit | f9336751bc0c0977b26a58faa13ce37fd0bd5b08 (patch) | |
tree | 46fc1be0441c2f37135aaf25d7e8e7faa1b0bc9d /src | |
parent | 8af9de0a38ff9ed2e50a9ad05a3e21551f211f0b (diff) |
spirv: Add and use vtn_type_without_array() helper
v2: Renamed from vtn_interface_type. (Jason)
Accept any type not only pointers.
Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 8 | ||||
-rw-r--r-- | src/compiler/spirv/vtn_private.h | 2 | ||||
-rw-r--r-- | src/compiler/spirv/vtn_variables.c | 13 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 8bfc38cd6a3..7072f8a3fc3 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -648,6 +648,14 @@ vtn_types_compatible(struct vtn_builder *b, vtn_fail("Invalid base type"); } +struct vtn_type * +vtn_type_without_array(struct vtn_type *type) +{ + while (type->base_type == vtn_base_type_array) + type = type->array_element; + return type; +} + /* does a shallow copy of a vtn_type */ static struct vtn_type * diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index faaf94a40b1..9fb508734a2 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -396,6 +396,8 @@ bool vtn_type_contains_block(struct vtn_builder *b, struct vtn_type *type); bool vtn_types_compatible(struct vtn_builder *b, struct vtn_type *t1, struct vtn_type *t2); +struct vtn_type *vtn_type_without_array(struct vtn_type *type); + struct vtn_variable; enum vtn_access_mode { diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 1ddac6c4c1c..bc6b0ebedcc 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1864,14 +1864,13 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa, { vtn_assert(ptr_type->base_type == vtn_base_type_pointer); - struct vtn_type *interface_type = ptr_type->deref; - while (interface_type->base_type == vtn_base_type_array) - interface_type = interface_type->array_element; - struct vtn_pointer *ptr = rzalloc(b, struct vtn_pointer); + struct vtn_type *without_array = + vtn_type_without_array(ptr_type->deref); + nir_variable_mode nir_mode; ptr->mode = vtn_storage_class_to_mode(b, ptr_type->storage_class, - interface_type, &nir_mode); + without_array, &nir_mode); ptr->type = ptr_type->deref; ptr->ptr_type = ptr_type; @@ -2009,9 +2008,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, vtn_assert(ptr_type->base_type == vtn_base_type_pointer); struct vtn_type *type = ptr_type->deref; - struct vtn_type *without_array = type; - while(glsl_type_is_array(without_array->type)) - without_array = without_array->array_element; + struct vtn_type *without_array = vtn_type_without_array(ptr_type->deref); enum vtn_variable_mode mode; nir_variable_mode nir_mode; |