mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
d3d12: Move fence setter helper method to gst-libs
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7057>
This commit is contained in:
parent
fa7c4a2e39
commit
2ec7d82bd7
11 changed files with 56 additions and 40 deletions
|
@ -631,19 +631,47 @@ gst_d3d12_buffer_copy_into (GstBuffer * dest, GstBuffer * src,
|
|||
gst_d3d12_frame_unmap (&dest_frame);
|
||||
gst_d3d12_frame_unmap (&src_frame);
|
||||
|
||||
auto fence = gst_d3d12_device_get_fence_handle (dest_device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT);
|
||||
|
||||
if (ret) {
|
||||
for (guint i = 0; i < num_mem; i++) {
|
||||
auto dmem = (GstD3D12Memory *) gst_buffer_peek_memory (dest, i);
|
||||
gst_d3d12_memory_set_fence (dmem, fence, fence_val, FALSE);
|
||||
}
|
||||
auto fence = gst_d3d12_device_get_fence_handle (dest_device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT);
|
||||
gst_d3d12_buffer_set_fence (dest, fence, fence_val, FALSE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_d3d12_buffer_set_fence:
|
||||
* @buffer: a #GstBuffer
|
||||
* @fence: (allow-none): a ID3D12Fence
|
||||
* @fence_value: fence value
|
||||
* @wait: waits previously configured fence in buffer
|
||||
*
|
||||
* Should be called after GPU write operation against @buffer.
|
||||
* This method will call gst_d3d12_memory_set_fence() for each memory in @buffer
|
||||
* and sets #GstD3D12MemoryTransfer flags to memory objects
|
||||
*
|
||||
* Since: 1.26
|
||||
*/
|
||||
void
|
||||
gst_d3d12_buffer_set_fence (GstBuffer * buffer, ID3D12Fence * fence,
|
||||
guint64 fence_value, gboolean wait)
|
||||
{
|
||||
g_return_if_fail (GST_IS_BUFFER (buffer));
|
||||
|
||||
auto num_mem = gst_buffer_n_memory (buffer);
|
||||
for (guint i = 0; i < num_mem; i++) {
|
||||
auto mem = gst_buffer_peek_memory (buffer, i);
|
||||
if (!gst_is_d3d12_memory (mem))
|
||||
return;
|
||||
|
||||
gst_d3d12_memory_set_fence (GST_D3D12_MEMORY_CAST (mem),
|
||||
fence, fence_value, wait);
|
||||
GST_MINI_OBJECT_FLAG_SET (mem, GST_D3D12_MEMORY_TRANSFER_NEED_DOWNLOAD);
|
||||
GST_MINI_OBJECT_FLAG_UNSET (mem, GST_D3D12_MEMORY_TRANSFER_NEED_UPLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* _gst_d3d12_result:
|
||||
* @result: HRESULT D3D12 API return code
|
||||
|
|
|
@ -65,6 +65,12 @@ gboolean gst_d3d12_buffer_copy_into (GstBuffer * dest,
|
|||
GstBuffer * src,
|
||||
const GstVideoInfo * info);
|
||||
|
||||
GST_D3D12_API
|
||||
void gst_d3d12_buffer_set_fence (GstBuffer * buffer,
|
||||
ID3D12Fence * fence,
|
||||
guint64 fence_value,
|
||||
gboolean wait);
|
||||
|
||||
GST_D3D12_API
|
||||
gboolean _gst_d3d12_result (HRESULT hr,
|
||||
GstD3D12Device * device,
|
||||
|
|
|
@ -2328,8 +2328,8 @@ gst_d3d12_compositor_draw_background (GstD3D12Compositor * self)
|
|||
|
||||
auto fence = gst_d3d12_device_get_fence_handle (self->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT);
|
||||
gst_d3d12_buffer_after_write (priv->generated_output_buf, fence,
|
||||
bg_render->fence_val);
|
||||
gst_d3d12_buffer_set_fence (priv->generated_output_buf, fence,
|
||||
bg_render->fence_val, FALSE);
|
||||
|
||||
if (bg_render->vertex_index_upload) {
|
||||
gst_d3d12_fence_data_push (fence_data,
|
||||
|
@ -2425,7 +2425,8 @@ gst_d3d12_compositor_aggregate_frames (GstVideoAggregator * vagg,
|
|||
}
|
||||
|
||||
fence_val = pad_priv->ctx->fence_val;
|
||||
gst_d3d12_buffer_after_write (priv->generated_output_buf, fence, fence_val);
|
||||
gst_d3d12_buffer_set_fence (priv->generated_output_buf,
|
||||
fence, fence_val, FALSE);
|
||||
}
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
|
|
|
@ -2037,7 +2037,7 @@ gst_d3d12_convert_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
gst_d3d12_buffer_after_write (outbuf, fence, priv->ctx->fence_val);
|
||||
gst_d3d12_buffer_set_fence (outbuf, fence, priv->ctx->fence_val, FALSE);
|
||||
gst_d3d12_command_queue_set_notify (cq, priv->ctx->fence_val,
|
||||
FENCE_NOTIFY_MINI_OBJECT (fence_data));
|
||||
|
||||
|
|
|
@ -1575,8 +1575,8 @@ gst_d3d12_decoder_process_output (GstD3D12Decoder * self,
|
|||
priv->session->staging->Unmap (0, nullptr);
|
||||
gst_video_frame_unmap (&vframe);
|
||||
} else {
|
||||
gst_d3d12_buffer_after_write (frame->output_buffer,
|
||||
fence, copy_fence_val);
|
||||
gst_d3d12_buffer_set_fence (frame->output_buffer,
|
||||
fence, copy_fence_val, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1430,8 +1430,8 @@ gst_d3d12_dxgi_capture_draw_mouse (GstD3D12DxgiCapture * self,
|
|||
|
||||
gst_d3d12_command_queue_set_notify (cq, fence_val, fence_data,
|
||||
(GDestroyNotify) gst_d3d12_fence_data_unref);
|
||||
gst_d3d12_buffer_after_write (buffer,
|
||||
gst_d3d12_command_queue_get_fence_handle (cq), fence_val);
|
||||
gst_d3d12_buffer_set_fence (buffer,
|
||||
gst_d3d12_command_queue_get_fence_handle (cq), fence_val, FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -784,9 +784,9 @@ gst_d3d12_encoder_upload_frame (GstD3D12Encoder * self, GstBuffer * buffer)
|
|||
gst_d3d12_device_copy_texture_region (self->device, copy_args.size (),
|
||||
copy_args.data (), nullptr, num_fences_to_wait, fences_to_wait,
|
||||
fence_values_to_wait, D3D12_COMMAND_LIST_TYPE_DIRECT, &fence_val);
|
||||
gst_d3d12_buffer_after_write (upload,
|
||||
gst_d3d12_buffer_set_fence (upload,
|
||||
gst_d3d12_device_get_fence_handle (self->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT), fence_val);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT), fence_val, FALSE);
|
||||
} else {
|
||||
GstVideoFrame src_frame, dst_frame;
|
||||
if (!gst_video_frame_map (&src_frame, info, buffer, GST_MAP_READ)) {
|
||||
|
|
|
@ -525,9 +525,9 @@ gst_d3d12_ipc_client_have_data (GstD3D12IpcClient * self)
|
|||
gst_d3d12_command_queue_set_notify (queue, copy_fence_val, data,
|
||||
(GDestroyNotify) gst_d3d12_ipc_client_release_imported_data);
|
||||
|
||||
gst_d3d12_buffer_after_write (buffer,
|
||||
gst_d3d12_buffer_set_fence (buffer,
|
||||
gst_d3d12_device_get_fence_handle (priv->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT), copy_fence_val);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT), copy_fence_val, FALSE);
|
||||
|
||||
lk.lock ();
|
||||
} else {
|
||||
|
|
|
@ -113,21 +113,6 @@ gst_d3d12_msaa_mode_get_type (void)
|
|||
return type;
|
||||
}
|
||||
|
||||
void
|
||||
gst_d3d12_buffer_after_write (GstBuffer * buffer, ID3D12Fence * fence,
|
||||
guint64 fence_value)
|
||||
{
|
||||
for (guint i = 0; i < gst_buffer_n_memory (buffer); i++) {
|
||||
auto mem = gst_buffer_peek_memory (buffer, i);
|
||||
g_return_if_fail (gst_is_d3d12_memory (mem));
|
||||
|
||||
auto dmem = GST_D3D12_MEMORY_CAST (mem);
|
||||
gst_d3d12_memory_set_fence (dmem, fence, fence_value, FALSE);
|
||||
GST_MINI_OBJECT_FLAG_SET (dmem, GST_D3D12_MEMORY_TRANSFER_NEED_DOWNLOAD);
|
||||
GST_MINI_OBJECT_FLAG_UNSET (dmem, GST_D3D12_MEMORY_TRANSFER_NEED_UPLOAD);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_d3d12_need_transform (gfloat rotation_x, gfloat rotation_y,
|
||||
gfloat rotation_z, gfloat scale_x, gfloat scale_y)
|
||||
|
|
|
@ -49,10 +49,6 @@ enum GstD3D12MSAAMode
|
|||
#define GST_TYPE_D3D12_MSAA_MODE (gst_d3d12_msaa_mode_get_type())
|
||||
GType gst_d3d12_msaa_mode_get_type (void);
|
||||
|
||||
void gst_d3d12_buffer_after_write (GstBuffer * buffer,
|
||||
ID3D12Fence * fence,
|
||||
guint64 fence_value);
|
||||
|
||||
gboolean gst_d3d12_need_transform (gfloat rotation_x,
|
||||
gfloat rotation_y,
|
||||
gfloat rotation_z,
|
||||
|
|
|
@ -2229,9 +2229,9 @@ gst_d3d12_test_src_create (GstBaseSrc * bsrc, guint64 offset,
|
|||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
gst_d3d12_buffer_after_write (convert_buffer,
|
||||
gst_d3d12_buffer_set_fence (convert_buffer,
|
||||
gst_d3d12_device_get_fence_handle (self->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT), priv->ctx->fence_val);
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT), priv->ctx->fence_val, FALSE);
|
||||
|
||||
gst_d3d12_device_set_fence_notify (self->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, priv->ctx->fence_val,
|
||||
|
|
Loading…
Reference in a new issue