Disable EGL on Nvidia XWayland environments too

It renders a black window, just like native X11.
This commit is contained in:
Cameron Gutman
2025-12-11 20:10:37 -06:00
parent bd6a1d9a9b
commit 54163e30d0
4 changed files with 16 additions and 22 deletions
+1 -1
View File
@@ -476,7 +476,7 @@ int main(int argc, char *argv[])
#endif #endif
} }
if (WMUtils::isEGLSafe()) { if (WMUtils::isX11EGLSafe()) {
// Some ARM and RISC-V embedded devices don't have working GLX which can cause // Some ARM and RISC-V embedded devices don't have working GLX which can cause
// SDL to fail to find a working OpenGL implementation at all. Let's force EGL // SDL to fail to find a working OpenGL implementation at all. Let's force EGL
// on all platforms for both SDL and Qt. This also avoids GLX-EGL interop issues // on all platforms for both SDL and Qt. This also avoids GLX-EGL interop issues
@@ -14,15 +14,6 @@
#include <SDL_syswm.h> #include <SDL_syswm.h>
// These are extensions, so some platform headers may not provide them // These are extensions, so some platform headers may not provide them
#ifndef EGL_PLATFORM_WAYLAND_KHR
#define EGL_PLATFORM_WAYLAND_KHR 0x31D8
#endif
#ifndef EGL_PLATFORM_X11_KHR
#define EGL_PLATFORM_X11_KHR 0x31D5
#endif
#ifndef EGL_PLATFORM_GBM_KHR
#define EGL_PLATFORM_GBM_KHR 0x31D7
#endif
#ifndef GL_UNPACK_ROW_LENGTH_EXT #ifndef GL_UNPACK_ROW_LENGTH_EXT
#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 #define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2
#endif #endif
@@ -437,7 +428,7 @@ bool EGLRenderer::initialize(PDECODER_PARAMETERS params)
// If we're using X11 GLX (both in SDL and Qt), don't use this renderer. // If we're using X11 GLX (both in SDL and Qt), don't use this renderer.
// Switching between EGL and GLX can cause interoperability issues. // Switching between EGL and GLX can cause interoperability issues.
if (!WMUtils::isEGLSafe()) { if (strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0 && !WMUtils::isX11EGLSafe()) {
EGL_LOG(Warn, "Disabled due to use of GLX"); EGL_LOG(Warn, "Disabled due to use of GLX");
return false; return false;
} }
+2 -2
View File
@@ -7,10 +7,10 @@
namespace WMUtils { namespace WMUtils {
bool isRunningX11(); bool isRunningX11();
bool isRunningNvidiaProprietaryDriver(); bool isRunningNvidiaProprietaryDriverX11();
bool isRunningWayland(); bool isRunningWayland();
bool isRunningWindowManager(); bool isRunningWindowManager();
bool isRunningDesktopEnvironment(); bool isRunningDesktopEnvironment();
bool isEGLSafe(); bool isX11EGLSafe();
QString getDrmCardOverride(); QString getDrmCardOverride();
} }
+12 -9
View File
@@ -20,6 +20,10 @@
#ifdef HAVE_EGL #ifdef HAVE_EGL
#include <EGL/egl.h> #include <EGL/egl.h>
#ifndef EGL_PLATFORM_X11_KHR
#define EGL_PLATFORM_X11_KHR 0x31D5
#endif
#endif #endif
#define VALUE_SET 0x01 #define VALUE_SET 0x01
@@ -51,7 +55,7 @@ bool WMUtils::isRunningX11()
#endif #endif
} }
bool WMUtils::isRunningNvidiaProprietaryDriver() bool WMUtils::isRunningNvidiaProprietaryDriverX11()
{ {
#ifdef HAVE_EGL #ifdef HAVE_EGL
static SDL_atomic_t isRunningOnNvidiaDriver; static SDL_atomic_t isRunningOnNvidiaDriver;
@@ -61,7 +65,10 @@ bool WMUtils::isRunningNvidiaProprietaryDriver()
if (!(val & VALUE_SET)) { if (!(val & VALUE_SET)) {
bool nvidiaDriver = false; bool nvidiaDriver = false;
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); // Open the default X11 display. This is critical for accurate detection of the
// Nvidia driver under XWayland because eglGetDisplay(EGL_DEFAULT_DISPLAY) will
// return the Wayland display but Qt will use the X11 display.
EGLDisplay display = eglGetPlatformDisplay(EGL_PLATFORM_X11_KHR, EGL_DEFAULT_DISPLAY, nullptr);
if (display != EGL_NO_DISPLAY && eglInitialize(display, nullptr, nullptr)) { if (display != EGL_NO_DISPLAY && eglInitialize(display, nullptr, nullptr)) {
const char* vendorString = eglQueryString(display, EGL_VENDOR); const char* vendorString = eglQueryString(display, EGL_VENDOR);
nvidiaDriver = vendorString && strstr(vendorString, "NVIDIA") != NULL; nvidiaDriver = vendorString && strstr(vendorString, "NVIDIA") != NULL;
@@ -177,13 +184,9 @@ QString WMUtils::getDrmCardOverride()
return QString(); return QString();
} }
bool WMUtils::isEGLSafe() bool WMUtils::isX11EGLSafe()
{ {
// We can use EGL if: // Nvidia's driver has broken EGL support on X11 and XWayland
// a) We're not using X11/Wayland (EGLFS requires it)
// b) We're using Wayland (even XWayland is fine)
// c) We're using X11 but not the Nvidia proprietary driver
//
// https://github.com/moonlight-stream/moonlight-qt/issues/1751 // https://github.com/moonlight-stream/moonlight-qt/issues/1751
return !WMUtils::isRunningWindowManager() || WMUtils::isRunningWayland() || !WMUtils::isRunningNvidiaProprietaryDriver(); return !WMUtils::isRunningNvidiaProprietaryDriverX11();
} }