diff options
Diffstat (limited to 'render')
-rw-r--r-- | render/vulkan/renderer.c | 6 | ||||
-rw-r--r-- | render/vulkan/texture.c | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c index 0ef256c2..4a6f9bdf 100644 --- a/render/vulkan/renderer.c +++ b/render/vulkan/renderer.c @@ -200,7 +200,7 @@ static void release_stage_allocations(struct wlr_vk_renderer *renderer) { } struct wlr_vk_buffer_span vulkan_get_stage_span(struct wlr_vk_renderer *r, - VkDeviceSize size) { + VkDeviceSize size, VkDeviceSize alignment) { // try to find free span // simple greedy allocation algorithm - should be enough for this usecase // since all allocations are freed together after the frame @@ -215,6 +215,10 @@ struct wlr_vk_buffer_span vulkan_get_stage_span(struct wlr_vk_renderer *r, } assert(start <= buf->buf_size); + + // ensure the proposed start is a multiple of alignment + start += alignment - 1 - ((start + alignment - 1) % alignment); + if (buf->buf_size - start < size) { continue; } diff --git a/render/vulkan/texture.c b/render/vulkan/texture.c index 45e3fec9..9437cafc 100644 --- a/render/vulkan/texture.c +++ b/render/vulkan/texture.c @@ -73,7 +73,7 @@ static bool write_pixels(struct wlr_vk_texture *texture, } // get staging buffer - struct wlr_vk_buffer_span span = vulkan_get_stage_span(renderer, bsize); + struct wlr_vk_buffer_span span = vulkan_get_stage_span(renderer, bsize, bytespb); if (!span.buffer || span.alloc.size != bsize) { wlr_log(WLR_ERROR, "Failed to retrieve staging buffer"); free(copies); |