d3d12: Add support for resource copy between d3d11 and d3d12

If driver can support cross-api resource sharing, use device-to-device
resource copy in d3d12upload/download elements.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7119>
This commit is contained in:
Seungha Yang 2024-06-29 23:02:21 +09:00 committed by GStreamer Marge Bot
parent 6cac053549
commit c0a02affa4
4 changed files with 1518 additions and 4 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,61 @@
/* GStreamer
* Copyright (C) 2024 Seungha Yang <seungha@centricular.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <gst/base/gstbasetransform.h>
G_BEGIN_DECLS
#define GST_TYPE_D3D12_MEMORY_COPY (gst_d3d12_memory_copy_get_type())
#define GST_D3D12_MEMORY_COPY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_D3D12_MEMORY_COPY,GstD3D12MemoryCopy))
#define GST_D3D12_MEMORY_COPY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_D3D12_MEMORY_COPY,GstD3D12MemoryCopyClass))
#define GST_D3D12_MEMORY_COPY_GET_CLASS(obj) (GST_D3D12_MEMORY_COPY_CLASS(G_OBJECT_GET_CLASS(obj)))
#define GST_IS_D3D12_MEMORY_COPY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_D3D12_MEMORY_COPY))
#define GST_IS_D3D12_MEMORY_COPY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_D3D12_MEMORY_COPY))
typedef struct _GstD3D12MemoryCopy GstD3D12MemoryCopy;
typedef struct _GstD3D12MemoryCopyClass GstD3D12MemoryCopyClass;
typedef struct _GstD3D12MemoryCopyPrivate GstD3D12MemoryCopyPrivate;
struct _GstD3D12MemoryCopy
{
GstBaseTransform parent;
GstD3D12MemoryCopyPrivate *priv;
};
struct _GstD3D12MemoryCopyClass
{
GstBaseTransformClass parent_class;
};
GType gst_d3d12_memory_copy_get_type (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstD3D12MemoryCopy, gst_object_unref)
#define GST_TYPE_D3D12_UPLOAD (gst_d3d12_upload_get_type())
G_DECLARE_FINAL_TYPE (GstD3D12Upload,
gst_d3d12_upload, GST, D3D12_UPLOAD, GstD3D12MemoryCopy);
#define GST_TYPE_D3D12_DOWNLOAD (gst_d3d12_download_get_type())
G_DECLARE_FINAL_TYPE (GstD3D12Download,
gst_d3d12_download, GST, D3D12_DOWNLOAD, GstD3D12MemoryCopy);
G_END_DECLS

View file

@ -5,7 +5,6 @@ d3d12_sources = [
'gstd3d12convert.cpp',
'gstd3d12decoder.cpp',
'gstd3d12decodercpbpool.cpp',
'gstd3d12download.cpp',
'gstd3d12dpbstorage.cpp',
'gstd3d12dxgicapture.cpp',
'gstd3d12encoder.cpp',
@ -25,7 +24,6 @@ d3d12_sources = [
'gstd3d12screencapturedevice.cpp',
'gstd3d12screencapturesrc.cpp',
'gstd3d12testsrc.cpp',
'gstd3d12upload.cpp',
'gstd3d12videosink.cpp',
'gstd3d12vp8dec.cpp',
'gstd3d12vp9dec.cpp',
@ -159,6 +157,19 @@ if have_wgc and dwmapi_lib.found()
extra_deps += [dwmapi_lib]
endif
if gstd3d11_dep.found()
extra_args += ['-DHAVE_GST_D3D11']
extra_deps += [gstd3d11_dep]
d3d12_sources += [
'gstd3d12memorycopy.cpp',
]
else
d3d12_sources += [
'gstd3d12download.cpp',
'gstd3d12upload.cpp',
]
endif
gstd3d12 = library('gstd3d12',
d3d12_sources,
c_args : gst_plugins_bad_args + extra_args,

View file

@ -31,8 +31,6 @@
#include <gst/d3d12/gstd3d12.h>
#include "gstd3d12pluginutils.h"
#include "gstd3d12convert.h"
#include "gstd3d12download.h"
#include "gstd3d12upload.h"
#include "gstd3d12videosink.h"
#include "gstd3d12testsrc.h"
#include "gstd3d12compositor.h"
@ -53,6 +51,13 @@
#include <wrl.h>
#include <glib/gi18n-lib.h>
#ifdef HAVE_GST_D3D11
#include "gstd3d12memorycopy.h"
#else
#include "gstd3d12download.h"
#include "gstd3d12upload.h"
#endif
/* *INDENT-OFF* */
using namespace Microsoft::WRL;
/* *INDENT-ON* */