From: Carlos Garcia Campos Subject: Disable DMABuf renderer for NVIDIA proprietary drivers Bug: https://bugs.webkit.org/show_bug.cgi?id=262607 Bug-Debian: https://bugs.debian.org/1039720 Origin: https://github.com/WebKit/WebKit/pull/18614 Index: webkitgtk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp =================================================================== --- webkitgtk.orig/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp +++ webkitgtk/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp @@ -36,11 +36,13 @@ #include #include #include +#include #include #include #if USE(GBM) #include +#include #include static constexpr uint64_t s_dmabufInvalidModifier = uint64_t(WebCore::DMABufFormat::Modifier::Invalid); #else @@ -53,6 +55,29 @@ static constexpr uint64_t s_dmabufInvali namespace WebKit { +static bool isNVIDIA() +{ + const char* forceDMABuf = getenv("WEBKIT_FORCE_DMABUF_RENDERER"); + if (forceDMABuf && strcmp(forceDMABuf, "0")) + return false; + + std::unique_ptr platformDisplay; +#if USE(GBM) + const char* disableGBM = getenv("WEBKIT_DMABUF_RENDERER_DISABLE_GBM"); + if (!disableGBM || !strcmp(disableGBM, "0")) { + if (auto* device = WebCore::PlatformDisplay::sharedDisplay().gbmDevice()) + platformDisplay = WebCore::PlatformDisplayGBM::create(device); + } +#endif + if (!platformDisplay) + platformDisplay = WebCore::PlatformDisplaySurfaceless::create(); + + WebCore::GLContext::ScopedGLContext glContext(WebCore::GLContext::createOffscreen(platformDisplay ? *platformDisplay : WebCore::PlatformDisplay::sharedDisplay())); + if (strstr(reinterpret_cast(glGetString(GL_VENDOR)), "NVIDIA")) + return true; + return false; +} + OptionSet AcceleratedBackingStoreDMABuf::rendererBufferMode() { static OptionSet mode; @@ -68,6 +93,9 @@ OptionSet Acce return; } + if (isNVIDIA()) + return; + mode.add(DMABufRendererBufferMode::SharedMemory); const auto& eglExtensions = WebCore::PlatformDisplay::sharedDisplay().eglExtensions();