nir: Handle array-deref-of-vector case in loop analysis
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 22 Mar 2019 03:37:12 +0000 (20:37 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 22 Mar 2019 20:50:39 +0000 (13:50 -0700)
SPIR-V can produce those for SSBO and UBO access.  Found when testing
the ARB_gl_spirv series.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/nir/nir_loop_analyze.c

index cb71a55f2f177050e73ba0525ed291d80f3b75f6..781dac27bb7188d9ad3e53daee077f8acd17aa30 100644 (file)
@@ -480,9 +480,12 @@ find_array_access_via_induction(loop_info_state *state,
          *array_index_out = array_index;
 
       nir_deref_instr *parent = nir_deref_instr_parent(d);
-      assert(glsl_type_is_array_or_matrix(parent->type));
-
-      return glsl_get_length(parent->type);
+      if (glsl_type_is_array_or_matrix(parent->type)) {
+         return glsl_get_length(parent->type);
+      } else {
+         assert(glsl_type_is_vector(parent->type));
+         return glsl_get_vector_elements(parent->type);
+      }
    }
 
    return 0;