Never use X11 EGL on Nvidia proprietary drivers

Fixes #1751
This commit is contained in:
Cameron Gutman
2025-12-05 23:10:31 -06:00
parent 58f9b2a83b
commit 1c24aada0a
4 changed files with 55 additions and 13 deletions

View File

@@ -47,6 +47,40 @@ bool WMUtils::isRunningX11()
return false;
}
bool WMUtils::isRunningX11NvidiaProprietaryDriver()
{
#ifdef HAS_X11
static SDL_atomic_t isRunningOnX11NvidiaDriver;
// If the value is not set yet, populate it now.
int val = SDL_AtomicGet(&isRunningOnX11NvidiaDriver);
if (!(val & VALUE_SET)) {
Display* display = XOpenDisplay(nullptr);
bool nvidiaDriver = false;
if (display != nullptr) {
int opcode, event, error;
// We use the presence of the NV-CONTROL extension to indicate
// that the Nvidia proprietary driver is in use on native X11
nvidiaDriver = XQueryExtension(display, "NV-CONTROL", &opcode, &event, &error);
XCloseDisplay(display);
}
// Populate the value to return and have for next time.
// This can race with another thread populating the same data,
// but that's no big deal.
val = VALUE_SET | (nvidiaDriver ? VALUE_TRUE : 0);
SDL_AtomicSet(&isRunningOnX11NvidiaDriver, val);
}
return !!(val & VALUE_TRUE);
#endif
return false;
}
bool WMUtils::isRunningWayland()
{
#ifdef HAS_WAYLAND