From e2d7418c1d4428ea4f7c3f5e3e2b7a2b0a0790a5 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Wed, 30 Oct 2024 14:39:03 +0100 Subject: [PATCH] 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-nvidia-dmabuf.patch --- .../gtk/AcceleratedBackingStoreDMABuf.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp b/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp index 95f8f8a3cc..965e16a4e3 100644 --- a/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp +++ b/Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,7 @@ #if USE(GBM) #include +#include #include static constexpr uint64_t s_dmabufInvalidModifier = DRM_FORMAT_MOD_INVALID; @@ -66,6 +68,33 @@ namespace WebKit { WTF_MAKE_TZONE_ALLOCATED_IMPL(AcceleratedBackingStoreDMABuf); +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")) { + + auto& manager = WebCore::DRMDeviceManager::singleton(); + if (!manager.isInitialized()) + manager.initializeMainDevice(drmRenderNodeDevice()); + if (auto* device = manager.mainGBMDeviceNode(WebCore::DRMDeviceManager::NodeType::Render)) + 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; @@ -81,6 +110,9 @@ OptionSet AcceleratedBackingStoreDMABuf::rendererBuffe return; } + if (isNVIDIA()) + return; + mode.add(DMABufRendererBufferMode::SharedMemory); const char* forceSHM = getenv("WEBKIT_DMABUF_RENDERER_FORCE_SHM"); -- 2.30.2