Bug 98974

Summary: Can't see borders/empires in Stellaris
Product: Mesa Reporter: lukas.fuernkranz+bugzilla2
Component: Drivers/Gallium/r600Assignee: Default DRI bug account <dri-devel>
Status: RESOLVED FIXED QA Contact: Default DRI bug account <dri-devel>
Severity: normal    
Priority: medium CC: andy641, arpad.kunszt, baker.dylan.c, bugs.freedesktop, jlp.bugs, nikolai.vaags, pierre.morrow
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Patch for r600 GPUs

Description lukas.fuernkranz+bugzilla2 2016-12-02 17:32:46 UTC
I'm using Ubuntu 16.04 and an AMD Radeon 6870 with the drivers from https://launchpad.net/~oibaf/+archive/ubuntu/graphics-drivers.

In Stellaris (a video game) I can't see the borders/empires on the map.  Unless I set the graphics quality to low that is.

(Temporarily I used an AMD R9 270x---also with the drivers from the oibaf PPA; radeonsi though---and there I didn't have that problem.)

In case more infos are needed please say so and I'll do my best to provide it.
Comment 1 Dylan Baker 2016-12-03 00:06:32 UTC
I can verify this bug on Archlinux using the i965 driver on both HSW and SKL, thus moving to mesa core.

On i965 I'm using low settings but see no borders for my own empire, but other empires get a light grey border.

I can also verify that the game works correctly on the Nvidia blob on SteamOS.
Comment 2 Pierre Moreau 2016-12-04 10:20:08 UTC
(In reply to Dylan Baker from comment #1)
> I can verify this bug on Archlinux using the i965 driver on both HSW and
> SKL, thus moving to mesa core.
> 
> On i965 I'm using low settings but see no borders for my own empire, but
> other empires get a light grey border.
> 
> I can also verify that the game works correctly on the Nvidia blob on
> SteamOS.

Which version of Mesa are you using? It works fine for me on HSW with both low and high graphics settings, on Mesa 13.0.2; I'm also using Arch. Also, two persons in https://bugs.freedesktop.org/show_bug.cgi?id=95530 reported the borders being shown since Mesa 12 on Haswell.
Comment 3 Pierre Moreau 2016-12-04 10:21:06 UTC
Also, which version of Stellaris are you using?
Comment 4 Dylan Baker 2016-12-04 18:11:44 UTC
Mesa 13.0.2 and 13.0.1 demonstrate the problem, and I'm using stellaris 1.3.2 (2620). I saw the bug that idr opened, and I have a work around, setting the launch options in steam to "MESA_GL_VERSION_OVERRIDE=31 %command%" fixes the problem. For me at least I think this is a duplicate of 95530.

Lukas, could you try setting the command as above and see if that fixes the problem for you as well?
Comment 5 lukas.fuernkranz+bugzilla2 2016-12-04 19:34:14 UTC
Unfortunately I doesn't seem to fix the problem for me, Dylan.
Comment 6 Eero Tamminen 2016-12-05 09:09:47 UTC
(In reply to Dylan Baker from comment #1)
> I can verify this bug on Archlinux using the i965 driver on both HSW and
> SKL, thus moving to mesa core.
> 
> On i965 I'm using low settings but see no borders for my own empire, but
> other empires get a light grey border.
> 
> I can also verify that the game works correctly on the Nvidia blob on
> SteamOS.

When testing different drivers, it's better to use Apitrace trace, that way you can be sure that both drivers are given the same content content (games can adapt things based on which driver is being used).
Comment 7 Ernst Sjöstrand 2017-01-10 03:13:34 UTC
Can't reproduce with Fiji, drm-next-4.10 and mesa 13.0-branchpoint-2089-g230b756

Running with multisample 4x, high, high.

Stellaris is now v1.4.1.
Comment 8 lukas.fuernkranz+bugzilla2 2017-04-08 11:25:38 UTC
I still have that problem. with the new Stellaris version (1.5.0) and Mesa 17.1.0-devel.
Comment 9 Bronson 2017-04-17 00:42:18 UTC
yes still have this issue on 17.1 git/dev under the latest 1.51 patch also
Comment 10 andy641 2017-04-30 09:26:19 UTC
Created attachment 131158 [details] [review]
Patch for r600 GPUs
Comment 11 andy641 2017-04-30 09:27:03 UTC
Comment on attachment 131158 [details] [review]
Patch for r600 GPUs

I have written a mod for the game Stellaris, which seems to fix this problem for AMD GPUs that use the r600 driver.

http://steamcommunity.com/sharedfiles/filedetails/?id=907468268

The mod changes the pixel shader that creates the border. I simply manually unrolled a loop and turned a function into a macro. There are no functional differences and these changes should make no difference in the resulting code, yet they make the shader work.

I don't know why it works and I am not an expert in this stuff, but I think there could be a bug in the GLSL compiler. Maybe the register allocator messes something up and manually unrolling the loop fixes it.
Comment 12 William Bonnaventure 2017-05-10 10:39:50 UTC
I can verify this bug with an AMD Radeon HD 6870 and Mesa 17.0.5 on Fedora.
The Stellaris mod "Patch for r600 GPUs" fixed indeed this bug, but the real bug is in Mesa.

This bug seems to only affect AMD GPUs with r600 driver (Intel GPU fixed a similar bug with same effects in a previous Mesa version).

There's no usefull logs from Stellaris nor crash dump.
Comment 13 William Bonnaventure 2017-05-11 10:07:31 UTC
With apitrace there is a lot of :
EE r600_shader.c:3663 r600_shader_from_tgsi - GPR limit exceeded - shader requires 213 registers
EE r600_shader.c:183 r600_pipe_shader_create - translation from TGSI failed !
EE r600_state_common.c:799 r600_shader_select - Failed to build shader variant (type=1) -12
EE r600_shader.c:3663 r600_shader_from_tgsi - GPR limit exceeded - shader requires 215 registers
EE r600_shader.c:183 r600_pipe_shader_create - translation from TGSI failed !
EE r600_state_common.c:799 r600_shader_select - Failed to build shader variant (type=1) -12
Comment 14 Gert Wollny 2017-12-12 18:44:54 UTC
Could you check whether the bug persists in 17.3.0? It includes patches  that improve the register allocation on r600. 

If this doesn't fix the bug, could you post an apitrace?
Comment 15 James Lovinsky 2017-12-14 17:35:44 UTC
I have a thinkpad x220 (Intel HD 3000 integrated graphics).  I can confirm that this bug is fixed for me with MESA 17.2.4

/--------------------------------------------------------------------------/
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
    Max core profile version: 3.3
    Max compat profile version: 3.0
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL core profile version string: 3.3 (Core Profile) Mesa 17.2.4
OpenGL core profile shading language version string: 3.30
OpenGL version string: 3.0 Mesa 17.2.4
OpenGL shading language version string: 1.30
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 17.2.4
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
/--------------------------------------------------------------------------/

Bug was present in previous MESA version, I believe it was ~17.0.5.
Comment 16 James Lovinsky 2017-12-14 17:39:50 UTC
I'm using Stellaris v1.9 through the Steam client on Linux Mint 18.3 with the MATE desktop.
Comment 17 Gert Wollny 2017-12-14 20:24:04 UTC
@James Lovinsky: since you are running the game on Intel graphics hardware you probably saw #95530, this bug refers to AMD hardware (r600).
Comment 18 James Lovinsky 2017-12-14 20:38:26 UTC
Sorry, my mistake.  Will refer to #95530, thanks!
Comment 19 lukas.fuernkranz+bugzilla2 2018-01-23 19:04:28 UTC
(In reply to Gert Wollny from comment #14)
> Could you check whether the bug persists in 17.3.0? It includes patches 
> that improve the register allocation on r600. 
> 
> If this doesn't fix the bug, could you post an apitrace?

I can test it in two weeks at the earliest.  If someone beat me to it that would be great.  However, if nobody does that and you don't hear back from me within three weeks please remind me about this issue.
Comment 20 John 2018-01-26 01:17:15 UTC
(In reply to Gert Wollny from comment #14)
> If this doesn't fix the bug, could you post an apitrace?

mesa 17.3.2
no galaxy map borders

apitrace:
DEBUGGER="apitrace trace" steam-native steam://rungameid/281990
https://www.dropbox.com/s/a8d38yoaeu7n9uy/stellaris_noborders_r600g.trace?dl=1

SHA256(stellaris_noborders_r600g.trace)= bfc9f724dff5f27a3b3670a15b0bdd72c14b049e047c9194d22fe0651f653888

EE r600_shader.c:3672 r600_shader_from_tgsi - GPR limit exceeded - shader requires 213 registers
EE r600_shader.c:183 r600_pipe_shader_create - translation from TGSI failed !
EE r600_state_common.c:787 r600_shader_select - Failed to build shader variant (type=1) -12

AMD 5850
DRI3
Arch Linux 

Stellaris 1.9.1

Is there a preferred apitrace file host?

Thanks
Comment 21 John 2018-03-05 23:38:09 UTC
I now see borders with versions:

Stellaris v2.0.1

Linux 4.15.6
mesa 17.3.6
xorg 1.19.6
Comment 22 Timothy Arceri 2018-03-28 22:31:48 UTC
Marking as fixed as per comment 21. Please reopen if there are still issues.

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.