[Mesa-dev] [PATCH 06/10] glsl: add MAX_NUM_STATE_SLOTS and check against builtin uniform variables

Tapani Pälli tapani.palli at intel.com
Wed Jan 29 01:25:01 PST 2014


Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 src/glsl/builtin_variables.cpp | 3 +++
 src/mesa/main/config.h         | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index d6bc3c0..3e660af 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -494,6 +494,9 @@ builtin_variable_generator::add_uniform(const glsl_type *type,
 
    uni->state_slots = slots;
 
+   /* see main/config.h */
+   assert(uni->num_state_slots <= MAX_NUM_STATE_SLOTS);
+
    for (unsigned a = 0; a < array_count; a++) {
       for (unsigned j = 0; j < statevar->num_elements; j++) {
 	 struct gl_builtin_uniform_element *element = &statevar->elements[j];
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 0c1782a..03fd9b3 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -290,5 +290,9 @@
  */
 #define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
 
+/**
+ * Maximum number of builtin state backing up a uniform variable.
+ */
+#define MAX_NUM_STATE_SLOTS 96
 
 #endif /* MESA_CONFIG_H_INCLUDED */
-- 
1.8.5.3



More information about the mesa-dev mailing list