KalebDark / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Add support for ESSL3 invariant declarations #987

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to compile the following shader:
#version 300 es

invariant out float a;

void main() {
    a = 0.0;
    gl_Position = vec4(0.0);
};

What is the expected output? What do you see instead?
Expected: Compilation succeeds
Actual: Compilation fails

The parser needs support for additional syntax under type_qualifier, and the 
AST needs to store types that have both out and invariant qualifiers.

Original issue reported on code.google.com by oetu...@nvidia.com on 28 Apr 2015 at 8:19

GoogleCodeExporter commented 9 years ago
There's one tricky GLSL backend specific issue here when shaders are linked:
-ESSL3.00 doesn't allow shader inputs to be declared as invariant.
-GLSL4.20 and earlier versions require shader inputs to be declared as 
invariant to be successfully linked against invariant outputs.

This means that the GLSL fragment shader source needs to be generated at link 
time to take into account whether the vertex shader outputs linked against it 
are declared as invariant.

Original comment by oetu...@nvidia.com on 28 Apr 2015 at 12:01

GoogleCodeExporter commented 9 years ago
It seems like ESSL3 also contradicts itself on this issue:

-Section 4.6.1 (that the previous comment was based on) says that "As only 
outputs can be declared as invariant, an invariant output from one shader stage 
will still match an input of a subsequent stage without the input being 
declared as invariant."

-Section 4.3.9 says that "The type and presence of the interpolation qualifiers 
and storage qualifiers and invariant qualifiers of variables with the same name 
declared in all linked shaders must match, otherwise the link command will 
fail."

Section 4.6.1 was most recently changed in version 3.00.3 of the spec with 
discussion on the Khronos bug tracker, so it's probably safe to assume that it 
is correct and section 4.3.9 is wrong, being a remnant of an earlier version of 
the spec. The Khronos bug has been reopened to get this eventually cleaned up 
for good.

Original comment by oetu...@nvidia.com on 28 Apr 2015 at 2:03

GoogleCodeExporter commented 9 years ago
Added Ken to this issue - as it may require adding the ability to query the 
shader version from the translator, and adding a new API for linking shaders 
and generating extra code (and knowing when we translate a shader if we need 
the extra step).

Original comment by jmad...@chromium.org on 28 Apr 2015 at 6:59

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Olli Etuaho <oetuaho@nvidia.com>
Commit : 214c2d8e4dd65662e1f6c5821065716e13e82cd6

Code-Review  0 : Jamie Madill, Zhenyao Mo
Code-Review  +2: Olli Etuaho
Verified     0 : Jamie Madill, Zhenyao Mo
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : I0c6629e5ca2ded06db9ac9e5bab2fb6480299a5a
Reviewed-at    : https://chromium-review.googlesource.com/267662

Separate invariance from qualifiers

ESSL3 makes it possible to combine invariant with several more different
qualifiers. To avoid combinatorial explosion of the qualifier enum, track
invariance with a separate boolean.

TEST=WebGL conformance tests, angle_unittests
BUG=angleproject:987

src/compiler/translator/BaseTypes.h
src/compiler/translator/IntermNode.h
src/compiler/translator/OutputGLSLBase.cpp
src/compiler/translator/ParseContext.cpp
src/compiler/translator/ParseContext.h
src/compiler/translator/Types.cpp
src/compiler/translator/Types.h
src/compiler/translator/UtilsHLSL.cpp
src/compiler/translator/VersionGLSL.cpp
src/compiler/translator/glslang.y
src/compiler/translator/glslang_tab.cpp
src/compiler/translator/intermOut.cpp
src/compiler/translator/util.cpp

Original comment by bugdro...@chromium.org on 5 May 2015 at 11:06