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 <ian.d.romanick@intel.com>
Reviewed-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -357,6 +357,33 @@ public:
|
||||
return this->mode == ir_var_uniform && this->interface_type != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user