From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 8B3F745C8C for ; Sat, 3 Jun 2023 00:43:47 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3D34968C36D; Sat, 3 Jun 2023 03:43:44 +0300 (EEST) Received: from mail.overt.org (mail.overt.org [72.14.183.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6331568C2D2 for ; Sat, 3 Jun 2023 03:43:37 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=overt.org; s=mail; t=1685753015; bh=mvNxqGjmfgai22kmlE1+ErQzj8N3IOFDhPEBpHS4luk=; h=From:To:Cc:Subject:Date:From; b=LCX6gHIyTL3c9jNQPSWNRmsrnhVl3uZ+FFaDeO4vIxx+4KOQVUEMkwcjacu/A3hIV cKb8puFDL4275+6CTgE3IksR13E0u3vbsRa4ubZOwFdKkeGqmLGmvOCszh8TFb+yZ/ LXl5jezkaNAgku1QBhsY1Jl2BE+kEc3t3Yc6x86tNbJfkTVpgOgdsJ+lZIEPdrXkKZ +Pc8Yrg5oLGIr9DPuoQfGPwpKI/uT9Wdrluc+lZBMWvhDonscuKmbk7Bx6e+sdBIxC JeQSbv/I9/rM2PYOmQm9HIEgRfjQVNEkaKY5iil4J3dz/5gP/mLKqSy8GfNkkRNxdH kFkWyLC9o9p2Q== Received: from authenticated-user (mail.overt.org [72.14.183.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 4E0ED60844; Fri, 2 Jun 2023 19:43:35 -0500 (CDT) From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Fri, 2 Jun 2023 17:43:28 -0700 Message-Id: <20230603004328.139825-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] V2: avutil/hwcontext_vulkan: disable multiplane when deriving from cuda X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Philip Langdale Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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,,hwupload=derive_device=cuda Signed-off-by: Philip Langdale --- libavutil/hwcontext_vulkan.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index e8241638d9..ec084d94d7 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -1180,6 +1180,7 @@ static void vulkan_device_free(AVHWDeviceContext *ctx) static int vulkan_device_create_internal(AVHWDeviceContext *ctx, VulkanDeviceSelection *dev_select, + int disable_multiplane, AVDictionary *opts, int flags) { int err = 0; @@ -1335,9 +1336,15 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, if (opt_d) p->use_linear_images = strtol(opt_d->value, NULL, 10); - opt_d = av_dict_get(opts, "disable_multiplane", NULL, 0); - if (opt_d) - p->disable_multiplane = strtol(opt_d->value, NULL, 10); + /* + * The disable_multiplane argument takes precedent over the option. + */ + p->disable_multiplane = disable_multiplane; + if (!p->disable_multiplane) { + opt_d = av_dict_get(opts, "disable_multiplane", NULL, 0); + if (opt_d) + p->disable_multiplane = strtol(opt_d->value, NULL, 10); + } hwctx->enabled_dev_extensions = dev_info.ppEnabledExtensionNames; hwctx->nb_enabled_dev_extensions = dev_info.enabledExtensionCount; @@ -1511,7 +1518,7 @@ static int vulkan_device_create(AVHWDeviceContext *ctx, const char *device, } } - return vulkan_device_create_internal(ctx, &dev_select, opts, flags); + return vulkan_device_create_internal(ctx, &dev_select, 0, opts, flags); } static int vulkan_device_derive(AVHWDeviceContext *ctx, @@ -1537,7 +1544,7 @@ static int vulkan_device_derive(AVHWDeviceContext *ctx, if (strstr(vendor, "AMD")) dev_select.vendor_id = 0x1002; - return vulkan_device_create_internal(ctx, &dev_select, opts, flags); + return vulkan_device_create_internal(ctx, &dev_select, 0, opts, flags); } #endif #if CONFIG_LIBDRM @@ -1570,7 +1577,7 @@ static int vulkan_device_derive(AVHWDeviceContext *ctx, drmFreeDevice(&drm_dev_info); - return vulkan_device_create_internal(ctx, &dev_select, opts, flags); + return vulkan_device_create_internal(ctx, &dev_select, 0, opts, flags); } #endif #if CONFIG_CUDA @@ -1589,7 +1596,11 @@ static int vulkan_device_derive(AVHWDeviceContext *ctx, dev_select.has_uuid = 1; - return vulkan_device_create_internal(ctx, &dev_select, opts, flags); + /* + * CUDA is not able to import multiplane images, so always derive a + * Vulkan device with multiplane disabled. + */ + return vulkan_device_create_internal(ctx, &dev_select, 1, opts, flags); } #endif default: -- 2.39.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".