Bug 97804

Summary: Later precision statement isn't overriding earlier one
Product: Mesa Reporter: Eero Tamminen <eero.t.tamminen>
Component: glsl-compilerAssignee: mesa-dev
Status: VERIFIED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: lemody
Version: git   
Hardware: Other   
OS: All   
See Also: https://bugs.freedesktop.org/show_bug.cgi?id=97532
i915 platform: i915 features:
Attachments: Glmark2-es2 Jellyfish shader_test triggering the bug

Description Eero Tamminen 2016-09-14 11:21:58 UTC
Created attachment 126514 [details]
Glmark2-es2 Jellyfish shader_test triggering the bug

GLES 3.2 spec:

States following in "4.7.4 Default Precision Qualifiers":
Non-precision qualified declarations will use the precision qualifier specified in the most recent precision statement that is still in scope. The precision statement has the same scoping rules as variable declarations.
*Multiple precision statements for the same basic type can appear inside the same scope, with later statements overriding earlier statements within that scope.*
All languages except for the fragment language have the following predeclared globally scoped default precision statements:
   precision highp float;
The fragment language has no default precision qualifier for floating point types. Hence for float, floating point vector and matrix variable declarations, either the declaration must include a precision qualifier or the default float precision must have been previously declared.

Check for latter was added with bug 60737, but precision overriding doesn't seem to work.

Attached Glmark2 shader test fails to Mesa bug 97532.  Vertex shader float uniform defaults to highp, and same should happen in fragment shader, however, that happens only if the first precision statement in shader is removed, as only then it will pass the linker check.  I.e.  precision overriding doesn't work.
Comment 1 Eero Tamminen 2016-09-15 14:43:29 UTC
GL 4.5 GLSL spec:

Says the same in "4.7.3 Default Precision Qualifiers":
"Multiple precision statements for the same basic type can appear inside the same scope, with later statements overriding earlier statements within that scope."
Comment 2 Samuel Iglesias Gonsálvez 2016-10-20 10:41:52 UTC
I wrote a piglit test that reproduces the failure:


And sent a couple of patches to fix it in Mesa:

Comment 3 Samuel Iglesias Gonsálvez 2016-10-26 10:06:39 UTC
Piglit test and Mesa fix pushed:

commit 0e742926c6895dcaf8bdbe43022c8a0bc74fdd96
Author: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Date:   Fri Oct 21 08:23:59 2016 +0200

    glsl: update default precision qualifier when it is set in the shader
Comment 4 Eero Tamminen 2016-10-27 10:37:42 UTC
Verified.  "glmark2-es2 -b jellyfish" works now, and old versions of terrain & ideas tests fail as expected.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.