render/vulkan: New staging buffer implementation

Implement a ring-buffer that uses timeline points to track and release
allocated spans. We add larger ring-buffers when it fills, and remove
them when they have been unused for many collection cycles.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
This commit is contained in:
Kenny Levinsen 2026-04-12 17:10:40 +02:00 committed by Félix Poisot
parent 02abf1cd28
commit 4ee896af99
4 changed files with 211 additions and 155 deletions

View file

@ -72,16 +72,16 @@ static bool write_pixels(struct wlr_vk_texture *texture,
// get staging buffer
struct wlr_vk_buffer_span span = vulkan_get_stage_span(renderer, bsize, format_info->bytes_per_block);
if (!span.buffer || span.alloc.size != bsize) {
if (!span.buffer || span.size != bsize) {
wlr_log(WLR_ERROR, "Failed to retrieve staging buffer");
free(copies);
return false;
}
char *map = (char*)span.buffer->cpu_mapping + span.alloc.start;
char *map = (char*)span.buffer->cpu_mapping + span.offset;
// upload data
uint32_t buf_off = span.alloc.start;
uint32_t buf_off = span.offset;
for (int i = 0; i < rects_len; i++) {
pixman_box32_t rect = rects[i];
uint32_t width = rect.x2 - rect.x1;