[FFmpeg-cvslog] vulkan: move alignment of host-visible allocations outside of ff_vk_alloc_mem

Lynne git at videolan.org
Wed Oct 23 09:16:31 EEST 2024


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Wed Oct 23 06:11:40 2024 +0000| [9eb7e8d2a4da108c9cf5d25984cf20b613ce593e] | committer: Lynne

vulkan: move alignment of host-visible allocations outside of ff_vk_alloc_mem

The issue is that if dedicated allocation is used, VkBufferCreateInfo.size
and the actual allocated size mismatched, which is a validation error.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9eb7e8d2a4da108c9cf5d25984cf20b613ce593e
---

 libavutil/vulkan.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index f15f5f8000..39143c6d94 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -883,10 +883,6 @@ int ff_vk_alloc_mem(FFVulkanContext *s, VkMemoryRequirements *req,
         .pNext           = alloc_extension,
     };
 
-    /* Align if we need to */
-    if ((req_flags != UINT32_MAX) && req_flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
-        req->size = FFALIGN(req->size, s->props.properties.limits.minMemoryMapAlignment);
-
     alloc_info.allocationSize = req->size;
 
     /* The vulkan spec requires memory types to be sorted in the "optimal"
@@ -939,8 +935,9 @@ int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, size_t size,
         .pNext       = pNext,
         .usage       = usage,
         .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
-        .size        = size, /* Gets FFALIGNED during alloc if host visible
-                                but should be ok */
+        .size        = flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT ?
+                       FFALIGN(size, s->props.properties.limits.minMemoryMapAlignment) :
+                       size,
     };
 
     VkMemoryAllocateFlagsInfo alloc_flags = {



More information about the ffmpeg-cvslog mailing list