Bug 88815 - Incorrect handling of GLSL #line directive
Summary: Incorrect handling of GLSL #line directive
Status: NEW
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: 10.1
Hardware: Other All
: medium normal
Assignee: Ian Romanick
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-27 00:17 UTC by Will
Modified: 2015-12-18 21:43 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Will 2015-01-27 00:17:48 UTC
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 number `line` and source string
> number `source-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!
Comment 1 Antia Puentes 2015-03-23 09:00:29 UTC
Patches sent to mesa-dev mailing list:

glsl: Update the #line behaviour on GLSL 3.30+ and GLSL ES+
http://lists.freedesktop.org/archives/mesa-dev/2015-March/080286.html

glsl: respect the source number set by #line <line> <source>
http://lists.freedesktop.org/archives/mesa-dev/2015-March/080287.html
Comment 2 Matt Turner 2015-12-18 21:43:46 UTC
(In reply to Antia Puentes from comment #1)
> Patches sent to mesa-dev mailing list:
> 
> glsl: Update the #line behaviour on GLSL 3.30+ and GLSL ES+
> http://lists.freedesktop.org/archives/mesa-dev/2015-March/080286.html

commit 490621f0f2814ff1713c74f030acaff3f19cf8fb
Author: Antia Puentes <apuentes@igalia.com>
Date:   Tue Mar 17 19:12:23 2015 +0100

    glsl: Update the #line behaviour on GLSL 3.30+ and GLSL ES+

> glsl: respect the source number set by #line <line> <source>
> http://lists.freedesktop.org/archives/mesa-dev/2015-March/080287.html

commit c0a7014601ca93d30ba9bf1ec3c6d04da904d503
Author: Antia Puentes <apuentes@igalia.com>
Date:   Tue Mar 17 19:28:25 2015 +0100

    glsl: respect the source number set by #line <line> <source>


But presumably there's still more to be done for this bug.


bug/show.html.tmpl processed on Jan 18, 2017 at 04:06:35.
(provided by the Example extension).