From patchwork Sat Jun 3 00:43:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 41964 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp1627066pzb; Fri, 2 Jun 2023 17:43:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6tMBbT6kR8bQJtsMKWvhh0uaUKBtbGGNgfalhQZp4fvBCtky7H8tY/y4h9Bo6qmLilwmuY X-Received: by 2002:a17:906:478a:b0:974:6176:2223 with SMTP id cw10-20020a170906478a00b0097461762223mr273354ejc.13.1685753028843; Fri, 02 Jun 2023 17:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685753028; cv=none; d=google.com; s=arc-20160816; b=yjcLwUBlj4DNr0N48EI1PL4Z2SydiVkFzwVEpqt3P/AEZUtcAYRLltJhWjkD1myi2o AzXUIXGPWYgXgGRk30pR1ciKp5k0J5JaxTT6HUIQcsDz9ZT6bJcmy329vWBISKMrum9F reUnAeTO6C4ZyMFNpUdc9kKN3zEFhRG7Zh/gU4oO4RkVb9vGw0CQhuGznalhOv71qPqS HHygZOiuQpVPiuYF1cRviUtUN9KGOwGXxEQsUEOBXVyxisFCVJBvPAUx+wTH0ncxrTmq DQdJLYrOnO008Bm3/C2xaGK3dNFG+CJA9GzoPX2bwYmtGkhTKT+ujy8KvGPDf4mfyADQ khJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=UcqAlSuuTDPANnN7krgxCgvnKCox8b/FCqC25VwNQj8=; b=vu8PgFMZk7OmJrVgwirfYq4IfYNqhjqD1oeE4aPXYJbLgSWPdxw2NpXQ+3ZfsTLcop /dqmp5cvKtrlqF5Vpi0Qw0RRy3KlXk7vznlfzE9HAqem/sE3nBCJb/UHBQ7NSopV5VWP Ddg/EOo8iyBfnnv6WnomHD1qGABXooF7+Ut8l/ODToQE28re32NS3V6gy2hV/lVv2/f0 FVDd+ogIrQsmSLXGHuDa1U/+zeOkkoJ/FbNff78k609b7T5+kN4HdU1AQXYSUXZvNIyF e6EWfpDtHANtXBYm2OiV91OHVgVN+OMC56TU34B0t4qv9xABvD+cvKSb/2tFgEGO2Z4s LqNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=LCX6gHIy; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dn22-20020a17090794d600b0096a36b9c937si1801660ejc.22.2023.06.02.17.43.48; Fri, 02 Jun 2023 17:43:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=LCX6gHIy; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 77D9268C371; Sat, 3 Jun 2023 03:43:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: h4yAeQ8VqvNQ 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: