Bug 107842 - "invariant" qualifier on outputs of GLSL ES fragment shader causes compilation error.
Summary: "invariant" qualifier on outputs of GLSL ES fragment shader causes compilatio...
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Danylo
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-05 13:48 UTC by Danylo
Modified: 2019-01-11 08:43 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Danylo 2018-09-05 13:48:41 UTC
For example fragment shader containing:

 invariant gl_FragColor;

Or:

 invariant out highp vec4 test;

Causes similar error:

 error: `gl_FragColor' cannot be marked invariant; interfaces between shader stages only.

However in all GLSL ES specs there is no restriction on usage of "invariant" with output variables in fragment shader.

 From Section 4.6.1 ("The Invariant Qualifier") GLSL ES 1.00 spec:
 "Only the following variables may be declared as invariant:
   ...
   - Built-in special variables output from the fragment shader."

 From Section 4.6.1 ("The Invariant Qualifier") GLSL ES 3.00 spec:
 "Only variables output from a shader can be candidates for invariance."
Comment 1 Danylo 2018-09-06 11:26:24 UTC
I've sent a small patch to Mesa - https://patchwork.freedesktop.org/patch/247340/

Also I want to add Piglit tests but got confused where to place them:

There are glsl-es-1.00/compiler tests where I can add folder with tests for "invariant" qualifier, however there are tests similar to what I want in glslparsertest/glsl2 but they are seem to be created for desktop GL. 

Is there a way to test "invariant" qualifier without creating duplicate tests for GL ES?
Comment 2 Dylan Baker 2018-09-06 16:56:37 UTC
There was some question at one point as to whether invariant could be implemented as spec'd and I have no idea if that was ever resolved. Curro was looking into it and I've cc'd him.
Comment 3 Danylo 2018-09-07 08:41:50 UTC
The issue I have reported and made the patch for seems to be just a small oversight in code.

In Desktop GL (in certain versions) it is allowed to have outputs from fragment shader as invariant and it works in Mesa; in GL ES it is always allowed as mentioned in cited spec but in Mesa the check for the version in which it is allowed didn't take into account GL ES. So from my pov this issue is a trivial one, on the other hand there is a more tricky bug https://bugs.freedesktop.org/show_bug.cgi?id=100316 which I attempted to fix.
Comment 4 Dylan Baker 2018-09-07 16:43:07 UTC
I was mis-remembering, it was "volatile" not "invariant" that was broken by design. sorry for the confusion.

The only way you can avoid that kind of duplication (as of this moment):
1) write a C test that is compiled multiple times, once for each API you want to test
2) use a python generator to create the tests.
Comment 5 Timothy Arceri 2019-01-11 02:04:53 UTC
Fixed by:

commit a2db6b4254462c62fe60dcc62645da6901986690
Author: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
Date:   Wed Sep 5 15:26:48 2018 +0300

    glsl: Make invariant outputs in ES fragment shader not to cause error
    
    In all GLSL ES versions output variables in fragment shader are allowed
    to be invariant.
    
     From Section 4.6.1 ("The Invariant Qualifier") GLSL ES 1.00 spec:
     "Only the following variables may be declared as invariant:
       ...
       - Built-in special variables output from the fragment shader."
    
     From Section 4.6.1 ("The Invariant Qualifier") GLSL ES 3.00 spec:
     "Only variables output from a shader can be candidates for invariance."
    
    Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107842
Comment 6 Sergii Romantsov 2019-01-11 08:43:01 UTC
Piglit-test:

commit 41b01e6b8c4a8e4c8949a13743125458100ff152
Author: Danylo Piliaiev <danylo.piliaiev@gmail.com>
Date:   Thu Jan 10 12:13:52 2019 +0200

    Test that ES frag shader with invariant outputs compiles
    
    In all GLSL ES versions output variables in fragment shader are allowed
    to be invariant.
    
     From Section 4.6.1 ("The Invariant Qualifier") GLSL ES 1.00 spec:
     "Only the following variables may be declared as invariant:
       ...
       - Built-in special variables output from the fragment shader."
    
     From Section 4.6.1 ("The Invariant Qualifier") GLSL ES 3.00 spec:
     "Only variables output from a shader can be candidates for invariance."
    
    v2: moved new tests to tests/spec/glsl-es folders
    
    Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
    Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107842


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.