hwcontext_vulkan: remove VK_HOST_IMAGE_COPY_MEMCPY flag

Reading the spec for what this flag means, it copies the data verbatim, including any swizzling/tiling, this has two issues

1. the format may not be what ffmpeg expects elsewhere, as it is expecing normal pitch linear host memeory in `swf`
2. the size of the copied data may not match the size of buffer provided, causing heap buffer overflow

It seems like addition of this flag is an oversight as it seems to be for caching/backups of image data, just to be used with copying back to the GPU with the MEMCPY flag, which is *not* how its used in ffmpeg.

Additionally, set memoryRowLength as if it isn't set, it assumes pitch = width_in_bytes, which I don't think is necessarily the case
This commit is contained in:
Russell Greene
2025-11-29 12:42:13 -07:00
committed by Lynne
parent 59d75bf9e4
commit 3beaa2d70f

View File

@@ -4440,7 +4440,6 @@ static int vulkan_transfer_host(AVHWFramesContext *hwfc, AVFrame *hwf,
};
VkCopyMemoryToImageInfoEXT copy_info = {
.sType = VK_STRUCTURE_TYPE_COPY_MEMORY_TO_IMAGE_INFO_EXT,
.flags = VK_HOST_IMAGE_COPY_MEMCPY_EXT,
.regionCount = 1,
.pRegions = &region_info,
};
@@ -4466,7 +4465,6 @@ static int vulkan_transfer_host(AVHWFramesContext *hwfc, AVFrame *hwf,
};
VkCopyImageToMemoryInfoEXT copy_info = {
.sType = VK_STRUCTURE_TYPE_COPY_IMAGE_TO_MEMORY_INFO_EXT,
.flags = VK_HOST_IMAGE_COPY_MEMCPY_EXT,
.regionCount = 1,
.pRegions = &region_info,
};
@@ -4476,6 +4474,7 @@ static int vulkan_transfer_host(AVHWFramesContext *hwfc, AVFrame *hwf,
get_plane_wh(&p_w, &p_h, swf->format, swf->width, swf->height, i);
region_info.pHostPointer = swf->data[i];
region_info.memoryRowLength = swf->linesize[i];
region_info.imageSubresource.aspectMask = ff_vk_aspect_flag(hwf, i);
region_info.imageExtent = (VkExtent3D){ p_w, p_h, 1 };
copy_info.srcImage = hwf_vk->img[img_idx];