mirror of
https://gitee.com/openharmony/third_party_mesa3d
synced 2024-11-30 11:00:40 +00:00
glsl: Fix invariant matching in GLSL 4.30 and GLSL ES 1.00.
Old languages (GLSL <= 4.20 and GLSL ES 1.00) require "invariant"
to be specified on both inputs and outputs, and match when linking.
New languages only allow outputs to be qualified as "invariant"
and remove the "invariant must match" restriction when linking
varyings (because no input can have that qualifier).
Commit 426a50e208
introduced the new
behavior for ES 3.00. It also removed the "must match" restriction
for ES 1.00 shaders, which I believe is incorrect. This patch adds
that back, as well as making 4.30+ follow the new rules.
Thanks to Qiankun Miao for noticing this discrepancy.
Fixes a WebGL 2.0 conformance test when run in Chromium:
https://www.khronos.org/registry/webgl/sdk/tests/deqp/data/gles3/shaders/qualification_order.html?webglVersion=2
Cc: mesa-stable@lists.freedesktop.org
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96971
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
This commit is contained in:
parent
0ed316360f
commit
f9f462936a
@ -1774,8 +1774,10 @@ type_qualifier:
|
|||||||
* variables. As only outputs can be declared as invariant, an invariant
|
* variables. As only outputs can be declared as invariant, an invariant
|
||||||
* output from one shader stage will still match an input of a subsequent
|
* output from one shader stage will still match an input of a subsequent
|
||||||
* stage without the input being declared as invariant."
|
* stage without the input being declared as invariant."
|
||||||
|
*
|
||||||
|
* On the desktop side, this text first appears in GLSL 4.30.
|
||||||
*/
|
*/
|
||||||
if (state->es_shader && state->language_version >= 300 && $$.flags.q.in)
|
if (state->is_version(430, 300) && $$.flags.q.in)
|
||||||
_mesa_glsl_error(&@1, state, "invariant qualifiers cannot be used with shader inputs");
|
_mesa_glsl_error(&@1, state, "invariant qualifiers cannot be used with shader inputs");
|
||||||
}
|
}
|
||||||
| interpolation_qualifier type_qualifier
|
| interpolation_qualifier type_qualifier
|
||||||
|
@ -308,7 +308,25 @@ cross_validate_types_and_qualifiers(struct gl_shader_program *prog,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prog->IsES && input->data.invariant != output->data.invariant) {
|
/* The GLSL 4.30 and GLSL ES 3.00 specifications say:
|
||||||
|
*
|
||||||
|
* "As only outputs need be declared with invariant, an output from
|
||||||
|
* one shader stage will still match an input of a subsequent stage
|
||||||
|
* without the input being declared as invariant."
|
||||||
|
*
|
||||||
|
* while GLSL 4.20 says:
|
||||||
|
*
|
||||||
|
* "For variables leaving one shader and coming into another shader,
|
||||||
|
* the invariant keyword has to be used in both shaders, or a link
|
||||||
|
* error will result."
|
||||||
|
*
|
||||||
|
* and GLSL ES 1.00 section 4.6.4 "Invariance and Linking" says:
|
||||||
|
*
|
||||||
|
* "The invariance of varyings that are declared in both the vertex
|
||||||
|
* and fragment shaders must match."
|
||||||
|
*/
|
||||||
|
if (input->data.invariant != output->data.invariant &&
|
||||||
|
prog->Version < (prog->IsES ? 300 : 430)) {
|
||||||
linker_error(prog,
|
linker_error(prog,
|
||||||
"%s shader output `%s' %s invariant qualifier, "
|
"%s shader output `%s' %s invariant qualifier, "
|
||||||
"but %s shader input %s invariant qualifier\n",
|
"but %s shader input %s invariant qualifier\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user