KhronosGroup/WebGL

Clarify double underscore in varyings

Opened this issue · 1 comments

In addition, all identifiers containing two consecutive underscores (__) are reserved for use by underlying software layers. Defining such a name in a shader does not itself result in an error, but may result in unintended behaviors that stem from having multiple definitions of the same name.

consider case

// VS
varying float a__b;
void main()
{
    gl_Position = vec4(...);
    a__b = 0.0;
}

// FS
varying float a__b;
void main()
{
    gl_FragColor = vec4(a__b, 0, 0, 1);
}

Implementations that transform GLSL to C++-like languages (e.g. Metal) likely use the user names somehow in their destination source. If they don't, they'd need to hash interface names.

Metal matches vertex outs to fragment ins with either struct member names or [[user(name)]].

To encourage language quality, we should just require support for this in var names. (and mangle internally to support it if it is problematic)