[Mesa-dev] [PATCH 14/32] glsl: Add a predicate to determine whether a variable is an interface block

Ian Romanick idr at freedesktop.org
Tue Jan 22 00:52:05 PST 2013


From: Ian Romanick <ian.d.romanick at intel.com>

For the first declaration below, there will be an ir_variable named
"instance" whose type and whose instance_type will be the same
glsl_type.  For the second declaration, there will be an ir_variable
named "f" whose type is float and whose instance_type is B2.

"instance" is an interface instance variable, but "f" is not.

uniform B1 {
    float f;
} instance;

uniform B2 {
    float f;
};

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/ir.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 49c5f8d..a776f49 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -355,6 +355,14 @@ public:
       return this->mode == ir_var_uniform && this->interface_type != NULL;
    }
 
+   inline bool is_interface_instance() const
+   {
+      const glsl_type *const t = this->type;
+
+      return (t == this->interface_type)
+         || (t->is_array() && t->fields.array == this->interface_type);
+    }
+
    /**
     * Declared type of the variable
     */
-- 
1.7.11.7



More information about the mesa-dev mailing list