nir/spirv: Make vectors a proper array time with an array_element
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 21 Jan 2016 18:58:03 +0000 (10:58 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 22 Jan 2016 00:20:39 +0000 (16:20 -0800)
This makes dealing with single-component derefs easier

src/glsl/nir/spirv/spirv_to_nir.c
src/glsl/nir/spirv/vtn_variables.c

index 7d8699b1c00594a337f7f17eb59f374aab9e72f3..7d9d0981269419479e938863f6c692ca361a3a31 100644 (file)
@@ -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: {
index d41f5cd3deca5739a54a255c9d9b13f2de8e2149..edd2263b167c8bf402f2b1b52bf84919d448de8a 100644 (file)
@@ -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: {