Commit 825aa4ac authored by Martin Flöser's avatar Martin Flöser

[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
parent c2c92fab
......@@ -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:
......
......@@ -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
......
......@@ -23,19 +23,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "virtual_backend.h"
#include "options.h"
#include "screens.h"
#include "udev.h"
#include <logging.h>
// kwin libs
#include <kwinglplatform.h>
#include <kwinglutils.h>
// Qt
#include <QOpenGLContext>
// system
#include <fcntl.h>
#include <unistd.h>
#if HAVE_GBM
#include <gbm.h>
#endif
namespace KWin
{
......@@ -58,39 +51,6 @@ EglGbmBackend::~EglGbmBackend()
cleanup();
}
void EglGbmBackend::initGbmDevice()
{
if (m_backend->drmFd() != -1) {
// already initialized
return;
}
QScopedPointer<Udev> 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";
}
}
......
......@@ -49,7 +49,6 @@ private:
bool initializeEgl();
bool initBufferConfigs();
bool initRenderingContext();
void initGbmDevice();
VirtualBackend *m_backend;
GLTexture *m_backBuffer = nullptr;
GLRenderTarget *m_fbo = nullptr;
......
......@@ -31,9 +31,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <fcntl.h>
#include <unistd.h>
#include <config-kwin.h>
#if HAVE_GBM
#include <gbm.h>
#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()
......
......@@ -28,8 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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<CompositingType> supportedCompositors() const override {
return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing};
}
......@@ -85,8 +69,6 @@ private:
QVector<VirtualOutput*> m_enabledOutputs;
QScopedPointer<QTemporaryDir> m_screenshotDir;
int m_drmFd = -1;
gbm_device *m_gbmDevice = nullptr;
};
}
......
......@@ -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) {
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment