glsl: prevent qualifiers modification of predeclared variables
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 9 Oct 2018 18:34:15 +0000 (11:34 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 15 Nov 2018 22:27:26 +0000 (14:27 -0800)
commit9b9f3218dbad1079aec6ed90ef8aa1da39f5d6e3
treeb9d48a6ae973a5fc243a099b55e4fbf0207f44ec
parent538bca78e267b1c8cce41d5b4623fafd1e253d82
glsl: prevent qualifiers modification of predeclared variables

Section 3.7 (Identifiers) of the GLSL spec says:

    However, as noted in the specification, there are some cases where
    previously declared variables can be redeclared to change or add
    some property, and predeclared "gl_" names are allowed to be
    redeclared in a shader only for these specific purposes.  More
    generally, it is an error to redeclare a variable, including those
    starting "gl_".

This patch should fix piglit tests:
clip-distance-redeclare-without-inout.frag
clip-distance-redeclare-without-inout.vert

However, this causes a regression in
clip-distance-out-values.shader_test.  A fix for that test has been sent
to the piglit list for review:

    https://patchwork.freedesktop.org/patch/255201/

As far as I understood following mailing thread:
https://lists.freedesktop.org/archives/piglit/2013-October/007935.html
looks like we have accepted to remove an ability to change qualifiers
but have not done it yet. Unless I missed something)

v2 (idr): Move 'earlier->data.mode != var->data.mode' test much earlier
in the function.  Add special handling for gl_LastFragData.

Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/ast_to_hir.cpp