Question

My GLSL (OpenGL ES 2.0, "#version 100") shaders fail to compile on a Vivante GC800 GPU. The shaders compile fine on lots of other GPUs.

The error I get is:

(2:0) : error : Expect positive integer-line-number after #line.

I use

#line 0

to reset the line number after including a bunch of preamble code (like #version and some precision specifiers) before the "real" shader. Anyone know if this is a case of the Vivante shader compiler being broken, or of everyone else's shader compiler being too lenient?

My workaround is to only include this directive when debugging my shaders locally.

Was it helpful?

Solution

The GLES Shading Language spec has this to say about the issue (section 3.4 "Preprocessor"):

#line must have, after macro substitution, one of the following two forms:

#line line
#line line source-string-number

where line and source-string-number are constant integer expressions. After processing this directive (including its new-line), the implementation will behave as if the following line has line number line and starts with source string number source-string-number. Subsequent source strings will be numbered sequentially, until another #line directive overrides that numbering.

That would not rule out 0 (or even negative values). However there is also

__LINE__ will substitute a decimal integer constant that is one more than the number of preceding newlines in the current source string.

One could argue that that means that the line number can never be below 1, since that implies a negative number of newlines. YMMV.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top