[FFmpeg-devel] [PATCH] libavutil: Replace obsolete functions with 2-suffix

Link Mauve ffmpeg at linkmauve.fr
Wed Apr 9 21:28:18 EEST 2025


From: Link Mauve <linkmauve at linkmauve.fr>

These functions got replaced in the Vulkan API because they had
forgotten extensibility through the pNext pointer, otherwise used
everywhere in the API.

For two of these functions we already had the 2 pointer loaded, so this
avoids loading the old one as well.

On most drivers these old functions are implemented through the 2
functions automatically anyway, so this avoids the conversion.

I have tested it against anv so far, using the ANV_VIDEO_DECODE=1
environment variable.
---
 libavutil/hwcontext_vulkan.c | 17 +++++++++--------
 libavutil/vulkan.c           |  9 +++++----
 libavutil/vulkan.h           |  2 +-
 libavutil/vulkan_functions.h |  4 +---
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 6b9c438222..62cddb424b 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -112,7 +112,7 @@ typedef struct VulkanDevicePriv {
 
     /* Properties */
     VkPhysicalDeviceProperties2 props;
-    VkPhysicalDeviceMemoryProperties mprops;
+    VkPhysicalDeviceMemoryProperties2 mprops;
     VkPhysicalDeviceExternalMemoryHostPropertiesEXT hprops;
 
     /* Opaque FD external semaphore properties */
@@ -1414,7 +1414,7 @@ static int setup_queue_families(AVHWDeviceContext *ctx, VkDeviceCreateInfo *cd)
     VkQueueFamilyVideoPropertiesKHR *qf_vid = NULL;
 
     /* First get the number of queue families */
-    vk->GetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &num, NULL);
+    vk->GetPhysicalDeviceQueueFamilyProperties2(hwctx->phys_dev, &num, NULL);
     if (!num) {
         av_log(ctx, AV_LOG_ERROR, "Failed to get queues!\n");
         return AVERROR_EXTERNAL;
@@ -1775,7 +1775,7 @@ static int vulkan_device_init(AVHWDeviceContext *ctx)
 
     p->dev_is_nvidia = (p->props.properties.vendorID == 0x10de);
 
-    vk->GetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &qf_num, NULL);
+    vk->GetPhysicalDeviceQueueFamilyProperties2(hwctx->phys_dev, &qf_num, NULL);
     if (!qf_num) {
         av_log(ctx, AV_LOG_ERROR, "Failed to get queues!\n");
         return AVERROR_EXTERNAL;
@@ -1947,7 +1947,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
         hwctx->unlock_queue = unlock_queue;
 
     /* Get device capabilities */
-    vk->GetPhysicalDeviceMemoryProperties(hwctx->phys_dev, &p->mprops);
+    vk->GetPhysicalDeviceMemoryProperties2(hwctx->phys_dev, &p->mprops);
 
     p->vkctx.device = ctx;
     p->vkctx.hwctx = hwctx;
@@ -2134,6 +2134,7 @@ static int alloc_mem(AVHWDeviceContext *ctx, VkMemoryRequirements *req,
     VkResult ret;
     int index = -1;
     VulkanDevicePriv *p = ctx->hwctx;
+    VkPhysicalDeviceMemoryProperties *mprops = &p->mprops.memoryProperties;
     FFVulkanFunctions *vk = &p->vkctx.vkfn;
     AVVulkanDeviceContext *dev_hwctx = &p->p;
     VkMemoryAllocateInfo alloc_info = {
@@ -2144,8 +2145,8 @@ static int alloc_mem(AVHWDeviceContext *ctx, VkMemoryRequirements *req,
 
     /* The vulkan spec requires memory types to be sorted in the "optimal"
      * order, so the first matching type we find will be the best/fastest one */
-    for (int i = 0; i < p->mprops.memoryTypeCount; i++) {
-        const VkMemoryType *type = &p->mprops.memoryTypes[i];
+    for (int i = 0; i < mprops->memoryTypeCount; i++) {
+        const VkMemoryType *type = &mprops->memoryTypes[i];
 
         /* The memory type must be supported by the requirements (bitfield) */
         if (!(req->memoryTypeBits & (1 << i)))
@@ -2156,7 +2157,7 @@ static int alloc_mem(AVHWDeviceContext *ctx, VkMemoryRequirements *req,
             continue;
 
         /* The memory type must be large enough */
-        if (req->size > p->mprops.memoryHeaps[type->heapIndex].size)
+        if (req->size > mprops->memoryHeaps[type->heapIndex].size)
             continue;
 
         /* Found a suitable memory type */
@@ -2180,7 +2181,7 @@ static int alloc_mem(AVHWDeviceContext *ctx, VkMemoryRequirements *req,
         return AVERROR(ENOMEM);
     }
 
-    *mem_flags |= p->mprops.memoryTypes[index].propertyFlags;
+    *mem_flags |= mprops->memoryTypes[index].propertyFlags;
 
     return 0;
 }
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 52b42cdc32..643caf1f90 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -152,7 +152,7 @@ int ff_vk_load_props(FFVulkanContext *s)
     };
 
     vk->GetPhysicalDeviceProperties2(s->hwctx->phys_dev, &s->props);
-    vk->GetPhysicalDeviceMemoryProperties(s->hwctx->phys_dev, &s->mprops);
+    vk->GetPhysicalDeviceMemoryProperties2(s->hwctx->phys_dev, &s->mprops);
     vk->GetPhysicalDeviceFeatures2(s->hwctx->phys_dev, &s->feats);
 
     load_enabled_qfs(s);
@@ -901,6 +901,7 @@ int ff_vk_alloc_mem(FFVulkanContext *s, VkMemoryRequirements *req,
     VkResult ret;
     int index = -1;
     FFVulkanFunctions *vk = &s->vkfn;
+    VkPhysicalDeviceMemoryProperties *mprops = &s->mprops.memoryProperties;
 
     VkMemoryAllocateInfo alloc_info = {
         .sType           = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
@@ -911,14 +912,14 @@ int ff_vk_alloc_mem(FFVulkanContext *s, VkMemoryRequirements *req,
 
     /* The vulkan spec requires memory types to be sorted in the "optimal"
      * order, so the first matching type we find will be the best/fastest one */
-    for (int i = 0; i < s->mprops.memoryTypeCount; i++) {
+    for (int i = 0; i < mprops->memoryTypeCount; i++) {
         /* The memory type must be supported by the requirements (bitfield) */
         if (!(req->memoryTypeBits & (1 << i)))
             continue;
 
         /* The memory type flags must include our properties */
         if ((req_flags != UINT32_MAX) &&
-            ((s->mprops.memoryTypes[i].propertyFlags & req_flags) != req_flags))
+            ((mprops->memoryTypes[i].propertyFlags & req_flags) != req_flags))
             continue;
 
         /* Found a suitable memory type */
@@ -940,7 +941,7 @@ int ff_vk_alloc_mem(FFVulkanContext *s, VkMemoryRequirements *req,
         return AVERROR(ENOMEM);
 
     if (mem_flags)
-        *mem_flags |= s->mprops.memoryTypes[index].propertyFlags;
+        *mem_flags |= mprops->memoryTypes[index].propertyFlags;
 
     return 0;
 }
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index 9c068f03e1..b758d30c56 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -282,7 +282,7 @@ typedef struct FFVulkanContext {
     VkPhysicalDeviceProperties2 props;
     VkPhysicalDeviceVulkan11Properties props_11;
     VkPhysicalDeviceDriverProperties driver_props;
-    VkPhysicalDeviceMemoryProperties mprops;
+    VkPhysicalDeviceMemoryProperties2 mprops;
     VkPhysicalDeviceExternalMemoryHostPropertiesEXT hprops;
     VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props;
     VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props;
diff --git a/libavutil/vulkan_functions.h b/libavutil/vulkan_functions.h
index f5ea9b7bce..8d67d1893e 100644
--- a/libavutil/vulkan_functions.h
+++ b/libavutil/vulkan_functions.h
@@ -80,7 +80,6 @@ typedef uint64_t FFVulkanExtensions;
     MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetDeviceProcAddr)                       \
     MACRO(1, 0, FF_VK_EXT_NO_FLAG,              CreateDevice)                            \
     MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceFeatures2)              \
-    MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceProperties)             \
     MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceExternalSemaphoreProperties)          \
     MACRO(1, 0, FF_VK_EXT_VIDEO_QUEUE,          GetPhysicalDeviceVideoCapabilitiesKHR)     \
     MACRO(1, 0, FF_VK_EXT_VIDEO_QUEUE,          GetPhysicalDeviceVideoFormatPropertiesKHR) \
@@ -91,10 +90,9 @@ typedef uint64_t FFVulkanExtensions;
     MACRO(1, 0, FF_VK_EXT_NO_FLAG,              EnumerateDeviceExtensionProperties)      \
                                                                                          \
     MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceProperties2)            \
-    MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceMemoryProperties)       \
+    MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceMemoryProperties2)      \
     MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceFormatProperties2)      \
     MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceImageFormatProperties2) \
-    MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceQueueFamilyProperties)  \
     MACRO(1, 0, FF_VK_EXT_NO_FLAG,              GetPhysicalDeviceQueueFamilyProperties2) \
     MACRO(1, 0, FF_VK_EXT_COOP_MATRIX,          GetPhysicalDeviceCooperativeMatrixPropertiesKHR) \
                                                                                          \
-- 
2.49.0



More information about the ffmpeg-devel mailing list