glslang icon indicating copy to clipboard operation
glslang copied to clipboard

Linking multiple tese shaders with single layout, complains of contradictory layouts

Open amalon opened this issue 8 months ago • 0 comments

If multiple tessellation evaluation shaders are linked, where only one contains a layout qualifier, glslangValidator reports errors.

For example, if test.tese contains:

#version 460 core

layout (quads, fractional_odd_spacing, ccw) in;

// lib.glsl
vec4 foo();

void main()
{
    gl_Position = foo();
}

and lib.glsl contains:

#version 460 core

vec4 foo()
{
    return vec4(1.0);
}

Then:

$ glslangValidator -l -S tese test.tese lib.glsl
test.tese
lib.glsl
ERROR: Linking tessellation evaluation stage: Contradictory input vertex spacing
ERROR: Linking tessellation evaluation stage: Contradictory triangle ordering

If the layout qualifier is added to lib.glsl, the error goes away.

The glslang 4.6 spec says:

Any or all of these identifiers may be specified one or more times in a single input layout declaration. If primitive mode, vertex spacing, or ordering is declared more than once in the tessellation evaluation shaders of a program, all such declarations must use the same identifier.

At least one tessellation evaluation shader (compilation unit) in a program must declare a primitive mode in its input layout. Declaring vertex spacing, ordering, or point mode identifiers is optional. It is not required that all tessellation evaluation shaders in a program declare a primitive mode. If spacing or vertex ordering declarations are omitted, the tessellation primitive generator will use equal spacing or counter-clockwise vertex ordering, respectively. If a point mode declaration is omitted, the tessellation primitive generator will produce lines or triangles according to the primitive mode.

That doesn't specify that every single tese shader should have the layout qualifier, only that they should match if they have them, and in fact that would be an significant issue for shader stage agnostic library code to have to have the layout qualifier.

amalon avatar Apr 02 '25 20:04 amalon