1
0
Fork 0
Commit graph

8407 commits

Author SHA1 Message Date
Daniel van Vugt
f2290877be
clutter/frame-clock: Optimize latency for platforms missing TIMESTAMP_QUERY
Previously if we had no measurements then `compute_max_render_time_us`
would pessimise its answer to ensure triple buffering could be reached:
```
if (frame_clock->state == CLUTTER_FRAME_CLOCK_STATE_DISPATCHED_ONE)
  ret += refresh_interval_us;
```
But that also meant entering triple buffering even when not required.

Now we make `compute_max_render_time_us` more honest and return failure
if the answer isn't known (or is disabled). This in turn allows us to
optimize `calculate_next_update_time_us` for this special case, ensuring
triple buffering can be used, but isn't blindly always used.

This makes a visible difference to the latency when dragging windows in
Xorg, but will also help Wayland sessions on platforms lacking
TIMESTAMP_QUERY such as Raspberry Pi.

(cherry picked from commit 7852451a9e93f5116fa853350020a318d31cb710)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:13:55 +09:00
Daniel van Vugt
d7b8793f34
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
(cherry picked from commit b2c16a63d2127faa0ebd811fab65c8be97a74469)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:13:25 +09:00
Daniel van Vugt
0615b2376b
clutter/frame-clock: Conditionally disable triple buffering
1. When direct scanout is attempted

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.

2. If disabled by environment variable MUTTER_DEBUG_TRIPLE_BUFFERING

With possible values {never, auto, always} where auto is the default.

3. When VRR is in use

VRR calls `clutter_frame_clock_schedule_update_now` which would keep
the buffer queue full, which in turn prevented direct scanout mode.
Because OnscreenNative currently only supports direct scanout with
double buffering.

We now break that feedback loop by preventing triple buffering from
being scheduled when the frame clock mode becomes variable. Long term
this could also be solved by supporting triple buffering in direct
scanout mode. But whether or not that would be desirable given the
latency penalty remains to be seen.

(cherry picked from commit 280f7f6b26cd3e7a82706d1d001419295ea15d8b)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:12:42 +09:00
Daniel van Vugt
06d2bca831
clutter: Pass ClutterFrameHint(s) to the frame clock
(cherry picked from commit 5fa0c83a5fd5267f1c5e91c34dc3b91d6177105b)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:12:11 +09:00
Daniel van Vugt
287a23ace7
clutter/frame: Add ClutterFrameHint to ClutterFrame
This will allow the backend to provide performance hints to the frame
clock in future.

(cherry picked from commit 9b5f91b086b6a16c548626fed0e33f776cf3f030)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:11:28 +09:00
Daniel van Vugt
68061c3581
clutter/frame-clock: Add triple buffering support
This replaces the DISPATCHED state with four new states that are possible
with triple buffering:

  DISPATCHED_ONE:                   Double buffering
  DISPATCHED_ONE_AND_SCHEDULED:     Scheduled switch to triple buffering
  DISPATCHED_ONE_AND_SCHEDULED_NOW: Scheduled switch to triple buffering
  DISPATCHED_TWO:                   Triple buffering

It's four states simply because you now have two booleans that are no
longer mutually exclusive: DISPATCHED and SCHEDULED.

(cherry picked from commit e323bc74b9abb3f694637848421237cf163594bc)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:11:02 +09:00
Daniel van Vugt
04421c2648
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.

(cherry picked from commit a83535e24aecb9148f334b3d5cef9537709dc52a)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:10:42 +09:00
Daniel van Vugt
1c1ff4aab1
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.

(cherry picked from commit 4304155aa2ef681814641f3ccb5e60c06347178c)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:10:22 +09:00
Daniel van Vugt
2ebb183629
clutter/frame-clock: Move "last" frame fields into structs
While in double buffering we only care about one previous presentation,
triple buffering will sometimes need to refer to the presentation from
two dispatches prior. So it might help to separate those frame stats
more clearly. This way each frame's dispatch and presentation times are
stored more cohesively such as to not be overwritten during overlapping
frame lifetimes.

Having two types of frame reference (dispatch and presentation) moving
at difference speeds meant that they could not be stored in a ring. Not
all dispatches become presentations and so storing them in a ring would
necessitate very complex conflict avoidance. Instead, a simple reference
counting model was used.

(cherry picked from commit 817a951b246b64fd1c4148e486d24017f71fc4c4)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3961>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:00:57 +09:00
Daniel van Vugt
6f955a0668
clutter/frame-clock: Notify on all empty frames
So that we maintain a perfectly balanced number of callbacks:

  dispatch == notify_ready + notify_presented

Otherwise you can't put any useful logic inside notify_ready and be sure
you're handling all the empty frames.

(cherry picked from commit 85f0f4e227b7f6896fc9fe6d6b9da4d568d2a9e7)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3961>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
2024-10-22 17:00:37 +09:00
Sebastian Wick
bd2fa3b885 gir: Correct usage of the closure annotation
Quoting Ebassi https://www.bassi.io/articles/2023/02/20/bindable-api-2023/:

    Whenever you’re describing a function that takes a callback, you
    should always annotate the callback argument with the argument that
    contains the user data using the (closure argument) annotation

    You should not annotate the data argument with a unary (closure).

    The unary (closure) is meant to be used when annotating the callback
    type

Recently gobject-introspection became a bit more strict with this and
that generated some warnings:

    Warning: Cogl: invalid "closure" annotation: only valid on callback
    parameters

This commit fix all the closure annotations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4058>
(cherry picked from commit 077eb80a8d)
2024-10-18 14:55:35 +02:00
Christian Hergert
1247452d19 gwakeup: Reduce wake-ups to only first item in queue
We only need to wake up the other side of the GAsyncQueue if we transition
from 0 to 1 item in the queue. Otherwise, we can be certain that the other
side has received a wakeup and will eventually flush the queue.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4007>
2024-09-17 10:07:07 +00:00
Bilal Elmoussaoui
736082f41a clutter/input-pointer: Get context from seat
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3989>
2024-09-01 00:13:28 +02:00
Bilal Elmoussaoui
0c03a6b676 clutter/seat: Keep a pointer to the context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3989>
2024-09-01 00:13:28 +02:00
Bilal Elmoussaoui
3c1d2d765b clutter/offscreen-effect: Pass a CoglContext to create_texture
As creating a texture requires one anyways

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3989>
2024-09-01 00:13:28 +02:00
Bilal Elmoussaoui
a80360ad38 clutter/stage: Remove unused title property
It was used for the titlebar title, which is no longer relavant
in current Clutter

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3989>
2024-09-01 00:13:28 +02:00
Bilal Elmoussaoui
2dc2ab94d3 clutter/backend: Remove unused vfuncs
The signals are still used by Actor/Text

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3989>
2024-09-01 00:13:28 +02:00
Sebastian Wick
86a0797819 clutter/color-state: Match reference luminance
This uses the luminance levels of the color states to anchor the white
of content instead of hard-coding the levels.

This also starts using uniforms for parts of the mapping which means we
don't have to generate and compile a shader when the luminance levels
change.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3953>
2024-08-30 20:03:43 +00:00
Sebastian Wick
03aad0d99e clutter/color-state: Add min/max/ref luminances
They represent the minimum and maximum luminance levels of the primary
color volume and the reference luminance level (reference white, SDR
white, ...) in the reference viewing environment.

They help anchoring the white level, optionally help with preserving the
dynamic range and help with adjusting from a "dark" to a "bright"
viewing environment.

The values have defaults which depend on the transfer characteristics.

This reflects the wayland color management protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3953>
2024-08-30 20:03:43 +00:00
Carlos Garnacho
fe9fff2729 clutter: Make detached actions let events through
Actions might get detached sometime during event processing,
at a time that the stage did already prepare an emission chain
holding references to the actions and actors that need to handle
events. This means actions might become detached, but still handle
the incoming event, or possible crossing events generated in-place
when the actor becomes unparented.

Avoid this situation, by skipping event handling on actions that
went detached, we will just instruct to continue event processing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3988>
2024-08-30 17:24:24 +00:00
Bilal Elmoussaoui
d584a512cb clutter/stage: Get Context from actor state
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:40 +02:00
Bilal Elmoussaoui
b3da64c20e clutter/pick-context: Get CoglContext from actor context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:40 +02:00
Bilal Elmoussaoui
617a3aa58b clutter/actor: Get Backend from associated actor context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:40 +02:00
Bilal Elmoussaoui
370e7d3157 clutter/text: Get Backend from associated actor context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:40 +02:00
Bilal Elmoussaoui
3152b4a3f1 clutter/stage: Get Backend & Context from the associated actor
Had to move the state construction from init to constructed, to ensure
that the Actor's constructor has been executed and Actor.get_context
won't return NULL

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:40 +02:00
Bilal Elmoussaoui
62da8d7aac clutter: Get CoglContext from a CoglTexture where possible
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:40 +02:00
Bilal Elmoussaoui
75c7ced752 clutter/text: Get CoglContext from the actor's associated Backend
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:39 +02:00
Bilal Elmoussaoui
bc633280d9 clutter/stage: Get Backend from stage's associated context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:39 +02:00
Bilal Elmoussaoui
1abbfb5ed2 clutter/context: Create a Settings when constructed
Instead of removing Settings.get_default, we mark it as deprecated
as a lot of extensions seems to use it

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:39 +02:00
Bilal Elmoussaoui
8013049130 clutter: Stop using Settings.get_default
Instead, get it from the context. See next commit
For ClutterText, we had to switch to using constructed
as the ClutterContext will be set for the ClutterActor in the
constructor phase

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:39 +02:00
Bilal Elmoussaoui
8a71c89442 clutter/backend: Keep a back pointer to the Context
Will be useful in the upcoming commits

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:39 +02:00
Bilal Elmoussaoui
b02a29fee7 clutter/context: Add API to get the corresponding Settings
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3977>
2024-08-29 15:26:39 +02:00
Michel Dänzer
c2621eca15 onscreen/native: Set latest cogl sync_fd on KMS update
See previous commit log on the effects of this.

This means the deadline evasion needs to be added in both cases in
clutter_frame_clock_notify_presented.

v2:
* Use meta_kms_update_set_sync_fd. (Jonas Ådahl)

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3958>
2024-08-28 14:42:38 +00:00
Bilal Elmoussaoui
70dc8cabac clutter/settings: Remove unused fontconfig-timestamp property
As a writable property, nothing sets it in both Mutter/GNOME Shell
making it a dead-code. As we will be moving pango related bits to
gnome-shell, remove this one already

Removes pango-ft2 dependency

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3969>
2024-08-22 19:09:51 +00:00
Bilal Elmoussaoui
60edafe3eb cogl/pango: Drop mipmapping API/env variables
As GNOME Shell always sets that to FALSE anyways
This does not drop the separate caching whether the mipmapping is
disabled or not, in case shell wants to make use of that in the future

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:01 +00:00
Bilal Elmoussaoui
4f606261d3 clutter: Remove unused get_font_map
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:01 +00:00
Bilal Elmoussaoui
39da6e10fa clutter/context: Move get_show_fps to it correct namespace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:01 +00:00
Bilal Elmoussaoui
078bbd82c8 clutter: Export Context header
As otherwise, GNOME Shell canno't make use of the public APIs, especially the
future Context.get_settings / Context.get_text_direction for example

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:01 +00:00
Bilal Elmoussaoui
8291b2d6d0 clutter/context: Free the stage manager
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:01 +00:00
Bilal Elmoussaoui
0d93f805d4 clutter/context: Create a StageManager when constructed
Instead of delegating that to StageManager.get_default and add a private getter
for it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:01 +00:00
Bilal Elmoussaoui
914787294f clutter/stage-manager: Mark as private type
Nothing is supposed to interact with it externally

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:01 +00:00
Bilal Elmoussaoui
09c7c2bf7b clutter/stage-manager: Remove unused APIs
As the type will be made private in future commits

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:01 +00:00
Bilal Elmoussaoui
5391ab56e8 clutter/stage-manager: Mark as final
It is not something that can be replaced

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:00 +00:00
Bilal Elmoussaoui
3fb1c9ab21 clutter/context: Remove unused is_initalized
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:00 +00:00
Bilal Elmoussaoui
3453a6e51f clutter/stage-manager: Remove unused default-stage
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3962>
2024-08-22 16:45:00 +00:00
Sebastian Wick
7610973a94 Replace deprecated g_qsort_with_data with g_sort_array
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3899>
2024-08-15 23:58:53 +02:00
Jonas Ådahl
6ec1312384 renderer-view/native: Update deadline evasion each frame
The deadline evasion depends on debug flags, but they are not trackable,
so update the deadline evasion each time we schedule an update.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3184>
2024-08-13 10:09:05 +00:00
Jonas Ådahl
5da94d2c1d clutter/frame-clock: Take deadline evasion into account
This is meant to be the amount of time before a CRTC deadline we're
usually dispatching at. It's not yet set by anything however.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3184>
2024-08-13 10:09:04 +00:00
Sebastian Wick
608d66afa5 renderer-view: Set ClutterColorStates from a MetaColorDevice
And stop passing in the color states from the RendererNative. We also
keep the color states updated by listening for changes in the color
device.

The RendererX11Cm has a single view and no mapping to a specific color
device, so we handle the absense of a color device as well and rely on
ClutterStageView to have the default color states.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00
Sebastian Wick
5b44d589b1 clutter/stage-view: Move offscreen creation functions around
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3930>
2024-08-09 15:51:36 +00:00