mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-13 23:22:54 +00:00
d3d12converter: Don't map output buffer with write flag
Conversion will happen when constructed command list is executed, not by converter element. Thus this object should not map output buffer with write flag which will result in error if multiple threads are building commands for the same output target frame. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5875>
This commit is contained in:
parent
bffbf0d951
commit
996346f8d3
5 changed files with 22 additions and 27 deletions
|
@ -23,8 +23,6 @@
|
|||
|
||||
#include "gstd3d12convert.h"
|
||||
#include "gstd3d12pluginutils.h"
|
||||
#include "gstd3d12fencedatapool.h"
|
||||
#include "gstd3d12commandallocatorpool.h"
|
||||
#include <directx/d3dx12.h>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
@ -2117,16 +2115,12 @@ gst_d3d12_convert_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
gst_d3d12_buffer_after_write (outbuf, priv->ctx->fence_val);
|
||||
|
||||
gst_d3d12_device_set_fence_notify (priv->ctx->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, priv->ctx->fence_val, fence_data,
|
||||
(GDestroyNotify) gst_d3d12_fence_data_unref);
|
||||
|
||||
auto num_mem = gst_buffer_n_memory (outbuf);
|
||||
for (guint i = 0; i < num_mem; i++) {
|
||||
auto mem = (GstD3D12Memory *) gst_buffer_peek_memory (outbuf, i);
|
||||
mem->fence_value = priv->ctx->fence_val;
|
||||
}
|
||||
|
||||
priv->ctx->scheduled.push (priv->ctx->fence_val);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
|
|
|
@ -2188,7 +2188,6 @@ gst_d3d12_converter_convert_buffer (GstD3D12Converter * converter,
|
|||
g_return_val_if_fail (cl, FALSE);
|
||||
|
||||
GstMapInfo in_info[GST_VIDEO_MAX_PLANES];
|
||||
GstMapInfo out_info[GST_VIDEO_MAX_PLANES];
|
||||
|
||||
gboolean need_upload = gst_d3d12_converter_check_needs_upload (converter,
|
||||
in_buf);
|
||||
|
@ -2205,22 +2204,11 @@ gst_d3d12_converter_convert_buffer (GstD3D12Converter * converter,
|
|||
gst_buffer_unref (in_buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gst_d3d12_converter_map_buffer (out_buf, out_info, GST_MAP_WRITE)) {
|
||||
GST_ERROR_OBJECT (converter, "Couldn't map output buffer");
|
||||
gst_d3d12_converter_unmap_buffer (in_buf, in_info);
|
||||
if (need_upload)
|
||||
gst_buffer_unref (in_buf);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
gst_d3d12_converter_unmap_buffer (in_buf, in_info);
|
||||
|
||||
auto ret = gst_d3d12_converter_execute (converter,
|
||||
in_buf, out_buf, fence_data, cl);
|
||||
|
||||
gst_d3d12_converter_unmap_buffer (out_buf, out_info);
|
||||
gst_d3d12_converter_unmap_buffer (in_buf, in_info);
|
||||
|
||||
/* fence data will hold this buffer */
|
||||
if (need_upload)
|
||||
gst_buffer_unref (in_buf);
|
||||
|
|
|
@ -69,3 +69,17 @@ gst_d3d12_sampling_method_to_native (GstD3D12SamplingMethod method)
|
|||
|
||||
return D3D12_FILTER_MIN_MAG_MIP_POINT;
|
||||
}
|
||||
|
||||
void
|
||||
gst_d3d12_buffer_after_write (GstBuffer * buffer, 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);
|
||||
dmem->fence_value = fence_value;
|
||||
GST_MINI_OBJECT_FLAG_SET (dmem, GST_D3D12_MEMORY_TRANSFER_NEED_DOWNLOAD);
|
||||
GST_MINI_OBJECT_FLAG_UNSET (dmem, GST_D3D12_MEMORY_TRANSFER_NEED_UPLOAD);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,7 @@ GType gst_d3d12_sampling_method_get_type (void);
|
|||
|
||||
D3D12_FILTER gst_d3d12_sampling_method_to_native (GstD3D12SamplingMethod method);
|
||||
|
||||
void gst_d3d12_buffer_after_write (GstBuffer * buffer,
|
||||
guint64 fence_value);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -2184,16 +2184,12 @@ gst_d3d12_test_src_create (GstBaseSrc * bsrc, guint64 offset,
|
|||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
gst_d3d12_buffer_after_write (convert_buffer, priv->ctx->fence_val);
|
||||
|
||||
gst_d3d12_device_set_fence_notify (self->device,
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, priv->ctx->fence_val, fence_data,
|
||||
(GDestroyNotify) gst_d3d12_fence_data_unref);
|
||||
|
||||
auto num_mem = gst_buffer_n_memory (convert_buffer);
|
||||
for (guint i = 0; i < num_mem; i++) {
|
||||
auto mem = (GstD3D12Memory *) gst_buffer_peek_memory (convert_buffer, i);
|
||||
mem->fence_value = priv->ctx->fence_val;
|
||||
}
|
||||
|
||||
priv->ctx->scheduled.push (priv->ctx->fence_val);
|
||||
|
||||
if (priv->downstream_supports_d3d12) {
|
||||
|
|
Loading…
Reference in a new issue