NVIDIA / libglvnd

The GL Vendor-Neutral Dispatch library
502 stars 90 forks source link

Incorrect vendor selected when using DRI_PRIME=1 #203

Closed garyvdm closed 3 years ago

garyvdm commented 3 years ago

I have a hybrid graphic setup with a Nvidia & Intel graphics cards. When I set my machine to use either nvidia or intel using prime-select then all works as expected. However when I try use on-demand and I try to run an application with DRI_PRIME=1 to get it to use the Nvidia card, libglvnd incorrectly loads mesa, which tries to load nouveau, which fails, and then falls back to using the Intel card.

# DRI_PRIME=1 glxinfo | grep "OpenGL renderer"
libGL error: failed to create dri screen
libGL error: failed to load driver: nouveau
OpenGL renderer string: Mesa Intel(R) UHD Graphics 630 (CFL GT2)

It would be nice if libglvnd detected when run with DRI_PRIME=1 and used the correct vendor.

garyvdm commented 3 years ago

Examples of other people encountering this issue:

https://askubuntu.com/questions/1267834/nouveau-drivers-doesnt-work-on-ubuntu-20-04-with-prime https://unix.stackexchange.com/questions/594273/how-do-i-switch-gpus-with-libglvnd https://askubuntu.com/questions/1272422/run-application-using-a-specific-gpu-on-a-system-with-multiple-gpus

kbrenneman commented 3 years ago

Libglvnd has been moved over to Freedesktop, so any new bug reports should go there: https://gitlab.freedesktop.org/glvnd/libglvnd

That said, DRI_PRIME is specific to Mesa, not libglvnd. Libglvnd can't use it because it has no knowledge of available hardware.

To use GPU offloading with the NVIDIA driver, you'd need to set these:

# Tell libglvnd to use the NVIDIA vendor library even if the X server would tell it to use Mesa
__GLX_VENDOR_LIBRARY_NAME=nvidia
# Tell the NVIDIA vendor library to use GPU offloading
__NV_PRIME_RENDER_OFFLOAD=1