[Mesa-dev] [PATCH 0/2] Allow redeclaration of GLSL builtins; fixes Dying Light and Dead Island Definitive Edition

John Brooks john at fastquake.com
Fri May 12 13:39:46 UTC 2017


Since release, Dying Light and Dead Island Definitive Edition have been broken
on Mesa, producing at best only a black screen after loading. I found that the
root of the problem is that their vertex shaders redeclare the GLSL builtin
gl_VertexID, which Mesa's compiler considers to be an error:

    error: `gl_VertexID' redeclared

These patches make the compiler more lenient so that the shaders compile.
Because such redeclarations are not explicitly valid in the spec, this
behaviour is selectively activated by the new allow_glsl_builtin_redeclaration
driconf option, which has been enabled for both games in the default drirc.

With this change, both games work on Mesa and render correctly. Note that the
games require OpenGL 4.4+, and so it is necessary to launch them with
MESA_GL_VERSION_OVERRIDE and MESA_GLSL_VERSION_OVERRIDE set to OpenGL 4.4 (GLSL
440) or higher.

Contrary to popular belief, this problem actually had nothing whatsoever to do
with compatibility profiles. Forcing Mesa to create a higher version
compatibility profile with MESA_GL_VERSION_OVERRIDE=4.5COMPAT or
allow_higher_compat_version results in graphical glitches, so don't use that.


A few extra notes for users reading this: I had terrible, unplayable
performance with Dying Light on a configuration with an R9 290, Mesa 17.1-rc3,
and the radeon kernel driver on kernel 4.10. Switching to the amdgpu driver
(enable CONFIG_DRM_AMDGPU_CIK, blacklist radeon, install amdgpu DDX and set
Driver "amdgpu" in xorg.conf) on kernel 4.11 made it playable.  With amdgpu it
hovers around 25-35fps except in select areas (such as the Tower lobby and near
Zere's trailer) near the start of the game where the framerate plummets for no
apparent reason. Dead Island Definitive Edition performs much better in general
than Dying Light, at least on amdgpu. I did not test DIDE on radeon. Ongoing
TTM optimization work may mitigate the performance problems in the future.


The main thing I'm unsure of is whether allowing GLSL builtin redeclarations
should be a driconf option or default behaviour. I looked through the GLSL spec
and initially thought that such redeclarations were permitted because of this
line from page 66 of <https://khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.50.pdf>:

    in vec4 gl_FragCoord; // redeclaration that changes nothing is allowed

But others on IRC interpreted it as referring only to gl_FragCoord, which I
agree would make sense given the context. So to be on the safe side I made it
conditional on a driconf option. I leave the final decision to the reviewers.
Let me know what you think.

Thank you to to funfunctor, notaz, and others from the #radeon IRC channel for
their suggestions and their help with analyzing the game binaries.

--
John Brooks
Frogging101 on IRC and elsewhere



More information about the mesa-dev mailing list