summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir.h
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-01-21 22:18:16 -0500
committerIan Romanick <[email protected]>2013-01-25 09:07:34 -0500
commit23b7ce3a824013c8b4d7340294cb59b0b4cb8f87 (patch)
tree8856b0f90c68618c62ad7dc4735e618bfa5dd805 /src/glsl/ir.h
parent3b09603dda7108f7f7d58c903b15510262f845c0 (diff)
glsl: Add a predicate to determine whether a variable is an interface block
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; }; v2: Copy the comment message documentation into the code. Suggested by Paul Berry. Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Carl Worth <[email protected]> Reviewed-by: Paul Berry <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/ir.h')
-rw-r--r--src/glsl/ir.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index ff47b3a5a80..7d5906d1d4f 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -358,6 +358,33 @@ public:
}
/**
+ * Determine whether or not a variable is the declaration of an interface
+ * block
+ *
+ * For the first declaration below, there will be an \c ir_variable named
+ * "instance" whose type and whose instance_type will be the same
+ * \cglsl_type. For the second declaration, there will be an \c 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;
+ * };
+ */
+ 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
*/
const struct glsl_type *type;