From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B587248013 for ; Wed, 8 Nov 2023 16:32:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CC5A868CAD8; Wed, 8 Nov 2023 18:32:39 +0200 (EET) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E243E68C902 for ; Wed, 8 Nov 2023 18:32:33 +0200 (EET) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 273BF5C01B4 for ; Wed, 8 Nov 2023 06:04:16 -0500 (EST) Received: from imap49 ([10.202.2.99]) by compute3.internal (MEProxy); Wed, 08 Nov 2023 06:04:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1699441456; x=1699527856; bh=U63rpzTpkKLKb 2/rBdPRduOel5w6Rep1195IxNmgMrg=; b=MaaIxUczDkDWHGHHd3qGl4RzqP1pT dlgq3ewecePHEEBXf3LXFAg32SBuTEVoeu/CJ+fZcwaIkzOHXibDS7V03K3Y9MSD 71Ca3QrhMz75QBbNLDObpuVW2NGk6MnytA6lrzULMRrRbvSI9UkjvAiDgkSj/+FZ 0c2dja9QPxq/ANtQRHst7kA8PMAUtYAgdQVbhf/5R32Pt2mFyQkk0fjq0geKiwnp ffocnxju16IanrTjwHGs7HZ1HiN3s7hv16YltUoZKm0jHpl0ZX+JDls6J56avcev +wXs7uJruWRN4XnAPcPiYXnM93Cy1eTHC9B+k0pyEspC5JFRAtRersSvQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudduledgvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdflvggr nhdquegrphhtihhsthgvucfmvghmphhffdcuoehjsgesvhhiuggvohhlrghnrdhorhhgqe enucggtffrrghtthgvrhhnpeetgeehjeekieefleevtdeifeefffeugefhvdeggfdttdei ueduiedthedvfeehvdenucffohhmrghinhepmhhitghrohhsohhfthdrtghomhdpfhhfmh hpvghgrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhepjhgssehvihguvgholhgrnhdrohhrgh X-ME-Proxy: Feedback-ID: i06904239:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id A90DB15A0091; Wed, 8 Nov 2023 06:04:15 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1108-g3a29173c6d-fm-20231031.005-g3a29173c MIME-Version: 1.0 Message-Id: <4b6393f5-c9a2-47d1-811a-ece7694d1dcc@betaapp.fastmail.com> In-Reply-To: <20231108010552.52-1-tong1.wu@intel.com> References: <20231108010552.52-1-tong1.wu@intel.com> Date: Wed, 08 Nov 2023 12:03:54 +0100 From: "Jean-Baptiste Kempf" To: fmpeg-devel Subject: Re: [FFmpeg-devel] [PATCH v9 1/9] libavutil: add hwcontext_d3d12va and AV_PIX_FMT_D3D12 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Hello, On Wed, 8 Nov 2023, at 02:05, Tong Wu wrote: > +/** > + * @brief This struct is used to sync d3d12 execution > + * > + */ > +typedef struct AVD3D12VASyncContext { > + /** > + * D3D12 fence object > + */ > + ID3D12Fence *fence; > + > + /** > + * A handle to the event object > + */ > + HANDLE event; Sorry, but which event object? I would guess it's the ID3D12Fence::Signal, but I'm not even sure. I think this needs a bit more doc and explanations. > + > + /** > + * The fence value used for sync > + */ > + uint64_t fence_value; > +} AVD3D12VASyncContext; > + > +/** > + * @brief D3D12VA frame descriptor for pool allocation. > + * > + */ > +typedef struct AVD3D12VAFrame { > + /** > + * The texture in which the frame is located. The reference count > is > + * managed by the AVBufferRef, and destroying the reference will > release > + * the interface. > + */ > + ID3D12Resource *texture; > + > + /** > + * The index into the array texture element representing the frame > + */ > + intptr_t index; > + > + /** > + * The sync context for the texture > + * > + * Use av_d3d12va_wait_idle(sync_ctx) to ensure the decoding or > encoding have been finised > + * @see: > https://learn.microsoft.com/en-us/windows/win32/medfound/direct3d-12-video-overview#directx-12-fences > + */ > + AVD3D12VASyncContext *sync_ctx; > +} AVD3D12VAFrame; > + > +/** > + * @brief This struct is allocated as AVHWFramesContext.hwctx > + * > + */ > +typedef struct AVD3D12VAFramesContext { > + /** > + * This field is not able to be user-allocated at the present. > + */ > + AVD3D12VAFrame *texture_infos; > +} AVD3D12VAFramesContext; > + > +/** > + * @brief Map sw pixel format to d3d12 format > + * > + * @return d3d12 specified format > + */ > +DXGI_FORMAT av_d3d12va_map_sw_to_hw_format(enum AVPixelFormat pix_fmt); > + > +/** > + * @brief Allocate an AVD3D12VASyncContext > + * > + * @return Error code (ret < 0 if failed) > + */ > +int av_d3d12va_sync_context_alloc(AVD3D12VADeviceContext *ctx, > AVD3D12VASyncContext **sync_ctx); > + > +/** > + * @brief Free an AVD3D12VASyncContext > + */ > +void av_d3d12va_sync_context_free(AVD3D12VASyncContext **sync_ctx); > + > +#endif /* AVUTIL_HWCONTEXT_D3D12VA_H */ > diff --git a/libavutil/hwcontext_d3d12va_internal.h > b/libavutil/hwcontext_d3d12va_internal.h > new file mode 100644 > index 0000000000..bfd89b3545 > --- /dev/null > +++ b/libavutil/hwcontext_d3d12va_internal.h > @@ -0,0 +1,59 @@ > +/* > + * Direct3D 12 HW acceleration. > + * > + * copyright (c) 2022-2023 Wu Jianhua > + * > + * 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 AVUTIL_HWCONTEXT_D3D12VA_INTERNAL_H > +#define AVUTIL_HWCONTEXT_D3D12VA_INTERNAL_H > + > +/** > + * @def COBJMACROS > + * > + * @brief Enable C style interface for D3D12 > + */ > +#ifndef COBJMACROS > +#define COBJMACROS > +#endif > + > +/** > + * @def DX_CHECK > + * > + * @brief A check macro used by D3D12 functions highly frequently > + */ > +#define DX_CHECK(hr) \ > + do { \ > + if (FAILED(hr)) \ > + goto fail; \ > + } while (0) > + > +/** > + * @def D3D12_OBJECT_RELEASE > + * > + * @brief A release macro used by D3D12 objects highly frequently > + */ > +#define D3D12_OBJECT_RELEASE(pInterface) \ > + do { \ > + if (pInterface) { \ > + IUnknown_Release((IUnknown *)pInterface); \ > + pInterface = NULL; \ > + } \ > + } while (0) > + > +#endif /* AVUTIL_HWCONTEXT_D3D12VA_INTERNAL_H */ > \ No newline at end of file > diff --git a/libavutil/hwcontext_internal.h > b/libavutil/hwcontext_internal.h > index e6266494ac..4df516ee6a 100644 > --- a/libavutil/hwcontext_internal.h > +++ b/libavutil/hwcontext_internal.h > @@ -165,6 +165,7 @@ int ff_hwframe_map_replace(AVFrame *dst, const > AVFrame *src); > > extern const HWContextType ff_hwcontext_type_cuda; > extern const HWContextType ff_hwcontext_type_d3d11va; > +extern const HWContextType ff_hwcontext_type_d3d12va; > extern const HWContextType ff_hwcontext_type_drm; > extern const HWContextType ff_hwcontext_type_dxva2; > extern const HWContextType ff_hwcontext_type_opencl; > diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c > index 4e4a63e287..0db4167934 100644 > --- a/libavutil/pixdesc.c > +++ b/libavutil/pixdesc.c > @@ -2311,6 +2311,10 @@ static const AVPixFmtDescriptor > av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { > .name = "d3d11", > .flags = AV_PIX_FMT_FLAG_HWACCEL, > }, > + [AV_PIX_FMT_D3D12] = { > + .name = "d3d12", > + .flags = AV_PIX_FMT_FLAG_HWACCEL, > + }, > [AV_PIX_FMT_GBRPF32BE] = { > .name = "gbrpf32be", > .nb_components = 3, > diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h > index a26c72d56b..58f9ad28bd 100644 > --- a/libavutil/pixfmt.h > +++ b/libavutil/pixfmt.h > @@ -429,6 +429,13 @@ enum AVPixelFormat { > AV_PIX_FMT_GBRAP14BE, ///< planar GBR 4:4:4:4 56bpp, big-endian > AV_PIX_FMT_GBRAP14LE, ///< planar GBR 4:4:4:4 56bpp, little-endian > > + /** > + * Hardware surfaces for Direct3D 12. > + * > + * data[0] points to an AVD3D12VAFrame > + */ > + AV_PIX_FMT_D3D12, > + > AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE > THIS if you want to link with shared libav* because the number of > formats might differ between versions > }; > > diff --git a/libavutil/tests/hwdevice.c b/libavutil/tests/hwdevice.c > index c57586613a..9d7964f9ee 100644 > --- a/libavutil/tests/hwdevice.c > +++ b/libavutil/tests/hwdevice.c > @@ -137,6 +137,8 @@ static const struct { > { "0", "1", "2" } }, > { AV_HWDEVICE_TYPE_D3D11VA, > { "0", "1", "2" } }, > + { AV_HWDEVICE_TYPE_D3D12VA, > + { "0", "1", "2" } }, > { AV_HWDEVICE_TYPE_OPENCL, > { "0.0", "0.1", "1.0", "1.1" } }, > { AV_HWDEVICE_TYPE_VAAPI, > diff --git a/libavutil/version.h b/libavutil/version.h > index 589a42b0fa..c5fa7c3692 100644 > --- a/libavutil/version.h > +++ b/libavutil/version.h > @@ -79,7 +79,7 @@ > */ > > #define LIBAVUTIL_VERSION_MAJOR 58 > -#define LIBAVUTIL_VERSION_MINOR 31 > +#define LIBAVUTIL_VERSION_MINOR 32 > #define LIBAVUTIL_VERSION_MICRO 100 > > #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ > -- > 2.41.0.windows.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". -- Jean-Baptiste Kempf - President +33 672 704 734 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".