Bug 75664

Summary: Unigine Valley & Heaven "error: syntax error, unexpected EXTENSION, expecting $end" IVB HD4000
Product: Mesa Reporter: commiethebeastie
Component: Drivers/DRI/i965Assignee: Ian Romanick <idr>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: bugs.freedesktop.org, eero.t.tamminen, jianx.zhou, mengmeng.meng, vitalif
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Bug Depends on: 71591    
Bug Blocks:    
Attachments: Unigine Valley log
screenshot

Description commiethebeastie 2014-03-02 09:07:30 UTC
Created attachment 94954 [details]
Unigine Valley log

Intel(R) Core(TM) i7-3537U CPU @ 2.00GHz

00:02.0 VGA compatible controller [0300]: Intel Corporation 3rd Gen Core processor Graphics Controller [8086:0166] (rev 09)

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.2.0-devel (git-fc25956 trusty-oibaf-ppa)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile


GLShader::loadFragment(): error in "core/shaders/default/sky/fragment_volume_ambient.shader" file
defines: INTEL,QUALITY_LOW,QUALITY_MEDIUM,QUALITY_HIGH,MULTISAMPLE_0,USE_INSTANCING,USE_GEOMETRY_SHADER,USE_TEXTURE_3D,USE_TEXTURE_ARRAY,USE_ALPHA_FADE,USE_REFLECTION,USE_OCCLUSION,HAS_DEFERRED_COLOR,HAS_DEFERRED_NORMAL,USE_RGB10A2,USE_ENVIRONMENT,USE_NORMALIZATION,USE_DIRECTIONAL_LIGHTMAPS,USE_SHADOW_KERNEL,OPENGL,HAS_ARB_DRAW_INSTANCED,HAS_ARB_TEXTURE_SNORM,SHADING_LANGUAGE=330,USE_ARB_BLEND_FUNC_EXTENDED,USE_ARB_SHADER_BIT_ENCODING,USE_ARB_SAMPLE_SHADING,,TURBULENCE
0:170(1): error: syntax error, unexpected EXTENSION, expecting $end
Comment 1 commiethebeastie 2014-03-02 09:08:38 UTC
Created attachment 94955 [details]
screenshot
Comment 2 Eero Tamminen 2014-03-03 16:19:07 UTC
There's already a bug 71591 about allowing (some) extension declarations in middle of shader.  After that is allowed (there are Mesa patches for that), both Unigine tests run [1].

However, Valley benchmark is still lacking most of lightning.  That can be worked around by running it with:
MESA_EXTENSION_OVERRIDE="-GL_ARB_blend_func_extended" MESA_GL_VERSION_OVERRIDE=3.2 ./valley

If one specifies some other Mesa version, there are GL enum errors and lightning doesn't work.  Without blend override, there aren't error messages, but lightning doesn't work either, regardless of specif Mesa. I.e. there might be some bug in Mesa GL_ARB_blend_func_extended implementation.


[1] If you don't patch Mesa to allow extension declarations in middle of shaders, you need to add "-GL_ARB_sample_shading" to MESA_EXTENSION_OVERRIDE.
Comment 3 Kenneth Graunke 2014-03-14 03:54:42 UTC
The missing lighting is due to a bug in Unigine's dual source blending code.  They enable two source blending, label both outputs as color 0, and never specify color 1.  We could guess, but we'd have a 50/50 chance of getting it right.  I attempted to report that to Unigine today; we'll see what happens though.
Comment 4 Eero Tamminen 2014-04-11 07:19:46 UTC
In the meanwhile, maybe appropriate workarounds could be added to Mesa drirc also for Valley?


As to other issues with these demos, If I enable MSAA, I get a lot of these warnings from Heaven & Valley:
----------
GLFrameBuffer::enable(): incomplete attachment
GLFrameBuffer::enable(): incomplete attachment
GLFrameBuffer::enable(): incomplete attachment
GLFrameBuffer::enable(): incomplete attachment
GLFrameBuffer::enable(): incomplete attachment
OpenGL error: invalid framebuffer operation
----------

And once:
  UserArray::push(): bad array index 4

On quick look, I don't see a visual problem in the demos though.


Whereas enabling MSAA for Tropics or Sanctuary demo completely breaks them with Mesa.  I get lots of these errors:
-------------
0:165(89): error: bit-wise operations are forbidden in GLSL 1.10 (GLSL 1.30 or GLSL ES 3.00 required)
GLShader::loadFragment(): error in "core/shaders/meshes/fragment_leaf_ambient.shader" file
-------------

Trying to force indicated GLSL version or disabling bit encoding with Mesa environment variables to work around the issue doesn't have any effect on it.
Comment 5 Vitaliy Filippov 2014-07-02 22:35:51 UTC
I experience the same bug on a same GPU (Ivybridge HD Graphics 4000) and Mesa 10.2.1... CPU is Core i7-3635QM, Unigine Valley and Heaven don't work - they show white picture instead, and they show the same error log.

I've read comments and I find strange that these apps work on r600 and radeonsi cards with the same Mesa (tested both myself)... Do r600/radeonsi cards have a workaround for that bug or do they use a different shader compiler? O_oo
Comment 6 Eero Tamminen 2014-07-03 10:28:24 UTC
Yes, Gallium drivers have quite different shader compiler code from classic Mesa side.

Blend function issue will be fixed in next version of Valley, it's a bug in the demo.  If  you don't want to work around the demo bugs with environment variables, you have also an option to patch Mesa:
http://cgit.freedesktop.org/~kwg/mesa/log/?h=unigine

(There are also patches floating around for allowing extension declarations elsewhere in shader source, but they seem to get fairly quickly out of date, and AFAIK they won't get merged into Mesa until Khronos GL specs have been changed accordingly.  See e.g. patch mentioned in bug 71591.)
Comment 7 Ian Romanick 2014-08-08 21:18:21 UTC
(In reply to comment #6)
> Yes, Gallium drivers have quite different shader compiler code from classic
> Mesa side.

The front end of the compiler (the only part that sees the GLSL code from the application) is the same for all Mesa drivers.  The difference is the Gallium drivers that are not affected by this issue do not expose GL_ARB_sample_shading... so the Unigine demos don't try to enable it in the middle of the shader.

> Blend function issue will be fixed in next version of Valley, it's a bug in
> the demo.  If  you don't want to work around the demo bugs with environment
> variables, you have also an option to patch Mesa:
> http://cgit.freedesktop.org/~kwg/mesa/log/?h=unigine
> 
> (There are also patches floating around for allowing extension declarations
> elsewhere in shader source, but they seem to get fairly quickly out of date,
> and AFAIK they won't get merged into Mesa until Khronos GL specs have been
> changed accordingly.  See e.g. patch mentioned in bug 71591.)

Allowing extensions in the middle of the shader will NOT be made the default in Mesa.  Khronos decided (wisely, IMO) that the spec is correct as-is.  At least one vendor vowed to fix his implementation.  I posted a bit more explanation in another bug related to this issue... or perhaps it was on the mesa-dev mailing list.

Code has landed in Mesa to enable a driconf option for this, and Ken has a patch on the mesa-dev list to enable this driconf option in the i965 driver:

http://lists.freedesktop.org/archives/mesa-dev/2014-August/065134.html

This patch should land any time now.
Comment 8 Kenneth Graunke 2014-08-16 21:22:13 UTC
The workarounds are upstream.  You do need a new ~/.drirc or /etc/drirc - I would just copy the one from src/mesa/drivers/dri/common/drirc.  It's also installed by "make install", so if you aren't getting it in your distro packages, you should file a bug with your distribution.

We can all hope that Unigine fixes this in the future.

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.