KhronosGroup/WebGL

Clarify VS/FS fragment shader matching with anonymous struct varying

Opened this issue · 0 comments

Clarify how are the output or input variables variables matched when the variable declaration contains possibly anonymous struct.

The type of vertex outputs and fragment inputs with the same name must match, otherwise the link
command will fail. The precision does not need to match. Only those fragment inputs statically used (i.e.
read) in the fragment shader must be declared as outputs in the vertex shader; declaring superfluous vertex
shader outputs is permissible.

https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf

Two unnamed structs

// VS
out struct { float field; } s0;

// FS
in struct { float field; } s0;

Two named structs with the same name

// VS
out struct T { float field; } s0;

// FS
in struct T { float field; } s0;

One unnamed struct and one named struct

// VS
out struct T { float field; } s0;

// FS
in struct { float field; } s0;

Two named structs with different struct names

// VS
out struct T { float field; } s0;

// FS
in struct Q { float field; } s0;

Anonymous struct matched to two distinct anonymous structs at the other side

// VS
out struct { float field; } s0, s1;

// FS
in struct { float field; } s0;
in struct { float field; } s1;