Commit graph

61 commits

Author SHA1 Message Date
Ian Douglas Scott
b823dd4247 kms/surface: Split off part of redraw into take_screencopy_frames 2025-06-10 16:01:04 +02:00
Ian Douglas Scott
e80e46e911 kms/surface: Update how errors in send_screencopy_result are handled
Previously, some errors in the screencopy code resulted in `redraw`
returning an error, while others make the screencopy frame fail, and
logged a warning.

Instead, make all errors here log a warning, and call `reset()` on the
session, but continue running `redraw()`.

Calling `frame.error` explictly isn't needed, since the same error will
be sent on drop otherwise.
2025-06-10 16:01:04 +02:00
Ian Douglas Scott
ca817e2579 kms/surface: Split off part of redraw into postprocess_elements 2025-06-10 16:01:04 +02:00
Ian Douglas Scott
39b1ac2955 kms/surface: Split off part of redraw into a send_screencopy_result
This should not change behavior in any way.
2025-06-10 16:01:04 +02:00
Ian Douglas Scott
f86cd933d4 kms/surface: Call cleanup_texture_cache for each device at end of draw
Fixes an issue where a dual GPU system would keep allocating dGPU PBOs in
`cpu_copy()` every frame, but `cleanup()` was not being called, since the
surface thread for the builtin output was rendered on the
primary/integrated GPU, targeting the same GPU.

Even if a different monitor was compositing on the dGPU, That wouldn't
help since that thread has it's own `GpuManager` with it's own renderer
and cache.

Running cleanup at the end (or start) of each frame seems like a good
idea. Not sure if it would be best to avoid additional calls, or if
that's desirable/fine.
2025-06-02 18:58:49 +02:00
Victoria Brekenfeld
3d3a566a3c kms: Always send frame callbacks 2025-05-27 20:00:21 +02:00
Victoria Brekenfeld
a65e1d6b5f debug: More profiling annotations 2025-05-27 20:00:21 +02:00
Victoria Brekenfeld
465813c1c5 shell: Using parking_lot's RwLock for fairness guarantees 2025-05-27 20:00:21 +02:00
Victoria Brekenfeld
8194be30c6 kms: Allow updating the primary node
Add more sophisticated code to handle the primary node disappearing.

Also overhaul the selection logic to respect our allow/deny-list and
prefer devices with built-in connectors before using the boot gpu.

This will also allow triggering a primary node switch at runtime
for debugging purposes in the future.
2025-05-27 20:00:21 +02:00
Ian Douglas Scott
194d5c8967 protocols/screencopy: Make frame/session send stopped/fail on drop
Previously, `Frame` was stored in KMS frame udata, but in some cases the
udata was dropped without a capture happening, and `Frame` did not
implement `Drop`, so `fail` was never sent.

Instead, rename `DropableFrame` to `Frame` and `Frame` to `FrameRef`, so
we can have a single instance of `Frame`, that will send `fail` on drop.
This guarantees either `.success` or `.fail` are send, as long as its
not leaked.

This seems to fix https://github.com/pop-os/cosmic-comp/issues/1305.
xdg-desktop-portal-cosmic prints an error, buy retries (as it should for
an `Unknown` error; though maybe there should be a retry limit) and the
session continues working.

(Not sure if it should be sending `failed`, or queing it with the next
frame so it can send `success` to the client, but this works and is
desirable as a failsafe anyway.)

`Session` and `CursorSession` are similiarly updated.

`.fail()`, `.success()`, and `.stop()` now consume
`Frame`/`Session`/`CursorSession`. So to stop a session, it is now
necessary to call `.remove_session()`, but then simply dropping with
send `.stop()`.

Factoring out some `Request::Capture` handling into a `capture_frame`
function seems to clean up error handling and such a bit.
2025-05-19 16:53:46 -07:00
Ian Douglas Scott
e1a817bc06 kms/surface: Fix thread crash on error return of redraw
If `redraw()` returned early, before updating `self.state`, but after
calling `queue_frame`, `on_vblank` would later be called, and reach
`unreachable` since state isn't set to `WaitinfForVBlank`.

In particular, this was happening when the dmabuf from the image copy
frame failed to `bind`.

To avoid this, make sure to update `self.state` immediately after
calling `queue_frame`, before any early return from an error.
2025-05-19 19:58:36 +02:00
Ian Douglas Scott
d7b37cfde5 Update smithay
Updates to use `GbmFramebufferExporter`.
2025-04-29 14:42:07 +02:00
Victoria Brekenfeld
74c7a216f5 kms: Skip overlay tests on fullscreen 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
7c222ae6d1 debug: Fix crashes and deadlocks 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
4e6713291d kms/timing: Faster cleanup 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
8aaaa12d5c kms: Fix VRR check having already missed the deadline 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
db25cc4b0b kms/timings: Base next_render_time on time to submit 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
d1e0e28d3c kms: Add tracy profiling 2025-04-28 18:03:09 +02:00
Victoria Brekenfeld
7a8577592d kms: Support screencopy cursor modes with active filters 2025-03-24 19:10:52 +01:00
Victoria Brekenfeld
7929e25966 kms: Support screen filters 2025-03-24 19:10:52 +01:00
Victoria Brekenfeld
18335c6758 kms: Refactor out postprocessing helpers 2025-03-24 19:10:52 +01:00
Clayton Craft
29a649541d kms.timings.presented: print debug msg when frame time is overflowing
Also see: #1062
2025-03-19 18:45:44 +01:00
Clayton Craft
8f40fc7a1b kms: protect against potential overflow of Duration when calculating avg frametime
Also see: https://github.com/Smithay/smithay/pull/1685

Fixes #1062

Co-authored-by: Victoria Brekenfeld <victoria@system76.com>
2025-03-19 18:45:44 +01:00
Victoria Brekenfeld
95b27637ae chore: smithay update 2025-03-12 16:50:58 +01:00
Ian Douglas Scott
a3714b036e Improve mirroring size/scale comparison
To determine if `mirroring_state` is needed, we want to compare the
untransformed dimensions of the source output to the target outputs
mode. The fact the mode comparision previously compared refresh rate
(since it compared the whole `Mode`) seems unintended.

We also re-create the `MirroringState` when the source output
dimensions changes.
2025-02-04 20:01:24 +01:00
Ian Douglas Scott
9963887ac5 Fix mirroring with scale on target output
The actual render will pass a scale other than 1.0 here, so this needs
to do the same.
2025-02-04 20:01:24 +01:00
Ian Douglas Scott
3f5c64f50f Use HashMap entry API in a cleaner way
Careful use of the right `VacantEntry` and `OccupiedEntry` methods makes
this possible without hacks or lifetime errors.
2025-02-04 20:01:24 +01:00
Ian Douglas Scott
32f9ff3cac Use untransformed texture in MirroringState::new_with_renderer
Apply inverse of output transform to mode to get render size, and apply
no transform during rendering. The transform of the output being
mirrored from shouldn't affect the final render.

Fixes issues when source output for mirroring has a transform, and also
fixes issues in https://github.com/pop-os/cosmic-comp/pull/1058
when this code is used for postprocessing, where this resulted in the
same transform being applied twice.
2025-02-04 20:01:24 +01:00
Ian Douglas Scott
b685512127 Migrate away from Rectangle::from_loc_and_size
Deprecated in `smithay` by https://github.com/Smithay/smithay/pull/1621.
2025-01-07 12:50:35 +01:00
Victoria Brekenfeld
db13eea91c shell: Allow active workspace to be None 2025-01-06 20:23:05 +01:00
Victoria Brekenfeld
3926aee5b6 debug: Fixup feature compilation 2025-01-06 20:23:05 +01:00
Victoria Brekenfeld
6be5009b37 kms: Allow diverging primary plane formats under certain conditions 2025-01-06 20:23:05 +01:00
Victoria Brekenfeld
b5cd62fd7a kms: skip cursor updates for fullscreen content above the minimum refresh rate 2025-01-06 20:23:05 +01:00
Victoria Brekenfeld
546966bf15 drm_lease: Disable overlay planes when active 2025-01-06 20:23:05 +01:00
Victoria Brekenfeld
8b87d6524e kms: Use new DrmOutput api 2025-01-06 20:23:05 +01:00
Victoria Brekenfeld
f12f4db0e1 chore: Update smithay 2025-01-06 20:23:05 +01:00
Victoria Brekenfeld
9b4127555e kms/surface: Fix racy output disable 2024-12-12 14:29:50 +01:00
Victoria Brekenfeld
81b9fb179b output-configuration: Support cosmic-ext v2 2024-11-27 09:37:01 +01:00
Victoria Brekenfeld
80965a61b9 kms: Adaptive VRR support 2024-11-27 09:37:01 +01:00
Victoria Brekenfeld
d72bf54628 deps: Update smithay 2024-11-27 09:37:01 +01:00
Ashley Wulber
8d5541b27f fix: apply transform to damage before blitting 2024-11-13 16:33:43 +01:00
Ian Douglas Scott
ea27ec5e28 DPMS with wlr-output-power-management-unstable-v1 protocol 2024-10-25 10:31:24 +02:00
Ian Douglas Scott
b8c429facb Add COSMIC_DISABLE_DIRECT_SCANOUT env var
Like `anvil`. Useful for testing and working around issues.
2024-10-15 11:45:46 +02:00
Ian Douglas Scott
a96394f7a6 Update egui, smithay-egui, smithay 2024-10-02 23:55:10 +02:00
Victoria Brekenfeld
07f898590a kms: Fix rare mirroring crash 2024-09-02 20:44:23 +02:00
julianbraha
52ad30c264 Remove unnecessary lifetimes 2024-08-30 17:53:56 +02:00
Ian Douglas Scott
0e78104477 Fix build with profile-with-tracy feature 2024-07-29 14:49:44 +02:00
Ian Douglas Scott
0636bcdef3 Add workspace_overview_is_open function; put in a utils::quirks mod
This is increasingly not just related to screencopy, so it's weird to
add there. I don't see any other module that fits, so add one called
"quirks" (like the Linux kernel uses for device-specific handling in
generic drives).
2024-07-15 17:12:05 +02:00
Ian Douglas Scott
355b142c52 When cosmic-workspaces is shown, render only layer-shell surfaces
This allows `cosmic-workspaces` to rely on cosmic-comp for rendering the
background, and just have transparency. This should be a more reliable
and performant way of doing things, at least for now.

Instead of adding another opaque bool argument, this defines an
`ElementFilter` enum, which makes calls more readable.

Window surfaces are still included in screencopy, as needed for the
workspace previews.
2024-07-15 17:12:05 +02:00
Victoria Brekenfeld
2d0f1cbf2b chore: smithay update 2024-07-02 13:15:30 +02:00