glsl: Require that all image uniforms have a format qualifier in GLSL ES.

Note that this is slightly more permissive than the spec language
requires: "Any image variable must specify a format layout qualifier."

The GLSL ES spec seems really sketchy regarding format layout
qualifiers on function formal parameters -- On the one hand they are
required, but on the other hand it doesn't provide any syntax to
specify them (see section 6.1.1), they don't participate in parameter
type matching for overload resolution, and are in fact explictly
forbidden ("Layout qualifiers cannot be used on formal function
parameters").  Of course none of the image built-in functions defined
by the spec specify format layout qualifiers (and they probably
couldn't sensibly), to contradict its own requirement.

This probably qualifies for a spec bug, but in the meantime do the
sensible thing and require layout qualifiers on uniforms *only*.

Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au>
This commit is contained in:
Francisco Jerez 2015-08-17 01:26:40 +03:00
parent 241774aa03
commit 527ae5d428

View file

@ -2455,10 +2455,16 @@ apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
var->data.image_format = qual->image_format;
} else {
if (var->data.mode == ir_var_uniform && !qual->flags.q.write_only) {
_mesa_glsl_error(loc, state, "uniforms not qualified with "
"`writeonly' must have a format layout "
"qualifier");
if (var->data.mode == ir_var_uniform) {
if (state->es_shader) {
_mesa_glsl_error(loc, state, "all image uniforms "
"must have a format layout qualifier");
} else if (!qual->flags.q.write_only) {
_mesa_glsl_error(loc, state, "image uniforms not qualified with "
"`writeonly' must have a format layout "
"qualifier");
}
}
var->data.image_format = GL_NONE;