Make NVIDIA drivers use the GPU instead of the IGPU for 0 A.D

Hi,

I work for the FLOSS ( Free Libre and Open Source) game 0 A.D. (play0ad.com) and I noticed that on most laptops it uses the integrated GPU instead of the dedicated one, which leads to poor performance, and sometimes crashes with buggy intel drivers. Is there any good reason for it?

Also it would be nice to have it in the GeForce experience window.

We have a significant audience more than 300k last year according to our statistics Download Statistics

So it would be great if this could be fixed.

To be clear I know we can tell our users to do that manually, but it’d be better if it was automatic…

Found a solution for Windows. (Note that it only works if the user hasn’t forced the GPU)

#ifdef WIN32
// Tell system that it should use nvidia on optimus devices and amd on enduro devices
extern "C" {
    __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
    __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
}
#endif

Hi @stanislas.dolcini , nice to read you again!

Thank you very much for sharing that information. As you can imagine for Linux this is more involved, but in general if the user installs the correct NVIDIA drivers and follows installation instructions correctly, the NVIDIA GPU should be prioritized for GL usage. Any GL app or game will use the same renderer that is also running the X screen for your GLX context. If that is not the case you could use PRIME to override this.

For Vulkan the situation is a bit different. You can explicitly pick the device (e.g. the discrete GPU) for your render queue and if you use that same device for your swapchain, the output will go through that device.