[Mesa-dev] [PATCH 06/10] glsl: Sanity check max_ifc_array_access in ir_validate::visit(ir_variable *).

Paul Berry stereotype441 at gmail.com
Fri Sep 27 12:05:32 PDT 2013


---
 src/glsl/ir_validate.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 2c64f4e..93bc4d9 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -674,6 +674,26 @@ ir_validate::visit(ir_variable *ir)
       }
    }
 
+   /* If a variable is an interface block (or an array of interface blocks),
+    * verify that the maximum array index for each interface member is in
+    * bounds.
+    */
+   if (ir->is_interface_instance()) {
+      const glsl_struct_field *fields =
+         ir->get_interface_type()->fields.structure;
+      for (int i = 0; i < ir->get_interface_type()->length; i++) {
+         if (fields[i].type->array_size() > 0) {
+            if (ir->max_ifc_array_access[i] >= fields[i].type->length) {
+               printf("ir_variable has maximum access out of bounds for "
+                      "field %s (%d vs %d)\n", fields[i].name,
+                      ir->max_ifc_array_access[i], fields[i].type->length);
+               ir->print();
+               abort();
+            }
+         }
+      }
+   }
+
    if (ir->constant_initializer != NULL && !ir->has_initializer) {
       printf("ir_variable didn't have an initializer, but has a constant "
 	     "initializer value.\n");
-- 
1.8.4



More information about the mesa-dev mailing list