1
0
Fork 0
Commit graph

31963 commits

Author SHA1 Message Date
Daniel van Vugt
bd3b5b64ee backends/native: Make await_flush later and inlined
"Later" as in after GL is finished rendering so as to not block the deadline
timer from updating the cursor smoothly during long GL renders. Indeed this
could make a primary plane frame late in some cases but that's only when
going from idle to active, so there is no previous frame to observe stutter
within the primary plane. It does however fix observable stutter in the
cursor plane by not dropping/stalling an otherwise good cursor update in a
continuous stream of cursor updates.

"Inlined" as in we don't need most of `meta_kms_device_await_flush`. The
important part is that it calls `disarm_crtc_frame_deadline_timer` to avoid
attempting two posts at once. So that's all that is kept.

This also fixes a deadlock in triple buffering. By not cancelling the
cursor update during a GL render we're also not cancelling a primary plane
update that might have already been piggybacked onto it by `queue_update`.

Cherry picked from !3149
2024-08-06 14:08:28 +08:00
Daniel van Vugt
17648c4b2d clutter/frame-clock: Record measurements of zero for cursor-only updates
But only if we've ever got actual swap measurements
(COGL_FEATURE_ID_TIMESTAMP_QUERY). If it's supported then we now drop to
double buffering and get optimal latency on a burst of cursor-only
updates.

Closes: https://launchpad.net/bugs/2023363
2024-08-06 14:08:28 +08:00
Daniel van Vugt
0cb8c3783f onscreen/native: Avoid callbacks on "detached" onscreens
Detached onscreens have no valid view so avoid servicing callbacks on
them during/after sleep mode. As previously mentioned in 45bda2d969.

Closes: https://launchpad.net/bugs/2020049
2024-08-06 14:08:28 +08:00
Daniel van Vugt
87947f7fc5 tests/native-kms-render: Fix failing client-scanout test
It was assuming an immediate transition from compositing (triple
buffering) to direct scanout (double buffering), whereas there is
a one frame delay in that transition as the buffer queue shrinks.
We don't lose any frames in the transition.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
cc9fdb67ce clutter/frame-clock: Add environment variable MUTTER_DEBUG_TRIPLE_BUFFERING
With possible values {never, auto, always} where auto is the default.

This also allows some unification with automatic throttling for
direct scanout.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
53888593a8 clutter/frame-clock: Throttle back to double buffering for direct scanout
There's no compositing during direct scanout so the "render" time is zero.
Thus there is no need to implement triple buffering for direct scanouts.
Stick to double buffering and enjoy the lower latency.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
5fb8b37183 clutter: Pass ClutterFrameHint(s) to the frame clock 2024-08-06 14:08:28 +08:00
Daniel van Vugt
cd81b7538c backends: Flag that the frame attempted direct scanout
We need this hint whether direct scanout succeeds or fails because it's
the mechanism by which we will tell the clock to enforce double buffering,
thus making direct scanout possible on future frames. Triple buffering
will be disabled until such time that direct scanout is not being attempted.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
d7bd143b1c clutter/frame: Add ClutterFrameHint to ClutterFrame
This will allow the backend to provide performance hints to the frame
clock in future.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
0c44b387c2 clutter/frame-clock: Log N-buffers in CLUTTTER_DEBUG=frame-timings 2024-08-06 14:08:28 +08:00
Daniel van Vugt
1328fa9ff8 clutter/frame-clock: Add triple buffering support 2024-08-06 14:08:28 +08:00
Daniel van Vugt
e4df885306 clutter/frame-clock: Clamp render times to two frames, not one
Because the buffer queue may grow by an extra frame in triple buffering,
we need measurements exceeding one frame to indicate when and by how much
the scaling is necessary.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
6cc1801e45 clutter/frame-clock: Merge states DISPATCHING and PENDING_PRESENTED
Chronologically they already overlap in time as presentation may
complete in the middle of the dispatch function, otherwise they are
contiguous in time. And most switch statements treated the two states
the same already so they're easy to merge into a single `DISPATCHED`
state.

Having fewer states now will make life easier when we add more states
later.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
09fa9d14d9 clutter/frame-clock: Lower the threshold for disabling error diffusion
Error diffusion was introduced in 0555a5bbc1 for Nvidia where last
presentation time is always unknown (zero). Dispatch times would drift
apart always being a fraction of a frame late, and accumulated to cause
periodic frame skips. So error diffusion corrected that precisely and
avoided the skips.

That works great with double buffering but less great with triple
buffering. It's certainly still needed with triple buffering but
correcting for a lateness of many milliseconds isn't a good idea. That's
because a dispatch being that late is not due to main loop jitter but due
to Nvidia's swap buffers blocking when the queue is full. So scheduling
the next frame even earlier using last_dispatch_lateness_us would just
perpetuate the problem of swap buffers blocking for too long.

So now we lower the threshold of when error diffusion gets disabled. It's
still high enough to fix the original smoothness problem it was for, but
now low enough to detect Nvidia's occasionally blocking swaps and backs
off in that case.

Since the average duration of a blocking swap is half a frame interval
and we want to distinguish between that and sub-millisecond jitter, the
logical threshold is halfway again: refresh_interval_us/4.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
28e3334b10 clutter/frame-clock: Reuse existing idle period detection
While it was correct for double buffering, the test was wrong for
triple buffering and would lead to accidentally staying in triple
buffering for too long.

Fixes: 8f27ebf87e
2024-08-06 14:08:28 +08:00
Daniel van Vugt
dc37139410 renderer/native: Discard pending swaps when rebuilding views
It's analogous to discard_pending_page_flips but represents swaps that
might become flips after the next frame notification callbacks, thanks
to triple buffering. Since the views are being rebuilt and their onscreens
are about to be destroyed, turning those swaps into more flips/posts would
just lead to unexpected behaviour (like trying to flip on a half-destroyed
inactive CRTC).
2024-08-06 14:08:28 +08:00
Daniel van Vugt
5209a0896b onscreen/native: Skip try_post_latest_swap if shutting down
Otherwise we could get:

  meta_kms_prepare_shutdown ->
  flush_callbacks ->
  ... ->
  try_post_latest_swap ->
  post and queue more callbacks

So later in shutdown those callbacks would trigger an assertion failure
in meta_kms_impl_device_atomic_finalize:

  g_hash_table_size (impl_device_atomic->page_flip_datas) == 0
2024-08-06 14:08:28 +08:00
Daniel van Vugt
5a6892f3e2 onscreen/native: Add function meta_onscreen_native_discard_pending_swaps 2024-08-06 14:08:28 +08:00
Daniel van Vugt
2fbaa03a9d onscreen/native: Increase secondary GPU dumb_fbs from 2 to 3
So that they don't get overwritten prematurely during triple buffering
causing tearing.

https://launchpad.net/bugs/1999216
2024-08-06 14:08:28 +08:00
Daniel van Vugt
d6d0fa3f3c onscreen/native: Defer posting if there's already a post in progress
And when the number of pending posts decreases we know it's safe to submit
a new one. Since KMS generally only supports one outstanding post right now,
"decreases" means equal to zero.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
f5a36efe3a onscreen/native: Insert a 'posted' frame between 'next' and 'current'
This will allow us to keep track of up to two buffers that have been
swapped but not yet scanning out, for triple buffering.

This commit replaces mutter!1968.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
c12fbdb912 onscreen/native: Add a missing frame notification
In the unlikely event that swap_buffers_with_damage drops the previous swap
it was forgetting to notify about the discarded frame. That could lead to
frame clock freezes.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
0e903858df onscreen/native: Split swap_buffers_with_damage into two functions
1. The EGL part: meta_onscreen_native_swap_buffers_with_damage
2. The KMS part: post_latest_swap
2024-08-06 14:08:28 +08:00
Daniel van Vugt
271dee0967 onscreen/native: Deduplicate calls to clutter_frame_set_result
All paths out of `meta_onscreen_native_swap_buffers_with_damage` from
here onward would set the same `CLUTTER_FRAME_RESULT_PENDING_PRESENTED`
(or terminate with `g_assert_not_reached`).

Even failed posts set this result because they will do a
`meta_onscreen_native_notify_frame_complete` in
`page_flip_feedback_discarded`.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
91453c1b88 onscreen/native: Replace an assertion that double buffering is the maximum
Because it soon won't be the maximum. But we do want to verify that the
frame info queue is not empty, to avoid NULL dereferencing and catch logic
errors.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
c25bcd5477 onscreen/native: Log swapbuffers and N-buffering when MUTTER_DEBUG=kms 2024-08-06 14:08:28 +08:00
Daniel van Vugt
74dc77b65b renderer/native: Steal the power save flip list before iterating over it
Because a single iteration might also grow the list again.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
5ff79eb6b7 renderer/native: Avoid requeuing the same onscreen for a power save flip
This is a case that triple buffering will encounter. We don't want it
to queue the same onscreen multiple times because that would represent
multiple flips occurring simultaneously.

It's a linear search but the list length is typically only 1 or 2 so
no need for anything fancier yet.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
0f18e66535 kms: Keep a shutting_down flag 2024-08-06 14:08:28 +08:00
Daniel van Vugt
b61fe512ef cogl/onscreen: Indent declaration parameters to align with above/below
This fixes warnings from check-code-style.
2024-08-06 14:08:28 +08:00
Daniel van Vugt
e3ad4264fe cogl/onscreen: Add function cogl_onscreen_count_pending_frames 2024-08-06 14:08:28 +08:00
Florian Müllner
04995f5664
Bump version to 46.4
Update NEWS.
2024-08-04 17:36:56 +02:00
Jonas Ådahl
4fb2a62c1f display: Rename mandatory X11 initialization function
Simply to make it clear that the renamed function is specific to a
particular X11 initialization mode (mandatory Xwayland), put that in the
name, so that it's easier to understand when this function is relevant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3329>
2024-08-04 15:03:58 +00:00
Jonas Ådahl
56cfac14fb tests/x11: Fix replace test to catch the second instance failing
The test never noticed that the second instance never actually managed
to load; it was looping a multi second retry session trying to redirect
windows, meaning it failed to catch https://gitlab.gnome.org/GNOME/mutter/-/issues/3089.

Fix the test so that it always waits for mutter to finish loading
successfully, just like it waits fro the first.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3329>
2024-08-04 15:03:58 +00:00
Jonas Ådahl
827adc898e display: Move X11 initial focus handling to MetaX11Display
It's X11 specific, so put it in the X11 display manager object.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3329>
2024-08-04 15:03:58 +00:00
Jonas Ådahl
de31822ecc x11-display: Make subwindow redirection call mode specific
This means that for X11 sessions we'll do it before any windows are
mapped, and before any plugin implementation is started. Doing it before
a plugin is started is important, because things that the plugin does
during startup can have consequences on how compositing on Xorg works.

For the Xwayland case, we'll do it relatively in the setup phase. It
appears to have been harmless to do it later in the post-opened signal,
but there is no harm in doing it as one of the earlier steps.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3089
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3329>
2024-08-04 15:03:58 +00:00
Robert Mader
1ccf2cfb56 multi-texture-format: Fix limited range quantization
And stop pre-computing values, making errors like this harder to spot.

The values 0.0625 (16/256) and 0.5 (128/256) were slightly off,
resulting e.g. in "black" not being #000000 but #010001 RGB instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3906>

(cherry picked from commit dfa5238bf9)
2024-07-29 17:06:29 +02:00
Chao-Hsiung Liao
bb9a2f1ede Update Chinese (Taiwan) translation 2024-07-27 07:38:16 +00:00
Carlos Garnacho
7e0e428016 clutter: Specify that input-only grabs are started inactive in API
Add the _inactive suffix, so that the state of these objects is clear.

(cherry-picked from commit 01444e803f)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3874>
2024-07-09 12:33:23 +02:00
Carlos Garnacho
827c4fea4b clutter: Add API to create inactive ClutterGrabs, and activate them explicitly
This gives greater control to the callers on the place where a grab is being
activated, this may make a difference in the handling of crossing events
triggered through it, e.g. by having callers rely on having already obtained
a ClutterGrab prior to handling the resulting effects.

The "input only" grab has also been turned inactive by default, in order to
to have the ClutterGrab pointer available for checks at the MetaWaylandEventHandler
focus changing methods triggered through grab activation.

(cherry-picked from commit 8e5f3a1f83)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3874>
2024-07-09 12:33:23 +02:00
Jürgen Benvenuti
0ffc27ad5c Update German translation 2024-07-07 16:15:03 +00:00
Florian Müllner
c1ffc17331
Bump version to 46.3.1
Update NEWS.
2024-07-04 00:10:40 +02:00
Michel Dänzer
b09c1d3bfa wayland/actor-surface: Don't bail for Xwayland surfaces
Thawing Xwayland surfaces don't hit meta_window_actor_wayland_set_frozen,
so we need to sync actor state for them here.

v2:
* Guard META_IS_XWAYLAND_SURFACE by HAVE_XWAYLAND, fixes Wayland-only
  build.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3557
Fixes: ec5444f541 ("wayland/actor-surface: Don't sync actor state for frozen actors")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3862>

(cherry picked from commit 041a404ba0)
2024-07-03 18:12:29 +02:00
Marco Trevisan (Treviño)
7515316395 clutter/clone: Do not use global transformation for scaling clones
When cloning an actor we were applying a global scale to it, based on
the size of the clone itself and of the cloned actor.

This implied that the transformed size of the clone was not the one that
was set, but it was taking taking in account the actor scaling too.
So in practice we were scaling it twice.

While this had no visual implications it indeed was causing troubles
when a ClutterClone was reactive because in such case only the scaled
area of the scaled clone was considered reactive.

Assume you had an actor of 100x100 pixels, scaling it to a clone of
50x50 pixels:
 - The scale applied to the clone was 0.5
 - The transformed size of the clone was: 25x25 pixels
 - The clone was reactive only in that sub-area

To avoid this, never touch the clone transformation matrix, but only
transform it at paint time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2959>

(cherry picked from commit 44c0c311ba)
2024-07-03 10:38:15 +02:00
Florian Müllner
3998f8a422
Bump version to 46.3
Update NEWS.
2024-06-29 21:32:23 +02:00
Corentin Noël
24f2e76576 meta/plugin: Annotate dialog creation virtuals as return full
The two dialog creation virtual functions returned by these functions have to
be unreferenced by the caller (and are actually unreferenced in other places in
the code).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3790>
(cherry picked from commit 4134d12789)
2024-06-29 21:12:29 +02:00
Jeffrey Knockel
18c17aaa5a constraints: Allow resize of windows moved above screen
If the titlebar of a window has been moved above the screen by a user
via an unconstrained move, then any constrained user resize following
this move will cause the window to jump below the top of the screen or
cause other glitchy behavior.

This commit removes the constraint that the titlebar of a window must be
below the top of the screen for any resize that is both (1) triggered by
a user and (2) is a resize that affects only the left, right, or bottom
edges of the window.  This allows users to move a window partially above
the screen and then resize the window to be wider or resize the bottom
edge of the window to make it taller or shorter.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1206
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3764>
(cherry picked from commit 5ba364a947)
2024-06-28 23:22:22 +02:00
Shiki Okasaka
a0dd01c95f clutter: Use character offsets for specifying the surrounding text
clutter_input_focus_set_surrounding() expects cursor and anchor positions
to be provided in character offsets.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3440
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3719>
(cherry picked from commit 4b1411696e)
2024-06-28 23:22:14 +02:00
Orko Garai
7f344053f8 Use byte offset for cursor_end/anchor value sent in preedit_string.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3845>
(cherry picked from commit f214eb5134)
2024-06-28 23:22:06 +02:00
Michel Dänzer
8978f74c1e wayland/surface: Can't send scale events with NULL surface->resource
The committed state can't have any children sub-surfaces either, so
just bail.

Fixes: ae403f2e94 ("wayland: Use new highest scale monitor tracking for fractional_scale_v1")
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3552

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3849>
(cherry picked from commit 94f3bbd94b)
2024-06-28 21:18:01 +02:00