diff options
author | Wenbin Chen <wenbin.chen@intel.com> | 2021-12-07 17:05:51 +0800 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2021-12-10 17:03:48 +0100 |
commit | bd6ef73399f3f2fcd59ae2ff358954bb536540f2 (patch) | |
tree | 03f38f2fc38984c8f19afbd68054f5e46f365f4c /libavutil/hwcontext_vulkan.h | |
parent | f3c9847c2754b7a43eb721c95e356a53085c2491 (diff) | |
download | ffmpeg-bd6ef73399f3f2fcd59ae2ff358954bb536540f2.tar.gz |
hwcontext_vulkan: add support for allocating all planes in a single allocation
VAAPI on Intel can import external frame, but the planes of the external
frames should be in the same drm object. A new option "contiguous_planes"
is added to device. This flag tells device to allocate places in one
memory. When device is derived from vaapi this flag will be enabled.
A new flag frame_flag is also added to AVVulkanFramesContext. User
can use this flag to force enable or disable this behaviour.
A new variable "offset "is added to AVVKFrame. It describe describe the
offset from the memory currently bound to the VkImage.
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Further-modifications-by: Lynne <dev@lynne.ee>
Diffstat (limited to 'libavutil/hwcontext_vulkan.h')
-rw-r--r-- | libavutil/hwcontext_vulkan.h | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h index fdf2a60156..ed59fe9f0a 100644 --- a/libavutil/hwcontext_vulkan.h +++ b/libavutil/hwcontext_vulkan.h @@ -138,6 +138,20 @@ typedef struct AVVulkanDeviceContext { } AVVulkanDeviceContext; /** + * Defines the behaviour of frame allocation. + */ +typedef enum AVVkFrameFlags { + /* Unless this flag is set, autodetected flags will be OR'd based on the + * device and tiling during av_hwframe_ctx_init(). */ + AV_VK_FRAME_FLAG_NONE = (1ULL << 0), + + /* Image planes will be allocated in a single VkDeviceMemory, rather + * than as per-plane VkDeviceMemory allocations. Required for exporting + * to VAAPI on Intel devices. */ + AV_VK_FRAME_FLAG_CONTIGUOUS_MEMORY = (1ULL << 1), +} AVVkFrameFlags; + +/** * Allocated as AVHWFramesContext.hwctx, used to set pool-specific options */ typedef struct AVVulkanFramesContext { @@ -165,6 +179,13 @@ typedef struct AVVulkanFramesContext { * extensions are present in enabled_dev_extensions. */ void *alloc_pnext[AV_NUM_DATA_POINTERS]; + + /** + * A combination of AVVkFrameFlags. Unless AV_VK_FRAME_FLAG_NONE is set, + * autodetected flags will be OR'd based on the device and tiling during + * av_hwframe_ctx_init(). + */ + AVVkFrameFlags flags; } AVVulkanFramesContext; /* @@ -192,8 +213,9 @@ typedef struct AVVkFrame { VkImageTiling tiling; /** - * Memory backing the images. Could be less than the amount of images - * if importing from a DRM or VAAPI frame. + * Memory backing the images. Could be less than the amount of planes, + * in which case the offset value will indicate the binding offset of + * each plane in the memory. */ VkDeviceMemory mem[AV_NUM_DATA_POINTERS]; size_t size[AV_NUM_DATA_POINTERS]; @@ -230,6 +252,11 @@ typedef struct AVVkFrame { * Internal data. */ struct AVVkFrameInternal *internal; + + /** + * Describes the binding offset of each plane to the VkDeviceMemory. + */ + ptrdiff_t offset[AV_NUM_DATA_POINTERS]; } AVVkFrame; /** |