hwcontext_vulkan: add APIs to get optional extensions

These provide a way for apps that initialize Vulkan themselves to know
which extensions we may be able to use without having to hardcode it.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
This commit is contained in:
Cameron Gutman
2025-12-07 13:51:05 -06:00
committed by Lynne
parent ac9552bebf
commit 212eb8413a
4 changed files with 52 additions and 2 deletions

View File

@@ -2,6 +2,10 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first:
2025-12-xx - xxxxxxxxxx - lavu 60.20.100 - hwcontext_vulkan.h
Add av_vk_get_optional_instance_extensions().
Add av_vk_get_optional_device_extensions().
2025-12-xx - xxxxxxxxxx - lavc 62.22.101 - avcodec.h
Add avcodec_receive_frame_flags().
Add AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS.

View File

@@ -693,6 +693,34 @@ static const VulkanOptExtension optional_device_exts[] = {
{ VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME, FF_VK_EXT_VIDEO_DECODE_AV1 },
};
const char **av_vk_get_optional_instance_extensions(int *count)
{
const char **exts = av_malloc_array(sizeof(*exts),
FF_ARRAY_ELEMS(optional_instance_exts));
if (!exts)
return NULL;
for (int i = 0; i < FF_ARRAY_ELEMS(optional_instance_exts); i++)
exts[i] = optional_instance_exts[i].name;
*count = FF_ARRAY_ELEMS(optional_instance_exts);
return exts;
}
const char **av_vk_get_optional_device_extensions(int *count)
{
const char **exts = av_malloc_array(sizeof(*exts),
FF_ARRAY_ELEMS(optional_device_exts));
if (!exts)
return NULL;
for (int i = 0; i < FF_ARRAY_ELEMS(optional_device_exts); i++)
exts[i] = optional_device_exts[i].name;
*count = FF_ARRAY_ELEMS(optional_device_exts);
return exts;
}
static VkBool32 VKAPI_CALL vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity,
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *data,

View File

@@ -97,6 +97,8 @@ typedef struct AVVulkanDeviceContext {
* each entry containing the specified Vulkan extension string to enable.
* Duplicates are possible and accepted.
* If no extensions are enabled, set these fields to NULL, and 0 respectively.
* av_vk_get_optional_instance_extensions() can be used to enumerate extensions
* that FFmpeg may use if enabled.
*/
const char * const *enabled_inst_extensions;
int nb_enabled_inst_extensions;
@@ -108,6 +110,8 @@ typedef struct AVVulkanDeviceContext {
* If supplying your own device context, these fields takes the same format as
* the above fields, with the same conditions that duplicates are possible
* and accepted, and that NULL and 0 respectively means no extensions are enabled.
* av_vk_get_optional_device_extensions() can be used to enumerate extensions
* that FFmpeg may use if enabled.
*/
const char * const *enabled_dev_extensions;
int nb_enabled_dev_extensions;
@@ -375,4 +379,18 @@ AVVkFrame *av_vk_frame_alloc(void);
*/
const VkFormat *av_vkfmt_from_pixfmt(enum AVPixelFormat p);
/**
* Returns an array of optional Vulkan instance extensions that FFmpeg
* may use if enabled.
* @note Must be freed via av_free()
*/
const char **av_vk_get_optional_instance_extensions(int *count);
/**
* Returns an array of optional Vulkan device extensions that FFmpeg
* may use if enabled.
* @note Must be freed via av_free()
*/
const char **av_vk_get_optional_device_extensions(int *count);
#endif /* AVUTIL_HWCONTEXT_VULKAN_H */

View File

@@ -79,8 +79,8 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 60
#define LIBAVUTIL_VERSION_MINOR 19
#define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_MINOR 20
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \