From c02872e033b431d9f02a240abeebdf0aaa043ea6 Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Fri, 25 Nov 2022 12:28:43 -0500 Subject: render/vulkan: align staging buffers for texture upload vkCmdCopyBufferToImage requires that the buffer offset be a multiple of the texel block size, which for single plane uncompressed formats is the same as the number of bytes per pixel. This commit adds an alignment parameter to vulkan_get_stage_span which ensures that the provided span (and the sequence of image copy operations derived which use it) have this alignment. --- include/render/vulkan.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/render') diff --git a/include/render/vulkan.h b/include/render/vulkan.h index 8063291f..149161c2 100644 --- a/include/render/vulkan.h +++ b/include/render/vulkan.h @@ -231,9 +231,11 @@ bool vulkan_submit_stage_wait(struct wlr_vk_renderer *renderer); // Suballocates a buffer span with the given size that can be mapped // and used as staging buffer. The allocation is implicitly released when the -// stage cb has finished execution. +// stage cb has finished execution. The start of the span will be a multiple +// of the given alignment. struct wlr_vk_buffer_span vulkan_get_stage_span( - struct wlr_vk_renderer *renderer, VkDeviceSize size); + struct wlr_vk_renderer *renderer, VkDeviceSize size, + VkDeviceSize alignment); // Tries to allocate a texture descriptor set. Will additionally // return the pool it was allocated from when successful (for freeing it later). -- cgit v1.2.3