diff --git a/TESTING.md b/TESTING.md --- a/TESTING.md +++ b/TESTING.md @@ -10,13 +10,13 @@ * 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 --- a/plugins/platforms/virtual/CMakeLists.txt +++ b/plugins/platforms/virtual/CMakeLists.txt @@ -14,10 +14,6 @@ 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.h b/plugins/platforms/virtual/egl_gbm_backend.h --- a/plugins/platforms/virtual/egl_gbm_backend.h +++ b/plugins/platforms/virtual/egl_gbm_backend.h @@ -49,7 +49,6 @@ 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/egl_gbm_backend.cpp b/plugins/platforms/virtual/egl_gbm_backend.cpp --- a/plugins/platforms/virtual/egl_gbm_backend.cpp +++ b/plugins/platforms/virtual/egl_gbm_backend.cpp @@ -23,19 +23,12 @@ #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 @@ 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 @@ // 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/virtual_backend.h b/plugins/platforms/virtual/virtual_backend.h --- a/plugins/platforms/virtual/virtual_backend.h +++ b/plugins/platforms/virtual/virtual_backend.h @@ -28,8 +28,6 @@ class QTemporaryDir; -struct gbm_device; - namespace KWin { class VirtualOutput; @@ -59,20 +57,6 @@ 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 @@ QVector m_enabledOutputs; QScopedPointer m_screenshotDir; - int m_drmFd = -1; - gbm_device *m_gbmDevice = nullptr; }; } diff --git a/plugins/platforms/virtual/virtual_backend.cpp b/plugins/platforms/virtual/virtual_backend.cpp --- a/plugins/platforms/virtual/virtual_backend.cpp +++ b/plugins/platforms/virtual/virtual_backend.cpp @@ -31,9 +31,6 @@ #include #include #include -#if HAVE_GBM -#include -#endif namespace KWin { @@ -56,14 +53,6 @@ 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/udev.h b/udev.h --- a/udev.h +++ b/udev.h @@ -83,8 +83,6 @@ } UdevDevice::Ptr primaryGpu(); UdevDevice::Ptr primaryFramebuffer(); - UdevDevice::Ptr virtualGpu(); - UdevDevice::Ptr renderNode(); UdevDevice::Ptr deviceFromSyspath(const char *syspath); UdevMonitor *monitor(); operator udev*() const { diff --git a/udev.cpp b/udev.cpp --- a/udev.cpp +++ b/udev.cpp @@ -156,36 +156,6 @@ }); } -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) {