From: Jason Ekstrand Date: Thu, 21 Jan 2016 18:58:03 +0000 (-0800) Subject: nir/spirv: Make vectors a proper array time with an array_element X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7e5e64c8a9612de307ae6d17c94853f6106626d6;p=mesa.git nir/spirv: Make vectors a proper array time with an array_element This makes dealing with single-component derefs easier --- diff --git a/src/glsl/nir/spirv/spirv_to_nir.c b/src/glsl/nir/spirv/spirv_to_nir.c index 7d8699b1c00..7d9d0981269 100644 --- a/src/glsl/nir/spirv/spirv_to_nir.c +++ b/src/glsl/nir/spirv/spirv_to_nir.c @@ -394,21 +394,17 @@ vtn_type_copy(struct vtn_builder *b, struct vtn_type *src) if (src->is_builtin) dest->builtin = src->builtin; - if (!glsl_type_is_vector_or_scalar(src->type)) { + if (!glsl_type_is_scalar(src->type)) { switch (glsl_get_base_type(src->type)) { - case GLSL_TYPE_ARRAY: - dest->array_element = src->array_element; - dest->stride = src->stride; - break; - case GLSL_TYPE_INT: case GLSL_TYPE_UINT: case GLSL_TYPE_BOOL: case GLSL_TYPE_FLOAT: case GLSL_TYPE_DOUBLE: - /* matrices */ + case GLSL_TYPE_ARRAY: dest->row_major = src->row_major; dest->stride = src->stride; + dest->array_element = src->array_element; break; case GLSL_TYPE_STRUCT: { diff --git a/src/glsl/nir/spirv/vtn_variables.c b/src/glsl/nir/spirv/vtn_variables.c index d41f5cd3dec..edd2263b167 100644 --- a/src/glsl/nir/spirv/vtn_variables.c +++ b/src/glsl/nir/spirv/vtn_variables.c @@ -101,16 +101,9 @@ vtn_access_chain_to_deref(struct vtn_builder *b, struct vtn_access_chain *chain) case GLSL_TYPE_DOUBLE: case GLSL_TYPE_BOOL: case GLSL_TYPE_ARRAY: { - nir_deref_array *deref_arr = nir_deref_array_create(b); - if (base_type == GLSL_TYPE_ARRAY || - glsl_type_is_matrix(deref_type->type)) { - deref_type = deref_type->array_element; - } else { - assert(glsl_type_is_vector(deref_type->type)); - deref_type = ralloc(b, struct vtn_type); - deref_type->type = glsl_scalar_type(base_type); - } + deref_type = deref_type->array_element; + nir_deref_array *deref_arr = nir_deref_array_create(b); deref_arr->deref.type = deref_type->type; if (chain->link[i].mode == vtn_access_mode_literal) { @@ -350,14 +343,7 @@ vtn_access_chain_to_offset(struct vtn_builder *b, vtn_access_link_as_ssa(b, chain->link[idx], type->stride)); - if (glsl_type_is_vector(type->type)) { - /* This had better be the tail */ - assert(idx == chain->length - 1); - type = rzalloc(b, struct vtn_type); - type->type = glsl_scalar_type(base_type); - } else { - type = type->array_element; - } + type = type->array_element; break; case GLSL_TYPE_STRUCT: {