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 6CAFC49CB1 for ; Fri, 8 Mar 2024 07:14:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B98068CFFE; Fri, 8 Mar 2024 09:14:08 +0200 (EET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4398868C970 for ; Fri, 8 Mar 2024 09:13:59 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709882044; x=1741418044; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=EtDThkZCyiLpkjhNa6j4KAyQK5+CAdiZful72yGIsjg=; b=e/bEx5/oRYA/NKKKGACqOdZwo7uR/927DRZ+pFfFskWHZvi++EES9uH7 Ykg4WZAAUM0ZFXXKAgI1tWQI3yvLxYgf57g2e0ria0Gt6bRqy1SfsCLNA 3hrf+B+MVGUHyML2susYTYrCHhwc1AJDHt+Lq7scwTPkBAYy2x4M3tDtQ wlSV3SX8jM10VME+SKh91tZq25gs88V3xu8sxIQDSoLF/QdDl/1n6OQsp fImUX8j2rda/GGRULQ5ZFawR0i4sli/DIi/IjDx43pVzWNsRbL4HZS+um GjBdza73I+uJ1UkpffBDfrNgTcynCSHv6LPQnyoZrqTBFjNHdiS8rnsMF w==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="4715960" X-IronPort-AV: E=Sophos;i="6.07,108,1708416000"; d="scan'208";a="4715960" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 23:13:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,108,1708416000"; d="scan'208";a="10788588" Received: from xhh-dg264.sh.intel.com ([10.238.2.76]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 23:13:55 -0800 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Mar 2024 15:13:43 +0800 Message-Id: <20240308071343.2904928-1-haihao.xiang@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavu/hwcontext_vulkan: check both vendor and PCI IDs 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: Haihao Xiang 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: From: Haihao Xiang Otherwise the derived device and the source device might have different PCI ID or vendor ID in a multiple-device system. Signed-off-by: Haihao Xiang --- libavutil/hwcontext_vulkan.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 855f099e26..9d94f74d78 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -975,6 +975,20 @@ static int find_device(AVHWDeviceContext *ctx, VulkanDeviceSelection *select) select->name); err = AVERROR(ENODEV); goto end; + } else if (select->vendor_id && select->pci_device) { + av_log(ctx, AV_LOG_VERBOSE, "Requested vendor:device %04x:%04x\n", + select->vendor_id, select->pci_device); + for (int i = 0; i < num; i++) { + if (select->vendor_id == prop[i].properties.vendorID && + select->pci_device == prop[i].properties.deviceID) { + choice = i; + goto end; + } + } + av_log(ctx, AV_LOG_ERROR, "Unable to find device with vendor ID 0x%x " + "and PCI ID 0x%x!\n", select->vendor_id, select->pci_device); + err = AVERROR(EINVAL); + goto end; } else if (select->pci_device) { av_log(ctx, AV_LOG_VERBOSE, "Requested device: 0x%x\n", select->pci_device); for (int i = 0; i < num; i++) { @@ -1597,8 +1611,14 @@ static int vulkan_device_derive(AVHWDeviceContext *ctx, #if CONFIG_VAAPI case AV_HWDEVICE_TYPE_VAAPI: { AVVAAPIDeviceContext *src_hwctx = src_ctx->hwctx; - - const char *vendor = vaQueryVendorString(src_hwctx->display); + VADisplay dpy = src_hwctx->display; +#if VA_CHECK_VERSION(1, 15, 0) + VAStatus vas; + VADisplayAttribute attr = { + .type = VADisplayPCIID, + }; +#endif + const char *vendor = vaQueryVendorString(dpy); if (!vendor) { av_log(ctx, AV_LOG_ERROR, "Unable to get device info from VAAPI!\n"); return AVERROR_EXTERNAL; @@ -1607,6 +1627,13 @@ static int vulkan_device_derive(AVHWDeviceContext *ctx, if (strstr(vendor, "AMD")) dev_select.vendor_id = 0x1002; +#if VA_CHECK_VERSION(1, 15, 0) + vas = vaGetDisplayAttributes(dpy, &attr, 1); + if (vas == VA_STATUS_SUCCESS && attr.flags != VA_DISPLAY_ATTRIB_NOT_SUPPORTED) { + dev_select.vendor_id = ((attr.value >> 16) & 0xFFFF); + dev_select.pci_device = (attr.value & 0xFFFF); + } +#endif return vulkan_device_create_internal(ctx, &dev_select, 0, opts, flags); } #endif -- 2.34.1 _______________________________________________ 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".