PR #24816 opened by nyanmisaka URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24816 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24816.patch
# Summary of changes - avutil/hwcontext_vulkan: avoid_host_import on AMD proprietary driver It is simply very slow on Windows, where RADV is not available. --- - avutil/hwcontext_vulkan: disable VK_KHR_maintenance11 on AMD proprietary driver VK_KHR_maintenance11 on the AMD proprietary driver forces copies to be performed on the Compute engine rather than SDMA. --- - avutil/hwcontext_vulkan: add debug option no_host_image_copy In some environments, the use of HIC results in performance differences. Adding a debug option allows users to make their own choice. This also helps with debugging. --- ``` ffmpeg -init_hw_device vulkan -f lavfi \ -i nullsrc=s=1920x1080,format=yuv444p10le \ -vf hwupload -c:v apv_vulkan -f null - ``` tested on: RDNA3 Navi33, 26.9.2 driver, pcie 3.0x8 (w/o ReBAR) default: 108 fps disable maintenance11: 425 fps disable host import: 525 fps >From 7d521793df90816cf28345125b58fc3f96cf7d08 Mon Sep 17 00:00:00 2001 From: nyanmisaka <[email protected]> Date: Wed, 30 Sep 2026 19:37:03 +0800 Subject: [PATCH 1/3] avutil/hwcontext_vulkan: avoid_host_import on AMD proprietary driver It is simply very slow on Windows, where RADV is not available. Signed-off-by: nyanmisaka <[email protected]> --- libavutil/hwcontext_vulkan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 47c685c6e6..5b4e01071d 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -1947,8 +1947,9 @@ 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; + /* Disable host pointer imports (by default on NVIDIA & AMD proprietary) */ + p->avoid_host_import = p->dprops.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY || + p->dprops.driverID == VK_DRIVER_ID_AMD_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); -- 2.52.0 >From 53d1a0852c3d56088ecc190f13d5de9684eda408 Mon Sep 17 00:00:00 2001 From: nyanmisaka <[email protected]> Date: Wed, 30 Sep 2026 19:59:03 +0800 Subject: [PATCH 2/3] avutil/hwcontext_vulkan: disable VK_KHR_maintenance11 on AMD proprietary driver VK_KHR_maintenance11 on the AMD proprietary driver forces copies to be performed on the Compute engine rather than SDMA. Signed-off-by: nyanmisaka <[email protected]> --- libavutil/hwcontext_vulkan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 5b4e01071d..01bc25ddf7 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -1009,6 +1009,12 @@ static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary *opts, !vulkan_device_has_rebar(ctx)) continue; + /* VK_KHR_maintenance11 on the AMD proprietary driver forces + * copies to be performed on the Compute engine rather than SDMA */ + if (!strcmp(tstr, VK_KHR_MAINTENANCE_11_EXTENSION_NAME) && + p->dprops.driverID == VK_DRIVER_ID_AMD_PROPRIETARY) + continue; + if (dev && ((debug_mode == FF_VULKAN_DEBUG_VALIDATE) || (debug_mode == FF_VULKAN_DEBUG_PRINTF) || -- 2.52.0 >From e503240bdd9fbf9ccaa95ff29f93f3143bdea44a Mon Sep 17 00:00:00 2001 From: nyanmisaka <[email protected]> Date: Wed, 30 Sep 2026 21:06:33 +0800 Subject: [PATCH 3/3] avutil/hwcontext_vulkan: add debug option no_host_image_copy In some environments, the use of HIC results in performance differences. Adding a debug option allows users to make their own choice. This also helps with debugging. Signed-off-by: nyanmisaka <[email protected]> --- doc/filters.texi | 3 +++ libavutil/hwcontext_vulkan.c | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index e8c8b23481..18cb79677d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -29603,6 +29603,9 @@ 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. + +@item no_host_image_copy +Disables host_image_copy extension for perf comparison. @end table @item -filter_hw_device @var{name} diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 01bc25ddf7..ca35832e56 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -185,6 +185,9 @@ typedef struct VulkanDevicePriv { /* Prefer memcpy over dynamic host pointer imports */ int avoid_host_import; + /* Disable host_image_copy extension */ + int no_host_image_copy; + /* Alignment the transfer queue needs for buffer offsets in image copies */ int transfer_offset_align; @@ -1006,7 +1009,7 @@ static int check_extensions(AVHWDeviceContext *ctx, int dev, AVDictionary *opts, /* Check if the device has ReBAR for host image copies */ if (!strcmp(tstr, VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME) && - !vulkan_device_has_rebar(ctx)) + (p->no_host_image_copy || !vulkan_device_has_rebar(ctx))) continue; /* VK_KHR_maintenance11 on the AMD proprietary driver forces @@ -1894,6 +1897,11 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, /* Get supported memory types */ vk->GetPhysicalDeviceMemoryProperties(hwctx->phys_dev, &p->mprops); + /* Disable host_image_copy extension for perf comparison */ + opt_d = av_dict_get(opts, "no_host_image_copy", NULL, 0); + if (opt_d) + p->no_host_image_copy = strtol(opt_d->value, NULL, 10); + /* Find and enable extensions for the physical device */ if ((err = check_extensions(ctx, 1, opts, &dev_info.ppEnabledExtensionNames, &dev_info.enabledExtensionCount, debug_mode))) { -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
