[Mesa-dev] [PATCH 41/46] glsl: allow indexing of gl_out with a non-const if length isn't known

Marek Olšák maraeo at gmail.com
Tue Jun 16 16:01:37 PDT 2015


From: Marek Olšák <marek.olsak at amd.com>

---
 src/glsl/ast_array_index.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/glsl/ast_array_index.cpp b/src/glsl/ast_array_index.cpp
index 0130c14..0b6b5c7 100644
--- a/src/glsl/ast_array_index.cpp
+++ b/src/glsl/ast_array_index.cpp
@@ -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");
          }
-- 
2.1.0



More information about the mesa-dev mailing list