mutter tearing patches

This commit is contained in:
2026-09-03 10:10:52 +02:00
parent 777acf7503
commit c9725d3b78
3 changed files with 103 additions and 1 deletions
@@ -34,6 +34,7 @@ in
# inherit system; # inherit system;
imports = [ imports = [
./configuration.nix ./configuration.nix
./mutter-tearing.nix
./video.nix ./video.nix
inputs.aagl.nixosModules.default inputs.aagl.nixosModules.default
]; ];
@@ -0,0 +1,51 @@
diff --git a/src/compositor/meta-compositor-view-native.c b/src/compositor/meta-compositor-view-native.c
--- a/src/compositor/meta-compositor-view-native.c
+++ b/src/compositor/meta-compositor-view-native.c
@@ -289,9 +289,11 @@ find_scanout_candidate (MetaCompositorView *compositor_view,
return FALSE;
if (!meta_stage_view_is_cursor_overlay_inhibited (view) &&
+ !meta_onscreen_native_is_tearing_enabled (
+ META_ONSCREEN_NATIVE (framebuffer)) &&
surface_actor_has_overlapping_cursor_overlays (compositor,
compositor_view,
surface_actor))
{
meta_topic (META_DEBUG_RENDER,
"No direct scanout candidate: overlapping software cursors");
diff --git a/src/meson.build b/src/meson.build
--- a/src/meson.build
+++ b/src/meson.build
@@ -1077,5 +1077,6 @@ wayland_protocols = [
['single-pixel-buffer', 'staging', 1, ],
['tablet', 'stable', 2, ],
+ ['tearing-control', 'staging', 1, ],
['text-input-unstable-v3', 'private', ],
['viewporter', 'stable', ],
['xdg-activation', 'staging', 1, ],
diff --git a/src/wayland/meta-wayland-dma-buf.c b/src/wayland/meta-wayland-dma-buf.c
--- a/src/wayland/meta-wayland-dma-buf.c
+++ b/src/wayland/meta-wayland-dma-buf.c
@@ -630,11 +630,22 @@ has_modifier (GArray *modifiers,
}
#ifdef HAVE_NATIVE_BACKEND
+static gboolean
+async_supports_modifier (MetaKmsPlane *plane,
+ uint32_t drm_format,
+ uint64_t drm_modifier)
+{
+ GArray *async_modifiers =
+ meta_kms_plane_get_async_modifiers_for_format (plane, drm_format);
+ return async_modifiers && has_modifier (async_modifiers, drm_modifier);
+}
+
static gboolean
crtc_supports_modifier (MetaCrtcKms *crtc_kms,
uint32_t drm_format,
- uint64_t drm_modifier)
+ uint64_t drm_modifier,
+ gboolean is_async)
{
MetaKmsPlane *plane = meta_crtc_kms_get_assigned_primary_plane (crtc_kms);
GArray *crtc_modifiers;
@@ -0,0 +1,50 @@
{ lib, pkgs, ... }:
let
# GNOME/mutter!3797, pinned because the MR is still under development.
mutterTearingRevision = "a8d56d423edde9e6d76f6b9cab663d82c65cf1a2";
mutterTearingPatch = pkgs.fetchurl {
url = "https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3797.diff";
hash = "sha256-3up5PsHX+BSQRKb9JS5bnJLPaTGmvV55M18tKkepIng=";
};
in
{
nixpkgs.overlays = [
(final: prev: {
mutter = prev.mutter.overrideAttrs (old: {
pname = "mutter-tearing";
# The MR currently targets Mutter 51. Apply it to the packaged Mutter
# 50 source, then resolve the four small context conflicts separately.
prePatch = ''
${old.prePatch or ""}
set +e
patch --batch -p1 --forward < ${mutterTearingPatch}
mr_status=$?
set -e
if [ "$mr_status" -ne 0 ]; then
reject_count="$(find . -name '*.rej' -type f | wc -l)"
if [ "$reject_count" -ne 3 ]; then
echo "Unexpected number of Mutter !3797 rejects: $reject_count" >&2
exit 1
fi
fi
patch --batch -p1 --forward < ${./mutter-50-tearing-compat.patch}
find . -name '*.rej' -type f -delete
'';
passthru = (old.passthru or { }) // {
tearingMr = 3797;
tearingRevision = mutterTearingRevision;
};
});
})
];
# Mutter keeps tearing support behind an experimental runtime switch.
environment.sessionVariables.MUTTER_DEBUG_EXPERIMENTAL_FEATURES =
lib.mkDefault "tearing";
}