From: Carlos Garcia Campos Date: Mon, 26 Aug 2024 13:24:02 +0000 (+0200) Subject: Disable DMABuf renderer for NVIDIA proprietary drivers X-Git-Tag: archive/raspbian/2.44.3-1+rpi1^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a81d41ec6ccbb153f12e2552b9ceffea6fb7f0fe;p=webkit2gtk.git 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 =================================================================== Gbp-Pq: Name disable-dmabuf-nvidia.patch --- diff --git a/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp b/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp index a6a3ddf731..5970f9ccc3 100644 --- a/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp +++ b/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include #if USE(GBM) +#include #include #include @@ -58,6 +60,29 @@ static constexpr uint64_t s_dmabufInvalidModifier = ((1ULL << 56) - 1); 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; @@ -73,6 +98,9 @@ OptionSet AcceleratedBackingStoreDMABuf::rendererBuffe return; } + if (isNVIDIA()) + return; + mode.add(DMABufRendererBufferMode::SharedMemory); const char* forceSHM = getenv("WEBKIT_DMABUF_RENDERER_FORCE_SHM");