mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
hwcontext_vulkan: add support for mapping frames with planes in a single VkDeviceMemory
Add support to map vulkan frames to software frames when using contiguous_planes flag. Signed-off-by: Wenbin Chen <wenbin.chen@intel.com> Further-modifications-by: Lynne <dev@lynne.ee>
This commit is contained in:
parent
bd6ef73399
commit
0d524b170e
@ -2332,9 +2332,10 @@ static int vulkan_map_frame_to_mem(AVHWFramesContext *hwfc, AVFrame *dst,
|
|||||||
const AVFrame *src, int flags)
|
const AVFrame *src, int flags)
|
||||||
{
|
{
|
||||||
VkResult ret;
|
VkResult ret;
|
||||||
int err, mapped_mem_count = 0;
|
int err, mapped_mem_count = 0, mem_planes = 0;
|
||||||
AVVkFrame *f = (AVVkFrame *)src->data[0];
|
AVVkFrame *f = (AVVkFrame *)src->data[0];
|
||||||
AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
|
AVVulkanDeviceContext *hwctx = hwfc->device_ctx->hwctx;
|
||||||
|
AVVulkanFramesContext *hwfctx = hwfc->hwctx;
|
||||||
const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
|
const int planes = av_pix_fmt_count_planes(hwfc->sw_format);
|
||||||
VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
|
VulkanDevicePriv *p = hwfc->device_ctx->internal->priv;
|
||||||
FFVulkanFunctions *vk = &p->vkfn;
|
FFVulkanFunctions *vk = &p->vkfn;
|
||||||
@ -2361,7 +2362,8 @@ static int vulkan_map_frame_to_mem(AVHWFramesContext *hwfc, AVFrame *dst,
|
|||||||
dst->width = src->width;
|
dst->width = src->width;
|
||||||
dst->height = src->height;
|
dst->height = src->height;
|
||||||
|
|
||||||
for (int i = 0; i < planes; i++) {
|
mem_planes = hwfctx->flags & AV_VK_FRAME_FLAG_CONTIGUOUS_MEMORY ? 1 : planes;
|
||||||
|
for (int i = 0; i < mem_planes; i++) {
|
||||||
ret = vk->MapMemory(hwctx->act_dev, f->mem[i], 0,
|
ret = vk->MapMemory(hwctx->act_dev, f->mem[i], 0,
|
||||||
VK_WHOLE_SIZE, 0, (void **)&dst->data[i]);
|
VK_WHOLE_SIZE, 0, (void **)&dst->data[i]);
|
||||||
if (ret != VK_SUCCESS) {
|
if (ret != VK_SUCCESS) {
|
||||||
@ -2373,6 +2375,11 @@ static int vulkan_map_frame_to_mem(AVHWFramesContext *hwfc, AVFrame *dst,
|
|||||||
mapped_mem_count++;
|
mapped_mem_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hwfctx->flags & AV_VK_FRAME_FLAG_CONTIGUOUS_MEMORY) {
|
||||||
|
for (int i = 0; i < planes; i++)
|
||||||
|
dst->data[i] = dst->data[0] + f->offset[i];
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if the memory contents matter */
|
/* Check if the memory contents matter */
|
||||||
if (((flags & AV_HWFRAME_MAP_READ) || !(flags & AV_HWFRAME_MAP_OVERWRITE)) &&
|
if (((flags & AV_HWFRAME_MAP_READ) || !(flags & AV_HWFRAME_MAP_OVERWRITE)) &&
|
||||||
!(f->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
|
!(f->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user