Commit graph

175 commits

Author SHA1 Message Date
Xaver Hugl
5bd938f0f0 platforms/drm: release gbm buffers before eglDestroySurface
BUG: 436500
2021-05-04 17:36:09 +00:00
Adriaan de Groot
49fcadb185 Fix build on 32-bit systems
The added comment explains it all, really: you can't fit a 32-bit
unsigned into a 32-bit (signed) time_t, but we don't care.
2021-05-04 12:34:07 +00:00
Xaver Hugl
bd4a8be319 platforms/drm: fix DrmOutput::updateMode 2021-05-04 10:01:55 +00:00
Xaver Hugl
089134d0bd platforms/drm: GPU power management
When a GPU has no outputs attached we need to release all resources and
close the fd to allow the driver to completely power down the GPU. This
is also required to allow the driver to be unloaded for VFIO.
2021-05-03 18:03:09 +02:00
l10n daemon script
31cdb8676d SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-05-03 01:21:56 +00:00
Ömer Fadıl Usta
a8d7e99874 [plugins/platforms/drm/drm_backend] Fix build for bsd 2021-05-01 19:43:00 +00:00
Vlad Zahorodnii
8d9e47ee22 platforms/drm: Introduce KWIN_DRM_DEVICES
This allows to instruct kwin what drm devices must be used explicitly.

BUG: 435467
2021-05-01 12:14:34 +00:00
Xaver Hugl
faddf0bf5f Wayland: variable refresh rate support
BUG: 405912
2021-04-30 16:18:39 +02:00
Vlad Zahorodnii
706eb16b3a Remove Platform::screenGeometries and Platform::screenScales
If you need screen geometries or scales, use AbstractOutput::geometry()
and AbstractOutput::scale(), respectively.
2021-04-29 11:31:31 +00:00
Vlad Zahorodnii
ac3c09ba75 Remove Platform::areOutputsEnabled()
This flag is redundant. If an output is disabled, the compositor won't
attempt to perform compositing on it.
2021-04-29 10:47:41 +00:00
Vlad Zahorodnii
f8c00a530f Remove Platform::prepareShutdown()
Platform::prepareShutdown() was introduced to work around the issue
where the platform accesses destroyed OutputDeviceInterface objects.

Since we no longer query OutputDeviceInterface for output info, the
Platform::prepareShutdown() function can be dropped.
2021-04-29 10:47:41 +00:00
Vlad Zahorodnii
2200f4ded9 windowsystem: Fix compilation with no deprecated build of KWindowSystem
Highlight window and present windows API has been deprecated in 5.82.
2021-04-29 10:46:39 +03:00
Vlad Zahorodnii
9e1de4522e platforms/drm: Remove unused defs and includes in drm_backend.cpp 2021-04-29 08:45:27 +03:00
Vlad Zahorodnii
c4c46a089f platforms/drm: Properly detect if there are no DRM devices
If no primary gpu can be found, we need to quit.
2021-04-29 05:34:19 +00:00
Vlad Zahorodnii
9f030ecd40 platforms/drm: Enable atomic modesetting in hot plugged gpus
At the moment, if a gpu is hot plugged, it won't have atomic modesetting
enabled.
2021-04-29 05:34:19 +00:00
Vlad Zahorodnii
03c38e02e9 platforms/drm: Remove DrmBackend::findOutput()
It's unused.
2021-04-29 08:10:37 +03:00
Vlad Zahorodnii
54a034b7cf platforms/drm: Use dev nums to find gpus
This way we don't need to convert strings to ints every time
udev_device_get_sysnum() is called.
2021-04-29 04:58:46 +00:00
Vlad Zahorodnii
fe0039091c platforms/drm: Don't search for gpus on add udev event
If a gpu is added, don't search for it pointlessly in m_gpus.
2021-04-29 04:58:46 +00:00
Vlad Zahorodnii
04c3bee803 Remove unused things in drm_backend.h 2021-04-28 22:12:58 +03:00
Xaver Hugl
9cd046f206 platforms/drm: add GPU hotplug support 2021-04-28 18:57:47 +02:00
Xaver Hugl
0284aeb7bb platforms/drm: Don't release drm buffers in EglGbmBackend
When we release the buffers that also removes the drm fbs.
This causes failing atomic commits that the atomic code
doesn't (yet) handle correctly, the result is a black
screen when compositing is restarted.
2021-04-28 13:51:06 +00:00
Xaver Hugl
40eb0e4f0e platforms/drm: only print error for direct scanout when useful
Most wayland-native apps provide buffers that aren't suitable
for direct scanout; the message usually only spams the log full
without proper reason or useful information
2021-04-27 15:22:20 +02:00
Aleix Pol
af6f95b2eb fb: remove unnecessary casts 2021-04-27 15:14:06 +02:00
Aleix Pol
4b3b5fa368 fb: make it easier to run on nomodeset
In the few cases where the framebuffer is needed, we'd get problems
because ioctl(KWIN_FB_NO_VSYNC) fails.
This removes the code entirely to just use a timer to refresh.

BUG: 436053
2021-04-26 12:46:55 +00:00
Vlad Zahorodnii
2c05229141 qpa: Set minimum device ratio of 1 for windows
This is to prevent rendering issues in the present windows close buttons
as Qt supports scale factors that are less than one poorly.
2021-04-26 11:41:37 +00:00
Vlad Zahorodnii
c9ac2e3fb8 decoration: Fix rendering issues with scale factors < 1
QPainter::setWindow() doesn't work as we expect if the device pixel
ratio of the paint device is less than 1, for example 0.5 or 0.75.

QPainter only allows the effective device pixel ratios that are greater
than or equal to 1. This restriction probably has to be lifted.

For the time being, this change introduces a helper function that can be
used to determine the scale factor by which QPainter::window() must be
multiplied.

BUG: 432766
2021-04-26 11:41:37 +00:00
Vlad Zahorodnii
c103eb8f5c qpa: Simplify backing store blitting
We can use QPainter::drawImage() to update the dirty area of the front
buffer. This way, we don't need to call std::copy().
2021-04-26 09:21:34 +00:00
Aleix Pol
b372de8c74 Fix startup when running with ASAN
We can't call kwinApp() before KWin::Application hasn't been properly
initialized.
2021-04-23 09:38:42 +00:00
l10n daemon script
6276c8882e SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-04-23 01:18:39 +00:00
Xaver Hugl
49c650eed2 platforms/drm: don't ignore blob properties without valid blobs
Instead of deleting all blob properties without a valid
blob check for the blob existing before using it. This is
necessary because some properties are needed even without
currently valid blobs.

BUG: 435786
2021-04-22 12:40:48 +00:00
Aleix Pol
b3ddb11b7c drm: hide the cursor as we are setting dpms off
It seems to crash amdgpu and it's consistent with how we're cleaning all
our planes.

BUG: 435941
2021-04-22 10:18:15 +00:00
Aleix Pol
633136d228 drm: remove unused attribute in DrmOutput 2021-04-22 10:17:29 +00:00
Vlad Zahorodnii
0d9185053c platforms/drm: Ignore udev events while session is inactive
While the session is inactive, the drm master permissions are revoked.
Therefore, we cannot perform things such as modesetting, etc. It also
makes no sense to create or destroy DrmOutput objects.

CCBUG: 435941
2021-04-21 23:17:54 +00:00
Aleix Pol
f7526f50fe build... 2021-04-21 17:42:55 +02:00
Aleix Pol
8d186efa08 drm: Do not check egl extensions before setting them up 2021-04-21 17:34:07 +02:00
Xaver Hugl
5a2177a51c platforms/drm: use surfaceless context
On multi-gpu systems it could happen that the primary GPU
has no working outputs attached, yet we still need the
egl context.
2021-04-21 09:06:17 +00:00
Vlad Zahorodnii
700028b37d Fix build 2021-04-20 14:37:43 +03:00
Vlad Zahorodnii
15f1b9792b Revert "platforms/drm: Introduce DrmPipeline"
This reverts commit 5a22deda3b.

We still need more work to finish the DrmPipeline. At the moment, there
are a few major issues, e.g. some outputs not turning on, output
transforms not working correctly, a crash when changing dpms mode.

Let's merge this change back once all major issues are fixed and after
more testing.
2021-04-20 11:34:04 +00:00
Aleix Pol
d999aa6c6a drm: destroy the gbm device after we are done with all of the objects
Just in case they still need to interact with gbm
2021-04-20 13:02:46 +02:00
Aleix Pol
300f28a5a9 drm: remember to clean up DrmGpu's outputs when destroying 2021-04-20 13:02:46 +02:00
Aleix Pol
d5ac0cf919 drm: Also release the pipeline buffer when DrmOutput::releaseBuffers() 2021-04-20 13:02:46 +02:00
Aleix Pol
b82840d7e0 drm: Don't call virtual methods from a parent class destructor
We'd be relying on AbstractEglDrmBackend on calling cleanup but we'd be
doing it when cleanupSurfaces cannot be reached out anymore, turning it
into a half-baked cleanup.

Instead call cleanup from the leaf class destructors.
2021-04-20 13:02:46 +02:00
Xaver Hugl
7a9676dc0a Introduce the legacy flag for drm properties
There are properties like for example rotation
that don't have the atomic flag, yet work and
are needed in atomic mode setting.
2021-04-20 09:22:50 +02:00
Xaver Hugl
0292c4a74c platforms/drm: Add support for setting overscan
BUG: 428201
2021-04-19 18:46:41 +02:00
Xaver Hugl
7dddcf202b platforms/drm: Don't create outputs without primary plane in AMS 2021-04-19 12:12:26 +00:00
Xaver Hugl
5a22deda3b platforms/drm: Introduce DrmPipeline
DrmPipeline is what now contains all the drm bits related to
modesetting and presentation, instead of that being in DrmOutput.
This gives a lot more freedom for managing drm resources and
enables far better usage of the atomic API with guaranteed
immutability for failed tests.
2021-04-16 20:26:34 +02:00
Aleix Pol
b68cd3110a Fix streaming of windows when we are using a mix of scales
At the moment a streamed screen when the screen scale was differnt
buffer scale would render wrong. This change addresses it by
compensating it.

This change compensates it resizing the rendered viewport to their
difference.

BUG: 428594
2021-04-16 17:18:56 +02:00
Aleix Pol
01f7ef35e7 drm: Make sure we read all pending udev events 2021-04-15 15:00:52 +00:00
Aleix Pol
b49c7497fa --warning: remove unused class member 2021-04-15 16:40:38 +02:00
Xaver Hugl
888a08530e Make DrmObject::Property flags const 2021-04-15 11:16:18 +00:00
David Edmundson
ab34fa348c Follow kwindoweffects::windowSizes deprecation 2021-04-15 05:55:46 +00:00
Alois Wohlschlager
59f6b77612
Fix crash when stopping PipeWire streaming
The stream object was deleted from a slot connected to its stopStreaming
signal. This is unsafe and can lead to memory corruption and ultimately
crashes when PipWwire streaming is stopped. Use deleteLater instead.

BUG: 428268 435588
2021-04-13 10:28:15 +02:00
Xaver Hugl
a461ff918d platforms/drm: replace dpms property hack with proper check
Instead of marking the dpms property as immutable, read the
DRM_MODE_PROP_ATOMIC flag and only add atomic properties to
atomic requests.
2021-04-12 19:30:17 +02:00
Xaver Hugl
18f857b1f3 platforms/drm: fix crash with multi-gpu 2021-04-11 20:52:08 +02:00
Vlad Zahorodnii
e88033f914 wayland: Fix blank window thumbnails
With the introduction of stripped down window items, the WindowPixmap
objects no longer form a hierarchy. WindowPixmap::children() method was
removed.

Surprisingly, the removal of the children() method didn't result in a
compilation error because the QObject class has a method with the same
name.

Currently, a window pixmap will have no QObject children even if the
associated wayland surface has child sub-surfaces. This may result in
blank thumbnails of apps that use sub-surfaces, e.g. Firefox. In order
to fix that issue, we need to check if there are child items instead.
2021-04-08 22:15:33 +03:00
Vlad Zahorodnii
24d865ea38 wayland: Generate valid output uuids
Currently, kwin generates invalid output uuids.
2021-04-08 19:04:17 +00:00
Vlad Zahorodnii
d1c5970273 Fix build 2021-04-07 20:49:32 +03:00
Vlad Zahorodnii
da5fc3d9e9 wayland: Wire in subpixel information
kwaylandserver has all the code to send subpixel information but kwin
doesn't really use it.
2021-04-07 16:33:50 +03:00
Vlad Zahorodnii
9d9747490e wayland: Send missing output-device properties
Currently, we don't set eisa id and the serial number.
2021-04-07 15:00:56 +03:00
Vlad Zahorodnii
c27230719c wayland: Move Wayland-specific code out of AbstractWaylandOutput
Currently, output properties are looked up either on the wl_output
object or the output device object. This puts a hard dependency on the
wayland server in the platforms.

This change intends to fix some flaws in the current output
abstractions, and allow creating/destroying wayland-specific globals as
we wish.

With the work done in this patch, the need for the AbstractWaylandOutput
class is unclear, and it might be a good idea to merge it with the base
AbstractOutput class.
2021-04-07 14:23:16 +03:00
Xaver Hugl
50f03ac6dc platforms/drm: improve buffer handling with GbmBuffer 2021-04-06 23:18:25 +02:00
Vlad Zahorodnii
913d242bd9 platforms/drm: Fix crash in EglGbmBackend::presentOnOutput()
If the damage history is empty and EGL_KHR_partial_update is supported,
kwin may crash.
2021-04-06 11:53:26 +03:00
Jan Blackquill
9f215a06fa Fix crash on hotplugging displays while switched to another TTY
Currently, we inhibit renderloops when switching to another TTY, and unhibit
when switching back. When we hotplug a display while switched to another TTY,
its renderloop isn't inhibited by default, yet when we switch back, we try
to uninhibit the fresh renderloop, which triggers an assert.

Inhibiting newly created outputs while switched to another TTY fixes this crash.

BUG: 435388
FIXED-IN: 5.21
2021-04-05 15:08:59 -04:00
Xaver Hugl
8bbd186f8e platform/drm: add dpmsFinishOn to atomicEnable
Without it the output will stay blank after enabling
2021-04-05 11:03:53 +00:00
Xaver Hugl
b2653c45c8 platforms/drm: drop connector name from modelName with serial
The connector name is not relevant to applications or
users - expectation is that the same physical monitor always gets the
same name, regardless of how it's connected. If no serial is available,
fall back to the old scheme to prevent multiple connected outputs from
having the same name.
2021-04-05 11:02:01 +00:00
Vlad Zahorodnii
7054f6b2d6 platforms/drm: Drop stream operator for DrmOutput
There is already one that works for all AbstractOutput classes and
properly restores the state of QDebug.
2021-04-01 18:15:42 +03:00
Vlad Zahorodnii
dd9a1e5320 platforms/drm: Rename DrmCrtc::resIndex()
The value that the DrmCrtc::resIndex() function returns is better known
as "pipe index." This change renames the method to match the terminology
used by kernel developers and other compositor developers.
2021-04-01 14:41:07 +03:00
Vlad Zahorodnii
53796aacb2 platforms/drm: Remove unused parameter in DrmCrtc constructor 2021-04-01 14:41:07 +03:00
Vlad Zahorodnii
d883cccfd3 platforms/drm: Minor coding style fixes
This reformats some code according to the KF coding style.
2021-04-01 14:41:05 +03:00
Vlad Zahorodnii
7926fce598 platforms/drm: Make DrmObject::m_id private
There's already a getter for the object id.
2021-04-01 14:19:48 +03:00
Vlad Zahorodnii
2ea66eb4c3 platforms/drm: Remove unused field in DrmObject 2021-04-01 14:17:46 +03:00
Vlad Zahorodnii
f534b64e5c platforms/drm: Associate drm objects with their gpus
This makes the code more consistent. At the moment, we initialize drm
objects either with the corresponding gpu object or with its fd.
2021-04-01 14:15:42 +03:00
Vlad Zahorodnii
75e7562953 platforms/drm: Fix handling of missing EDID
drmModeGetPropertyBlob() may return null and we should handle that. In
addition to that, m_conn is not initialized in DrmConnector so kwin will
crash whenever the connector info is accessed.
2021-04-01 11:01:53 +00:00
Vlad Zahorodnii
53f7bda7d2 platforms/drm: Make DRM backend less chatty
These warnings can be safely ignored, their priority can be lowered.
2021-04-01 13:21:33 +03:00
Xaver Hugl
2efb9c473d Move Edid and DPMS into DrmConnector 2021-03-31 16:08:33 +00:00
Vlad Zahorodnii
326d211691 platform: Use damage tracked by SurfaceItem
There is no need for both kwin and kwaylandserver track damage.
2021-03-31 13:56:55 +00:00
Vlad Zahorodnii
2ade92d69b platform: Make OpenGLBackend::scanout take SurfaceItem
This allows removing SurfaceInterface::trackedDamage().
2021-03-31 13:56:55 +00:00
Vlad Zahorodnii
47113e09b8 scene: Introduce window items
Currently, dealing with sub-surfaces is very difficult due to the scene
design being heavily influenced by X11 requirements.

The goal of this change is to re-work scene abstractions to make improving
the wayland support easier.

The Item class is based on the QQuickItem class. My hope is that one day
we will be able to transition to QtQuick for painting scene, but in
meanwhile it makes more sense to have a minimalistic internal item class.

The WindowItem class represents a window. The SurfaceItem class represents
the contents of either an X11, or a Wayland, or an internal surface. The
DecorationItem and the ShadowItem class represent the server-side deco and
drop-shadow, respectively.

At the moment, the SurfaceItem is bound to the scene window, but the long
term plan is to break that connection so we could re-use the SurfaceItem
for things such as software cursors and drag-and-drop additional icons.

One of the responsibilities of the Item is to schedule repaints as needed.
Ideally, there shouldn't be any addRepaint() calls in the core code. The
Item class schedules repaints on geometry updates. In the future, it also
has to request an update if its opacity or visibility changes.
2021-03-31 13:56:55 +00:00
Vlad Zahorodnii
0f1afdbdc0 scene: Pass dirty region to SceneOpenGLTexture::updateTexture 2021-03-31 13:56:55 +00:00
Vlad Zahorodnii
0bb5a51da8 x11: Move damage fetching code to X11Compositor
This is needed to make damage fetching specific to X11 surfaces.
2021-03-31 13:56:55 +00:00
Xaver Hugl
c0c3ec09af Refactor DrmObject 2021-03-31 10:19:42 +00:00
Xaver Hugl
e262c8df33 Move pageFlipHandler to DrmGpu 2021-03-30 14:32:43 +02:00
Xaver Hugl
eb7703cd64 Only use drmModeAddFB2WithModifiers if supported 2021-03-23 22:13:00 +00:00
Xaver Hugl
c737fde3da DRM: Use QSharedPointer 2021-03-23 15:47:59 +00:00
Vlad Zahorodnii
ade861d6de Refactor session code
At the moment, the session code is far from being extensible. If we
decide to add support for libseatd, it will be a challenging task with
the current design of session management code. The goal of this
refactoring is to fix that.

Another motivation behind this change is to prepare session related code
for upstreaming to kwayland-server where it belongs.
2021-03-23 08:01:19 +00:00
Xaver Hugl
a8055e4546 Refactor DRM presentation
Presentation doesn't have to go through DrmBackend and by moving
DrmGpu::deleteBufferAfterPageflip into DrmBuffer some code can be
simplified
2021-03-22 13:52:50 +00:00
Xaver Hugl
ca23bca813 Port DrmSurfaceBuffer to drmModeAddFB2 2021-03-19 08:59:58 +00:00
Xaver Hugl
38a15996f4 Consider the opaque region for direct scanout 2021-03-18 23:51:29 +01:00
Xaver Hugl
6569bf80c3 EglGbmBackend: use output reference
CCBUG: 432707
2021-03-18 15:22:31 +01:00
Alexander Lohnau
3cbbdbee99 GIT_SILENT Silence warning about unused parameter in windows runner 2021-03-16 08:45:29 +01:00
Alexander Lohnau
81b40966ed GIT_SILENT Add trailing comma to enums 2021-03-14 18:06:22 +01:00
Aleix Pol
58debd72a3 Only scanout when the texture matches the display size
Otherwise drmModeAtomicCommit() in DrmOutput::doAtomicCommit() fails due
to unmatched buffer sizes.

While rendering continues working properly, this makes drm freak out and
try to go back to a previous state (see the test commit in
presentAtomically()) that in turn starts issuing screen events to every
process even though it's just to say the same thing. The fact that this
happens per frame makes the system unusable as soon as fullscreen starts
happening on a scaled display.

Another thing we could do is get EglGbmBackend::scanout() to take care
of the resizing.
2021-03-11 15:01:09 +01:00
Méven Car
ef19948c00 Reflect changes in kwayland-server changes
https://invent.kde.org/plasma/kwayland-server/-/merge_requests/180
2021-03-11 08:24:33 +00:00
Vlad Zahorodnii
38996d9725 libkwineffects: Introduce EffectScreen
This provides the compositor a way to indicate what output is being
rendered. The effects such as the screenshot can check the provided
screen object in order to function as expected.
2021-03-09 08:58:22 +00:00
Vlad Zahorodnii
b3e7031893 platforms/drm: Fix potential stack corruption
If the file descriptor of the DRM device is greater than FD_SETSIZE, the
stack will be corrupted. However, it is highly unlikely that we ever hit
this case because DRM devices are opened at startup of kwin, so the file
descriptors should small.

In order to prevent the potential stack corruption, this change replaces
the usage of select() with poll().

Unlike select(), the api of poll() is much more sensible. Back 20 or so
years ago the main argument against poll() was that it's not implemented
by all platforms. But, nowadays, it's supported on all major platforms.
2021-03-09 10:27:17 +02:00
Xaver Hugl
7a937fc7af Ignore fully translucent Toplevels for direct scanout 2021-03-05 19:59:48 +01:00
Bhushan Shah
debea631f3 platforms/drm: inhibit the renderloop when screen is turned off
Otherwise we will continue using gpu resources even when we can not show
any content on screen.
2021-03-04 15:01:15 +00:00
Vlad Zahorodnii
691df1ae00 qpa: Use imported targets for QtCore and QtGui private headers 2021-03-04 13:11:27 +00:00
Chaojiang Luo
fdc7e976fe screencast: Add OpenGLES support for screencasting
OpenGLES does not support glGetTextureImage, we use glReadPixels to
replace it.
2021-03-04 09:29:57 +00:00
l10n daemon script
5f7a2806f0 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-03-03 07:52:05 +01:00