backends/drm,wayland: require gbm
The ifdefs for have_gbm obfuscate the code unnecessarily - the drm backend is not a great experience with qpainter, so in practice noone should ship it without gbm anyways.
This commit is contained in:
parent
87afdb3e01
commit
c68f7f13f3
11 changed files with 30 additions and 86 deletions
|
@ -222,8 +222,7 @@ find_package(Libdrm 2.4.62)
|
|||
set_package_properties(Libdrm PROPERTIES TYPE REQUIRED PURPOSE "Required for drm output on Wayland.")
|
||||
|
||||
find_package(gbm)
|
||||
set_package_properties(gbm PROPERTIES TYPE OPTIONAL PURPOSE "Required for egl output of drm backend.")
|
||||
set(HAVE_GBM ${gbm_FOUND})
|
||||
set_package_properties(gbm PROPERTIES TYPE REQUIRED PURPOSE "Required for egl output of drm backend.")
|
||||
if (${gbm_VERSION} GREATER_EQUAL 21.1)
|
||||
set(HAVE_GBM_BO_GET_FD_FOR_PLANE 1)
|
||||
else()
|
||||
|
|
|
@ -19,24 +19,15 @@ set(DRM_SOURCES
|
|||
drm_abstract_output.cpp
|
||||
drm_virtual_output.cpp
|
||||
drm_lease_output.cpp
|
||||
egl_gbm_backend.cpp
|
||||
drm_buffer_gbm.cpp
|
||||
gbm_surface.cpp
|
||||
gbm_dmabuf.cpp
|
||||
)
|
||||
|
||||
if (HAVE_GBM)
|
||||
set(DRM_SOURCES ${DRM_SOURCES}
|
||||
egl_gbm_backend.cpp
|
||||
drm_buffer_gbm.cpp
|
||||
gbm_surface.cpp
|
||||
gbm_dmabuf.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(KWinWaylandDrmBackend MODULE ${DRM_SOURCES})
|
||||
set_target_properties(KWinWaylandDrmBackend PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/org.kde.kwin.waylandbackends/")
|
||||
target_link_libraries(KWinWaylandDrmBackend kwin Libdrm::Libdrm)
|
||||
|
||||
if (HAVE_GBM)
|
||||
target_link_libraries(KWinWaylandDrmBackend gbm::gbm)
|
||||
endif()
|
||||
target_link_libraries(KWinWaylandDrmBackend kwin Libdrm::Libdrm gbm::gbm)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
|
|
|
@ -27,11 +27,8 @@
|
|||
#include "drm_pipeline.h"
|
||||
#include "drm_virtual_output.h"
|
||||
#include "waylandoutputconfig.h"
|
||||
#if HAVE_GBM
|
||||
#include "egl_gbm_backend.h"
|
||||
#include <gbm.h>
|
||||
#include "gbm_dmabuf.h"
|
||||
#endif
|
||||
// KF5
|
||||
#include <KCoreAddons>
|
||||
#include <KLocalizedString>
|
||||
|
@ -48,6 +45,7 @@
|
|||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
// drm
|
||||
#include <gbm.h>
|
||||
#include <xf86drm.h>
|
||||
#include <libdrm/drm_mode.h>
|
||||
|
||||
|
@ -588,7 +586,6 @@ QPainterBackend *DrmBackend::createQPainterBackend()
|
|||
|
||||
OpenGLBackend *DrmBackend::createOpenGLBackend()
|
||||
{
|
||||
#if HAVE_GBM
|
||||
auto primaryBackend = new EglGbmBackend(this, m_gpus.at(0));
|
||||
AbstractEglBackend::setPrimaryBackend(primaryBackend);
|
||||
EglMultiBackend *backend = new EglMultiBackend(this, primaryBackend);
|
||||
|
@ -596,9 +593,6 @@ OpenGLBackend *DrmBackend::createOpenGLBackend()
|
|||
backend->addGpu(m_gpus[i]);
|
||||
}
|
||||
return backend;
|
||||
#else
|
||||
return Platform::createOpenGLBackend();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DrmBackend::sceneInitialized()
|
||||
|
@ -611,11 +605,7 @@ QVector<CompositingType> DrmBackend::supportedCompositors() const
|
|||
if (selectedCompositor() != NoCompositing) {
|
||||
return {selectedCompositor()};
|
||||
}
|
||||
#if HAVE_GBM
|
||||
return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing};
|
||||
#else
|
||||
return QVector<CompositingType>{QPainterCompositing};
|
||||
#endif
|
||||
}
|
||||
|
||||
QString DrmBackend::supportInformation() const
|
||||
|
@ -650,13 +640,12 @@ void DrmBackend::removeVirtualOutput(AbstractOutput *output)
|
|||
|
||||
DmaBufTexture *DrmBackend::createDmaBufTexture(const QSize &size)
|
||||
{
|
||||
#if HAVE_GBM
|
||||
if (primaryGpu()->eglBackend() && primaryGpu()->gbmDevice()) {
|
||||
primaryGpu()->eglBackend()->makeCurrent();
|
||||
return GbmDmaBuf::createBuffer(size, primaryGpu()->gbmDevice());
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DrmGpu *DrmBackend::primaryGpu() const
|
||||
|
|
|
@ -22,12 +22,8 @@
|
|||
#include "drm_virtual_output.h"
|
||||
#include "wayland_server.h"
|
||||
#include "drm_lease_output.h"
|
||||
|
||||
#if HAVE_GBM
|
||||
#include "egl_gbm_backend.h"
|
||||
#include <gbm.h>
|
||||
#include "gbm_dmabuf.h"
|
||||
#endif
|
||||
// system
|
||||
#include <algorithm>
|
||||
#include <errno.h>
|
||||
|
@ -35,6 +31,7 @@
|
|||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
// drm
|
||||
#include <gbm.h>
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include <libdrm/drm_mode.h>
|
||||
|
@ -80,9 +77,7 @@ DrmGpu::DrmGpu(DrmBackend *backend, const QString &devNode, int fd, dev_t device
|
|||
// find out if this GPU is using the NVidia proprietary driver
|
||||
DrmScopedPointer<drmVersion> version(drmGetVersion(fd));
|
||||
m_isNVidia = strstr(version->name, "nvidia-drm");
|
||||
#if HAVE_GBM
|
||||
m_gbmDevice = gbm_create_device(m_fd);
|
||||
#endif
|
||||
|
||||
m_socketNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
|
||||
connect(m_socketNotifier, &QSocketNotifier::activated, this, &DrmGpu::dispatchEvents);
|
||||
|
@ -142,11 +137,9 @@ DrmGpu::~DrmGpu()
|
|||
qDeleteAll(m_connectors);
|
||||
qDeleteAll(m_planes);
|
||||
delete m_socketNotifier;
|
||||
#if HAVE_GBM
|
||||
if (m_gbmDevice) {
|
||||
gbm_device_destroy(m_gbmDevice);
|
||||
}
|
||||
#endif
|
||||
m_platform->session()->closeRestricted(m_fd);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,14 +21,10 @@
|
|||
#include "session.h"
|
||||
#include "drm_output.h"
|
||||
#include "drm_backend.h"
|
||||
|
||||
#if HAVE_GBM
|
||||
#include <gbm.h>
|
||||
|
||||
#include "egl_gbm_backend.h"
|
||||
#include "drm_buffer_gbm.h"
|
||||
#endif
|
||||
|
||||
#include <gbm.h>
|
||||
#include <drm_fourcc.h>
|
||||
|
||||
namespace KWin
|
||||
|
@ -62,13 +58,9 @@ bool DrmPipeline::present(const QSharedPointer<DrmBuffer> &buffer)
|
|||
return false;
|
||||
}
|
||||
m_primaryBuffer = buffer;
|
||||
bool directScanout = false;
|
||||
#if HAVE_GBM
|
||||
auto buf = dynamic_cast<DrmGbmBuffer*>(buffer.data());
|
||||
// with direct scanout disallow modesets, calling presentFailed() and logging warnings
|
||||
if (auto buf = dynamic_cast<DrmGbmBuffer*>(buffer.data()); buf && buf->clientBuffer()) {
|
||||
directScanout = true;
|
||||
}
|
||||
#endif
|
||||
bool directScanout = buf && buf->clientBuffer();
|
||||
if (gpu()->needsModeset()) {
|
||||
if (directScanout) {
|
||||
return false;
|
||||
|
@ -302,19 +294,18 @@ bool DrmPipeline::checkTestBuffer()
|
|||
checkBuffer(pending.crtc->current());
|
||||
}
|
||||
// if we don't have a fitting buffer already, get or create one
|
||||
if (buffer) {
|
||||
#if HAVE_GBM
|
||||
} else if (backend && m_output) {
|
||||
buffer = backend->renderTestFrame(m_output);
|
||||
} else if (backend && gpu()->gbmDevice()) {
|
||||
gbm_bo *bo = gbm_bo_create(gpu()->gbmDevice(), sourceSize().width(), sourceSize().height(), GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
|
||||
if (!bo) {
|
||||
return false;
|
||||
if (!buffer) {
|
||||
if (backend && m_output) {
|
||||
buffer = backend->renderTestFrame(m_output);
|
||||
} else if (backend && gpu()->gbmDevice()) {
|
||||
gbm_bo *bo = gbm_bo_create(gpu()->gbmDevice(), sourceSize().width(), sourceSize().height(), GBM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
|
||||
if (!bo) {
|
||||
return false;
|
||||
}
|
||||
buffer = QSharedPointer<DrmGbmBuffer>::create(gpu(), bo, nullptr);
|
||||
} else {
|
||||
buffer = QSharedPointer<DrmDumbBuffer>::create(gpu(), sourceSize());
|
||||
}
|
||||
buffer = QSharedPointer<DrmGbmBuffer>::create(gpu(), bo, nullptr);
|
||||
#endif
|
||||
} else {
|
||||
buffer = QSharedPointer<DrmDumbBuffer>::create(gpu(), sourceSize());
|
||||
}
|
||||
if (buffer && buffer->bufferId()) {
|
||||
m_oldTestBuffer = m_primaryBuffer;
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
#include "egl_multi_backend.h"
|
||||
#include <config-kwin.h>
|
||||
#include "logging.h"
|
||||
#if HAVE_GBM
|
||||
#include "egl_gbm_backend.h"
|
||||
#endif
|
||||
#include "drm_backend.h"
|
||||
#include "drm_gpu.h"
|
||||
|
||||
|
@ -112,13 +110,11 @@ bool EglMultiBackend::directScanoutAllowed(AbstractOutput *output) const
|
|||
|
||||
void EglMultiBackend::addGpu(DrmGpu *gpu)
|
||||
{
|
||||
#if HAVE_GBM
|
||||
AbstractEglDrmBackend *backend= new EglGbmBackend(m_platform, gpu);
|
||||
if (m_initialized) {
|
||||
backend->init();
|
||||
}
|
||||
m_backends.append(backend);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EglMultiBackend::removeGpu(DrmGpu *gpu)
|
||||
|
|
|
@ -6,10 +6,7 @@ set(WAYLAND_BACKEND_SOURCES
|
|||
)
|
||||
|
||||
if (HAVE_WAYLAND_EGL)
|
||||
set(WAYLAND_BACKEND_SOURCES egl_wayland_backend.cpp ${WAYLAND_BACKEND_SOURCES})
|
||||
if (HAVE_GBM)
|
||||
list(APPEND WAYLAND_BACKEND_SOURCES ../drm/gbm_dmabuf.cpp)
|
||||
endif()
|
||||
set(WAYLAND_BACKEND_SOURCES egl_wayland_backend.cpp ${WAYLAND_BACKEND_SOURCES} ../drm/gbm_dmabuf.cpp)
|
||||
endif()
|
||||
|
||||
add_library(KWinWaylandWaylandBackend MODULE ${WAYLAND_BACKEND_SOURCES})
|
||||
|
@ -17,10 +14,7 @@ set_target_properties(KWinWaylandWaylandBackend PROPERTIES LIBRARY_OUTPUT_DIRECT
|
|||
target_link_libraries(KWinWaylandWaylandBackend kwin KF5::WaylandClient)
|
||||
|
||||
if (HAVE_WAYLAND_EGL)
|
||||
target_link_libraries(KWinWaylandWaylandBackend Wayland::Egl)
|
||||
if (HAVE_GBM)
|
||||
target_link_libraries(KWinWaylandWaylandBackend gbm::gbm)
|
||||
endif()
|
||||
target_link_libraries(KWinWaylandWaylandBackend Wayland::Egl gbm::gbm)
|
||||
endif()
|
||||
|
||||
install(
|
||||
|
|
|
@ -12,11 +12,9 @@
|
|||
|
||||
#if HAVE_WAYLAND_EGL
|
||||
#include "egl_wayland_backend.h"
|
||||
#if HAVE_GBM
|
||||
#include "../drm/gbm_dmabuf.h"
|
||||
#include <gbm.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "logging.h"
|
||||
#include "renderloop_p.h"
|
||||
#include "scene_qpainter_wayland_backend.h"
|
||||
|
@ -586,7 +584,7 @@ WaylandBackend::WaylandBackend(QObject *parent)
|
|||
connect(this, &WaylandBackend::connectionFailed, qApp, &QCoreApplication::quit);
|
||||
|
||||
|
||||
#if HAVE_GBM && HAVE_WAYLAND_EGL
|
||||
#if HAVE_WAYLAND_EGL
|
||||
char const *drm_render_node = "/dev/dri/renderD128";
|
||||
m_drmFileDescriptor = open(drm_render_node, O_RDWR);
|
||||
if (m_drmFileDescriptor < 0) {
|
||||
|
@ -627,7 +625,7 @@ WaylandBackend::~WaylandBackend()
|
|||
m_connectionThread->quit();
|
||||
m_connectionThread->wait();
|
||||
m_connectionThreadObject->deleteLater();
|
||||
#if HAVE_GBM && HAVE_WAYLAND_EGL
|
||||
#if HAVE_WAYLAND_EGL
|
||||
gbm_device_destroy(m_gbmDevice);
|
||||
close(m_drmFileDescriptor);
|
||||
#endif
|
||||
|
@ -1016,7 +1014,7 @@ void WaylandBackend::addConfiguredOutput(WaylandOutput *output)
|
|||
|
||||
DmaBufTexture *WaylandBackend::createDmaBufTexture(const QSize& size)
|
||||
{
|
||||
#if HAVE_GBM && HAVE_WAYLAND_EGL
|
||||
#if HAVE_WAYLAND_EGL
|
||||
return GbmDmaBuf::createBuffer(size, m_gbmDevice);
|
||||
#else
|
||||
return nullptr;
|
||||
|
|
|
@ -322,7 +322,7 @@ private:
|
|||
KWayland::Client::ServerSideDecorationManager *m_ssdManager = nullptr;
|
||||
KWayland::Client::ServerSideDecorationManager *ssdManager();
|
||||
int m_nextId = 0;
|
||||
#if HAVE_GBM && HAVE_WAYLAND_EGL
|
||||
#if HAVE_WAYLAND_EGL
|
||||
int m_drmFileDescriptor = 0;
|
||||
gbm_device *m_gbmDevice;
|
||||
#endif
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#define KWIN_XCLIPBOARD_SYNC_BIN "${CMAKE_INSTALL_FULL_LIBEXECDIR}/org_kde_kwin_xclipboard_syncer"
|
||||
#cmakedefine01 HAVE_X11_XCB
|
||||
#cmakedefine01 HAVE_X11_XINPUT
|
||||
#cmakedefine01 HAVE_GBM
|
||||
#cmakedefine01 HAVE_GBM_BO_GET_FD_FOR_PLANE
|
||||
#cmakedefine01 HAVE_WAYLAND_EGL
|
||||
#cmakedefine01 HAVE_SYS_PRCTL_H
|
||||
|
|
|
@ -1496,12 +1496,6 @@ QString Workspace::supportInformation() const
|
|||
support.append(yes);
|
||||
#else
|
||||
support.append(no);
|
||||
#endif
|
||||
support.append(QStringLiteral("HAVE_GBM: "));
|
||||
#if HAVE_GBM
|
||||
support.append(yes);
|
||||
#else
|
||||
support.append(no);
|
||||
#endif
|
||||
support.append(QStringLiteral("HAVE_X11_XCB: "));
|
||||
#if HAVE_X11_XCB
|
||||
|
|
Loading…
Reference in a new issue