diff options
author | Francisco Jerez <currojerez@riseup.net> | 2013-09-20 14:58:03 -0700 |
---|---|---|
committer | Francisco Jerez <currojerez@riseup.net> | 2013-10-29 12:40:55 -0700 |
commit | cc744a0947e619a4350551f5e9d5e380ac8d9e23 (patch) | |
tree | cecfc057f2e902860d770935396a1352f091bc43 /src/glsl/glsl_types.cpp | |
parent | 26db3b933f7fbc81d6c2bead2a8b0479a3691424 (diff) |
glsl: Add type predicate to check whether a type contains any opaque types.
And use it to forbid comparisons of opaque operands. According to the
GL 4.2 specification:
> Except for array indexing, structure member selection, and
> parentheses, opaque variables are not allowed to be operands in
> expressions.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/glsl_types.cpp')
-rw-r--r-- | src/glsl/glsl_types.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 281e6902e85..f740130968c 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -168,6 +168,24 @@ glsl_type::contains_integer() const } } +bool +glsl_type::contains_opaque() const { + switch (base_type) { + case GLSL_TYPE_SAMPLER: + case GLSL_TYPE_ATOMIC_UINT: + return true; + case GLSL_TYPE_ARRAY: + return element_type()->contains_opaque(); + case GLSL_TYPE_STRUCT: + for (unsigned int i = 0; i < length; i++) { + if (fields.structure[i].type->contains_opaque()) + return true; + } + return false; + default: + return false; + } +} gl_texture_index glsl_type::sampler_index() const |