From 825aa4ac38869d29c025dff1be6dd1aacbe631b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Thu, 10 Jan 2019 18:18:29 +0100 Subject: [PATCH] [platform/virtual] Drop support for vgem and rendernode Summary: Instead we depend on the surfaceless platform for which we recently added support. Thus the plugin does not need to use gbm and udev anymore. So simplifies a lot. Test Plan: ctest (prior to breaking change) passes Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D18160 --- TESTING.md | 12 ++-- plugins/platforms/virtual/CMakeLists.txt | 4 -- plugins/platforms/virtual/egl_gbm_backend.cpp | 66 +------------------ plugins/platforms/virtual/egl_gbm_backend.h | 1 - plugins/platforms/virtual/virtual_backend.cpp | 11 ---- plugins/platforms/virtual/virtual_backend.h | 18 ----- udev.cpp | 30 --------- udev.h | 2 - 8 files changed, 8 insertions(+), 136 deletions(-) diff --git a/TESTING.md b/TESTING.md index a8a764212d..34655886a1 100644 --- a/TESTING.md +++ b/TESTING.md @@ -10,13 +10,13 @@ The following additional software needs to be installed for running the test sui * DMZ-white cursor theme * breeze window decoration -# Preparing a run of the test suite -In case your system does not support the EGL extension EGL_MESA_platform_surfaceless, -please load the kernel module "vgem". This is required to provide a virtual OpenGL device. +# Preparing OpenGL +Some of the tests require OpenGL. The test suite is implemented against Mesa and uses the Mesa specific EGL extension +EGL_MESA_platform_surfaceless. This extension supports rendering without any real GPU using llvmpipe as software +emulation. This gives the tests a stable base removing variance introduced by different hardware and drivers. - sudo modprobe vgem - -Furthermore the user executing the test suite must be able to read and write to the dri device created by vgem. +Users of non-Mesa drivers (e.g. proprietary NVIDIA driver) need to ensure that Mesa is also installed. If your system +uses libglvnd this should work out of the box, if not you might need to tune LD_LIBRARY_PATH. # Running the test suite The test suite can be run from the build directory. Best is to do: diff --git a/plugins/platforms/virtual/CMakeLists.txt b/plugins/platforms/virtual/CMakeLists.txt index 0d3880acda..532a8857f2 100644 --- a/plugins/platforms/virtual/CMakeLists.txt +++ b/plugins/platforms/virtual/CMakeLists.txt @@ -14,10 +14,6 @@ add_library(KWinWaylandVirtualBackend MODULE ${VIRTUAL_SOURCES}) set_target_properties(KWinWaylandVirtualBackend PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/org.kde.kwin.waylandbackends/") target_link_libraries(KWinWaylandVirtualBackend kwin SceneQPainterBackend SceneOpenGLBackend) -if(HAVE_GBM) - target_link_libraries(KWinWaylandVirtualBackend gbm::gbm) -endif() - install( TARGETS KWinWaylandVirtualBackend diff --git a/plugins/platforms/virtual/egl_gbm_backend.cpp b/plugins/platforms/virtual/egl_gbm_backend.cpp index 36ba67eb19..9986da0487 100644 --- a/plugins/platforms/virtual/egl_gbm_backend.cpp +++ b/plugins/platforms/virtual/egl_gbm_backend.cpp @@ -23,19 +23,12 @@ along with this program. If not, see . #include "virtual_backend.h" #include "options.h" #include "screens.h" -#include "udev.h" #include // kwin libs #include #include // Qt #include -// system -#include -#include -#if HAVE_GBM -#include -#endif namespace KWin { @@ -58,39 +51,6 @@ EglGbmBackend::~EglGbmBackend() cleanup(); } -void EglGbmBackend::initGbmDevice() -{ - if (m_backend->drmFd() != -1) { - // already initialized - return; - } - QScopedPointer udev(new Udev); - UdevDevice::Ptr device = udev->virtualGpu(); - if (!device) { - // if we don't have a virtual (vgem) device, try to find a render node - qCDebug(KWIN_VIRTUAL) << "No vgem device, looking for a render node"; - device = udev->renderNode(); - } - if (!device) { - qCDebug(KWIN_VIRTUAL) << "Neither a render node, nor a vgem device found"; - return; - } - qCDebug(KWIN_VIRTUAL) << "Found a device: " << device->devNode(); - int fd = open(device->devNode(), O_RDWR | O_CLOEXEC); - if (fd == -1) { - qCWarning(KWIN_VIRTUAL) << "Failed to open: " << device->devNode(); - return; - } - m_backend->setDrmFd(fd); -#if HAVE_GBM - auto gbmDevice = gbm_create_device(fd); - if (!gbmDevice) { - qCWarning(KWIN_VIRTUAL) << "Failed to open gbm device"; - } - m_backend->setGbmDevice(gbmDevice); -#endif -} - bool EglGbmBackend::initializeEgl() { initClientExtensions(); @@ -102,30 +62,8 @@ bool EglGbmBackend::initializeEgl() // first try surfaceless if (hasClientExtension(QByteArrayLiteral("EGL_MESA_platform_surfaceless"))) { display = eglGetPlatformDisplayEXT(EGL_PLATFORM_SURFACELESS_MESA, EGL_DEFAULT_DISPLAY, nullptr); - } - } - if (display == EGL_NO_DISPLAY) { - qCDebug(KWIN_VIRTUAL) << "Failed to create surfaceless platform, trying with vgem device"; - const bool hasMesaGBM = hasClientExtension(QByteArrayLiteral("EGL_MESA_platform_gbm")); - const bool hasKHRGBM = hasClientExtension(QByteArrayLiteral("EGL_KHR_platform_gbm")); - const GLenum platform = hasMesaGBM ? EGL_PLATFORM_GBM_MESA : EGL_PLATFORM_GBM_KHR; - - if (!hasClientExtension(QByteArrayLiteral("EGL_EXT_platform_base")) || - (!hasMesaGBM && !hasKHRGBM)) { - setFailed("missing one or more extensions between EGL_EXT_platform_base, EGL_MESA_platform_gbm, EGL_KHR_platform_gbm"); - return false; - } - -#if HAVE_GBM - initGbmDevice(); - if (auto device = m_backend->gbmDevice()) { - display = eglGetPlatformDisplayEXT(platform, device, nullptr); - } -#endif - - if (display == EGL_NO_DISPLAY) { - qCWarning(KWIN_VIRTUAL) << "Failed to create EGLDisplay through GBM device, trying with default device"; - display = eglGetPlatformDisplayEXT(platform, EGL_DEFAULT_DISPLAY, nullptr); + } else { + qCWarning(KWIN_VIRTUAL) << "Extension EGL_MESA_platform_surfaceless not available"; } } diff --git a/plugins/platforms/virtual/egl_gbm_backend.h b/plugins/platforms/virtual/egl_gbm_backend.h index 3940e9e246..c8b7a71692 100644 --- a/plugins/platforms/virtual/egl_gbm_backend.h +++ b/plugins/platforms/virtual/egl_gbm_backend.h @@ -49,7 +49,6 @@ private: bool initializeEgl(); bool initBufferConfigs(); bool initRenderingContext(); - void initGbmDevice(); VirtualBackend *m_backend; GLTexture *m_backBuffer = nullptr; GLRenderTarget *m_fbo = nullptr; diff --git a/plugins/platforms/virtual/virtual_backend.cpp b/plugins/platforms/virtual/virtual_backend.cpp index 339aaef00a..2951fe945e 100644 --- a/plugins/platforms/virtual/virtual_backend.cpp +++ b/plugins/platforms/virtual/virtual_backend.cpp @@ -31,9 +31,6 @@ along with this program. If not, see . #include #include #include -#if HAVE_GBM -#include -#endif namespace KWin { @@ -56,14 +53,6 @@ VirtualBackend::VirtualBackend(QObject *parent) VirtualBackend::~VirtualBackend() { -#if HAVE_GBM - if (m_gbmDevice) { - gbm_device_destroy(m_gbmDevice); - } -#endif - if (m_drmFd != -1) { - close(m_drmFd); - } } void VirtualBackend::init() diff --git a/plugins/platforms/virtual/virtual_backend.h b/plugins/platforms/virtual/virtual_backend.h index 167628f7c4..b22f4b3fae 100644 --- a/plugins/platforms/virtual/virtual_backend.h +++ b/plugins/platforms/virtual/virtual_backend.h @@ -28,8 +28,6 @@ along with this program. If not, see . class QTemporaryDir; -struct gbm_device; - namespace KWin { class VirtualOutput; @@ -59,20 +57,6 @@ public: Outputs outputs() const override; Outputs enabledOutputs() const override; - int drmFd() const { - return m_drmFd; - } - void setDrmFd(int fd) { - m_drmFd = fd; - } - - gbm_device *gbmDevice() const { - return m_gbmDevice; - } - void setGbmDevice(gbm_device *device) { - m_gbmDevice = device; - } - QVector supportedCompositors() const override { return QVector{OpenGLCompositing, QPainterCompositing}; } @@ -85,8 +69,6 @@ private: QVector m_enabledOutputs; QScopedPointer m_screenshotDir; - int m_drmFd = -1; - gbm_device *m_gbmDevice = nullptr; }; } diff --git a/udev.cpp b/udev.cpp index f064b089b6..da3b6072b1 100644 --- a/udev.cpp +++ b/udev.cpp @@ -156,36 +156,6 @@ UdevDevice::Ptr Udev::primaryGpu() }); } -UdevDevice::Ptr Udev::virtualGpu() -{ - if (!m_udev) { - return UdevDevice::Ptr(); - } - UdevEnumerate enumerate(this); - enumerate.addMatch(UdevEnumerate::Match::SubSystem, "drm"); - enumerate.addMatch(UdevEnumerate::Match::SysName, "card[0-9]*"); - enumerate.scan(); - return enumerate.find([](const UdevDevice::Ptr &device) { - const QByteArray deviceName(udev_device_get_syspath(*device)); - return deviceName.contains("virtual"); - }); -} - -UdevDevice::Ptr Udev::renderNode() -{ - if (!m_udev) { - return UdevDevice::Ptr(); - } - UdevEnumerate enumerate(this); - enumerate.addMatch(UdevEnumerate::Match::SubSystem, "drm"); - enumerate.addMatch(UdevEnumerate::Match::SysName, "renderD[0-9]*"); - enumerate.scan(); - return enumerate.find([](const UdevDevice::Ptr &device) { - Q_UNUSED(device) - return true; - }); -} - UdevDevice::Ptr Udev::primaryFramebuffer() { if (!m_udev) { diff --git a/udev.h b/udev.h index 88a87e8692..c00520e513 100644 --- a/udev.h +++ b/udev.h @@ -83,8 +83,6 @@ public: } UdevDevice::Ptr primaryGpu(); UdevDevice::Ptr primaryFramebuffer(); - UdevDevice::Ptr virtualGpu(); - UdevDevice::Ptr renderNode(); UdevDevice::Ptr deviceFromSyspath(const char *syspath); UdevMonitor *monitor(); operator udev*() const {