The branch, master has been updated
       via  67c15cf54156df469bb926d631fd9e21a259c9df (commit)
       via  a7efcbd0e325fb7f6fd820adab683efe8323751f (commit)
       via  78beb4f5f40c7fbd7fd89c93b8a10f0a08281eb1 (commit)
       via  881224b21324e5f0c43569928cf96f0e92a686e2 (commit)
      from  d151d3aecbe2a478c44be7faca56caae1848ca87 (commit)


- Log -----------------------------------------------------------------
commit 67c15cf54156df469bb926d631fd9e21a259c9df
Author:     Niklas Haas <g...@haasn.dev>
AuthorDate: Fri Aug 1 15:35:41 2025 +0200
Commit:     Niklas Haas <ffm...@haasn.dev>
CommitDate: Wed Aug 20 15:05:41 2025 +0000

    avutil/hwcontext_vulkan: add debug option to avoid host ptr imports
    
    In some environments, these are prohibitively slow. Add a debug option
    to prefer memcpy instead of importing host pointers.

diff --git a/doc/filters.texi b/doc/filters.texi
index fbd1d1959b..2818bd28b0 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -28755,6 +28755,10 @@ Allocates linear images. Does not apply to decoding.
 
 @item disable_multiplane
 Disables multiplane images. Does not apply to decoding.
+
+@item avoid_host_import
+Avoids the use of dynamic host memory imports, in favor of a regular memcpy()
+into a previously mapped buffer.
 @end table
 
 @item -filter_hw_device @var{name}
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 22fbd5d934..47f894f75f 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -153,6 +153,9 @@ typedef struct VulkanDevicePriv {
     /* Disable host image transfer */
     int disable_host_transfer;
 
+    /* Prefer memcpy over dynamic host pointer imports */
+    int avoid_host_import;
+
     /* Maximum queues */
     int limit_queues;
 } VulkanDevicePriv;
@@ -1793,6 +1796,12 @@ static int 
vulkan_device_create_internal(AVHWDeviceContext *ctx,
             p->disable_multiplane = strtol(opt_d->value, NULL, 10);
     }
 
+    /* Disable host pointer imports (by default on nvidia) */
+    p->avoid_host_import = p->dprops.driverID == 
VK_DRIVER_ID_NVIDIA_PROPRIETARY;
+    opt_d = av_dict_get(opts, "avoid_host_import", NULL, 0);
+    if (opt_d)
+        p->avoid_host_import = strtol(opt_d->value, NULL, 10);
+
     /* Set the public device feature struct and its pNext chain */
     hwctx->device_features = p->feats.device;
 
@@ -4472,7 +4481,7 @@ static int vulkan_transfer_frame(AVHWFramesContext *hwfc,
     }
 
     /* Setup buffers first */
-    if (p->vkctx.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY) {
+    if (p->vkctx.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY && 
!p->avoid_host_import) {
         err = host_map_frame(hwfc, bufs, &nb_bufs, swf, region, upload);
         if (err >= 0)
             host_mapped = 1;

commit a7efcbd0e325fb7f6fd820adab683efe8323751f
Author:     Niklas Haas <g...@haasn.dev>
AuthorDate: Tue Aug 5 23:19:41 2025 +0200
Commit:     Niklas Haas <ffm...@haasn.dev>
CommitDate: Wed Aug 20 15:05:41 2025 +0000

    avutil/hwcontext_vulkan: check driver ID instead of hard-coded vendor check

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 4c7e81d540..22fbd5d934 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -155,9 +155,6 @@ typedef struct VulkanDevicePriv {
 
     /* Maximum queues */
     int limit_queues;
-
-    /* Nvidia */
-    int dev_is_nvidia;
 } VulkanDevicePriv;
 
 typedef struct VulkanFramesPriv {
@@ -1871,8 +1868,6 @@ static int vulkan_device_init(AVHWDeviceContext *ctx)
         av_log(ctx, AV_LOG_VERBOSE, "    minImportedHostPointerAlignment:    
%"PRIu64"\n",
                p->hprops.minImportedHostPointerAlignment);
 
-    p->dev_is_nvidia = (p->props.properties.vendorID == 0x10de);
-
     vk->GetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &qf_num, NULL);
     if (!qf_num) {
         av_log(ctx, AV_LOG_ERROR, "Failed to get queues!\n");
@@ -2891,7 +2886,7 @@ static int vulkan_frames_init(AVHWFramesContext *hwfc)
     }
 
     /* Nvidia is violating the spec because they thought no one would use 
this. */
-    if (p->dev_is_nvidia &&
+    if (p->dprops.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY &&
         (((fmt->nb_images == 1) && (fmt->vk_planes > 1)) ||
          (av_pix_fmt_desc_get(hwfc->sw_format)->nb_components == 1)))
         supported_usage &= ~VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT;

commit 78beb4f5f40c7fbd7fd89c93b8a10f0a08281eb1
Author:     Niklas Haas <g...@haasn.dev>
AuthorDate: Tue Aug 5 23:18:21 2025 +0200
Commit:     Niklas Haas <ffm...@haasn.dev>
CommitDate: Wed Aug 20 15:05:41 2025 +0000

    avutil/hwcontext_vulkan: don't re-query driver props in qf setup
    
    This is already queried when the device is selected, so there's no need
    to re-query the exact same struct.

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 4e078eb527..4c7e81d540 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1463,13 +1463,6 @@ static int setup_queue_families(AVHWDeviceContext *ctx, 
VkDeviceCreateInfo *cd)
     VulkanDevicePriv *p = ctx->hwctx;
     AVVulkanDeviceContext *hwctx = &p->p;
     FFVulkanFunctions *vk = &p->vkctx.vkfn;
-    VkPhysicalDeviceDriverProperties dprops = {
-        .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES,
-    };
-    VkPhysicalDeviceProperties2 props2 = {
-        .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
-        .pNext = &dprops,
-    };
 
     VkQueueFamilyProperties2 *qf = NULL;
     VkQueueFamilyVideoPropertiesKHR *qf_vid = NULL;
@@ -1523,13 +1516,6 @@ static int setup_queue_families(AVHWDeviceContext *ctx, 
VkDeviceCreateInfo *cd)
 
     hwctx->nb_qf = 0;
 
-    /* NVIDIA's proprietary drivers have stupid limits, where each queue
-     * you allocate takes tens of milliseconds, and the more queues you
-     * allocate, the less you'll have left before initializing a device
-     * simply fails (112 seems to be the max). GLOBALLY.
-     * Detect this, and minimize using queues as much as possible. */
-    vk->GetPhysicalDeviceProperties2(hwctx->phys_dev, &props2);
-
     /* Pick each queue family to use. */
 #define PICK_QF(type, vid_op)                                            \
     do {                                                                 \
@@ -1555,7 +1541,7 @@ static int setup_queue_families(AVHWDeviceContext *ctx, 
VkDeviceCreateInfo *cd)
             hwctx->qf[i].idx = idx;                                      \
             hwctx->qf[i].num = qf[idx].queueFamilyProperties.queueCount; \
             if (p->limit_queues ||                                       \
-                dprops.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY) {    \
+                p->dprops.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY) { \
                 int max = p->limit_queues;                               \
                 if (type == VK_QUEUE_GRAPHICS_BIT)                       \
                     hwctx->qf[i].num = FFMIN(hwctx->qf[i].num,           \

commit 881224b21324e5f0c43569928cf96f0e92a686e2
Author:     Niklas Haas <g...@haasn.dev>
AuthorDate: Tue Aug 5 23:13:39 2025 +0200
Commit:     Niklas Haas <ffm...@haasn.dev>
CommitDate: Wed Aug 20 15:05:41 2025 +0000

    avutil/hwcontext_vulkan: also re-query dprops in device_init()
    
    This can be unset if using an externally provided device, as in this case
    device_create() never gets called.

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 2e04e63212..4e078eb527 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1868,6 +1868,8 @@ static int vulkan_device_init(AVHWDeviceContext *ctx)
     p->props.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
     p->props.pNext = &p->hprops;
     p->hprops.sType = 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT;
+    p->hprops.pNext = &p->dprops;
+    p->dprops.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES;
 
     vk->GetPhysicalDeviceProperties2(hwctx->phys_dev, &p->props);
     av_log(ctx, AV_LOG_VERBOSE, "Using device: %s\n",

-----------------------------------------------------------------------

Summary of changes:
 doc/filters.texi             |  4 ++++
 libavutil/hwcontext_vulkan.c | 36 ++++++++++++++----------------------
 2 files changed, 18 insertions(+), 22 deletions(-)


hooks/post-receive
-- 

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to