Bug 107581 - Graphics Not Rendered Due to Missing 4.5 COMPAT Profile
Summary: Graphics Not Rendered Due to Missing 4.5 COMPAT Profile
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/radeonsi (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
URL:
Whiteboard:
Keywords:
: 107778 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-08-15 12:46 UTC by Benjamin Hodgetts
Modified: 2018-09-10 15:36 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Lack of rendered image (327.37 KB, image/jpeg)
2018-08-15 12:46 UTC, Benjamin Hodgetts
Details
APITrace (286.65 MB, application/octet-stream)
2018-08-15 12:55 UTC, Benjamin Hodgetts
Details
APITrace Playback Log (482.09 KB, text/plain)
2018-08-15 16:33 UTC, Benjamin Hodgetts
Details
hack around preprocessor stringification (781 bytes, patch)
2018-08-21 07:27 UTC, Timothy Arceri
Details | Splinter Review
hack around layout qualifiers (1.19 KB, patch)
2018-08-22 01:30 UTC, Timothy Arceri
Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Hodgetts 2018-08-15 12:46:17 UTC
Created attachment 141109 [details]
Lack of rendered image

Slightly obtuse issue as it's a game inside Wine.

No Man's Sky used to work if you faked a compatibility profile. This no-longer works as, since the last game update, it seems they are actually using some of the COMPAT mode features. The result of this is that the game menu renders fine, but any of the "3D" graphics in the game are either missing or just render completely white.

e.g. the starfield during loading should be various pinkish colours, but instead you just see a black screen. Once in-game, you should see the game world, but instead just have a (what seems to be non-refreshing) white screen.

The game seems to be fine on Nvidia cards using their proprietary driver.

Attached is an image of the issue to see specific what I'm referring to and a trace, from launch of the game, to a few minutes in game, to exiting the game. Generated with APITrace (I'll attach the trace in the next comment).
Comment 1 Benjamin Hodgetts 2018-08-15 12:55:58 UTC
Created attachment 141110 [details]
APITrace

~900MB uncompressed.
Comment 2 Karol Herbst 2018-08-15 13:38:17 UTC
when replaying the trace I see some compilation issues:

227035: message: major shader compiler error 2: 0:25(25): error: no matching function for call to `texture2DLod(sampler2D, vec2, float)'; candidates are:
227035: message: major shader compiler error 3: 0:25(17): error: operands to arithmetic operators must be numeric
Comment 3 Karol Herbst 2018-08-15 13:40:55 UTC
and there are some 0:1294(3): preprocessor error: Unterminated #if

I think this is mostly due to uncompiled shaders, maybe there is more to it, but we should concentrate on those issues first.
Comment 4 Benjamin Hodgetts 2018-08-15 16:33:13 UTC
Created attachment 141122 [details]
APITrace Playback Log

As it may contain something useful.
Comment 5 Timothy Arceri 2018-08-20 05:18:41 UTC
(In reply to Benjamin Hodgetts from comment #1)
> Created attachment 141110 [details]
> APITrace
> 
> ~900MB uncompressed.

Please don't attach large traces to the bug itself instead please upload to an external site such as google drive.

It seems you have captured the trace without using overrides. You must use MESA_GL_VERSION_OVERRIDE=4.5COMPAT for NMS to work correctly. Also there is a drirc option that is needed for the game to work correctly (you can also set it from the command line for testing) force_glsl_extensions_warn=true.

Do these two environment vars fix the issues for you?
Comment 6 Benjamin Hodgetts 2018-08-20 08:08:41 UTC
I haven't tried force_glsl_extensions_warn, but MESA_GL_VERSION_OVERRIDE=4.5COMPAT doesn't help. It worked on older versions of the game, but has no positive effect with the current version of the game (aka No Man's Sky NEXT).
Comment 7 Timothy Arceri 2018-08-21 02:10:24 UTC
(In reply to Benjamin Hodgetts from comment #6)
> I haven't tried force_glsl_extensions_warn, but
> MESA_GL_VERSION_OVERRIDE=4.5COMPAT doesn't help. It worked on older versions
> of the game, but has no positive effect with the current version of the game
> (aka No Man's Sky NEXT).

The override used to be broken and actually caused you to get an OpenGL core like profile. Since this is now fixed things will have changed, this is not a regression.

Please try using force_glsl_extensions_warn=true it works around some game bugs.
Comment 8 Timothy Arceri 2018-08-21 07:27:17 UTC
Created attachment 141209 [details] [review]
hack around preprocessor stringification

Ok I've taken a closer look and there is indeed new issues with this game besides the existing ones.

Shaders include preprocessor stringification which is legal in C by not specified in the GLSL spec e.g.

#define DOMAIN_PARAMS(dmn)         ROOT_SIG(DS) [domain(#dmn)]

I've hacked around that with the following patch but then hit further shaders that fail to compile "unexpected LAYOUT_TOK"
Comment 9 Benjamin Hodgetts 2018-08-21 10:52:20 UTC
>Please try using force_glsl_extensions_warn=true it works around some game bugs.

That generated the two new messages in the terminal...

ATTENTION: default value of option force_glsl_extensions_warn overridden by environment.
ATTENTION: option value of option force_glsl_extensions_warn ignored.

... so I assume it was picked up properly, but rendering behaviour didn't change. The nebula clouds were still missing on the loading screen (so space is just black) and in-game looked the same as the screenshot I originally posted (screen is just white except for the menu). All in all, no change.

I'll try with your hack patch and see if that changes behaviour.
Comment 10 Benjamin Hodgetts 2018-08-21 10:53:43 UTC
BTW, the attachment limit on bugs is 4GB and my attachment was 286MB. If people shouldn't post large attachments then it's probably worth lowering that limit, otherwise people have no way of knowing that they aren't supposed to attach large files.
Comment 11 Benjamin Hodgetts 2018-08-21 11:13:10 UTC
Applied the patch in attachment 141209 [details] [review] and rebuilt, but the game looks the same. Something of note is that it's supposed to build the shaders on the first load of the game, but the SHADERCACHE folder of the game is remaining empty (I assume as the shaders are failing to build).
Comment 12 Timothy Arceri 2018-08-21 12:35:26 UTC
(In reply to Benjamin Hodgetts from comment #11)
> Applied the patch in attachment 141209 [details] [review] [review] and rebuilt, but
> the game looks the same. Something of note is that it's supposed to build
> the shaders on the first load of the game, but the SHADERCACHE folder of the
> game is remaining empty (I assume as the shaders are failing to build).

The hack should make the planets/stars render correctly on the shader loading screen. It also helps the sky render in-game, everything else is missing but I'm sure it's because of the remaining failing shaders. All in all this game is extremely buggy. Do you know if it actually renders correctly on the AMD windows drivers?
Comment 13 Benjamin Hodgetts 2018-08-21 12:49:39 UTC
AFAIK it works fine on Windows. The only people that had issues were people with old cards (e.g. 6000 series and below, due to lack of support).

Just to clarify, you're using the latest version of the game, labeled "NEXT"?
Comment 14 Benjamin Hodgetts 2018-08-21 13:05:51 UTC
I've just rebuilt Mesa again with your patch, no CCache or anything this time, just in case. I'm still getting no clouds on the loading screen (you can see the stars as white dot and the names, but there's no colour, everything is just black and white) and then when it gets "in game" the menu is there, but the screen is still just white.

I wonder if the card is specific here:
OpenGL renderer string: Radeon RX 580 Series (POLARIS10, DRM 3.26.0, 4.18.3-1-clear, LLVM 8.0.0)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.3.0-devel (git-9e5e3a8ead)
Comment 15 Timothy Arceri 2018-08-22 01:30:52 UTC
Created attachment 141230 [details] [review]
hack around layout qualifiers

The next shader compilation problem is that they are applying layout qualifiers to function params. e.g

void WriteTextureCacheFeedback(
    vec2 lCacheCoords,
    ivec2 lResolution,
    float lfDesiredMip,
    layout( r32i ) iimage2D lFeedbackMap,      < --------
    uint liFeedbackIndex )

layout( r32i ) can only be applied to uniforms.

I've attached another hack that together with the other hack makes the game playable for me.
Comment 16 Benjamin Hodgetts 2018-08-22 09:59:47 UTC
Looks like I lost MESA_GL_VERSION_OVERRIDE=4.5COMPAT somewhere along the line which is why I couldn't see anything. That, plus force_glsl_extensions_warn=true and your two patches does indeed work.

The starfield renders now but it's still missing the coloured cloud nebulae (this - https://cdn.cnn.com/cnnnext/dam/assets/150617071718-game-faces-no-mans-sky-ns-natpkg-00014710-large-169.jpg).

So it seems your patches (and the overrides) get us most of the way there.
Comment 17 Matthew Vaughn 2018-08-25 17:17:55 UTC
I've been following this issue since it was reported and I would like to contribute if I can. Since the bug status is currently "NEEDINFO" I will endeavor to provide corroborating details and offer my platform for investigation and testing.

I can begin by validating everything discussed in the comments so far. The issue presents itself on my platform exactly as Benjamin documented. My platform only differs slightly:

OpenGL renderer string: Radeon RX Vega (VEGA10, DRM 3.26.0, 4.18.4-gentoo, LLVM 6.0.1)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.2.0-rc4


The patches Timothy provided apply and build perfectly, and with the suggested environment variables set while running NMS I can also exactly reproduce Benjamin's result. World assets render correctly; the game is playable; the galaxy map "clouds" are not visible; there appear to be significant artifacts in the semi-transparent background textures of most UI elements (conversation dialogs and the tab menu).

My first attempt at reproducing the problem and using the proposed patches was done on Mesa 18.2.0-rc4 built from source, but I have no problem in principle with testing further against the current 18.3.0 development branch.

I am happy to test additional patches and gather any additional information upon request. Thank you for starting the work.
Comment 18 Timothy Arceri 2018-08-26 00:26:24 UTC
(In reply to Matthew Vaughn from comment #17)
> The patches Timothy provided apply and build perfectly, and with the
> suggested environment variables set while running NMS I can also exactly
> reproduce Benjamin's result. World assets render correctly; the game is
> playable; the galaxy map "clouds" are not visible; there appear to be
> significant artifacts in the semi-transparent background textures of most UI
> elements (conversation dialogs and the tab menu).
> 

The artifacts should be fixed by the zerovram part of this patch series [1] which you can already do with the following environment var R600_DEBUG=zerovram

I've reported the shaders bugs from this bug report to the No Mans Sky devs and also created some CTS tests to expose them on the Nvidia driver so hopefully they will get fixed in the game.

As for the missing nebulae I'm not sure what the problem is there. All I know is it was working before the last game update and I suspect there may have been another bug introduced somewhere. I'll have another look tomorrow but I'm probably not going to spend too much time on that issue since the game is otherwise now playable.

[1] https://patchwork.freedesktop.org/series/48664/
Comment 19 Benjamin Hodgetts 2018-08-26 14:01:52 UTC
Thanks for all the work so far Timothy.
Comment 20 Timothy Arceri 2018-08-30 00:02:25 UTC
(In reply to Benjamin Hodgetts from comment #19)
> Thanks for all the work so far Timothy.

No problem. Thanks for reporting the issues.

I've now pushed patches to enable OpenGL 4.5 compat for radeonsi. I've fixed a bug in the lexer that was causing some shaders to fail to compile, and I've added a workaround to another shader bug in the game that they don't currently want to work around as the Nvidia driver depends on the buggy shaders. So as of git master a couple of minutes ago No Mans Sky should run out of the box no manual environment vars required.

As for the missing nebulae there is a shader failing to compile as they are missing an #endif to go with an #ifdef. This is my guess as to why its failing to display, and I've let the NMS devs know about it. If I'm correct this issue should be present even on Nvidia drivers currently.

So with that I think we can now close this bug.
Comment 21 Timothy Arceri 2018-09-06 02:33:42 UTC
*** Bug 107778 has been marked as a duplicate of this bug. ***
Comment 22 Benjamin Hodgetts 2018-09-10 15:36:27 UTC
Just an FYI, testing with Mesa GIT this morning and the coloured space nebulae are being rendered correctly as well. Additionally the weird garbage/distortion below the "NEXT" notification when you first start the game has also disappeared.


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.