d3d11: Use scoped device lock
Make code simpler and more deadlock-free Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2728>
This commit is contained in:
parent
dfea5070df
commit
b09ca8635f
@ -19,12 +19,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <gst/d3d11/gstd3d11_fwd.h>
|
|
||||||
#include <d3d11_4.h>
|
#include <d3d11_4.h>
|
||||||
#include <dxgi1_6.h>
|
#include <dxgi1_6.h>
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/video/video.h>
|
||||||
#include <gst/d3d11/gstd3d11format.h>
|
#include <gst/d3d11/gstd3d11format.h>
|
||||||
|
#include <gst/d3d11/gstd3d11device.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -112,3 +113,24 @@ static const GstD3D11Format _gst_d3d11_default_format_map[] = {
|
|||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
class GstD3D11DeviceLockGuard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit GstD3D11DeviceLockGuard(GstD3D11Device * device) : device_ (device)
|
||||||
|
{
|
||||||
|
gst_d3d11_device_lock (device_);
|
||||||
|
}
|
||||||
|
|
||||||
|
~GstD3D11DeviceLockGuard()
|
||||||
|
{
|
||||||
|
gst_d3d11_device_unlock (device_);
|
||||||
|
}
|
||||||
|
|
||||||
|
GstD3D11DeviceLockGuard(const GstD3D11DeviceLockGuard&) = delete;
|
||||||
|
GstD3D11DeviceLockGuard& operator=(const GstD3D11DeviceLockGuard&) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
GstD3D11Device *device_;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
@ -383,8 +383,8 @@ gst_d3d11_memory_map_full (GstMemory * mem, GstMapInfo * info, gsize maxsize)
|
|||||||
GstD3D11MemoryPrivate *priv = dmem->priv;
|
GstD3D11MemoryPrivate *priv = dmem->priv;
|
||||||
GstMapFlags flags = info->flags;
|
GstMapFlags flags = info->flags;
|
||||||
gpointer ret = NULL;
|
gpointer ret = NULL;
|
||||||
|
GstD3D11DeviceLockGuard lk (dmem->device);
|
||||||
|
|
||||||
gst_d3d11_device_lock (dmem->device);
|
|
||||||
GST_D3D11_MEMORY_LOCK (dmem);
|
GST_D3D11_MEMORY_LOCK (dmem);
|
||||||
|
|
||||||
memset (info->user_data, 0, sizeof (info->user_data));
|
memset (info->user_data, 0, sizeof (info->user_data));
|
||||||
@ -448,7 +448,6 @@ gst_d3d11_memory_map_full (GstMemory * mem, GstMapInfo * info, gsize maxsize)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
GST_D3D11_MEMORY_UNLOCK (dmem);
|
GST_D3D11_MEMORY_UNLOCK (dmem);
|
||||||
gst_d3d11_device_unlock (dmem->device);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -469,8 +468,8 @@ gst_d3d11_memory_unmap_full (GstMemory * mem, GstMapInfo * info)
|
|||||||
{
|
{
|
||||||
GstD3D11Memory *dmem = GST_D3D11_MEMORY_CAST (mem);
|
GstD3D11Memory *dmem = GST_D3D11_MEMORY_CAST (mem);
|
||||||
GstD3D11MemoryPrivate *priv = dmem->priv;
|
GstD3D11MemoryPrivate *priv = dmem->priv;
|
||||||
|
GstD3D11DeviceLockGuard lk (dmem->device);
|
||||||
|
|
||||||
gst_d3d11_device_lock (dmem->device);
|
|
||||||
GST_D3D11_MEMORY_LOCK (dmem);
|
GST_D3D11_MEMORY_LOCK (dmem);
|
||||||
|
|
||||||
if ((info->flags & GST_MAP_D3D11) == GST_MAP_D3D11) {
|
if ((info->flags & GST_MAP_D3D11) == GST_MAP_D3D11) {
|
||||||
@ -491,7 +490,6 @@ gst_d3d11_memory_unmap_full (GstMemory * mem, GstMapInfo * info)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
GST_D3D11_MEMORY_UNLOCK (dmem);
|
GST_D3D11_MEMORY_UNLOCK (dmem);
|
||||||
gst_d3d11_device_unlock (dmem->device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstMemory *
|
static GstMemory *
|
||||||
@ -521,7 +519,8 @@ gst_d3d11_memory_update_size (GstMemory * mem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (dmem->device);
|
GstD3D11DeviceLockGuard lk (dmem->device);
|
||||||
|
|
||||||
if (!gst_d3d11_memory_map_cpu_access (dmem, D3D11_MAP_READ_WRITE)) {
|
if (!gst_d3d11_memory_map_cpu_access (dmem, D3D11_MAP_READ_WRITE)) {
|
||||||
GST_ERROR_OBJECT (mem->allocator, "Couldn't map staging texture");
|
GST_ERROR_OBJECT (mem->allocator, "Couldn't map staging texture");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -540,7 +539,6 @@ gst_d3d11_memory_update_size (GstMemory * mem)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
GST_D3D11_CLEAR_COM (priv->staging);
|
GST_D3D11_CLEAR_COM (priv->staging);
|
||||||
gst_d3d11_device_unlock (dmem->device);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1326,10 +1324,10 @@ gst_d3d11_memory_copy (GstMemory * mem, gssize offset, gssize size)
|
|||||||
return priv->fallback_copy (mem, offset, size);
|
return priv->fallback_copy (mem, offset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
|
|
||||||
if (!gst_memory_map (mem, &info,
|
if (!gst_memory_map (mem, &info,
|
||||||
(GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
(GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
GST_WARNING_OBJECT (alloc, "Failed to map memory, try fallback copy");
|
GST_WARNING_OBJECT (alloc, "Failed to map memory, try fallback copy");
|
||||||
|
|
||||||
@ -1362,7 +1360,6 @@ gst_d3d11_memory_copy (GstMemory * mem, gssize offset, gssize size)
|
|||||||
copy = gst_d3d11_allocator_alloc_internal (alloc, device, &dst_desc, nullptr);
|
copy = gst_d3d11_allocator_alloc_internal (alloc, device, &dst_desc, nullptr);
|
||||||
if (!copy) {
|
if (!copy) {
|
||||||
gst_memory_unmap (mem, &info);
|
gst_memory_unmap (mem, &info);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
GST_WARNING_OBJECT (alloc,
|
GST_WARNING_OBJECT (alloc,
|
||||||
"Failed to allocate new d3d11 map memory, try fallback copy");
|
"Failed to allocate new d3d11 map memory, try fallback copy");
|
||||||
@ -1375,7 +1372,6 @@ gst_d3d11_memory_copy (GstMemory * mem, gssize offset, gssize size)
|
|||||||
dmem->priv->texture, dmem->priv->subresource_index, NULL);
|
dmem->priv->texture, dmem->priv->subresource_index, NULL);
|
||||||
copy->maxsize = copy->size = mem->maxsize;
|
copy->maxsize = copy->size = mem->maxsize;
|
||||||
gst_memory_unmap (mem, &info);
|
gst_memory_unmap (mem, &info);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
/* newly allocated memory holds valid image data. We need download this
|
/* newly allocated memory holds valid image data. We need download this
|
||||||
* pixel data into staging memory for CPU access */
|
* pixel data into staging memory for CPU access */
|
||||||
@ -1541,9 +1537,8 @@ gst_d3d11_allocator_alloc_internal (GstD3D11Allocator * self,
|
|||||||
return mem;
|
return mem;
|
||||||
|
|
||||||
context_handle = gst_d3d11_device_get_device_context_handle (device);
|
context_handle = gst_d3d11_device_get_device_context_handle (device);
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
clear_func (context_handle, rtv);
|
clear_func (context_handle, rtv);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
@ -2046,29 +2046,26 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
|
|||||||
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES] = { nullptr, };
|
ID3D11RenderTargetView *rtv[GST_VIDEO_MAX_PLANES] = { nullptr, };
|
||||||
GstVideoFrame target_frame;
|
GstVideoFrame target_frame;
|
||||||
guint num_rtv = GST_VIDEO_INFO_N_PLANES (&vagg->info);
|
guint num_rtv = GST_VIDEO_INFO_N_PLANES (&vagg->info);
|
||||||
|
GstD3D11DeviceLockGuard lk (self->device);
|
||||||
|
|
||||||
if (!self->downstream_supports_d3d11)
|
if (!self->downstream_supports_d3d11)
|
||||||
target_buf = self->fallback_buf;
|
target_buf = self->fallback_buf;
|
||||||
|
|
||||||
gst_d3d11_device_lock (self->device);
|
|
||||||
if (!gst_video_frame_map (&target_frame, &vagg->info, target_buf,
|
if (!gst_video_frame_map (&target_frame, &vagg->info, target_buf,
|
||||||
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map render target frame");
|
GST_ERROR_OBJECT (self, "Failed to map render target frame");
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_d3d11_buffer_get_render_target_view (target_buf, rtv)) {
|
if (!gst_d3d11_buffer_get_render_target_view (target_buf, rtv)) {
|
||||||
GST_ERROR_OBJECT (self, "RTV is unavailable");
|
GST_ERROR_OBJECT (self, "RTV is unavailable");
|
||||||
gst_video_frame_unmap (&target_frame);
|
gst_video_frame_unmap (&target_frame);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_d3d11_compositor_draw_background (self, rtv, num_rtv)) {
|
if (!gst_d3d11_compositor_draw_background (self, rtv, num_rtv)) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't draw background");
|
GST_ERROR_OBJECT (self, "Couldn't draw background");
|
||||||
gst_video_frame_unmap (&target_frame);
|
gst_video_frame_unmap (&target_frame);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2098,7 +2095,6 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
|
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1596,7 +1596,6 @@ gst_d3d11_base_convert_crop_and_copy (GstD3D11BaseConvert * self,
|
|||||||
guint in_subresource;
|
guint in_subresource;
|
||||||
guint out_subresource;
|
guint out_subresource;
|
||||||
ID3D11Texture2D *in_tex, *out_tex;
|
ID3D11Texture2D *in_tex, *out_tex;
|
||||||
gboolean ret = FALSE;
|
|
||||||
|
|
||||||
/* Copy into output memory */
|
/* Copy into output memory */
|
||||||
in_mem = gst_buffer_peek_memory (inbuf, 0);
|
in_mem = gst_buffer_peek_memory (inbuf, 0);
|
||||||
@ -1636,18 +1635,18 @@ gst_d3d11_base_convert_crop_and_copy (GstD3D11BaseConvert * self,
|
|||||||
in_subresource = gst_d3d11_memory_get_subresource_index (in_dmem);
|
in_subresource = gst_d3d11_memory_get_subresource_index (in_dmem);
|
||||||
out_subresource = gst_d3d11_memory_get_subresource_index (out_dmem);
|
out_subresource = gst_d3d11_memory_get_subresource_index (out_dmem);
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
if (!gst_memory_map (in_mem, &in_map,
|
if (!gst_memory_map (in_mem, &in_map,
|
||||||
(GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
(GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map input memory");
|
GST_ERROR_OBJECT (self, "Failed to map input memory");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_memory_map (out_mem, &out_map,
|
if (!gst_memory_map (out_mem, &out_map,
|
||||||
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map output memory");
|
GST_ERROR_OBJECT (self, "Failed to map output memory");
|
||||||
gst_memory_unmap (in_mem, &in_map);
|
gst_memory_unmap (in_mem, &in_map);
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_tex = (ID3D11Texture2D *) in_map.data;
|
in_tex = (ID3D11Texture2D *) in_map.data;
|
||||||
@ -1658,10 +1657,8 @@ gst_d3d11_base_convert_crop_and_copy (GstD3D11BaseConvert * self,
|
|||||||
gst_memory_unmap (in_mem, &in_map);
|
gst_memory_unmap (in_mem, &in_map);
|
||||||
gst_memory_unmap (out_mem, &out_map);
|
gst_memory_unmap (out_mem, &out_map);
|
||||||
|
|
||||||
if (gst_buffer_n_memory (inbuf) == 1) {
|
if (gst_buffer_n_memory (inbuf) == 1)
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
/* Non-native DXGI format YUV cases, copy UV plane(s) */
|
/* Non-native DXGI format YUV cases, copy UV plane(s) */
|
||||||
switch (format) {
|
switch (format) {
|
||||||
@ -1698,7 +1695,7 @@ gst_d3d11_base_convert_crop_and_copy (GstD3D11BaseConvert * self,
|
|||||||
default:
|
default:
|
||||||
GST_ERROR_OBJECT (self, "Unexpected format %s",
|
GST_ERROR_OBJECT (self, "Unexpected format %s",
|
||||||
gst_video_format_to_string (format));
|
gst_video_format_to_string (format));
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_TRACE_OBJECT (self, "UV left:top:right:bottom = %d, %d, %d, %d",
|
GST_TRACE_OBJECT (self, "UV left:top:right:bottom = %d, %d, %d, %d",
|
||||||
@ -1710,12 +1707,12 @@ gst_d3d11_base_convert_crop_and_copy (GstD3D11BaseConvert * self,
|
|||||||
|
|
||||||
if (!gst_is_d3d11_memory (in_mem)) {
|
if (!gst_is_d3d11_memory (in_mem)) {
|
||||||
GST_ERROR_OBJECT (self, "Input is not a d3d11 memory");
|
GST_ERROR_OBJECT (self, "Input is not a d3d11 memory");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_is_d3d11_memory (out_mem)) {
|
if (!gst_is_d3d11_memory (out_mem)) {
|
||||||
GST_ERROR_OBJECT (self, "Output is not a d3d11 memory");
|
GST_ERROR_OBJECT (self, "Output is not a d3d11 memory");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_dmem = GST_D3D11_MEMORY_CAST (in_mem);
|
in_dmem = GST_D3D11_MEMORY_CAST (in_mem);
|
||||||
@ -1723,7 +1720,7 @@ gst_d3d11_base_convert_crop_and_copy (GstD3D11BaseConvert * self,
|
|||||||
|
|
||||||
if (in_dmem->device != out_dmem->device) {
|
if (in_dmem->device != out_dmem->device) {
|
||||||
GST_ERROR_OBJECT (self, "Different device");
|
GST_ERROR_OBJECT (self, "Different device");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_subresource = gst_d3d11_memory_get_subresource_index (in_dmem);
|
in_subresource = gst_d3d11_memory_get_subresource_index (in_dmem);
|
||||||
@ -1732,14 +1729,14 @@ gst_d3d11_base_convert_crop_and_copy (GstD3D11BaseConvert * self,
|
|||||||
if (!gst_memory_map (in_mem, &in_map,
|
if (!gst_memory_map (in_mem, &in_map,
|
||||||
(GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
(GstMapFlags) (GST_MAP_READ | GST_MAP_D3D11))) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map input memory");
|
GST_ERROR_OBJECT (self, "Failed to map input memory");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_memory_map (out_mem, &out_map,
|
if (!gst_memory_map (out_mem, &out_map,
|
||||||
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map output memory");
|
GST_ERROR_OBJECT (self, "Failed to map output memory");
|
||||||
gst_memory_unmap (in_mem, &in_map);
|
gst_memory_unmap (in_mem, &in_map);
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_tex = (ID3D11Texture2D *) in_map.data;
|
in_tex = (ID3D11Texture2D *) in_map.data;
|
||||||
@ -1751,11 +1748,7 @@ gst_d3d11_base_convert_crop_and_copy (GstD3D11BaseConvert * self,
|
|||||||
gst_memory_unmap (out_mem, &out_map);
|
gst_memory_unmap (out_mem, &out_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
|
|
||||||
out:
|
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -1264,13 +1264,12 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
hr = context_handle->Map (const_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
hr = context_handle->Map (const_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
||||||
&map);
|
&map);
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_ERROR_OBJECT (self,
|
GST_ERROR_OBJECT (self,
|
||||||
"Couldn't map constant buffer, hr: 0x%x", (guint) hr);
|
"Couldn't map constant buffer, hr: 0x%x", (guint) hr);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1281,7 +1280,6 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
|
|||||||
&map);
|
&map);
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't map vertex buffer, hr: 0x%x", (guint) hr);
|
GST_ERROR_OBJECT (self, "Couldn't map vertex buffer, hr: 0x%x", (guint) hr);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1292,7 +1290,6 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
|
|||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't map index buffer, hr: 0x%x", (guint) hr);
|
GST_ERROR_OBJECT (self, "Couldn't map index buffer, hr: 0x%x", (guint) hr);
|
||||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1337,7 +1334,6 @@ gst_d3d11_color_convert_setup_shader (GstD3D11Converter * self,
|
|||||||
|
|
||||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||||
context_handle->Unmap (index_buffer.Get (), 0);
|
context_handle->Unmap (index_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
/* holds vertex buffer for crop rect update */
|
/* holds vertex buffer for crop rect update */
|
||||||
priv->vertex_buffer = vertex_buffer.Detach ();
|
priv->vertex_buffer = vertex_buffer.Detach ();
|
||||||
@ -2811,7 +2807,7 @@ gst_d3d11_converter_setup_processor (GstD3D11Converter * self)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
/* We don't want auto processing by driver */
|
/* We don't want auto processing by driver */
|
||||||
video_context1->VideoProcessorSetStreamAutoProcessingMode
|
video_context1->VideoProcessorSetStreamAutoProcessingMode
|
||||||
(processor.Get (), 0, FALSE);
|
(processor.Get (), 0, FALSE);
|
||||||
@ -2819,7 +2815,6 @@ gst_d3d11_converter_setup_processor (GstD3D11Converter * self)
|
|||||||
0, (DXGI_COLOR_SPACE_TYPE) in_space.dxgi_color_space_type);
|
0, (DXGI_COLOR_SPACE_TYPE) in_space.dxgi_color_space_type);
|
||||||
video_context1->VideoProcessorSetOutputColorSpace1 (processor.Get (),
|
video_context1->VideoProcessorSetOutputColorSpace1 (processor.Get (),
|
||||||
(DXGI_COLOR_SPACE_TYPE) in_space.dxgi_color_space_type);
|
(DXGI_COLOR_SPACE_TYPE) in_space.dxgi_color_space_type);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
priv->video_device = video_device;
|
priv->video_device = video_device;
|
||||||
video_device->AddRef ();
|
video_device->AddRef ();
|
||||||
@ -3795,18 +3790,14 @@ gboolean
|
|||||||
gst_d3d11_converter_convert_buffer (GstD3D11Converter * converter,
|
gst_d3d11_converter_convert_buffer (GstD3D11Converter * converter,
|
||||||
GstBuffer * in_buf, GstBuffer * out_buf)
|
GstBuffer * in_buf, GstBuffer * out_buf)
|
||||||
{
|
{
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_D3D11_CONVERTER (converter), FALSE);
|
g_return_val_if_fail (GST_IS_D3D11_CONVERTER (converter), FALSE);
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (in_buf), FALSE);
|
g_return_val_if_fail (GST_IS_BUFFER (in_buf), FALSE);
|
||||||
g_return_val_if_fail (GST_IS_BUFFER (out_buf), FALSE);
|
g_return_val_if_fail (GST_IS_BUFFER (out_buf), FALSE);
|
||||||
|
|
||||||
gst_d3d11_device_lock (converter->device);
|
GstD3D11DeviceLockGuard lk (converter->device);
|
||||||
ret = gst_d3d11_converter_convert_buffer_internal (converter,
|
|
||||||
in_buf, out_buf);
|
|
||||||
gst_d3d11_device_unlock (converter->device);
|
|
||||||
|
|
||||||
return ret;
|
return gst_d3d11_converter_convert_buffer_internal (converter,
|
||||||
|
in_buf, out_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -833,6 +833,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * self)
|
|||||||
GstD3D11DeviceVendor vendor;
|
GstD3D11DeviceVendor vendor;
|
||||||
ID3D11VideoDevice *video_device;
|
ID3D11VideoDevice *video_device;
|
||||||
GstVideoInfo *info = &self->info;
|
GstVideoInfo *info = &self->info;
|
||||||
|
GstD3D11DeviceLockGuard lk (self->device);
|
||||||
|
|
||||||
if (self->opened)
|
if (self->opened)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -844,7 +845,6 @@ gst_d3d11_decoder_open (GstD3D11Decoder * self)
|
|||||||
|
|
||||||
video_device = self->video_device;
|
video_device = self->video_device;
|
||||||
|
|
||||||
gst_d3d11_device_lock (self->device);
|
|
||||||
if (!gst_d3d11_decoder_get_supported_decoder_profile (self->device,
|
if (!gst_d3d11_decoder_get_supported_decoder_profile (self->device,
|
||||||
self->codec, GST_VIDEO_INFO_FORMAT (info), &selected_profile)) {
|
self->codec, GST_VIDEO_INFO_FORMAT (info), &selected_profile)) {
|
||||||
goto error;
|
goto error;
|
||||||
@ -1001,7 +1001,6 @@ gst_d3d11_decoder_open (GstD3D11Decoder * self)
|
|||||||
self->wait_on_pool_full = FALSE;
|
self->wait_on_pool_full = FALSE;
|
||||||
|
|
||||||
self->opened = TRUE;
|
self->opened = TRUE;
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
|
|
||||||
gst_d3d11_decoder_enable_high_precision_timer (self);
|
gst_d3d11_decoder_enable_high_precision_timer (self);
|
||||||
|
|
||||||
@ -1009,7 +1008,6 @@ gst_d3d11_decoder_open (GstD3D11Decoder * self)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
gst_d3d11_decoder_reset (self);
|
gst_d3d11_decoder_reset (self);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1175,12 +1173,9 @@ gst_d3d11_decoder_decode_frame (GstD3D11Decoder * decoder,
|
|||||||
buffer_desc_size++;
|
buffer_desc_size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (decoder->device);
|
GstD3D11DeviceLockGuard lk (decoder->device);
|
||||||
if (!gst_d3d11_decoder_begin_frame (decoder, output_view, 0, nullptr)) {
|
if (!gst_d3d11_decoder_begin_frame (decoder, output_view, 0, nullptr))
|
||||||
gst_d3d11_device_unlock (decoder->device);
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (!gst_d3d11_decoder_get_decoder_buffer (decoder,
|
if (!gst_d3d11_decoder_get_decoder_buffer (decoder,
|
||||||
D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS, &d3d11_buffer_size,
|
D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS, &d3d11_buffer_size,
|
||||||
@ -1293,18 +1288,13 @@ gst_d3d11_decoder_decode_frame (GstD3D11Decoder * decoder,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_d3d11_decoder_end_frame (decoder)) {
|
if (!gst_d3d11_decoder_end_frame (decoder))
|
||||||
gst_d3d11_device_unlock (decoder->device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
gst_d3d11_device_unlock (decoder->device);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
gst_d3d11_decoder_end_frame (decoder);
|
gst_d3d11_decoder_end_frame (decoder);
|
||||||
gst_d3d11_device_unlock (decoder->device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1415,6 +1405,7 @@ gst_d3d11_decoder_crop_and_copy_texture (GstD3D11Decoder * self,
|
|||||||
ID3D11DeviceContext *context =
|
ID3D11DeviceContext *context =
|
||||||
gst_d3d11_device_get_device_context_handle (device);
|
gst_d3d11_device_get_device_context_handle (device);
|
||||||
D3D11_BOX src_box = { 0, };
|
D3D11_BOX src_box = { 0, };
|
||||||
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
|
|
||||||
src_box.left = self->offset_x;
|
src_box.left = self->offset_x;
|
||||||
src_box.top = self->offset_y;
|
src_box.top = self->offset_y;
|
||||||
@ -1423,10 +1414,8 @@ gst_d3d11_decoder_crop_and_copy_texture (GstD3D11Decoder * self,
|
|||||||
src_box.front = 0;
|
src_box.front = 0;
|
||||||
src_box.back = 1;
|
src_box.back = 1;
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
|
||||||
context->CopySubresourceRegion (dst_texture, dst_subresource,
|
context->CopySubresourceRegion (dst_texture, dst_subresource,
|
||||||
0, 0, 0, src_texture, src_subresource, &src_box);
|
0, 0, 0, src_texture, src_subresource, &src_box);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1472,6 +1461,7 @@ gst_d3d11_decoder_crop_and_copy_buffer (GstD3D11Decoder * self,
|
|||||||
if (!gst_d3d11_decoder_ensure_staging_texture (self))
|
if (!gst_d3d11_decoder_ensure_staging_texture (self))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
if (!gst_video_frame_map (&frame, &self->output_info, dst, GST_MAP_WRITE)) {
|
if (!gst_video_frame_map (&frame, &self->output_info, dst, GST_MAP_WRITE)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map output buffer");
|
GST_ERROR_OBJECT (self, "Failed to map output buffer");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1480,11 +1470,9 @@ gst_d3d11_decoder_crop_and_copy_buffer (GstD3D11Decoder * self,
|
|||||||
gst_d3d11_decoder_crop_and_copy_texture (self, src_texture, src_subresource,
|
gst_d3d11_decoder_crop_and_copy_texture (self, src_texture, src_subresource,
|
||||||
self->staging, 0);
|
self->staging, 0);
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
|
||||||
hr = context->Map (self->staging, 0, D3D11_MAP_READ, 0, &d3d11_map);
|
hr = context->Map (self->staging, 0, D3D11_MAP_READ, 0, &d3d11_map);
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map staging texture");
|
GST_ERROR_OBJECT (self, "Failed to map staging texture");
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
gst_video_frame_unmap (&frame);
|
gst_video_frame_unmap (&frame);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1507,7 +1495,6 @@ gst_d3d11_decoder_crop_and_copy_buffer (GstD3D11Decoder * self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
context->Unmap (self->staging, 0);
|
context->Unmap (self->staging, 0);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
gst_video_frame_unmap (&frame);
|
gst_video_frame_unmap (&frame);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1210,7 +1210,7 @@ gst_d3d11_deinterlace_set_caps (GstBaseTransform * trans,
|
|||||||
if (self->method == GST_D3D11_DEINTERLACE_METHOD_BLEND)
|
if (self->method == GST_D3D11_DEINTERLACE_METHOD_BLEND)
|
||||||
output_rate = D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_HALF;
|
output_rate = D3D11_VIDEO_PROCESSOR_OUTPUT_RATE_HALF;
|
||||||
|
|
||||||
gst_d3d11_device_lock (self->device);
|
GstD3D11DeviceLockGuard lk (self->device);
|
||||||
self->video_context->VideoProcessorSetStreamSourceRect (self->video_proc,
|
self->video_context->VideoProcessorSetStreamSourceRect (self->video_proc,
|
||||||
0, TRUE, &rect);
|
0, TRUE, &rect);
|
||||||
self->video_context->VideoProcessorSetStreamDestRect (self->video_proc,
|
self->video_context->VideoProcessorSetStreamDestRect (self->video_proc,
|
||||||
@ -1221,7 +1221,6 @@ gst_d3d11_deinterlace_set_caps (GstBaseTransform * trans,
|
|||||||
VideoProcessorSetStreamAutoProcessingMode (self->video_proc, 0, FALSE);
|
VideoProcessorSetStreamAutoProcessingMode (self->video_proc, 0, FALSE);
|
||||||
self->video_context->VideoProcessorSetStreamOutputRate (self->video_proc, 0,
|
self->video_context->VideoProcessorSetStreamOutputRate (self->video_proc, 0,
|
||||||
output_rate, TRUE, NULL);
|
output_rate, TRUE, NULL);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1755,13 +1754,12 @@ gst_d3d11_deinterlace_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||||||
proc_stream.ppPastSurfaces = past_surfaces;
|
proc_stream.ppPastSurfaces = past_surfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (self->device);
|
GstD3D11DeviceLockGuard lk (self->device);
|
||||||
self->video_context->VideoProcessorSetStreamFrameFormat (self->video_proc, 0,
|
self->video_context->VideoProcessorSetStreamFrameFormat (self->video_proc, 0,
|
||||||
frame_foramt);
|
frame_foramt);
|
||||||
|
|
||||||
hr = self->video_context->VideoProcessorBlt (self->video_proc, pov, 0,
|
hr = self->video_context->VideoProcessorBlt (self->video_proc, pov, 0,
|
||||||
1, &proc_stream);
|
1, &proc_stream);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
|
|
||||||
if (!gst_d3d11_result (hr, self->device)) {
|
if (!gst_d3d11_result (hr, self->device)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to perform deinterlacing");
|
GST_ERROR_OBJECT (self, "Failed to perform deinterlacing");
|
||||||
|
@ -254,13 +254,12 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
hr = context_handle->Map (vertex_buffer.Get (),
|
hr = context_handle->Map (vertex_buffer.Get (),
|
||||||
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||||
|
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't map vertex buffer, hr: 0x%x", (guint) hr);
|
GST_ERROR_OBJECT (self, "Couldn't map vertex buffer, hr: 0x%x", (guint) hr);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +309,6 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self,
|
|||||||
vertex_data[3].texture.v = 1.0f;
|
vertex_data[3].texture.v = 1.0f;
|
||||||
|
|
||||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
overlay = g_new0 (GstD3D11CompositionOverlay, 1);
|
overlay = g_new0 (GstD3D11CompositionOverlay, 1);
|
||||||
overlay->overlay_rect = gst_video_overlay_rectangle_ref (overlay_rect);
|
overlay->overlay_rect = gst_video_overlay_rectangle_ref (overlay_rect);
|
||||||
@ -441,13 +439,12 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
hr = context_handle->Map (index_buffer.Get (),
|
hr = context_handle->Map (index_buffer.Get (),
|
||||||
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||||
|
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't map index buffer, hr: 0x%x", (guint) hr);
|
GST_ERROR_OBJECT (self, "Couldn't map index buffer, hr: 0x%x", (guint) hr);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +460,6 @@ gst_d3d11_overlay_compositor_setup_shader (GstD3D11OverlayCompositor * self)
|
|||||||
indices[5] = 2; /* top right */
|
indices[5] = 2; /* top right */
|
||||||
|
|
||||||
context_handle->Unmap (index_buffer.Get (), 0);
|
context_handle->Unmap (index_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
priv->ps = ps.Detach ();
|
priv->ps = ps.Detach ();
|
||||||
priv->vs = vs.Detach ();
|
priv->vs = vs.Detach ();
|
||||||
@ -623,16 +619,11 @@ gboolean
|
|||||||
gst_d3d11_overlay_compositor_draw (GstD3D11OverlayCompositor * compositor,
|
gst_d3d11_overlay_compositor_draw (GstD3D11OverlayCompositor * compositor,
|
||||||
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES])
|
ID3D11RenderTargetView * rtv[GST_VIDEO_MAX_PLANES])
|
||||||
{
|
{
|
||||||
gboolean ret = TRUE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (compositor != nullptr, FALSE);
|
g_return_val_if_fail (compositor != nullptr, FALSE);
|
||||||
g_return_val_if_fail (rtv != nullptr, FALSE);
|
g_return_val_if_fail (rtv != nullptr, FALSE);
|
||||||
|
|
||||||
gst_d3d11_device_lock (compositor->device);
|
GstD3D11DeviceLockGuard lk (compositor->device);
|
||||||
ret = gst_d3d11_overlay_compositor_draw_unlocked (compositor, rtv);
|
return gst_d3d11_overlay_compositor_draw_unlocked (compositor, rtv);
|
||||||
gst_d3d11_device_unlock (compositor->device);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -948,10 +948,9 @@ gst_d3d11_buffer_copy_into (GstBuffer * dst, GstBuffer * src,
|
|||||||
dst_subidx = gst_d3d11_memory_get_subresource_index (dst_dmem);
|
dst_subidx = gst_d3d11_memory_get_subresource_index (dst_dmem);
|
||||||
src_subidx = gst_d3d11_memory_get_subresource_index (src_dmem);
|
src_subidx = gst_d3d11_memory_get_subresource_index (src_dmem);
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
device_context->CopySubresourceRegion (dst_texture, dst_subidx, 0, 0, 0,
|
device_context->CopySubresourceRegion (dst_texture, dst_subidx, 0, 0, 0,
|
||||||
src_texture, src_subidx, &src_box);
|
src_texture, src_subidx, &src_box);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
gst_memory_unmap (src_mem, &src_info);
|
gst_memory_unmap (src_mem, &src_info);
|
||||||
gst_memory_unmap (dst_mem, &dst_info);
|
gst_memory_unmap (dst_mem, &dst_info);
|
||||||
|
@ -405,12 +405,11 @@ setup_snow_render (GstD3D11TestSrc * self, GstD3D11TestSrcRender * render,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (self->device);
|
GstD3D11DeviceLockGuard lk (self->device);
|
||||||
hr = context_handle->Map (vertex_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
hr = context_handle->Map (vertex_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
||||||
&map);
|
&map);
|
||||||
if (!gst_d3d11_result (hr, self->device)) {
|
if (!gst_d3d11_result (hr, self->device)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map vertex buffer");
|
GST_ERROR_OBJECT (self, "Failed to map vertex buffer");
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
vertex_data = (UvVertexData *) map.pData;
|
vertex_data = (UvVertexData *) map.pData;
|
||||||
@ -420,7 +419,6 @@ setup_snow_render (GstD3D11TestSrc * self, GstD3D11TestSrcRender * render,
|
|||||||
if (!gst_d3d11_result (hr, self->device)) {
|
if (!gst_d3d11_result (hr, self->device)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map index buffer");
|
GST_ERROR_OBJECT (self, "Failed to map index buffer");
|
||||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
indices = (WORD *) map.pData;
|
indices = (WORD *) map.pData;
|
||||||
@ -506,7 +504,6 @@ setup_snow_render (GstD3D11TestSrc * self, GstD3D11TestSrcRender * render,
|
|||||||
|
|
||||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||||
context_handle->Unmap (index_buffer.Get (), 0);
|
context_handle->Unmap (index_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
|
|
||||||
quad = g_new0 (GstD3D11TestSrcQuad, 1);
|
quad = g_new0 (GstD3D11TestSrcQuad, 1);
|
||||||
if (on_smpte)
|
if (on_smpte)
|
||||||
@ -602,12 +599,11 @@ setup_smpte_render (GstD3D11TestSrc * self, GstD3D11TestSrcRender * render)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (self->device);
|
GstD3D11DeviceLockGuard lk (self->device);
|
||||||
hr = context_handle->Map (vertex_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
hr = context_handle->Map (vertex_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
||||||
&map);
|
&map);
|
||||||
if (!gst_d3d11_result (hr, self->device)) {
|
if (!gst_d3d11_result (hr, self->device)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map vertex buffer");
|
GST_ERROR_OBJECT (self, "Failed to map vertex buffer");
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
vertex_data = (ColorVertexData *) map.pData;
|
vertex_data = (ColorVertexData *) map.pData;
|
||||||
@ -617,7 +613,6 @@ setup_smpte_render (GstD3D11TestSrc * self, GstD3D11TestSrcRender * render)
|
|||||||
if (!gst_d3d11_result (hr, self->device)) {
|
if (!gst_d3d11_result (hr, self->device)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map index buffer");
|
GST_ERROR_OBJECT (self, "Failed to map index buffer");
|
||||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
indices = (WORD *) map.pData;
|
indices = (WORD *) map.pData;
|
||||||
@ -849,7 +844,6 @@ setup_smpte_render (GstD3D11TestSrc * self, GstD3D11TestSrcRender * render)
|
|||||||
|
|
||||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||||
context_handle->Unmap (index_buffer.Get (), 0);
|
context_handle->Unmap (index_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
|
|
||||||
render->quad[0] = quad = g_new0 (GstD3D11TestSrcQuad, 1);
|
render->quad[0] = quad = g_new0 (GstD3D11TestSrcQuad, 1);
|
||||||
|
|
||||||
@ -943,12 +937,11 @@ setup_checker_render (GstD3D11TestSrc * self, GstD3D11TestSrcRender * render,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (self->device);
|
GstD3D11DeviceLockGuard lk (self->device);
|
||||||
hr = context_handle->Map (vertex_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
hr = context_handle->Map (vertex_buffer.Get (), 0, D3D11_MAP_WRITE_DISCARD, 0,
|
||||||
&map);
|
&map);
|
||||||
if (!gst_d3d11_result (hr, self->device)) {
|
if (!gst_d3d11_result (hr, self->device)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map vertex buffer");
|
GST_ERROR_OBJECT (self, "Failed to map vertex buffer");
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
vertex_data = (UvVertexData *) map.pData;
|
vertex_data = (UvVertexData *) map.pData;
|
||||||
@ -958,7 +951,6 @@ setup_checker_render (GstD3D11TestSrc * self, GstD3D11TestSrcRender * render,
|
|||||||
if (!gst_d3d11_result (hr, self->device)) {
|
if (!gst_d3d11_result (hr, self->device)) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map index buffer");
|
GST_ERROR_OBJECT (self, "Failed to map index buffer");
|
||||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
indices = (WORD *) map.pData;
|
indices = (WORD *) map.pData;
|
||||||
@ -1001,7 +993,6 @@ setup_checker_render (GstD3D11TestSrc * self, GstD3D11TestSrcRender * render,
|
|||||||
|
|
||||||
context_handle->Unmap (vertex_buffer.Get (), 0);
|
context_handle->Unmap (vertex_buffer.Get (), 0);
|
||||||
context_handle->Unmap (index_buffer.Get (), 0);
|
context_handle->Unmap (index_buffer.Get (), 0);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
|
|
||||||
render->quad[0] = quad = g_new0 (GstD3D11TestSrcQuad, 1);
|
render->quad[0] = quad = g_new0 (GstD3D11TestSrcQuad, 1);
|
||||||
|
|
||||||
@ -1698,6 +1689,7 @@ gst_d3d11_test_src_create (GstBaseSrc * bsrc, guint64 offset,
|
|||||||
GstD3D11Memory *dmem;
|
GstD3D11Memory *dmem;
|
||||||
ID3D11RenderTargetView *pattern_rtv;
|
ID3D11RenderTargetView *pattern_rtv;
|
||||||
gboolean convert_ret;
|
gboolean convert_ret;
|
||||||
|
GstD3D11DeviceLockGuard lk (self->device);
|
||||||
|
|
||||||
ret = GST_BASE_SRC_CLASS (parent_class)->alloc (bsrc, offset, size, &buffer);
|
ret = GST_BASE_SRC_CLASS (parent_class)->alloc (bsrc, offset, size, &buffer);
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
@ -1720,11 +1712,9 @@ gst_d3d11_test_src_create (GstBaseSrc * bsrc, guint64 offset,
|
|||||||
|
|
||||||
mem = gst_buffer_peek_memory (render_buffer, 0);
|
mem = gst_buffer_peek_memory (render_buffer, 0);
|
||||||
|
|
||||||
gst_d3d11_device_lock (self->device);
|
|
||||||
if (!gst_memory_map (mem, &render_info,
|
if (!gst_memory_map (mem, &render_info,
|
||||||
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
(GstMapFlags) (GST_MAP_WRITE | GST_MAP_D3D11))) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to map render buffer");
|
GST_ERROR_OBJECT (self, "Failed to map render buffer");
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1733,7 +1723,6 @@ gst_d3d11_test_src_create (GstBaseSrc * bsrc, guint64 offset,
|
|||||||
if (!pattern_rtv) {
|
if (!pattern_rtv) {
|
||||||
GST_ERROR_OBJECT (self, "RTV is not available");
|
GST_ERROR_OBJECT (self, "RTV is not available");
|
||||||
gst_memory_unmap (mem, &render_info);
|
gst_memory_unmap (mem, &render_info);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1741,7 +1730,6 @@ gst_d3d11_test_src_create (GstBaseSrc * bsrc, guint64 offset,
|
|||||||
gst_memory_unmap (mem, &render_info);
|
gst_memory_unmap (mem, &render_info);
|
||||||
convert_ret = gst_d3d11_converter_convert_buffer_unlocked (self->converter,
|
convert_ret = gst_d3d11_converter_convert_buffer_unlocked (self->converter,
|
||||||
render_buffer, convert_buffer);
|
render_buffer, convert_buffer);
|
||||||
gst_d3d11_device_unlock (self->device);
|
|
||||||
|
|
||||||
if (!convert_ret) {
|
if (!convert_ret) {
|
||||||
GST_ERROR_OBJECT (self, "Failed to convert buffer");
|
GST_ERROR_OBJECT (self, "Failed to convert buffer");
|
||||||
|
@ -282,12 +282,11 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * self, guint width,
|
|||||||
GstD3D11Memory *dmem;
|
GstD3D11Memory *dmem;
|
||||||
ID3D11RenderTargetView *rtv;
|
ID3D11RenderTargetView *rtv;
|
||||||
gsize size;
|
gsize size;
|
||||||
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
gst_d3d11_device_lock (device);
|
|
||||||
|
|
||||||
gst_clear_buffer (&self->backbuffer);
|
gst_clear_buffer (&self->backbuffer);
|
||||||
if (!self->swap_chain)
|
if (!self->swap_chain)
|
||||||
goto done;
|
return;
|
||||||
|
|
||||||
swap_chain = self->swap_chain;
|
swap_chain = self->swap_chain;
|
||||||
swap_chain->GetDesc (&swap_desc);
|
swap_chain->GetDesc (&swap_desc);
|
||||||
@ -295,14 +294,14 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * self, guint width,
|
|||||||
swap_desc.Flags);
|
swap_desc.Flags);
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't resize buffers, hr: 0x%x", (guint) hr);
|
GST_ERROR_OBJECT (self, "Couldn't resize buffers, hr: 0x%x", (guint) hr);
|
||||||
goto done;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = swap_chain->GetBuffer (0, IID_PPV_ARGS (&backbuffer));
|
hr = swap_chain->GetBuffer (0, IID_PPV_ARGS (&backbuffer));
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_ERROR_OBJECT (self,
|
GST_ERROR_OBJECT (self,
|
||||||
"Cannot get backbuffer from swapchain, hr: 0x%x", (guint) hr);
|
"Cannot get backbuffer from swapchain, hr: 0x%x", (guint) hr);
|
||||||
goto done;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
backbuffer->GetDesc (&desc);
|
backbuffer->GetDesc (&desc);
|
||||||
@ -320,7 +319,7 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * self, guint width,
|
|||||||
self->device, backbuffer.Get (), size, nullptr, nullptr);
|
self->device, backbuffer.Get (), size, nullptr, nullptr);
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
GST_ERROR_OBJECT (self, "Couldn't allocate wrapped memory");
|
GST_ERROR_OBJECT (self, "Couldn't allocate wrapped memory");
|
||||||
goto done;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dmem = GST_D3D11_MEMORY_CAST (mem);
|
dmem = GST_D3D11_MEMORY_CAST (mem);
|
||||||
@ -328,7 +327,7 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * self, guint width,
|
|||||||
if (!rtv) {
|
if (!rtv) {
|
||||||
GST_ERROR_OBJECT (self, "RTV is unavailable");
|
GST_ERROR_OBJECT (self, "RTV is unavailable");
|
||||||
gst_memory_unref (mem);
|
gst_memory_unref (mem);
|
||||||
goto done;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->backbuffer = gst_buffer_new ();
|
self->backbuffer = gst_buffer_new ();
|
||||||
@ -379,9 +378,6 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * self, guint width,
|
|||||||
/* redraw the last scene if cached buffer exits */
|
/* redraw the last scene if cached buffer exits */
|
||||||
if (self->cached_buffer)
|
if (self->cached_buffer)
|
||||||
gst_d3d111_window_present (self, self->cached_buffer, self->backbuffer);
|
gst_d3d111_window_present (self, self->cached_buffer, self->backbuffer);
|
||||||
|
|
||||||
done:
|
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -557,7 +553,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
|
|||||||
if (SUCCEEDED (hr) && allow_tearing)
|
if (SUCCEEDED (hr) && allow_tearing)
|
||||||
window->allow_tearing = allow_tearing;
|
window->allow_tearing = allow_tearing;
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
window->dxgi_format = chosen_format->dxgi_format;
|
window->dxgi_format = chosen_format->dxgi_format;
|
||||||
|
|
||||||
klass = GST_D3D11_WINDOW_GET_CLASS (window);
|
klass = GST_D3D11_WINDOW_GET_CLASS (window);
|
||||||
@ -568,7 +564,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
|
|||||||
GST_ERROR_OBJECT (window, "Cannot create swapchain");
|
GST_ERROR_OBJECT (window, "Cannot create swapchain");
|
||||||
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
||||||
"Cannot create swapchain");
|
"Cannot create swapchain");
|
||||||
goto error;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this rect struct will be used to calculate render area */
|
/* this rect struct will be used to calculate render area */
|
||||||
@ -675,7 +671,7 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
|
|||||||
GST_ERROR_OBJECT (window, "Cannot create converter");
|
GST_ERROR_OBJECT (window, "Cannot create converter");
|
||||||
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
||||||
"Cannot create converter");
|
"Cannot create converter");
|
||||||
goto error;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_hdr10_meta) {
|
if (have_hdr10_meta) {
|
||||||
@ -693,9 +689,8 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
|
|||||||
GST_ERROR_OBJECT (window, "Cannot create overlay compositor");
|
GST_ERROR_OBJECT (window, "Cannot create overlay compositor");
|
||||||
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
||||||
"Cannot create overlay compositor");
|
"Cannot create overlay compositor");
|
||||||
goto error;
|
return FALSE;
|
||||||
}
|
}
|
||||||
gst_d3d11_device_unlock (window->device);
|
|
||||||
|
|
||||||
/* call resize to allocated resources */
|
/* call resize to allocated resources */
|
||||||
klass->on_resize (window, display_width, display_height);
|
klass->on_resize (window, display_width, display_height);
|
||||||
@ -706,11 +701,6 @@ gst_d3d11_window_prepare_default (GstD3D11Window * window, guint display_width,
|
|||||||
GST_DEBUG_OBJECT (window, "New swap chain 0x%p created", window->swap_chain);
|
GST_DEBUG_OBJECT (window, "New swap chain 0x%p created", window->swap_chain);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
|
||||||
gst_d3d11_device_unlock (window->device);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -850,19 +840,14 @@ gst_d3d111_window_present (GstD3D11Window * self, GstBuffer * buffer,
|
|||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
gst_d3d11_window_render (GstD3D11Window * window, GstBuffer * buffer)
|
gst_d3d11_window_render (GstD3D11Window * window, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstFlowReturn ret;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_D3D11_WINDOW (window), GST_FLOW_ERROR);
|
g_return_val_if_fail (GST_IS_D3D11_WINDOW (window), GST_FLOW_ERROR);
|
||||||
|
|
||||||
gst_d3d11_device_lock (window->device);
|
GstD3D11DeviceLockGuard lk (window->device);
|
||||||
if (buffer)
|
if (buffer)
|
||||||
gst_buffer_replace (&window->cached_buffer, buffer);
|
gst_buffer_replace (&window->cached_buffer, buffer);
|
||||||
|
|
||||||
ret = gst_d3d111_window_present (window, window->cached_buffer,
|
return gst_d3d111_window_present (window, window->cached_buffer,
|
||||||
window->backbuffer);
|
window->backbuffer);
|
||||||
gst_d3d11_device_unlock (window->device);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
@ -886,17 +871,15 @@ gst_d3d11_window_render_on_shared_handle (GstD3D11Window * window,
|
|||||||
data.acquire_key = acquire_key;
|
data.acquire_key = acquire_key;
|
||||||
data.release_key = release_key;
|
data.release_key = release_key;
|
||||||
|
|
||||||
gst_d3d11_device_lock (window->device);
|
GstD3D11DeviceLockGuard (window->device);
|
||||||
if (!klass->open_shared_handle (window, &data)) {
|
if (!klass->open_shared_handle (window, &data)) {
|
||||||
GST_ERROR_OBJECT (window, "Couldn't open shared handle");
|
GST_ERROR_OBJECT (window, "Couldn't open shared handle");
|
||||||
gst_d3d11_device_unlock (window->device);
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gst_d3d111_window_present (window, buffer, data.render_target);
|
ret = gst_d3d111_window_present (window, buffer, data.render_target);
|
||||||
|
|
||||||
klass->release_shared_handle (window, &data);
|
klass->release_shared_handle (window, &data);
|
||||||
gst_d3d11_device_unlock (window->device);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -930,9 +913,8 @@ gst_d3d11_window_unlock_stop (GstD3D11Window * window)
|
|||||||
if (klass->unlock_stop)
|
if (klass->unlock_stop)
|
||||||
ret = klass->unlock_stop (window);
|
ret = klass->unlock_stop (window);
|
||||||
|
|
||||||
gst_d3d11_device_lock (window->device);
|
GstD3D11DeviceLockGuard lk (window->device);
|
||||||
gst_clear_buffer (&window->cached_buffer);
|
gst_clear_buffer (&window->cached_buffer);
|
||||||
gst_d3d11_device_unlock (window->device);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1007,7 +989,7 @@ gst_d3d11_window_set_orientation (GstD3D11Window * window,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (window->device);
|
GstD3D11DeviceLockGuard lk (window->device);
|
||||||
if (window->method != method) {
|
if (window->method != method) {
|
||||||
window->method = method;
|
window->method = method;
|
||||||
if (window->swap_chain) {
|
if (window->swap_chain) {
|
||||||
@ -1016,5 +998,4 @@ gst_d3d11_window_set_orientation (GstD3D11Window * window,
|
|||||||
klass->on_resize (window, window->surface_width, window->surface_height);
|
klass->on_resize (window, window->surface_width, window->surface_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst_d3d11_device_unlock (window->device);
|
|
||||||
}
|
}
|
||||||
|
@ -390,10 +390,9 @@ create_swap_chain_for_core_window (GstD3D11WindowCoreWindow * self,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
hr = factory2->CreateSwapChainForCoreWindow (device_handle,
|
hr = factory2->CreateSwapChainForCoreWindow (device_handle,
|
||||||
(IUnknown *) core_window, desc, output, &swap_chain);
|
(IUnknown *) core_window, desc, output, &swap_chain);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
||||||
|
@ -117,7 +117,7 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
|
|||||||
window->render_info.colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
|
window->render_info.colorimetry.transfer = GST_VIDEO_TRANSFER_BT709;
|
||||||
window->render_info.colorimetry.range = GST_VIDEO_COLOR_RANGE_0_255;
|
window->render_info.colorimetry.range = GST_VIDEO_COLOR_RANGE_0_255;
|
||||||
|
|
||||||
gst_d3d11_device_lock (window->device);
|
GstD3D11DeviceLockGuard lk (window->device);
|
||||||
window->converter = gst_d3d11_converter_new (window->device, &window->info,
|
window->converter = gst_d3d11_converter_new (window->device, &window->info,
|
||||||
&window->render_info, &method);
|
&window->render_info, &method);
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
|
|||||||
GST_ERROR_OBJECT (window, "Cannot create converter");
|
GST_ERROR_OBJECT (window, "Cannot create converter");
|
||||||
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
||||||
"Cannot create converter");
|
"Cannot create converter");
|
||||||
goto error;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->compositor =
|
window->compositor =
|
||||||
@ -134,17 +134,10 @@ gst_d3d11_window_dummy_prepare (GstD3D11Window * window,
|
|||||||
GST_ERROR_OBJECT (window, "Cannot create overlay compositor");
|
GST_ERROR_OBJECT (window, "Cannot create overlay compositor");
|
||||||
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
||||||
"Cannot create overlay compositor");
|
"Cannot create overlay compositor");
|
||||||
goto error;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_unlock (window->device);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
|
||||||
gst_d3d11_device_unlock (window->device);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -363,10 +363,9 @@ create_swap_chain_for_composition (GstD3D11WindowSwapChainPanel * self,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
hr = factory2->CreateSwapChainForComposition (device_handle,
|
hr = factory2->CreateSwapChainForComposition (device_handle,
|
||||||
desc, output, &swap_chain);
|
desc, output, &swap_chain);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
||||||
|
@ -888,9 +888,8 @@ create_swap_chain (GstD3D11WindowWin32 * self, GstD3D11Device * device,
|
|||||||
ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device);
|
ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device);
|
||||||
IDXGIFactory1 *factory = gst_d3d11_device_get_dxgi_factory_handle (device);
|
IDXGIFactory1 *factory = gst_d3d11_device_get_dxgi_factory_handle (device);
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
hr = factory->CreateSwapChain (device_handle, desc, &swap_chain);
|
hr = factory->CreateSwapChain (device_handle, desc, &swap_chain);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
||||||
@ -918,10 +917,9 @@ create_swap_chain_for_hwnd (GstD3D11WindowWin32 * self, GstD3D11Device * device,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
hr = factory2->CreateSwapChainForHwnd (device_handle, hwnd, desc,
|
hr = factory2->CreateSwapChainForHwnd (device_handle, hwnd, desc,
|
||||||
fullscreen_desc, output, &swap_chain);
|
fullscreen_desc, output, &swap_chain);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
GST_WARNING_OBJECT (self, "Cannot create SwapChain Object: 0x%x",
|
||||||
@ -1008,10 +1006,9 @@ gst_d3d11_window_win32_create_swap_chain (GstD3D11Window * window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* disable alt+enter here. It should be manually handled */
|
/* disable alt+enter here. It should be manually handled */
|
||||||
gst_d3d11_device_lock (device);
|
GstD3D11DeviceLockGuard lk (device);
|
||||||
gst_d3d11_window_win32_disable_alt_enter (self,
|
gst_d3d11_window_win32_disable_alt_enter (self,
|
||||||
device, new_swapchain, desc.OutputWindow);
|
device, new_swapchain, desc.OutputWindow);
|
||||||
gst_d3d11_device_unlock (device);
|
|
||||||
|
|
||||||
*swap_chain = new_swapchain;
|
*swap_chain = new_swapchain;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user