1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
From: Carlos Garcia Campos <cgarcia@igalia.com>
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
@@ -39,6 +39,7 @@
#include <WebCore/NativeImage.h>
#include <WebCore/NotImplemented.h>
#include <WebCore/PlatformDisplay.h>
+#include <WebCore/PlatformDisplaySurfaceless.h>
#include <WebCore/RefPtrCairo.h>
#include <WebCore/ShareableBitmap.h>
#include <WebCore/SharedMemory.h>
@@ -53,6 +54,7 @@
#if USE(GBM)
#include <WebCore/DRMDeviceManager.h>
+#include <WebCore/PlatformDisplayGBM.h>
#include <gbm.h>
static constexpr uint64_t s_dmabufInvalidModifier = DRM_FORMAT_MOD_INVALID;
@@ -77,6 +79,34 @@ 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<WebCore::PlatformDisplay> 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()));
+ const char* glVendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
+ if (glVendor && strstr(glVendor, "NVIDIA"))
+ return true;
+ return false;
+}
+
OptionSet<RendererBufferTransportMode> AcceleratedBackingStoreDMABuf::rendererBufferTransportMode()
{
static OptionSet<RendererBufferTransportMode> mode;
@@ -92,6 +122,9 @@ OptionSet<RendererBufferTransportMode> A
return;
}
+ if (isNVIDIA())
+ return;
+
mode.add(RendererBufferTransportMode::SharedMemory);
const char* forceSHM = getenv("WEBKIT_DMABUF_RENDERER_FORCE_SHM");
|