glslang
glslang copied to clipboard
gl_FragDepth redeclaration only needed if there are a static assignment
Using the following shaders:
01.frag:
#version 450
layout(depth_less) out float gl_FragDepth;
void foo();
void main()
{
gl_FragDepth = gl_FragCoord.z;
foo();
}
02.frag:
#version 450
/* this shader contains no static write to gl_FragDepth,
* so need not redeclare it
*/
out vec4 color;
void foo()
{
color = vec4(1);
}
And executing glslang as:
$glslangValidator -G --aml --amb /tmp/01.frag /tmp/02.frag
It throws the following error:
ERROR: Linking fragment stage: Contradictory depth layouts
It throws the error as the second fragment stage doesn't redeclare it with the previous depth layout. But as the comment say, from GLSL 4.6 spec, section 4.4.2 "Ouput Layout Qualifiers", "Fragment Outputs":
If gl_FragDepth is redeclared in any fragment shader in a program, it must be redeclared in all fragment shaders in that program that have static assignments to gl_FragDepth
That redeclaration is only needed if gl_FragDepth is assigned on the shader.
Hey, ran into this issue. Seeing this is an open issue, Can I work on it?
Go for it, patches are most welcome.