Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ to `main` publishes every changed version at once, so when merging, rename

## Unreleased

### wlroots0.20 1:0.20.2-3

- Changing the display's refresh rate at the same resolution no longer
flashes a black frame before the compositor repaints.

### Updates follow releases

- The kernel packages and `omarchy-a` move to a new orchard or Omarchy A
Expand Down
14 changes: 9 additions & 5 deletions packages/wlroots0.20/arch/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Maintainer: Robin Candau <antiz@archlinux.org>
# Orchard: Arch's wlroots0.20 with fast rotated pixman compositing, a GLES2
# renderer that samples shared-memory buffers in place, and text-input-v3
# version 2 (apps asking for the on-screen keyboard), until wlroots has them
# renderer that samples shared-memory buffers in place, text-input-v3
# version 2 (apps asking for the on-screen keyboard), and flicker-free
# same-resolution refresh-rate modesets, until wlroots has them
# (see ../patches). The name is Arch's and [orchard] is listed first,
# so pacman takes this one; the epoch puts it above whatever Arch build a
# tablet already has.
Expand All @@ -10,7 +11,7 @@ pkgname=wlroots0.20
_pkgname=wlroots
epoch=1
pkgver=0.20.2
pkgrel=2
pkgrel=3
pkgdesc="Modular Wayland compositor library"
url="https://gitlab.freedesktop.org/wlroots/wlroots"
license=('MIT')
Expand All @@ -25,16 +26,19 @@ provides=("libwlroots-${pkgver%.*}.so")
source=("${_pkgname}-${pkgver}.tar.gz::${url}/-/releases/${pkgver}/downloads/${_pkgname}-${pkgver}.tar.gz"
'0001-render-pixman-rotate-first-then-blend-for-90-degree.patch'
'0002-render-gles2-sample-shared-memory-client-buffers-in-place.patch'
'0003-text-input-v3-support-version-2.patch')
'0003-text-input-v3-support-version-2.patch'
'0004-output-reuse-front-buffer-on-same-resolution-modeset.patch')
sha256sums=('80c567d2ed4efb2cfa6b077f22c7a710d9c78ba4e185a75e8694001114af0733'
'234879eb7b870b361bab5197409ef30201a09d9f5ab6c3b5715fde9f5ff796b8'
'f1301387337c41e6b2910e2c839d4120888aed883bcdf7ccdd0421699c328529'
'd814b1eebe52237c032b0355295cfb42282036520b24450b1b147d66bd84521d')
'd814b1eebe52237c032b0355295cfb42282036520b24450b1b147d66bd84521d'
'0903bb3a4144cffc7333607d71d93fd90a47abeb7013a1201756ec42084e1343')

prepare() {
patch -d "${_pkgname}-${pkgver}" -p1 < 0001-render-pixman-rotate-first-then-blend-for-90-degree.patch
patch -d "${_pkgname}-${pkgver}" -p1 < 0002-render-gles2-sample-shared-memory-client-buffers-in-place.patch
patch -d "${_pkgname}-${pkgver}" -p1 < 0003-text-input-v3-support-version-2.patch
patch -d "${_pkgname}-${pkgver}" -p1 < 0004-output-reuse-front-buffer-on-same-resolution-modeset.patch
}

build() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
From 14fefa05c1fcb2cc69632a944003d5052db62d5e Mon Sep 17 00:00:00 2001
From: Grier Johnson <grier@scooterfarm.com>
Date: Fri, 4 Dec 2026 19:49:09 -0700
Subject: [PATCH] types/output: Reuse current buffer on same-resolution mode
change

When a compositor changes only the refresh rate of an already-enabled
output without attaching a new buffer (e.g. wlr-output-management
applying a mode with the same width and height), output_ensure_buffer()
unconditionally acquired a newly cleared empty buffer and committed it
with the modeset, causing a brief black flash (~19 ms on simpledrm)
before the compositor painted the next frame.

The DRM backend already reuses primary->queued_fb / primary->current_fb
when WLR_OUTPUT_STATE_BUFFER is omitted. Skip attaching an empty buffer
on same-resolution mode changes when the output is already enabled, no
color transform or image description is being committed, and the
backend implements and passes test() without a new buffer, falling back
to an empty buffer otherwise.

In backend/drm:
- In per-output drm_connector_commit_state() (leaving device-wide
wlr_backend_test/commit untouched), only allow bufferless modeset
reuse when not running on a secondary GPU (mgpu_renderer) and when
the existing primary FB belongs to the output swapchain matching
output->render_format (avoiding scaled or lower-bpc direct-scanout
buffers across a modeset).
- Track queued_fb_reused on wlr_drm_plane and preserve
queued_release_timeline / current_release_timeline when a bufferless
commit keeps the same primary FB queued or scanning out, so
explicit-sync clients are never signaled while still displayed and
explicit resubmissions of the same buffer still release normally.

Assisted-by: LLM
---
backend/drm/drm.c | 67 +++++++++++++++++++++++++++++----------
include/backend/drm/drm.h | 1 +
types/output/render.c | 20 +++++++++---
3 files changed, 67 insertions(+), 21 deletions(-)

diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index bd29872..859e36a 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -14,6 +14,7 @@
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/render/drm_syncobj.h>
+#include <wlr/render/swapchain.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/util/box.h>
#include <wlr/util/log.h>
@@ -367,6 +368,7 @@ static void drm_plane_finish_surface(struct wlr_drm_plane *plane) {
}

drm_fb_clear(&plane->queued_fb);
+ plane->queued_fb_reused = false;
if (plane->queued_release_timeline != NULL) {
wlr_drm_syncobj_timeline_signal(plane->queued_release_timeline, plane->queued_release_point);
wlr_drm_syncobj_timeline_unref(plane->queued_release_timeline);
@@ -565,17 +567,24 @@ static void drm_connector_apply_commit(const struct wlr_drm_connector_state *sta
struct wlr_drm_connector *conn = state->connector;
struct wlr_drm_crtc *crtc = conn->crtc;

+ bool same_queued_fb = (crtc->primary->queued_fb != NULL &&
+ crtc->primary->queued_fb == state->primary_fb &&
+ !(state->base->committed & WLR_OUTPUT_STATE_BUFFER));
drm_fb_copy(&crtc->primary->queued_fb, state->primary_fb);
- if (crtc->primary->queued_release_timeline != NULL) {
- wlr_drm_syncobj_timeline_signal(crtc->primary->queued_release_timeline, crtc->primary->queued_release_point);
- wlr_drm_syncobj_timeline_unref(crtc->primary->queued_release_timeline);
- }
- if (state->base->signal_timeline != NULL) {
- crtc->primary->queued_release_timeline = wlr_drm_syncobj_timeline_ref(state->base->signal_timeline);
- crtc->primary->queued_release_point = state->base->signal_point;
- } else {
- crtc->primary->queued_release_timeline = NULL;
- crtc->primary->queued_release_point = 0;
+ if (!same_queued_fb) {
+ crtc->primary->queued_fb_reused =
+ !(state->base->committed & WLR_OUTPUT_STATE_BUFFER);
+ if (crtc->primary->queued_release_timeline != NULL) {
+ wlr_drm_syncobj_timeline_signal(crtc->primary->queued_release_timeline, crtc->primary->queued_release_point);
+ wlr_drm_syncobj_timeline_unref(crtc->primary->queued_release_timeline);
+ }
+ if (state->base->signal_timeline != NULL) {
+ crtc->primary->queued_release_timeline = wlr_drm_syncobj_timeline_ref(state->base->signal_timeline);
+ crtc->primary->queued_release_point = state->base->signal_point;
+ } else {
+ crtc->primary->queued_release_timeline = NULL;
+ crtc->primary->queued_release_point = 0;
+ }
}

crtc->primary->viewport = state->primary_viewport;
@@ -945,6 +954,25 @@ static bool drm_connector_commit_state(struct wlr_drm_connector *conn,
bool ok = false;
struct wlr_drm_connector_state pending = {0};
drm_connector_state_init(&pending, conn, state);
+
+ if (conn->output.renderer != NULL &&
+ (state->committed & WLR_OUTPUT_STATE_MODE) &&
+ !(state->committed & WLR_OUTPUT_STATE_BUFFER)) {
+ if (drm->mgpu_renderer.wlr_rend != NULL) {
+ wlr_drm_conn_log(conn, WLR_DEBUG,
+ "Cannot reuse primary FB across modeset on secondary GPU");
+ goto out;
+ }
+ if (pending.primary_fb == NULL || conn->output.swapchain == NULL ||
+ conn->output.swapchain->format.format != conn->output.render_format ||
+ !wlr_swapchain_has_buffer(conn->output.swapchain,
+ pending.primary_fb->wlr_buf)) {
+ wlr_drm_conn_log(conn, WLR_DEBUG,
+ "Cannot reuse non-swapchain primary FB across modeset");
+ goto out;
+ }
+ }
+
struct wlr_drm_device_state pending_dev = {
.modeset = state->allow_reconfiguration,
// The wlr_output API requires non-modeset commits with a new buffer to
@@ -2038,15 +2066,20 @@ static void handle_page_flip(int fd, unsigned seq,

struct wlr_drm_plane *plane = conn->crtc->primary;
if (plane->queued_fb) {
+ bool same_current_fb = (plane->current_fb == plane->queued_fb &&
+ plane->queued_fb_reused);
+ plane->queued_fb_reused = false;
drm_fb_move(&plane->current_fb, &plane->queued_fb);
- if (plane->current_release_timeline != NULL) {
- wlr_drm_syncobj_timeline_signal(plane->current_release_timeline, plane->current_release_point);
- wlr_drm_syncobj_timeline_unref(plane->current_release_timeline);
+ if (!same_current_fb) {
+ if (plane->current_release_timeline != NULL) {
+ wlr_drm_syncobj_timeline_signal(plane->current_release_timeline, plane->current_release_point);
+ wlr_drm_syncobj_timeline_unref(plane->current_release_timeline);
+ }
+ plane->current_release_timeline = plane->queued_release_timeline;
+ plane->current_release_point = plane->queued_release_point;
+ plane->queued_release_timeline = NULL;
+ plane->queued_release_point = 0;
}
- plane->current_release_timeline = plane->queued_release_timeline;
- plane->current_release_point = plane->queued_release_point;
- plane->queued_release_timeline = NULL;
- plane->queued_release_point = 0;
}
if (conn->crtc->cursor && conn->crtc->cursor->queued_fb) {
drm_fb_move(&conn->crtc->cursor->current_fb,
diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h
index a8c5e07..d47403d 100644
--- a/include/backend/drm/drm.h
+++ b/include/backend/drm/drm.h
@@ -29,6 +29,7 @@ struct wlr_drm_plane {

/* Buffer submitted to the kernel, will be presented on next vblank */
struct wlr_drm_fb *queued_fb;
+ bool queued_fb_reused;
struct wlr_drm_syncobj_timeline *queued_release_timeline;
uint64_t queued_release_point;
/* Buffer currently displayed on screen */
diff --git a/types/output/render.c b/types/output/render.c
index 155da5c..4499e33 100644
--- a/types/output/render.c
+++ b/types/output/render.c
@@ -99,14 +99,14 @@ bool output_ensure_buffer(struct wlr_output *output,
}

// If we're lighting up an output or changing its mode, make sure to
- // provide a new buffer
+ // provide a new buffer. Changing only the refresh rate on an already-
+ // enabled output at the same resolution can reuse the current front
+ // buffer if the backend accepts it, avoiding a blank black frame on
+ // modeset.
bool needs_new_buffer = false;
if ((state->committed & WLR_OUTPUT_STATE_ENABLED) && state->enabled) {
needs_new_buffer = true;
}
- if (state->committed & WLR_OUTPUT_STATE_MODE) {
- needs_new_buffer = true;
- }
if (state->committed & WLR_OUTPUT_STATE_RENDER_FORMAT) {
needs_new_buffer = true;
}
@@ -116,6 +116,18 @@ bool output_ensure_buffer(struct wlr_output *output,
// so the swapchain is created now.
needs_new_buffer = true;
}
+ if (!needs_new_buffer && (state->committed & WLR_OUTPUT_STATE_MODE)) {
+ int width, height;
+ output_pending_resolution(output, state, &width, &height);
+ if (!output->enabled || output->commit_seq == 0 ||
+ width != output->width || height != output->height ||
+ (state->committed & (WLR_OUTPUT_STATE_COLOR_TRANSFORM |
+ WLR_OUTPUT_STATE_IMAGE_DESCRIPTION)) ||
+ output->impl->test == NULL ||
+ !output->impl->test(output, state)) {
+ needs_new_buffer = true;
+ }
+ }
if (!needs_new_buffer) {
return true;
}
--
2.56.0