diddlesnaps / gog-galaxy-wine

MIT License
50 stars 1 forks source link

Support hybrid graphics via DRI PRIME #12

Open bauermann opened 5 years ago

bauermann commented 5 years ago

PRIME allows selecting which of the graphics card present on the system should render a given app.

My laptop has two cards:

$ xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x66 cap: 0x9, Source Output, Sink Offload crtcs: 3 outputs: 4 associated providers: 1 name:modesetting
Provider 1: id: 0x3f cap: 0x4, Source Offload crtcs: 0 outputs: 0 associated providers: 1 name:Unknown AMD Radeon GPU @ pci:0000:01:00.0

By setting the DRI_PRIME environment variable to 1, I can tell apps to use my discrete Radeon card, which is much better than the integrated Intel one. Unfortunately, snaps don't inherit the environment and can't see that variable so GOG Galaxy uses the puny Intel card.

This bug is to request this to be allowed. I see three options:

  1. Replicate the DRI_PRIME variable inside the container, if it's set outside of it at the time the snap is launched. Not sure if snap allows this.

  2. Expose a dri-prime snap configuration option which I can set to cause the DRI_PRIME variable to be set with the value in the config option. This is less ideal because it requires manual configuration, but at least allows me to choose the graphics card to be used.

  3. gog-galaxy-wine snap sees that there are two graphics cards available (probably using the xrandr command above) and automatically sets DRI_PRIME to the non-Intel one, since I don't think anyone would want to play games with their less-powerful card. IMHO this is the best alternative since things automagically work. It could be combined with option 1 and 2 above as a default in case DRI_PRIME or dri-prime haven't been set by the user.

lucyllewy commented 5 years ago

Setting an environment variable outside the snap should already be visible from inside the snap execution environment.

bauermann commented 4 years ago

Thank you for your quick response.

I'm sorry that I missed the notification of your reply. Unfortunately I don't have a computer with two graphics cards anymore and I can't test solutions to this issue anymore.

But do I remember that I tried setting the environment variable outside the snap and I verified that it wasn't visible from inside the snap execution environment. I thought I had mentioned that in my issue description, but now I see that it's implied but not explicitly stated.