d3d12decoder: Lock DPB while building command

Since DPB resource can be modified in output thread, protect
it when building command list.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6717>
This commit is contained in:
Seungha Yang 2024-04-23 01:40:44 +09:00 committed by Backport Bot
parent d22fe06234
commit 06e955f94e

View file

@ -125,7 +125,6 @@ public:
subresources_[id] = 0;
heaps_[id] = nullptr;
cond_.notify_one ();
}
@ -137,24 +136,14 @@ public:
frames.ppHeaps = heaps_.data ();
}
guint8 GetSize ()
void Lock ()
{
return size_;
lock_.lock ();
}
ID3D12Resource ** GetTextures ()
void Unlock ()
{
return &textures_[0];
}
UINT * GetSubresources ()
{
return &subresources_[0];
}
ID3D12VideoDecoderHeap ** GetHeaps ()
{
return &heaps_[0];
lock_.unlock ();
}
private:
@ -1265,6 +1254,7 @@ gst_d3d12_decoder_end_picture (GstD3D12Decoder * decoder,
in_args.CompressedBitstream.Size = args->bitstream_size;
in_args.pHeap = decoder_pic->heap.Get ();
priv->session->dpb->Lock ();
priv->session->dpb->GetReferenceFrames (in_args.ReferenceFrames);
priv->cmd->cl->DecodeFrame (priv->session->decoder.Get (),
@ -1274,6 +1264,8 @@ gst_d3d12_decoder_end_picture (GstD3D12Decoder * decoder,
priv->cmd->cl->ResourceBarrier (post_barriers.size (), &post_barriers[0]);
hr = priv->cmd->cl->Close ();
priv->session->dpb->Unlock ();
if (!gst_d3d12_result (hr, decoder->device)) {
GST_ERROR_OBJECT (decoder, "Couldn't record decoding command");
gst_d3d12_command_allocator_unref (gst_ca);