PR #24452 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24452
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24452.patch

NVIDIA's host image copy resolves every plane's parameters as if it
were plane 0, so a plain hwupload,hwdownload round trip returns a
corrupted frame. Frames with one image per plane and single-plane
formats are not affected. Exclude HIC for multi-plane images instead of
restoring the full blocklist dropped in 4ec050211a.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/24451


From 05c312e11ea780394504ea4e1aec43073daf83dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Fri, 11 Sep 2026 00:31:48 +0200
Subject: [PATCH] avutil/hwcontext_vulkan: disable host image transfers for
 multi-plane images on NVIDIA
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

NVIDIA's host image copy resolves every plane's parameters as if it
were plane 0, so a plain hwupload,hwdownload round trip returns a
corrupted frame. Frames with one image per plane and single-plane
formats are not affected. Exclude HIC for multi-plane images instead of
restoring the full blocklist dropped in 4ec050211a.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/24451

Signed-off-by: Kacper Michajłow <[email protected]>
---
 libavutil/hwcontext_vulkan.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index aa0efdd755..2859ee17c3 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -3033,6 +3033,18 @@ static int vulkan_host_transfer_usable(AVHWFramesContext 
*hwfc)
     FFVulkanFunctions *vk = &p->vkctx.vkfn;
     VkResult ret;
 
+    /* NVIDIA's host image copy resolves every plane's parameters as if it were
+     * plane 0, so every plane but the first is corrupted on both upload and
+     * download. Frames with one image per plane are unaffected.
+     */
+    const struct FFVkFormatEntry *fmt = vk_find_format_entry(hwfc->sw_format);
+    if (p->dprops.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY &&
+        fmt && fmt->vk_planes > 1 && hwctx->format[0] == fmt->vkf) {
+        av_log(hwfc, AV_LOG_VERBOSE, "Disabling host image transfers: "
+               "NVIDIA drivers mishandle multi-plane images\n");
+        return 0;
+    }
+
     const VkImageDrmFormatModifierListCreateInfoEXT *mod_list =
         ff_vk_find_struct(hwctx->create_pnext,
                           
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to