[Mesa-dev] [RFC 07/20] glsl: add MAX_NUM_STATE_SLOTS and check against builtin uniforms

Tapani Pälli tapani.palli at intel.com
Mon Jun 2 05:05:48 PDT 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 9b35850..60b0e38 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -496,6 +496,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++) {
 	 const struct gl_builtin_uniform_element *element =
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index c96502a..b041e96 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -307,5 +307,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.3.1



More information about the mesa-dev mailing list