From c4b8f06837c568be7ef2fc1e2945c94ae4f7533e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:27 +0200 Subject: [PATCH 01/11] render: Use pixman_region_empty() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can expect recent enough pixman that supports this nowadays. Signed-off-by: Guido Günther Part-of: --- src/render.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/render.c b/src/render.c index 18f723a64..cc5c291c9 100644 --- a/src/render.c +++ b/src/render.c @@ -482,10 +482,9 @@ phoc_renderer_render_output (PhocRenderer *self, PhocOutput *output, PhocRenderC g_assert (PHOC_IS_RENDERER (self)); - if (!pixman_region32_not_empty (damage)) { - /* Output isn't damaged but needs buffer swap */ + /* Output isn't damaged but needs buffer swap */ + if (pixman_region32_empty (damage)) goto renderer_end; - } wlr_render_pass_add_rect (ctx->render_pass, &(struct wlr_render_rect_options){ -- GitLab From f7ea4b264144eee6b0f19fdf4882197648da8152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:27 +0200 Subject: [PATCH 02/11] render: Exit early when there is no damage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As touch-points and debug-damage submit proper damage nowadays there's no point in proceeding. Software cursors are only rendered when they overlap with the pass in damage either. This has the nice side effect that we don't emit any tracemarks when there was nothing to render. We keep emitting `render-end` for the moment until we received that signal from the output shields. Signed-off-by: Guido Günther Part-of: --- src/render.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/render.c b/src/render.c index cc5c291c9..0b9ed93c3 100644 --- a/src/render.c +++ b/src/render.c @@ -482,9 +482,10 @@ phoc_renderer_render_output (PhocRenderer *self, PhocOutput *output, PhocRenderC g_assert (PHOC_IS_RENDERER (self)); - /* Output isn't damaged but needs buffer swap */ - if (pixman_region32_empty (damage)) - goto renderer_end; + if (pixman_region32_empty (damage)) { + g_signal_emit (self, signals[RENDER_END], 0, ctx); + return; + } wlr_render_pass_add_rect (ctx->render_pass, &(struct wlr_render_rect_options){ @@ -538,7 +539,6 @@ phoc_renderer_render_output (PhocRenderer *self, PhocOutput *output, PhocRenderC render_output_blings (output, ctx); - renderer_end: wlr_output_add_software_cursors_to_render_pass (wlr_output, ctx->render_pass, damage); if (G_UNLIKELY (phoc_server_check_debug_flags (server, PHOC_SERVER_DEBUG_FLAG_TOUCH_POINTS))) -- GitLab From 36a1aff7ec9df5eaa62cab972a587bf1de83dfbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:28 +0200 Subject: [PATCH 03/11] output: Fix indent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gbp-Dch: Ignore Signed-off-by: Guido Günther Part-of: --- src/output.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/output.c b/src/output.c index 6ebc5bbf4..536740cb6 100644 --- a/src/output.c +++ b/src/output.c @@ -562,9 +562,8 @@ build_debug_damage_tracking (PhocOutput *self) elem = next; }; - if (pixman_region32_not_empty (&highlight_damage)) { + if (pixman_region32_not_empty (&highlight_damage)) wlr_damage_ring_add (&self->damage_ring, &highlight_damage); - } pixman_region32_fini (&highlight_damage); } @@ -2438,7 +2437,6 @@ phoc_output_handle_gamma_control_set_gamma (struct wl_listener *listener, void * wlr_output_schedule_frame (self->wlr_output); } - /** * phoc_output_transform_damage: * @self: The output to transform for -- GitLab From 3289ea353bfc39868c6e29f7ce90a50d75fe0489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:29 +0200 Subject: [PATCH 04/11] output: Move pending finish closer to commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No need to keep it around longer Signed-off-by: Guido Günther Part-of: --- src/output.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index 536740cb6..29efc3b71 100644 --- a/src/output.c +++ b/src/output.c @@ -1059,6 +1059,7 @@ phoc_output_initable_init (GInitable *initable, phoc_output_fill_state (self, output_config, &pending); phoc_output_set_layout_pos (self, output_config); wlr_output_commit_state (self->wlr_output, &pending); + wlr_output_state_finish (&pending); for (GSList *elem = phoc_input_get_seats (input); elem; elem = elem->next) { PhocSeat *seat = PHOC_SEAT (elem->data); @@ -1089,8 +1090,6 @@ phoc_output_initable_init (GInitable *initable, } } - wlr_output_state_finish (&pending); - g_message ("Output '%s' added ('%s'/'%s'/'%s'), " "%" PRId32 "mm x %" PRId32 "mm", self->wlr_output->name, -- GitLab From 0d5d42a13d0390a735ef0875ddddc02696274485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:29 +0200 Subject: [PATCH 05/11] output: Use pixman_region_empty() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can expect recent enough pixman that supports this nowadays. Signed-off-by: Guido Günther Part-of: --- src/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output.c b/src/output.c index 29efc3b71..ab0bb19ba 100644 --- a/src/output.c +++ b/src/output.c @@ -1819,7 +1819,7 @@ phoc_output_damage_region (PhocOutput *self, const pixman_region32_t *region) pixman_region32_init (&clipped); pixman_region32_intersect_rect (&clipped, region, 0, 0, width, height); - if (!pixman_region32_not_empty (&clipped)) { + if (pixman_region32_empty (&clipped)) { pixman_region32_fini (&clipped); return FALSE; } -- GitLab From f998ec8e6c56e175ca82d960428826947cf1217d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:30 +0200 Subject: [PATCH 06/11] output: Drop pointless call to wlr_output_transformed_resolution() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: 550062499 ("wlroots: Upate to 79e06303") Signed-off-by: Guido Günther Part-of: --- src/output.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/output.c b/src/output.c index ab0bb19ba..6940a2fde 100644 --- a/src/output.c +++ b/src/output.c @@ -1009,7 +1009,6 @@ phoc_output_initable_init (GInitable *initable, PhocOutputPrivate *priv = phoc_output_get_instance_private (self); PhocOutputConfig *output_config; struct wlr_output_state pending; - int width, height; self->wlr_output->data = self; wl_list_insert (&self->desktop->outputs, &self->link); @@ -1075,8 +1074,6 @@ phoc_output_initable_init (GInitable *initable, update_output_manager_config (self->desktop); - wlr_output_transformed_resolution (self->wlr_output, &width, &height); - if (phoc_server_check_debug_flags (server, PHOC_SERVER_DEBUG_FLAG_CUTOUTS)) { priv->cutouts = phoc_cutouts_overlay_new (phoc_server_get_compatibles (server)); if (priv->cutouts) { -- GitLab From 6293d069ef13aaf18570a1357ee11990c161e96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:30 +0200 Subject: [PATCH 07/11] output: Drop pointless copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wlr_output_state_set_damage() copies aready so no need to copy it upfront. Signed-off-by: Guido Günther Part-of: --- src/output.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/output.c b/src/output.c index 6940a2fde..d063ac611 100644 --- a/src/output.c +++ b/src/output.c @@ -575,7 +575,7 @@ phoc_output_draw (PhocOutput *self) PhocOutputPrivate *priv = phoc_output_get_instance_private (self); struct wlr_output *wlr_output = self->wlr_output; bool needs_frame, scanned_out = false; - pixman_region32_t buffer_damage, frame_damage; + pixman_region32_t buffer_damage; PhocRenderContext render_context; struct wlr_buffer *buffer; struct wlr_render_pass *render_pass; @@ -596,10 +596,7 @@ phoc_output_draw (PhocOutput *self) if (G_UNLIKELY (priv->gamma_lut_changed)) phoc_output_set_gamma_lut (self, &pending); - pixman_region32_init (&frame_damage); - pixman_region32_copy (&frame_damage, &self->damage_ring.current); - wlr_output_state_set_damage (&pending, &frame_damage); - pixman_region32_fini (&frame_damage); + wlr_output_state_set_damage (&pending, &self->damage_ring.current); /* Check if we can delegate the fullscreen surface to the output */ if (self->fullscreen_view) -- GitLab From c85ce4bb3c74a05fae2fd23e22d107f5d8b27fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:31 +0200 Subject: [PATCH 08/11] output: Damage output early MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures we have a sufficiently sized damage size early on. Signed-off-by: Guido Günther Part-of: --- src/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output.c b/src/output.c index d063ac611..ab4040dd6 100644 --- a/src/output.c +++ b/src/output.c @@ -1020,6 +1020,7 @@ phoc_output_initable_init (GInitable *initable, } wlr_damage_ring_init (&self->damage_ring); + phoc_output_damage_whole (self); self->output_destroy.notify = phoc_output_handle_destroy; wl_signal_add (&self->wlr_output->events.destroy, &self->output_destroy); @@ -1067,7 +1068,6 @@ phoc_output_initable_init (GInitable *initable, phoc_layer_shell_arrange (self); phoc_layer_shell_update_focus (); - phoc_output_damage_whole (self); update_output_manager_config (self->desktop); -- GitLab From 3e57835adaea6550e957e6eb43d1321b5387f0af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:31 +0200 Subject: [PATCH 09/11] output: Damage whole output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of just adding the current damage_ring (of whatever size) ensure the damage ring's buffer covers the whole output. Signed-off-by: Guido Günther Part-of: --- src/output.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/output.c b/src/output.c index ab4040dd6..ca57032b0 100644 --- a/src/output.c +++ b/src/output.c @@ -1612,10 +1612,17 @@ phoc_output_for_each_surface (PhocOutput *self, void phoc_output_damage_whole (PhocOutput *self) { + pixman_region32_t damage; + int width, height; + if (self == NULL || self->wlr_output == NULL) return; - wlr_damage_ring_add_whole (&self->damage_ring); + wlr_output_transformed_resolution (self->wlr_output, &width, &height); + pixman_region32_init_rect (&damage, 0, 0, width, height); + phoc_output_damage_region (self, &damage); + pixman_region32_fini (&damage); + wlr_output_schedule_frame (self->wlr_output); } -- GitLab From f5ace945bb25dee58dbd73b69b498b23f6a8a106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:04:32 +0200 Subject: [PATCH 10/11] output: Drop check for debug_damage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we render debug-damage the damage-ring will contain the damage information for the rects to render so damage_ring.current will already be non-empty. Signed-off-by: Guido Günther Part-of: --- src/output.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/output.c b/src/output.c index ca57032b0..e38b23531 100644 --- a/src/output.c +++ b/src/output.c @@ -588,7 +588,6 @@ phoc_output_draw (PhocOutput *self) needs_frame = wlr_output->needs_frame; needs_frame |= pixman_region32_not_empty (&self->damage_ring.current); needs_frame |= priv->gamma_lut_changed; - needs_frame |= (priv->debug_damage != NULL); if (!needs_frame) return; -- GitLab From 6ed2eeac49f2ca6e565e5e2d5a90eba7ed0b93f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Sun, 28 Sep 2025 16:10:01 +0200 Subject: [PATCH 11/11] output: Damage output when transform/scale/mode changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wlr_damage_ring_set_bounds() damaged the whole buffer. Since that is gone we need to do that on our own. Fixes: 550062499 ("wlroots: Upate to 79e06303") Signed-off-by: Guido Günther Part-of: --- src/output.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/output.c b/src/output.c index e38b23531..cb2fc02ee 100644 --- a/src/output.c +++ b/src/output.c @@ -744,6 +744,7 @@ phoc_output_handle_commit (struct wl_listener *listener, void *data) phoc_output_raise_shield (self, FALSE); priv->modeset_shield = TRUE; } + phoc_output_damage_whole (self); } if (event->state->committed & (WLR_OUTPUT_STATE_ENABLED | @@ -753,11 +754,6 @@ phoc_output_handle_commit (struct wl_listener *listener, void *data) update_output_manager_config (self->desktop); } - if (event->state->committed & (WLR_OUTPUT_STATE_MODE | - WLR_OUTPUT_STATE_TRANSFORM)) { - wlr_output_schedule_frame (self->wlr_output); - } - if (event->state->committed & WLR_OUTPUT_STATE_ENABLED && self->wlr_output->enabled) { priv->gamma_lut_changed = TRUE; wlr_output_schedule_frame (self->wlr_output); -- GitLab