Skip to content

Possible ambiguity with continuations and #version #291

@dj2

Description

@dj2

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions