Commit graph

322 commits

Author SHA1 Message Date
Xaver Hugl
18a72f7187 backends/drm: also force linear layout for dumb buffer cursors
While it usually shouldn't make a difference, it ensures that the buffer import
always works properly

CCBUG: 456306
2022-10-04 07:33:59 +00:00
Xaver Hugl
ae4dd73e99 backends/drm: use linear buffers for multi gpu where necessary 2022-10-03 10:44:51 +00:00
Xaver Hugl
1f92dc5e5d backends/drm: correct test buffer check
There can be situations where the surface fits but there's no test buffer yet
2022-10-03 10:44:51 +00:00
Vlad Zahorodnii
1d8c9c62cf backends/drm: Fix 100% cpu usage after tty switch
The drm fd can get stuck in readable state, in which case the
QSocketNotifier will fire the activated signal as often as it can
leading to high cpu usage.

We need to read() the drm fd in order to make the socket notifier stop
firing QSocketNotifier::activated.

This change removes the m_platform->isActive() check to ensure that
drmHandleEvent() gets called, in general, it should be safe as we only
notify the outputs about completed pageflips.

BUG: 452726
2022-09-27 07:29:05 +00:00
Fabian Vogt
494feb2eea Fix build with older libgbm
The code for the !HAVE_GBM_BO_GET_FD_FOR_PLANE case needed an explicit
constructor call.
2022-09-16 17:51:36 +00:00
Xaver Hugl
1a902b1dec backends/drm: supress warning for disconnected connector
It just pollutes the log with useless information
2022-09-16 01:43:08 +02:00
Xaver Hugl
eccfbbd6fd backends/drm: turn all outputs on when new output is hotplugged
Otherwise only the new output is turned on, which is a bit weird
2022-09-14 12:58:39 +02:00
Vlad Zahorodnii
a1e1d72f4b backends/drm: Emit Platform::outputsQueried signal after removing virtual output
It's needed so the Workspace can react to output removal.
2022-09-13 18:53:47 +00:00
Vlad Zahorodnii
d1de19e212 Make Workspace process batched output updates
Currently the Workspace processes output updates as they occur, e.g.
when the drm backend scans connectors, the Workspace will handle
hotplugged outputs one by one or if an output configuration changes the
mode of several outputs, the workspace will process output layout
updates one by one instead of handling it in one pass. The main reason
for the current behavior is simplicity.

However, that can create issues because it's possible that the output
layout will be temporarily in degenerate state and features such as
sticking windows to their outputs will be broken.

In order to fix that, this change makes the Workspace process batched
output updates. There are several challenges - disconnected outputs have
to be alive when the outputsQueried signal is emitted, the workspace
needs to determine what outputs have been added or removed on its own.
2022-09-12 08:03:48 +00:00
Vlad Zahorodnii
e0945886ed Rename Platform::screensQueried() to Platform::outputsQueried()
It makes the vocabulary consistent. We use the word "output" more than
"screen."
2022-09-12 08:03:48 +00:00
Vlad Zahorodnii
dbef4fa3f0 backends/drm: Rework GPU removal
The proposed way to handle unplugged gpus allows us to ensure that
removed outputs' lifetime can be extended to the moment when the
Platform::outputsQueried signal is emitted.

Besides that, it's possible to extend this code a bit further to make
sure that output updates are batched when hotplugging multiple gpus,
e.g. after resuming, etc.
2022-09-12 08:03:48 +00:00
Vlad Zahorodnii
3d1b3c9c66 backends/drm: Store hardware and virtual outputs in two different lists
Currently, we effectively almost everywhere need DrmOutput outputs,
DrmVirtualOutput outputs are needed only in a couple of places. There's
not a lot that we gain from storing real and virtual outputs in one
list, it adds unnecessary casting, etc. Ideally, virtual outputs must
come from a different backend, the current approach is not scalable.
2022-09-07 17:40:51 +00:00
Vlad Zahorodnii
9c4bcb92c3 backends/drm: Don't sort DrmBackend::m_outputs
This std::sort() function traces its origin back to
cbbd684430. The sort step was necessary to
ensure that we get same configuration hash regardless the order in which
outputs were connected.

On the other hand, our KWinKScreenIntegration code already does that so
it seems excessive to sort outputs the second time.
2022-09-06 17:54:52 +03:00
Vlad Zahorodnii
d8ea87a9ea Add dummy placeholder output type
Placeholder outputs are not rendered so they don't need render data.
Also, this simplifies the control flow when the last real output is
removed. The Platform::screensQueried signal won't be emitted inside a
Platform::screensQueried slot.
2022-09-06 10:36:33 +00:00
Vlad Zahorodnii
d2fb4147fc Move multi-purpose code in its own directory
Things such as Output, InputDevice and so on are made to be
multi-purpose. In order to make this separation more clear, this change
moves that code in the core directory. Some things still link to the
abstraction level above (kwin), they can be tackled in future refactors.
Ideally code in core/ should depend either on other code in core/ or
system libs.
2022-09-06 11:21:40 +03:00
Laurent Montel
0ea72e9275 Remove extra ';' 2022-09-02 08:27:52 +02:00
Vlad Zahorodnii
207a16f14f backends/drm: Fix software cursor fallback in DrmOutput::renderCursorOpengl()
We need to return if the cursor sprite is bigger than DrmGpu::cursorSize().

BUG: 458036
2022-09-01 13:11:13 +00:00
Vlad Zahorodnii
df79d68309 backends/drm: Port from kwinApp()
kwinApp() lives in abstraction layer above and we can use
QCoreApplication to terminate the application.
2022-09-01 12:49:39 +03:00
Xaver Hugl
e195d42916 backends/drm: ensure pipeline mode is always in the connector mode list
The current mode of an output not being in its mode list can lead to crashes
2022-08-31 09:18:59 +00:00
Xaver Hugl
c4b9626117 backends/drm: replace manual IN_FORMATS parsing with libdrm functions
!2819 reminded me that it's time to replace this mess with libdrm functions

Upstream MR: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/146
2022-08-30 08:30:01 +00:00
Vlad Zahorodnii
ed49d7c59b Refactor output state setting
If multiple properties that affect the geometry change, then the
Output::geometryChanged() signal will be emitted multiple times, which
in its turn may force the Workspace to re-arrange windows, etc.

With this, the geometryChanged signal will be emitted in more expected
fashion only once as long as relevant property changes are batched.
2022-08-28 14:30:24 +00:00
Xaver Hugl
a1ed313a42 backends/drm: move placeholder output management to Workspace
Backends aren't the right layer to take care of placeholder outputs, and
don't really have enough information to do it either. This also fixes a
crash, because the placeholder output currently gets created too late
2022-08-27 20:30:27 +02:00
Vlad Zahorodnii
ace5b58f7a Drop Platform::{outputEnabled,outputDisabled} signals
Use Output::enabledChanged signal to determine if an output is enabled
or disabled.
2022-08-25 06:35:55 +00:00
Vlad Zahorodnii
a32869594e Fix some -Wunused-variable warnings 2022-08-23 10:54:39 +03:00
Vlad Zahorodnii
b5a4c08231 Move kscreen integration in Workspace
The main motivation behind moving kscreen integration to the
Workspace is to make output configuration work the same way
regardless of the backend and simplify the drm backend.
2022-08-18 10:20:53 +00:00
Vlad Zahorodnii
59907c12ff Remove own copies of drm_fourcc.h
libdrm is a mandatory dependency so we don't need to keep own copies of
drm_fourcc.h anymore.
2022-08-17 14:08:05 +00:00
Janet Blackquill
506e2d6f9f drm_gpu: don't bother trying to assign a crtc to a connector that isn't connected
BUG: 457002
2022-08-16 13:04:31 +00:00
Vlad Zahorodnii
f2e594358c Remove Platform::supportsOutputChanges()
If the platform does not support configuring outputs, applying a config
must fail. However, almost all output backends support output
configuring except, perhaps, the x11 backend, but that case doesn't
matter.
2022-08-16 12:31:28 +00:00
Volker Krause
835dc7c818 Explicitly mark DrmObject as non-copyable
It implicitly already is not copyable, due to the unique_ptr member.
However, Qt6 moc code isn't realizing that and fails to compile the
DrmPlane Q_GADGET sub-class of this.
2022-08-15 18:03:46 +02:00
Xaver Hugl
6cdb1e6f64 backends/drm: add stricter checks for direct scanout
Buffers with implicit modifiers from another GPU must not be imported, as
the layouts may not be compatible.
For buffers with incompatible modifiers, direct scanout can also be rejected
early, saving some computational power.

BUG: 457851
2022-08-14 19:53:30 +02:00
Xaver Hugl
f4e917f734 backends/drm: release buffers for disabled objects
BUG: 456686
2022-08-12 19:52:24 +00:00
Xaver Hugl
1b1e0ab95f wayland/drmlease: use FileDescriptor class 2022-08-11 21:27:33 +02:00
Xaver Hugl
1464028934 backends/drm: use FileDescriptor class for drm buffer fds 2022-08-11 21:27:33 +02:00
Xaver Hugl
6cd4d69644 dmabuf: make use of FileDescriptor class 2022-08-11 21:27:33 +02:00
Xaver Hugl
9f41620b77 backends/drm: don't crash if beginFrame fails
CCBUG: 455532
2022-08-09 22:18:58 +02:00
Xaver Hugl
97939ceae8 backends/drm: fix blob updating
Two things about the code were wrong:
1. m_current is used in updateBlob() but was only updated afterwards
2. the assumption that the property having the same ID means it has the
same blob contents is not always true

BUG: 449285
2022-08-04 15:48:32 +00:00
Vlad Zahorodnii
e604b6852f backends/drm: Remove Compositor dependency
This breaks cyclic dependency between Compositor and DRM backend, there
are still indirect dependencies though. However, fewer cyclic
dependencies should make the architecture more cleaner and easier to
tweak.
2022-07-28 08:56:47 +00:00
Vlad Zahorodnii
a198516871 Drop Platform::enabledOutputs()
At the moment, a platform should provide two output lists - one that
lists all available outputs, and the other one that contains only
enabled outputs. In general, this amounts to some boilerplate code and
forces backends to be implemented in some certain way, which sometimes
is inconvenient, e.g. if an output is disabled or enabled, it will be
simpler if we only change Output::isEnabled(), otherwise we need to
start accounting for corner cases such as the order in which
Output::isEnabled() and Platform::enabledOutputs() are changed, etc.
2022-07-27 09:22:10 +00:00
Vlad Zahorodnii
2629007eef Make outputs disabled by default
This can be used to make our backends more multi-purpose. At the moment,
new outputs are enabled by default, but it makes sense to do otherwise.

For example, if an output is disabled by default, it would be possible
to delegate initial output configuration to layer above, to kwin.

In long term, the drm backend would need to scan connectors, create an
Output for every one of them, kwin sees new outputs and tries to apply
the initial output configuration, which includes the enabled status.
2022-07-27 09:22:10 +00:00
Vlad Zahorodnii
3ce24a0cbf Make OutputConfiguration take OutputMode
OutputMode provides a more robust way to refer to outputs. A mode can
have flags and things as such that are not taken into account with mode
+ refresh rate.
2022-07-27 07:26:48 +00:00
Xaver Hugl
5e602434c0 backends/drm: fix memory leak 2022-07-26 19:41:51 +00:00
Xaver Hugl
4be81e0176 backends/drm: make modeset tests explicit
Instead of checking for properties needing a modeset, do atomic tests
with ALLOW_MODESET where it makes sense, and do a second atomic test
afterwards without ALLOW_MODESET to check if the modeset can be skipped.

This should ensure that KWin always does a modeset when it needs to do one,
 and not do a modeset when it's not necessary. Doing this also allows
reducing the complexity of the drm backend a bit.
2022-07-26 19:03:33 +00:00
Vlad Zahorodnii
71a58231e8 backends/drm: Make DrmOutput::queueChanges() not touch active status
The DrmOutput synchronizes the enabled state with the active state,
which makes sense on one hand, but on the other hand, that's not good.
The drm backend makes a decision that should be ideally made by either
kscreen (turn on outputs before applying an output config), user, or
kwin itself.

This would also allow kwin to control the allocation of crtcs for
non-desktop outputs, which is a minor thing, but it might be useful in
the future.
2022-07-26 13:40:29 +00:00
Xaver Hugl
361fc0a38e backends/drm: remove drm lease layers
They just add more code and more potential problems, and the difference in
VRAM usage is very minimal
2022-07-26 09:57:06 +02:00
Xaver Hugl
b7d7a99fcb backends/drm: fix placeholder output check
Non-desktop outputs must be ignored
2022-07-26 07:06:30 +00:00
Vlad Zahorodnii
1b4258bf17 kwineffects: Move infiniteRegion() to kwinglobals.h
infiniteRegion() is useful not only to effects but also other kwin
components, so move it to kwinglobals.h in order to make backends stop
depending on libkwineffects
2022-07-25 10:52:03 +03:00
Vlad Zahorodnii
1baf39daf7 backends/drm: Improve device seat assignment handling
This fixes the drm backend adding hotplugged gpus that belong to other
seats and makes the udev helper depend on less stuff from the layer
above backends.
2022-07-24 19:36:50 +03:00
Vlad Zahorodnii
cf3fe003e6 Move ownership of Session to Application
The Session can be useful not only to the platform backend but also
input backends and for things such as vt switching, etc. Therefore it's
better to have the Application own the Session.
2022-07-24 19:14:26 +03:00
Vlad Zahorodnii
5e669aece9 backends/libinput: Take Session explicitly
The API will be more clear about what the libinput backend needs.
2022-07-24 19:14:26 +03:00
Vlad Zahorodnii
36e238cda5 backends/drm: Remove EdidOverwrite config option
This is a too niche feature. It also doesn't have to be implemented in
the compositor. The kernel provides a way to overwrite the edid blob,
which is not specific to the running compositor.
2022-07-24 15:37:44 +00:00