glsl: allow indexing of gl_out with a non-const if length isn't known
authorMarek Olšák <marek.olsak@amd.com>
Tue, 16 Jun 2015 00:43:55 +0000 (02:43 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 22 Jul 2015 22:59:28 +0000 (00:59 +0200)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/ast_array_index.cpp

index 50971bb22bb3ab854753d90553c3065930a53396..27e84d101ecfe9755835cd45cf7113434a0fc100 100644 (file)
@@ -216,6 +216,16 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
             if (v != NULL)
                v->data.max_array_access = implicit_size - 1;
          }
+         else if (state->stage == MESA_SHADER_TESS_CTRL &&
+                  array->variable_referenced()->data.mode == ir_var_shader_out &&
+                  !array->variable_referenced()->data.patch) {
+            /* Tessellation control shader output non-patch arrays are
+             * initially unsized. Despite that, they are allowed to be
+             * indexed with a non-constant expression (typically
+             * "gl_InvocationID"). The array size will be determined
+             * by the linker.
+             */
+         }
          else {
             _mesa_glsl_error(&loc, state, "unsized array index must be constant");
          }