GLSL icon indicating copy to clipboard operation
GLSL copied to clipboard

Possible ambiguity with continuations and #version

Open dj2 opened this issue 2 months ago • 0 comments

In the GLSL 4.60 spec it states:

Lines separated by the line-continuation character preceding a new-line are concatenated together before either comment processing or preprocessing.

The #version is processed as part of the preprocessing stage, which means I should be able to do:

#ver\
sion 460

This leads to the issue that continuations were not available before 4.20, so, we don't know we should process the continuation until we've parsed the version, but we can't parse the version until we've satisfied the continuation.

For context, GLSLang errors given the shader:

#ver\
sion 420

int main() {}

with:

ERROR: #version: compute shaders require es profile with version 310 or above, or non-es profile with version 420 or above
ERROR: #version: statement must appear first in es-profile shader; before comments or newlines
ERROR: out/ver.comp.glsl:2: '#version' : must occur first in shader 
ERROR: out/ver.comp.glsl:2: '#version' : bad profile name; use es, core, or compatibility 
ERROR: out/ver.comp.glsl:2: '#version' : bad tokens following profile -- expected newline 
ERROR: 4 compilation errors.  No code generated.

dj2 avatar Oct 19 '25 16:10 dj2