Incorrect handling of GLSL #line directive
Submitted by Will
Assigned to Ian Romanick
Description
Hey all, I've noticed a bug in Mesa's treatment of the #line directive in GLSL 3.3+.
The 3.3 spec changed the line number set by #line to be the line number for the following line of source (pg 11 GLSL 3.3 spec):
#line `line`
#line `line` `source-string-number`
After processing this directive (including its new-line), the implementation
will behave as if it is compiling at line numberline
and source string numbersource-string-number
. Subsequent source strings will be numbered sequentially, until another #line directive overrides that numbering.
So for a shader with some silly error in it:
#version 330 core
#line 1 4
not_valid vec4 thingy_error;
#line 1 0
layout(location = 0) in vec4 pos;
void main(void){
gl_Position = pos;
}
We'd expect the error to specify something about the incorrect identifier/token w/e on line 1 of source string 4, however Mesa's compilation log contains the following:
0:2(1): error: syntax error, unexpected NEW_IDENTIFIER
From some other shader compilers it seems like the first number refers to the source string number, which should be 4 here. The compiler also seems to be using the GLSL 1.5 line directive where the following line is line number line
+ 1.
Nvidia's compiler gives the expected source string number and line number:
4(1) : warning C7022: unrecognized profile specifier "not_valid" 4(1) : error C0502: syntax error at token "not_valid"
Information about my Mesa & GL version:
OpenGL Version: 3.3 (Core Profile) Mesa 10.1.3 OpenGL Vendor: Intel Open Source Technology Center OpenGL Renderer: Mesa DRI Intel(R) Ivybridge Mobile GLSL Version: 3.30
Thanks!
Version: 10.1