2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2015-04-09 12:49:32 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
2015-04-09 12:49:32 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2015-04-09 12:49:32 +00:00
|
|
|
#include "drm_backend.h"
|
2016-03-21 14:11:17 +00:00
|
|
|
#include "drm_output.h"
|
2016-08-31 12:00:31 +00:00
|
|
|
#include "drm_object_connector.h"
|
|
|
|
#include "drm_object_crtc.h"
|
|
|
|
#include "drm_object_plane.h"
|
2015-04-13 07:23:03 +00:00
|
|
|
#include "composite.h"
|
2015-04-13 14:25:34 +00:00
|
|
|
#include "cursor.h"
|
2015-05-05 15:27:03 +00:00
|
|
|
#include "logging.h"
|
2015-04-09 12:49:32 +00:00
|
|
|
#include "logind.h"
|
2016-04-13 12:08:38 +00:00
|
|
|
#include "main.h"
|
2015-05-05 11:32:33 +00:00
|
|
|
#include "scene_qpainter_drm_backend.h"
|
2015-04-09 12:49:32 +00:00
|
|
|
#include "udev.h"
|
2015-04-24 10:01:39 +00:00
|
|
|
#include "wayland_server.h"
|
2015-04-10 08:44:07 +00:00
|
|
|
#if HAVE_GBM
|
|
|
|
#include "egl_gbm_backend.h"
|
2016-08-19 14:09:18 +00:00
|
|
|
#include <gbm.h>
|
2020-07-22 17:31:23 +00:00
|
|
|
#include "gbm_dmabuf.h"
|
2015-04-10 08:44:07 +00:00
|
|
|
#endif
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
#if HAVE_EGL_STREAMS
|
|
|
|
#include "egl_stream_backend.h"
|
|
|
|
#endif
|
2015-04-24 10:01:39 +00:00
|
|
|
// KWayland
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/seat_interface.h>
|
2015-04-27 09:06:04 +00:00
|
|
|
// KF5
|
|
|
|
#include <KConfigGroup>
|
2017-09-21 12:52:46 +00:00
|
|
|
#include <KCoreAddons>
|
2015-04-27 09:06:04 +00:00
|
|
|
#include <KLocalizedString>
|
|
|
|
#include <KSharedConfig>
|
2015-04-13 07:23:03 +00:00
|
|
|
// Qt
|
2015-11-02 08:34:32 +00:00
|
|
|
#include <QCryptographicHash>
|
2015-04-13 07:23:03 +00:00
|
|
|
#include <QSocketNotifier>
|
2015-04-13 14:25:34 +00:00
|
|
|
#include <QPainter>
|
2015-04-09 12:49:32 +00:00
|
|
|
// system
|
2018-03-28 23:27:21 +00:00
|
|
|
#include <algorithm>
|
2015-04-09 12:49:32 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
// drm
|
|
|
|
#include <xf86drm.h>
|
|
|
|
#include <libdrm/drm_mode.h>
|
|
|
|
|
2020-10-05 21:05:55 +00:00
|
|
|
#include "drm_gpu.h"
|
2020-11-28 17:53:41 +00:00
|
|
|
#include "egl_multi_backend.h"
|
2020-10-05 21:05:55 +00:00
|
|
|
|
2015-04-13 14:25:34 +00:00
|
|
|
#ifndef DRM_CAP_CURSOR_WIDTH
|
|
|
|
#define DRM_CAP_CURSOR_WIDTH 0x8
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef DRM_CAP_CURSOR_HEIGHT
|
|
|
|
#define DRM_CAP_CURSOR_HEIGHT 0x9
|
|
|
|
#endif
|
|
|
|
|
2017-04-10 04:52:44 +00:00
|
|
|
#define KWIN_DRM_EVENT_CONTEXT_VERSION 2
|
|
|
|
|
2015-04-09 12:49:32 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
DrmBackend::DrmBackend(QObject *parent)
|
2016-04-07 07:18:10 +00:00
|
|
|
: Platform(parent)
|
2015-04-09 12:49:32 +00:00
|
|
|
, m_udev(new Udev)
|
2015-04-24 06:15:55 +00:00
|
|
|
, m_udevMonitor(m_udev->monitor())
|
2016-02-15 14:40:25 +00:00
|
|
|
, m_dpmsFilter()
|
2015-04-09 12:49:32 +00:00
|
|
|
{
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
setSupportsGammaControl(true);
|
2020-11-09 12:19:15 +00:00
|
|
|
setPerScreenRenderingEnabled(true);
|
2019-08-28 18:54:37 +00:00
|
|
|
supportsOutputChanges();
|
2015-04-09 12:49:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DrmBackend::~DrmBackend()
|
|
|
|
{
|
2020-10-05 21:05:55 +00:00
|
|
|
if (m_gpus.size() > 0) {
|
2015-04-14 09:25:16 +00:00
|
|
|
// wait for pageflips
|
|
|
|
while (m_pageFlipsPending != 0) {
|
|
|
|
QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents);
|
|
|
|
}
|
2020-10-05 21:05:55 +00:00
|
|
|
qDeleteAll(m_gpus);
|
2015-04-09 12:49:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrmBackend::init()
|
|
|
|
{
|
|
|
|
LogindIntegration *logind = LogindIntegration::self();
|
|
|
|
auto takeControl = [logind, this]() {
|
|
|
|
if (logind->hasSessionControl()) {
|
|
|
|
openDrm();
|
|
|
|
} else {
|
|
|
|
logind->takeControl();
|
|
|
|
connect(logind, &LogindIntegration::hasSessionControlChanged, this, &DrmBackend::openDrm);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if (logind->isConnected()) {
|
|
|
|
takeControl();
|
|
|
|
} else {
|
|
|
|
connect(logind, &LogindIntegration::connectedChanged, this, takeControl);
|
|
|
|
}
|
2020-11-02 01:28:36 +00:00
|
|
|
connect(logind, &LogindIntegration::prepareForSleep, this, [this] (bool active) {
|
|
|
|
if (!active) {
|
|
|
|
turnOutputsOn();
|
|
|
|
}
|
|
|
|
});
|
2015-04-15 16:26:25 +00:00
|
|
|
}
|
|
|
|
|
2019-09-05 14:59:53 +00:00
|
|
|
void DrmBackend::prepareShutdown()
|
|
|
|
{
|
|
|
|
writeOutputsConfiguration();
|
|
|
|
for (DrmOutput *output : m_outputs) {
|
|
|
|
output->teardown();
|
|
|
|
}
|
|
|
|
Platform::prepareShutdown();
|
|
|
|
}
|
|
|
|
|
2018-03-28 23:27:21 +00:00
|
|
|
Outputs DrmBackend::outputs() const
|
|
|
|
{
|
|
|
|
return m_outputs;
|
|
|
|
}
|
|
|
|
|
|
|
|
Outputs DrmBackend::enabledOutputs() const
|
|
|
|
{
|
|
|
|
return m_enabledOutputs;
|
|
|
|
}
|
|
|
|
|
2019-08-31 08:27:04 +00:00
|
|
|
void DrmBackend::createDpmsFilter()
|
2016-02-15 14:40:25 +00:00
|
|
|
{
|
|
|
|
if (!m_dpmsFilter.isNull()) {
|
|
|
|
// already another output is off
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_dpmsFilter.reset(new DpmsInputEventFilter(this));
|
2017-01-02 19:13:30 +00:00
|
|
|
input()->prependInputEventFilter(m_dpmsFilter.data());
|
2016-02-15 14:40:25 +00:00
|
|
|
}
|
|
|
|
|
2016-02-15 15:30:22 +00:00
|
|
|
void DrmBackend::turnOutputsOn()
|
2016-02-15 14:40:25 +00:00
|
|
|
{
|
|
|
|
m_dpmsFilter.reset();
|
2017-11-21 12:04:30 +00:00
|
|
|
for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) {
|
2020-04-29 15:18:41 +00:00
|
|
|
(*it)->updateDpms(KWaylandServer::OutputInterface::DpmsMode::On);
|
2016-02-15 14:40:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrmBackend::checkOutputsAreOn()
|
|
|
|
{
|
|
|
|
if (m_dpmsFilter.isNull()) {
|
|
|
|
// already disabled, all outputs are on
|
|
|
|
return;
|
|
|
|
}
|
2017-11-21 12:04:30 +00:00
|
|
|
for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) {
|
2016-02-15 14:40:25 +00:00
|
|
|
if (!(*it)->isDpmsEnabled()) {
|
|
|
|
// dpms still disabled, need to keep the filter
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// all outputs are on, disable the filter
|
|
|
|
m_dpmsFilter.reset();
|
|
|
|
}
|
|
|
|
|
2015-04-15 16:26:25 +00:00
|
|
|
void DrmBackend::activate(bool active)
|
|
|
|
{
|
|
|
|
if (active) {
|
2017-05-09 19:29:10 +00:00
|
|
|
qCDebug(KWIN_DRM) << "Activating session.";
|
2015-04-15 16:26:25 +00:00
|
|
|
reactivate();
|
|
|
|
} else {
|
2017-05-09 19:29:10 +00:00
|
|
|
qCDebug(KWIN_DRM) << "Deactivating session.";
|
2015-04-15 16:26:25 +00:00
|
|
|
deactivate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrmBackend::reactivate()
|
|
|
|
{
|
|
|
|
if (m_active) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_active = true;
|
2016-06-28 08:20:27 +00:00
|
|
|
if (!usesSoftwareCursor()) {
|
|
|
|
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
|
|
|
DrmOutput *o = *it;
|
2017-05-09 19:29:10 +00:00
|
|
|
// only relevant in atomic mode
|
|
|
|
o->m_modesetRequested = true;
|
[DRM plugin] Remember static kernel objects, amplify use of DrmCrtc
To get an image from KWin to the screen in the DRM pipeline we combine a CRTC,
an encoder and a connector. These objects are static in the sense, that they
represent real hardware on the graphics card, which doesn't change in a
session. See here for more details:
https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html
Until now we used DrmOutput as the main representation for such an active
rendering pipeline. I.e. it gets created and destroyed on hot plug events of
displays. On the other side we had no fixed representation of the static kernel
objects throughout the lifetime of KWin. This has several disadvantages:
* We always need to query all available static objects on an hot plug event.
* We can't manipulate the frame buffer of a CRTC after an output has been
disconnected
* Adding functionality for driving multiple displays on a single CRTC (i.e.
cloning) would be difficult
* We can't destroy the last frame buffer on display disconnect because the CRTC
still accesses it and have therefore a memory leak on every display disconnect
This patch solves these issues by storing representations of all available CRTC
and Connector objects in DrmBackend on init via DrmCrtc and DrmConnector
instances. On an hotplug event these vectors are looped for a fitting CRTC and
Connector combinations. Buffer handling is moved to the respective CRTC
instance. All changes in overview:
* Query all available CRTCs and Connectors and save for subsequent hotplug
events
* Fix logic errors in `queryResources()`
* Move framebuffers, buffer flip and blank logic in DrmCrtc
* Remove `restoreSaved()`. It isn't necessary and is dangerous if the old
framebuffer was deleted in the meantime. Also could reveal sensitive user
info from old session.
Test Plan:
Login, logout, VT switching, connect and disconnect external monitor, energy
saving mode.
Reviewers: #kwin
Subscribers: kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5118
2017-05-09 18:02:49 +00:00
|
|
|
o->m_crtc->blank();
|
2017-11-05 10:59:24 +00:00
|
|
|
o->showCursor();
|
2020-10-27 11:50:06 +00:00
|
|
|
o->moveCursor();
|
2016-06-28 08:20:27 +00:00
|
|
|
}
|
2015-04-15 16:26:25 +00:00
|
|
|
}
|
|
|
|
// restart compositor
|
|
|
|
m_pageFlipsPending = 0;
|
|
|
|
if (Compositor *compositor = Compositor::self()) {
|
|
|
|
compositor->bufferSwapComplete();
|
|
|
|
compositor->addRepaintFull();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrmBackend::deactivate()
|
|
|
|
{
|
|
|
|
if (!m_active) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// block compositor
|
|
|
|
if (m_pageFlipsPending == 0 && Compositor::self()) {
|
|
|
|
Compositor::self()->aboutToSwapBuffers();
|
|
|
|
}
|
|
|
|
// hide cursor and disable
|
|
|
|
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
|
|
|
DrmOutput *o = *it;
|
|
|
|
o->hideCursor();
|
|
|
|
}
|
|
|
|
m_active = false;
|
2015-04-09 12:49:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-13 07:23:03 +00:00
|
|
|
void DrmBackend::pageFlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data)
|
|
|
|
{
|
|
|
|
Q_UNUSED(fd)
|
|
|
|
Q_UNUSED(frame)
|
|
|
|
Q_UNUSED(sec)
|
|
|
|
Q_UNUSED(usec)
|
2015-04-14 09:25:16 +00:00
|
|
|
auto output = reinterpret_cast<DrmOutput*>(data);
|
2019-08-31 08:27:04 +00:00
|
|
|
|
2015-04-14 09:25:16 +00:00
|
|
|
output->pageFlipped();
|
|
|
|
output->m_backend->m_pageFlipsPending--;
|
|
|
|
if (output->m_backend->m_pageFlipsPending == 0) {
|
|
|
|
// TODO: improve, this currently means we wait for all page flips or all outputs.
|
|
|
|
// It would be better to driver the repaint per output
|
2017-05-09 19:29:10 +00:00
|
|
|
|
2015-04-14 09:25:16 +00:00
|
|
|
if (Compositor::self()) {
|
|
|
|
Compositor::self()->bufferSwapComplete();
|
|
|
|
}
|
2015-04-10 08:44:07 +00:00
|
|
|
}
|
2015-04-13 07:23:03 +00:00
|
|
|
}
|
|
|
|
|
2015-04-09 12:49:32 +00:00
|
|
|
void DrmBackend::openDrm()
|
|
|
|
{
|
2015-04-15 16:26:25 +00:00
|
|
|
connect(LogindIntegration::self(), &LogindIntegration::sessionActiveChanged, this, &DrmBackend::activate);
|
2020-10-05 21:05:55 +00:00
|
|
|
std::vector<UdevDevice::Ptr> devices = m_udev->listGPUs();
|
|
|
|
if (devices.size() == 0) {
|
2015-05-05 15:27:03 +00:00
|
|
|
qCWarning(KWIN_DRM) << "Did not find a GPU";
|
2015-04-09 12:49:32 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-11-27 19:57:24 +00:00
|
|
|
|
2020-10-05 21:05:55 +00:00
|
|
|
for (unsigned int gpu_index = 0; gpu_index < devices.size(); gpu_index++) {
|
|
|
|
auto device = std::move(devices.at(gpu_index));
|
|
|
|
auto devNode = QByteArray(device->devNode());
|
|
|
|
int fd = LogindIntegration::self()->takeDevice(devNode.constData());
|
|
|
|
if (fd < 0) {
|
|
|
|
qCWarning(KWIN_DRM) << "failed to open drm device at" << devNode;
|
|
|
|
return;
|
2015-04-13 07:23:03 +00:00
|
|
|
}
|
2020-10-13 17:09:29 +00:00
|
|
|
|
|
|
|
// try to make a simple drm get resource call, if it fails it is not useful for us
|
|
|
|
drmModeRes *resources = drmModeGetResources(fd);
|
|
|
|
if (!resources) {
|
|
|
|
qCDebug(KWIN_DRM) << "Skipping KMS incapable drm device node at" << devNode;
|
|
|
|
LogindIntegration::self()->releaseDevice(fd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
drmModeFreeResources(resources);
|
|
|
|
|
2020-10-05 21:05:55 +00:00
|
|
|
m_active = true;
|
|
|
|
QSocketNotifier *notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
|
|
|
|
connect(notifier, &QSocketNotifier::activated, this,
|
|
|
|
[fd] {
|
|
|
|
if (!LogindIntegration::self()->isActiveSession()) {
|
|
|
|
return;
|
2016-08-31 12:00:31 +00:00
|
|
|
}
|
2020-10-05 21:05:55 +00:00
|
|
|
drmEventContext e;
|
|
|
|
memset(&e, 0, sizeof e);
|
|
|
|
e.version = KWIN_DRM_EVENT_CONTEXT_VERSION;
|
|
|
|
e.page_flip_handler = pageFlipHandler;
|
|
|
|
drmHandleEvent(fd, &e);
|
2016-08-31 12:00:31 +00:00
|
|
|
}
|
2020-10-05 21:05:55 +00:00
|
|
|
);
|
|
|
|
DrmGpu *gpu = new DrmGpu(this, devNode, fd, device->sysNum());
|
|
|
|
connect(gpu, &DrmGpu::outputAdded, this, &DrmBackend::addOutput);
|
|
|
|
connect(gpu, &DrmGpu::outputRemoved, this, &DrmBackend::removeOutput);
|
2020-11-28 17:53:41 +00:00
|
|
|
if (gpu->useEglStreams()) {
|
|
|
|
// TODO this needs to be removed once EglStreamBackend supports multi-gpu operation
|
|
|
|
if (gpu_index == 0) {
|
|
|
|
m_gpus.append(gpu);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
m_gpus.append(gpu);
|
|
|
|
}
|
2020-10-05 21:05:55 +00:00
|
|
|
}
|
2020-11-27 19:57:24 +00:00
|
|
|
|
2020-10-05 21:05:55 +00:00
|
|
|
// trying to activate Atomic Mode Setting (this means also Universal Planes)
|
|
|
|
if (!qEnvironmentVariableIsSet("KWIN_DRM_NO_AMS")) {
|
|
|
|
for (auto gpu : m_gpus)
|
|
|
|
gpu->tryAMS();
|
2016-08-31 12:00:31 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 10:59:24 +00:00
|
|
|
initCursor();
|
2020-04-07 11:24:08 +00:00
|
|
|
if (!updateOutputs())
|
|
|
|
return;
|
[DRM plugin] Remember static kernel objects, amplify use of DrmCrtc
To get an image from KWin to the screen in the DRM pipeline we combine a CRTC,
an encoder and a connector. These objects are static in the sense, that they
represent real hardware on the graphics card, which doesn't change in a
session. See here for more details:
https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html
Until now we used DrmOutput as the main representation for such an active
rendering pipeline. I.e. it gets created and destroyed on hot plug events of
displays. On the other side we had no fixed representation of the static kernel
objects throughout the lifetime of KWin. This has several disadvantages:
* We always need to query all available static objects on an hot plug event.
* We can't manipulate the frame buffer of a CRTC after an output has been
disconnected
* Adding functionality for driving multiple displays on a single CRTC (i.e.
cloning) would be difficult
* We can't destroy the last frame buffer on display disconnect because the CRTC
still accesses it and have therefore a memory leak on every display disconnect
This patch solves these issues by storing representations of all available CRTC
and Connector objects in DrmBackend on init via DrmCrtc and DrmConnector
instances. On an hotplug event these vectors are looped for a fitting CRTC and
Connector combinations. Buffer handling is moved to the respective CRTC
instance. All changes in overview:
* Query all available CRTCs and Connectors and save for subsequent hotplug
events
* Fix logic errors in `queryResources()`
* Move framebuffers, buffer flip and blank logic in DrmCrtc
* Remove `restoreSaved()`. It isn't necessary and is dangerous if the old
framebuffer was deleted in the meantime. Also could reveal sensitive user
info from old session.
Test Plan:
Login, logout, VT switching, connect and disconnect external monitor, energy
saving mode.
Reviewers: #kwin
Subscribers: kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5118
2017-05-09 18:02:49 +00:00
|
|
|
|
2016-07-11 09:26:03 +00:00
|
|
|
if (m_outputs.isEmpty()) {
|
2020-01-08 00:11:48 +00:00
|
|
|
qCDebug(KWIN_DRM) << "No connected outputs found on startup.";
|
2016-07-11 09:26:03 +00:00
|
|
|
}
|
2020-11-27 19:57:24 +00:00
|
|
|
|
2015-04-24 06:15:55 +00:00
|
|
|
// setup udevMonitor
|
|
|
|
if (m_udevMonitor) {
|
|
|
|
m_udevMonitor->filterSubsystemDevType("drm");
|
|
|
|
const int fd = m_udevMonitor->fd();
|
|
|
|
if (fd != -1) {
|
|
|
|
QSocketNotifier *notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
|
|
|
|
connect(notifier, &QSocketNotifier::activated, this,
|
|
|
|
[this] {
|
|
|
|
auto device = m_udevMonitor->getDevice();
|
|
|
|
if (!device) {
|
|
|
|
return;
|
|
|
|
}
|
2020-10-05 21:05:55 +00:00
|
|
|
bool drm = false;
|
|
|
|
for (auto gpu : m_gpus) {
|
|
|
|
if (gpu->drmId() == device->sysNum()) {
|
|
|
|
drm = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!drm) {
|
2015-04-24 06:15:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (device->hasProperty("HOTPLUG", "1")) {
|
2015-05-05 15:27:03 +00:00
|
|
|
qCDebug(KWIN_DRM) << "Received hot plug event for monitored drm device";
|
2017-05-09 19:29:10 +00:00
|
|
|
updateOutputs();
|
2015-04-24 06:15:55 +00:00
|
|
|
updateCursor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
m_udevMonitor->enable();
|
|
|
|
}
|
|
|
|
}
|
2015-05-05 17:02:52 +00:00
|
|
|
setReady(true);
|
2015-04-09 12:49:32 +00:00
|
|
|
}
|
|
|
|
|
2020-10-05 21:05:55 +00:00
|
|
|
void DrmBackend::addOutput(DrmOutput *o)
|
2015-04-09 12:49:32 +00:00
|
|
|
{
|
2020-10-05 21:05:55 +00:00
|
|
|
m_outputs.append(o);
|
|
|
|
m_enabledOutputs.append(o);
|
|
|
|
emit o->gpu()->outputEnabled(o);
|
2020-11-07 18:27:38 +00:00
|
|
|
emit outputAdded(o);
|
2020-12-09 14:01:29 +00:00
|
|
|
emit outputEnabled(o);
|
2020-10-05 21:05:55 +00:00
|
|
|
}
|
[DRM plugin] Remember static kernel objects, amplify use of DrmCrtc
To get an image from KWin to the screen in the DRM pipeline we combine a CRTC,
an encoder and a connector. These objects are static in the sense, that they
represent real hardware on the graphics card, which doesn't change in a
session. See here for more details:
https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html
Until now we used DrmOutput as the main representation for such an active
rendering pipeline. I.e. it gets created and destroyed on hot plug events of
displays. On the other side we had no fixed representation of the static kernel
objects throughout the lifetime of KWin. This has several disadvantages:
* We always need to query all available static objects on an hot plug event.
* We can't manipulate the frame buffer of a CRTC after an output has been
disconnected
* Adding functionality for driving multiple displays on a single CRTC (i.e.
cloning) would be difficult
* We can't destroy the last frame buffer on display disconnect because the CRTC
still accesses it and have therefore a memory leak on every display disconnect
This patch solves these issues by storing representations of all available CRTC
and Connector objects in DrmBackend on init via DrmCrtc and DrmConnector
instances. On an hotplug event these vectors are looped for a fitting CRTC and
Connector combinations. Buffer handling is moved to the respective CRTC
instance. All changes in overview:
* Query all available CRTCs and Connectors and save for subsequent hotplug
events
* Fix logic errors in `queryResources()`
* Move framebuffers, buffer flip and blank logic in DrmCrtc
* Remove `restoreSaved()`. It isn't necessary and is dangerous if the old
framebuffer was deleted in the meantime. Also could reveal sensitive user
info from old session.
Test Plan:
Login, logout, VT switching, connect and disconnect external monitor, energy
saving mode.
Reviewers: #kwin
Subscribers: kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5118
2017-05-09 18:02:49 +00:00
|
|
|
|
2020-10-05 21:05:55 +00:00
|
|
|
void DrmBackend::removeOutput(DrmOutput *o)
|
|
|
|
{
|
|
|
|
emit o->gpu()->outputDisabled(o);
|
2020-12-09 14:01:29 +00:00
|
|
|
if (m_enabledOutputs.removeOne(o)) {
|
|
|
|
emit outputDisabled(o);
|
|
|
|
}
|
2020-10-05 21:05:55 +00:00
|
|
|
m_outputs.removeOne(o);
|
2020-11-07 18:27:38 +00:00
|
|
|
emit outputRemoved(o);
|
2020-10-05 21:05:55 +00:00
|
|
|
}
|
[DRM plugin] Remember static kernel objects, amplify use of DrmCrtc
To get an image from KWin to the screen in the DRM pipeline we combine a CRTC,
an encoder and a connector. These objects are static in the sense, that they
represent real hardware on the graphics card, which doesn't change in a
session. See here for more details:
https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html
Until now we used DrmOutput as the main representation for such an active
rendering pipeline. I.e. it gets created and destroyed on hot plug events of
displays. On the other side we had no fixed representation of the static kernel
objects throughout the lifetime of KWin. This has several disadvantages:
* We always need to query all available static objects on an hot plug event.
* We can't manipulate the frame buffer of a CRTC after an output has been
disconnected
* Adding functionality for driving multiple displays on a single CRTC (i.e.
cloning) would be difficult
* We can't destroy the last frame buffer on display disconnect because the CRTC
still accesses it and have therefore a memory leak on every display disconnect
This patch solves these issues by storing representations of all available CRTC
and Connector objects in DrmBackend on init via DrmCrtc and DrmConnector
instances. On an hotplug event these vectors are looped for a fitting CRTC and
Connector combinations. Buffer handling is moved to the respective CRTC
instance. All changes in overview:
* Query all available CRTCs and Connectors and save for subsequent hotplug
events
* Fix logic errors in `queryResources()`
* Move framebuffers, buffer flip and blank logic in DrmCrtc
* Remove `restoreSaved()`. It isn't necessary and is dangerous if the old
framebuffer was deleted in the meantime. Also could reveal sensitive user
info from old session.
Test Plan:
Login, logout, VT switching, connect and disconnect external monitor, energy
saving mode.
Reviewers: #kwin
Subscribers: kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5118
2017-05-09 18:02:49 +00:00
|
|
|
|
2020-10-05 21:05:55 +00:00
|
|
|
bool DrmBackend::updateOutputs()
|
|
|
|
{
|
|
|
|
if (m_gpus.size() == 0) {
|
|
|
|
return false;
|
2015-04-09 12:49:32 +00:00
|
|
|
}
|
2020-10-26 17:35:58 +00:00
|
|
|
const auto oldOutputs = m_outputs;
|
2020-11-28 17:53:41 +00:00
|
|
|
for (auto gpu : m_gpus) {
|
2020-10-05 21:05:55 +00:00
|
|
|
gpu->updateOutputs();
|
2020-11-28 17:53:41 +00:00
|
|
|
}
|
2020-11-27 19:57:24 +00:00
|
|
|
|
2020-10-05 21:05:55 +00:00
|
|
|
std::sort(m_outputs.begin(), m_outputs.end(), [] (DrmOutput *a, DrmOutput *b) { return a->m_conn->id() < b->m_conn->id(); });
|
2020-10-26 17:35:58 +00:00
|
|
|
if (oldOutputs != m_outputs) {
|
|
|
|
readOutputsConfiguration();
|
|
|
|
}
|
2020-01-08 00:11:48 +00:00
|
|
|
updateOutputsEnabled();
|
2016-07-11 09:26:03 +00:00
|
|
|
if (!m_outputs.isEmpty()) {
|
|
|
|
emit screensQueried();
|
|
|
|
}
|
2020-04-07 11:24:08 +00:00
|
|
|
return true;
|
2015-11-02 08:34:32 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 20:19:10 +00:00
|
|
|
static QString transformToString(DrmOutput::Transform transform)
|
|
|
|
{
|
|
|
|
switch (transform) {
|
|
|
|
case DrmOutput::Transform::Normal:
|
|
|
|
return QStringLiteral("normal");
|
|
|
|
case DrmOutput::Transform::Rotated90:
|
|
|
|
return QStringLiteral("rotate-90");
|
|
|
|
case DrmOutput::Transform::Rotated180:
|
|
|
|
return QStringLiteral("rotate-180");
|
|
|
|
case DrmOutput::Transform::Rotated270:
|
|
|
|
return QStringLiteral("rotate-270");
|
|
|
|
case DrmOutput::Transform::Flipped:
|
|
|
|
return QStringLiteral("flip");
|
|
|
|
case DrmOutput::Transform::Flipped90:
|
|
|
|
return QStringLiteral("flip-90");
|
|
|
|
case DrmOutput::Transform::Flipped180:
|
|
|
|
return QStringLiteral("flip-180");
|
|
|
|
case DrmOutput::Transform::Flipped270:
|
|
|
|
return QStringLiteral("flip-270");
|
|
|
|
default:
|
|
|
|
return QStringLiteral("normal");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static DrmOutput::Transform stringToTransform(const QString &text)
|
|
|
|
{
|
|
|
|
static const QHash<QString, DrmOutput::Transform> stringToTransform {
|
|
|
|
{ QStringLiteral("normal"), DrmOutput::Transform::Normal },
|
|
|
|
{ QStringLiteral("rotate-90"), DrmOutput::Transform::Rotated90 },
|
|
|
|
{ QStringLiteral("rotate-180"), DrmOutput::Transform::Rotated180 },
|
|
|
|
{ QStringLiteral("rotate-270"), DrmOutput::Transform::Rotated270 },
|
|
|
|
{ QStringLiteral("flip"), DrmOutput::Transform::Flipped },
|
|
|
|
{ QStringLiteral("flip-90"), DrmOutput::Transform::Flipped90 },
|
|
|
|
{ QStringLiteral("flip-180"), DrmOutput::Transform::Flipped180 },
|
|
|
|
{ QStringLiteral("flip-270"), DrmOutput::Transform::Flipped270 }
|
|
|
|
};
|
|
|
|
return stringToTransform.value(text, DrmOutput::Transform::Normal);
|
|
|
|
}
|
|
|
|
|
2015-11-02 08:34:32 +00:00
|
|
|
void DrmBackend::readOutputsConfiguration()
|
|
|
|
{
|
|
|
|
if (m_outputs.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const QByteArray uuid = generateOutputConfigurationUuid();
|
2016-01-29 10:24:18 +00:00
|
|
|
const auto outputGroup = kwinApp()->config()->group("DrmOutputs");
|
2015-11-02 08:34:32 +00:00
|
|
|
const auto configGroup = outputGroup.group(uuid);
|
|
|
|
// default position goes from left to right
|
|
|
|
QPoint pos(0, 0);
|
|
|
|
for (auto it = m_outputs.begin(); it != m_outputs.end(); ++it) {
|
2017-05-11 10:08:03 +00:00
|
|
|
qCDebug(KWIN_DRM) << "Reading output configuration for [" << uuid << "] ["<< (*it)->uuid() << "]";
|
2015-11-02 08:34:32 +00:00
|
|
|
const auto outputConfig = configGroup.group((*it)->uuid());
|
|
|
|
(*it)->setGlobalPos(outputConfig.readEntry<QPoint>("Position", pos));
|
2019-04-24 23:45:14 +00:00
|
|
|
if (outputConfig.hasKey("Scale"))
|
|
|
|
(*it)->setScale(outputConfig.readEntry("Scale", 1.0));
|
2020-10-12 20:19:10 +00:00
|
|
|
(*it)->setTransform(stringToTransform(outputConfig.readEntry("Transform", "normal")));
|
2016-11-14 18:30:29 +00:00
|
|
|
pos.setX(pos.x() + (*it)->geometry().width());
|
2020-12-15 20:20:10 +00:00
|
|
|
if (outputConfig.hasKey("Mode")) {
|
|
|
|
QString mode = outputConfig.readEntry("Mode");
|
|
|
|
QStringList list = mode.split("_");
|
|
|
|
if (list.size() > 1) {
|
|
|
|
QStringList size = list[0].split("x");
|
|
|
|
if (size.size() > 1) {
|
|
|
|
int width = size[0].toInt();
|
|
|
|
int height = size[1].toInt();
|
|
|
|
int refreshRate = list[1].toInt();
|
|
|
|
(*it)->updateMode(width, height, refreshRate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-02 08:34:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-05 17:38:32 +00:00
|
|
|
void DrmBackend::writeOutputsConfiguration()
|
|
|
|
{
|
|
|
|
if (m_outputs.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const QByteArray uuid = generateOutputConfigurationUuid();
|
|
|
|
auto configGroup = KSharedConfig::openConfig()->group("DrmOutputs").group(uuid);
|
|
|
|
// default position goes from left to right
|
|
|
|
for (auto it = m_outputs.cbegin(); it != m_outputs.cend(); ++it) {
|
|
|
|
qCDebug(KWIN_DRM) << "Writing output configuration for [" << uuid << "] ["<< (*it)->uuid() << "]";
|
|
|
|
auto outputConfig = configGroup.group((*it)->uuid());
|
|
|
|
outputConfig.writeEntry("Scale", (*it)->scale());
|
2020-10-12 20:19:10 +00:00
|
|
|
outputConfig.writeEntry("Transform", transformToString((*it)->transform()));
|
2020-12-15 20:20:10 +00:00
|
|
|
QString mode;
|
|
|
|
mode += QString::number((*it)->modeSize().width());
|
|
|
|
mode += "x";
|
|
|
|
mode += QString::number((*it)->modeSize().height());
|
|
|
|
mode += "_";
|
|
|
|
mode += QString::number((*it)->refreshRate());
|
|
|
|
outputConfig.writeEntry("Mode", mode);
|
2019-07-05 17:38:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-02 08:34:32 +00:00
|
|
|
QByteArray DrmBackend::generateOutputConfigurationUuid() const
|
|
|
|
{
|
|
|
|
auto it = m_outputs.constBegin();
|
|
|
|
if (m_outputs.size() == 1) {
|
|
|
|
// special case: one output
|
|
|
|
return (*it)->uuid();
|
|
|
|
}
|
|
|
|
QCryptographicHash hash(QCryptographicHash::Md5);
|
|
|
|
for (; it != m_outputs.constEnd(); ++it) {
|
|
|
|
hash.addData((*it)->uuid());
|
|
|
|
}
|
|
|
|
return hash.result().toHex().left(10);
|
2015-04-09 12:49:32 +00:00
|
|
|
}
|
|
|
|
|
2019-08-31 08:27:04 +00:00
|
|
|
void DrmBackend::enableOutput(DrmOutput *output, bool enable)
|
2016-03-10 18:57:07 +00:00
|
|
|
{
|
2019-08-28 18:54:37 +00:00
|
|
|
if (enable) {
|
2019-08-31 08:27:04 +00:00
|
|
|
Q_ASSERT(!m_enabledOutputs.contains(output));
|
|
|
|
m_enabledOutputs << output;
|
2020-10-05 21:05:55 +00:00
|
|
|
emit output->gpu()->outputEnabled(output);
|
2020-12-09 14:01:29 +00:00
|
|
|
emit outputEnabled(output);
|
2017-11-21 12:04:30 +00:00
|
|
|
} else {
|
2019-08-31 08:27:04 +00:00
|
|
|
Q_ASSERT(m_enabledOutputs.contains(output));
|
|
|
|
m_enabledOutputs.removeOne(output);
|
|
|
|
Q_ASSERT(!m_enabledOutputs.contains(output));
|
2020-10-05 21:05:55 +00:00
|
|
|
emit output->gpu()->outputDisabled(output);
|
2020-12-09 14:01:29 +00:00
|
|
|
emit outputDisabled(output);
|
2017-11-21 12:04:30 +00:00
|
|
|
}
|
2019-08-31 08:27:04 +00:00
|
|
|
updateOutputsEnabled();
|
|
|
|
checkOutputsAreOn();
|
|
|
|
emit screensQueried();
|
2016-03-10 18:57:07 +00:00
|
|
|
}
|
|
|
|
|
2015-04-24 06:15:55 +00:00
|
|
|
DrmOutput *DrmBackend::findOutput(quint32 connector)
|
|
|
|
{
|
|
|
|
auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [connector] (DrmOutput *o) {
|
[DRM plugin] Remember static kernel objects, amplify use of DrmCrtc
To get an image from KWin to the screen in the DRM pipeline we combine a CRTC,
an encoder and a connector. These objects are static in the sense, that they
represent real hardware on the graphics card, which doesn't change in a
session. See here for more details:
https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-kms.html
Until now we used DrmOutput as the main representation for such an active
rendering pipeline. I.e. it gets created and destroyed on hot plug events of
displays. On the other side we had no fixed representation of the static kernel
objects throughout the lifetime of KWin. This has several disadvantages:
* We always need to query all available static objects on an hot plug event.
* We can't manipulate the frame buffer of a CRTC after an output has been
disconnected
* Adding functionality for driving multiple displays on a single CRTC (i.e.
cloning) would be difficult
* We can't destroy the last frame buffer on display disconnect because the CRTC
still accesses it and have therefore a memory leak on every display disconnect
This patch solves these issues by storing representations of all available CRTC
and Connector objects in DrmBackend on init via DrmCrtc and DrmConnector
instances. On an hotplug event these vectors are looped for a fitting CRTC and
Connector combinations. Buffer handling is moved to the respective CRTC
instance. All changes in overview:
* Query all available CRTCs and Connectors and save for subsequent hotplug
events
* Fix logic errors in `queryResources()`
* Move framebuffers, buffer flip and blank logic in DrmCrtc
* Remove `restoreSaved()`. It isn't necessary and is dangerous if the old
framebuffer was deleted in the meantime. Also could reveal sensitive user
info from old session.
Test Plan:
Login, logout, VT switching, connect and disconnect external monitor, energy
saving mode.
Reviewers: #kwin
Subscribers: kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5118
2017-05-09 18:02:49 +00:00
|
|
|
return o->m_conn->id() == connector;
|
2015-04-24 06:15:55 +00:00
|
|
|
});
|
|
|
|
if (it != m_outputs.constEnd()) {
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
bool DrmBackend::present(DrmBuffer *buffer, DrmOutput *output)
|
2015-04-17 09:16:00 +00:00
|
|
|
{
|
2017-07-14 11:42:52 +00:00
|
|
|
if (!buffer || buffer->bufferId() == 0) {
|
2020-10-25 17:47:58 +00:00
|
|
|
if (output->gpu()->deleteBufferAfterPageFlip()) {
|
2017-07-14 11:42:52 +00:00
|
|
|
delete buffer;
|
|
|
|
}
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
return false;
|
2017-07-14 11:42:52 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 09:16:00 +00:00
|
|
|
if (output->present(buffer)) {
|
2015-04-14 09:25:16 +00:00
|
|
|
m_pageFlipsPending++;
|
|
|
|
if (m_pageFlipsPending == 1 && Compositor::self()) {
|
|
|
|
Compositor::self()->aboutToSwapBuffers();
|
|
|
|
}
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
return true;
|
2020-10-25 17:47:58 +00:00
|
|
|
} else if (output->gpu()->deleteBufferAfterPageFlip()) {
|
2017-07-14 11:42:52 +00:00
|
|
|
delete buffer;
|
2015-04-13 07:23:03 +00:00
|
|
|
}
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
return false;
|
2015-04-09 12:49:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-13 14:25:34 +00:00
|
|
|
void DrmBackend::initCursor()
|
|
|
|
{
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
|
|
|
|
#if HAVE_EGL_STREAMS
|
|
|
|
// Hardware cursors aren't currently supported with EGLStream backend,
|
|
|
|
// possibly an NVIDIA driver bug
|
2020-10-25 17:47:58 +00:00
|
|
|
bool needsSoftwareCursor = false;
|
|
|
|
for (auto gpu : qAsConst(m_gpus)) {
|
|
|
|
if (gpu->useEglStreams()) {
|
|
|
|
needsSoftwareCursor = true;
|
|
|
|
break;
|
|
|
|
}
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
}
|
2020-10-28 07:03:09 +00:00
|
|
|
setSoftwareCursorForced(needsSoftwareCursor);
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-27 09:40:38 +00:00
|
|
|
if (waylandServer()->seat()->hasPointer()) {
|
|
|
|
// The cursor is visible by default, do nothing.
|
|
|
|
} else {
|
|
|
|
hideCursor();
|
|
|
|
}
|
|
|
|
|
2020-04-29 15:18:41 +00:00
|
|
|
connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::hasPointerChanged, this,
|
2016-05-25 09:24:45 +00:00
|
|
|
[this] {
|
2020-10-27 09:40:38 +00:00
|
|
|
if (waylandServer()->seat()->hasPointer()) {
|
|
|
|
showCursor();
|
|
|
|
} else {
|
|
|
|
hideCursor();
|
2016-05-25 09:24:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2015-04-13 14:25:34 +00:00
|
|
|
// now we have screens and can set cursors, so start tracking
|
2020-04-02 16:18:01 +00:00
|
|
|
connect(Cursors::self(), &Cursors::currentCursorChanged, this, &DrmBackend::updateCursor);
|
|
|
|
connect(Cursors::self(), &Cursors::positionChanged, this, &DrmBackend::moveCursor);
|
2015-04-13 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrmBackend::updateCursor()
|
|
|
|
{
|
2020-10-28 07:03:09 +00:00
|
|
|
if (isSoftwareCursorForced() || isCursorHidden()) {
|
2016-10-20 08:21:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-04-02 16:18:01 +00:00
|
|
|
|
|
|
|
auto cursor = Cursors::self()->currentCursor();
|
2020-10-28 07:03:09 +00:00
|
|
|
if (cursor->image().isNull()) {
|
2016-10-20 08:21:54 +00:00
|
|
|
doHideCursor();
|
2015-04-13 14:25:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-28 07:03:09 +00:00
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
for (DrmOutput *output : qAsConst(m_outputs)) {
|
|
|
|
success = output->updateCursor();
|
|
|
|
if (!success) {
|
|
|
|
qCDebug(KWIN_DRM) << "Failed to update cursor on output" << output->name();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
success = output->showCursor();
|
|
|
|
if (!success) {
|
|
|
|
qCDebug(KWIN_DRM) << "Failed to show cursor on output" << output->name();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
output->moveCursor();
|
|
|
|
}
|
2020-04-02 16:18:01 +00:00
|
|
|
|
2020-10-28 07:03:09 +00:00
|
|
|
setSoftwareCursor(!success);
|
2015-04-13 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2016-10-20 08:21:54 +00:00
|
|
|
void DrmBackend::doShowCursor()
|
|
|
|
{
|
2020-10-28 07:03:09 +00:00
|
|
|
if (usesSoftwareCursor()) {
|
|
|
|
return;
|
|
|
|
}
|
2016-10-20 08:21:54 +00:00
|
|
|
updateCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrmBackend::doHideCursor()
|
2015-04-13 14:25:34 +00:00
|
|
|
{
|
2020-10-27 09:40:38 +00:00
|
|
|
if (usesSoftwareCursor()) {
|
2016-05-25 09:24:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-04-14 09:25:16 +00:00
|
|
|
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
|
|
|
(*it)->hideCursor();
|
|
|
|
}
|
2015-04-13 14:25:34 +00:00
|
|
|
}
|
|
|
|
|
2020-10-28 07:03:09 +00:00
|
|
|
void DrmBackend::doSetSoftwareCursor()
|
|
|
|
{
|
|
|
|
if (isCursorHidden() || !usesSoftwareCursor()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
|
|
|
(*it)->hideCursor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-27 11:50:06 +00:00
|
|
|
void DrmBackend::moveCursor()
|
2015-04-13 14:25:34 +00:00
|
|
|
{
|
2020-10-27 09:40:38 +00:00
|
|
|
if (isCursorHidden() || usesSoftwareCursor()) {
|
2016-05-25 09:24:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-04-14 09:25:16 +00:00
|
|
|
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
2020-10-27 11:50:06 +00:00
|
|
|
(*it)->moveCursor();
|
2015-04-14 09:25:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-09 12:49:32 +00:00
|
|
|
QPainterBackend *DrmBackend::createQPainterBackend()
|
|
|
|
{
|
2020-10-25 17:47:58 +00:00
|
|
|
m_gpus.at(0)->setDeleteBufferAfterPageFlip(false);
|
2020-10-05 21:05:55 +00:00
|
|
|
return new DrmQPainterBackend(this, m_gpus.at(0));
|
2015-04-09 12:49:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-10 08:44:07 +00:00
|
|
|
OpenGLBackend *DrmBackend::createOpenGLBackend()
|
|
|
|
{
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
#if HAVE_EGL_STREAMS
|
2020-10-25 17:47:58 +00:00
|
|
|
if (m_gpus.at(0)->useEglStreams()) {
|
2020-11-28 17:53:41 +00:00
|
|
|
auto backend = new EglStreamBackend(this, m_gpus.at(0));
|
|
|
|
AbstractEglBackend::setPrimaryBackend(backend);
|
|
|
|
return backend;
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-10 08:44:07 +00:00
|
|
|
#if HAVE_GBM
|
2020-11-28 17:53:41 +00:00
|
|
|
auto backend0 = new EglGbmBackend(this, m_gpus.at(0));
|
|
|
|
AbstractEglBackend::setPrimaryBackend(backend0);
|
|
|
|
EglMultiBackend *backend = new EglMultiBackend(backend0);
|
|
|
|
for (int i = 1; i < m_gpus.count(); i++) {
|
|
|
|
auto backendi = new EglGbmBackend(this, m_gpus.at(i));
|
|
|
|
backend->addBackend(backendi);
|
|
|
|
}
|
|
|
|
return backend;
|
2015-04-24 13:14:53 +00:00
|
|
|
#else
|
2016-04-07 07:18:10 +00:00
|
|
|
return Platform::createOpenGLBackend();
|
2015-04-24 13:14:53 +00:00
|
|
|
#endif
|
2015-04-10 08:44:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-31 08:27:04 +00:00
|
|
|
void DrmBackend::updateOutputsEnabled()
|
2015-08-31 09:41:19 +00:00
|
|
|
{
|
|
|
|
bool enabled = false;
|
2017-11-21 12:04:30 +00:00
|
|
|
for (auto it = m_enabledOutputs.constBegin(); it != m_enabledOutputs.constEnd(); ++it) {
|
2015-08-31 09:41:19 +00:00
|
|
|
enabled = enabled || (*it)->isDpmsEnabled();
|
|
|
|
}
|
|
|
|
setOutputsEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
2017-10-15 20:24:49 +00:00
|
|
|
QVector<CompositingType> DrmBackend::supportedCompositors() const
|
|
|
|
{
|
2019-02-16 19:50:46 +00:00
|
|
|
if (selectedCompositor() != NoCompositing) {
|
|
|
|
return {selectedCompositor()};
|
|
|
|
}
|
2017-10-15 20:24:49 +00:00
|
|
|
#if HAVE_GBM
|
|
|
|
return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing};
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
#elif HAVE_EGL_STREAMS
|
2020-10-25 17:47:58 +00:00
|
|
|
return m_gpus.at(0)->useEglStreams() ?
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
QVector<CompositingType>{OpenGLCompositing, QPainterCompositing} :
|
|
|
|
QVector<CompositingType>{QPainterCompositing};
|
2017-10-15 20:24:49 +00:00
|
|
|
#else
|
|
|
|
return QVector<CompositingType>{QPainterCompositing};
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-11-07 19:12:51 +00:00
|
|
|
QString DrmBackend::supportInformation() const
|
|
|
|
{
|
|
|
|
QString supportInfo;
|
|
|
|
QDebug s(&supportInfo);
|
|
|
|
s.nospace();
|
2020-04-24 06:43:46 +00:00
|
|
|
s << "Name: " << "DRM" << Qt::endl;
|
|
|
|
s << "Active: " << m_active << Qt::endl;
|
2020-10-05 21:05:55 +00:00
|
|
|
for (int g = 0; g < m_gpus.size(); g++) {
|
|
|
|
s << "Atomic Mode Setting on GPU " << g << ": " << m_gpus.at(g)->atomicModeSetting() << Qt::endl;
|
|
|
|
}
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
#if HAVE_EGL_STREAMS
|
2020-10-25 17:47:58 +00:00
|
|
|
s << "Using EGL Streams: " << m_gpus.at(0)->useEglStreams() << Qt::endl;
|
[platforms/drm] EGLStream DRM Backend Initial Implementation
Summary:
This is the initial implementation of a DRM backend based on the EGLDevice,
EGLOutput, and EGLStream extensions, supporting NVIDIA graphics hardware using
their proprietary driver. The new backend will be used if the environment
variable KWIN_DRM_USE_EGL_STREAMS is set. On initialization, it will attempt to
create an EGLDevice based on the DRM device currently in use and create
EGLOutputs and EGLStreams for any attached displays. These are used to control
presentation of the final composited frame. Additionally, it will register the
wl_eglstream_controller Wayland interface so that native EGL windows created by
clients can be attached to an EGLStream allowing buffer contents to be shared
with the compositor as a GL texture.
At this time there are two known bugs in the NVIDIA driver's EGL implementation
affecting desktop functionality. The first can result in tooltip windows drawn
by plasmashell to contain incorrect contents. The second prevents KWayland from
being able to query the format of EGLStream-backed buffers which interferes
with the blur effect. Fixes for both of these are currently in development and
should appear in an upcoming NVIDIA driver release.
Additionally, hardware cursors are currently not supported with this backend.
Enabling them causes the desktop to intermittently hang for several seconds.
This is also likely a bug in the NVIDIA DRM-KMS implementation but the root
cause is still under investigation.
Test Plan:
On a system with an NVIDIA graphics card running a recent release of their
proprietary driver
* Ensure the nvidia_drm kernel module is loaded with the option "modeset=1"
("# cat /sys/module/nvidia_drm/parameters/modeset" should print "Y")
* Ensure EGL external platform support is installed
https://github.com/NVIDIA/eglexternalplatform
* Ensure KWin was build with the CMake option
KWIN_BUILD_EGL_STREAM_BACKEND=ON (this is the default)
* Start a plasma wayland session with the environment variable
KWIN_DRM_USE_EGL_STREAMS set
* Ensure output from KWin OpenGL initialization indicates the NVIDIA EGL
driver is in use (as opposed to Mesa / llvmpipe).
* Desktop should be fully functional and perform smoothly.
Reviewers: #kwin, romangg, davidedmundson
Reviewed By: #kwin, romangg, davidedmundson
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D18570
2019-04-15 14:26:22 +00:00
|
|
|
#endif
|
2017-11-07 19:12:51 +00:00
|
|
|
return supportInfo;
|
|
|
|
}
|
|
|
|
|
2020-07-22 17:31:23 +00:00
|
|
|
DmaBufTexture *DrmBackend::createDmaBufTexture(const QSize &size)
|
|
|
|
{
|
|
|
|
#if HAVE_GBM
|
2020-10-05 21:05:55 +00:00
|
|
|
// as the first GPU is assumed to always be the one used for scene rendering
|
2020-11-28 17:53:41 +00:00
|
|
|
// make sure we're on the right context:
|
|
|
|
m_gpus.at(0)->eglBackend()->makeCurrent();
|
2020-10-05 21:05:55 +00:00
|
|
|
return GbmDmaBuf::createBuffer(size, m_gpus.at(0)->gbmDevice());
|
2020-07-22 17:31:23 +00:00
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-04-09 12:49:32 +00:00
|
|
|
}
|