mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-01 22:40:09 +01:00
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>
This commit is contained in:
parent
26db3b933f
commit
cc744a0947
3 changed files with 27 additions and 0 deletions
|
|
@ -1238,6 +1238,10 @@ ast_expression::hir(exec_list *instructions,
|
|||
!state->check_version(120, 300, &loc,
|
||||
"array comparisons forbidden")) {
|
||||
error_emitted = true;
|
||||
} else if ((op[0]->type->contains_opaque() ||
|
||||
op[1]->type->contains_opaque())) {
|
||||
_mesa_glsl_error(&loc, state, "opaque type comparisons forbidden");
|
||||
error_emitted = true;
|
||||
}
|
||||
|
||||
if (error_emitted) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -462,6 +462,11 @@ struct glsl_type {
|
|||
return atomic_size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a type contains any opaque types.
|
||||
*/
|
||||
bool contains_opaque() const;
|
||||
|
||||
/**
|
||||
* Query the full type of a matrix row
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue