From patchwork Fri Oct 4 09:31:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 52043 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp295878vqg; Fri, 4 Oct 2024 03:09:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVHHFF3GBNSHcGBG/ylqZ8uFYOtk7Z/lzbyDlewmZiKmCe6rN1cvi266+F3EAEZ8Evuca2BA9wwNrnE5S5DpZWV@gmail.com X-Google-Smtp-Source: AGHT+IF5o5BCPvCny0Sp0PP8uQ213OHRni3/VgOs1rynfDfscmhFRYxN19Ly+11mEMcnfSx+6SzT X-Received: by 2002:a05:651c:2226:b0:2f7:6812:d0ae with SMTP id 38308e7fff4ca-2faf3c1cd82mr11512791fa.13.1728036544807; Fri, 04 Oct 2024 03:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728036544; cv=none; d=google.com; s=arc-20240605; b=E9kxYCG+gUw0PdUiMwB7qAqvLsPfWx5mpdmrS0xem8UGUksMIy4+xiRbSe5w169RWX IFuCO4KasTuoeqK+Ex0P/eCoc6/5PCetY6ZMFEAFjiLFtkYG8jJaIvkkp0hkoCa+Ieny cX9zTmoesyVSTPQZrc0bVhUo29FjSCVIPYvkKRgUsuPQ0T6VrYJ1Cz7gHZMZmO7dTHCk u6oNM4P3Y3yyCtDw9IQEpP12dKDt+yIB6wa1P4iN5OrZFdkJSKZVqk+SomuU/YxO+8nU HTRtzCfxmzIoapUMKnhHQomZ2wCT0KW45A86S6B4mNEfH1GfVGKhmgyyHGjoA/IG5gsf 34fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to :delivered-to; bh=xf0wDXJU+09X4oVLHkj/ojvd3IQOZuLtWb3py78stbU=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=PmaNb/3xAxgD9cezgob5DrcrSfrf56UrOHTOfJBs/mBglU2zUQSkvI41M5uLLqdPCH AmZQcPHxyv3IJVL5WQMhhjpjytSw3VZcl0Cluy35aj79JxP37Nr8SwNWTofjr5sDMBOi z+TogImgBvCaRIdSXxORk4ewlT5/67Do+1XQ09mTJrk4HmNNiAhI72jCwS29JrqGRixr x6KvDsCmBK3+z1bLmw1nb23MgqF2Yw5d3QO0AJ/1GF0D76h5fD3AlJZnIbAq/olLaUfW hijBrGXpfsVi1shmL+1/9LMTo1MsFlIfgj2Am+zlLNSUKleCAP38xHxjIuXZ9LBobb/j tYHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2faecc6be84si10163231fa.425.2024.10.04.03.09.04; Fri, 04 Oct 2024 03:09:04 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B023B68DAF5; Fri, 4 Oct 2024 12:31:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFEE468DA0D for ; Fri, 4 Oct 2024 12:31:39 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Fri, 4 Oct 2024 11:31:28 +0200 Message-ID: <20241004093137.139470-1-dev@lynne.ee> X-Mailer: git-send-email 2.45.2.753.g447d99e1c3b MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] lavfi/vulkan: remove redundant header 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: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PoV2E0k5I/qT --- libavfilter/Makefile | 2 +- libavfilter/vulkan.h | 24 ------------------------ libavfilter/vulkan_filter.h | 2 +- libavfilter/vulkan_spirv.h | 1 - 4 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 libavfilter/vulkan.h diff --git a/libavfilter/Makefile b/libavfilter/Makefile index a56c8e8b79..9253e362fc 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -662,7 +662,7 @@ SKIPHEADERS-$(CONFIG_LIBVIDSTAB) += vidstabutils.h SKIPHEADERS-$(CONFIG_QSVVPP) += qsvvpp.h stack_internal.h SKIPHEADERS-$(CONFIG_OPENCL) += opencl.h SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_vpp.h stack_internal.h -SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_filter.h +SKIPHEADERS-$(CONFIG_VULKAN) += vulkan_filter.h SKIPHEADERS-$(CONFIG_LIBSHADERC) += vulkan_spirv.h SKIPHEADERS-$(CONFIG_LIBGLSLANG) += vulkan_spirv.h diff --git a/libavfilter/vulkan.h b/libavfilter/vulkan.h deleted file mode 100644 index 928b2e21c3..0000000000 --- a/libavfilter/vulkan.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVFILTER_VULKAN_H -#define AVFILTER_VULKAN_H - -#include "libavutil/vulkan.h" - -#endif /* AVFILTER_VULKAN_H */ diff --git a/libavfilter/vulkan_filter.h b/libavfilter/vulkan_filter.h index 9f1297e0d2..6ed9c4de39 100644 --- a/libavfilter/vulkan_filter.h +++ b/libavfilter/vulkan_filter.h @@ -23,7 +23,7 @@ #include "avfilter.h" -#include "vulkan.h" +#include "libavutil/vulkan.h" /** * General lavfi IO functions diff --git a/libavfilter/vulkan_spirv.h b/libavfilter/vulkan_spirv.h index d008804ab2..b0349b6b54 100644 --- a/libavfilter/vulkan_spirv.h +++ b/libavfilter/vulkan_spirv.h @@ -21,7 +21,6 @@ #include "libavutil/vulkan.h" -#include "vulkan.h" #include "config.h" typedef struct FFVkSPIRVCompiler { From patchwork Fri Oct 4 09:31:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 52034 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp278559vqg; Fri, 4 Oct 2024 02:31:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVwyifBhcSj5Mgn+sQliK4YBuDL73huNNp9GmOZrOwgOeNbiHFq3DXZvkvQ+G2XAxyU2e0yXTKF+vhYecgt1Oma@gmail.com X-Google-Smtp-Source: AGHT+IH18MFNyNNidaGR9f+lgiHFK6XhzylJY5FB4lJtrrcjzuQsG23Bth8qFAmE6ig8aFvId0q0 X-Received: by 2002:a05:6512:b0b:b0:536:741a:6bb2 with SMTP id 2adb3069b0e04-539ab8630f4mr331682e87.4.1728034311388; Fri, 04 Oct 2024 02:31:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728034311; cv=none; d=google.com; s=arc-20240605; b=IpIokg+SBTdoGo7rSQhNYb7BGdghUpONQblGJc8KNwDsIvPWm00afYqz3Xh9Ku9bw+ YxLprmEyvIR+w/ahCNWZs1z9HJ6MtJxlvms5y85kixdgZqdnnw08Dfbc4aHqmJwsf8a7 kNUxuOZGVCsKxi9hg0wDIvlQmRXzs/62mRbY9U6LIguH/pzYQivb/yR9k8tFMYDfxmGK Bbb4PIGJZv2JOfXhbIra1fvtQJFiFN6khkbeHNVgaswi8pcwyj3rIpM8TZOGnpFZkzyR pU2pg7SsfpcY7zgivHhgPzfNAGYbM6Sx8AHU3n/Gbfmk5PvhfwnY5Sr5lguSlF70oO4t pb7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:delivered-to; bh=hoHW0iNq9cIYGTITMojk/sxqdBtXUkuuRI2y+913Hjc=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=hMUvqsABZiiqtycB/QvkTlZIpREshbU8iTnzqFxKfku21chAG7pD2oSyeugBpaKrAE iLXIsTulZ+0B2rbgL68iOa3lYe3ImU9rXnbk6RWqhqjX7KdmTW0mkv/o9vYERD3UqByj NtjrAchvVlIxYUMDExuDgYl+ydBTOKsU38XJKjJuyYvT8sBeZAK350tk5uAnD1SEKQhS G+70jtu6diHT1QxY2oioloJRG5OVcxo5PslhnAk8J6foT1/PqigMz3HDqpsjST51AhbS jdtze0hLxifaph071p3xpdsqLreFZmXbjmgNPjubIa+X0jXel4UDueHGsIb5reFpb4oe J0Cg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-539a8286e13si955517e87.256.2024.10.04.02.31.50; Fri, 04 Oct 2024 02:31:51 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9E41F68DA3B; Fri, 4 Oct 2024 12:31:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DCDF768CD3E for ; Fri, 4 Oct 2024 12:31:39 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Fri, 4 Oct 2024 11:31:29 +0200 Message-ID: <20241004093137.139470-2-dev@lynne.ee> X-Mailer: git-send-email 2.45.2.753.g447d99e1c3b In-Reply-To: <20241004093137.139470-1-dev@lynne.ee> References: <20241004093137.139470-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] lavc/vulkan: remove redundant header 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: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 8mBse+fmI0t8 --- libavcodec/Makefile | 2 +- libavcodec/vulkan.h | 24 ------------------------ libavcodec/vulkan_video.h | 2 +- 3 files changed, 2 insertions(+), 26 deletions(-) delete mode 100644 libavcodec/vulkan.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 5aed2fff28..a253a9b160 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1290,7 +1290,7 @@ SKIPHEADERS-$(CONFIG_QSVENC) += qsvenc.h SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_decode.h vaapi_hevc.h vaapi_encode.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h -SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_encode.h vulkan_decode.h +SKIPHEADERS-$(CONFIG_VULKAN) += vulkan_video.h vulkan_encode.h vulkan_decode.h SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m.h SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h diff --git a/libavcodec/vulkan.h b/libavcodec/vulkan.h deleted file mode 100644 index b15efd4add..0000000000 --- a/libavcodec/vulkan.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_VULKAN_H -#define AVCODEC_VULKAN_H - -#include "libavutil/vulkan.h" - -#endif /* AVCODEC_VULKAN_H */ diff --git a/libavcodec/vulkan_video.h b/libavcodec/vulkan_video.h index c205f7b88f..1ec5f419ed 100644 --- a/libavcodec/vulkan_video.h +++ b/libavcodec/vulkan_video.h @@ -20,7 +20,7 @@ #define AVCODEC_VULKAN_VIDEO_H #include "avcodec.h" -#include "vulkan.h" +#include "libavutil/vulkan.h" #include From patchwork Fri Oct 4 09:31:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 52042 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp285620vqg; Fri, 4 Oct 2024 02:49:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2zF9eREZO1daS3R6CAvYY8d9JhushLkZ80HbYwKq52lP1wbqYlQmrI/O8NIT5aZKfbGA1xl9w4sf/l1G/A2R+@gmail.com X-Google-Smtp-Source: AGHT+IEN1jiNhNIs4rFu3Jt+m2Nbw+X6jryWbl1HGDRm3wUmoK7Tt9DHHz1PLfcG1UNjsS9Abxow X-Received: by 2002:a17:907:6e89:b0:a90:419f:d8c3 with SMTP id a640c23a62f3a-a991c0284cemr231569666b.49.1728035344935; Fri, 04 Oct 2024 02:49:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728035344; cv=none; d=google.com; s=arc-20240605; b=iefWV7n4NClfSFE5nNncv/2ag3UglQD/XcQsOzmbPMXdf9wt0F6StY8r9TBpzj3Y1k kJYKIKt/ga+e6q+arh1IToBVL9JCkIFqLnXVKpAmAuUCB4InpURiCXlp9uTc8rV/uyL+ keUKPYZ9x4IidV1Uy487XCrzlpoSJyNgBVUY6JZOGXEfoTwkOfhpmZaXhLdBOhK9BbdG 3X4DFnaPJUNOd8MOy+peU78RTs5IQ/QaThoaRvlNHHS18zycRyLDi4fABtBZpwtVm6sQ FzL+GQJsk0NizX51XWy3x8bjud+hF4wHS2FoBliG0lyAXy5LR1YvjSrK65huhjWLsyEs 9z4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:delivered-to; bh=RrLHDIXcSXIsVKDLRZdbJ4UTLXx7Vli22HwC3jeiV+w=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=hAW3wSVrC6ng8sEm86+ZGV4Po/RUhP3tHGbmwl/Eu215mFCxFP5bhzaVshvZo8DUm+ Fph0W/pGFTqsIT6tiaDG2qw0RS6MwANiXMwjgouq8zmtywDcCJbOx5oIxpdeLghV7N0z 1h33DDJpKHSwy6ORNZyBb3I7QD5L0CunuIlT4sgDgdtZtCpIlmR0qT8CK41TJaeOqOoR AHJsbphTxUgH1rnZxEHmR+F+7wX0PbWhJm7IFf30AOzJAlQUiWp3F0wA1RuP8xag/uMS xNGSrTOey3xYSlMtp8Xsl4d2lAJ24iRFR3d9PYcpjnfJgdrvFtBn/aJa0IviRx84j0qC /fLw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a99110e2a85si191552666b.704.2024.10.04.02.49.04; Fri, 04 Oct 2024 02:49:04 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D038D68DB18; Fri, 4 Oct 2024 12:31:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 01B1468DA3B for ; Fri, 4 Oct 2024 12:31:39 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Fri, 4 Oct 2024 11:31:30 +0200 Message-ID: <20241004093137.139470-3-dev@lynne.ee> X-Mailer: git-send-email 2.45.2.753.g447d99e1c3b In-Reply-To: <20241004093137.139470-1-dev@lynne.ee> References: <20241004093137.139470-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] vulkan: move SPIR-V compilation code to libavutil 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: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: MOiTba8gjN8f The code is not currently used by libavutil, its just where our common Vulkan code is. Since SPIR-V compilation will be needed by lavc, move it, rather than having lavc including lavfi. --- libavfilter/Makefile | 2 - libavfilter/vf_avgblur_vulkan.c | 2 +- libavfilter/vf_blend_vulkan.c | 2 +- libavfilter/vf_bwdif_vulkan.c | 2 +- libavfilter/vf_chromaber_vulkan.c | 2 +- libavfilter/vf_flip_vulkan.c | 2 +- libavfilter/vf_gblur_vulkan.c | 2 +- libavfilter/vf_nlmeans_vulkan.c | 2 +- libavfilter/vf_overlay_vulkan.c | 2 +- libavfilter/vf_scale_vulkan.c | 2 +- libavfilter/vf_transpose_vulkan.c | 2 +- libavfilter/vf_xfade_vulkan.c | 2 +- libavfilter/vsrc_testsrc_vulkan.c | 2 +- libavfilter/vulkan_glslang.c | 291 +------------------- libavfilter/vulkan_shaderc.c | 127 +-------- libavutil/vulkan_glslang.c | 308 ++++++++++++++++++++++ libavutil/vulkan_shaderc.c | 144 ++++++++++ {libavfilter => libavutil}/vulkan_spirv.h | 2 +- 18 files changed, 467 insertions(+), 431 deletions(-) create mode 100644 libavutil/vulkan_glslang.c create mode 100644 libavutil/vulkan_shaderc.c rename {libavfilter => libavutil}/vulkan_spirv.h (98%) diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 9253e362fc..7d8391f132 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -663,8 +663,6 @@ SKIPHEADERS-$(CONFIG_QSVVPP) += qsvvpp.h stack_internal.h SKIPHEADERS-$(CONFIG_OPENCL) += opencl.h SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_vpp.h stack_internal.h SKIPHEADERS-$(CONFIG_VULKAN) += vulkan_filter.h -SKIPHEADERS-$(CONFIG_LIBSHADERC) += vulkan_spirv.h -SKIPHEADERS-$(CONFIG_LIBGLSLANG) += vulkan_spirv.h TOOLS = graph2dot TESTPROGS = drawutils filtfmts formats integral diff --git a/libavfilter/vf_avgblur_vulkan.c b/libavfilter/vf_avgblur_vulkan.c index 9214ebcc0f..36f00a7a74 100644 --- a/libavfilter/vf_avgblur_vulkan.c +++ b/libavfilter/vf_avgblur_vulkan.c @@ -19,9 +19,9 @@ */ #include "libavutil/random_seed.h" +#include "libavutil/vulkan_spirv.h" #include "libavutil/opt.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "video.h" diff --git a/libavfilter/vf_blend_vulkan.c b/libavfilter/vf_blend_vulkan.c index 406b087503..a2834353e7 100644 --- a/libavfilter/vf_blend_vulkan.c +++ b/libavfilter/vf_blend_vulkan.c @@ -22,9 +22,9 @@ */ #include "libavutil/random_seed.h" +#include "libavutil/vulkan_spirv.h" #include "libavutil/opt.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "framesync.h" diff --git a/libavfilter/vf_bwdif_vulkan.c b/libavfilter/vf_bwdif_vulkan.c index 2ea9512fcb..0d6f1dc39e 100644 --- a/libavfilter/vf_bwdif_vulkan.c +++ b/libavfilter/vf_bwdif_vulkan.c @@ -22,8 +22,8 @@ #include "libavutil/random_seed.h" #include "libavutil/opt.h" +#include "libavutil/vulkan_spirv.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "yadif.h" #include "filters.h" diff --git a/libavfilter/vf_chromaber_vulkan.c b/libavfilter/vf_chromaber_vulkan.c index 8a62e514fa..e677261259 100644 --- a/libavfilter/vf_chromaber_vulkan.c +++ b/libavfilter/vf_chromaber_vulkan.c @@ -20,8 +20,8 @@ #include "libavutil/random_seed.h" #include "libavutil/opt.h" +#include "libavutil/vulkan_spirv.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "video.h" diff --git a/libavfilter/vf_flip_vulkan.c b/libavfilter/vf_flip_vulkan.c index 3e0a7ebc85..396f85da9b 100644 --- a/libavfilter/vf_flip_vulkan.c +++ b/libavfilter/vf_flip_vulkan.c @@ -21,8 +21,8 @@ #include "libavutil/random_seed.h" #include "libavutil/opt.h" +#include "libavutil/vulkan_spirv.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "video.h" diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c index 9632a084e4..110f19e555 100644 --- a/libavfilter/vf_gblur_vulkan.c +++ b/libavfilter/vf_gblur_vulkan.c @@ -22,8 +22,8 @@ #include "libavutil/mem.h" #include "libavutil/random_seed.h" #include "libavutil/opt.h" +#include "libavutil/vulkan_spirv.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "video.h" diff --git a/libavfilter/vf_nlmeans_vulkan.c b/libavfilter/vf_nlmeans_vulkan.c index 39460dc194..1c729a2e7a 100644 --- a/libavfilter/vf_nlmeans_vulkan.c +++ b/libavfilter/vf_nlmeans_vulkan.c @@ -20,9 +20,9 @@ #include "libavutil/mem.h" #include "libavutil/random_seed.h" +#include "libavutil/vulkan_spirv.h" #include "libavutil/opt.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "video.h" diff --git a/libavfilter/vf_overlay_vulkan.c b/libavfilter/vf_overlay_vulkan.c index 3af2482772..4c77dcc8fe 100644 --- a/libavfilter/vf_overlay_vulkan.c +++ b/libavfilter/vf_overlay_vulkan.c @@ -20,8 +20,8 @@ #include "libavutil/random_seed.h" #include "libavutil/opt.h" +#include "libavutil/vulkan_spirv.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "framesync.h" diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c index 95cc25f8d7..d8f2b5303d 100644 --- a/libavfilter/vf_scale_vulkan.c +++ b/libavfilter/vf_scale_vulkan.c @@ -20,8 +20,8 @@ #include "libavutil/random_seed.h" #include "libavutil/opt.h" +#include "libavutil/vulkan_spirv.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "scale_eval.h" #include "filters.h" #include "colorspace.h" diff --git a/libavfilter/vf_transpose_vulkan.c b/libavfilter/vf_transpose_vulkan.c index 8ab782cc79..48d60be6cc 100644 --- a/libavfilter/vf_transpose_vulkan.c +++ b/libavfilter/vf_transpose_vulkan.c @@ -21,8 +21,8 @@ #include "libavutil/random_seed.h" #include "libavutil/opt.h" +#include "libavutil/vulkan_spirv.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "transpose.h" diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c index 0b6f1350fb..8f7b8a0913 100644 --- a/libavfilter/vf_xfade_vulkan.c +++ b/libavfilter/vf_xfade_vulkan.c @@ -19,8 +19,8 @@ #include "libavutil/avassert.h" #include "libavutil/random_seed.h" #include "libavutil/opt.h" +#include "libavutil/vulkan_spirv.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "video.h" diff --git a/libavfilter/vsrc_testsrc_vulkan.c b/libavfilter/vsrc_testsrc_vulkan.c index 0641beed5b..a7d573b529 100644 --- a/libavfilter/vsrc_testsrc_vulkan.c +++ b/libavfilter/vsrc_testsrc_vulkan.c @@ -21,8 +21,8 @@ #include "libavutil/random_seed.h" #include "libavutil/csp.h" #include "libavutil/opt.h" +#include "libavutil/vulkan_spirv.h" #include "vulkan_filter.h" -#include "vulkan_spirv.h" #include "filters.h" #include "colorspace.h" #include "video.h" diff --git a/libavfilter/vulkan_glslang.c b/libavfilter/vulkan_glslang.c index 9e1b8f4d8d..9aa41567a3 100644 --- a/libavfilter/vulkan_glslang.c +++ b/libavfilter/vulkan_glslang.c @@ -16,293 +16,4 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - -#include -#include - -#include "vulkan_spirv.h" -#include "libavutil/mem.h" -#include "libavutil/avassert.h" - -static pthread_mutex_t glslc_mutex = PTHREAD_MUTEX_INITIALIZER; -static int glslc_refcount = 0; - -static const glslang_resource_t glslc_resource_limits = { - .max_lights = 32, - .max_clip_planes = 6, - .max_texture_units = 32, - .max_texture_coords = 32, - .max_vertex_attribs = 64, - .max_vertex_uniform_components = 4096, - .max_varying_floats = 64, - .max_vertex_texture_image_units = 32, - .max_combined_texture_image_units = 80, - .max_texture_image_units = 32, - .max_fragment_uniform_components = 4096, - .max_draw_buffers = 32, - .max_vertex_uniform_vectors = 128, - .max_varying_vectors = 8, - .max_fragment_uniform_vectors = 16, - .max_vertex_output_vectors = 16, - .max_fragment_input_vectors = 15, - .min_program_texel_offset = -8, - .max_program_texel_offset = 7, - .max_clip_distances = 8, - .max_compute_work_group_count_x = 65535, - .max_compute_work_group_count_y = 65535, - .max_compute_work_group_count_z = 65535, - .max_compute_work_group_size_x = 1024, - .max_compute_work_group_size_y = 1024, - .max_compute_work_group_size_z = 64, - .max_compute_uniform_components = 1024, - .max_compute_texture_image_units = 16, - .max_compute_image_uniforms = 8, - .max_compute_atomic_counters = 8, - .max_compute_atomic_counter_buffers = 1, - .max_varying_components = 60, - .max_vertex_output_components = 64, - .max_geometry_input_components = 64, - .max_geometry_output_components = 128, - .max_fragment_input_components = 128, - .max_image_units = 8, - .max_combined_image_units_and_fragment_outputs = 8, - .max_combined_shader_output_resources = 8, - .max_image_samples = 0, - .max_vertex_image_uniforms = 0, - .max_tess_control_image_uniforms = 0, - .max_tess_evaluation_image_uniforms = 0, - .max_geometry_image_uniforms = 0, - .max_fragment_image_uniforms = 8, - .max_combined_image_uniforms = 8, - .max_geometry_texture_image_units = 16, - .max_geometry_output_vertices = 256, - .max_geometry_total_output_components = 1024, - .max_geometry_uniform_components = 1024, - .max_geometry_varying_components = 64, - .max_tess_control_input_components = 128, - .max_tess_control_output_components = 128, - .max_tess_control_texture_image_units = 16, - .max_tess_control_uniform_components = 1024, - .max_tess_control_total_output_components = 4096, - .max_tess_evaluation_input_components = 128, - .max_tess_evaluation_output_components = 128, - .max_tess_evaluation_texture_image_units = 16, - .max_tess_evaluation_uniform_components = 1024, - .max_tess_patch_components = 120, - .max_patch_vertices = 32, - .max_tess_gen_level = 64, - .max_viewports = 16, - .max_vertex_atomic_counters = 0, - .max_tess_control_atomic_counters = 0, - .max_tess_evaluation_atomic_counters = 0, - .max_geometry_atomic_counters = 0, - .max_fragment_atomic_counters = 8, - .max_combined_atomic_counters = 8, - .max_atomic_counter_bindings = 1, - .max_vertex_atomic_counter_buffers = 0, - .max_tess_control_atomic_counter_buffers = 0, - .max_tess_evaluation_atomic_counter_buffers = 0, - .max_geometry_atomic_counter_buffers = 0, - .max_fragment_atomic_counter_buffers = 1, - .max_combined_atomic_counter_buffers = 1, - .max_atomic_counter_buffer_size = 16384, - .max_transform_feedback_buffers = 4, - .max_transform_feedback_interleaved_components = 64, - .max_cull_distances = 8, - .max_combined_clip_and_cull_distances = 8, - .max_samples = 4, - .max_mesh_output_vertices_nv = 256, - .max_mesh_output_primitives_nv = 512, - .max_mesh_work_group_size_x_nv = 32, - .max_mesh_work_group_size_y_nv = 1, - .max_mesh_work_group_size_z_nv = 1, - .max_task_work_group_size_x_nv = 32, - .max_task_work_group_size_y_nv = 1, - .max_task_work_group_size_z_nv = 1, - .max_mesh_view_count_nv = 4, - .maxDualSourceDrawBuffersEXT = 1, - - .limits = { - .non_inductive_for_loops = 1, - .while_loops = 1, - .do_while_loops = 1, - .general_uniform_indexing = 1, - .general_attribute_matrix_vector_indexing = 1, - .general_varying_indexing = 1, - .general_sampler_indexing = 1, - .general_variable_indexing = 1, - .general_constant_matrix_vector_indexing = 1, - } -}; - -static int glslc_shader_compile(FFVulkanContext *s, FFVkSPIRVCompiler *ctx, - FFVulkanShader *shd, uint8_t **data, - size_t *size, const char *entrypoint, - void **opaque) -{ - const char *messages; - glslang_shader_t *glslc_shader; - glslang_program_t *glslc_program; - - static const glslang_stage_t glslc_stage[] = { - [VK_SHADER_STAGE_VERTEX_BIT] = GLSLANG_STAGE_VERTEX, - [VK_SHADER_STAGE_FRAGMENT_BIT] = GLSLANG_STAGE_FRAGMENT, - [VK_SHADER_STAGE_COMPUTE_BIT] = GLSLANG_STAGE_COMPUTE, -#if ((GLSLANG_VERSION_MAJOR) > 12) - [VK_SHADER_STAGE_TASK_BIT_EXT] = GLSLANG_STAGE_TASK, - [VK_SHADER_STAGE_MESH_BIT_EXT] = GLSLANG_STAGE_MESH, - [VK_SHADER_STAGE_RAYGEN_BIT_KHR] = GLSLANG_STAGE_RAYGEN, - [VK_SHADER_STAGE_INTERSECTION_BIT_KHR] = GLSLANG_STAGE_INTERSECT, - [VK_SHADER_STAGE_ANY_HIT_BIT_KHR] = GLSLANG_STAGE_ANYHIT, - [VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR] = GLSLANG_STAGE_CLOSESTHIT, - [VK_SHADER_STAGE_MISS_BIT_KHR] = GLSLANG_STAGE_MISS, - [VK_SHADER_STAGE_CALLABLE_BIT_KHR] = GLSLANG_STAGE_CALLABLE, -#endif - }; - - const glslang_input_t glslc_input = { - .language = GLSLANG_SOURCE_GLSL, - .stage = glslc_stage[shd->stage], - .client = GLSLANG_CLIENT_VULKAN, -#if ((GLSLANG_VERSION_MAJOR) >= 12) - .client_version = GLSLANG_TARGET_VULKAN_1_3, - .target_language_version = GLSLANG_TARGET_SPV_1_6, -#else - .client_version = GLSLANG_TARGET_VULKAN_1_2, - .target_language_version = GLSLANG_TARGET_SPV_1_5, -#endif - .target_language = GLSLANG_TARGET_SPV, - .code = shd->src.str, - .default_version = 460, - .default_profile = GLSLANG_NO_PROFILE, - .force_default_version_and_profile = false, - .forward_compatible = false, - .messages = GLSLANG_MSG_DEFAULT_BIT, - .resource = &glslc_resource_limits, - }; - -#if ((GLSLANG_VERSION_MAJOR) >= 12) - glslang_spv_options_t glslc_opts = { - .generate_debug_info = !!(s->extensions & (FF_VK_EXT_DEBUG_UTILS | FF_VK_EXT_RELAXED_EXTENDED_INSTR)), - .emit_nonsemantic_shader_debug_info = !!(s->extensions & FF_VK_EXT_RELAXED_EXTENDED_INSTR), - .emit_nonsemantic_shader_debug_source = !!(s->extensions & FF_VK_EXT_RELAXED_EXTENDED_INSTR), - .disable_optimizer = !!(s->extensions & FF_VK_EXT_DEBUG_UTILS), - .strip_debug_info = !(s->extensions & (FF_VK_EXT_DEBUG_UTILS | FF_VK_EXT_RELAXED_EXTENDED_INSTR)), - .optimize_size = 0, - .disassemble = 0, - .validate = 1, - .compile_only = 0, - }; -#endif - - av_assert0(glslc_refcount); - - *opaque = NULL; - - if (!(glslc_shader = glslang_shader_create(&glslc_input))) - return AVERROR(ENOMEM); - - if (!glslang_shader_preprocess(glslc_shader, &glslc_input)) { - ff_vk_shader_print(s, shd, AV_LOG_WARNING); - av_log(s, AV_LOG_ERROR, "Unable to preprocess shader: %s (%s)!\n", - glslang_shader_get_info_log(glslc_shader), - glslang_shader_get_info_debug_log(glslc_shader)); - glslang_shader_delete(glslc_shader); - return AVERROR(EINVAL); - } - - if (!glslang_shader_parse(glslc_shader, &glslc_input)) { - ff_vk_shader_print(s, shd, AV_LOG_WARNING); - av_log(s, AV_LOG_ERROR, "Unable to parse shader: %s (%s)!\n", - glslang_shader_get_info_log(glslc_shader), - glslang_shader_get_info_debug_log(glslc_shader)); - glslang_shader_delete(glslc_shader); - return AVERROR(EINVAL); - } - - if (!(glslc_program = glslang_program_create())) { - glslang_shader_delete(glslc_shader); - return AVERROR(EINVAL); - } - - glslang_program_add_shader(glslc_program, glslc_shader); - - if (!glslang_program_link(glslc_program, GLSLANG_MSG_SPV_RULES_BIT | - GLSLANG_MSG_VULKAN_RULES_BIT)) { - ff_vk_shader_print(s, shd, AV_LOG_WARNING); - av_log(s, AV_LOG_ERROR, "Unable to link shader: %s (%s)!\n", - glslang_program_get_info_log(glslc_program), - glslang_program_get_info_debug_log(glslc_program)); - glslang_program_delete(glslc_program); - glslang_shader_delete(glslc_shader); - return AVERROR(EINVAL); - } - -#if ((GLSLANG_VERSION_MAJOR) >= 12) - glslang_program_SPIRV_generate_with_options(glslc_program, glslc_input.stage, &glslc_opts); -#else - glslang_program_SPIRV_generate(glslc_program, glslc_input.stage); -#endif - - messages = glslang_program_SPIRV_get_messages(glslc_program); - if (messages) { - ff_vk_shader_print(s, shd, AV_LOG_WARNING); - av_log(s, AV_LOG_WARNING, "%s\n", messages); - } else { - ff_vk_shader_print(s, shd, AV_LOG_VERBOSE); - } - - glslang_shader_delete(glslc_shader); - - *size = glslang_program_SPIRV_get_size(glslc_program) * sizeof(unsigned int); - *data = (void *)glslang_program_SPIRV_get_ptr(glslc_program); - *opaque = glslc_program; - - return 0; -} - -static void glslc_shader_free(FFVkSPIRVCompiler *ctx, void **opaque) -{ - if (!opaque || !*opaque) - return; - - av_assert0(glslc_refcount); - glslang_program_delete(*opaque); - *opaque = NULL; -} - -static void glslc_uninit(FFVkSPIRVCompiler **ctx) -{ - if (!ctx || !*ctx) - return; - - pthread_mutex_lock(&glslc_mutex); - if (glslc_refcount && (--glslc_refcount == 0)) - glslang_finalize_process(); - pthread_mutex_unlock(&glslc_mutex); - - av_freep(ctx); -} - -FFVkSPIRVCompiler *ff_vk_glslang_init(void) -{ - FFVkSPIRVCompiler *ret = av_mallocz(sizeof(*ret)); - if (!ret) - return NULL; - - ret->compile_shader = glslc_shader_compile; - ret->free_shader = glslc_shader_free; - ret->uninit = glslc_uninit; - - pthread_mutex_lock(&glslc_mutex); - if (!glslc_refcount++) { - if (!glslang_initialize_process()) { - av_freep(&ret); - glslc_refcount--; - } - } - pthread_mutex_unlock(&glslc_mutex); - - return ret; -} +#include "libavutil/vulkan_glslang.c" diff --git a/libavfilter/vulkan_shaderc.c b/libavfilter/vulkan_shaderc.c index 6e7475c49f..9f60bf4dfd 100644 --- a/libavfilter/vulkan_shaderc.c +++ b/libavfilter/vulkan_shaderc.c @@ -16,129 +16,4 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - -#include "libavutil/mem.h" -#include "vulkan_spirv.h" - -static int shdc_shader_compile(FFVulkanContext *s, FFVkSPIRVCompiler *ctx, - FFVulkanShader *shd, uint8_t **data, - size_t *size, const char *entrypoint, - void **opaque) -{ - int loglevel, err, warn, ret; - const char *status, *message; - shaderc_compilation_result_t res; - static const char *shdc_result[] = { - [shaderc_compilation_status_success] = "success", - [shaderc_compilation_status_invalid_stage] = "invalid stage", - [shaderc_compilation_status_compilation_error] = "error", - [shaderc_compilation_status_internal_error] = "internal error", - [shaderc_compilation_status_null_result_object] = "no result", - [shaderc_compilation_status_invalid_assembly] = "invalid assembly", - }; - static const shaderc_shader_kind shdc_kind[] = { - [VK_SHADER_STAGE_VERTEX_BIT] = shaderc_glsl_vertex_shader, - [VK_SHADER_STAGE_FRAGMENT_BIT] = shaderc_glsl_fragment_shader, - [VK_SHADER_STAGE_COMPUTE_BIT] = shaderc_glsl_compute_shader, - [VK_SHADER_STAGE_MESH_BIT_EXT] = shaderc_mesh_shader, - [VK_SHADER_STAGE_TASK_BIT_EXT] = shaderc_task_shader, - [VK_SHADER_STAGE_RAYGEN_BIT_KHR] = shaderc_raygen_shader, - [VK_SHADER_STAGE_ANY_HIT_BIT_KHR] = shaderc_anyhit_shader, - [VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR] = shaderc_closesthit_shader, - [VK_SHADER_STAGE_MISS_BIT_KHR] = shaderc_miss_shader, - [VK_SHADER_STAGE_INTERSECTION_BIT_KHR] = shaderc_intersection_shader, - [VK_SHADER_STAGE_CALLABLE_BIT_KHR] = shaderc_callable_shader, - }; - - shaderc_compile_options_t opts = shaderc_compile_options_initialize(); - *opaque = NULL; - if (!opts) - return AVERROR(ENOMEM); - - shaderc_compile_options_set_target_env(opts, shaderc_target_env_vulkan, - shaderc_env_version_vulkan_1_3); - shaderc_compile_options_set_target_spirv(opts, shaderc_spirv_version_1_6); - - /* If either extension is set, turn on debug info */ - if (s->extensions & (FF_VK_EXT_DEBUG_UTILS | FF_VK_EXT_RELAXED_EXTENDED_INSTR)) - shaderc_compile_options_set_generate_debug_info(opts); - - if (s->extensions & FF_VK_EXT_DEBUG_UTILS) - shaderc_compile_options_set_optimization_level(opts, - shaderc_optimization_level_zero); - else - shaderc_compile_options_set_optimization_level(opts, - shaderc_optimization_level_performance); - - res = shaderc_compile_into_spv((shaderc_compiler_t)ctx->priv, - shd->src.str, strlen(shd->src.str), - shdc_kind[shd->stage], - shd->name, entrypoint, opts); - shaderc_compile_options_release(opts); - - ret = shaderc_result_get_compilation_status(res); - err = shaderc_result_get_num_errors(res); - warn = shaderc_result_get_num_warnings(res); - message = shaderc_result_get_error_message(res); - - if (ret != shaderc_compilation_status_success && !err) - err = 1; - - loglevel = err ? AV_LOG_ERROR : warn ? AV_LOG_WARNING : AV_LOG_VERBOSE; - - ff_vk_shader_print(s, shd, loglevel); - if (message && (err || warn)) - av_log(s, loglevel, "%s\n", message); - status = ret < FF_ARRAY_ELEMS(shdc_result) ? shdc_result[ret] : "unknown"; - av_log(s, loglevel, "shaderc compile status '%s' (%d errors, %d warnings)\n", - status, err, warn); - - if (err > 0) - return AVERROR(EINVAL); - - *data = (uint8_t *)shaderc_result_get_bytes(res); - *size = shaderc_result_get_length(res); - *opaque = res; - - return 0; -} - -static void shdc_shader_free(FFVkSPIRVCompiler *ctx, void **opaque) -{ - if (!opaque || !*opaque) - return; - - shaderc_result_release((shaderc_compilation_result_t)*opaque); - *opaque = NULL; -} - -static void shdc_uninit(FFVkSPIRVCompiler **ctx) -{ - FFVkSPIRVCompiler *s; - - if (!ctx || !*ctx) - return; - - s = *ctx; - - shaderc_compiler_release((shaderc_compiler_t)s->priv); - av_freep(ctx); -} - -FFVkSPIRVCompiler *ff_vk_shaderc_init(void) -{ - FFVkSPIRVCompiler *ret = av_mallocz(sizeof(*ret)); - if (!ret) - return NULL; - - ret->compile_shader = shdc_shader_compile; - ret->free_shader = shdc_shader_free; - ret->uninit = shdc_uninit; - - ret->priv = (void *)shaderc_compiler_initialize(); - if (!ret->priv) - av_freep(&ret); - - return ret; -} +#include "libavutil/vulkan_shaderc.c" diff --git a/libavutil/vulkan_glslang.c b/libavutil/vulkan_glslang.c new file mode 100644 index 0000000000..9e1b8f4d8d --- /dev/null +++ b/libavutil/vulkan_glslang.c @@ -0,0 +1,308 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include +#include + +#include "vulkan_spirv.h" +#include "libavutil/mem.h" +#include "libavutil/avassert.h" + +static pthread_mutex_t glslc_mutex = PTHREAD_MUTEX_INITIALIZER; +static int glslc_refcount = 0; + +static const glslang_resource_t glslc_resource_limits = { + .max_lights = 32, + .max_clip_planes = 6, + .max_texture_units = 32, + .max_texture_coords = 32, + .max_vertex_attribs = 64, + .max_vertex_uniform_components = 4096, + .max_varying_floats = 64, + .max_vertex_texture_image_units = 32, + .max_combined_texture_image_units = 80, + .max_texture_image_units = 32, + .max_fragment_uniform_components = 4096, + .max_draw_buffers = 32, + .max_vertex_uniform_vectors = 128, + .max_varying_vectors = 8, + .max_fragment_uniform_vectors = 16, + .max_vertex_output_vectors = 16, + .max_fragment_input_vectors = 15, + .min_program_texel_offset = -8, + .max_program_texel_offset = 7, + .max_clip_distances = 8, + .max_compute_work_group_count_x = 65535, + .max_compute_work_group_count_y = 65535, + .max_compute_work_group_count_z = 65535, + .max_compute_work_group_size_x = 1024, + .max_compute_work_group_size_y = 1024, + .max_compute_work_group_size_z = 64, + .max_compute_uniform_components = 1024, + .max_compute_texture_image_units = 16, + .max_compute_image_uniforms = 8, + .max_compute_atomic_counters = 8, + .max_compute_atomic_counter_buffers = 1, + .max_varying_components = 60, + .max_vertex_output_components = 64, + .max_geometry_input_components = 64, + .max_geometry_output_components = 128, + .max_fragment_input_components = 128, + .max_image_units = 8, + .max_combined_image_units_and_fragment_outputs = 8, + .max_combined_shader_output_resources = 8, + .max_image_samples = 0, + .max_vertex_image_uniforms = 0, + .max_tess_control_image_uniforms = 0, + .max_tess_evaluation_image_uniforms = 0, + .max_geometry_image_uniforms = 0, + .max_fragment_image_uniforms = 8, + .max_combined_image_uniforms = 8, + .max_geometry_texture_image_units = 16, + .max_geometry_output_vertices = 256, + .max_geometry_total_output_components = 1024, + .max_geometry_uniform_components = 1024, + .max_geometry_varying_components = 64, + .max_tess_control_input_components = 128, + .max_tess_control_output_components = 128, + .max_tess_control_texture_image_units = 16, + .max_tess_control_uniform_components = 1024, + .max_tess_control_total_output_components = 4096, + .max_tess_evaluation_input_components = 128, + .max_tess_evaluation_output_components = 128, + .max_tess_evaluation_texture_image_units = 16, + .max_tess_evaluation_uniform_components = 1024, + .max_tess_patch_components = 120, + .max_patch_vertices = 32, + .max_tess_gen_level = 64, + .max_viewports = 16, + .max_vertex_atomic_counters = 0, + .max_tess_control_atomic_counters = 0, + .max_tess_evaluation_atomic_counters = 0, + .max_geometry_atomic_counters = 0, + .max_fragment_atomic_counters = 8, + .max_combined_atomic_counters = 8, + .max_atomic_counter_bindings = 1, + .max_vertex_atomic_counter_buffers = 0, + .max_tess_control_atomic_counter_buffers = 0, + .max_tess_evaluation_atomic_counter_buffers = 0, + .max_geometry_atomic_counter_buffers = 0, + .max_fragment_atomic_counter_buffers = 1, + .max_combined_atomic_counter_buffers = 1, + .max_atomic_counter_buffer_size = 16384, + .max_transform_feedback_buffers = 4, + .max_transform_feedback_interleaved_components = 64, + .max_cull_distances = 8, + .max_combined_clip_and_cull_distances = 8, + .max_samples = 4, + .max_mesh_output_vertices_nv = 256, + .max_mesh_output_primitives_nv = 512, + .max_mesh_work_group_size_x_nv = 32, + .max_mesh_work_group_size_y_nv = 1, + .max_mesh_work_group_size_z_nv = 1, + .max_task_work_group_size_x_nv = 32, + .max_task_work_group_size_y_nv = 1, + .max_task_work_group_size_z_nv = 1, + .max_mesh_view_count_nv = 4, + .maxDualSourceDrawBuffersEXT = 1, + + .limits = { + .non_inductive_for_loops = 1, + .while_loops = 1, + .do_while_loops = 1, + .general_uniform_indexing = 1, + .general_attribute_matrix_vector_indexing = 1, + .general_varying_indexing = 1, + .general_sampler_indexing = 1, + .general_variable_indexing = 1, + .general_constant_matrix_vector_indexing = 1, + } +}; + +static int glslc_shader_compile(FFVulkanContext *s, FFVkSPIRVCompiler *ctx, + FFVulkanShader *shd, uint8_t **data, + size_t *size, const char *entrypoint, + void **opaque) +{ + const char *messages; + glslang_shader_t *glslc_shader; + glslang_program_t *glslc_program; + + static const glslang_stage_t glslc_stage[] = { + [VK_SHADER_STAGE_VERTEX_BIT] = GLSLANG_STAGE_VERTEX, + [VK_SHADER_STAGE_FRAGMENT_BIT] = GLSLANG_STAGE_FRAGMENT, + [VK_SHADER_STAGE_COMPUTE_BIT] = GLSLANG_STAGE_COMPUTE, +#if ((GLSLANG_VERSION_MAJOR) > 12) + [VK_SHADER_STAGE_TASK_BIT_EXT] = GLSLANG_STAGE_TASK, + [VK_SHADER_STAGE_MESH_BIT_EXT] = GLSLANG_STAGE_MESH, + [VK_SHADER_STAGE_RAYGEN_BIT_KHR] = GLSLANG_STAGE_RAYGEN, + [VK_SHADER_STAGE_INTERSECTION_BIT_KHR] = GLSLANG_STAGE_INTERSECT, + [VK_SHADER_STAGE_ANY_HIT_BIT_KHR] = GLSLANG_STAGE_ANYHIT, + [VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR] = GLSLANG_STAGE_CLOSESTHIT, + [VK_SHADER_STAGE_MISS_BIT_KHR] = GLSLANG_STAGE_MISS, + [VK_SHADER_STAGE_CALLABLE_BIT_KHR] = GLSLANG_STAGE_CALLABLE, +#endif + }; + + const glslang_input_t glslc_input = { + .language = GLSLANG_SOURCE_GLSL, + .stage = glslc_stage[shd->stage], + .client = GLSLANG_CLIENT_VULKAN, +#if ((GLSLANG_VERSION_MAJOR) >= 12) + .client_version = GLSLANG_TARGET_VULKAN_1_3, + .target_language_version = GLSLANG_TARGET_SPV_1_6, +#else + .client_version = GLSLANG_TARGET_VULKAN_1_2, + .target_language_version = GLSLANG_TARGET_SPV_1_5, +#endif + .target_language = GLSLANG_TARGET_SPV, + .code = shd->src.str, + .default_version = 460, + .default_profile = GLSLANG_NO_PROFILE, + .force_default_version_and_profile = false, + .forward_compatible = false, + .messages = GLSLANG_MSG_DEFAULT_BIT, + .resource = &glslc_resource_limits, + }; + +#if ((GLSLANG_VERSION_MAJOR) >= 12) + glslang_spv_options_t glslc_opts = { + .generate_debug_info = !!(s->extensions & (FF_VK_EXT_DEBUG_UTILS | FF_VK_EXT_RELAXED_EXTENDED_INSTR)), + .emit_nonsemantic_shader_debug_info = !!(s->extensions & FF_VK_EXT_RELAXED_EXTENDED_INSTR), + .emit_nonsemantic_shader_debug_source = !!(s->extensions & FF_VK_EXT_RELAXED_EXTENDED_INSTR), + .disable_optimizer = !!(s->extensions & FF_VK_EXT_DEBUG_UTILS), + .strip_debug_info = !(s->extensions & (FF_VK_EXT_DEBUG_UTILS | FF_VK_EXT_RELAXED_EXTENDED_INSTR)), + .optimize_size = 0, + .disassemble = 0, + .validate = 1, + .compile_only = 0, + }; +#endif + + av_assert0(glslc_refcount); + + *opaque = NULL; + + if (!(glslc_shader = glslang_shader_create(&glslc_input))) + return AVERROR(ENOMEM); + + if (!glslang_shader_preprocess(glslc_shader, &glslc_input)) { + ff_vk_shader_print(s, shd, AV_LOG_WARNING); + av_log(s, AV_LOG_ERROR, "Unable to preprocess shader: %s (%s)!\n", + glslang_shader_get_info_log(glslc_shader), + glslang_shader_get_info_debug_log(glslc_shader)); + glslang_shader_delete(glslc_shader); + return AVERROR(EINVAL); + } + + if (!glslang_shader_parse(glslc_shader, &glslc_input)) { + ff_vk_shader_print(s, shd, AV_LOG_WARNING); + av_log(s, AV_LOG_ERROR, "Unable to parse shader: %s (%s)!\n", + glslang_shader_get_info_log(glslc_shader), + glslang_shader_get_info_debug_log(glslc_shader)); + glslang_shader_delete(glslc_shader); + return AVERROR(EINVAL); + } + + if (!(glslc_program = glslang_program_create())) { + glslang_shader_delete(glslc_shader); + return AVERROR(EINVAL); + } + + glslang_program_add_shader(glslc_program, glslc_shader); + + if (!glslang_program_link(glslc_program, GLSLANG_MSG_SPV_RULES_BIT | + GLSLANG_MSG_VULKAN_RULES_BIT)) { + ff_vk_shader_print(s, shd, AV_LOG_WARNING); + av_log(s, AV_LOG_ERROR, "Unable to link shader: %s (%s)!\n", + glslang_program_get_info_log(glslc_program), + glslang_program_get_info_debug_log(glslc_program)); + glslang_program_delete(glslc_program); + glslang_shader_delete(glslc_shader); + return AVERROR(EINVAL); + } + +#if ((GLSLANG_VERSION_MAJOR) >= 12) + glslang_program_SPIRV_generate_with_options(glslc_program, glslc_input.stage, &glslc_opts); +#else + glslang_program_SPIRV_generate(glslc_program, glslc_input.stage); +#endif + + messages = glslang_program_SPIRV_get_messages(glslc_program); + if (messages) { + ff_vk_shader_print(s, shd, AV_LOG_WARNING); + av_log(s, AV_LOG_WARNING, "%s\n", messages); + } else { + ff_vk_shader_print(s, shd, AV_LOG_VERBOSE); + } + + glslang_shader_delete(glslc_shader); + + *size = glslang_program_SPIRV_get_size(glslc_program) * sizeof(unsigned int); + *data = (void *)glslang_program_SPIRV_get_ptr(glslc_program); + *opaque = glslc_program; + + return 0; +} + +static void glslc_shader_free(FFVkSPIRVCompiler *ctx, void **opaque) +{ + if (!opaque || !*opaque) + return; + + av_assert0(glslc_refcount); + glslang_program_delete(*opaque); + *opaque = NULL; +} + +static void glslc_uninit(FFVkSPIRVCompiler **ctx) +{ + if (!ctx || !*ctx) + return; + + pthread_mutex_lock(&glslc_mutex); + if (glslc_refcount && (--glslc_refcount == 0)) + glslang_finalize_process(); + pthread_mutex_unlock(&glslc_mutex); + + av_freep(ctx); +} + +FFVkSPIRVCompiler *ff_vk_glslang_init(void) +{ + FFVkSPIRVCompiler *ret = av_mallocz(sizeof(*ret)); + if (!ret) + return NULL; + + ret->compile_shader = glslc_shader_compile; + ret->free_shader = glslc_shader_free; + ret->uninit = glslc_uninit; + + pthread_mutex_lock(&glslc_mutex); + if (!glslc_refcount++) { + if (!glslang_initialize_process()) { + av_freep(&ret); + glslc_refcount--; + } + } + pthread_mutex_unlock(&glslc_mutex); + + return ret; +} diff --git a/libavutil/vulkan_shaderc.c b/libavutil/vulkan_shaderc.c new file mode 100644 index 0000000000..6e7475c49f --- /dev/null +++ b/libavutil/vulkan_shaderc.c @@ -0,0 +1,144 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/mem.h" +#include "vulkan_spirv.h" + +static int shdc_shader_compile(FFVulkanContext *s, FFVkSPIRVCompiler *ctx, + FFVulkanShader *shd, uint8_t **data, + size_t *size, const char *entrypoint, + void **opaque) +{ + int loglevel, err, warn, ret; + const char *status, *message; + shaderc_compilation_result_t res; + static const char *shdc_result[] = { + [shaderc_compilation_status_success] = "success", + [shaderc_compilation_status_invalid_stage] = "invalid stage", + [shaderc_compilation_status_compilation_error] = "error", + [shaderc_compilation_status_internal_error] = "internal error", + [shaderc_compilation_status_null_result_object] = "no result", + [shaderc_compilation_status_invalid_assembly] = "invalid assembly", + }; + static const shaderc_shader_kind shdc_kind[] = { + [VK_SHADER_STAGE_VERTEX_BIT] = shaderc_glsl_vertex_shader, + [VK_SHADER_STAGE_FRAGMENT_BIT] = shaderc_glsl_fragment_shader, + [VK_SHADER_STAGE_COMPUTE_BIT] = shaderc_glsl_compute_shader, + [VK_SHADER_STAGE_MESH_BIT_EXT] = shaderc_mesh_shader, + [VK_SHADER_STAGE_TASK_BIT_EXT] = shaderc_task_shader, + [VK_SHADER_STAGE_RAYGEN_BIT_KHR] = shaderc_raygen_shader, + [VK_SHADER_STAGE_ANY_HIT_BIT_KHR] = shaderc_anyhit_shader, + [VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR] = shaderc_closesthit_shader, + [VK_SHADER_STAGE_MISS_BIT_KHR] = shaderc_miss_shader, + [VK_SHADER_STAGE_INTERSECTION_BIT_KHR] = shaderc_intersection_shader, + [VK_SHADER_STAGE_CALLABLE_BIT_KHR] = shaderc_callable_shader, + }; + + shaderc_compile_options_t opts = shaderc_compile_options_initialize(); + *opaque = NULL; + if (!opts) + return AVERROR(ENOMEM); + + shaderc_compile_options_set_target_env(opts, shaderc_target_env_vulkan, + shaderc_env_version_vulkan_1_3); + shaderc_compile_options_set_target_spirv(opts, shaderc_spirv_version_1_6); + + /* If either extension is set, turn on debug info */ + if (s->extensions & (FF_VK_EXT_DEBUG_UTILS | FF_VK_EXT_RELAXED_EXTENDED_INSTR)) + shaderc_compile_options_set_generate_debug_info(opts); + + if (s->extensions & FF_VK_EXT_DEBUG_UTILS) + shaderc_compile_options_set_optimization_level(opts, + shaderc_optimization_level_zero); + else + shaderc_compile_options_set_optimization_level(opts, + shaderc_optimization_level_performance); + + res = shaderc_compile_into_spv((shaderc_compiler_t)ctx->priv, + shd->src.str, strlen(shd->src.str), + shdc_kind[shd->stage], + shd->name, entrypoint, opts); + shaderc_compile_options_release(opts); + + ret = shaderc_result_get_compilation_status(res); + err = shaderc_result_get_num_errors(res); + warn = shaderc_result_get_num_warnings(res); + message = shaderc_result_get_error_message(res); + + if (ret != shaderc_compilation_status_success && !err) + err = 1; + + loglevel = err ? AV_LOG_ERROR : warn ? AV_LOG_WARNING : AV_LOG_VERBOSE; + + ff_vk_shader_print(s, shd, loglevel); + if (message && (err || warn)) + av_log(s, loglevel, "%s\n", message); + status = ret < FF_ARRAY_ELEMS(shdc_result) ? shdc_result[ret] : "unknown"; + av_log(s, loglevel, "shaderc compile status '%s' (%d errors, %d warnings)\n", + status, err, warn); + + if (err > 0) + return AVERROR(EINVAL); + + *data = (uint8_t *)shaderc_result_get_bytes(res); + *size = shaderc_result_get_length(res); + *opaque = res; + + return 0; +} + +static void shdc_shader_free(FFVkSPIRVCompiler *ctx, void **opaque) +{ + if (!opaque || !*opaque) + return; + + shaderc_result_release((shaderc_compilation_result_t)*opaque); + *opaque = NULL; +} + +static void shdc_uninit(FFVkSPIRVCompiler **ctx) +{ + FFVkSPIRVCompiler *s; + + if (!ctx || !*ctx) + return; + + s = *ctx; + + shaderc_compiler_release((shaderc_compiler_t)s->priv); + av_freep(ctx); +} + +FFVkSPIRVCompiler *ff_vk_shaderc_init(void) +{ + FFVkSPIRVCompiler *ret = av_mallocz(sizeof(*ret)); + if (!ret) + return NULL; + + ret->compile_shader = shdc_shader_compile; + ret->free_shader = shdc_shader_free; + ret->uninit = shdc_uninit; + + ret->priv = (void *)shaderc_compiler_initialize(); + if (!ret->priv) + av_freep(&ret); + + return ret; +} diff --git a/libavfilter/vulkan_spirv.h b/libavutil/vulkan_spirv.h similarity index 98% rename from libavfilter/vulkan_spirv.h rename to libavutil/vulkan_spirv.h index b0349b6b54..c51f444997 100644 --- a/libavfilter/vulkan_spirv.h +++ b/libavutil/vulkan_spirv.h @@ -19,7 +19,7 @@ #ifndef AVFILTER_VULKAN_SPIRV_H #define AVFILTER_VULKAN_SPIRV_H -#include "libavutil/vulkan.h" +#include "vulkan.h" #include "config.h" From patchwork Fri Oct 4 09:31:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 52035 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:938f:0:b0:48e:c0f8:d0de with SMTP id z15csp278783vqg; Fri, 4 Oct 2024 02:32:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU54RDxjF1F0BLgo8cbbMF0qz5w3g7qaOYkDXozR0IO0TD8aVb6wSalcR+6Co9iAp0y5liNk13MzA3lNFJs2zda@gmail.com X-Google-Smtp-Source: AGHT+IHSh/vNb2Nmg4mC3NIZqp9fFaoorJe/Dt3k+4zUzNSriJp3kNY2El/ohNk0z/N8/IBzsXuX X-Received: by 2002:a05:6402:5411:b0:5c2:609d:397e with SMTP id 4fb4d7f45d1cf-5c8d2e27df8mr1301983a12.15.1728034340082; Fri, 04 Oct 2024 02:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728034340; cv=none; d=google.com; s=arc-20240605; b=dV8sbPAZKOrnTl2uI6LMgn+eeye0HvNNRhx6dHT7J35sVizH6XpxKp7dIAKv/CkrX4 PKGoJrJ5MTzW4+uoVoLFnxsuDbO6w53uZZgYjUWgQ16kk5px5OPCJ4E4A5IzgKd6iICu LPgJIKbPS/smoJWeK28zWkalKzCnRCrCUkAixI+41EEAdlliMo5FAR/EbsKLhEn/4k9y 2uGLLYvdG6h1kup7+HYZ4dE1olThrUIMUvcsTiTcYkzrdbvn/44/d7O0Z6lq12/HwGH0 YBKACdpffIyESxQb72szizcXwJKgS1LejvYsu9DMdYoN+iD3b+pCOWjKgjaJ/VC+U7nJ EFvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:delivered-to; bh=JifHxLEIvBn6LqAF2wXqtzRB4MUFRCOOHISqN+pqIzA=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=cP+DdCr29xwFPmGbgtpuwxdChkmvC7Yi/jkFDubdG7oVY5AYy5a4nD30paPiPrTh3H uG+Ydz/inDrwQRHjgcoPxi51AFXmpuGGEnY+Ly0taXAyJPKj3CZfLroJwS9rw+8lPQIf ZcCRVF7MKFSCRn7YGKJWFYiyGdFLV23NP0h4a4UkJnWuzNklK+GyMz9nmXKHyZj22FHy CqEhxHcI3f59+qwzKsgwuQ+atj8ntG7OFFhIQOORmrbUeHZo1+V/iExKQfGJRFC6rNNR vvlJLnq6OCqfbvKOOVWVVPE0gyyiRg8Ef8Q6e4BnN8kPylUeD2Yx39O/JWJJ2FV42dll aN5g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5c8ca3c1cd0si2140484a12.81.2024.10.04.02.32.19; Fri, 04 Oct 2024 02:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3523268DB4D; Fri, 4 Oct 2024 12:31:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2163768DA5B for ; Fri, 4 Oct 2024 12:31:40 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Fri, 4 Oct 2024 11:31:31 +0200 Message-ID: <20241004093137.139470-4-dev@lynne.ee> X-Mailer: git-send-email 2.45.2.753.g447d99e1c3b In-Reply-To: <20241004093137.139470-1-dev@lynne.ee> References: <20241004093137.139470-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] lavc/vulkan: add SPIR-V compilation support 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: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: O8HkLCnS2kYE This is the same as with libavfilter. We will need SPIR-V compilation for at least three different things, like the VC-2 encoder and decoder, AV1 film grain synthesis for hardware with no support for it, and possibly other codecs. --- libavcodec/Makefile | 4 ++++ libavcodec/vulkan_glslang.c | 19 +++++++++++++++++++ libavcodec/vulkan_shaderc.c | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 libavcodec/vulkan_glslang.c create mode 100644 libavcodec/vulkan_shaderc.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a253a9b160..7147ed0360 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1257,6 +1257,10 @@ OBJS-$(HAVE_THREADS) += pthread.o pthread_slice.o pthread_fram OBJS-$(CONFIG_FRAME_THREAD_ENCODER) += frame_thread_encoder.o +# vulkan libs +OBJS-$(CONFIG_LIBGLSLANG) += vulkan_glslang.o +OBJS-$(CONFIG_LIBSHADERC) += vulkan_shaderc.o + # Windows resource file SHLIBOBJS-$(HAVE_GNU_WINDRES) += avcodecres.o diff --git a/libavcodec/vulkan_glslang.c b/libavcodec/vulkan_glslang.c new file mode 100644 index 0000000000..9aa41567a3 --- /dev/null +++ b/libavcodec/vulkan_glslang.c @@ -0,0 +1,19 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/vulkan_glslang.c" diff --git a/libavcodec/vulkan_shaderc.c b/libavcodec/vulkan_shaderc.c new file mode 100644 index 0000000000..9f60bf4dfd --- /dev/null +++ b/libavcodec/vulkan_shaderc.c @@ -0,0 +1,19 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/vulkan_shaderc.c"