ffmpeg | branch: master | Lynne <[email protected]> | Mon Jul 20 12:36:47 2020 
+0000| [fe3ea13131d56bbd2b37af032abc3b7208050f61] | committer: Lynne

hwcontext_vulkan: remove plane size alignment checks when host importing

The process space is guaranteed to be aligned to the page size, hence we're
never going to map outside of our address space.
There are more optimizations to do with respect to chroma plane alignment and
buffer offsets, but that can be done later.

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

 libavutil/hwcontext_vulkan.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 5e51d0390f..a98ea916e7 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -3025,7 +3025,8 @@ static int 
vulkan_transfer_data_from_mem(AVHWFramesContext *hwfc, AVFrame *dst,
     for (int i = 0; i < planes; i++) {
         int h = src->height;
         int p_height = i > 0 ? AV_CEIL_RSHIFT(h, log2_chroma) : h;
-        size_t p_size = FFABS(src->linesize[i]) * p_height;
+        size_t p_size = FFALIGN(FFABS(src->linesize[i]) * p_height,
+                                p->hprops.minImportedHostPointerAlignment);
 
         VkImportMemoryHostPointerInfoEXT import_desc = {
             .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT,
@@ -3036,7 +3037,6 @@ static int 
vulkan_transfer_data_from_mem(AVHWFramesContext *hwfc, AVFrame *dst,
         /* We can only map images with positive stride and alignment 
appropriate
          * for the device. */
         host_mapped[i] = map_host && src->linesize[i] > 0 &&
-                         !(p_size % p->hprops.minImportedHostPointerAlignment) 
&&
                          !(((uintptr_t)import_desc.pHostPointer) %
                            p->hprops.minImportedHostPointerAlignment);
         p_size = host_mapped[i] ? p_size : 0;
@@ -3209,7 +3209,8 @@ static int vulkan_transfer_data_to_mem(AVHWFramesContext 
*hwfc, AVFrame *dst,
     for (int i = 0; i < planes; i++) {
         int h = dst->height;
         int p_height = i > 0 ? AV_CEIL_RSHIFT(h, log2_chroma) : h;
-        size_t p_size = FFABS(dst->linesize[i]) * p_height;
+        size_t p_size = FFALIGN(FFABS(dst->linesize[i]) * p_height,
+                                p->hprops.minImportedHostPointerAlignment);
 
         VkImportMemoryHostPointerInfoEXT import_desc = {
             .sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT,
@@ -3220,7 +3221,6 @@ static int vulkan_transfer_data_to_mem(AVHWFramesContext 
*hwfc, AVFrame *dst,
         /* We can only map images with positive stride and alignment 
appropriate
          * for the device. */
         host_mapped[i] = map_host && dst->linesize[i] > 0 &&
-                         !(p_size % p->hprops.minImportedHostPointerAlignment) 
&&
                          !(((uintptr_t)import_desc.pHostPointer) %
                            p->hprops.minImportedHostPointerAlignment);
         p_size = host_mapped[i] ? p_size : 0;

_______________________________________________
ffmpeg-cvslog mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to