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
Summary: We need to set the viewport so that we scale from device pixels to global compositor space.
Test Plan:
Ran kwin_wayland properly on my laptop without setting KWIN_COMPOSE.
Most things worked.
Reviewers: #plasma
Subscribers: plasma-devel, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3504
Summary:
Libdrm 2.4.78 introduces a version 2 and if KWin gets built against it
our code would break. Given that this change is for Plasma/5.8 branch.
Closes T5839
Reviewers: #kwin, #plasma
Subscribers: plasma-devel, kwin
Tags: #kwin
Maniphest Tasks: T5839
Differential Revision: https://phabricator.kde.org/D5380
Summary:
Cursors are drawn low level, so need to go from global compositor space
to device space
(multiplied by the out scale)
Test Plan: Elements interacted underneath where the mouse was
Reviewers: #plasma
Subscribers: plasma-devel, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3499
Test Plan:
For the first time, actually plugged in my high DPI laptop.
Tested both 1x and 2x windows on 2 real displays one high DPI, one normal
Reviewers: #plasma
Subscribers: plasma-devel, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3498
The logic on page flips was inconsistent in the sense, that it should never
release a GBM buffer before it's not used (i.e. viewable on the display)
anymore. This happened unintended until now (on page flip we never really
did something useful in the else statement, because if we're here it's not
a GBM buffer anyway).
With this patch we:
* delete on page flips always only the old buffer, which is not used anymore
* release the buffer earlier on interrupts like display disconnect in order
to be able to destroy the EGL context
Test Plan:
Tested in non atomic mode (atomic mode is obsolete right now until my other
WIP patch D4539 is ready to be merged): Login, logout, suspend, normal use.
Reviewers: #kwin, graesslin
Reviewed By: #kwin, graesslin
Subscribers: plasma-devel, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5060
Summary:
This isn't used and if it was would give the wrong value.
Actual correct size can be determined via Screens object.
Test Plan:
Grepped it's not overriding anything
Compiles
Reviewers: #plasma
Subscribers: plasma-devel, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3385
Summary:
to uniquely identify screens (in QScreen::name()) add the conenctor
name and id (such as HDMI-A-1) to the model identification
Test Plan: tested a full plasma session
Reviewers: #plasma, graesslin
Reviewed By: #plasma, graesslin
Subscribers: graesslin, plasma-devel, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D3341
Summary:
Some platforms support to hide and show the cursor. This will be needed
by e.g. the zoom effect which currently only provides this functionality
on X11.
This change introduces a new method in the Platform to hide and show the
cursor. The methods need to be called balanced and the implementation
takes care of only showing again if all hide got matched by a show.
The actual hiding and showing is performed in the platform plugins. So
far the DRM and X11/Standalone platforms implement the required
functionality, though other platforms probably could implement as well.
Reviewers: #kwin, #plasma_on_wayland
Subscribers: plasma-devel, kwin
Tags: #plasma_on_wayland, #kwin
Differential Revision: https://phabricator.kde.org/D3119
This is Milestone 1 of full support of Atomic Mode Setting (AMS) and
Universal Planes in the KWin DRM backend.
With Milestone 1 we can use the primary plane of a DRM output and do an
AMS commit (this means mode setting aswell as page flipping), if the
driver supports it. Until now the functionality is only tested on Intel
graphics. You need the drm-next kernel for most recent DRM kernel
developments. As boot option set "i915.nuclear_pageflip". Additionally
at the moment AMS is still hidden behind the environment variable
KWIN_DRM_AMS. Set it, if you want to try out AMS.
What needs to be done next: Make it possible to transfer EGL buffers
directly to planes and implement logic for deciding about using a plane
or not for a specific buffer.
You can read more about it on LWN:
https://lwn.net/Articles/653071
And on Martin's blog:
https://blog.martin-graesslin.com/blog/2015/08/layered-compositing/
I used as model previous work by Daniel Stone for Weston:
https://git.collabora.com/cgit/user/daniels/weston.git
Reviewed-by: mgraesslin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D2370
Just like 4e7392b907:
the ownership of the gbm_device must be passed to the Platform as
the ownership of the EGLDisplay is also passed to the Platform and
we may not destroy the gbm_device for an EGLDisplay we are still using.
With this change I could restart the OpenGL compositor successfully
and switch from OpenGL 3.1 to OpenGL 2 without a crash or rendering
issues.
Screens::init sets up a Qt::QueuedConnection connect from countChanged
to changed. This means that when first setting up the connection a
changed signal will be delivered in the next event cycle. This can mess
with other code. E.g. WaylandServer recreating outputs which can make
Xwayland crash or KWin internally crash.
To solve this problem we just need to make sure to set the output count
to the initial value before performing the init.
Reviewed-By: bshah
Summary:
KWin needs to support restarting the OpenGL compositor in case of a
graphics reset event.
On Wayland the tricky part is that the applications should not notice
this. Most importantly KWin cannot just destroy the EGLDisplay and create
a new one. But this is how a restart works: the complete compositor gets
torn down and recreated - including the EGLDisplay.
This change moves ownership of the EGLDisplay to the Platform.
The AbstractEglBackend subclasses query the Platform whether there is
already an EGLDisplay. Only if there is no EGLDisplay the EGLDisplay is
created and only if no EGLDisplay is registered with Wayland the bind
is performed.
Another change is regarding the destruction: the AbstractEglDisplay does
no longer unbind the Wayland display and does no longer destroy the
EGLDisplay. The EGLDisplay is destroyed by the Platform - so very late
on application exit. The Wayland display is unbound when the Compositor
terminates.
Test Plan:
Limited testing with the added auto-test. This one needs to
be extended to fully verify that OpenGL applications continue to work.
But this requires build.kde.org to support OpenGL on Wayland.
Reviewers: #kwin, #plasma_on_wayland
Subscribers: plasma-devel, kwin
Tags: #plasma_on_wayland, #kwin
Differential Revision: https://phabricator.kde.org/D2202
For virtual machines with Cirrus device the drmModeAddFB fails. So
far there was no error message at all, we only saw it failed.
With this change the drmModeAddFB is checked for error and a warning
is shown. Also further debug messages are added for other cases where
things can fail.
Reviewed-By: Eike Hein
Summary:
If it's not possible to create a buffer to blank the output, KWin won't
be able to render to the output. In that case the output should not be
added to the list of outputs.
To support this DrmOutput::blank and DrmOutput::init return bool to
indicate whether they succeeded. DrmBackend handles this situation and
doesn't add the output to the list of outputs if init failed.
If after init there are no outputs KWin is in a state where it won't
be functional. Thus the platform emits the initFailed signal to
terminate.
BUG: 365242
FIXED-IN: 5.7.2
Test Plan: No hardware to reproduce the condition
Reviewers: #kwin, #plasma_on_wayland
Subscribers: plasma-devel, kwin
Tags: #plasma_on_wayland, #kwin
Differential Revision: https://phabricator.kde.org/D2135
Summary:
So far the drm platform did not verify whether creating and mapping a
DrmBuffer for a cursor works. This could result in a crash in the worst
case.
This change verfies whether mapping the two cursor buffers works, if
not software cursor is enabled. The code is adjusted to ensure that
none of the cursor buffers is accessed in case software cursor are
enabled.
Please note that right now the drm platform's rendering does not
support software cursors. Thus currently this change results in no
cursor at all. This will be addressed by following patches.
BUG: 364740
FIXED-IN: 5.7
Test Plan:
Verfied that it properly falls back to software cursor,
but could not verify that the crash is actually fixed.
Reviewers: #kwin, #plasma_on_wayland
Subscribers: plasma-devel, kwin
Tags: #plasma_on_wayland, #kwin
Differential Revision: https://phabricator.kde.org/D2026
Summary:
When we get a configuration request, we also need to update the global
position on the DrmOutput, otherwise Wayland will know about the new
position, but KWin internally does not.
In addition we also need to trigger the changed signal on KWin::Screens,
so that internally code can react on the change.
With this change configuring layout of connected screens in KScreen
does work also in KWin.
Reviewers: #kwin, #plasma_on_wayland, sebas
Subscribers: plasma-devel, kwin
Tags: #plasma_on_wayland, #kwin
Differential Revision: https://phabricator.kde.org/D1858
Summary:
When the pointer device gets plugged off the cursor is hidden, when
a pointer device gets plugged in the cursor is shown again.
This allows to easily turn a tablet into a proper system by showing
the cursor only when it makes sense.
Test Plan: Tested on exopc with external mouse
Reviewers: #plasma
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D1682
Summary: This seems to just have been forgotten here.
Test Plan: Builds
Reviewers: graesslin
Reviewed By: graesslin
Subscribers: plasma-devel
Projects: #plasma
Differential Revision: https://phabricator.kde.org/D1499
Summary:
Source code reorganization:
The base class AbstractBackend got renamed to Platform, thus the
"backends" are "platforms" now. As they are plugins they should go
together with other KWin plugins which are nowadays in the folder
plugins.
So new location is plugins/platforms/
Reviewers: #plasma, sebas
Subscribers: plasma-devel
Projects: #plasma
Differential Revision: https://phabricator.kde.org/D1353