nir/locals_to_regs: Hanadle indirect accesses of length-1 arrays
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 11 Apr 2015 00:38:17 +0000 (17:38 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 23 Apr 2015 01:10:41 +0000 (18:10 -0700)
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/glsl/nir/nir_lower_locals_to_regs.c

index 48459f7..bc6a3d3 100644 (file)
@@ -135,6 +135,14 @@ get_deref_reg_src(nir_deref_var *deref, nir_instr *instr,
    src.reg.base_offset = 0;
    src.reg.indirect = NULL;
 
+   /* It is possible for a user to create a shader that has an array with a
+    * single element and then proceed to access it indirectly.  Indirectly
+    * accessing a non-array register is not allowed in NIR.  In order to
+    * handle this case we just convert it to a direct reference.
+    */
+   if (src.reg.reg->num_array_elems == 0)
+      return src;
+
    nir_deref *tail = &deref->deref;
    while (tail->child != NULL) {
       const struct glsl_type *parent_type = tail->type;