diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index e4aadc10..37569c18 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -89,7 +89,7 @@ struct wlr_buffer *drm_surface_blit(struct wlr_drm_surface *surf, return NULL; } - struct wlr_buffer *dst = wlr_swapchain_acquire(surf->swapchain, NULL); + struct wlr_buffer *dst = wlr_swapchain_acquire(surf->swapchain); if (!dst) { wlr_log(WLR_ERROR, "Failed to acquire multi-GPU swapchain buffer"); goto error_tex; diff --git a/include/wlr/render/swapchain.h b/include/wlr/render/swapchain.h index cb3aee9d..2317f1b6 100644 --- a/include/wlr/render/swapchain.h +++ b/include/wlr/render/swapchain.h @@ -10,7 +10,6 @@ struct wlr_swapchain_slot { struct wlr_buffer *buffer; bool acquired; // waiting for release - int age; struct wl_listener release; }; @@ -36,21 +35,12 @@ void wlr_swapchain_destroy(struct wlr_swapchain *swapchain); * The returned buffer is locked. When the caller is done with it, they must * unlock it by calling wlr_buffer_unlock. */ -struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain, - int *age); +struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain); /** * Returns true if this buffer has been created by this swapchain, and false * otherwise. */ bool wlr_swapchain_has_buffer(struct wlr_swapchain *swapchain, struct wlr_buffer *buffer); -/** - * Mark the buffer as submitted for presentation. This needs to be called by - * swap chain users on frame boundaries. - * - * If the buffer hasn't been created via the swap chain, the call is ignored. - */ -void wlr_swapchain_set_buffer_submitted(struct wlr_swapchain *swapchain, - struct wlr_buffer *buffer); #endif diff --git a/include/wlr/types/wlr_damage_ring.h b/include/wlr/types/wlr_damage_ring.h index 203d919f..3f469af6 100644 --- a/include/wlr/types/wlr_damage_ring.h +++ b/include/wlr/types/wlr_damage_ring.h @@ -15,9 +15,6 @@ #include #include -/* For triple buffering, a history of two frames is required. */ -#define WLR_DAMAGE_RING_PREVIOUS_LEN 2 - struct wlr_box; struct wlr_damage_ring_buffer { @@ -37,9 +34,6 @@ struct wlr_damage_ring { // private state - pixman_region32_t previous[WLR_DAMAGE_RING_PREVIOUS_LEN]; - size_t previous_idx; - struct wl_list buffers; // wlr_damage_ring_buffer.link }; @@ -79,20 +73,6 @@ bool wlr_damage_ring_add_box(struct wlr_damage_ring *ring, */ void wlr_damage_ring_add_whole(struct wlr_damage_ring *ring); -/** - * Rotate the damage ring. This needs to be called after using the accumulated - * damage, e.g. after rendering to an output's back buffer. - */ -void wlr_damage_ring_rotate(struct wlr_damage_ring *ring); - -/** - * Get accumulated damage, which is the difference between the current buffer - * and the buffer with age of buffer_age; in context of rendering, this is - * the region that needs to be redrawn. - */ -void wlr_damage_ring_get_buffer_damage(struct wlr_damage_ring *ring, - int buffer_age, pixman_region32_t *damage); - /** * Get accumulated buffer damage and rotate the damage ring. * diff --git a/render/swapchain.c b/render/swapchain.c index a50dae5c..233d85eb 100644 --- a/render/swapchain.c +++ b/render/swapchain.c @@ -65,7 +65,7 @@ static void slot_handle_release(struct wl_listener *listener, void *data) { } static struct wlr_buffer *slot_acquire(struct wlr_swapchain *swapchain, - struct wlr_swapchain_slot *slot, int *age) { + struct wlr_swapchain_slot *slot) { assert(!slot->acquired); assert(slot->buffer != NULL); @@ -74,15 +74,10 @@ static struct wlr_buffer *slot_acquire(struct wlr_swapchain *swapchain, slot->release.notify = slot_handle_release; wl_signal_add(&slot->buffer->events.release, &slot->release); - if (age != NULL) { - *age = slot->age; - } - return wlr_buffer_lock(slot->buffer); } -struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain, - int *age) { +struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain) { struct wlr_swapchain_slot *free_slot = NULL; for (size_t i = 0; i < WLR_SWAPCHAIN_CAP; i++) { struct wlr_swapchain_slot *slot = &swapchain->slots[i]; @@ -90,7 +85,7 @@ struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain, continue; } if (slot->buffer != NULL) { - return slot_acquire(swapchain, slot, age); + return slot_acquire(swapchain, slot); } free_slot = slot; } @@ -110,7 +105,7 @@ struct wlr_buffer *wlr_swapchain_acquire(struct wlr_swapchain *swapchain, wlr_log(WLR_ERROR, "Failed to allocate buffer"); return NULL; } - return slot_acquire(swapchain, free_slot, age); + return slot_acquire(swapchain, free_slot); } bool wlr_swapchain_has_buffer(struct wlr_swapchain *swapchain, @@ -123,23 +118,3 @@ bool wlr_swapchain_has_buffer(struct wlr_swapchain *swapchain, } return false; } - -void wlr_swapchain_set_buffer_submitted(struct wlr_swapchain *swapchain, - struct wlr_buffer *buffer) { - assert(buffer != NULL); - - if (!wlr_swapchain_has_buffer(swapchain, buffer)) { - return; - } - - // See the algorithm described in: - // https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_buffer_age.txt - for (size_t i = 0; i < WLR_SWAPCHAIN_CAP; i++) { - struct wlr_swapchain_slot *slot = &swapchain->slots[i]; - if (slot->buffer == buffer) { - slot->age = 1; - } else if (slot->age > 0) { - slot->age++; - } - } -} diff --git a/types/output/cursor.c b/types/output/cursor.c index 95793a39..7bc8d0d6 100644 --- a/types/output/cursor.c +++ b/types/output/cursor.c @@ -241,8 +241,7 @@ static struct wlr_buffer *render_cursor_buffer(struct wlr_output_cursor *cursor) } } - struct wlr_buffer *buffer = - wlr_swapchain_acquire(output->cursor_swapchain, NULL); + struct wlr_buffer *buffer = wlr_swapchain_acquire(output->cursor_swapchain); if (buffer == NULL) { return NULL; } diff --git a/types/output/output.c b/types/output/output.c index 1c9a0077..6755493f 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -271,11 +271,6 @@ static void output_apply_state(struct wlr_output *output, } } - if ((state->committed & WLR_OUTPUT_STATE_BUFFER) && - output->swapchain != NULL) { - wlr_swapchain_set_buffer_submitted(output->swapchain, state->buffer); - } - bool mode_updated = false; if (state->committed & WLR_OUTPUT_STATE_MODE) { int width = 0, height = 0, refresh = 0; diff --git a/types/output/render.c b/types/output/render.c index a70b79b7..b71478a6 100644 --- a/types/output/render.c +++ b/types/output/render.c @@ -55,7 +55,7 @@ static struct wlr_buffer *output_acquire_empty_buffer(struct wlr_output *output, return NULL; } - struct wlr_buffer *buffer = wlr_swapchain_acquire(output->swapchain, NULL); + struct wlr_buffer *buffer = wlr_swapchain_acquire(output->swapchain); if (buffer == NULL) { return NULL; } @@ -204,7 +204,7 @@ struct wlr_render_pass *wlr_output_begin_render_pass(struct wlr_output *output, return NULL; } - struct wlr_buffer *buffer = wlr_swapchain_acquire(output->swapchain, NULL); + struct wlr_buffer *buffer = wlr_swapchain_acquire(output->swapchain); if (buffer == NULL) { return NULL; } diff --git a/types/output/swapchain.c b/types/output/swapchain.c index 5a16610d..01857a20 100644 --- a/types/output/swapchain.c +++ b/types/output/swapchain.c @@ -50,7 +50,7 @@ static struct wlr_swapchain *create_swapchain(struct wlr_output *output, static bool test_swapchain(struct wlr_output *output, struct wlr_swapchain *swapchain, const struct wlr_output_state *state) { - struct wlr_buffer *buffer = wlr_swapchain_acquire(swapchain, NULL); + struct wlr_buffer *buffer = wlr_swapchain_acquire(swapchain); if (buffer == NULL) { return false; } diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index b3d9aade..884c2e11 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -2089,7 +2089,7 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output, swapchain = output->swapchain; } - struct wlr_buffer *buffer = wlr_swapchain_acquire(swapchain, NULL); + struct wlr_buffer *buffer = wlr_swapchain_acquire(swapchain); if (buffer == NULL) { return false; } diff --git a/types/wlr_damage_ring.c b/types/wlr_damage_ring.c index 2934de8b..840c872d 100644 --- a/types/wlr_damage_ring.c +++ b/types/wlr_damage_ring.c @@ -15,10 +15,6 @@ void wlr_damage_ring_init(struct wlr_damage_ring *ring) { }; pixman_region32_init(&ring->current); - for (size_t i = 0; i < WLR_DAMAGE_RING_PREVIOUS_LEN; ++i) { - pixman_region32_init(&ring->previous[i]); - } - wl_list_init(&ring->buffers); } @@ -31,9 +27,6 @@ static void buffer_destroy(struct wlr_damage_ring_buffer *entry) { void wlr_damage_ring_finish(struct wlr_damage_ring *ring) { pixman_region32_fini(&ring->current); - for (size_t i = 0; i < WLR_DAMAGE_RING_PREVIOUS_LEN; ++i) { - pixman_region32_fini(&ring->previous[i]); - } struct wlr_damage_ring_buffer *entry, *tmp_entry; wl_list_for_each_safe(entry, tmp_entry, &ring->buffers, link) { buffer_destroy(entry); @@ -92,43 +85,6 @@ void wlr_damage_ring_add_whole(struct wlr_damage_ring *ring) { &ring->current, 0, 0, ring->width, ring->height); } -void wlr_damage_ring_rotate(struct wlr_damage_ring *ring) { - // modular decrement - ring->previous_idx = ring->previous_idx + - WLR_DAMAGE_RING_PREVIOUS_LEN - 1; - ring->previous_idx %= WLR_DAMAGE_RING_PREVIOUS_LEN; - - pixman_region32_copy(&ring->previous[ring->previous_idx], &ring->current); - pixman_region32_clear(&ring->current); -} - -void wlr_damage_ring_get_buffer_damage(struct wlr_damage_ring *ring, - int buffer_age, pixman_region32_t *damage) { - if (buffer_age <= 0 || buffer_age - 1 > WLR_DAMAGE_RING_PREVIOUS_LEN) { - pixman_region32_clear(damage); - pixman_region32_union_rect(damage, damage, - 0, 0, ring->width, ring->height); - } else { - pixman_region32_copy(damage, &ring->current); - - // Accumulate damage from old buffers - for (int i = 0; i < buffer_age - 1; ++i) { - int j = (ring->previous_idx + i) % WLR_DAMAGE_RING_PREVIOUS_LEN; - pixman_region32_union(damage, damage, &ring->previous[j]); - } - - // Check the number of rectangles - int n_rects = pixman_region32_n_rects(damage); - if (n_rects > WLR_DAMAGE_RING_MAX_RECTS) { - pixman_box32_t *extents = pixman_region32_extents(damage); - pixman_region32_union_rect(damage, damage, - extents->x1, extents->y1, - extents->x2 - extents->x1, - extents->y2 - extents->y1); - } - } -} - static void entry_squash_damage(struct wlr_damage_ring_buffer *entry) { pixman_region32_t *prev; if (entry->link.prev == &entry->ring->buffers) { diff --git a/types/wlr_output_swapchain_manager.c b/types/wlr_output_swapchain_manager.c index c2cca43c..9df3a652 100644 --- a/types/wlr_output_swapchain_manager.c +++ b/types/wlr_output_swapchain_manager.c @@ -143,7 +143,7 @@ static bool manager_output_prepare(struct wlr_output_swapchain_manager_output *m return false; } - struct wlr_buffer *buffer = wlr_swapchain_acquire(swapchain, NULL); + struct wlr_buffer *buffer = wlr_swapchain_acquire(swapchain); if (buffer == NULL) { return false; } diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index acd584d5..c1fbb59c 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -542,8 +542,7 @@ static void capture_output(struct wl_client *wl_client, goto error; } - int buffer_age; - struct wlr_buffer *buffer = wlr_swapchain_acquire(output->swapchain, &buffer_age); + struct wlr_buffer *buffer = wlr_swapchain_acquire(output->swapchain); if (buffer == NULL) { goto error; }