Revert "d3d11: Enable native multi-thread protection layer and make use of it"

This reverts commit 872b7f503c.

Native multi-thread protection layer seems to be consuming more CPU
resource than application side protection approach in some cases

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2095>
This commit is contained in:
Seungha Yang 2021-03-20 16:15:35 +09:00
parent e463bcfadf
commit 824b0ce0f4
18 changed files with 104 additions and 28 deletions

View file

@ -30,7 +30,6 @@
#include <windows.h>
#include <versionhelpers.h>
#include <d3d10.h>
/**
* SECTION:gstd3d11device
@ -106,11 +105,11 @@ struct _GstD3D11DevicePrivate
ID3D11VideoDevice *video_device;
ID3D11VideoContext *video_context;
ID3D10Multithread *multi_thread;
IDXGIFactory1 *factory;
GstD3D11Format format_table[GST_D3D11_N_FORMATS];
GRecMutex extern_lock;
GMutex resource_lock;
#if HAVE_D3D11SDKLAYERS_H
@ -413,6 +412,7 @@ gst_d3d11_device_init (GstD3D11Device * self)
priv = gst_d3d11_device_get_instance_private (self);
priv->adapter = DEFAULT_ADAPTER;
g_rec_mutex_init (&priv->extern_lock);
g_mutex_init (&priv->resource_lock);
self->priv = priv;
@ -784,20 +784,6 @@ gst_d3d11_device_constructed (GObject * object)
goto error;
}
hr = ID3D11Device_QueryInterface (priv->device, &IID_ID3D10Multithread,
(void **) &priv->multi_thread);
if (!gst_d3d11_result (hr, NULL)) {
GST_ERROR_OBJECT (self, "ID3D10Multithread interface is not available");
ID3D11Device_Release (priv->device);
priv->device = NULL;
ID3D11DeviceContext_Release (priv->device_context);
priv->device_context = NULL;
goto error;
}
ID3D10Multithread_SetMultithreadProtected (priv->multi_thread, TRUE);
priv->factory = factory;
#if HAVE_D3D11SDKLAYERS_H
@ -913,11 +899,6 @@ gst_d3d11_device_dispose (GObject * object)
GST_LOG_OBJECT (self, "dispose");
if (priv->multi_thread) {
ID3D10Multithread_Release (priv->multi_thread);
priv->multi_thread = NULL;
}
if (priv->video_device) {
ID3D11VideoDevice_Release (priv->video_device);
priv->video_device = NULL;
@ -985,6 +966,7 @@ gst_d3d11_device_finalize (GObject * object)
GST_LOG_OBJECT (self, "finalize");
g_rec_mutex_clear (&priv->extern_lock);
g_mutex_clear (&priv->resource_lock);
g_free (priv->description);
@ -1166,7 +1148,7 @@ gst_d3d11_device_lock (GstD3D11Device * device)
priv = device->priv;
GST_TRACE_OBJECT (device, "device locking");
ID3D10Multithread_Enter (priv->multi_thread);
g_rec_mutex_lock (&priv->extern_lock);
GST_TRACE_OBJECT (device, "device locked");
}
@ -1187,8 +1169,8 @@ gst_d3d11_device_unlock (GstD3D11Device * device)
g_return_if_fail (GST_IS_D3D11_DEVICE (device));
priv = device->priv;
ID3D10Multithread_Leave (priv->multi_thread);
g_rec_mutex_unlock (&priv->extern_lock);
GST_TRACE_OBJECT (device, "device unlocked");
}

View file

@ -347,6 +347,7 @@ map_cpu_access_data (GstD3D11Memory * dmem, D3D11_MAP map_type)
ID3D11DeviceContext *device_context =
gst_d3d11_device_get_device_context_handle (dmem->device);
gst_d3d11_device_lock (dmem->device);
if (GST_MEMORY_FLAG_IS_SET (dmem, GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD)) {
ID3D11DeviceContext_CopySubresourceRegion (device_context,
staging, 0, 0, 0, 0, texture, priv->subresource_index, NULL);
@ -361,6 +362,8 @@ map_cpu_access_data (GstD3D11Memory * dmem, D3D11_MAP map_type)
ret = FALSE;
}
gst_d3d11_device_unlock (dmem->device);
return ret;
}
@ -380,6 +383,7 @@ gst_d3d11_memory_map_staging (GstMemory * mem, GstMapFlags flags)
map_type = gst_map_flags_to_d3d11 (flags);
gst_d3d11_device_lock (dmem->device);
hr = ID3D11DeviceContext_Map (device_context,
(ID3D11Resource *) priv->texture, 0, map_type, 0, &priv->map);
if (!gst_d3d11_result (hr, dmem->device)) {
@ -387,6 +391,7 @@ gst_d3d11_memory_map_staging (GstMemory * mem, GstMapFlags flags)
"Failed to map staging texture (0x%x)", (guint) hr);
ret = FALSE;
}
gst_d3d11_device_unlock (dmem->device);
if (!ret) {
GST_D3D11_MEMORY_UNLOCK (dmem);
@ -420,9 +425,11 @@ gst_d3d11_memory_map (GstMemory * mem, gsize maxsize, GstMapFlags flags)
ID3D11DeviceContext *device_context =
gst_d3d11_device_get_device_context_handle (dmem->device);
gst_d3d11_device_lock (dmem->device);
ID3D11DeviceContext_CopySubresourceRegion (device_context,
(ID3D11Resource *) priv->texture, priv->subresource_index, 0, 0, 0,
(ID3D11Resource *) priv->staging, 0, NULL);
gst_d3d11_device_unlock (dmem->device);
}
GST_MEMORY_FLAG_UNSET (dmem, GST_D3D11_MEMORY_TRANSFER_NEED_UPLOAD);
@ -485,7 +492,9 @@ unmap_cpu_access_data (GstD3D11Memory * dmem)
if (priv->type == GST_D3D11_MEMORY_TYPE_STAGING)
staging = (ID3D11Resource *) priv->texture;
gst_d3d11_device_lock (dmem->device);
ID3D11DeviceContext_Unmap (device_context, staging, 0);
gst_d3d11_device_unlock (dmem->device);
}
static void
@ -684,6 +693,7 @@ calculate_mem_size (GstD3D11Device * device, ID3D11Texture2D * texture,
ID3D11DeviceContext *device_context =
gst_d3d11_device_get_device_context_handle (device);
gst_d3d11_device_lock (device);
hr = ID3D11DeviceContext_Map (device_context,
(ID3D11Resource *) texture, 0, map_type, 0, &map);
@ -697,6 +707,7 @@ calculate_mem_size (GstD3D11Device * device, ID3D11Texture2D * texture,
desc->Width, desc->Height, map.RowPitch, offset, stride, size);
ID3D11DeviceContext_Unmap (device_context, (ID3D11Resource *) texture, 0);
gst_d3d11_device_unlock (device);
return ret;
}

View file

@ -72,7 +72,7 @@ foreach d3d11_h: d3d11_headers
endif
endforeach
have_d3d11 = d3d11_lib.found() and dxgi_lib.found() and have_d3d11_header and have_dxgi_header and cc.has_header('d3d10.h')
have_d3d11 = d3d11_lib.found() and dxgi_lib.found() and have_d3d11_header and have_dxgi_header
if not have_d3d11
if d3d11_option.enabled()
error('The d3d11 was enabled explicitly, but required dependencies were not found.')

View file

@ -2187,7 +2187,6 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
ret = GST_FLOW_ERROR;
goto done;
}
gst_d3d11_device_unlock (self->device);
GST_OBJECT_LOCK (self);
@ -2224,7 +2223,7 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
}
}
if (!gst_d3d11_converter_convert(cpad->convert, srv, rtv,
if (!gst_d3d11_converter_convert_unlocked (cpad->convert, srv, rtv,
cpad->blend, cpad->blend_factor)) {
GST_ERROR_OBJECT (self, "Couldn't convert frame");
ret = GST_FLOW_ERROR;
@ -2232,6 +2231,7 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
}
}
GST_OBJECT_UNLOCK (self);
gst_d3d11_device_unlock (self->device);
if (ret != GST_FLOW_OK)
goto done;

View file

@ -1663,7 +1663,9 @@ create_shader_output_resource (GstD3D11BaseConvert * self,
}
}
gst_d3d11_device_lock (device);
clear_rtv_color_all (self, info, context_handle, view);
gst_d3d11_device_unlock (device);
self->num_output_view = i;
@ -1785,6 +1787,7 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
gboolean hardware = FALSE;
GstD3D11VideoProcessor *processor = NULL;
gst_d3d11_device_lock (filter->device);
g_object_get (filter->device, "hardware", &hardware, NULL);
if (hardware) {
processor = gst_d3d11_video_processor_new (filter->device,
@ -1828,6 +1831,7 @@ gst_d3d11_base_convert_set_info (GstD3D11BaseFilter * filter,
}
self->processor = processor;
gst_d3d11_device_unlock (filter->device);
}
#endif
@ -1983,7 +1987,9 @@ gst_d3d11_base_convert_transform_using_processor (GstD3D11BaseConvert * self,
return FALSE;
}
gst_d3d11_device_lock (bfilter->device);
clear_rtv_color_all (self, &bfilter->out_info, context_handle, render_view);
gst_d3d11_device_unlock (bfilter->device);
}
return gst_d3d11_video_processor_render (self->processor,
@ -2050,6 +2056,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
}
copy_input = TRUE;
gst_d3d11_device_lock (device);
for (i = 0; i < gst_buffer_n_memory (inbuf); i++) {
GstD3D11Memory *mem =
(GstD3D11Memory *) gst_buffer_peek_memory (inbuf, i);
@ -2073,6 +2080,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
context_handle->CopySubresourceRegion (self->in_texture[i], 0, 0, 0, 0,
(ID3D11Resource *) in_map[i].data, subidx, &src_box);
}
gst_d3d11_device_unlock (device);
}
/* Ensure render target views */
@ -2097,7 +2105,9 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
* area. Likely output texture was initialized with zeros which is fine for
* RGB, but it's not black color in case of YUV */
if (self->borders_w || self->borders_h) {
gst_d3d11_device_lock (device);
clear_rtv_color_all (self, &filter->out_info, context_handle, target_rtv);
gst_d3d11_device_unlock (device);
}
if (!gst_d3d11_converter_convert (self->converter,
@ -2107,6 +2117,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
}
if (copy_output) {
gst_d3d11_device_lock (device);
for (i = 0; i < gst_buffer_n_memory (outbuf); i++) {
GstD3D11Memory *mem =
(GstD3D11Memory *) gst_buffer_peek_memory (outbuf, i);
@ -2129,6 +2140,7 @@ gst_d3d11_base_convert_transform (GstBaseTransform * trans,
context_handle->CopySubresourceRegion ((ID3D11Resource *) out_map[i].data,
subidx, 0, 0, 0, self->out_texture[i], 0, &src_box);
}
gst_d3d11_device_unlock (device);
}
gst_d3d11_buffer_unmap (inbuf, in_map);

View file

@ -1136,11 +1136,13 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
return FALSE;
}
gst_d3d11_device_lock (device);
hr = context_handle->Map (const_buffer.Get (),
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
if (!gst_d3d11_result (hr, device)) {
GST_ERROR ("Couldn't map constant buffer, hr: 0x%x", (guint) hr);
gst_d3d11_device_unlock (device);
return FALSE;
}
@ -1148,6 +1150,7 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
sizeof (PixelShaderColorTransform));
context_handle->Unmap (const_buffer.Get (), 0);
gst_d3d11_device_unlock (device);
}
input_desc[0].SemanticName = "POSITION";
@ -1195,10 +1198,12 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
return FALSE;
}
gst_d3d11_device_lock (device);
hr = context_handle->Map (vertex_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
&map);
if (!gst_d3d11_result (hr, device)) {
GST_ERROR ("Couldn't map vertex buffer, hr: 0x%x", (guint) hr);
gst_d3d11_device_unlock (device);
return FALSE;
}
@ -1209,6 +1214,7 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
if (!gst_d3d11_result (hr, device)) {
GST_ERROR ("Couldn't map index buffer, hr: 0x%x", (guint) hr);
context_handle->Unmap (vertex_buffer.Get (), 0);
gst_d3d11_device_unlock (device);
return FALSE;
}
@ -1253,6 +1259,7 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
context_handle->Unmap (vertex_buffer.Get (), 0);
context_handle->Unmap (index_buffer.Get (), 0);
gst_d3d11_device_unlock (device);
self->quad[0] = gst_d3d11_quad_new (device,
ps[0].Get (), vs.Get (), layout.Get (), sampler.Get (), NULL, NULL,

View file

@ -661,6 +661,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * self)
video_device = self->video_device;
gst_d3d11_device_lock (self->device);
if (!gst_d3d11_decoder_get_supported_decoder_profile (self,
self->codec, GST_VIDEO_INFO_FORMAT (info), &selected_profile)) {
goto error;
@ -823,11 +824,13 @@ gst_d3d11_decoder_open (GstD3D11Decoder * self)
self->downstream_min_buffers = 0;
self->opened = TRUE;
gst_d3d11_device_unlock (self->device);
return TRUE;
error:
gst_d3d11_decoder_reset (self);
gst_d3d11_device_unlock (self->device);
return FALSE;
}
@ -848,8 +851,10 @@ gst_d3d11_decoder_begin_frame (GstD3D11Decoder * decoder,
do {
GST_LOG_OBJECT (decoder, "Try begin frame, retry count %d", retry_count);
gst_d3d11_device_lock (decoder->device);
hr = video_context->DecoderBeginFrame (decoder->decoder_handle,
output_view, content_key_size, content_key);
gst_d3d11_device_unlock (decoder->device);
/* HACK: Do 100 times retry with 1ms sleep per failure, since DXVA/D3D11
* doesn't provide API for "GPU-IS-READY-TO-DECODE" like signal.
@ -888,7 +893,9 @@ gst_d3d11_decoder_end_frame (GstD3D11Decoder * decoder)
video_context = decoder->video_context;
gst_d3d11_device_lock (decoder->device);
hr = video_context->DecoderEndFrame (decoder->decoder_handle);
gst_d3d11_device_unlock (decoder->device);
if (!gst_d3d11_result (hr, decoder->device)) {
GST_WARNING_OBJECT (decoder, "EndFrame failed, hr: 0x%x", (guint) hr);
@ -912,8 +919,10 @@ gst_d3d11_decoder_get_decoder_buffer (GstD3D11Decoder * decoder,
video_context = decoder->video_context;
gst_d3d11_device_lock (decoder->device);
hr = video_context->GetDecoderBuffer (decoder->decoder_handle,
type, &size, &decoder_buffer);
gst_d3d11_device_unlock (decoder->device);
if (!gst_d3d11_result (hr, decoder->device)) {
GST_WARNING_OBJECT (decoder, "Getting buffer type %d error, hr: 0x%x",
@ -938,7 +947,9 @@ gst_d3d11_decoder_release_decoder_buffer (GstD3D11Decoder * decoder,
video_context = decoder->video_context;
gst_d3d11_device_lock (decoder->device);
hr = video_context->ReleaseDecoderBuffer (decoder->decoder_handle, type);
gst_d3d11_device_unlock (decoder->device);
if (!gst_d3d11_result (hr, decoder->device)) {
GST_WARNING_OBJECT (decoder, "ReleaseDecoderBuffer failed, hr: 0x%x",
@ -960,8 +971,10 @@ gst_d3d11_decoder_submit_decoder_buffers (GstD3D11Decoder * decoder,
video_context = decoder->video_context;
gst_d3d11_device_lock (decoder->device);
hr = video_context->SubmitDecoderBuffers (decoder->decoder_handle,
buffer_count, buffers);
gst_d3d11_device_unlock (decoder->device);
if (!gst_d3d11_result (hr, decoder->device)) {
GST_WARNING_OBJECT (decoder, "SubmitDecoderBuffers failed, hr: 0x%x",
@ -1106,6 +1119,7 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
in_texture = gst_d3d11_memory_get_texture_handle (in_mem);
in_subresource_index = gst_d3d11_memory_get_subresource_index (in_mem);
gst_d3d11_device_lock (self->device);
device_context->CopySubresourceRegion (self->staging, 0, 0, 0, 0,
in_texture, in_subresource_index, NULL);
@ -1114,6 +1128,7 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
if (!gst_d3d11_result (hr, self->device)) {
GST_ERROR_OBJECT (self, "Failed to map, hr: 0x%x", (guint) hr);
gst_d3d11_device_unlock (self->device);
gst_video_frame_unmap (&out_frame);
return FALSE;
@ -1150,6 +1165,7 @@ copy_to_system (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
gst_video_frame_unmap (&out_frame);
device_context->Unmap (self->staging, 0);
gst_d3d11_device_unlock (self->device);
return TRUE;
}
@ -1176,6 +1192,7 @@ copy_to_d3d11 (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
return FALSE;
}
gst_d3d11_device_lock (self->device);
in_texture = gst_d3d11_memory_get_texture_handle (in_mem);
in_subresource_index = gst_d3d11_memory_get_subresource_index (in_mem);
@ -1192,6 +1209,7 @@ copy_to_d3d11 (GstD3D11Decoder * self, GstVideoInfo * info, gint display_width,
out_subresource_index, 0, 0, 0, in_texture, in_subresource_index,
&src_box);
gst_d3d11_device_unlock (self->device);
gst_memory_unmap (GST_MEMORY_CAST (out_mem), &out_map);
return TRUE;

View file

@ -1207,6 +1207,7 @@ gst_d3d11_deinterlace_set_caps (GstBaseTransform * trans,
if (self->method == GST_D3D11_DEINTERLACE_METHOD_BLEND)
output_rate = D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_HALF;
gst_d3d11_device_lock (self->device);
self->video_context->VideoProcessorSetStreamSourceRect (self->video_proc,
0, TRUE, &rect);
self->video_context->VideoProcessorSetStreamDestRect (self->video_proc,
@ -1217,6 +1218,7 @@ gst_d3d11_deinterlace_set_caps (GstBaseTransform * trans,
VideoProcessorSetStreamAutoProcessingMode (self->video_proc, 0, FALSE);
self->video_context->VideoProcessorSetStreamOutputRate (self->video_proc, 0,
output_rate, TRUE, NULL);
gst_d3d11_device_unlock (self->device);
return TRUE;
}
@ -1750,11 +1752,13 @@ gst_d3d11_deinterlace_transform (GstBaseTransform * trans, GstBuffer * inbuf,
proc_stream.ppPastSurfaces = past_surfaces;
}
gst_d3d11_device_lock (self->device);
self->video_context->VideoProcessorSetStreamFrameFormat (self->video_proc, 0,
frame_foramt);
hr = self->video_context->VideoProcessorBlt (self->video_proc, pov, 0,
1, &proc_stream);
gst_d3d11_device_unlock (self->device);
if (!gst_d3d11_result (hr, self->device)) {
GST_ERROR_OBJECT (self, "Failed to perform deinterlacing");

View file

@ -1820,8 +1820,10 @@ gst_d3d11_desktop_dup_capture (GstD3D11DesktopDup * desktop,
return ret;
}
gst_d3d11_device_lock (desktop->device);
ret = desktop->dupl_obj->Capture (draw_mouse);
if (ret != GST_FLOW_OK) {
gst_d3d11_device_unlock (desktop->device);
delete desktop->dupl_obj;
desktop->dupl_obj = nullptr;
@ -1834,6 +1836,7 @@ gst_d3d11_desktop_dup_capture (GstD3D11DesktopDup * desktop,
GST_ERROR_OBJECT (desktop, "Unexpected failure during capture");
}
g_rec_mutex_unlock (&desktop->lock);
return ret;
}
@ -1845,6 +1848,7 @@ gst_d3d11_desktop_dup_capture (GstD3D11DesktopDup * desktop,
desktop->texture, 0, nullptr);
if (draw_mouse)
desktop->dupl_obj->DrawMouse (rtv);
gst_d3d11_device_unlock (desktop->device);
g_rec_mutex_unlock (&desktop->lock);
return GST_FLOW_OK;

View file

@ -221,11 +221,13 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
return NULL;
}
gst_d3d11_device_lock (device);
hr = context_handle->Map (vertex_buffer.Get (),
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
if (!gst_d3d11_result (hr, device)) {
GST_ERROR ("Couldn't map vertex buffer, hr: 0x%x", (guint) hr);
gst_d3d11_device_unlock (device);
return NULL;
}
@ -276,6 +278,7 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
vertex_data[3].texture.y = 1.0f;
context_handle->Unmap (vertex_buffer.Get (), 0);
gst_d3d11_device_unlock (device);
overlay = g_new0 (GstD3D11CompositionOverlay, 1);
overlay->overlay_rect = gst_video_overlay_rectangle_ref (overlay_rect);
@ -411,11 +414,13 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self,
return FALSE;
}
gst_d3d11_device_lock (device);
hr = context_handle->Map (index_buffer.Get (),
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
if (!gst_d3d11_result (hr, device)) {
GST_ERROR ("Couldn't map index buffer, hr: 0x%x", (guint) hr);
gst_d3d11_device_unlock (device);
return FALSE;
}
@ -431,6 +436,7 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self,
indices[5] = 2; /* top right */
context_handle->Unmap (index_buffer.Get (), 0);
gst_d3d11_device_unlock (device);
self->ps = ps.Detach ();
self->vs = vs.Detach ();

View file

@ -833,8 +833,10 @@ gst_d3d11_buffer_copy_into (GstBuffer * dst, GstBuffer * src,
dst_subidx = gst_d3d11_memory_get_subresource_index (dst_dmem);
src_subidx = gst_d3d11_memory_get_subresource_index (src_dmem);
gst_d3d11_device_lock (device);
device_context->CopySubresourceRegion (dst_texture, dst_subidx, 0, 0, 0,
src_texture, src_subidx, &src_box);
gst_d3d11_device_unlock (device);
gst_memory_unmap (src_mem, &src_info);
gst_memory_unmap (dst_mem, &dst_info);

View file

@ -143,9 +143,11 @@ gst_d3d11_video_processor_new (GstD3D11Device * device, guint in_width,
#endif
/* Setting up default options */
gst_d3d11_device_lock (self->device);
/* We don't want auto processing by driver */
self->video_context->VideoProcessorSetStreamAutoProcessingMode
(self->processor, 0, FALSE);
gst_d3d11_device_unlock (self->device);
return self;
@ -493,8 +495,10 @@ gst_d3d11_video_processor_render (GstD3D11VideoProcessor * processor,
g_return_val_if_fail (in_view != NULL, FALSE);
g_return_val_if_fail (out_view != NULL, FALSE);
gst_d3d11_device_lock (processor->device);
ret = gst_d3d11_video_processor_render_unlocked (processor, in_rect, in_view,
out_rect, out_view);
gst_d3d11_device_unlock (processor->device);
return ret;
}

View file

@ -553,14 +553,13 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * window, guint width,
/* redraw the last scene if cached buffer exits */
if (window->cached_buffer) {
gst_d3d11_device_unlock (window->device);
gst_d3d111_window_present (window, window->cached_buffer, NULL,
window->pov, window->rtv);
gst_d3d11_device_lock (window->device);
}
done:
GST_D3D11_CLEAR_COM (backbuffer);
gst_d3d11_device_unlock (window->device);
}
@ -731,6 +730,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
swapchain_flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
}
gst_d3d11_device_lock (window->device);
window->dxgi_format = chosen_format->dxgi_format;
klass = GST_D3D11_WINDOW_GET_CLASS (window);
@ -943,6 +943,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
if (window->render_stats)
gst_d3d11_window_prepare_dwrite_device (window);
#endif
gst_d3d11_device_unlock (window->device);
/* call resize to allocated resources */
klass->on_resize (window, display_width, display_height);
@ -956,6 +957,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
return TRUE;
error:
gst_d3d11_device_unlock (window->device);
return FALSE;
}
@ -1214,10 +1216,12 @@ gst_d3d11_window_render (GstD3D11Window * window, GstBuffer * buffer,
return GST_FLOW_ERROR;
}
gst_d3d11_device_lock (window->device);
gst_buffer_replace (&window->cached_buffer, buffer);
ret = gst_d3d111_window_present (window, window->cached_buffer, stats,
window->pov, window->rtv);
gst_d3d11_device_unlock (window->device);
if (stats)
gst_structure_free (stats);
@ -1256,8 +1260,10 @@ gst_d3d11_window_render_on_shared_handle (GstD3D11Window * window,
data.acquire_key = acquire_key;
data.release_key = release_key;
gst_d3d11_device_lock (window->device);
if (!klass->open_shared_handle (window, &data)) {
GST_ERROR_OBJECT (window, "Couldn't open shared handle");
gst_d3d11_device_unlock (window->device);
return GST_FLOW_OK;
}
@ -1272,6 +1278,7 @@ gst_d3d11_window_render_on_shared_handle (GstD3D11Window * window,
ret = gst_d3d111_window_present (window, buffer, NULL, pov, rtv);
klass->release_shared_handle (window, &data);
gst_d3d11_device_unlock (window->device);
return ret;
}
@ -1305,7 +1312,9 @@ gst_d3d11_window_unlock_stop (GstD3D11Window * window)
if (klass->unlock_stop)
ret = klass->unlock_stop (window);
gst_d3d11_device_lock (window->device);
gst_clear_buffer (&window->cached_buffer);
gst_d3d11_device_unlock (window->device);
return ret;
}

View file

@ -393,8 +393,10 @@ create_swap_chain_for_core_window (GstD3D11WindowCoreWindow * self,
return NULL;
}
gst_d3d11_device_lock (device);
hr = factory2->CreateSwapChainForCoreWindow ((IUnknown *) device_handle,
(IUnknown *) core_window, desc, output, &swap_chain);
gst_d3d11_device_unlock (device);
if (!gst_d3d11_result (hr, device)) {
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",

View file

@ -116,6 +116,8 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
window->render_info.colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
window->render_info.colorimetry.range = GST_VIDEO_COLOR_RANGE_0_255;
gst_d3d11_device_lock (window->device);
#if (GST_D3D11_DXGI_HEADER_VERSION >= 4)
{
const GstDxgiColorSpace *in_color_space =
@ -192,6 +194,8 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
goto error;
}
gst_d3d11_device_unlock (window->device);
return TRUE;
error:

View file

@ -367,8 +367,10 @@ create_swap_chain_for_composition (GstD3D11WindowSwapChainPanel * self,
return NULL;
}
gst_d3d11_device_lock (device);
hr = factory2->CreateSwapChainForComposition ((IUnknown *) device_handle,
desc, output, &swap_chain);
gst_d3d11_device_unlock (device);
if (!gst_d3d11_result (hr, device)) {
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",

View file

@ -761,7 +761,9 @@ create_swap_chain (GstD3D11WindowWin32 * self, GstD3D11Device * device,
ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device);
IDXGIFactory1 *factory = gst_d3d11_device_get_dxgi_factory_handle (device);
gst_d3d11_device_lock (device);
hr = factory->CreateSwapChain ((IUnknown *) device_handle, desc, &swap_chain);
gst_d3d11_device_unlock (device);
if (!gst_d3d11_result (hr, device)) {
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
@ -790,9 +792,11 @@ create_swap_chain_for_hwnd (GstD3D11WindowWin32 * self, GstD3D11Device * device,
return NULL;
}
gst_d3d11_device_lock (device);
hr = factory2->CreateSwapChainForHwnd (
(IUnknown *) device_handle, hwnd, desc, fullscreen_desc,
output, &swap_chain);
gst_d3d11_device_unlock (device);
if (!gst_d3d11_result (hr, device)) {
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
@ -885,8 +889,10 @@ gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
}
/* disable alt+enter here. It should be manually handled */
gst_d3d11_device_lock (device);
gst_d3d11_window_win32_disable_alt_enter (self,
device, new_swapchain, desc.OutputWindow);
gst_d3d11_device_unlock (device);
*swap_chain = new_swapchain;

View file

@ -1037,6 +1037,7 @@ gst_mf_video_enc_create_input_sample_d3d11 (GstMFVideoEnc * self,
return FALSE;
}
gst_d3d11_device_lock (dmem->device);
context_handle->CopySubresourceRegion (shared_texture.Get (), 0, 0, 0, 0,
texture, subidx, &src_box);
context_handle->End (query.Get());
@ -1048,11 +1049,13 @@ gst_mf_video_enc_create_input_sample_d3d11 (GstMFVideoEnc * self,
if (!gst_d3d11_result (hr, dmem->device)) {
GST_ERROR_OBJECT (self, "Couldn't sync GPU operation");
gst_d3d11_device_unlock (dmem->device);
gst_memory_unmap (mem, &info);
return FALSE;
}
gst_d3d11_device_unlock (dmem->device);
gst_memory_unmap (mem, &info);
*sample = new_sample.Detach ();