From patchwork Sun Mar 3 18:41:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46732 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2428963pzb; Sun, 3 Mar 2024 10:39:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWgWJlBrJ3c97onNz8to898LJ2/vaUtrlgPWlK27jg7dhzX3cDuOIKoYAbJYswO+BspSgPUEDBkTibHXhSgwzjNPQqLrzDtED+AfA== X-Google-Smtp-Source: AGHT+IGiP1GGlFOdA7dRZUCvKL+DlE7Pbnqn0H1Ktd+8TWntwuC/OJfpVFqt7fhOGa60XGXUKaH6 X-Received: by 2002:a17:906:c40d:b0:a43:49c8:a8aa with SMTP id u13-20020a170906c40d00b00a4349c8a8aamr4670810ejz.55.1709491188289; Sun, 03 Mar 2024 10:39:48 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hq26-20020a1709073f1a00b00a3efc658f3bsi3269854ejc.731.2024.03.03.10.39.47; Sun, 03 Mar 2024 10:39:48 -0800 (PST) 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=@outlook.com header.s=selector1 header.b=bDWBOygD; arc=fail (body hash mismatch); 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=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7FB1B68D3A8; Sun, 3 Mar 2024 20:39:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2060.outbound.protection.outlook.com [40.92.74.60]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBDBA68D19D for ; Sun, 3 Mar 2024 20:39:37 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=khKJOCc4tUgm9dKkmzp57S9wSL3ZQNviGg5t73i4xFC1WbMpTzFH+IUx8soHVm7I2CfdjEVgoc0WVeBeCZ4uTvyjpd74uSHxgK/mMYIQxjpXh5V2lyVZZluhPFQqmjrUflwk0A541GAWG8qgGQiPpu2pSjK9FWeL7RHBBH0EQbtzdSa7liK4hAd1JJyoj4VRfZXT6jhZyuz0hR5LdRLRggx9pDJXU5427CFdrXBwRUJdZm9RysBFSQPGCnagz2I1eRtnID6Z20vicYT3uPGVyhu60YeAIDk2uiKHoRy+r4HVghRarOeX7cymtKUNXfKI9GIeZ1D0feFX0pspzTYznA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ea1mc4z4wRyO8qf4C6i5C2tLHKQsa+YjN2UaboA+XH4=; b=mso/gXSohuD3wbgow+Tn7L9x5Hlvwg/UP29TjD8/uMb3klbm9jYsLUMI9+JfQtN+wSEFat0klM2yTLUmIG043myrDwC2MLTQI+Hl3aVRLD3XCaVbNxLA8SKOWP7badzap4jbdPYJiBoDhVjBYzRWbsv/nsyY3kDbN5l9iicGzAeXq+BqQXoucuMeb2Mno3r/2ahPT9+GMEnG7gTeDtm3Aw6f+rVKPLMAQuhtUdXocX0m7NQsNrX8WCw69vOlUivu1+9SUVGWqMraLwC6H3iUe/kdnNzIFHIV/VFBrTBqaVkFU9GTYNm4UMrffJiy/AAo7kKdfChYMInFyY/3v6VlcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ea1mc4z4wRyO8qf4C6i5C2tLHKQsa+YjN2UaboA+XH4=; b=bDWBOygDmpjJ6iYNlPCI4h5jYNBA0uMVY1Gfj7hjIkheq5IYooV2MwivQKLlvVsi58g2yq+k35p+A4DvBEAVdH9NobbPTDZX/BcT6ARrgKNWxqJWyn0d3YENR5cTrygojc/ia92LkHCw6o5Db3s2T3Rd+CdMNfpqTex2G2D5p4wQWLEan4PxgseVusv0mWP+soS6qoss+FamvB5bFxZ6w4QYjg9gx6BBuBiyv0eIDQ9EJm69gzHzcIW0NtvCdyf8kU/Td/tS9BgTDHTUsqcsCBMvllPyphtTwRJJjNDvyngSrFbv8GsTf2C/if4t/m9MkkLUCrln1s+SxtKFvEMyTw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0538.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:295::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Sun, 3 Mar 2024 18:39:36 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 18:39:35 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 19:41:21 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 X-TMN: [/uf7Qyf1FA5aUKXj7sq/fOBBkuc3nMBnQTix0EOOdao=] X-ClientProxiedBy: ZR0P278CA0185.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::18) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303184128.541269-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0538:EE_ X-MS-Office365-Filtering-Correlation-Id: 1df9e137-96af-4c85-537f-08dc3bb14662 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqnx/C+6DC/TIciLJ1/n0VphZpUsw1sjR11RvK8y20g614sWaJmOdG6FX/gCD87HFGigJghm7R4b/1KXhhoxe+75mYyklzkkFArMWNIzbiaRx7yBdQhYHf3i8zWe7z43W2p6fXsSgUuMQgsr96mTumOyOrjo0AX+oo3bAiGe6ku6oQZGMUMynTz7qJp3SbI1g/ErBF1dqd0F+ZxbYF6DOQSGEC9/64BvSN+DYIKrOtWs6mdZKPsl8vDepyVgJUAyTzpzUZtdLZlQEehQ8wtA0Dg9XNusR3Z043rQPnTdXGCeKYtIjE4B6JS+qa7YrPkia15hH0SiCgT9sdRUCoUWJs+XSxVVAWe8fJIZLc/Sg8M+aH5+QzqWLcNG2n0dp50KGAyc1iSx1kQow8VGXJYZtucPiE6jgHFZooG0YC1r+6WHBSwyONn7I+6X+nxrNQ/yeut5qvhmTs6+tQVSrYKX/j/JcwuMYzHsbClU7WhwcBNtj8G0f/8dgQS55UQ82oIt1NkFCpbofjmAUX/2bW4yY0rdlRXSxb04azSTYUQaZO7DWs0oku2tZFt3byblI1DTCCnVSd0vCK1lZBpAn0mgss8Z0XhbBHdTCP7JCy5exxnTNcyOReVCigT35NtnMObWdSbsj9QEv1+35p3PJZLzI3ZeiuatZgWG4931FCGO0ThXQJyx3TcH5kf+sLwhJUEnbeDhbllNqHnSfLWGRtEzg3XBlU9dCgU+0PHI1+ipAp3z5WRi7vRP9k1ElVfF7MDi1c= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0qCTbix6iAGSyO+umgFksMaZREaFpCVQX3EkBDfbWR3DzwMOeEF7C2ICEQFI6mPoo9FaPMP6n1+SqDEOnwdG9/vevHOT+fb4VBa7wLPjfLDhWZQlXwDgC+LfLhq5NPo4/6jhXC4e7wKqvvNJxxSnUT1y4KC+xoOnlj5VE2aujv3rbCX0R1JLO8OLG0IXhPdseqlS/k0L2J6h5fa+8DlWJVVrpAj6gwfSnWqHg8b3mtj4dyxqCTCxraBw6I23MleBVTnPQMQrfmHhCDMZzyornBn0Xohq0ed7Q+bfxIoYGtBBo1+kFjYaF/q29JnSGkSCjj6odVgXq+AzueR3zNVohAgLxYaPnE+FzB+oKd73CpLUfL7+FerIDTWHPs4ZRwPariVpG8I2XTC0AJtAa1o1a/aEY8kjKachfGJx4oNZ9pbwo/BXd9dy6Jz/k6FWKjKmVa/ipz23GXFQaYl9f3dOF/Fs0WyscaibnnjIh72ulXVB86yS4TPx/dECXc57OnWNENoVD4ZykXkhKYNwPWGQs5FaEG0lwG83XKdTYrig+BI+28OxBRAzWT0cgMeDa5R58ZMJvEIAOk/vgq3oQy8PtkKoDO21NecAvHWZSTEIeAPioUP98QK1cokMiy48fIQ7 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Yk+Te3bPhXFe+odIrS51Bm6kr25GSuGygcm75QtKfA3pF88HwQ/V35eNN09CenFK35SvrF4xHrsQCSVL5laXZJYB1GegV5OUQOZT+BqxHlnlqoLUXQuqUZtRNjg3sXyS6sU6ZavyYmc0X6o7lGftUAl1st2eSt8FwnVgu8AMF1uc/Pfkzf66gzFZ+fr7qlYQYC0QfmwzvytLwW8I4NSl5gNct3k88CG1w1vJsVpM6QMlGww72aXrmUfrgy9er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-Network-Message-Id: 1df9e137-96af-4c85-537f-08dc3bb14662 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 18:39:35.8790 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0538 Subject: [FFmpeg-devel] [PATCH 1/8] avutil/vulkan: Don't autoinclude vulkan_loader.h 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: dgDtSQ1mFxcq Only include it where necessary. Signed-off-by: Andreas Rheinhardt --- libavcodec/vulkan_decode.c | 1 + libavfilter/vulkan_filter.c | 1 + libavutil/vulkan.c | 1 - libavutil/vulkan.h | 1 - 4 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c index 5def908a21..2448ee99ec 100644 --- a/libavcodec/vulkan_decode.c +++ b/libavcodec/vulkan_decode.c @@ -21,6 +21,7 @@ #include "vulkan_decode.h" #include "config_components.h" #include "libavutil/avassert.h" +#include "libavutil/vulkan_loader.h" #if CONFIG_H264_VULKAN_HWACCEL extern const VkExtensionProperties ff_vk_dec_h264_ext; diff --git a/libavfilter/vulkan_filter.c b/libavfilter/vulkan_filter.c index c77415d1be..d3dc2fdacb 100644 --- a/libavfilter/vulkan_filter.c +++ b/libavfilter/vulkan_filter.c @@ -19,6 +19,7 @@ */ #include "vulkan_filter.h" +#include "libavutil/vulkan_loader.h" int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s, AVBufferRef *frames_ref, diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index bf8456b06d..76b61dcaaa 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -21,7 +21,6 @@ #include "avassert.h" #include "vulkan.h" -#include "vulkan_loader.h" const VkComponentMapping ff_comp_identity_map = { .r = VK_COMPONENT_SWIZZLE_IDENTITY, diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index a5e78760d7..184d58ff5c 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -29,7 +29,6 @@ #include "hwcontext.h" #include "vulkan_functions.h" #include "hwcontext_vulkan.h" -#include "vulkan_loader.h" /* GLSL management macros */ #define INDENT(N) INDENT_##N From patchwork Sun Mar 3 18:42:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46733 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2429356pzb; Sun, 3 Mar 2024 10:41:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXVCbrZ57AADhB8br0hRDD54fIwO39vb46eqlCtWTTNUGNLH/ABfraoS9cb7SNbGchPmV9U1tVb4VIFzu9bPHxv/b0dSUUEAV9/AA== X-Google-Smtp-Source: AGHT+IExO0qXPnGNhFBdIJOuH+aMpxuWh2IwPrURBlThvycQcpPC7IKoEqHD1XWCCjP6dfbbzXMd X-Received: by 2002:a17:907:1682:b0:a3e:625f:246 with SMTP id cx2-20020a170907168200b00a3e625f0246mr4396079ejd.3.1709491269045; Sun, 03 Mar 2024 10:41:09 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h4-20020a170906590400b00a4504305012si896007ejq.100.2024.03.03.10.41.08; Sun, 03 Mar 2024 10:41:09 -0800 (PST) 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=@outlook.com header.s=selector1 header.b=Q8dDQW4m; arc=fail (body hash mismatch); 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=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AEE5868D397; Sun, 3 Mar 2024 20:41:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2069.outbound.protection.outlook.com [40.92.74.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1095B68C978 for ; Sun, 3 Mar 2024 20:41:00 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WAg1Jgt0J+CO/jQ1oMJjB5nwSNzHIThr+8dxMVbQV3UImStj0J1NjpBug7Of2qfRQMSgx5ETQqZ6D5dGDId3nIjA4H2PUQvscbaWICWFix89q5i+Zu11RjdYUrKirdxfHlkdZiHzRB5bV/5mck+xRXrJSjyECwpWsF2BKOMN3HttKyotQTvdjfgb0drsatlnvwBuJJHmiixZHOvOBSlMZsywREeaYoicvMgc32HAFw0OsrUeJSnZNKQFXDcS14JZvn4THbKBgsfUgFZAE/9ONWrQfDwyJmV/bfwka1K70AbRB2M8QL+XaT6bIpnxIrtLVcAVT3+knAhJpE4oIcxMrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mhEz+tuDAW2c3SNT9/MJj/0wXF9RcOZ2NRJcTdAvjzs=; b=RXDzATJFCvg+JVkSylmN52markbDeLrs4CKJN6ekrPTuSEpFSJBgxkynOH26+BopXNFk8KyaeQ3kEl3h7jSkncTDMvU2emBRz+ddydyN870qayiWnUYChYtlnZ86qOc7gXJaUZeqvCzLQeylVRdW1VAe+IaRPXJvas9hvybOpbl1OeNp8Jx9LUqlDJG8x/t3/czLUXAffWfBGIc9mGL0ps0J2xU2DtGMJWouLUNkZzXQH4Tro1a++EfDKNyzabr+Bh/BjZjStXxAprbzkL8fDjaiWa5CnGFf7TXcT786RaRsJtQW3v8X2gqQERILe57y71KGWznvqJ2qzhzZV/TGvA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mhEz+tuDAW2c3SNT9/MJj/0wXF9RcOZ2NRJcTdAvjzs=; b=Q8dDQW4mHlH27ipXxy6EivmjRg/KDOTdVW7So9/BPAUUtcnqruVZuYTGiVEBDcJH0HpesZDwMyf5yYmjfMYEnjeuxRJ7aHrjJ9RxWw58/FIrIngaIwPpFfG451Bt8m6yGSUQSoOQ3LMQnvSrS81V9udlY6plRuw5lp+TvRL1qSb91tlvgrbRvwtIhBEMh9Y4r+rymmiup0QfP8Qcw7KyYaKQbqL2jmZKjGh5wLFFstA+agYbPkKlMU7SYPzMAw2dX+ySBve/Bgov78LBBmkpA1hCLtSR5LAouquO7PZ52mHhVBQQ7nMVoRqAyGIMpljdAuMd+CBv8oy7SB8DONYWmw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0538.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:295::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Sun, 3 Mar 2024 18:40:58 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 18:40:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 19:42:44 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [NfvCGhXTsAb/sQ+YyjAd+uxfGwwamxmvUgzFBhTMUXU=] X-ClientProxiedBy: ZR2P278CA0066.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:52::20) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303184250.541590-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0538:EE_ X-MS-Office365-Filtering-Correlation-Id: 6449e25a-eb0d-422f-743b-08dc3bb17765 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqnx/C+6DC/TIciLJ1/n0VppyECWal18tgCc953MNGsoNsOdqytkif56EoTRph/Sg/WqjUrACA1ZHr9AuENlUwb82sHcmiROYVq4uNJ1bCvwU3JHtPYwsViWfIn+3veGsIiV9glnRjMEHhrovg70fPnOpBoohh6VSvab79e0hLPyD91dh/WRjQ9FRTdlEHUh58SiToxfXZHrshhhmq4DPImklGFu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zzM5F4LwvGbb6epxle9G9GfXM/ZZ+Z+FTDSL4szDUO89qvO2YUGByeEezUp6/FqKRNOPlEdaHqAFmF1x2riDbIkc0FQSdKBG07shLR7qG2viqr0TJ29eScznrGzprGBCaxlXqnVRLMHH1cM8uwJ1uOAVI12sSPbLuRa0AwRI99+5SHG9XCSjwqX/EENAc/9+ASlEF4BP7umdeQCFe+Uwf2QpdLfROGCJjSMXawql1fIVvugVA8wpkuzqDqCVMPZfMsaPYga/81AMi4Vf9Ecrw61+DBfRpJGi25aKFmo12eVg560TFcVXvYMvsgX0hLdsD5+wU/gqmyW2DHPD1M6yoRmokbCyO2i9xn3Zt4I1tjGX4SlJLufdpp9U5/jsH5S/ToLIGibTEVGFLGgl+xViunTRsmYpgOxvrbyKxsuEUA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6449e25a-eb0d-422f-743b-08dc3bb17765 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 18:40:57.9695 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0538 Subject: [FFmpeg-devel] [PATCH 2/8] avutil/vulkan_loader: Avoid redundant strings and relocations 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 2BNJvyQWMKvV There are three possible names for the functions requested; they only differ in an extension: "", "EXT" or "KHR". Yet vk_load_info contained pointers to all these strings. This is wasteful and this commit changes it to avoid the latter two strings. This saves 6353B of strings, 1776 B of .data.rel.ro as well as 5328 B due to the removed relocations (corresponding to 2 * 111 removed pointers) in lavc/vulkan_decode.o alone (ff_vk_load_functions() is inlined in lavfi/vulkan_filter.c, lavu/hwcontext_vulkan.c and lavc_vulkan_decode.c, so the savings are three times this for shared builds; for static builds, the number may be smaller depending upon whether strings are deduplicated). Signed-off-by: Andreas Rheinhardt --- libavutil/vulkan_loader.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/libavutil/vulkan_loader.h b/libavutil/vulkan_loader.h index f88722f28f..07b6316089 100644 --- a/libavutil/vulkan_loader.h +++ b/libavutil/vulkan_loader.h @@ -19,6 +19,9 @@ #ifndef AVUTIL_VULKAN_LOADER_H #define AVUTIL_VULKAN_LOADER_H +#include + +#include "avassert.h" #include "vulkan_functions.h" /* Macro to turn a function name into a loader struct */ @@ -28,7 +31,7 @@ req_dev, \ offsetof(FFVulkanFunctions, name), \ ext_flag, \ - { "vk"#name, "vk"#name"EXT", "vk"#name"KHR" } \ + "vk"#name, \ }, static inline uint64_t ff_vk_extensions_to_mask(const char * const *extensions, @@ -98,7 +101,7 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx, int req_dev; size_t struct_offset; FFVulkanExtensions ext_flag; - const char *names[3]; + const char *name; } vk_load_info[] = { FN_LIST(PFN_LOAD_INFO) #ifdef _WIN32 @@ -108,6 +111,8 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx, for (int i = 0; i < FF_ARRAY_ELEMS(vk_load_info); i++) { const struct FunctionLoadInfo *load = &vk_load_info[i]; + static const char extensions[][4] = { "", "EXT", "KHR" }; + const char *name = load->name; PFN_vkVoidFunction fn; if (load->req_dev && !has_dev) @@ -115,15 +120,19 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx, if (load->req_inst && !has_inst) continue; - for (int j = 0; j < FF_ARRAY_ELEMS(load->names); j++) { - const char *name = load->names[j]; + for (int j = 0; j < FF_ARRAY_ELEMS(extensions); j++) { + char ext_name[128]; + av_unused int n; + + n = snprintf(ext_name, sizeof(ext_name), "%s%s", name, extensions[j]); + av_assert1(n < sizeof(ext_name)); if (load->req_dev) - fn = vk->GetDeviceProcAddr(hwctx->act_dev, name); + fn = vk->GetDeviceProcAddr(hwctx->act_dev, ext_name); else if (load->req_inst) - fn = hwctx->get_proc_addr(hwctx->inst, name); + fn = hwctx->get_proc_addr(hwctx->inst, ext_name); else - fn = hwctx->get_proc_addr(NULL, name); + fn = hwctx->get_proc_addr(NULL, ext_name); if (fn) break; @@ -131,7 +140,7 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx, if (!fn && ((extensions_mask &~ FF_VK_EXT_NO_FLAG) & load->ext_flag)) { av_log(ctx, AV_LOG_ERROR, "Loader error, function \"%s\" indicated " - "as supported, but got NULL function pointer!\n", load->names[0]); + "as supported, but got NULL function pointer!\n", name); return AVERROR_EXTERNAL; } From patchwork Sun Mar 3 18:42:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46734 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2429412pzb; Sun, 3 Mar 2024 10:41:17 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX9LWdy7BIXqIYqqMcwG+0a7w2nMgLwiQH/ns932hy0Fii0dLid0mdiTOaVFaNUJq1Nm+tY6qZfnnHloKZrYlO3m7lccHOFbsJ+fg== X-Google-Smtp-Source: AGHT+IEExSQvxDv1pV7peknEOQmBdvnn1/G2CqRUpvrp6csZ2bO57ysKHBjQmuHb6jKw9hhIRJyp X-Received: by 2002:a17:907:a603:b0:a3e:9bce:b5b1 with SMTP id vt3-20020a170907a60300b00a3e9bceb5b1mr5852042ejc.5.1709491277092; Sun, 03 Mar 2024 10:41:17 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id du12-20020a17090772cc00b00a44c7cbcfdfsi1735146ejc.354.2024.03.03.10.41.16; Sun, 03 Mar 2024 10:41:17 -0800 (PST) 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=@outlook.com header.s=selector1 header.b=J9Qd8LBx; arc=fail (body hash mismatch); 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=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E278E68D3B2; Sun, 3 Mar 2024 20:41:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2069.outbound.protection.outlook.com [40.92.74.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3829568D368 for ; Sun, 3 Mar 2024 20:41:05 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d1N+2oKbJUu6L65tcBW1Q05A382nSWqqUve84o32Tzv5LSNqDkpnEaP3/jt8S6pOIIeVVMGpcwnFZXGv5f2SmBWLEQURKYxCbvvxFOu+fAaJE02A7pEM0zSQrXqOarZSy/bg0qeR0ZLtG2ik9h/MZX/jCbO19/aQidzCX0HTv+/XGJrPqtExEuooZ4lzYeh67ouzEoFC0OWY2bfAtutpYgg4DZdtv0FTImKvBPzlOP4bBcc2blgr97PrfBlpOW4j6dwwBAMY0ETmzs7lLR2XVbSFEW3IKPBnEwpK7wEpr0CT4Mr4AYrIDJcGb81FLc18V6LFtJlXeZx3rSxluUYNfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w3r6Jb6jDtiThCibna79arDX2KRZLatdG34SKsU0YT8=; b=BJ83py0fb2+YEapsXx5yEhchChnTYrf03X+oKAVNQ9VmpOkWe7PZsunFUWCEYXzBml/Y3fAApzpeEBlIbvXIpRSxTKkU7JelU1GdtpXx7dEA15EhBPMw8NJRHS1h9rPLUWPC9tXUhhL3WrUPZeuCD0+vtzmdHYBAbuUCWBj+Aqc0ZjbxCCpkwsLG6kHAc7vZxDzeAQTKJqZYOOrtLAQnoAh2YZvXuruJgBTqns0BPDs4pddzoPlTvdyEbGWTb/WwZ5bfuppWT+vDd6Am2m822zImkuLNil1wEJ8I8b4EYpW4YXuQsKhKh2xBuZjmkwvghTjP9F8TPGqLnEMV4sQtgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w3r6Jb6jDtiThCibna79arDX2KRZLatdG34SKsU0YT8=; b=J9Qd8LBxGHi5eOtjc4Qy3zZrGfYYPf7/pxKWsuhADr/a1HIVusT8x9fXNxvBx29IM8oSCF74poixTTI6qxvdjR085efqQdXkoLfvuiFrcJSG1YDubiCOVQXppkLaMFElgU/SM1QpICeU/v7cw/CRwj9h7zteL6LvKQUtNNwQsQdVgXJLr0TfkOgOeNCK91ATOLe1S/iWS+hXdn9v0yKEze1tJBR2PiNhNeWGNLtPjU/lT97QRHHsnkB/DnzqnqaCC1SMVhYRt39i0Kd4IEkihhIn6aKiiM5/4K4bbCN5/ReRu4i+DyaTrZHJQYTBSugt8WDPE5F/51JW+umxAVND7g== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0538.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:295::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Sun, 3 Mar 2024 18:41:02 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 18:41:02 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 19:42:45 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [gCuZM/TL8f/Uj/qwABeSicjEfaQyeLkGCrEl5PIbPZg=] X-ClientProxiedBy: ZR2P278CA0066.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:52::20) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303184250.541590-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0538:EE_ X-MS-Office365-Filtering-Correlation-Id: 88b8f14b-a393-4bf6-5cc4-08dc3bb179fb X-MS-Exchange-SLBlob-MailProps: 9IecXKUgicBNlqXpgndjr4h+wQt1UEYhsE/Hhwk77UAFDN4nPZvpYz/BSRHFBh3S36KjQ7zzgYks/OJ1230XwjXD8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PzF/G0429FkpdKL4DAhz3bD4GXArutJHBtXJT3vC2w/zYgTP03IP60X/NX/Rm5cKuPxZpF4DkUFei1oFFd6d5yNSHydEXrY+h8QlWjaz/0jD5LjRzb6B3famvDimyGVY9juyYJJWv3i8Yi3Yo+je/ScIgY+6CFMHAz1rR7H5M1kfRVXdlmMvWXlcWjrmW5CwEuB0A2BjPxV4pDHB/awVX53fhI1EXHVrgCNfJBU6ZpjzWeOef6PFpRSoMF3AkUukLt5GTIjWooJ3Tq4fFocClqM/q+lu7spDOhypw72Q0iUkE24DSys4+kTu4Y816ErtPTRTQSQgjvdye+1RxWfDyRDxKlpghKJb5gfeYnqMiEFM0siXkRx7rJZZNeuskAk8Y1CaXqM/0dB3Br3lfAdrLnX9y6vgL7nSpUo+GLAom9JFDkL4NAKAXx5AfHk0yaHD+MkDRPZmGCpplraiAYFxCRcrddFTIgqWxFIMUO4Y5HdaGt4vVLbjsxUdwQMGheI5U9bc0RwF3yf8pamJ0+UXTWV4cTJbSeQ00o4McxSXvty2mSnicBIOVU2g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88b8f14b-a393-4bf6-5cc4-08dc3bb179fb X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 18:41:02.4364 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0538 Subject: [FFmpeg-devel] [PATCH 3/8] avutil/vulkan_loader: Use smaller types 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YghQ8o6Voy2n Saves 16B per entry here (four of these 16 bytes are padding); leads to 1776 B of savings in each file that uses ff_vk_load_functions(). Signed-off-by: Andreas Rheinhardt --- libavutil/vulkan_loader.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavutil/vulkan_loader.h b/libavutil/vulkan_loader.h index 07b6316089..37ce339e1d 100644 --- a/libavutil/vulkan_loader.h +++ b/libavutil/vulkan_loader.h @@ -97,9 +97,9 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx, AVVulkanDeviceContext *hwctx = ctx->hwctx; static const struct FunctionLoadInfo { - int req_inst; - int req_dev; - size_t struct_offset; + char req_inst; + char req_dev; + uint16_t struct_offset; FFVulkanExtensions ext_flag; const char *name; } vk_load_info[] = { From patchwork Sun Mar 3 18:42:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46735 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2429477pzb; Sun, 3 Mar 2024 10:41:27 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWOscHsupquIitkqxlhSTwwr8HEiDul0EhEkH4D9w9c2cRDSymo/o8I2cs1peRGg4nis1B3BYT+NXvfdiQ2Zb7yMIcRIddha9BGEg== X-Google-Smtp-Source: AGHT+IEAQZOMlzIMPEQ1fHz4mTYF/FqJsdz/Q7A5QDNSylI3BC4pr0DXYkUY1wR/TE9YlRNHggan X-Received: by 2002:a17:907:c316:b0:a45:5509:e219 with SMTP id tl22-20020a170907c31600b00a455509e219mr134763ejc.1.1709491286976; Sun, 03 Mar 2024 10:41:26 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hp19-20020a1709073e1300b00a453e6bc7a4si260069ejc.180.2024.03.03.10.41.25; Sun, 03 Mar 2024 10:41:26 -0800 (PST) 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=@outlook.com header.s=selector1 header.b=slxeuTbo; arc=fail (body hash mismatch); 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=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1641468D3BC; Sun, 3 Mar 2024 20:41:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2069.outbound.protection.outlook.com [40.92.74.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5D98C68D3BA for ; Sun, 3 Mar 2024 20:41:10 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GFS7Tatl8PmvIo3HloLPW9yAXWJVRtQ3eEmVKYYMmXMYSC9Ib2tvcwDXcpTRcyP1kXjq2+awszbGOjdjCcm5Jy6ibGf8wnmrPNYrjDz/jBR35qOW4BYB8LUNhqbbMKi3yB7dYrovIHoyAG1PJ4jZH3uWfqqKrtaY3hdIMK0KW8xSmNPO8ET7IOyWQRcmVyHYggxSXUMDBgydqP2ebzY1pNZo81gFJvfrfzeUnPqSdF6Eu+57/wPwlk0AcDhZ6vrv0r6Xzkdm3eq5mmqcXYtUOuksqcLvBq8ZPg3UoUykd7QN4RCPK9HApThv0iWvuuS6+p85JaHFyBIOHiwRDCx1+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7/QU8eIiiOQpb91onkDUQ7ZPtnWkTRdZ7lC3XXjounw=; b=L/WCpUXqwJ9TcEjJLgP1h6SMSvdTW6yx0gmgoRcf8lfY4+G+ToOVtyIw7E8Xyq1STCXIdxIW2guy138yA7fW6a1jvkkX613qU2Y584I20zBpBgnBMSI/E8uBvHu1OIFcsyr7tTBe3KwAxN0pVZTJSyXIUTQ5VOPh6AIHlVOvxaQ/LqGbfNnn+KIvGFrE+gcUIwRZ/O3FhCVWa0bnVrvsq6JOMqxTzaStXAYZLFHkhfMBAUifoKpLp9FXc9ct9bGBS5eTCTH6NWA1WXYT4322/XglWtBwn17EsnHM6m4pmrklzt0SDzv9XzA3kiUWeWWlVup3Qd6qXNZqGuNpAxGAyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7/QU8eIiiOQpb91onkDUQ7ZPtnWkTRdZ7lC3XXjounw=; b=slxeuTboSdJ7XjEXBuhQzkq3PUuYDFlaRnJsUouLeI4VxJQnDvHoeccYI1iORg9vqWsKsaORw+VnugvMP3bTv3OvHHUPGOn3ACKBGSXlr440mFLzR6DotyqbVC/iiqjFh3b686dFPu5IwaJM21I19MEyKN9OtWcmAvdEoa0ux0r+DWCrVI3p8c6JGlBkAStchVYAHgkh2ThPOTAYeXOMq/xMMjKC6uijG3Jd+P9z8QR+bg3EBz9rZ5Blqj46o+2yb6RyzcKdrU013TsSl5YpJnUPXiB5EtVYwCiPtQUiO52Cq7bSOr3F4QJqrLCxyrdo7/m5HjSHNhPRuMiC0Ohkww== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0538.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:295::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Sun, 3 Mar 2024 18:41:04 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 18:41:04 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 19:42:46 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [+6se2w2xmIS/RZAAJ3JnjSgo9rb7lIHSfs6ViJcWwu8=] X-ClientProxiedBy: ZR2P278CA0066.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:52::20) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303184250.541590-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0538:EE_ X-MS-Office365-Filtering-Correlation-Id: e06e66ed-5d90-4735-3e6e-08dc3bb17b03 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqnx/C+6DC/TIciLJ1/n0Vp9OyQnCkjKBIU7ouvlD833GxeaKo0AnJLKG24nqEYd0ZccQSGUh4xjd5f4kmopQ651bFMGLQfbc+VolUsCEWfa0z4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Cw9hQPPZPMkls2GZS4tnbEP38hSAGkMj5FuYTwqpXeDWNQj1pV2xZKEHG2FwvxxvEqIJcYTXzZmwE1vjYSxY5bLmg1yscOnok441gpaNFp7r5UA9JsP7WzR7jrEXJF088sUW5utzofVNTDW9pqLr/BTOenQKieJxpqGNUKElBM0NEID/aernRLlVWk0oALGI2rPW8PbksFmbcBc5Spd0vb1ViSk1vVe2Ef6lihdHKWJxlAmysZpxSec/2KNmmCt9t+/NT6BM8rOTInl9xXdNtEftyamOCr/sgSl30BLYPoq0nApd0t4CbhMTBEAV/IJXhZJBJkcDtyOl4ckYmJl8LMOaf1dADE75hHmR0glg9wZgNEaHtFfe19/tkF/E1o5s3+Zd4ObprTRmTtDItxQ2hYOQuVrDCwV/rXZiul8P2EazfcmaFnidPiEMUvFSzd3ntP+h0CYaCv/uW5MEilzYWX25lU488wHyp5nvdgIM8sgxATr7XFy3YFAO9LhcEGwsAvx0g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e06e66ed-5d90-4735-3e6e-08dc3bb17b03 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 18:41:04.0579 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0538 Subject: [FFmpeg-devel] [PATCH 4/8] avutil/vulkan_loader: Avoid relocations for strings 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Wn8kzuk3WR5r To do so, concatenate all the names together to one big string name1\0name2\0....lastname\0\0. This avoids the pointer in the FunctionLoadInfo structure and thereby moves vk_load_info into .rodata (and makes it smaller by 888B). Signed-off-by: Andreas Rheinhardt --- libavutil/vulkan_loader.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavutil/vulkan_loader.h b/libavutil/vulkan_loader.h index 37ce339e1d..f9e739e1e3 100644 --- a/libavutil/vulkan_loader.h +++ b/libavutil/vulkan_loader.h @@ -31,7 +31,6 @@ req_dev, \ offsetof(FFVulkanFunctions, name), \ ext_flag, \ - "vk"#name, \ }, static inline uint64_t ff_vk_extensions_to_mask(const char * const *extensions, @@ -101,18 +100,26 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx, char req_dev; uint16_t struct_offset; FFVulkanExtensions ext_flag; - const char *name; } vk_load_info[] = { FN_LIST(PFN_LOAD_INFO) #ifdef _WIN32 FN_LIST_WIN32(PFN_LOAD_INFO) #endif }; + // Concatenate the names to avoid relocations. The resulting string + // will end with \0\0 +#define FUNC_NAME(req_inst, req_dev, ext_flag, name) "vk"#name"\0" + const char *name = + FN_LIST(FUNC_NAME) +#ifdef _WIN32 + FN_LIST_WIN32(FUNC_NAME) +#endif + ; +#undef FUNC_NAME - for (int i = 0; i < FF_ARRAY_ELEMS(vk_load_info); i++) { + for (int i = 0; i < FF_ARRAY_ELEMS(vk_load_info); name += strlen(name) + 1, i++) { const struct FunctionLoadInfo *load = &vk_load_info[i]; static const char extensions[][4] = { "", "EXT", "KHR" }; - const char *name = load->name; PFN_vkVoidFunction fn; if (load->req_dev && !has_dev) @@ -146,6 +153,7 @@ static inline int ff_vk_load_functions(AVHWDeviceContext *ctx, *(PFN_vkVoidFunction *)((uint8_t *)vk + load->struct_offset) = fn; } + av_assert1(*name == '\0'); return 0; } From patchwork Sun Mar 3 18:42:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46736 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2429515pzb; Sun, 3 Mar 2024 10:41:34 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWnmwi2tBd+1q9h0AledYMdPRhw0SuUYmiZjjmBbdrBWqz8t5S+Mi9XcT3brcl9X/qaBokZ664p1+8z5ndz2sgrDb3rgo35+i6pfQ== X-Google-Smtp-Source: AGHT+IEnlAsmzAFkfZXDc3pybKjWE0EOWbknSDQvZ3wqdOGtmoCZ/B3btvSNedhqAtgGm36SmhLu X-Received: by 2002:a17:907:9717:b0:a44:d812:39e5 with SMTP id jg23-20020a170907971700b00a44d81239e5mr2270603ejc.2.1709491293971; Sun, 03 Mar 2024 10:41:33 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j3-20020a170906474300b00a45322c32f0si396458ejs.485.2024.03.03.10.41.33; Sun, 03 Mar 2024 10:41:33 -0800 (PST) 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=@outlook.com header.s=selector1 header.b=gcYiGgOA; arc=fail (body hash mismatch); 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=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F3B568D3BD; Sun, 3 Mar 2024 20:41:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2069.outbound.protection.outlook.com [40.92.74.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A70B368D3BA for ; Sun, 3 Mar 2024 20:41:15 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oNLG5TYNSewdiRxffbICIEJYxe2Y4vhgJDhjeEoteGWXBEpAv5Ombz/wZkPLzi5EfJwnVLeL7qwbQBOtKIoapT3UpsK/X9bNvfMrfjqcxYdCDmprAvwq/MhvMq+eUaxCbNH0U/q/VQkDOjN1IaSuGzH0ZlqMZvPh2VfuJCpZ3VPGdp+fkcGIyuPYRL94DzOfWJG/VGeo759wodUpaF4u+e0fJFyB0ubw5yTGg+ocrNpf74rdxa8jLYlQXrkzXdgKk3I2LEwclNyIfxDoVrSKUlh4zT4b8LigNIWNaZ1oF8tzWMax51iU9+HJsb7QCi9+glcMGXKvY2/DP9hFRH4jPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qOHe6qM9EXrps58MvYRas/3MiHbX0dOO7oFSp9+LRbg=; b=J3ZzoGiqTZ6pdYOjAyPuCKTn2J1HCyXiXCpK9jTS/YtuogHT4eUzCegLe3OEaJB5Wvc6jPI1cXyQSdP2ncSCTT+ssH5PHXLKutbBaJ0F+3oUxoV1nxtgIh20C4OtUf9syfmTTwvfp5D0++P+Atd2+NHs3Rud0WxsJyVCCk3kgeybcpzpz9dsQw6BtzRAgz9y9ri1ZHmaJPd2H/HRnwjPV+UL7d95Sad83PEZYvGujHiE2oINKhJ8zKN170wHna1hFimIppD3Iy8dxfMycFxV8No5oyvfxBRxF5F0VuEYnDTe2j+cDIou+YcLYqU3/nMaGwQXqj+ZwmhAf8Te9xYI2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qOHe6qM9EXrps58MvYRas/3MiHbX0dOO7oFSp9+LRbg=; b=gcYiGgOAaBQNJeCGAt92nuD09bh41/LIJMdK6Gpn6dI82covh59XUcuhLZeffjkvWtjSN/0VPoF5KfB5MgPMHRms7o3IMEL0i7oA5yaJoqey7PymsA1L1iDYIoBPnQhnUQUR5BH89770R9DGmSB3i6jgVeBAtc7OgVIXwG+A2Y4B8/b7LRbtWCZz072z/Pbyc3TaCz7bSpeR86gVef2V/7a6jcX4Fx5sZUsbTGZ3xYBgh6yqDvkxFUe+A7HndWNlIqRPTyTH5gPjJ3Hen8Lxkg+ImAB6uuWgVKsGhJBlX9WSRLtf2rqtehCQKdIXGrP9Tw/pkor47AEMSP3qlAF3jQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0538.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:295::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Sun, 3 Mar 2024 18:41:06 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 18:41:06 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 19:42:47 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [+I42Cs2U9wf+QOrEccTdnnAWcn3Y5IojOU6IK1BHI00=] X-ClientProxiedBy: ZR2P278CA0066.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:52::20) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303184250.541590-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0538:EE_ X-MS-Office365-Filtering-Correlation-Id: 2524561d-41db-4a66-8a48-08dc3bb17c36 X-MS-Exchange-SLBlob-MailProps: 9IecXKUgicBNlqXpgndjr4h+wQt1UEYh3aBYgyaNCwYM216tJJ0TFzEjOfstSFXWCzTfPzqmhyIl7zqsWBD/BtVOhCMKf6aqOhzTl43v2AcE34wEZN1iiRZhW3mSj+4+cU4zQaIw+x6y0xtFM3OQOcAHqxy6JET1s3/y0p6LpqcLuvReUq2LJggJPouBB/pso5sDP/qXDgKH4FoULGwb+R06he0DKrwmuP5sH0U7V2zmalmiFReGa/593TPmpPA70F8mzLselaDXJTIO26D8lY26FqipbVSqRd8j5mcMqND6/f64Ut9DzkQBNjuvIEG4+tLDnN/ViDSRh5cU9nEjR/5LqInMy5M6EsyMI2ERY7TFzpdwBvwcQcVGC320toQLTK2Piiu692KlwK16S2VX8PFAO5HYnC2OhvKzEDAOtA+yjXaMsv2degXJh6rLap8IVdP6R/SOqAwXBnpC1ThQIwkDYERK6gFyfSpRlDEU2ceAXrqTMbnKcY6F+5qOgYlbZ0lGL5aihnFsdfqpcnq3KXexbAj7BlXK/boQrpnefBXd59YBDybV0OHG2svwQO1pKVrGX+A49jsKjQ6Mj+y+KzEyM3s+3qF6Iz2GIjtlSbpjsm3w67ax3dmk9qvvoHcPikQ5/KCvIzOCq7RMT3pjgHintD6P140P205sA8tXBT1owQr0uQi7tJxh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2524561d-41db-4a66-8a48-08dc3bb17c36 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 18:41:06.1032 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0538 Subject: [FFmpeg-devel] [PATCH 5/8] avutil/vulkan: Avoid shadowing 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: lggGBga2LeC2 Signed-off-by: Andreas Rheinhardt --- libavutil/vulkan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 76b61dcaaa..4392a77d6c 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -1308,13 +1308,15 @@ void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, VkImageLayout new_layout, uint32_t new_qf) { - int i, found; + int found = -1; AVVkFrame *vkf = (AVVkFrame *)pic->data[0]; const int nb_images = ff_vk_count_images(vkf); - for (i = 0; i < e->nb_frame_deps; i++) - if (e->frame_deps[i]->data[0] == pic->data[0]) + for (int i = 0; i < e->nb_frame_deps; i++) + if (e->frame_deps[i]->data[0] == pic->data[0]) { + if (e->frame_update[i]) + found = i; break; - found = (i < e->nb_frame_deps) && (e->frame_update[i]) ? i : -1; + } for (int i = 0; i < nb_images; i++) { bar[*nb_bar] = (VkImageMemoryBarrier2) { From patchwork Sun Mar 3 18:42:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46737 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2429554pzb; Sun, 3 Mar 2024 10:41:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVK5LPSvIeeu7ZSD1TbhgR7IyznxGHfPLSqUXqDj6rWz5pu3+bgtVPUmgN0iqYOFlBnK1BoLPbxksK08xVW5owBojzshUhoSPONiQ== X-Google-Smtp-Source: AGHT+IEmvmEVQGrvle6AgACPOp0GAdbivdR8GJJfndpYxw4MluuRI5/DXElsbaH9I3BscnbgKFi+ X-Received: by 2002:a17:906:f2ca:b0:a3d:e2e9:a7f7 with SMTP id gz10-20020a170906f2ca00b00a3de2e9a7f7mr4930830ejb.27.1709491302132; Sun, 03 Mar 2024 10:41:42 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r11-20020a170906c28b00b00a453d040f37si277036ejz.413.2024.03.03.10.41.41; Sun, 03 Mar 2024 10:41:42 -0800 (PST) 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=@outlook.com header.s=selector1 header.b=EUu4avmI; arc=fail (body hash mismatch); 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=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EA93868D3C8; Sun, 3 Mar 2024 20:41:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2069.outbound.protection.outlook.com [40.92.74.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CFCDE68D3B1 for ; Sun, 3 Mar 2024 20:41:15 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QEggF6oJLdiCKqyzzEd6+RY/kDxXoPn+yPVM228lZuMZqD2WBuWY8BzOLYpKYe/Sz3TbYVugRbnYffOXiBAGLjeT9WXUo6KFyZCQNR/gmuckpGP4+WWkzD6/g8LsZOs3m1jud1DxkOzcF3Gd+3byIpSikmXmHZLbHUiOzEILky5qWUXxLiMlKiP/cUlLZPoSxkmQkfbVBDPZm3WITyWpUGZxiNEiRTMqrZuZAC2z2Y7DKWv7IGe/O8ga9lvzw2dulDyQOPQ+xVjdWkWXfxlz9k7vkYQNqsEofst21XcEUWdnlLw8hYYYfuYPJ+Nf3Ptox85+lxY7SIYxYnAXLa3zyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EGztIC29o1RKW5EAG0Nja2JQijbbSXcQXTjR8VD+wfs=; b=fF1d5jmIDqNlGS8Rsw8OCcJllv9UpGf6Xm3JnSFZmawy3I1r0XGCm3DEjAb8d8tJ4mFFG0Tsk+ox9xS4pWQPK6rtJ55QpJZ/kCa440ExW/vrmQQXtGkAPoMb/2/95/c9dA8DEU8JLOSxbtBZQf4kloy/jD5beWoxOSQt+bPAjjOVADDA0W+rOBvbu2jJcpFKIo3RWEqLN3uVGPcuC1Op83ATVuiwijJofMbYzQr/9ZrB1a+s1WNSn0BrjAKl0vWOOwTuCPCu+2/8AefaHzlSSRwtSTPKxX8xhSfxHc9oOGPAbIeYClYyR80WTN6en1U9+IRmoejobnbvmjZ3F3FD6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EGztIC29o1RKW5EAG0Nja2JQijbbSXcQXTjR8VD+wfs=; b=EUu4avmIz37vM5h261j7/CmVQjvuvzvpa6errI0nMV+QfoeM4tHKCqKoYCemJeKegkKCp0eNpfvn4zTHBBuOY+EH//4tpX+tkL+QBlhfOSVmd0/lLmbuVrwV0DaStLDq6rkyvJAGMRBmGZkc8Suu2l9trFg1el0p67/DVdB6WKuWIsK8fys917fYB3pfch5JXnUVjKLjRXgUJfGNmLNVT7ow9mGdaq8WTlgt3rxdSQHXQdXbuluUy/Nl3UnvYFJn2pGS8fxofgcy623TUjXGaeMYqAhuIDag93x9/Pw2WJDqrQSi5oxtllxD+G9Q1M+c4oJJZNYKF9sE8FbHKBOdJA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0538.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:295::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Sun, 3 Mar 2024 18:41:07 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 18:41:07 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 19:42:48 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [euWGPcR/6poNgwDOx+OoQ4eMEvAzFmfxrTwtoukUnkw=] X-ClientProxiedBy: ZR2P278CA0066.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:52::20) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303184250.541590-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0538:EE_ X-MS-Office365-Filtering-Correlation-Id: 578b318c-276f-4d90-87af-08dc3bb17d2d X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqnx/C+6DC/TIciLJ1/n0VpfCzQof8J3WE9bKAStLR1CzdzDd0KCKBotn5/psVs0t9Q8znUxoHLcNWlrSGUmq6kszShjg1kSvKUa9j5i7Y6VsBT3PJ4ETfkd8DH6SW6q7rM232Rz/ckZIyHXxpu/WtiJFraD9Oowb6PnBQWrDLz/3kQelLfexKRznvWozpZftIhGLwc66OPNxuJjaSwNkFHSV6/vux++QeaVpLGaJNKIDPF/NAzEYAtK79v9j9l4CK5gkQIAqdrDWLz17Z7464vpQnAeUqEKsj7xcp4W/7hgP+XOEFyioReBvSSEc7gws5we5oxc9npaATTJRzI3kNqE5nIeueQpXGMWuou1OqFdIavXYz2LCr/IQFFepHuACUsZp2B+GEHiXzTGDyaMyzE6fQreD4OYj5JenKquoyY7xFktvdIi5VLTSK+fRquHh+7UveYGZ3C+CLreG8CmGNrsFmPFkUplUjpiW81lLWRFpEkbxiJP6d76kam6XFF+QTo/2sHJ/+eWP4ehRHN6lkMoTfYL9xOl3MlITFh0+VP9X5d46ZA5SHm6Jj5wqX9z9rbVkwnN+VJlmkW07uJzxdYmcy9K3jZHq8PiHK0Lk47ImrHVBVqghMU0zPg8i1H0jw4xAiKls0RCIiC1B/+xJGIRU5LcVtfmHgEYYVz7KjV3axzAam3hxYA+QzVbljg3q72O0RCCFjwxJvU27IsuvbbiVTV9MRqkE6I8sIL71dl4YksfJM/VRYDcKkT+8AcNqY= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /x9FuT4uD4loADdpsrqns7hut1gDbRdEzk0aCycGb3bUDfCleXku3NLWXDE/YzRbot+5mUOIgb8BVoHF1JMuZTKcC51oeASpVX/1yB24Evz80gJBqb23IUvfL2AMfOYLS3rNMwkGK5BSsRrO36lJygZj5knLMtbDNChvdw2sYSxCRrM+LwUjVGmkeSgldb88297WDd770eW6muLyqKk5yDueUCiXrHWyUTBBU4nUCpG8oV7IcThKtdt8ixVypw7Nez+Td/XrYORQlsZ2wWTbx1UKL7wZ0mSfEsL1huA1H9rxtJmptl3cumPMPwD56vBHzVDacD/DgNLkLwkcr5x2bMeUeCBXNASu6jL/KOEPtp6N4pFLvxM7iddAudE3bxuITp2NC9rwPEXkFE0QJatKUnJVtQtReADR4zsuymUoCP6PY5hR4mYvcg3KvgyA/WKAGCebdbGnaumD+lKNLZSn0ACHzIH19BlDTaJuY3rGbEhhiIBfJrwHhKJn7gHEAZNJ1EbQGOn3VUREdfNMSmegCELVGoe8tnGiAtAAHzfWeqRhcUJkyRb37l0UawCDEAr1vY45x+4BY2+6bTeIaR40FhhR9e2WBftxcC3tR1Ieop/I1/lSyZxJM6Lh9JGYEosO X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gj1ztzYjVa76xwudTvm5UeQPvx4YJVLZYZh3dC0+GlnRIoxfT0TIdUBXQzvlR3yEUkhN+zCvXk7LrzChobnasJOqaczRJTLVk8YtProAM16oFiwqfplZMhQXYU6mZrC6PIUbnVHP/xssTRYGTTMnXf3ZKjGKldkPmUSW7Cm1SRGgO1SOSXrcR6E2m20zIZMYlrkYIXps6LY6xcvn4CywNA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== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 578b318c-276f-4d90-87af-08dc3bb17d2d X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 18:41:07.7678 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0538 Subject: [FFmpeg-devel] [PATCH 6/8] avutil/vulkan: Make ff_vk_set_descriptor_image() static 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: b782l2yndqTE Only used in vulkan.c. Signed-off-by: Andreas Rheinhardt --- libavutil/vulkan.c | 11 ++++++----- libavutil/vulkan.h | 3 --- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 4392a77d6c..c725634fef 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -1659,9 +1659,10 @@ int ff_vk_set_descriptor_sampler(FFVulkanContext *s, FFVulkanPipeline *pl, return 0; } -int ff_vk_set_descriptor_image(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkExecContext *e, int set, int bind, int offs, - VkImageView view, VkImageLayout layout, VkSampler sampler) +static int vk_set_descriptor_image(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkExecContext *e, int set, int bind, int offs, + VkImageView view, VkImageLayout layout, + VkSampler sampler) { FFVulkanDescriptorSet *desc_set = &pl->desc_set[set]; VkDescriptorGetInfoEXT desc_get_info = { @@ -1758,8 +1759,8 @@ void ff_vk_update_descriptor_img_array(FFVulkanContext *s, FFVulkanPipeline *pl, const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format); for (int i = 0; i < nb_planes; i++) - ff_vk_set_descriptor_image(s, pl, e, set, binding, i, - views[i], layout, sampler); + vk_set_descriptor_image(s, pl, e, set, binding, i, + views[i], layout, sampler); } void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index 184d58ff5c..c04a43e278 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -485,9 +485,6 @@ void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, int ff_vk_set_descriptor_sampler(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkSampler *sampler); -int ff_vk_set_descriptor_image(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkExecContext *e, int set, int bind, int offs, - VkImageView view, VkImageLayout layout, VkSampler sampler); int ff_vk_set_descriptor_buffer(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt); From patchwork Sun Mar 3 18:42:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46738 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2429586pzb; Sun, 3 Mar 2024 10:41:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVrGf+kI6tGdLvZdvbEaLCpqYxfBzMq6nADGh2BifxO5IGUjj2RVosjovuSC8pbJh/NOpaa7sWc3FxMAdwVXg6pe6AOGUn0BWGBZw== X-Google-Smtp-Source: AGHT+IEfZ6APxZ9ovyq+bp107hCjp5+lKWrum6LZO7O6lClt6/5ThZyDoQD95n35HwmmSjFouCY2 X-Received: by 2002:a17:907:8e86:b0:a3f:a12:f8e6 with SMTP id tx6-20020a1709078e8600b00a3f0a12f8e6mr5606537ejc.6.1709491310487; Sun, 03 Mar 2024 10:41:50 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bu9-20020a170906a14900b00a3ba6fe0848si3220208ejb.765.2024.03.03.10.41.50; Sun, 03 Mar 2024 10:41:50 -0800 (PST) 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=@outlook.com header.s=selector1 header.b=a5f1Rkr4; arc=fail (body hash mismatch); 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=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C8A5168D3D0; Sun, 3 Mar 2024 20:41:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2069.outbound.protection.outlook.com [40.92.74.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2909868D3B1 for ; Sun, 3 Mar 2024 20:41:16 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UyClqi7SEVihJNAi8aPXgXbXHkiMQKs7XvWAod/eT94T2YcOg8LC62GgLxAmBqZcLrVjAUgatnsDqPtHj+7mixqYbkmyWbwP3JJVhma1eZFdi2b9//ihbaspDM22t1ZwaPtnISX5nt3qhI0V4CRUzbkLlM8XzgbCTJCe3r2QlrxTcmdIr55m9xkhMpBqHXRYL47aWLXqlUM/gzaOVu2M0QY6Vp4lOfY5IoR6WnV7N4WXRRLEXymDiU+VlbNxL8Os/mA5X+2c9NZ8uvmfLt4VDwooBsiSDXiZSlsFD3zelmqecPnZiHhqs8eaKY7F0Qpi6NLv3CBxj3cTe8F/TDVs3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xgOTay1rE/XVm/SxLXBmW0I3CGqkRb8rvUGCc90g5hA=; b=UJlK7kKhV0zFnv+RfDeGvj0VoK4DNQJMNpcURqSjOJyG+aFTVq8Say2VVoHKUVvXrXWJslu0yY0hv0UsobjR17aDa3to7nisLD0mtip1S8SmfVH9Ag6zexopdGkr4+0Au97zDv9/MdaQqynh3eesSAkyPURpKcO9XJ/FcomfCDiZ+ZAemoU1Dd6360F2RYitC5IGiRPvztizOaK31TG7sARDFqrvXsnWmPk3wdcLo/EpIeQb8pQPhZOnieNAMbhLrGecwBEM4TidOvzX2kt2axUtr3DM+lLEpNqvmJ0nV0G/D9tzyMQ2qOLg7Ibft58JWMDdPSDn5/uGekXlQsi7UA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xgOTay1rE/XVm/SxLXBmW0I3CGqkRb8rvUGCc90g5hA=; b=a5f1Rkr4rwJYi+0u8SNKz9/39o187EUTANjfx7ASFNX5Mp+7EY12hCA4ee6egeyLcz6kKKvEWAki+LvoqqI0gM0MMdN96PkioTBmU43TblOEOnB1WrynQhZGRu2URXidJ3BfDyvof5VvXkRs6X+1chRgQIku8dTOQWbWyF0wJUuCYpMfY32OJnlxreHglCwezbhvebTHLr14Ik5vAYEY+GvskxL7CkAkthoCB5r2wvteifLbC1Wq0/kp4YA+yjBcpK5fzBnAM/TAa3/WOul2DQnXbzYsubUqKUJN+kSoxHUMgOQhe/azY3iW+o5gljmB+0D2ZwHPbzW4WTCRO7d0uQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0538.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:295::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Sun, 3 Mar 2024 18:41:12 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 18:41:12 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 19:42:49 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [K3oNwwOPT+tCV1MWB0hWOiXFceJb/N1tPWAVmKoYI24=] X-ClientProxiedBy: ZR2P278CA0066.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:52::20) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303184250.541590-6-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0538:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a4c0398-57dc-4c7c-e55b-08dc3bb18048 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqnx/C+6DC/TIciLJ1/n0VpX6i9u6U61pWzF+CV9jW2TBq6xlo834xuJyYM8xSKO/9tJODJLUVI1Xc+9k5VvZvvDXWVyrU/3mKxRGnXsTzgBRhQDvGzXcqf8E+44hAuctaDKdlZNxLk90RuMWnVv6UnKRqMIPuzuU+UjcXCgcXgVCdC8XpU2cXiCTW40B3787duHZSRLA7Db4mO2IiFLLYDwzLEcvrHP658XC8+WhGtPun2JygQ3Q2ZP4qZo4WLfw/W3UXLnwW45g9aF94NmRnmfdY3X49Hwj7zR1RcfjApRLoO1bh5iuaB4r8lnnxEQMCEUBWUm19ad6hNaQCYhO+ZWkOx+26kcImsfwUwKJkXY+/RShQsh0MhX5amdptm9AedPJIe4D59vUqJK8ChrfkBBKDVV1FToyyvnhG5FLsYZrDe2k8MPfCJfF9k3zAT5Ne3sxCiWz6REyOl78IEepgamtKKTPBf21m1vJWJ1+4yB79hHk7YNR4A2rShBhcMx4oPbTr4zyaooSxqidfQ2SvNt3xd2nNAXKQDEDn+ayfaJnbv/o+hpSwG1FleZcswlBYJbaTQucbIxfbuoU7z8M32px4vBcMDc5OYbBjFYK5OVpS2EE90JWu8Z7wstn/t9AjHPXhaESUbaH/GHp+SaKi6B0Pbk6cdu3a3B2Iaav4IbfVGLqe5WbEIn6YVZ3PYrt9yMtQWrTbqqSNQO+OTmYdpheYMrYC+RXVg4XwmE8XkZtEIkCuUcvAb6AvRzT+J99A= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XKt2OTDppFZFTAnaYaFz71ghcg327Mzdq13f1mcXFHf2197ipMmQqLfEwt3CDqkHYbwMquIeSvON7sCHxxHmosbkLSlpwOZfcVE18hrBs7iRqfST/UMUqi8aal5tCsPFVYWsLetkbZnG/q7XzTUGUYpIao92/nF9qr5E8c84Tk25YIgv7MInEjuqwgf5bmathNkkHOVlDGv7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f8udWkB/dnLnCefjnaU0oZ8HYSaQKbXVZNnNEkqPzYO9bm2OqFYaHQHRwXeSCm+VaKrnMRE4dw7AJ/INnxbVFJTxzTxm2qmdrr3B1/76HIjl5qpGURB0hTmSjXBLLI/zBax1iaELTYJm7Lr1QhGOnosYsifG1d3lpHdZBRl96CcV8qVHxXOLDMTdpEWF1GlZxUzyia5setwmJV2MQW3c6N54SFpXLhbKRCP+1fQlWO5gb2qFElfgkc4+XhAKLRmntAxjypd5Giytt2oksjZoXZaLVgEDBLDIL+4rRXBmyCAxSDhNasnaGRnKQ+NflCzwE/MO6OwUXEytAYpRExqHetUANJq46oTjkD82UZ6oasYUSmVQR75x/4m8dtsfmOaj6c8YBmj4I8rr6H+cexP0gdkVc3d/MVR2lqy+oX37pEvdRmSOZkIK/KbNyj1VwsbuPPaMu+hWdcin6cJbHfDbFWkk+KFcYTcCxY/WiDS8iF7Sqc3eoGANV4zIdGfRfTAW+eb0ClbDvQFb3yaOsQssibGR09lvkZAG27eKqEXN6jvcqo10aw7qW3/+h5hO6QtzoCw5aqIvXLljED9hD0Bnt80tWZ4Z9wnRw80or89aaiAvePB5FVZBg1ixaK/s0stgUi7tPzTy2HO4tli0dgy437ZMinK9NRE/2JWtr2T1uuMy6Z1w4dDzduvYaBr5mQdjvLvkvuT5ytn8npP11eNYuVR2dQRdaWELA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a4c0398-57dc-4c7c-e55b-08dc3bb18048 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 18:41:12.8986 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0538 Subject: [FFmpeg-devel] [PATCH 7/8] avutil/vulkan: Remove unused ff_vk_set_descriptor_sampler() 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: laSWIJL7gc8j Signed-off-by: Andreas Rheinhardt --- libavutil/vulkan.c | 27 --------------------------- libavutil/vulkan.h | 4 ---- 2 files changed, 31 deletions(-) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index c725634fef..67b9526255 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -1632,33 +1632,6 @@ static inline void update_set_descriptor(FFVulkanContext *s, FFVkExecContext *e, vk->GetDescriptorEXT(s->hwctx->act_dev, desc_get_info, desc_size, desc); } -int ff_vk_set_descriptor_sampler(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkExecContext *e, int set, int bind, int offs, - VkSampler *sampler) -{ - FFVulkanDescriptorSet *desc_set = &pl->desc_set[set]; - VkDescriptorGetInfoEXT desc_get_info = { - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT, - .type = desc_set->binding[bind].descriptorType, - }; - - switch (desc_get_info.type) { - case VK_DESCRIPTOR_TYPE_SAMPLER: - desc_get_info.data.pSampler = sampler; - break; - default: - av_log(s, AV_LOG_ERROR, "Invalid descriptor type at set %i binding %i: %i!\n", - set, bind, desc_get_info.type); - return AVERROR(EINVAL); - break; - }; - - update_set_descriptor(s, e, desc_set, bind, offs, &desc_get_info, - s->desc_buf_props.samplerDescriptorSize); - - return 0; -} - static int vk_set_descriptor_image(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkImageView view, VkImageLayout layout, diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index c04a43e278..15d954fcb8 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -481,10 +481,6 @@ int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl); -/* Update sampler/image/buffer descriptors. e may be NULL for read-only descriptors. */ -int ff_vk_set_descriptor_sampler(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkExecContext *e, int set, int bind, int offs, - VkSampler *sampler); int ff_vk_set_descriptor_buffer(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt); From patchwork Sun Mar 3 18:42:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 46739 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a919:b0:19e:cdac:8cce with SMTP id cd25csp2429637pzb; Sun, 3 Mar 2024 10:41:59 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXCKOQ2yzzOfNnl0djy4OL1OecXaZwsPixIJJuUku3282yM6kP3JWTN/KxTqH+LABCUcSps4E0yqHcR1+X891e/IqSeSSScG2RC1Q== X-Google-Smtp-Source: AGHT+IEH3QD/zoxCA+04H+cI9teBsxso4s3OUTLwRcTJuHLBMM4a9dQd3K43axiBDivsnFGvVbfn X-Received: by 2002:a17:907:8e86:b0:a44:11b4:1d21 with SMTP id tx6-20020a1709078e8600b00a4411b41d21mr5823172ejc.3.1709491319451; Sun, 03 Mar 2024 10:41:59 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t8-20020a17090616c800b00a43532c219asi3269599ejd.271.2024.03.03.10.41.58; Sun, 03 Mar 2024 10:41:59 -0800 (PST) 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=@outlook.com header.s=selector1 header.b=uoDRIBii; arc=fail (body hash mismatch); 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=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DBBE668D3C5; Sun, 3 Mar 2024 20:41:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2108.outbound.protection.outlook.com [40.92.74.108]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7087468D368 for ; Sun, 3 Mar 2024 20:41:32 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LGHBkfOhVQCAXEt2F3GjBJpAGNIEvBpOsmhzH9V+UaGD06rmAqLLpbHm3CHU0u3S/lNT3NvopeAhjVUremwEYQxggxqtc95+7cl2/eCINPpmsAVX/SfaP9PrdEtqeWqdsWo8WJDl+9ZYD+HvAD/nW7g8JVTyYQD3g2pHKWdRtBy23xYZnsXl9E+inkKT0EW/QeueyI4ATP2YqhJ+YZMD/dEM3Ag/D032b/HV9EhbT94oEfOg5Uxm3IapieTgVcsl8ee70Y4/WH99Myd9eTKohnTUCiuKymAuaWswUH97Nbx7aiplNjuUKXyadTdLFxCdql7VZI7mnYIadAgTiWwTVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cIrz1tQJOZwH2iYIrM5DFSOimtTqBEEftiPmjjeCHXo=; b=muV/ZU7/huw2gaxhDSzny8A79BfbbPRLRvGgmb3MrijNKZrYg5bW/rAg0iyg+EngEpIVJwFrP6eYxQKSgLfHQtqlnB9yi5Kv6JsNVI37jcnp7wu31eFHTg8FyJiRZO9Cpo2y/JZMGUfQJAGktxQcXew6c3wkFK11u/TooSVVoiYb/4yk789fgId2cHeEp4Iv/Vlpr5ZSILPk2ngWqfbOA+hZJtXNkQZ58jhDQO7W4g07a01qXZ7qJRdtLFg9jNf0HMiloXfIvE1FrheSb6pkpCuO+rKHV1yaWGCh1GwJCfV2/xmi5mZ3y33jJB737vdzRJss5+LbfMSuNJbqKAD0og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cIrz1tQJOZwH2iYIrM5DFSOimtTqBEEftiPmjjeCHXo=; b=uoDRIBiiZjN+lxL33NXl2GvK7ygT0GC76CquuU+dLJQFRWnd31yu3i7dBc/d2efiv4pP+3jA7E+GZUrZieJ/Mf77v+++Vi87AHuGbp0U9p63YXhiwhdDAcbbNpIudc+mJdgCYCWsMZb80uzl+Qk8kYYJJHV0n6bgdSs1SwtKUs1YABm2Og8KOMmWPGseuFrq8NXEXVXbOBYBfNp8ypPA6sCrH2MvebPEyaXYEtUjaJuxQaNpEt1aIt3ALCwd7HX13n/EEIgBJxbmsX9zyXrlm/fFTf46hLGrQR+RdNzLuePQC1EjSU1EgOuW3T2rL03UcD/fsmbxKyQc/Q1nghuKKw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0538.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:295::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.37; Sun, 3 Mar 2024 18:41:28 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::65aa:deb0:a18e:d48d%5]) with mapi id 15.20.7316.023; Sun, 3 Mar 2024 18:41:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 3 Mar 2024 19:42:50 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [OI8DYQHbGnkcGJdo0g5MznBIvO/nt7OIPQw80UJJBT4=] X-ClientProxiedBy: ZR2P278CA0066.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:52::20) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240303184250.541590-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0538:EE_ X-MS-Office365-Filtering-Correlation-Id: 16f67f7b-cd64-4575-f016-08dc3bb18920 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqnx/C+6DC/TIciLJ1/n0VpCMlKH5japbfL8DkMUijoRe5QRBCR2ki97OEaGSwDNM9aavgYeBqaxUJcnXm5ZZ1gaysjlfZZj0doIbifqfbGKPzfJfXaILwCzWzS9XjPOfWeKs0E72619GxOkjvKd6abrw8c2VbWZMK/5IhAwEfH2Z/0YDhPnW5e1WTWvU+Dx3x4a35pbRZ+Da3fNLEbJqtyeuALEPsOG9Qx3cgFoFymu6kkFwo9Fe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77ffDxafFvqH3/gJ4D1AVjAGqQ0JrL6np1O9lFD8vuJqRKwPlJjls5811gm10QzLZLL9X6avecwc+Xraped2yLW/i73Ig1U/M4Q8C+QkUS6dejuXT+SSoKG4iW1HXo7f9im3XdOAUNnV/jLQBywy4S X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xJIgGcMrWfrVXARIRIyKAqkGGWcjloDrh8H2rRUccbQKFKn90lAxfz4QDMO2SbSJkkSwe10hzhEYCGmXq/DYCd8QVOz4H+Y+dl+KuGiB+Wf4lwAp8NDrY2883IbHMT4E4YfdI1fos1HdRBANRf0cfJtbERdAeLu/dI6YPujh+DxWmg4a024N5JWbtBYMjuLk+1seyJMG8QuC/k/ZAX1JwlTwIp0WNutGBVTahagLF2755+LcuHsp+EYcwNazFpAb0iFSNCubt8mkmcSdHtIC5A/7CLe7YYZlk8g+wSqShHi1RleLy9YpLESi92C27AXOhLkvcmZFK446kse+FOBXvmQydD5fKX2dk85qFF0gU5/eGACjj6yIhU7TOCDriHmPdt1Y26JxzWw7iey45e7xQ1kNP3cks96H7/gHgQoEJMGAI5ID33j/2DKnVEBIZrDZCImnPaqug296zv78Jk6UJ04nqpRqczFzrtUSYRInrAQX52lY7vCIKtMKAuuhepfMI4epffDRSOpiURUvc9KJ+xDbzjeo5UGIXJ6bDYdAI3y+hhNmqDVXU1d8XUepIQ4ybkbDT4pyM9+RuA92Y/2E8wzue08Sf/6PUzIFLv1S7y/NVQSPZDFXgKfn701YpoEUw0bxBoNgGrBexR+uJgHPnEMNp3xd73gPFMyYTOKBKFPs9hV6APkTnibkdwgZZUsYnhrZvlr5fIzML21n+sP/OQFPViWFY+CgpphJpd8h2elzmrZ8lmfV6gXUIPCese437UCeZWVxdg+asRRkjeqdijU+lseUCxATjlKywtVPTlWo7vQlQeprNzHRV9vvAF2JNT++r4FS+ezfObOwWfcSF5ead/1bUkvolDrurvxpROg9D4Qsc1SMS0lF8Ns2xCDkSHAJexVmQmU4wWa8GkkDyOtwLhK9jBUh0sN6m/Dmz/rHf+xgyTHM034TQyp/RyEsj7eQLDDaVFnhvYsrAnGR90xvBeRxjqeswAS1e/FGZQqea6JzPYX0k40kDz19pDuel376ztFyD6jxc42RgV3ehyZNyUJsG5d/IpFOyJYwCTvTNt2VbJeNAjR2v2Ki+mvc+tDBadMZwXL3iQPQhNjG95kxt2wRP3ZwtDH0xynr3ghkw965JcqZinf22h+GA/Ag2o0GZ+a+7o0Dll5MivcAi3wGAM26usFdWTu/1+Qu3aBCXUbJXXDZkUqIRWV03AJbxFjKv7TcoIpN9F9jEidLHHHreWc9B104DgSrXHV4ZHean8wdl67hiwBOhC0hm1jvdxRpJTNGB3/dI8V0JdIZgg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16f67f7b-cd64-4575-f016-08dc3bb18920 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2024 18:41:27.8592 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP250MB0538 Subject: [FFmpeg-devel] [PATCH 8/8] avutil/vulkan: Move functions only used by lavfi to it 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: F3XEXbxZZcxE lavu/vulkan.c is duplicated into lavfi, lavc and lavu, yet lots of functions in it are only used by lavfi. This commit moves them to lavfi, saving 6544B of .text from both lavc and lavu as well as some .rodata and .data.rel.ro (in total 7880B each for lavc and lavu). Signed-off-by: Andreas Rheinhardt --- One could also move this stuff to new files; e.g. both the shader and pipeline parts could be moved into files of their own which would then only be compiled for lavfi. libavfilter/vulkan_filter.c | 764 +++++++++++++++++++++++++++++++++++ libavfilter/vulkan_filter.h | 177 ++++++++ libavfilter/vulkan_glslang.c | 1 + libavfilter/vulkan_shaderc.c | 1 + libavutil/vulkan.c | 760 ---------------------------------- libavutil/vulkan.h | 176 -------- 6 files changed, 943 insertions(+), 936 deletions(-) diff --git a/libavfilter/vulkan_filter.c b/libavfilter/vulkan_filter.c index d3dc2fdacb..c354087dbc 100644 --- a/libavfilter/vulkan_filter.c +++ b/libavfilter/vulkan_filter.c @@ -19,6 +19,10 @@ */ #include "vulkan_filter.h" +#include "libavutil/bprint.h" +#include "libavutil/buffer.h" +#include "libavutil/mem.h" +#include "libavutil/pixdesc.h" #include "libavutil/vulkan_loader.h" int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s, @@ -457,3 +461,763 @@ fail: ff_vk_exec_discard_deps(vkctx, exec); return err; } + +static void free_data_buf(void *opaque, uint8_t *data) +{ + FFVulkanContext *ctx = opaque; + FFVkBuffer *buf = (FFVkBuffer *)data; + ff_vk_free_buf(ctx, buf); + av_free(data); +} + +static AVBufferRef *alloc_data_buf(void *opaque, size_t size) +{ + AVBufferRef *ref; + uint8_t *buf = av_mallocz(size); + if (!buf) + return NULL; + + ref = av_buffer_create(buf, size, free_data_buf, opaque, 0); + if (!ref) + av_free(buf); + return ref; +} + +int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVBufferPool **buf_pool, + AVBufferRef **buf, VkBufferUsageFlags usage, + void *create_pNext, size_t size, + VkMemoryPropertyFlagBits mem_props) +{ + int err; + AVBufferRef *ref; + FFVkBuffer *data; + + if (!(*buf_pool)) { + *buf_pool = av_buffer_pool_init2(sizeof(FFVkBuffer), ctx, + alloc_data_buf, NULL); + if (!(*buf_pool)) + return AVERROR(ENOMEM); + } + + *buf = ref = av_buffer_pool_get(*buf_pool); + if (!ref) + return AVERROR(ENOMEM); + + data = (FFVkBuffer *)ref->data; + data->stage = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT; + data->access = VK_ACCESS_2_NONE; + + if (data->size >= size) + return 0; + + ff_vk_free_buf(ctx, data); + memset(data, 0, sizeof(*data)); + + av_log(ctx, AV_LOG_DEBUG, "Allocating buffer of %"SIZE_SPECIFIER" bytes for pool %p\n", + size, *buf_pool); + + err = ff_vk_create_buf(ctx, data, size, + create_pNext, NULL, usage, + mem_props); + if (err < 0) { + av_buffer_unref(&ref); + return err; + } + + if (mem_props & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) { + err = ff_vk_map_buffer(ctx, data, &data->mapped_mem, 0); + if (err < 0) { + av_buffer_unref(&ref); + return err; + } + } + + return 0; +} + +int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, + VkShaderStageFlagBits stage) +{ + VkPushConstantRange *pc; + + pl->push_consts = av_realloc_array(pl->push_consts, sizeof(*pl->push_consts), + pl->push_consts_num + 1); + if (!pl->push_consts) + return AVERROR(ENOMEM); + + pc = &pl->push_consts[pl->push_consts_num++]; + memset(pc, 0, sizeof(*pc)); + + pc->stageFlags = stage; + pc->offset = offset; + pc->size = size; + + return 0; +} + +int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, + int unnorm_coords, VkFilter filt) +{ + VkResult ret; + FFVulkanFunctions *vk = &s->vkfn; + + VkSamplerCreateInfo sampler_info = { + .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, + .magFilter = filt, + .minFilter = sampler_info.magFilter, + .mipmapMode = unnorm_coords ? VK_SAMPLER_MIPMAP_MODE_NEAREST : + VK_SAMPLER_MIPMAP_MODE_LINEAR, + .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, + .addressModeV = sampler_info.addressModeU, + .addressModeW = sampler_info.addressModeU, + .anisotropyEnable = VK_FALSE, + .compareOp = VK_COMPARE_OP_NEVER, + .borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, + .unnormalizedCoordinates = unnorm_coords, + }; + + ret = vk->CreateSampler(s->hwctx->act_dev, &sampler_info, + s->hwctx->alloc, sampler); + if (ret != VK_SUCCESS) { + av_log(s, AV_LOG_ERROR, "Unable to init sampler: %s\n", + ff_vk_ret2str(ret)); + return AVERROR_EXTERNAL; + } + + return 0; +} + +int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt) +{ + if (pix_fmt == AV_PIX_FMT_ABGR || pix_fmt == AV_PIX_FMT_BGRA || + pix_fmt == AV_PIX_FMT_RGBA || pix_fmt == AV_PIX_FMT_RGB24 || + pix_fmt == AV_PIX_FMT_BGR24 || pix_fmt == AV_PIX_FMT_RGB48 || + pix_fmt == AV_PIX_FMT_RGBA64 || pix_fmt == AV_PIX_FMT_RGB565 || + pix_fmt == AV_PIX_FMT_BGR565 || pix_fmt == AV_PIX_FMT_BGR0 || + pix_fmt == AV_PIX_FMT_0BGR || pix_fmt == AV_PIX_FMT_RGB0) + return 1; + return 0; +} + +typedef struct ImageViewCtx { + VkImageView views[AV_NUM_DATA_POINTERS]; + int nb_views; +} ImageViewCtx; + +static void destroy_imageviews(void *opaque, uint8_t *data) +{ + FFVulkanContext *s = opaque; + FFVulkanFunctions *vk = &s->vkfn; + ImageViewCtx *iv = (ImageViewCtx *)data; + + for (int i = 0; i < iv->nb_views; i++) + vk->DestroyImageView(s->hwctx->act_dev, iv->views[i], s->hwctx->alloc); + + av_free(iv); +} + +int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, + VkImageView views[AV_NUM_DATA_POINTERS], + AVFrame *f) +{ + int err; + VkResult ret; + AVBufferRef *buf; + FFVulkanFunctions *vk = &s->vkfn; + AVHWFramesContext *hwfc = (AVHWFramesContext *)f->hw_frames_ctx->data; + const VkFormat *rep_fmts = av_vkfmt_from_pixfmt(hwfc->sw_format); + AVVkFrame *vkf = (AVVkFrame *)f->data[0]; + const int nb_images = ff_vk_count_images(vkf); + const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format); + + ImageViewCtx *iv = av_mallocz(sizeof(*iv)); + if (!iv) + return AVERROR(ENOMEM); + + for (int i = 0; i < nb_planes; i++) { + VkImageAspectFlags plane_aspect[] = { VK_IMAGE_ASPECT_COLOR_BIT, + VK_IMAGE_ASPECT_PLANE_0_BIT, + VK_IMAGE_ASPECT_PLANE_1_BIT, + VK_IMAGE_ASPECT_PLANE_2_BIT, }; + + VkImageViewCreateInfo view_create_info = { + .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, + .pNext = NULL, + .image = vkf->img[FFMIN(i, nb_images - 1)], + .viewType = VK_IMAGE_VIEW_TYPE_2D, + .format = rep_fmts[i], + .components = ff_comp_identity_map, + .subresourceRange = { + .aspectMask = plane_aspect[(nb_planes != nb_images) + + i*(nb_planes != nb_images)], + .levelCount = 1, + .layerCount = 1, + }, + }; + + ret = vk->CreateImageView(s->hwctx->act_dev, &view_create_info, + s->hwctx->alloc, &iv->views[i]); + if (ret != VK_SUCCESS) { + av_log(s, AV_LOG_ERROR, "Failed to create imageview: %s\n", + ff_vk_ret2str(ret)); + err = AVERROR_EXTERNAL; + goto fail; + } + + iv->nb_views++; + } + + buf = av_buffer_create((uint8_t *)iv, sizeof(*iv), destroy_imageviews, s, 0); + if (!buf) { + err = AVERROR(ENOMEM); + goto fail; + } + + /* Add to queue dependencies */ + err = ff_vk_exec_add_dep_buf(s, e, &buf, 1, 0); + if (err < 0) + av_buffer_unref(&buf); + + memcpy(views, iv->views, nb_planes*sizeof(*views)); + + return err; + +fail: + for (int i = 0; i < iv->nb_views; i++) + vk->DestroyImageView(s->hwctx->act_dev, iv->views[i], s->hwctx->alloc); + av_free(iv); + return err; +} + +const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pixfmt); + const int high = desc->comp[0].depth > 8; + return high ? "rgba16f" : "rgba8"; +} + +int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, + VkShaderStageFlags stage, uint32_t required_subgroup_size) +{ + av_bprint_init(&shd->src, 0, AV_BPRINT_SIZE_UNLIMITED); + + shd->shader.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + shd->shader.stage = stage; + + if (required_subgroup_size) { + shd->shader.flags |= VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT; + shd->shader.pNext = &shd->subgroup_info; + shd->subgroup_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO; + shd->subgroup_info.requiredSubgroupSize = required_subgroup_size; + } + + shd->name = name; + + GLSLF(0, #version %i ,460); + GLSLC(0, #define IS_WITHIN(v1, v2) ((v1.x < v2.x) && (v1.y < v2.y)) ); + GLSLC(0, ); + GLSLC(0, #extension GL_EXT_buffer_reference : require ); + GLSLC(0, #extension GL_EXT_buffer_reference2 : require ); + + return 0; +} + +void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z) +{ + shd->local_size[0] = x; + shd->local_size[1] = y; + shd->local_size[2] = z; + + av_bprintf(&shd->src, "layout (local_size_x = %i, " + "local_size_y = %i, local_size_z = %i) in;\n\n", + shd->local_size[0], shd->local_size[1], shd->local_size[2]); +} + +void ff_vk_shader_print(void *ctx, FFVkSPIRVShader *shd, int prio) +{ + int line = 0; + const char *p = shd->src.str; + const char *start = p; + const size_t len = strlen(p); + + AVBPrint buf; + av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); + + for (int i = 0; i < len; i++) { + if (p[i] == '\n') { + av_bprintf(&buf, "%i\t", ++line); + av_bprint_append_data(&buf, start, &p[i] - start + 1); + start = &p[i + 1]; + } + } + + av_log(ctx, prio, "Shader %s: \n%s", shd->name, buf.str); + av_bprint_finalize(&buf, NULL); +} + +void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd) +{ + FFVulkanFunctions *vk = &s->vkfn; + av_bprint_finalize(&shd->src, NULL); + + if (shd->shader.module) + vk->DestroyShaderModule(s->hwctx->act_dev, shd->shader.module, s->hwctx->alloc); +} + +int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, + uint8_t *spirv, size_t spirv_size, const char *entrypoint) +{ + VkResult ret; + FFVulkanFunctions *vk = &s->vkfn; + VkShaderModuleCreateInfo shader_create; + + shd->shader.pName = entrypoint; + + av_log(s, AV_LOG_VERBOSE, "Shader %s compiled! Size: %zu bytes\n", + shd->name, spirv_size); + + shader_create.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; + shader_create.pNext = NULL; + shader_create.codeSize = spirv_size; + shader_create.flags = 0; + shader_create.pCode = (void *)spirv; + + ret = vk->CreateShaderModule(s->hwctx->act_dev, &shader_create, NULL, + &shd->shader.module); + if (ret != VK_SUCCESS) { + av_log(s, AV_LOG_VERBOSE, "Error creating shader module: %s\n", + ff_vk_ret2str(ret)); + return AVERROR_EXTERNAL; + } + + return 0; +} + +static const struct descriptor_props { + size_t struct_size; /* Size of the opaque which updates the descriptor */ + const char *type; + int is_uniform; + int mem_quali; /* Can use a memory qualifier */ + int dim_needed; /* Must indicate dimension */ + int buf_content; /* Must indicate buffer contents */ +} descriptor_props[] = { + [VK_DESCRIPTOR_TYPE_SAMPLER] = { sizeof(VkDescriptorImageInfo), "sampler", 1, 0, 0, 0, }, + [VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE] = { sizeof(VkDescriptorImageInfo), "texture", 1, 0, 1, 0, }, + [VK_DESCRIPTOR_TYPE_STORAGE_IMAGE] = { sizeof(VkDescriptorImageInfo), "image", 1, 1, 1, 0, }, + [VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT] = { sizeof(VkDescriptorImageInfo), "subpassInput", 1, 0, 0, 0, }, + [VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER] = { sizeof(VkDescriptorImageInfo), "sampler", 1, 0, 1, 0, }, + [VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER] = { sizeof(VkDescriptorBufferInfo), NULL, 1, 0, 0, 1, }, + [VK_DESCRIPTOR_TYPE_STORAGE_BUFFER] = { sizeof(VkDescriptorBufferInfo), "buffer", 0, 1, 0, 1, }, + [VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC] = { sizeof(VkDescriptorBufferInfo), NULL, 1, 0, 0, 1, }, + [VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC] = { sizeof(VkDescriptorBufferInfo), "buffer", 0, 1, 0, 1, }, + [VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER] = { sizeof(VkBufferView), "samplerBuffer", 1, 0, 0, 0, }, + [VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER] = { sizeof(VkBufferView), "imageBuffer", 1, 0, 0, 0, }, +}; + +int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkSPIRVShader *shd, + FFVulkanDescriptorSetBinding *desc, int nb, + int read_only, int print_to_shader_only) +{ + VkResult ret; + int has_sampler = 0; + FFVulkanFunctions *vk = &s->vkfn; + FFVulkanDescriptorSet *set; + VkDescriptorSetLayoutCreateInfo desc_create_layout; + + if (print_to_shader_only) + goto print; + + /* Actual layout allocated for the pipeline */ + set = av_realloc_array(pl->desc_set, sizeof(*pl->desc_set), + pl->nb_descriptor_sets + 1); + if (!set) + return AVERROR(ENOMEM); + pl->desc_set = set; + set = &set[pl->nb_descriptor_sets]; + memset(set, 0, sizeof(*set)); + + set->binding = av_calloc(nb, sizeof(*set->binding)); + if (!set->binding) + return AVERROR(ENOMEM); + + set->binding_offset = av_calloc(nb, sizeof(*set->binding_offset)); + if (!set->binding_offset) { + av_freep(&set->binding); + return AVERROR(ENOMEM); + } + + desc_create_layout = (VkDescriptorSetLayoutCreateInfo) { + .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, + .bindingCount = nb, + .pBindings = set->binding, + .flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_DESCRIPTOR_BUFFER_BIT_EXT, + }; + + for (int i = 0; i < nb; i++) { + set->binding[i].binding = i; + set->binding[i].descriptorType = desc[i].type; + set->binding[i].descriptorCount = FFMAX(desc[i].elems, 1); + set->binding[i].stageFlags = desc[i].stages; + set->binding[i].pImmutableSamplers = desc[i].samplers; + + if (desc[i].type == VK_DESCRIPTOR_TYPE_SAMPLER || + desc[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) + has_sampler |= 1; + } + + set->usage = VK_BUFFER_USAGE_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT | + VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; + if (has_sampler) + set->usage |= VK_BUFFER_USAGE_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT; + + ret = vk->CreateDescriptorSetLayout(s->hwctx->act_dev, &desc_create_layout, + s->hwctx->alloc, &set->layout); + if (ret != VK_SUCCESS) { + av_log(s, AV_LOG_ERROR, "Unable to init descriptor set layout: %s", + ff_vk_ret2str(ret)); + return AVERROR_EXTERNAL; + } + + vk->GetDescriptorSetLayoutSizeEXT(s->hwctx->act_dev, set->layout, &set->layout_size); + + set->aligned_size = FFALIGN(set->layout_size, s->desc_buf_props.descriptorBufferOffsetAlignment); + + for (int i = 0; i < nb; i++) + vk->GetDescriptorSetLayoutBindingOffsetEXT(s->hwctx->act_dev, set->layout, + i, &set->binding_offset[i]); + + set->read_only = read_only; + set->nb_bindings = nb; + pl->nb_descriptor_sets++; + +print: + /* Write shader info */ + for (int i = 0; i < nb; i++) { + const struct descriptor_props *prop = &descriptor_props[desc[i].type]; + GLSLA("layout (set = %i, binding = %i", pl->nb_descriptor_sets - 1, i); + + if (desc[i].mem_layout) + GLSLA(", %s", desc[i].mem_layout); + GLSLA(")"); + + if (prop->is_uniform) + GLSLA(" uniform"); + + if (prop->mem_quali && desc[i].mem_quali) + GLSLA(" %s", desc[i].mem_quali); + + if (prop->type) + GLSLA(" %s", prop->type); + + if (prop->dim_needed) + GLSLA("%iD", desc[i].dimensions); + + GLSLA(" %s", desc[i].name); + + if (prop->buf_content) + GLSLA(" {\n %s\n}", desc[i].buf_content); + else if (desc[i].elems > 0) + GLSLA("[%i]", desc[i].elems); + + GLSLA(";"); + GLSLA("\n"); + } + GLSLA("\n"); + + return 0; +} + +int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, + FFVulkanPipeline *pl) +{ + int err; + + pl->desc_bind = av_calloc(pl->nb_descriptor_sets, sizeof(*pl->desc_bind)); + if (!pl->desc_bind) + return AVERROR(ENOMEM); + + pl->bound_buffer_indices = av_calloc(pl->nb_descriptor_sets, + sizeof(*pl->bound_buffer_indices)); + if (!pl->bound_buffer_indices) + return AVERROR(ENOMEM); + + for (int i = 0; i < pl->nb_descriptor_sets; i++) { + FFVulkanDescriptorSet *set = &pl->desc_set[i]; + int nb = set->read_only ? 1 : pool->pool_size; + + err = ff_vk_create_buf(s, &set->buf, set->aligned_size*nb, + NULL, NULL, set->usage, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); + if (err < 0) + return err; + + err = ff_vk_map_buffer(s, &set->buf, &set->desc_mem, 0); + if (err < 0) + return err; + + pl->desc_bind[i] = (VkDescriptorBufferBindingInfoEXT) { + .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_INFO_EXT, + .usage = set->usage, + .address = set->buf.address, + }; + + pl->bound_buffer_indices[i] = i; + } + + return 0; +} + +static inline void update_set_descriptor(FFVulkanContext *s, FFVkExecContext *e, + FFVulkanDescriptorSet *set, + int bind_idx, int array_idx, + VkDescriptorGetInfoEXT *desc_get_info, + size_t desc_size) +{ + FFVulkanFunctions *vk = &s->vkfn; + const size_t exec_offset = set->read_only ? 0 : set->aligned_size*e->idx; + void *desc = set->desc_mem + /* Base */ + exec_offset + /* Execution context */ + set->binding_offset[bind_idx] + /* Descriptor binding */ + array_idx*desc_size; /* Array position */ + + vk->GetDescriptorEXT(s->hwctx->act_dev, desc_get_info, desc_size, desc); +} + +static int vk_set_descriptor_image(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkExecContext *e, int set, int bind, int offs, + VkImageView view, VkImageLayout layout, + VkSampler sampler) +{ + FFVulkanDescriptorSet *desc_set = &pl->desc_set[set]; + VkDescriptorGetInfoEXT desc_get_info = { + .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT, + .type = desc_set->binding[bind].descriptorType, + }; + VkDescriptorImageInfo desc_img_info = { + .imageView = view, + .sampler = sampler, + .imageLayout = layout, + }; + size_t desc_size; + + switch (desc_get_info.type) { + case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: + desc_get_info.data.pSampledImage = &desc_img_info; + desc_size = s->desc_buf_props.sampledImageDescriptorSize; + break; + case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: + desc_get_info.data.pStorageImage = &desc_img_info; + desc_size = s->desc_buf_props.storageImageDescriptorSize; + break; + case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: + desc_get_info.data.pInputAttachmentImage = &desc_img_info; + desc_size = s->desc_buf_props.inputAttachmentDescriptorSize; + break; + case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: + desc_get_info.data.pCombinedImageSampler = &desc_img_info; + desc_size = s->desc_buf_props.combinedImageSamplerDescriptorSize; + break; + default: + av_log(s, AV_LOG_ERROR, "Invalid descriptor type at set %i binding %i: %i!\n", + set, bind, desc_get_info.type); + return AVERROR(EINVAL); + break; + }; + + update_set_descriptor(s, e, desc_set, bind, offs, &desc_get_info, desc_size); + + return 0; +} + +int ff_vk_set_descriptor_buffer(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkExecContext *e, int set, int bind, int offs, + VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt) +{ + FFVulkanDescriptorSet *desc_set = &pl->desc_set[set]; + VkDescriptorGetInfoEXT desc_get_info = { + .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT, + .type = desc_set->binding[bind].descriptorType, + }; + VkDescriptorAddressInfoEXT desc_buf_info = { + .address = addr, + .range = len, + .format = fmt, + }; + size_t desc_size; + + switch (desc_get_info.type) { + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: + desc_get_info.data.pUniformBuffer = &desc_buf_info; + desc_size = s->desc_buf_props.uniformBufferDescriptorSize; + break; + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: + desc_get_info.data.pStorageBuffer = &desc_buf_info; + desc_size = s->desc_buf_props.storageBufferDescriptorSize; + break; + case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: + desc_get_info.data.pUniformTexelBuffer = &desc_buf_info; + desc_size = s->desc_buf_props.uniformTexelBufferDescriptorSize; + break; + case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: + desc_get_info.data.pStorageTexelBuffer = &desc_buf_info; + desc_size = s->desc_buf_props.storageTexelBufferDescriptorSize; + break; + default: + av_log(s, AV_LOG_ERROR, "Invalid descriptor type at set %i binding %i: %i!\n", + set, bind, desc_get_info.type); + return AVERROR(EINVAL); + break; + }; + + update_set_descriptor(s, e, desc_set, bind, offs, &desc_get_info, desc_size); + + return 0; +} + +void ff_vk_update_descriptor_img_array(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkExecContext *e, AVFrame *f, + VkImageView *views, int set, int binding, + VkImageLayout layout, VkSampler sampler) +{ + AVHWFramesContext *hwfc = (AVHWFramesContext *)f->hw_frames_ctx->data; + const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format); + + for (int i = 0; i < nb_planes; i++) + vk_set_descriptor_image(s, pl, e, set, binding, i, + views[i], layout, sampler); +} + +void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, + FFVulkanPipeline *pl, + VkShaderStageFlagBits stage, + int offset, size_t size, void *src) +{ + FFVulkanFunctions *vk = &s->vkfn; + vk->CmdPushConstants(e->buf, pl->pipeline_layout, + stage, offset, size, src); +} + +static int init_pipeline_layout(FFVulkanContext *s, FFVulkanPipeline *pl) +{ + VkResult ret; + FFVulkanFunctions *vk = &s->vkfn; + VkPipelineLayoutCreateInfo pipeline_layout_info; + + VkDescriptorSetLayout *desc_layouts = av_malloc(pl->nb_descriptor_sets* + sizeof(desc_layouts)); + if (!desc_layouts) + return AVERROR(ENOMEM); + + for (int i = 0; i < pl->nb_descriptor_sets; i++) + desc_layouts[i] = pl->desc_set[i].layout; + + /* Finally create the pipeline layout */ + pipeline_layout_info = (VkPipelineLayoutCreateInfo) { + .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, + .pSetLayouts = desc_layouts, + .setLayoutCount = pl->nb_descriptor_sets, + .pushConstantRangeCount = pl->push_consts_num, + .pPushConstantRanges = pl->push_consts, + }; + + ret = vk->CreatePipelineLayout(s->hwctx->act_dev, &pipeline_layout_info, + s->hwctx->alloc, &pl->pipeline_layout); + av_free(desc_layouts); + if (ret != VK_SUCCESS) { + av_log(s, AV_LOG_ERROR, "Unable to init pipeline layout: %s\n", + ff_vk_ret2str(ret)); + return AVERROR_EXTERNAL; + } + + return 0; +} + +int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkSPIRVShader *shd) +{ + int err; + VkResult ret; + FFVulkanFunctions *vk = &s->vkfn; + + VkComputePipelineCreateInfo pipeline_create_info; + + err = init_pipeline_layout(s, pl); + if (err < 0) + return err; + + pipeline_create_info = (VkComputePipelineCreateInfo) { + .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, + .flags = VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT, + .layout = pl->pipeline_layout, + .stage = shd->shader, + }; + + ret = vk->CreateComputePipelines(s->hwctx->act_dev, VK_NULL_HANDLE, 1, + &pipeline_create_info, + s->hwctx->alloc, &pl->pipeline); + if (ret != VK_SUCCESS) { + av_log(s, AV_LOG_ERROR, "Unable to init compute pipeline: %s\n", + ff_vk_ret2str(ret)); + return AVERROR_EXTERNAL; + } + + pl->bind_point = VK_PIPELINE_BIND_POINT_COMPUTE; + pl->wg_size[0] = shd->local_size[0]; + pl->wg_size[1] = shd->local_size[1]; + pl->wg_size[2] = shd->local_size[2]; + + return 0; +} + +void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, + FFVulkanPipeline *pl) +{ + FFVulkanFunctions *vk = &s->vkfn; + VkDeviceSize offsets[1024]; + + /* Bind pipeline */ + vk->CmdBindPipeline(e->buf, pl->bind_point, pl->pipeline); + + if (pl->nb_descriptor_sets) { + for (int i = 0; i < pl->nb_descriptor_sets; i++) + offsets[i] = pl->desc_set[i].read_only ? 0 : pl->desc_set[i].aligned_size*e->idx; + + /* Bind descriptor buffers */ + vk->CmdBindDescriptorBuffersEXT(e->buf, pl->nb_descriptor_sets, pl->desc_bind); + /* Binding offsets */ + vk->CmdSetDescriptorBufferOffsetsEXT(e->buf, pl->bind_point, pl->pipeline_layout, + 0, pl->nb_descriptor_sets, + pl->bound_buffer_indices, offsets); + } +} + +void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl) +{ + FFVulkanFunctions *vk = &s->vkfn; + + if (pl->pipeline) + vk->DestroyPipeline(s->hwctx->act_dev, pl->pipeline, s->hwctx->alloc); + if (pl->pipeline_layout) + vk->DestroyPipelineLayout(s->hwctx->act_dev, pl->pipeline_layout, + s->hwctx->alloc); + + for (int i = 0; i < pl->nb_descriptor_sets; i++) { + FFVulkanDescriptorSet *set = &pl->desc_set[i]; + if (set->buf.mem) + ff_vk_unmap_buffer(s, &set->buf, 0); + ff_vk_free_buf(s, &set->buf); + if (set->layout) + vk->DestroyDescriptorSetLayout(s->hwctx->act_dev, set->layout, + s->hwctx->alloc); + av_free(set->binding); + av_free(set->binding_offset); + } + + av_freep(&pl->desc_set); + av_freep(&pl->desc_bind); + av_freep(&pl->bound_buffer_indices); + av_freep(&pl->push_consts); + pl->push_consts_num = 0; +} diff --git a/libavfilter/vulkan_filter.h b/libavfilter/vulkan_filter.h index d2c14601d9..9655f43caa 100644 --- a/libavfilter/vulkan_filter.h +++ b/libavfilter/vulkan_filter.h @@ -25,6 +25,98 @@ #include "vulkan.h" +#include "libavutil/bprint.h" + +/* GLSL management macros */ +#define INDENT(N) INDENT_##N +#define INDENT_0 +#define INDENT_1 INDENT_0 " " +#define INDENT_2 INDENT_1 INDENT_1 +#define INDENT_3 INDENT_2 INDENT_1 +#define INDENT_4 INDENT_3 INDENT_1 +#define INDENT_5 INDENT_4 INDENT_1 +#define INDENT_6 INDENT_5 INDENT_1 +#define C(N, S) INDENT(N) #S "\n" + +#define GLSLC(N, S) \ + do { \ + av_bprintf(&shd->src, C(N, S)); \ + } while (0) + +#define GLSLA(...) \ + do { \ + av_bprintf(&shd->src, __VA_ARGS__); \ + } while (0) + +#define GLSLF(N, S, ...) \ + do { \ + av_bprintf(&shd->src, C(N, S), __VA_ARGS__); \ + } while (0) + +#define GLSLD(D) \ + do { \ + av_bprintf(&shd->src, "\n"); \ + av_bprint_append_data(&shd->src, D, strlen(D)); \ + av_bprintf(&shd->src, "\n"); \ + } while (0) + +typedef struct FFVkSPIRVShader { + const char *name; /* Name for id/debugging purposes */ + AVBPrint src; + int local_size[3]; /* Compute shader workgroup sizes */ + VkPipelineShaderStageCreateInfo shader; + VkPipelineShaderStageRequiredSubgroupSizeCreateInfo subgroup_info; +} FFVkSPIRVShader; + +typedef struct FFVulkanDescriptorSetBinding { + const char *name; + VkDescriptorType type; + const char *mem_layout; /* Storage images (rgba8, etc.) and buffers (std430, etc.) */ + const char *mem_quali; /* readonly, writeonly, etc. */ + const char *buf_content; /* For buffers */ + uint32_t dimensions; /* Needed for e.g. sampler%iD */ + uint32_t elems; /* 0 - scalar, 1 or more - vector */ + VkShaderStageFlags stages; + VkSampler samplers[4]; /* Sampler to use for all elems */ +} FFVulkanDescriptorSetBinding; + +typedef struct FFVulkanDescriptorSet { + VkDescriptorSetLayout layout; + FFVkBuffer buf; + uint8_t *desc_mem; + VkDeviceSize layout_size; + VkDeviceSize aligned_size; /* descriptorBufferOffsetAlignment */ + VkDeviceSize total_size; /* Once registered to an exec context */ + VkBufferUsageFlags usage; + + VkDescriptorSetLayoutBinding *binding; + VkDeviceSize *binding_offset; + int nb_bindings; + + int read_only; +} FFVulkanDescriptorSet; + +typedef struct FFVulkanPipeline { + VkPipelineBindPoint bind_point; + + /* Contexts */ + VkPipelineLayout pipeline_layout; + VkPipeline pipeline; + + /* Push consts */ + VkPushConstantRange *push_consts; + int push_consts_num; + + /* Workgroup */ + int wg_size[3]; + + /* Descriptors */ + FFVulkanDescriptorSet *desc_set; + VkDescriptorBufferBindingInfoEXT *desc_bind; + uint32_t *bound_buffer_indices; + int nb_descriptor_sets; +} FFVulkanPipeline; + /** * General lavfi IO functions */ @@ -62,4 +154,89 @@ int ff_vk_filter_process_Nin(FFVulkanContext *vkctx, FFVkExecPool *e, AVFrame *out, AVFrame *in[], int nb_in, VkSampler sampler, void *push_src, size_t push_size); +/** + * Returns 1 if pixfmt is a usable RGB format. + */ +int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt); + +/** + * Create an imageview and add it as a dependency to an execution. + */ +int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, + VkImageView views[AV_NUM_DATA_POINTERS], + AVFrame *f); + +/** Initialize a pool and create AVBufferRefs containing FFVkBuffer. + * Threadsafe to use. Buffers are automatically mapped on creation if + * VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT is set in mem_props. Users should + * synchronize access themselvesd. Mainly meant for device-local buffers. */ +int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVBufferPool **buf_pool, + AVBufferRef **buf, VkBufferUsageFlags usage, + void *create_pNext, size_t size, + VkMemoryPropertyFlagBits mem_props); + +/** + * Create a sampler. + */ +int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, + int unnorm_coords, VkFilter filt); + +/** + * Returns the format to use for images in shaders. + */ +const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt); +/** + * Shader management. + */ +int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, + VkShaderStageFlags stage, uint32_t required_subgroup_size); +void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z); +void ff_vk_shader_print(void *ctx, FFVkSPIRVShader *shd, int prio); +int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, + uint8_t *spirv, size_t spirv_size, const char *entrypoint); +void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd); + +/** + * Add/update push constants for execution. + */ +int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, + VkShaderStageFlagBits stage); +void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, + FFVulkanPipeline *pl, + VkShaderStageFlagBits stage, + int offset, size_t size, void *src); + +/** + * Add descriptor to a pipeline. Must be called before pipeline init. + */ +int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkSPIRVShader *shd, + FFVulkanDescriptorSetBinding *desc, int nb, + int read_only, int print_to_shader_only); + +/* Initialize/free a pipeline. */ +int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkSPIRVShader *shd); +void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl); + +/** + * Register a pipeline with an exec pool. + * Pool may be NULL if all descriptor sets are read-only. + */ +int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, + FFVulkanPipeline *pl); + +/* Bind pipeline */ +void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, + FFVulkanPipeline *pl); + +int ff_vk_set_descriptor_buffer(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkExecContext *e, int set, int bind, int offs, + VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt); + +void ff_vk_update_descriptor_img_array(FFVulkanContext *s, FFVulkanPipeline *pl, + FFVkExecContext *e, AVFrame *f, + VkImageView *views, int set, int binding, + VkImageLayout layout, VkSampler sampler); + #endif /* AVFILTER_VULKAN_FILTER_H */ diff --git a/libavfilter/vulkan_glslang.c b/libavfilter/vulkan_glslang.c index 845a530ee0..9ee6ad7c39 100644 --- a/libavfilter/vulkan_glslang.c +++ b/libavfilter/vulkan_glslang.c @@ -21,6 +21,7 @@ #include #include +#include "vulkan_filter.h" #include "vulkan_spirv.h" #include "libavutil/mem.h" #include "libavutil/avassert.h" diff --git a/libavfilter/vulkan_shaderc.c b/libavfilter/vulkan_shaderc.c index 38be1030ad..57c62b618b 100644 --- a/libavfilter/vulkan_shaderc.c +++ b/libavfilter/vulkan_shaderc.c @@ -19,6 +19,7 @@ #include #include "libavutil/mem.h" +#include "vulkan_filter.h" #include "vulkan_spirv.h" static int shdc_shader_compile(FFVkSPIRVCompiler *ctx, void *avctx, diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 67b9526255..f609e8cd8d 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -1066,240 +1066,6 @@ void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf) vk->FreeMemory(s->hwctx->act_dev, buf->mem, s->hwctx->alloc); } -static void free_data_buf(void *opaque, uint8_t *data) -{ - FFVulkanContext *ctx = opaque; - FFVkBuffer *buf = (FFVkBuffer *)data; - ff_vk_free_buf(ctx, buf); - av_free(data); -} - -static AVBufferRef *alloc_data_buf(void *opaque, size_t size) -{ - AVBufferRef *ref; - uint8_t *buf = av_mallocz(size); - if (!buf) - return NULL; - - ref = av_buffer_create(buf, size, free_data_buf, opaque, 0); - if (!ref) - av_free(buf); - return ref; -} - -int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVBufferPool **buf_pool, - AVBufferRef **buf, VkBufferUsageFlags usage, - void *create_pNext, size_t size, - VkMemoryPropertyFlagBits mem_props) -{ - int err; - AVBufferRef *ref; - FFVkBuffer *data; - - if (!(*buf_pool)) { - *buf_pool = av_buffer_pool_init2(sizeof(FFVkBuffer), ctx, - alloc_data_buf, NULL); - if (!(*buf_pool)) - return AVERROR(ENOMEM); - } - - *buf = ref = av_buffer_pool_get(*buf_pool); - if (!ref) - return AVERROR(ENOMEM); - - data = (FFVkBuffer *)ref->data; - data->stage = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT; - data->access = VK_ACCESS_2_NONE; - - if (data->size >= size) - return 0; - - ff_vk_free_buf(ctx, data); - memset(data, 0, sizeof(*data)); - - av_log(ctx, AV_LOG_DEBUG, "Allocating buffer of %"SIZE_SPECIFIER" bytes for pool %p\n", - size, *buf_pool); - - err = ff_vk_create_buf(ctx, data, size, - create_pNext, NULL, usage, - mem_props); - if (err < 0) { - av_buffer_unref(&ref); - return err; - } - - if (mem_props & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) { - err = ff_vk_map_buffer(ctx, data, &data->mapped_mem, 0); - if (err < 0) { - av_buffer_unref(&ref); - return err; - } - } - - return 0; -} - -int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, - VkShaderStageFlagBits stage) -{ - VkPushConstantRange *pc; - - pl->push_consts = av_realloc_array(pl->push_consts, sizeof(*pl->push_consts), - pl->push_consts_num + 1); - if (!pl->push_consts) - return AVERROR(ENOMEM); - - pc = &pl->push_consts[pl->push_consts_num++]; - memset(pc, 0, sizeof(*pc)); - - pc->stageFlags = stage; - pc->offset = offset; - pc->size = size; - - return 0; -} - -int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, - int unnorm_coords, VkFilter filt) -{ - VkResult ret; - FFVulkanFunctions *vk = &s->vkfn; - - VkSamplerCreateInfo sampler_info = { - .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, - .magFilter = filt, - .minFilter = sampler_info.magFilter, - .mipmapMode = unnorm_coords ? VK_SAMPLER_MIPMAP_MODE_NEAREST : - VK_SAMPLER_MIPMAP_MODE_LINEAR, - .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, - .addressModeV = sampler_info.addressModeU, - .addressModeW = sampler_info.addressModeU, - .anisotropyEnable = VK_FALSE, - .compareOp = VK_COMPARE_OP_NEVER, - .borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, - .unnormalizedCoordinates = unnorm_coords, - }; - - ret = vk->CreateSampler(s->hwctx->act_dev, &sampler_info, - s->hwctx->alloc, sampler); - if (ret != VK_SUCCESS) { - av_log(s, AV_LOG_ERROR, "Unable to init sampler: %s\n", - ff_vk_ret2str(ret)); - return AVERROR_EXTERNAL; - } - - return 0; -} - -int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt) -{ - if (pix_fmt == AV_PIX_FMT_ABGR || pix_fmt == AV_PIX_FMT_BGRA || - pix_fmt == AV_PIX_FMT_RGBA || pix_fmt == AV_PIX_FMT_RGB24 || - pix_fmt == AV_PIX_FMT_BGR24 || pix_fmt == AV_PIX_FMT_RGB48 || - pix_fmt == AV_PIX_FMT_RGBA64 || pix_fmt == AV_PIX_FMT_RGB565 || - pix_fmt == AV_PIX_FMT_BGR565 || pix_fmt == AV_PIX_FMT_BGR0 || - pix_fmt == AV_PIX_FMT_0BGR || pix_fmt == AV_PIX_FMT_RGB0) - return 1; - return 0; -} - -const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt) -{ - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pixfmt); - const int high = desc->comp[0].depth > 8; - return high ? "rgba16f" : "rgba8"; -} - -typedef struct ImageViewCtx { - VkImageView views[AV_NUM_DATA_POINTERS]; - int nb_views; -} ImageViewCtx; - -static void destroy_imageviews(void *opaque, uint8_t *data) -{ - FFVulkanContext *s = opaque; - FFVulkanFunctions *vk = &s->vkfn; - ImageViewCtx *iv = (ImageViewCtx *)data; - - for (int i = 0; i < iv->nb_views; i++) - vk->DestroyImageView(s->hwctx->act_dev, iv->views[i], s->hwctx->alloc); - - av_free(iv); -} - -int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, - VkImageView views[AV_NUM_DATA_POINTERS], - AVFrame *f) -{ - int err; - VkResult ret; - AVBufferRef *buf; - FFVulkanFunctions *vk = &s->vkfn; - AVHWFramesContext *hwfc = (AVHWFramesContext *)f->hw_frames_ctx->data; - const VkFormat *rep_fmts = av_vkfmt_from_pixfmt(hwfc->sw_format); - AVVkFrame *vkf = (AVVkFrame *)f->data[0]; - const int nb_images = ff_vk_count_images(vkf); - const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format); - - ImageViewCtx *iv = av_mallocz(sizeof(*iv)); - if (!iv) - return AVERROR(ENOMEM); - - for (int i = 0; i < nb_planes; i++) { - VkImageAspectFlags plane_aspect[] = { VK_IMAGE_ASPECT_COLOR_BIT, - VK_IMAGE_ASPECT_PLANE_0_BIT, - VK_IMAGE_ASPECT_PLANE_1_BIT, - VK_IMAGE_ASPECT_PLANE_2_BIT, }; - - VkImageViewCreateInfo view_create_info = { - .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, - .pNext = NULL, - .image = vkf->img[FFMIN(i, nb_images - 1)], - .viewType = VK_IMAGE_VIEW_TYPE_2D, - .format = rep_fmts[i], - .components = ff_comp_identity_map, - .subresourceRange = { - .aspectMask = plane_aspect[(nb_planes != nb_images) + - i*(nb_planes != nb_images)], - .levelCount = 1, - .layerCount = 1, - }, - }; - - ret = vk->CreateImageView(s->hwctx->act_dev, &view_create_info, - s->hwctx->alloc, &iv->views[i]); - if (ret != VK_SUCCESS) { - av_log(s, AV_LOG_ERROR, "Failed to create imageview: %s\n", - ff_vk_ret2str(ret)); - err = AVERROR_EXTERNAL; - goto fail; - } - - iv->nb_views++; - } - - buf = av_buffer_create((uint8_t *)iv, sizeof(*iv), destroy_imageviews, s, 0); - if (!buf) { - err = AVERROR(ENOMEM); - goto fail; - } - - /* Add to queue dependencies */ - err = ff_vk_exec_add_dep_buf(s, e, &buf, 1, 0); - if (err < 0) - av_buffer_unref(&buf); - - memcpy(views, iv->views, nb_planes*sizeof(*views)); - - return err; - -fail: - for (int i = 0; i < iv->nb_views; i++) - vk->DestroyImageView(s->hwctx->act_dev, iv->views[i], s->hwctx->alloc); - av_free(iv); - return err; -} - void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags src_stage, @@ -1343,532 +1109,6 @@ void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, ff_vk_exec_update_frame(s, e, pic, &bar[*nb_bar - nb_images], NULL); } -int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, - VkShaderStageFlags stage, uint32_t required_subgroup_size) -{ - av_bprint_init(&shd->src, 0, AV_BPRINT_SIZE_UNLIMITED); - - shd->shader.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - shd->shader.stage = stage; - - if (required_subgroup_size) { - shd->shader.flags |= VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT; - shd->shader.pNext = &shd->subgroup_info; - shd->subgroup_info.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO; - shd->subgroup_info.requiredSubgroupSize = required_subgroup_size; - } - - shd->name = name; - - GLSLF(0, #version %i ,460); - GLSLC(0, #define IS_WITHIN(v1, v2) ((v1.x < v2.x) && (v1.y < v2.y)) ); - GLSLC(0, ); - GLSLC(0, #extension GL_EXT_buffer_reference : require ); - GLSLC(0, #extension GL_EXT_buffer_reference2 : require ); - - return 0; -} - -void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z) -{ - shd->local_size[0] = x; - shd->local_size[1] = y; - shd->local_size[2] = z; - - av_bprintf(&shd->src, "layout (local_size_x = %i, " - "local_size_y = %i, local_size_z = %i) in;\n\n", - shd->local_size[0], shd->local_size[1], shd->local_size[2]); -} - -void ff_vk_shader_print(void *ctx, FFVkSPIRVShader *shd, int prio) -{ - int line = 0; - const char *p = shd->src.str; - const char *start = p; - const size_t len = strlen(p); - - AVBPrint buf; - av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); - - for (int i = 0; i < len; i++) { - if (p[i] == '\n') { - av_bprintf(&buf, "%i\t", ++line); - av_bprint_append_data(&buf, start, &p[i] - start + 1); - start = &p[i + 1]; - } - } - - av_log(ctx, prio, "Shader %s: \n%s", shd->name, buf.str); - av_bprint_finalize(&buf, NULL); -} - -void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd) -{ - FFVulkanFunctions *vk = &s->vkfn; - av_bprint_finalize(&shd->src, NULL); - - if (shd->shader.module) - vk->DestroyShaderModule(s->hwctx->act_dev, shd->shader.module, s->hwctx->alloc); -} - -int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, - uint8_t *spirv, size_t spirv_size, const char *entrypoint) -{ - VkResult ret; - FFVulkanFunctions *vk = &s->vkfn; - VkShaderModuleCreateInfo shader_create; - - shd->shader.pName = entrypoint; - - av_log(s, AV_LOG_VERBOSE, "Shader %s compiled! Size: %zu bytes\n", - shd->name, spirv_size); - - shader_create.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - shader_create.pNext = NULL; - shader_create.codeSize = spirv_size; - shader_create.flags = 0; - shader_create.pCode = (void *)spirv; - - ret = vk->CreateShaderModule(s->hwctx->act_dev, &shader_create, NULL, - &shd->shader.module); - if (ret != VK_SUCCESS) { - av_log(s, AV_LOG_VERBOSE, "Error creating shader module: %s\n", - ff_vk_ret2str(ret)); - return AVERROR_EXTERNAL; - } - - return 0; -} - -static const struct descriptor_props { - size_t struct_size; /* Size of the opaque which updates the descriptor */ - const char *type; - int is_uniform; - int mem_quali; /* Can use a memory qualifier */ - int dim_needed; /* Must indicate dimension */ - int buf_content; /* Must indicate buffer contents */ -} descriptor_props[] = { - [VK_DESCRIPTOR_TYPE_SAMPLER] = { sizeof(VkDescriptorImageInfo), "sampler", 1, 0, 0, 0, }, - [VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE] = { sizeof(VkDescriptorImageInfo), "texture", 1, 0, 1, 0, }, - [VK_DESCRIPTOR_TYPE_STORAGE_IMAGE] = { sizeof(VkDescriptorImageInfo), "image", 1, 1, 1, 0, }, - [VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT] = { sizeof(VkDescriptorImageInfo), "subpassInput", 1, 0, 0, 0, }, - [VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER] = { sizeof(VkDescriptorImageInfo), "sampler", 1, 0, 1, 0, }, - [VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER] = { sizeof(VkDescriptorBufferInfo), NULL, 1, 0, 0, 1, }, - [VK_DESCRIPTOR_TYPE_STORAGE_BUFFER] = { sizeof(VkDescriptorBufferInfo), "buffer", 0, 1, 0, 1, }, - [VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC] = { sizeof(VkDescriptorBufferInfo), NULL, 1, 0, 0, 1, }, - [VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC] = { sizeof(VkDescriptorBufferInfo), "buffer", 0, 1, 0, 1, }, - [VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER] = { sizeof(VkBufferView), "samplerBuffer", 1, 0, 0, 0, }, - [VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER] = { sizeof(VkBufferView), "imageBuffer", 1, 0, 0, 0, }, -}; - -int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkSPIRVShader *shd, - FFVulkanDescriptorSetBinding *desc, int nb, - int read_only, int print_to_shader_only) -{ - VkResult ret; - int has_sampler = 0; - FFVulkanFunctions *vk = &s->vkfn; - FFVulkanDescriptorSet *set; - VkDescriptorSetLayoutCreateInfo desc_create_layout; - - if (print_to_shader_only) - goto print; - - /* Actual layout allocated for the pipeline */ - set = av_realloc_array(pl->desc_set, sizeof(*pl->desc_set), - pl->nb_descriptor_sets + 1); - if (!set) - return AVERROR(ENOMEM); - pl->desc_set = set; - set = &set[pl->nb_descriptor_sets]; - memset(set, 0, sizeof(*set)); - - set->binding = av_calloc(nb, sizeof(*set->binding)); - if (!set->binding) - return AVERROR(ENOMEM); - - set->binding_offset = av_calloc(nb, sizeof(*set->binding_offset)); - if (!set->binding_offset) { - av_freep(&set->binding); - return AVERROR(ENOMEM); - } - - desc_create_layout = (VkDescriptorSetLayoutCreateInfo) { - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, - .bindingCount = nb, - .pBindings = set->binding, - .flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_DESCRIPTOR_BUFFER_BIT_EXT, - }; - - for (int i = 0; i < nb; i++) { - set->binding[i].binding = i; - set->binding[i].descriptorType = desc[i].type; - set->binding[i].descriptorCount = FFMAX(desc[i].elems, 1); - set->binding[i].stageFlags = desc[i].stages; - set->binding[i].pImmutableSamplers = desc[i].samplers; - - if (desc[i].type == VK_DESCRIPTOR_TYPE_SAMPLER || - desc[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) - has_sampler |= 1; - } - - set->usage = VK_BUFFER_USAGE_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT | - VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT; - if (has_sampler) - set->usage |= VK_BUFFER_USAGE_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT; - - ret = vk->CreateDescriptorSetLayout(s->hwctx->act_dev, &desc_create_layout, - s->hwctx->alloc, &set->layout); - if (ret != VK_SUCCESS) { - av_log(s, AV_LOG_ERROR, "Unable to init descriptor set layout: %s", - ff_vk_ret2str(ret)); - return AVERROR_EXTERNAL; - } - - vk->GetDescriptorSetLayoutSizeEXT(s->hwctx->act_dev, set->layout, &set->layout_size); - - set->aligned_size = FFALIGN(set->layout_size, s->desc_buf_props.descriptorBufferOffsetAlignment); - - for (int i = 0; i < nb; i++) - vk->GetDescriptorSetLayoutBindingOffsetEXT(s->hwctx->act_dev, set->layout, - i, &set->binding_offset[i]); - - set->read_only = read_only; - set->nb_bindings = nb; - pl->nb_descriptor_sets++; - -print: - /* Write shader info */ - for (int i = 0; i < nb; i++) { - const struct descriptor_props *prop = &descriptor_props[desc[i].type]; - GLSLA("layout (set = %i, binding = %i", pl->nb_descriptor_sets - 1, i); - - if (desc[i].mem_layout) - GLSLA(", %s", desc[i].mem_layout); - GLSLA(")"); - - if (prop->is_uniform) - GLSLA(" uniform"); - - if (prop->mem_quali && desc[i].mem_quali) - GLSLA(" %s", desc[i].mem_quali); - - if (prop->type) - GLSLA(" %s", prop->type); - - if (prop->dim_needed) - GLSLA("%iD", desc[i].dimensions); - - GLSLA(" %s", desc[i].name); - - if (prop->buf_content) - GLSLA(" {\n %s\n}", desc[i].buf_content); - else if (desc[i].elems > 0) - GLSLA("[%i]", desc[i].elems); - - GLSLA(";"); - GLSLA("\n"); - } - GLSLA("\n"); - - return 0; -} - -int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, - FFVulkanPipeline *pl) -{ - int err; - - pl->desc_bind = av_calloc(pl->nb_descriptor_sets, sizeof(*pl->desc_bind)); - if (!pl->desc_bind) - return AVERROR(ENOMEM); - - pl->bound_buffer_indices = av_calloc(pl->nb_descriptor_sets, - sizeof(*pl->bound_buffer_indices)); - if (!pl->bound_buffer_indices) - return AVERROR(ENOMEM); - - for (int i = 0; i < pl->nb_descriptor_sets; i++) { - FFVulkanDescriptorSet *set = &pl->desc_set[i]; - int nb = set->read_only ? 1 : pool->pool_size; - - err = ff_vk_create_buf(s, &set->buf, set->aligned_size*nb, - NULL, NULL, set->usage, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); - if (err < 0) - return err; - - err = ff_vk_map_buffer(s, &set->buf, &set->desc_mem, 0); - if (err < 0) - return err; - - pl->desc_bind[i] = (VkDescriptorBufferBindingInfoEXT) { - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_INFO_EXT, - .usage = set->usage, - .address = set->buf.address, - }; - - pl->bound_buffer_indices[i] = i; - } - - return 0; -} - -static inline void update_set_descriptor(FFVulkanContext *s, FFVkExecContext *e, - FFVulkanDescriptorSet *set, - int bind_idx, int array_idx, - VkDescriptorGetInfoEXT *desc_get_info, - size_t desc_size) -{ - FFVulkanFunctions *vk = &s->vkfn; - const size_t exec_offset = set->read_only ? 0 : set->aligned_size*e->idx; - void *desc = set->desc_mem + /* Base */ - exec_offset + /* Execution context */ - set->binding_offset[bind_idx] + /* Descriptor binding */ - array_idx*desc_size; /* Array position */ - - vk->GetDescriptorEXT(s->hwctx->act_dev, desc_get_info, desc_size, desc); -} - -static int vk_set_descriptor_image(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkExecContext *e, int set, int bind, int offs, - VkImageView view, VkImageLayout layout, - VkSampler sampler) -{ - FFVulkanDescriptorSet *desc_set = &pl->desc_set[set]; - VkDescriptorGetInfoEXT desc_get_info = { - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT, - .type = desc_set->binding[bind].descriptorType, - }; - VkDescriptorImageInfo desc_img_info = { - .imageView = view, - .sampler = sampler, - .imageLayout = layout, - }; - size_t desc_size; - - switch (desc_get_info.type) { - case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: - desc_get_info.data.pSampledImage = &desc_img_info; - desc_size = s->desc_buf_props.sampledImageDescriptorSize; - break; - case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: - desc_get_info.data.pStorageImage = &desc_img_info; - desc_size = s->desc_buf_props.storageImageDescriptorSize; - break; - case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: - desc_get_info.data.pInputAttachmentImage = &desc_img_info; - desc_size = s->desc_buf_props.inputAttachmentDescriptorSize; - break; - case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: - desc_get_info.data.pCombinedImageSampler = &desc_img_info; - desc_size = s->desc_buf_props.combinedImageSamplerDescriptorSize; - break; - default: - av_log(s, AV_LOG_ERROR, "Invalid descriptor type at set %i binding %i: %i!\n", - set, bind, desc_get_info.type); - return AVERROR(EINVAL); - break; - }; - - update_set_descriptor(s, e, desc_set, bind, offs, &desc_get_info, desc_size); - - return 0; -} - -int ff_vk_set_descriptor_buffer(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkExecContext *e, int set, int bind, int offs, - VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt) -{ - FFVulkanDescriptorSet *desc_set = &pl->desc_set[set]; - VkDescriptorGetInfoEXT desc_get_info = { - .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT, - .type = desc_set->binding[bind].descriptorType, - }; - VkDescriptorAddressInfoEXT desc_buf_info = { - .address = addr, - .range = len, - .format = fmt, - }; - size_t desc_size; - - switch (desc_get_info.type) { - case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: - desc_get_info.data.pUniformBuffer = &desc_buf_info; - desc_size = s->desc_buf_props.uniformBufferDescriptorSize; - break; - case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: - desc_get_info.data.pStorageBuffer = &desc_buf_info; - desc_size = s->desc_buf_props.storageBufferDescriptorSize; - break; - case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: - desc_get_info.data.pUniformTexelBuffer = &desc_buf_info; - desc_size = s->desc_buf_props.uniformTexelBufferDescriptorSize; - break; - case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: - desc_get_info.data.pStorageTexelBuffer = &desc_buf_info; - desc_size = s->desc_buf_props.storageTexelBufferDescriptorSize; - break; - default: - av_log(s, AV_LOG_ERROR, "Invalid descriptor type at set %i binding %i: %i!\n", - set, bind, desc_get_info.type); - return AVERROR(EINVAL); - break; - }; - - update_set_descriptor(s, e, desc_set, bind, offs, &desc_get_info, desc_size); - - return 0; -} - -void ff_vk_update_descriptor_img_array(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkExecContext *e, AVFrame *f, - VkImageView *views, int set, int binding, - VkImageLayout layout, VkSampler sampler) -{ - AVHWFramesContext *hwfc = (AVHWFramesContext *)f->hw_frames_ctx->data; - const int nb_planes = av_pix_fmt_count_planes(hwfc->sw_format); - - for (int i = 0; i < nb_planes; i++) - vk_set_descriptor_image(s, pl, e, set, binding, i, - views[i], layout, sampler); -} - -void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, - FFVulkanPipeline *pl, - VkShaderStageFlagBits stage, - int offset, size_t size, void *src) -{ - FFVulkanFunctions *vk = &s->vkfn; - vk->CmdPushConstants(e->buf, pl->pipeline_layout, - stage, offset, size, src); -} - -static int init_pipeline_layout(FFVulkanContext *s, FFVulkanPipeline *pl) -{ - VkResult ret; - FFVulkanFunctions *vk = &s->vkfn; - VkPipelineLayoutCreateInfo pipeline_layout_info; - - VkDescriptorSetLayout *desc_layouts = av_malloc(pl->nb_descriptor_sets* - sizeof(desc_layouts)); - if (!desc_layouts) - return AVERROR(ENOMEM); - - for (int i = 0; i < pl->nb_descriptor_sets; i++) - desc_layouts[i] = pl->desc_set[i].layout; - - /* Finally create the pipeline layout */ - pipeline_layout_info = (VkPipelineLayoutCreateInfo) { - .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, - .pSetLayouts = desc_layouts, - .setLayoutCount = pl->nb_descriptor_sets, - .pushConstantRangeCount = pl->push_consts_num, - .pPushConstantRanges = pl->push_consts, - }; - - ret = vk->CreatePipelineLayout(s->hwctx->act_dev, &pipeline_layout_info, - s->hwctx->alloc, &pl->pipeline_layout); - av_free(desc_layouts); - if (ret != VK_SUCCESS) { - av_log(s, AV_LOG_ERROR, "Unable to init pipeline layout: %s\n", - ff_vk_ret2str(ret)); - return AVERROR_EXTERNAL; - } - - return 0; -} - -int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkSPIRVShader *shd) -{ - int err; - VkResult ret; - FFVulkanFunctions *vk = &s->vkfn; - - VkComputePipelineCreateInfo pipeline_create_info; - - err = init_pipeline_layout(s, pl); - if (err < 0) - return err; - - pipeline_create_info = (VkComputePipelineCreateInfo) { - .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, - .flags = VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT, - .layout = pl->pipeline_layout, - .stage = shd->shader, - }; - - ret = vk->CreateComputePipelines(s->hwctx->act_dev, VK_NULL_HANDLE, 1, - &pipeline_create_info, - s->hwctx->alloc, &pl->pipeline); - if (ret != VK_SUCCESS) { - av_log(s, AV_LOG_ERROR, "Unable to init compute pipeline: %s\n", - ff_vk_ret2str(ret)); - return AVERROR_EXTERNAL; - } - - pl->bind_point = VK_PIPELINE_BIND_POINT_COMPUTE; - pl->wg_size[0] = shd->local_size[0]; - pl->wg_size[1] = shd->local_size[1]; - pl->wg_size[2] = shd->local_size[2]; - - return 0; -} - -void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, - FFVulkanPipeline *pl) -{ - FFVulkanFunctions *vk = &s->vkfn; - VkDeviceSize offsets[1024]; - - /* Bind pipeline */ - vk->CmdBindPipeline(e->buf, pl->bind_point, pl->pipeline); - - if (pl->nb_descriptor_sets) { - for (int i = 0; i < pl->nb_descriptor_sets; i++) - offsets[i] = pl->desc_set[i].read_only ? 0 : pl->desc_set[i].aligned_size*e->idx; - - /* Bind descriptor buffers */ - vk->CmdBindDescriptorBuffersEXT(e->buf, pl->nb_descriptor_sets, pl->desc_bind); - /* Binding offsets */ - vk->CmdSetDescriptorBufferOffsetsEXT(e->buf, pl->bind_point, pl->pipeline_layout, - 0, pl->nb_descriptor_sets, - pl->bound_buffer_indices, offsets); - } -} - -void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl) -{ - FFVulkanFunctions *vk = &s->vkfn; - - if (pl->pipeline) - vk->DestroyPipeline(s->hwctx->act_dev, pl->pipeline, s->hwctx->alloc); - if (pl->pipeline_layout) - vk->DestroyPipelineLayout(s->hwctx->act_dev, pl->pipeline_layout, - s->hwctx->alloc); - - for (int i = 0; i < pl->nb_descriptor_sets; i++) { - FFVulkanDescriptorSet *set = &pl->desc_set[i]; - if (set->buf.mem) - ff_vk_unmap_buffer(s, &set->buf, 0); - ff_vk_free_buf(s, &set->buf); - if (set->layout) - vk->DestroyDescriptorSetLayout(s->hwctx->act_dev, set->layout, - s->hwctx->alloc); - av_free(set->binding); - av_free(set->binding_offset); - } - - av_freep(&pl->desc_set); - av_freep(&pl->desc_bind); - av_freep(&pl->bound_buffer_indices); - av_freep(&pl->push_consts); - pl->push_consts_num = 0; -} - void ff_vk_uninit(FFVulkanContext *s) { av_freep(&s->query_props); diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index 15d954fcb8..e30f0361c3 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -25,43 +25,10 @@ #include "thread.h" #include "pixdesc.h" -#include "bprint.h" #include "hwcontext.h" #include "vulkan_functions.h" #include "hwcontext_vulkan.h" -/* GLSL management macros */ -#define INDENT(N) INDENT_##N -#define INDENT_0 -#define INDENT_1 INDENT_0 " " -#define INDENT_2 INDENT_1 INDENT_1 -#define INDENT_3 INDENT_2 INDENT_1 -#define INDENT_4 INDENT_3 INDENT_1 -#define INDENT_5 INDENT_4 INDENT_1 -#define INDENT_6 INDENT_5 INDENT_1 -#define C(N, S) INDENT(N) #S "\n" - -#define GLSLC(N, S) \ - do { \ - av_bprintf(&shd->src, C(N, S)); \ - } while (0) - -#define GLSLA(...) \ - do { \ - av_bprintf(&shd->src, __VA_ARGS__); \ - } while (0) - -#define GLSLF(N, S, ...) \ - do { \ - av_bprintf(&shd->src, C(N, S), __VA_ARGS__); \ - } while (0) - -#define GLSLD(D) \ - do { \ - av_bprintf(&shd->src, "\n"); \ - av_bprint_append_data(&shd->src, D, strlen(D)); \ - av_bprintf(&shd->src, "\n"); \ - } while (0) /* Helper, pretty much every Vulkan return value needs to be checked */ #define RET(x) \ @@ -72,26 +39,6 @@ #define DUP_SAMPLER(x) { x, x, x, x } -typedef struct FFVkSPIRVShader { - const char *name; /* Name for id/debugging purposes */ - AVBPrint src; - int local_size[3]; /* Compute shader workgroup sizes */ - VkPipelineShaderStageCreateInfo shader; - VkPipelineShaderStageRequiredSubgroupSizeCreateInfo subgroup_info; -} FFVkSPIRVShader; - -typedef struct FFVulkanDescriptorSetBinding { - const char *name; - VkDescriptorType type; - const char *mem_layout; /* Storage images (rgba8, etc.) and buffers (std430, etc.) */ - const char *mem_quali; /* readonly, writeonly, etc. */ - const char *buf_content; /* For buffers */ - uint32_t dimensions; /* Needed for e.g. sampler%iD */ - uint32_t elems; /* 0 - scalar, 1 or more - vector */ - VkShaderStageFlags stages; - VkSampler samplers[4]; /* Sampler to use for all elems */ -} FFVulkanDescriptorSetBinding; - typedef struct FFVkBuffer { VkBuffer buf; VkDeviceMemory mem; @@ -112,43 +59,6 @@ typedef struct FFVkQueueFamilyCtx { int nb_queues; } FFVkQueueFamilyCtx; -typedef struct FFVulkanDescriptorSet { - VkDescriptorSetLayout layout; - FFVkBuffer buf; - uint8_t *desc_mem; - VkDeviceSize layout_size; - VkDeviceSize aligned_size; /* descriptorBufferOffsetAlignment */ - VkDeviceSize total_size; /* Once registered to an exec context */ - VkBufferUsageFlags usage; - - VkDescriptorSetLayoutBinding *binding; - VkDeviceSize *binding_offset; - int nb_bindings; - - int read_only; -} FFVulkanDescriptorSet; - -typedef struct FFVulkanPipeline { - VkPipelineBindPoint bind_point; - - /* Contexts */ - VkPipelineLayout pipeline_layout; - VkPipeline pipeline; - - /* Push consts */ - VkPushConstantRange *push_consts; - int push_consts_num; - - /* Workgroup */ - int wg_size[3]; - - /* Descriptors */ - FFVulkanDescriptorSet *desc_set; - VkDescriptorBufferBindingInfoEXT *desc_bind; - uint32_t *bound_buffer_indices; - int nb_descriptor_sets; -} FFVulkanPipeline; - typedef struct FFVkExecContext { uint32_t idx; const struct FFVkExecPool *parent; @@ -297,16 +207,6 @@ extern const VkComponentMapping ff_comp_identity_map; */ const char *ff_vk_ret2str(VkResult res); -/** - * Returns 1 if pixfmt is a usable RGB format. - */ -int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt); - -/** - * Returns the format to use for images in shaders. - */ -const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt); - /** * Loads props/mprops/driver_props */ @@ -371,13 +271,6 @@ int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f); void ff_vk_exec_discard_deps(FFVulkanContext *s, FFVkExecContext *e); -/** - * Create an imageview and add it as a dependency to an execution. - */ -int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, - VkImageView views[AV_NUM_DATA_POINTERS], - AVFrame *f); - void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags src_stage, @@ -421,75 +314,6 @@ static inline int ff_vk_unmap_buffer(FFVulkanContext *s, FFVkBuffer *buf, int fl void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf); -/** Initialize a pool and create AVBufferRefs containing FFVkBuffer. - * Threadsafe to use. Buffers are automatically mapped on creation if - * VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT is set in mem_props. Users should - * synchronize access themselvesd. Mainly meant for device-local buffers. */ -int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVBufferPool **buf_pool, - AVBufferRef **buf, VkBufferUsageFlags usage, - void *create_pNext, size_t size, - VkMemoryPropertyFlagBits mem_props); - -/** - * Create a sampler. - */ -int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, - int unnorm_coords, VkFilter filt); - -/** - * Shader management. - */ -int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, - VkShaderStageFlags stage, uint32_t required_subgroup_size); -void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z); -void ff_vk_shader_print(void *ctx, FFVkSPIRVShader *shd, int prio); -int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, - uint8_t *spirv, size_t spirv_size, const char *entrypoint); -void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd); - -/** - * Add/update push constants for execution. - */ -int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, - VkShaderStageFlagBits stage); -void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, - FFVulkanPipeline *pl, - VkShaderStageFlagBits stage, - int offset, size_t size, void *src); - -/** - * Add descriptor to a pipeline. Must be called before pipeline init. - */ -int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkSPIRVShader *shd, - FFVulkanDescriptorSetBinding *desc, int nb, - int read_only, int print_to_shader_only); - -/* Initialize/free a pipeline. */ -int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkSPIRVShader *shd); -void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl); - -/** - * Register a pipeline with an exec pool. - * Pool may be NULL if all descriptor sets are read-only. - */ -int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, - FFVulkanPipeline *pl); - -/* Bind pipeline */ -void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, - FFVulkanPipeline *pl); - -int ff_vk_set_descriptor_buffer(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkExecContext *e, int set, int bind, int offs, - VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt); - -void ff_vk_update_descriptor_img_array(FFVulkanContext *s, FFVulkanPipeline *pl, - FFVkExecContext *e, AVFrame *f, - VkImageView *views, int set, int binding, - VkImageLayout layout, VkSampler sampler); - /** * Frees main context. */