Module: Mesa
Branch: master
Commit: f0f2ec4d8a50c79c2943ac95eb790fb734d88980
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f0f2ec4d8a50c79c2943ac95eb790fb734d88980

Author: Chad Versace <chad.vers...@intel.com>
Date:   Tue Dec  7 10:35:36 2010 -0800

glsl: In ast_to_hir, check sampler array indexing

Raise error if a sampler array is indexed with a non-constant expression.

>From section 4.1.7 of the GLSL 1.30 spec:
  "Samplers aggregated into arrays within a shader (using square
  brackets [ ]) can only be indexed with integral constant
  expressions [...]."

---

 src/glsl/ast_to_hir.cpp |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 82b3f2e..1f4972c 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1567,6 +1567,20 @@ ast_expression::hir(exec_list *instructions,
         }
       }
 
+      /* From section 4.1.7 of the GLSL 1.30 spec:
+       *    "Samplers aggregated into arrays within a shader (using square
+       *    brackets [ ]) can only be indexed with integral constant
+       *    expressions [...]."
+       */
+      if (array->type->is_array() &&
+          array->type->element_type()->is_sampler() &&
+          const_index == NULL) {
+
+         _mesa_glsl_error(&loc, state, "sampler arrays can only be indexed "
+                          "with constant expressions");
+         error_emitted = true;
+      }
+
       if (error_emitted)
         result->type = glsl_type::error_type;
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to