[FFmpeg-devel] [PATCH] avutil/hwcontext_vulkan: disable multiplane when deriving from cuda

Philip Langdale philipl at overt.org
Sat Jun 3 02:30:27 EEST 2023


Today, cuda is not able to import multiplane images, and cuda requires
images to be imported whether you trying to import to cuda or export
from cuda (in the later case, the image is imported and then copied
into on the cuda side). So any interop between cuda and vulkan requires
that multiplane be disabled.

The existing option for this is not sufficient, because when deriving
devices it is not possible to specify any options.

And, it is necessary to derive the Vulkan device, because any pipeline
that involves uploading from cuda to vulkan and then back to cuda must
use the same cuda context on both sides, and the only way to propagate
the cuda context all the way through is to derive the device at each
stage.

ie:

-vf hwupload=derive_device=vulkan,<filters>,hwupload=derive_device=cuda

Signed-off-by: Philip Langdale <philipl at overt.org>
---
 libavutil/hwcontext_vulkan.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index e8241638d9..2c594317f9 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1589,6 +1589,11 @@ static int vulkan_device_derive(AVHWDeviceContext *ctx,
 
         dev_select.has_uuid = 1;
 
+        /*
+         * CUDA is not able to import multiplane images, so always derive a
+         * Vulkan device with multiplane disabled.
+         */
+        av_dict_set(&opts, "disable_multiplane", "1", 0);
         return vulkan_device_create_internal(ctx, &dev_select, opts, flags);
     }
 #endif
-- 
2.39.2



More information about the ffmpeg-devel mailing list