mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
d3d12: Remove unnecessary event handles
null event NT handle to ID3D12Fence::SetEventOnCompletion() will block the calling CPU thread already, thus it has no point that creating an event NT handle in order to immediate wait for fence at CPU-side. Note that passing a valid event NT handle to the fence API might be useful when we need to wait for the fence value later (or timeout is required), or want to wait for multiple fences at once via WaitForMultipleObjects(). But it's not a considered use case for now. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7176>
This commit is contained in:
parent
783e1ea327
commit
b37bfc02f5
17 changed files with 46 additions and 188 deletions
|
@ -26,7 +26,6 @@ G_BEGIN_DECLS
|
|||
|
||||
GST_D3D12_API
|
||||
HRESULT gst_d3d12_command_queue_idle_for_swapchain (GstD3D12CommandQueue * queue,
|
||||
guint64 fence_value,
|
||||
HANDLE event_handle);
|
||||
guint64 fence_value);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -62,11 +62,6 @@ struct gc_cmp {
|
|||
|
||||
struct _GstD3D12CommandQueuePrivate
|
||||
{
|
||||
_GstD3D12CommandQueuePrivate ()
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
}
|
||||
|
||||
~_GstD3D12CommandQueuePrivate ()
|
||||
{
|
||||
{
|
||||
|
@ -78,13 +73,8 @@ struct _GstD3D12CommandQueuePrivate
|
|||
g_clear_pointer (&gc_thread, g_thread_join);
|
||||
|
||||
auto completed = fence->GetCompletedValue ();
|
||||
if (fence_val > completed) {
|
||||
auto hr = fence->SetEventOnCompletion (completed, event_handle);
|
||||
if (SUCCEEDED (hr))
|
||||
WaitForSingleObjectEx (event_handle, INFINITE, FALSE);
|
||||
}
|
||||
|
||||
CloseHandle (event_handle);
|
||||
if (fence_val > completed)
|
||||
fence->SetEventOnCompletion (completed, nullptr);
|
||||
}
|
||||
|
||||
D3D12_COMMAND_QUEUE_DESC desc;
|
||||
|
@ -92,7 +82,6 @@ struct _GstD3D12CommandQueuePrivate
|
|||
ComPtr<ID3D12Device> device;
|
||||
ComPtr<ID3D12CommandQueue> cq;
|
||||
ComPtr<ID3D12Fence> fence;
|
||||
HANDLE event_handle;
|
||||
guint64 fence_val = 0;
|
||||
|
||||
GThread *gc_thread = nullptr;
|
||||
|
@ -251,12 +240,11 @@ gst_d3d12_command_queue_execute_command_lists_unlocked (GstD3D12CommandQueue *
|
|||
|
||||
if (completed + priv->queue_size < priv->fence_val) {
|
||||
hr = priv->fence->SetEventOnCompletion (priv->fence_val -
|
||||
priv->queue_size, priv->event_handle);
|
||||
priv->queue_size, nullptr);
|
||||
if (FAILED (hr)) {
|
||||
GST_ERROR_OBJECT (queue, "SetEventOnCompletion failed");
|
||||
return hr;
|
||||
}
|
||||
WaitForSingleObjectEx (priv->event_handle, INFINITE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,7 +368,6 @@ gst_d3d12_command_queue_get_completed_value (GstD3D12CommandQueue * queue)
|
|||
* gst_d3d12_command_queue_fence_wait:
|
||||
* @queue: a #GstD3D12CommandQueue
|
||||
* @fence_value: fence value to wait
|
||||
* @handle: (nullable) (transfer none): event handle used for fence wait
|
||||
*
|
||||
* Blocks calling CPU thread until command corresponding @fence_value
|
||||
* is completed. If @fence_value is %G_MAXUINT64, this method will block
|
||||
|
@ -392,7 +379,7 @@ gst_d3d12_command_queue_get_completed_value (GstD3D12CommandQueue * queue)
|
|||
*/
|
||||
HRESULT
|
||||
gst_d3d12_command_queue_fence_wait (GstD3D12CommandQueue * queue,
|
||||
guint64 fence_value, HANDLE event_handle)
|
||||
guint64 fence_value)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_D3D12_COMMAND_QUEUE (queue), E_INVALIDARG);
|
||||
|
||||
|
@ -414,24 +401,11 @@ gst_d3d12_command_queue_fence_wait (GstD3D12CommandQueue * queue,
|
|||
|
||||
auto completed = priv->fence->GetCompletedValue ();
|
||||
if (completed < fence_to_wait) {
|
||||
bool close_handle = false;
|
||||
if (!event_handle) {
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
close_handle = true;
|
||||
}
|
||||
|
||||
hr = priv->fence->SetEventOnCompletion (fence_to_wait, event_handle);
|
||||
hr = priv->fence->SetEventOnCompletion (fence_to_wait, nullptr);
|
||||
if (FAILED (hr)) {
|
||||
GST_ERROR_OBJECT (queue, "SetEventOnCompletion failed");
|
||||
if (close_handle)
|
||||
CloseHandle (event_handle);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
WaitForSingleObjectEx (event_handle, INFINITE, FALSE);
|
||||
if (close_handle)
|
||||
CloseHandle (event_handle);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
@ -444,8 +418,6 @@ gst_d3d12_command_queue_gc_thread (GstD3D12CommandQueue * self)
|
|||
|
||||
GST_INFO_OBJECT (self, "Entering GC thread");
|
||||
|
||||
HANDLE event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
|
||||
while (true) {
|
||||
GCDataPtr gc_data;
|
||||
|
||||
|
@ -477,12 +449,10 @@ gst_d3d12_command_queue_gc_thread (GstD3D12CommandQueue * self)
|
|||
if (gc_data) {
|
||||
GST_LOG_OBJECT (self, "Waiting for fence data %" G_GUINT64_FORMAT,
|
||||
gc_data->fence_val);
|
||||
auto hr =
|
||||
priv->fence->SetEventOnCompletion (gc_data->fence_val, event_handle);
|
||||
auto hr = priv->fence->SetEventOnCompletion (gc_data->fence_val, nullptr);
|
||||
if (FAILED (hr)) {
|
||||
GST_ERROR_OBJECT (self, "SetEventOnCompletion failed");
|
||||
} else {
|
||||
WaitForSingleObjectEx (event_handle, INFINITE, FALSE);
|
||||
GST_LOG_OBJECT (self, "Waiting done, %" G_GUINT64_FORMAT,
|
||||
gc_data->fence_val);
|
||||
}
|
||||
|
@ -491,8 +461,6 @@ gst_d3d12_command_queue_gc_thread (GstD3D12CommandQueue * self)
|
|||
|
||||
GST_INFO_OBJECT (self, "Leaving GC thread");
|
||||
|
||||
CloseHandle (event_handle);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -569,16 +537,11 @@ gst_d3d12_command_queue_drain (GstD3D12CommandQueue * queue)
|
|||
|
||||
auto completed = priv->fence->GetCompletedValue ();
|
||||
if (completed < priv->fence_val) {
|
||||
auto event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
hr = priv->fence->SetEventOnCompletion (priv->fence_val, event_handle);
|
||||
hr = priv->fence->SetEventOnCompletion (priv->fence_val, nullptr);
|
||||
if (FAILED (hr)) {
|
||||
GST_ERROR_OBJECT (queue, "SetEventOnCompletion failed");
|
||||
CloseHandle (event_handle);
|
||||
return hr;
|
||||
}
|
||||
|
||||
WaitForSingleObjectEx (event_handle, INFINITE, FALSE);
|
||||
CloseHandle (event_handle);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -597,7 +560,7 @@ gst_d3d12_command_queue_drain (GstD3D12CommandQueue * queue)
|
|||
|
||||
HRESULT
|
||||
gst_d3d12_command_queue_idle_for_swapchain (GstD3D12CommandQueue * queue,
|
||||
guint64 fence_value, HANDLE event_handle)
|
||||
guint64 fence_value)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_D3D12_COMMAND_QUEUE (queue), E_INVALIDARG);
|
||||
|
||||
|
@ -624,24 +587,11 @@ gst_d3d12_command_queue_idle_for_swapchain (GstD3D12CommandQueue * queue,
|
|||
|
||||
auto completed = priv->fence->GetCompletedValue ();
|
||||
if (completed < fence_to_wait) {
|
||||
bool close_handle = false;
|
||||
if (!event_handle) {
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
close_handle = true;
|
||||
}
|
||||
|
||||
hr = priv->fence->SetEventOnCompletion (fence_to_wait, event_handle);
|
||||
hr = priv->fence->SetEventOnCompletion (fence_to_wait, nullptr);
|
||||
if (FAILED (hr)) {
|
||||
GST_ERROR_OBJECT (queue, "SetEventOnCompletion failed");
|
||||
if (close_handle)
|
||||
CloseHandle (event_handle);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
WaitForSingleObjectEx (event_handle, INFINITE, FALSE);
|
||||
if (close_handle)
|
||||
CloseHandle (event_handle);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
|
|
@ -104,8 +104,7 @@ guint64 gst_d3d12_command_queue_get_completed_value (GstD3D12Comm
|
|||
|
||||
GST_D3D12_API
|
||||
HRESULT gst_d3d12_command_queue_fence_wait (GstD3D12CommandQueue * queue,
|
||||
guint64 fence_value,
|
||||
HANDLE event_handle);
|
||||
guint64 fence_value);
|
||||
|
||||
GST_D3D12_API
|
||||
void gst_d3d12_command_queue_set_notify (GstD3D12CommandQueue * queue,
|
||||
|
|
|
@ -237,7 +237,7 @@ struct _GstD3D12ConverterPrivate
|
|||
~_GstD3D12ConverterPrivate ()
|
||||
{
|
||||
if (fence_val > 0 && cq)
|
||||
gst_d3d12_command_queue_fence_wait (cq, fence_val, nullptr);
|
||||
gst_d3d12_command_queue_fence_wait (cq, fence_val);
|
||||
|
||||
gst_clear_object (&srv_heap_pool);
|
||||
gst_clear_object (&cq);
|
||||
|
|
|
@ -1696,7 +1696,6 @@ gst_d3d12_device_set_fence_notify (GstD3D12Device * device,
|
|||
* @device: a #GstD3D12Device
|
||||
* @queue_type: a D3D12_COMMAND_LIST_TYPE
|
||||
* @fence_value: target fence value
|
||||
* @handle: (nullable) (transfer none): event handle used for fence wait
|
||||
*
|
||||
* Exectues gst_d3d12_command_queue_fence_wait ()
|
||||
* using a #GstD3D12CommandQueue corresponding to @queue_type
|
||||
|
@ -1707,8 +1706,7 @@ gst_d3d12_device_set_fence_notify (GstD3D12Device * device,
|
|||
*/
|
||||
HRESULT
|
||||
gst_d3d12_device_fence_wait (GstD3D12Device * device,
|
||||
D3D12_COMMAND_LIST_TYPE queue_type, guint64 fence_value,
|
||||
HANDLE event_handle)
|
||||
D3D12_COMMAND_LIST_TYPE queue_type, guint64 fence_value)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_D3D12_DEVICE (device), E_INVALIDARG);
|
||||
|
||||
|
@ -1727,7 +1725,7 @@ gst_d3d12_device_fence_wait (GstD3D12Device * device,
|
|||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
return gst_d3d12_command_queue_fence_wait (queue, fence_value, event_handle);
|
||||
return gst_d3d12_command_queue_fence_wait (queue, fence_value);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
@ -118,8 +118,7 @@ gboolean gst_d3d12_device_set_fence_notify (GstD3D12Devic
|
|||
GST_D3D12_API
|
||||
HRESULT gst_d3d12_device_fence_wait (GstD3D12Device * device,
|
||||
D3D12_COMMAND_LIST_TYPE queue_type,
|
||||
guint64 fence_value,
|
||||
HANDLE event_handle);
|
||||
guint64 fence_value);
|
||||
|
||||
GST_D3D12_API
|
||||
gboolean gst_d3d12_device_is_equal (GstD3D12Device * device1,
|
||||
|
|
|
@ -326,15 +326,8 @@ struct D3D11Interop
|
|||
|
||||
struct _GstD3D12MemoryPrivate
|
||||
{
|
||||
_GstD3D12MemoryPrivate ()
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
}
|
||||
|
||||
~_GstD3D12MemoryPrivate ()
|
||||
{
|
||||
CloseHandle (event_handle);
|
||||
|
||||
if (nt_handle)
|
||||
CloseHandle (nt_handle);
|
||||
|
||||
|
@ -352,7 +345,6 @@ struct _GstD3D12MemoryPrivate
|
|||
|
||||
D3D12_RESOURCE_DESC desc;
|
||||
|
||||
HANDLE event_handle = nullptr;
|
||||
HANDLE nt_handle = nullptr;
|
||||
std::map<gint64, std::unique_ptr<GstD3D12MemoryTokenData>> token_map;
|
||||
std::vector<std::shared_ptr<D3D11Interop>> shared_texture11;
|
||||
|
@ -420,15 +412,13 @@ gst_d3d12_memory_set_fence_unlocked (GstD3D12Memory * dmem,
|
|||
ID3D12Fence * fence, guint64 fence_val, gboolean wait)
|
||||
{
|
||||
auto priv = dmem->priv;
|
||||
HRESULT hr;
|
||||
|
||||
if (priv->fence && priv->fence.Get () != fence && wait) {
|
||||
auto completed = priv->fence->GetCompletedValue ();
|
||||
if (completed < priv->fence_val) {
|
||||
hr = priv->fence->SetEventOnCompletion (priv->fence_val,
|
||||
priv->event_handle);
|
||||
if (SUCCEEDED (hr))
|
||||
WaitForSingleObjectEx (priv->event_handle, INFINITE, FALSE);
|
||||
auto hr = priv->fence->SetEventOnCompletion (priv->fence_val, nullptr);
|
||||
/* For debugging */
|
||||
gst_d3d12_result (hr, dmem->device);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,7 +468,7 @@ gst_d3d12_memory_download (GstD3D12Memory * dmem)
|
|||
}
|
||||
|
||||
gst_d3d12_device_fence_wait (dmem->device, D3D12_COMMAND_LIST_TYPE_COPY,
|
||||
fence_val, priv->event_handle);
|
||||
fence_val);
|
||||
|
||||
priv->fence = nullptr;
|
||||
priv->fence_val = 0;
|
||||
|
|
|
@ -229,7 +229,6 @@ struct PadContext
|
|||
{
|
||||
PadContext (GstD3D12Device * dev)
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
device = (GstD3D12Device *) gst_object_ref (dev);
|
||||
auto device_handle = gst_d3d12_device_get_device_handle (device);
|
||||
ca_pool = gst_d3d12_command_allocator_pool_new (device_handle,
|
||||
|
@ -242,9 +241,7 @@ struct PadContext
|
|||
~PadContext ()
|
||||
{
|
||||
gst_d3d12_device_fence_wait (device, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||
fence_val, event_handle);
|
||||
|
||||
CloseHandle (event_handle);
|
||||
fence_val);
|
||||
|
||||
gst_clear_d3d12_fence_data (&fence_data);
|
||||
gst_clear_object (&conv);
|
||||
|
@ -258,7 +255,6 @@ struct PadContext
|
|||
GstD3D12FenceData *fence_data = nullptr;
|
||||
GstD3D12Device *device;
|
||||
GstD3D12Converter *conv = nullptr;
|
||||
HANDLE event_handle;
|
||||
guint64 fence_val = 0;
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
@ -321,7 +317,6 @@ struct BackgroundRender
|
|||
{
|
||||
BackgroundRender (GstD3D12Device * dev, const GstVideoInfo & info)
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
device = (GstD3D12Device *) gst_object_ref (dev);
|
||||
auto device_handle = gst_d3d12_device_get_device_handle (device);
|
||||
ca_pool = gst_d3d12_command_allocator_pool_new (device_handle,
|
||||
|
@ -510,9 +505,7 @@ struct BackgroundRender
|
|||
~BackgroundRender ()
|
||||
{
|
||||
gst_d3d12_device_fence_wait (device, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||
fence_val, event_handle);
|
||||
|
||||
CloseHandle (event_handle);
|
||||
fence_val);
|
||||
|
||||
gst_clear_object (&ca_pool);
|
||||
gst_clear_object (&device);
|
||||
|
@ -532,7 +525,6 @@ struct BackgroundRender
|
|||
guint rtv_inc_size;
|
||||
bool need_upload = true;
|
||||
bool is_valid = false;
|
||||
HANDLE event_handle;
|
||||
guint64 fence_val = 0;
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
@ -2378,8 +2370,7 @@ gst_d3d12_compositor_aggregate_frames (GstVideoAggregator * vagg,
|
|||
GST_LOG_OBJECT (self, "Waiting for previous command, %" G_GUINT64_FORMAT,
|
||||
fence_to_wait);
|
||||
gst_d3d12_device_fence_wait (self->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait,
|
||||
priv->bg_render->event_handle);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait);
|
||||
}
|
||||
|
||||
if (!gst_d3d12_compositor_draw_background (self)) {
|
||||
|
|
|
@ -80,7 +80,6 @@ struct ConvertContext
|
|||
{
|
||||
ConvertContext (GstD3D12Device * dev)
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
device = (GstD3D12Device *) gst_object_ref (dev);
|
||||
auto device_handle = gst_d3d12_device_get_device_handle (device);
|
||||
ca_pool = gst_d3d12_command_allocator_pool_new (device_handle,
|
||||
|
@ -90,9 +89,8 @@ struct ConvertContext
|
|||
~ConvertContext ()
|
||||
{
|
||||
gst_d3d12_device_fence_wait (device, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||
fence_val, event_handle);
|
||||
fence_val);
|
||||
|
||||
CloseHandle (event_handle);
|
||||
gst_clear_object (&ca_pool);
|
||||
gst_clear_object (&conv);
|
||||
gst_clear_object (&device);
|
||||
|
@ -103,7 +101,6 @@ struct ConvertContext
|
|||
ComPtr<ID3D12GraphicsCommandList> cl;
|
||||
std::queue<guint64> scheduled;
|
||||
GstD3D12CommandAllocatorPool *ca_pool;
|
||||
HANDLE event_handle;
|
||||
guint64 fence_val = 0;
|
||||
};
|
||||
|
||||
|
@ -1984,7 +1981,7 @@ gst_d3d12_convert_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||
auto fence_to_wait = priv->ctx->scheduled.front ();
|
||||
priv->ctx->scheduled.pop ();
|
||||
gst_d3d12_device_fence_wait (priv->ctx->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait, priv->ctx->event_handle);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait);
|
||||
}
|
||||
|
||||
GstD3D12CommandAllocator *gst_ca;
|
||||
|
|
|
@ -218,16 +218,6 @@ constexpr UINT64 ASYNC_DEPTH = 4;
|
|||
|
||||
struct DecoderCmdData
|
||||
{
|
||||
DecoderCmdData ()
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
}
|
||||
|
||||
~DecoderCmdData ()
|
||||
{
|
||||
CloseHandle (event_handle);
|
||||
}
|
||||
|
||||
ComPtr<ID3D12Device> device;
|
||||
ComPtr<ID3D12VideoDevice> video_device;
|
||||
ComPtr<ID3D12VideoDecodeCommandList> cl;
|
||||
|
@ -235,7 +225,6 @@ struct DecoderCmdData
|
|||
bool need_full_drain = false;
|
||||
|
||||
/* Fence to wait at command record thread */
|
||||
HANDLE event_handle;
|
||||
UINT64 fence_val = 0;
|
||||
};
|
||||
|
||||
|
@ -333,13 +322,11 @@ struct GstD3D12DecoderPrivate
|
|||
{
|
||||
GstD3D12DecoderPrivate ()
|
||||
{
|
||||
copy_event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
fence_data_pool = gst_d3d12_fence_data_pool_new ();
|
||||
}
|
||||
|
||||
~GstD3D12DecoderPrivate ()
|
||||
{
|
||||
CloseHandle (copy_event_handle);
|
||||
gst_clear_object (&fence_data_pool);
|
||||
}
|
||||
|
||||
|
@ -352,8 +339,6 @@ struct GstD3D12DecoderPrivate
|
|||
std::atomic<bool> flushing;
|
||||
std::atomic<GstFlowReturn> last_flow;
|
||||
|
||||
HANDLE copy_event_handle;
|
||||
|
||||
GstD3D12FenceDataPool *fence_data_pool;
|
||||
|
||||
std::vector<D3D12_RESOURCE_BARRIER> pre_barriers;
|
||||
|
@ -464,10 +449,8 @@ gst_d3d12_decoder_drain (GstD3D12Decoder * decoder, GstVideoDecoder * videodec)
|
|||
auto priv = decoder->priv;
|
||||
|
||||
GST_DEBUG_OBJECT (decoder, "Draining");
|
||||
if (priv->cmd) {
|
||||
gst_d3d12_command_queue_fence_wait (priv->cmd->queue, priv->cmd->fence_val,
|
||||
priv->cmd->event_handle);
|
||||
}
|
||||
if (priv->cmd)
|
||||
gst_d3d12_command_queue_fence_wait (priv->cmd->queue, priv->cmd->fence_val);
|
||||
|
||||
GST_VIDEO_DECODER_STREAM_UNLOCK (videodec);
|
||||
if (priv->output_thread && priv->session) {
|
||||
|
@ -808,7 +791,7 @@ gst_d3d12_decoder_stop (GstD3D12Decoder * decoder)
|
|||
gst_d3d12_command_queue_drain (priv->cmd->queue);
|
||||
} else {
|
||||
gst_d3d12_command_queue_fence_wait (priv->cmd->queue,
|
||||
priv->cmd->fence_val, priv->cmd->event_handle);
|
||||
priv->cmd->fence_val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1471,8 +1454,7 @@ gst_d3d12_decoder_process_output (GstD3D12Decoder * self,
|
|||
guint8 *map_data;
|
||||
GstVideoFrame vframe;
|
||||
|
||||
gst_d3d12_device_fence_wait (self->device, queue_type,
|
||||
copy_fence_val, priv->copy_event_handle);
|
||||
gst_d3d12_device_fence_wait (self->device, queue_type, copy_fence_val);
|
||||
|
||||
hr = priv->session->staging->Map (0, nullptr, (void **) &map_data);
|
||||
if (!gst_d3d12_result (hr, self->device)) {
|
||||
|
@ -1538,8 +1520,6 @@ gst_d3d12_decoder_output_loop (GstD3D12Decoder * self)
|
|||
|
||||
GST_DEBUG_OBJECT (self, "Entering output thread");
|
||||
|
||||
auto event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
|
||||
while (true) {
|
||||
DecoderOutputData output_data;
|
||||
{
|
||||
|
@ -1561,7 +1541,7 @@ gst_d3d12_decoder_output_loop (GstD3D12Decoder * self)
|
|||
g_assert (decoder_pic);
|
||||
|
||||
gst_d3d12_command_queue_fence_wait (priv->cmd->queue,
|
||||
decoder_pic->fence_val, event_handle);
|
||||
decoder_pic->fence_val);
|
||||
|
||||
if (priv->flushing) {
|
||||
GST_DEBUG_OBJECT (self, "Drop framem, we are flushing");
|
||||
|
@ -1587,8 +1567,6 @@ gst_d3d12_decoder_output_loop (GstD3D12Decoder * self)
|
|||
|
||||
GST_DEBUG_OBJECT (self, "Leaving output thread");
|
||||
|
||||
CloseHandle (event_handle);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -895,7 +895,6 @@ struct GstD3D12DxgiCapturePrivate
|
|||
{
|
||||
GstD3D12DxgiCapturePrivate ()
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
fence_data_pool = gst_d3d12_fence_data_pool_new ();
|
||||
}
|
||||
|
||||
|
@ -903,7 +902,6 @@ struct GstD3D12DxgiCapturePrivate
|
|||
{
|
||||
WaitGPU ();
|
||||
ctx = nullptr;
|
||||
CloseHandle (event_handle);
|
||||
if (shared_fence_handle)
|
||||
CloseHandle (shared_fence_handle);
|
||||
gst_clear_buffer (&mouse_buf);
|
||||
|
@ -919,11 +917,8 @@ struct GstD3D12DxgiCapturePrivate
|
|||
{
|
||||
if (shared_fence) {
|
||||
auto completed = shared_fence->GetCompletedValue ();
|
||||
if (completed < fence_val) {
|
||||
auto hr = shared_fence->SetEventOnCompletion (fence_val, event_handle);
|
||||
if (SUCCEEDED (hr))
|
||||
WaitForSingleObject (event_handle, INFINITE);
|
||||
}
|
||||
if (completed < fence_val)
|
||||
shared_fence->SetEventOnCompletion (fence_val, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -948,7 +943,6 @@ struct GstD3D12DxgiCapturePrivate
|
|||
guint cached_width = 0;
|
||||
guint cached_height = 0;
|
||||
|
||||
HANDLE event_handle;
|
||||
guint64 fence_val = 0;
|
||||
|
||||
guint64 mouse_token = 0;
|
||||
|
|
|
@ -88,17 +88,11 @@ struct EncoderSessionData
|
|||
|
||||
struct EncoderCmdData
|
||||
{
|
||||
EncoderCmdData ()
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
}
|
||||
|
||||
~EncoderCmdData ()
|
||||
{
|
||||
if (queue)
|
||||
gst_d3d12_command_queue_fence_wait (queue, G_MAXUINT64, event_handle);
|
||||
gst_d3d12_command_queue_fence_wait (queue, G_MAXUINT64);
|
||||
|
||||
CloseHandle (event_handle);
|
||||
gst_clear_object (&ca_pool);
|
||||
gst_clear_object (&queue);
|
||||
}
|
||||
|
@ -107,7 +101,6 @@ struct EncoderCmdData
|
|||
ComPtr<ID3D12VideoEncodeCommandList2> cl;
|
||||
GstD3D12CommandQueue *queue = nullptr;
|
||||
GstD3D12CommandAllocatorPool *ca_pool = nullptr;
|
||||
HANDLE event_handle;
|
||||
guint64 fence_val = 0;
|
||||
};
|
||||
|
||||
|
@ -353,8 +346,7 @@ gst_d3d12_encoder_drain (GstD3D12Encoder * self, gboolean locked)
|
|||
if (priv->cmd) {
|
||||
GST_DEBUG_OBJECT (self, "Waiting for command finish %" G_GUINT64_FORMAT,
|
||||
priv->cmd->fence_val);
|
||||
gst_d3d12_command_queue_fence_wait (priv->cmd->queue, priv->cmd->fence_val,
|
||||
priv->cmd->event_handle);
|
||||
gst_d3d12_command_queue_fence_wait (priv->cmd->queue, priv->cmd->fence_val);
|
||||
}
|
||||
|
||||
if (priv->session && priv->output_thread) {
|
||||
|
@ -1145,8 +1137,6 @@ gst_d3d12_encoder_output_loop (GstD3D12Encoder * self)
|
|||
|
||||
GST_DEBUG_OBJECT (self, "Entering output thread");
|
||||
|
||||
HANDLE event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
|
||||
while (true) {
|
||||
EncoderOutputData output_data;
|
||||
{
|
||||
|
@ -1167,8 +1157,8 @@ gst_d3d12_encoder_output_loop (GstD3D12Encoder * self)
|
|||
GST_LOG_OBJECT (self, "Processing output %" G_GUINT64_FORMAT,
|
||||
output_data.fence_val);
|
||||
|
||||
gst_d3d12_command_queue_fence_wait (priv->cmd->queue, output_data.fence_val,
|
||||
event_handle);
|
||||
gst_d3d12_command_queue_fence_wait (priv->cmd->queue,
|
||||
output_data.fence_val);
|
||||
|
||||
if (priv->flushing) {
|
||||
GST_DEBUG_OBJECT (self, "We are flushing");
|
||||
|
@ -1218,8 +1208,6 @@ gst_d3d12_encoder_output_loop (GstD3D12Encoder * self)
|
|||
|
||||
GST_DEBUG_OBJECT (self, "Leaving output thread");
|
||||
|
||||
CloseHandle (event_handle);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,6 @@ struct RenderContext
|
|||
{
|
||||
RenderContext (GstD3D12Device * dev)
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
device = (GstD3D12Device *) gst_object_ref (dev);
|
||||
auto device_handle = gst_d3d12_device_get_device_handle (device);
|
||||
ca_pool = gst_d3d12_command_allocator_pool_new (device_handle,
|
||||
|
@ -236,9 +235,7 @@ struct RenderContext
|
|||
~RenderContext ()
|
||||
{
|
||||
gst_d3d12_device_fence_wait (device, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||
fence_val, event_handle);
|
||||
|
||||
CloseHandle (event_handle);
|
||||
fence_val);
|
||||
|
||||
{
|
||||
GstD3D12Device11on12LockGuard lk (device);
|
||||
|
@ -290,7 +287,6 @@ struct RenderContext
|
|||
StaticColor static_color[2];
|
||||
std::vector < std::shared_ptr < GstD3D12TestSrcQuad >> quad;
|
||||
GstD3D12TestSrcPattern pattern;
|
||||
HANDLE event_handle;
|
||||
guint64 fence_val = 0;
|
||||
};
|
||||
|
||||
|
@ -2183,7 +2179,7 @@ gst_d3d12_test_src_create (GstBaseSrc * bsrc, guint64 offset,
|
|||
auto fence_to_wait = priv->ctx->scheduled.front ();
|
||||
priv->ctx->scheduled.pop ();
|
||||
gst_d3d12_device_fence_wait (self->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait, priv->ctx->event_handle);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait);
|
||||
}
|
||||
|
||||
GstD3D12CommandAllocator *gst_ca;
|
||||
|
|
|
@ -69,7 +69,6 @@ struct SwapChainResource
|
|||
GstD3D12OverlayCompositor *comp = nullptr;
|
||||
GstD3D12Device *device = nullptr;
|
||||
GstD3D12CommandAllocatorPool *ca_pool = nullptr;
|
||||
HANDLE event_handle = nullptr;
|
||||
UINT64 fence_val = 0;
|
||||
std::queue<UINT64> prev_fence_val;
|
||||
DXGI_FORMAT render_format = DXGI_FORMAT_UNKNOWN;
|
||||
|
|
|
@ -49,7 +49,6 @@ SwapChainBuffer::~SwapChainBuffer ()
|
|||
|
||||
SwapChainResource::SwapChainResource (GstD3D12Device * dev)
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
device = (GstD3D12Device *) gst_object_ref (dev);
|
||||
auto device_handle = gst_d3d12_device_get_device_handle (device);
|
||||
ca_pool = gst_d3d12_command_allocator_pool_new (device_handle,
|
||||
|
@ -80,8 +79,6 @@ SwapChainResource::~SwapChainResource ()
|
|||
gst_clear_object (&conv);
|
||||
gst_clear_object (&ca_pool);
|
||||
gst_clear_object (&device);
|
||||
|
||||
CloseHandle (event_handle);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -90,7 +87,7 @@ SwapChainResource::clear_resource ()
|
|||
if (!buffers.empty ()) {
|
||||
auto cq = gst_d3d12_device_get_command_queue (device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT);
|
||||
gst_d3d12_command_queue_idle_for_swapchain (cq, fence_val, event_handle);
|
||||
gst_d3d12_command_queue_idle_for_swapchain (cq, fence_val);
|
||||
prev_fence_val = { };
|
||||
}
|
||||
|
||||
|
@ -234,8 +231,7 @@ SwapChain::~SwapChain()
|
|||
if (!resource_->buffers.empty ()) {
|
||||
auto cq = gst_d3d12_device_get_command_queue (resource_->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT);
|
||||
gst_d3d12_command_queue_idle_for_swapchain (cq, resource_->fence_val,
|
||||
resource_->event_handle);
|
||||
gst_d3d12_command_queue_idle_for_swapchain (cq, resource_->fence_val);
|
||||
}
|
||||
|
||||
resource_ = nullptr;
|
||||
|
@ -269,8 +265,7 @@ SwapChain::setup_swapchain (GstD3D12Window * window, GstD3D12Device * device,
|
|||
std::lock_guard <std::recursive_mutex> lk (lock_);
|
||||
if (!gst_d3d12_device_is_equal (device, resource_->device)) {
|
||||
gst_d3d12_device_fence_wait (resource_->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, resource_->fence_val,
|
||||
resource_->event_handle);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, resource_->fence_val);
|
||||
resource_ = std::make_unique <SwapChainResource> (device);
|
||||
}
|
||||
|
||||
|
@ -615,8 +610,7 @@ SwapChain::before_rendering ()
|
|||
D3D12_COMMAND_LIST_TYPE_DIRECT);
|
||||
if (completed < fence_val_to_wait) {
|
||||
gst_d3d12_device_fence_wait (resource_->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_val_to_wait,
|
||||
resource->event_handle);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_val_to_wait);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ struct GstDWriteD3D12RenderPrivate
|
|||
GstDWriteD3D12RenderPrivate ()
|
||||
{
|
||||
fence_data_pool = gst_d3d12_fence_data_pool_new ();
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
}
|
||||
|
||||
~GstDWriteD3D12RenderPrivate ()
|
||||
|
@ -52,14 +51,13 @@ struct GstDWriteD3D12RenderPrivate
|
|||
d2d_factory = nullptr;
|
||||
ClearResource ();
|
||||
gst_clear_object (&fence_data_pool);
|
||||
CloseHandle (event_handle);
|
||||
}
|
||||
|
||||
void ClearResource ()
|
||||
{
|
||||
if (device) {
|
||||
gst_d3d12_device_fence_wait (device, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||
fence_val, event_handle);
|
||||
fence_val);
|
||||
}
|
||||
|
||||
gst_clear_object (&ca_pool);
|
||||
|
@ -109,7 +107,6 @@ struct GstDWriteD3D12RenderPrivate
|
|||
GstD3D12Converter *blend_conv = nullptr;
|
||||
GstD3D12Converter *post_conv = nullptr;
|
||||
|
||||
HANDLE event_handle;
|
||||
guint64 fence_val = 0;
|
||||
|
||||
ComPtr<ID3D12GraphicsCommandList> cl;
|
||||
|
@ -331,7 +328,7 @@ gst_dwrite_d3d12_render_draw_layout (GstDWriteRender * render,
|
|||
auto fence_to_wait = priv->scheduled.front ();
|
||||
priv->scheduled.pop ();
|
||||
gst_d3d12_device_fence_wait (priv->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait, priv->event_handle);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait);
|
||||
}
|
||||
|
||||
GstBuffer *layout_buf = nullptr;
|
||||
|
@ -404,7 +401,7 @@ gst_dwrite_d3d12_render_blend (GstDWriteRender * render, GstBuffer * layout_buf,
|
|||
auto fence_to_wait = priv->scheduled.front ();
|
||||
priv->scheduled.pop ();
|
||||
gst_d3d12_device_fence_wait (priv->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait, priv->event_handle);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, fence_to_wait);
|
||||
}
|
||||
|
||||
GstD3D12Frame out_frame;
|
||||
|
|
|
@ -71,30 +71,20 @@ enum
|
|||
/* *INDENT-OFF* */
|
||||
struct GstWebView2SrcPrivate
|
||||
{
|
||||
GstWebView2SrcPrivate ()
|
||||
{
|
||||
event_handle = CreateEventEx (nullptr, nullptr, 0, EVENT_ALL_ACCESS);
|
||||
}
|
||||
|
||||
~GstWebView2SrcPrivate ()
|
||||
{
|
||||
ClearResource ();
|
||||
gst_clear_object (&object);
|
||||
gst_clear_object (&device12);
|
||||
gst_clear_object (&device);
|
||||
|
||||
CloseHandle (event_handle);
|
||||
}
|
||||
|
||||
void ClearResource ()
|
||||
{
|
||||
if (fence12) {
|
||||
auto completed = fence12->GetCompletedValue ();
|
||||
if (completed < fence_val) {
|
||||
auto hr = fence12->SetEventOnCompletion (fence_val, event_handle);
|
||||
if (SUCCEEDED (hr))
|
||||
WaitForSingleObject (event_handle, INFINITE);
|
||||
}
|
||||
if (completed < fence_val)
|
||||
fence12->SetEventOnCompletion (fence_val, nullptr);
|
||||
}
|
||||
|
||||
staging = nullptr;
|
||||
|
@ -124,7 +114,6 @@ struct GstWebView2SrcPrivate
|
|||
ComPtr<ID3D12Fence> fence12;
|
||||
gboolean can_d3d12_copy;
|
||||
UINT64 fence_val = 0;
|
||||
HANDLE event_handle;
|
||||
|
||||
/* properties */
|
||||
gint adapter_index = DEFAULT_ADAPTER;
|
||||
|
|
Loading…
Reference in a new issue