mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
d3d12: Remove d3d11 dependency
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5870>
This commit is contained in:
parent
43fdc9e9f9
commit
2578f234dd
12 changed files with 21 additions and 113 deletions
|
@ -324,7 +324,7 @@ gst_d3d12_av1_dec_output_picture (GstDxvaAV1Decoder * decoder,
|
|||
|
||||
void
|
||||
gst_d3d12_av1_dec_register (GstPlugin * plugin, GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device, guint rank, gboolean d3d11_interop)
|
||||
ID3D12VideoDevice * video_device, guint rank)
|
||||
{
|
||||
GType type;
|
||||
gchar *type_name;
|
||||
|
@ -347,7 +347,7 @@ gst_d3d12_av1_dec_register (GstPlugin * plugin, GstD3D12Device * device,
|
|||
|
||||
type_info.class_data =
|
||||
gst_d3d12_decoder_check_feature_support (device, video_device,
|
||||
GST_DXVA_CODEC_AV1, d3d11_interop);
|
||||
GST_DXVA_CODEC_AV1);
|
||||
if (!type_info.class_data)
|
||||
return;
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ G_BEGIN_DECLS
|
|||
void gst_d3d12_av1_dec_register (GstPlugin * plugin,
|
||||
GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device,
|
||||
guint rank,
|
||||
gboolean d3d11_interop);
|
||||
guint rank);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -215,7 +215,6 @@ enum GstD3D12DecoderOutputType
|
|||
GST_D3D12_DECODER_OUTPUT_UNKNOWN = 0,
|
||||
GST_D3D12_DECODER_OUTPUT_SYSTEM = (1 << 0),
|
||||
GST_D3D12_DECODER_OUTPUT_D3D12 = (1 << 1),
|
||||
GST_D3D12_DECODER_OUTPUT_D3D11 = (1 << 2),
|
||||
};
|
||||
|
||||
DEFINE_ENUM_FLAG_OPERATORS (GstD3D12DecoderOutputType);
|
||||
|
@ -380,7 +379,6 @@ struct _GstD3D12Decoder
|
|||
|
||||
GstDxvaCodec codec;
|
||||
GstD3D12Device *device;
|
||||
GstD3D11Device *d3d11_device;
|
||||
gint64 adapter_luid;
|
||||
|
||||
GstD3D12DecoderPrivate *priv;
|
||||
|
@ -412,7 +410,6 @@ gst_d3d12_decoder_finalize (GObject * object)
|
|||
auto self = GST_D3D12_DECODER (object);
|
||||
|
||||
gst_clear_object (&self->device);
|
||||
gst_clear_object (&self->d3d11_device);
|
||||
|
||||
delete self->priv;
|
||||
|
||||
|
@ -588,7 +585,6 @@ gst_d3d12_decoder_close (GstD3D12Decoder * decoder)
|
|||
priv->cmd = nullptr;
|
||||
|
||||
gst_clear_object (&decoder->device);
|
||||
gst_clear_object (&decoder->d3d11_device);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1460,7 +1456,6 @@ gst_d3d12_decoder_process_output (GstD3D12Decoder * self,
|
|||
ID3D12Resource *out_resource = nullptr;
|
||||
UINT out_subresource[2];
|
||||
GstD3D12Fence *out_fence = priv->cmd->copy_fence;
|
||||
ComPtr < ID3D12Resource > shared_resource;
|
||||
|
||||
ret = gst_video_decoder_allocate_output_frame (videodec, frame);
|
||||
if (ret != GST_FLOW_OK) {
|
||||
|
@ -1482,24 +1477,6 @@ gst_d3d12_decoder_process_output (GstD3D12Decoder * self,
|
|||
GST_MINI_OBJECT_FLAG_UNSET (dmem,
|
||||
GST_D3D12_MEMORY_TRANSFER_NEED_UPLOAD);
|
||||
}
|
||||
} else if (gst_is_d3d11_memory (mem) &&
|
||||
GST_D3D11_MEMORY_CAST (mem)->device == self->d3d11_device) {
|
||||
HANDLE resource_handle;
|
||||
if (gst_d3d11_memory_get_nt_handle (GST_D3D11_MEMORY_CAST (mem),
|
||||
&resource_handle)) {
|
||||
auto device_handle = gst_d3d12_device_get_device_handle (self->device);
|
||||
hr = device_handle->OpenSharedHandle (resource_handle,
|
||||
IID_PPV_ARGS (&shared_resource));
|
||||
if (gst_d3d12_result (hr, self->device)) {
|
||||
out_resource = shared_resource.Get ();
|
||||
out_subresource[0] = 0;
|
||||
out_subresource[1] = 1;
|
||||
GST_MINI_OBJECT_FLAG_SET (mem,
|
||||
GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD);
|
||||
GST_MINI_OBJECT_FLAG_UNSET (mem,
|
||||
GST_D3D11_MEMORY_TRANSFER_NEED_UPLOAD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!out_resource && !gst_d3d12_decoder_ensure_staging_texture (self)) {
|
||||
|
@ -1526,9 +1503,6 @@ gst_d3d12_decoder_process_output (GstD3D12Decoder * self,
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (shared_resource)
|
||||
gst_d3d11_device_lock (self->d3d11_device);
|
||||
|
||||
/* simultaneous access must be enabled already, so,barrier is not needed */
|
||||
for (guint i = 0; i < 2; i++) {
|
||||
D3D12_TEXTURE_COPY_LOCATION src =
|
||||
|
@ -1573,8 +1547,6 @@ gst_d3d12_decoder_process_output (GstD3D12Decoder * self,
|
|||
hr = priv->cmd->copy_cl->Close ();
|
||||
if (!gst_d3d12_result (hr, self->device)) {
|
||||
GST_ERROR_OBJECT (videodec, "Couldn't record copy command");
|
||||
if (shared_resource)
|
||||
gst_d3d11_device_unlock (self->d3d11_device);
|
||||
ret = GST_FLOW_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
@ -1586,8 +1558,6 @@ gst_d3d12_decoder_process_output (GstD3D12Decoder * self,
|
|||
hr = copy_queue->Signal (gst_d3d12_fence_get_handle (out_fence),
|
||||
fence_value);
|
||||
if (!gst_d3d12_result (hr, self->device)) {
|
||||
if (shared_resource)
|
||||
gst_d3d11_device_unlock (self->d3d11_device);
|
||||
ret = GST_FLOW_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
@ -1623,9 +1593,6 @@ gst_d3d12_decoder_process_output (GstD3D12Decoder * self,
|
|||
|
||||
priv->session->staging->Unmap (0, nullptr);
|
||||
gst_video_frame_unmap (&vframe);
|
||||
} else if (shared_resource) {
|
||||
gst_d3d12_fence_wait (out_fence);
|
||||
gst_d3d11_device_unlock (self->d3d11_device);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1770,9 +1737,6 @@ gst_d3d12_decoder_negotiate (GstD3D12Decoder * decoder,
|
|||
if (gst_caps_features_contains (features,
|
||||
GST_CAPS_FEATURE_MEMORY_D3D12_MEMORY)) {
|
||||
allowed_types |= GST_D3D12_DECODER_OUTPUT_D3D12;
|
||||
} else if (gst_caps_features_contains (features,
|
||||
GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY)) {
|
||||
allowed_types |= GST_D3D12_DECODER_OUTPUT_D3D11;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1820,8 +1784,6 @@ gst_d3d12_decoder_negotiate (GstD3D12Decoder * decoder,
|
|||
} else {
|
||||
if ((allowed_types & GST_D3D12_DECODER_OUTPUT_D3D12) != 0)
|
||||
priv->session->output_type = GST_D3D12_DECODER_OUTPUT_D3D12;
|
||||
else if ((allowed_types & GST_D3D12_DECODER_OUTPUT_D3D11) != 0)
|
||||
priv->session->output_type = GST_D3D12_DECODER_OUTPUT_D3D11;
|
||||
else
|
||||
priv->session->output_type = GST_D3D12_DECODER_OUTPUT_SYSTEM;
|
||||
}
|
||||
|
@ -1830,11 +1792,6 @@ gst_d3d12_decoder_negotiate (GstD3D12Decoder * decoder,
|
|||
gst_caps_set_features (state->caps, 0,
|
||||
gst_caps_features_new_single (GST_CAPS_FEATURE_MEMORY_D3D12_MEMORY));
|
||||
priv->session->output_type = GST_D3D12_DECODER_OUTPUT_D3D12;
|
||||
} else if (priv->session->output_type == GST_D3D12_DECODER_OUTPUT_D3D11
|
||||
&& gst_d3d11_ensure_element_data_for_adapter_luid (GST_ELEMENT (videodec),
|
||||
decoder->adapter_luid, &decoder->d3d11_device)) {
|
||||
gst_caps_set_features (state->caps, 0,
|
||||
gst_caps_features_new_single (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY));
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (decoder, "Selected output type %d",
|
||||
|
@ -1897,18 +1854,6 @@ gst_d3d12_decoder_decide_allocation (GstD3D12Decoder * decoder,
|
|||
gst_clear_object (&pool);
|
||||
}
|
||||
}
|
||||
} else if (priv->session->output_type == GST_D3D12_DECODER_OUTPUT_D3D11) {
|
||||
if (!GST_IS_D3D11_BUFFER_POOL (pool)) {
|
||||
GST_DEBUG_OBJECT (videodec,
|
||||
"Downstream pool is not d3d11, will create new one");
|
||||
gst_clear_object (&pool);
|
||||
} else {
|
||||
GstD3D11BufferPool *dpool = GST_D3D11_BUFFER_POOL (pool);
|
||||
if (dpool->device != decoder->d3d11_device) {
|
||||
GST_DEBUG_OBJECT (videodec, "Different device, will create new one");
|
||||
gst_clear_object (&pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1917,9 +1862,6 @@ gst_d3d12_decoder_decide_allocation (GstD3D12Decoder * decoder,
|
|||
case GST_D3D12_DECODER_OUTPUT_D3D12:
|
||||
pool = gst_d3d12_buffer_pool_new (decoder->device);
|
||||
break;
|
||||
case GST_D3D12_DECODER_OUTPUT_D3D11:
|
||||
pool = gst_d3d11_buffer_pool_new (decoder->d3d11_device);
|
||||
break;
|
||||
default:
|
||||
pool = gst_video_buffer_pool_new ();
|
||||
break;
|
||||
|
@ -1965,17 +1907,6 @@ gst_d3d12_decoder_decide_allocation (GstD3D12Decoder * decoder,
|
|||
/* We will not use downstream pool for decoding, and therefore preallocation
|
||||
* is unnecessary. So, Non-zero min buffer will be a waste of GPU memory */
|
||||
min = 0;
|
||||
} else if (priv->session->output_type == GST_D3D12_DECODER_OUTPUT_D3D11) {
|
||||
GstD3D11AllocationParams *params;
|
||||
const guint bind_flags = D3D11_BIND_SHADER_RESOURCE |
|
||||
D3D11_BIND_RENDER_TARGET;
|
||||
const guint misc_flags = D3D11_RESOURCE_MISC_SHARED_NTHANDLE |
|
||||
D3D11_RESOURCE_MISC_SHARED;
|
||||
|
||||
params = gst_d3d11_allocation_params_new (decoder->d3d11_device, &vinfo,
|
||||
GST_D3D11_ALLOCATION_FLAG_DEFAULT, bind_flags, misc_flags);
|
||||
gst_buffer_pool_config_set_d3d11_allocation_params (config, params);
|
||||
gst_d3d11_allocation_params_free (params);
|
||||
}
|
||||
|
||||
gst_buffer_pool_set_config (pool, config);
|
||||
|
@ -2008,8 +1939,6 @@ gst_d3d12_decoder_set_context (GstD3D12Decoder * decoder, GstElement * element,
|
|||
std::lock_guard < std::recursive_mutex > lk (priv->context_lock);
|
||||
gst_d3d12_handle_set_context_for_adapter_luid (element,
|
||||
context, decoder->adapter_luid, &decoder->device);
|
||||
gst_d3d11_handle_set_context_for_adapter_luid (element,
|
||||
context, decoder->adapter_luid, &decoder->d3d11_device);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -2021,12 +1950,7 @@ gst_d3d12_decoder_handle_query (GstD3D12Decoder * decoder, GstElement * element,
|
|||
|
||||
auto priv = decoder->priv;
|
||||
std::lock_guard < std::recursive_mutex > lk (priv->context_lock);
|
||||
if (gst_d3d12_handle_context_query (element, query, decoder->device) ||
|
||||
gst_d3d11_handle_context_query (element, query, decoder->d3d11_device)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return gst_d3d12_handle_context_query (element, query, decoder->device);
|
||||
}
|
||||
|
||||
enum
|
||||
|
@ -2072,8 +1996,7 @@ gst_d3d12_decoder_get_profiles (const GUID & profile,
|
|||
|
||||
GstD3D12DecoderClassData *
|
||||
gst_d3d12_decoder_check_feature_support (GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device, GstDxvaCodec codec,
|
||||
gboolean d3d11_interop)
|
||||
ID3D12VideoDevice * video_device, GstDxvaCodec codec)
|
||||
{
|
||||
HRESULT hr;
|
||||
GstDxvaResolution max_resolution = { 0, 0 };
|
||||
|
@ -2236,12 +2159,6 @@ gst_d3d12_decoder_check_feature_support (GstD3D12Device * device,
|
|||
GstCaps *src_caps = gst_caps_copy (raw_caps);
|
||||
gst_caps_set_features_simple (src_caps,
|
||||
gst_caps_features_new_single (GST_CAPS_FEATURE_MEMORY_D3D12_MEMORY));
|
||||
if (d3d11_interop) {
|
||||
GstCaps *d3d11_caps = gst_caps_copy (raw_caps);
|
||||
gst_caps_set_features_simple (d3d11_caps,
|
||||
gst_caps_features_new_single (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY));
|
||||
gst_caps_append (src_caps, d3d11_caps);
|
||||
}
|
||||
gst_caps_append (src_caps, raw_caps);
|
||||
|
||||
gint max_res = MAX (max_resolution.width, max_resolution.height);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <gst/video/video.h>
|
||||
#include <gst/codecs/gstcodecpicture.h>
|
||||
#include <gst/dxva/gstdxva.h>
|
||||
#include <gst/d3d11/gstd3d11.h>
|
||||
#include "gstd3d12_fwd.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -176,8 +175,7 @@ gboolean gst_d3d12_decoder_handle_query (GstD3D12Decoder * decoder
|
|||
/* Utils for element registration */
|
||||
GstD3D12DecoderClassData * gst_d3d12_decoder_check_feature_support (GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device,
|
||||
GstDxvaCodec codec,
|
||||
gboolean d3d11_interop);
|
||||
GstDxvaCodec codec);
|
||||
|
||||
void gst_d3d12_decoder_class_data_fill_subclass_data (GstD3D12DecoderClassData * data,
|
||||
GstD3D12DecoderSubClassData * subclass_data);
|
||||
|
|
|
@ -324,7 +324,7 @@ gst_d3d12_h264_dec_output_picture (GstDxvaH264Decoder * decoder,
|
|||
|
||||
void
|
||||
gst_d3d12_h264_dec_register (GstPlugin * plugin, GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device, guint rank, gboolean d3d11_interop)
|
||||
ID3D12VideoDevice * video_device, guint rank)
|
||||
{
|
||||
GType type;
|
||||
gchar *type_name;
|
||||
|
@ -347,7 +347,7 @@ gst_d3d12_h264_dec_register (GstPlugin * plugin, GstD3D12Device * device,
|
|||
|
||||
type_info.class_data =
|
||||
gst_d3d12_decoder_check_feature_support (device, video_device,
|
||||
GST_DXVA_CODEC_H264, d3d11_interop);
|
||||
GST_DXVA_CODEC_H264);
|
||||
if (!type_info.class_data)
|
||||
return;
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ G_BEGIN_DECLS
|
|||
void gst_d3d12_h264_dec_register (GstPlugin * plugin,
|
||||
GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device,
|
||||
guint rank,
|
||||
gboolean d3d11_interop);
|
||||
guint rank);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ gst_d3d12_h265_dec_output_picture (GstDxvaH265Decoder * decoder,
|
|||
|
||||
void
|
||||
gst_d3d12_h265_dec_register (GstPlugin * plugin, GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device, guint rank, gboolean d3d11_interop)
|
||||
ID3D12VideoDevice * video_device, guint rank)
|
||||
{
|
||||
GType type;
|
||||
gchar *type_name;
|
||||
|
@ -336,7 +336,7 @@ gst_d3d12_h265_dec_register (GstPlugin * plugin, GstD3D12Device * device,
|
|||
|
||||
type_info.class_data =
|
||||
gst_d3d12_decoder_check_feature_support (device, video_device,
|
||||
GST_DXVA_CODEC_H265, d3d11_interop);
|
||||
GST_DXVA_CODEC_H265);
|
||||
if (!type_info.class_data)
|
||||
return;
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ G_BEGIN_DECLS
|
|||
void gst_d3d12_h265_dec_register (GstPlugin * plugin,
|
||||
GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device,
|
||||
guint rank,
|
||||
gboolean d3d11_interop);
|
||||
guint rank);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -324,7 +324,7 @@ gst_d3d12_vp9_dec_output_picture (GstDxvaVp9Decoder * decoder,
|
|||
|
||||
void
|
||||
gst_d3d12_vp9_dec_register (GstPlugin * plugin, GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device, guint rank, gboolean d3d11_interop)
|
||||
ID3D12VideoDevice * video_device, guint rank)
|
||||
{
|
||||
GType type;
|
||||
gchar *type_name;
|
||||
|
@ -347,7 +347,7 @@ gst_d3d12_vp9_dec_register (GstPlugin * plugin, GstD3D12Device * device,
|
|||
|
||||
type_info.class_data =
|
||||
gst_d3d12_decoder_check_feature_support (device, video_device,
|
||||
GST_DXVA_CODEC_VP9, d3d11_interop);
|
||||
GST_DXVA_CODEC_VP9);
|
||||
if (!type_info.class_data)
|
||||
return;
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ G_BEGIN_DECLS
|
|||
void gst_d3d12_vp9_dec_register (GstPlugin * plugin,
|
||||
GstD3D12Device * device,
|
||||
ID3D12VideoDevice * video_device,
|
||||
guint rank,
|
||||
gboolean d3d11_interop);
|
||||
guint rank);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ dx_headers_dep = dependency('DirectX-Headers',
|
|||
allow_fallback: true,
|
||||
required: d3d12_option)
|
||||
|
||||
if not gstdxva_dep.found() or not gstd3d11_dep.found() or not d3d12_lib.found() or not dxgi_lib.found() or not dx_headers_dep.found()
|
||||
if not gstdxva_dep.found() or not d3d12_lib.found() or not dxgi_lib.found() or not dx_headers_dep.found()
|
||||
if d3d12_option.enabled()
|
||||
error('The d3d12 was enabled explicitly, but required GstD3D11 dependencies were not found.')
|
||||
endif
|
||||
|
@ -71,8 +71,7 @@ gstd3d12 = library('gstd3d12',
|
|||
cpp_args: gst_plugins_bad_args + extra_args,
|
||||
include_directories : [configinc],
|
||||
dependencies : [gstbase_dep, gstvideo_dep, gstcodecs_dep,
|
||||
gstdxva_dep, gstd3d11_dep, d3d12_lib, dxgi_lib,
|
||||
dx_headers_dep],
|
||||
gstdxva_dep, d3d12_lib, dxgi_lib, dx_headers_dep],
|
||||
install : true,
|
||||
install_dir : plugins_install_dir,
|
||||
)
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "gstd3d12av1dec.h"
|
||||
|
||||
#include <wrl.h>
|
||||
#include <d3d11_4.h>
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
using namespace Microsoft::WRL;
|
||||
|
@ -75,7 +74,6 @@ plugin_init (GstPlugin * plugin)
|
|||
ComPtr < ID3D12Device4 > device4;
|
||||
ComPtr < ID3D12VideoDevice > video_device;
|
||||
HRESULT hr;
|
||||
gboolean d3d11_interop = FALSE;
|
||||
|
||||
device = gst_d3d12_device_new (i);
|
||||
if (!device)
|
||||
|
@ -95,13 +93,13 @@ plugin_init (GstPlugin * plugin)
|
|||
}
|
||||
|
||||
gst_d3d12_h264_dec_register (plugin, device, video_device.Get (),
|
||||
GST_RANK_NONE, d3d11_interop);
|
||||
GST_RANK_NONE);
|
||||
gst_d3d12_h265_dec_register (plugin, device, video_device.Get (),
|
||||
GST_RANK_NONE, d3d11_interop);
|
||||
GST_RANK_NONE);
|
||||
gst_d3d12_vp9_dec_register (plugin, device, video_device.Get (),
|
||||
GST_RANK_NONE, d3d11_interop);
|
||||
GST_RANK_NONE);
|
||||
gst_d3d12_av1_dec_register (plugin, device, video_device.Get (),
|
||||
GST_RANK_NONE, d3d11_interop);
|
||||
GST_RANK_NONE);
|
||||
|
||||
gst_object_unref (device);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue