wlr_scene: Don't special case swapchain buffers

This fixes direct scanout VRR. As direct scanout buffers are not part
of the swapchain, we would mistakenly union instead of subtract the damage
meaning it will just accumulate indefinitely.

The reason for this existing in the first place is for compositors that
might want to sidestep scene and commit their own buffers to the output.
In this case, scene could theoretically acknowledge that and update the
damage. Except, this really didn't work because WLR_OUTPUT_STATE_DAMAGE
would need to be defined which is optional. This patch also properly
acknowledges commits without damage.

In the use case of a weird compositor that might want to sidestep scene,
they can just trash the damage ring themselves.

Fixes: #3871
This commit is contained in:
Alexander Orzechowski 2024-08-13 16:44:50 -04:00
parent 3e1358fec9
commit 14e1987f50

View File

@ -1447,22 +1447,13 @@ static void scene_output_handle_commit(struct wl_listener *listener, void *data)
// if the output has been committed with a certain damage, we know that region // if the output has been committed with a certain damage, we know that region
// will be acknowledged by the backend so we don't need to keep track of it // will be acknowledged by the backend so we don't need to keep track of it
// anymore // anymore
if (state->committed & WLR_OUTPUT_STATE_DAMAGE) { if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
bool tracking_buffer = false; if (state->committed & WLR_OUTPUT_STATE_DAMAGE) {
struct wlr_damage_ring_buffer *buffer;
wl_list_for_each(buffer, &scene_output->damage_ring.buffers, link) {
if (buffer->buffer == state->buffer) {
tracking_buffer = true;
break;
}
}
if (tracking_buffer) {
pixman_region32_subtract(&scene_output->pending_commit_damage, pixman_region32_subtract(&scene_output->pending_commit_damage,
&scene_output->pending_commit_damage, &state->damage); &scene_output->pending_commit_damage, &state->damage);
} else { } else {
pixman_region32_union(&scene_output->pending_commit_damage, pixman_region32_fini(&scene_output->pending_commit_damage);
&scene_output->pending_commit_damage, &state->damage); pixman_region32_init(&scene_output->pending_commit_damage);
} }
} }