Bug 97804 - Later precision statement isn't overriding earlier one
Summary: Later precision statement isn't overriding earlier one
Status: VERIFIED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-14 11:21 UTC by Eero Tamminen
Modified: 2016-10-27 10:37 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Glmark2-es2 Jellyfish shader_test triggering the bug (2.86 KB, text/plain)
2016-09-14 11:21 UTC, Eero Tamminen
Details

Note You need to log in before you can comment on or make changes to this 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:
https://www.khronos.org/registry/gles/specs/3.2/GLSL_ES_Specification_3.20.pdf

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:
  https://www.opengl.org/registry/doc/GLSLangSpec.4.50.pdf

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:

https://lists.freedesktop.org/archives/piglit/2016-October/021103.html

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

https://lists.freedesktop.org/archives/mesa-dev/2016-October/132772.html
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.