glsl: Forbid non-constant image array indexing in GLSL ES 3.1.
authorFrancisco Jerez <currojerez@riseup.net>
Sun, 16 Aug 2015 22:21:01 +0000 (01:21 +0300)
committerFrancisco Jerez <currojerez@riseup.net>
Thu, 20 Aug 2015 09:26:54 +0000 (12:26 +0300)
Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au>
src/glsl/ast_array_index.cpp

index 27e84d101ecfe9755835cd45cf7113434a0fc100..ae399f03a9b71a9d2558898f62b0aee4f1ea9afe 100644 (file)
@@ -290,6 +290,21 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
                                   "1.30 and later");
          }
       }
+
+      /* From page 27 of the GLSL ES 3.1 specification:
+       *
+       * "When aggregated into arrays within a shader, images can only be
+       *  indexed with a constant integral expression."
+       *
+       * On the other hand the desktop GL specification extension allows
+       * non-constant indexing of image arrays, but behavior is left undefined
+       * in cases where the indexing expression is not dynamically uniform.
+       */
+      if (state->es_shader && array->type->without_array()->is_image()) {
+         _mesa_glsl_error(&loc, state,
+                          "image arrays indexed with non-constant "
+                          "expressions are forbidden in GLSL ES.");
+      }
    }
 
    /* After performing all of the error checking, generate the IR for the