#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.
Using the following shaders:
01.frag:
02.frag:
And executing glslang as:
$glslangValidator -G --aml --amb /tmp/01.frag /tmp/02.frag
It throws the following error:
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":
That redeclaration is only needed if gl_FragDepth is assigned on the shader.