From: Seungha Yang Date: Thu, 5 May 2022 16:46:36 +0000 (+0900) Subject: d3d11memory: Protect against concurrent access from GPU and CPU to staging texture X-Git-Tag: 1.22.0~1666 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47ff41bcd2519257b275b191cd93284269344bd8;p=platform%2Fupstream%2Fgstreamer.git d3d11memory: Protect against concurrent access from GPU and CPU to staging texture Staging texture does not allow GPU access while it's CPU mapped. But because we cannot block concurrent READ access by GstMemory design, additional staging texture is still required. Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1182 Part-of: --- diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp index a0d41e8..21262d1 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp @@ -342,7 +342,7 @@ gst_d3d11_memory_upload (GstD3D11Memory * dmem) GstD3D11MemoryPrivate *priv = dmem->priv; ID3D11DeviceContext *device_context; - if (!priv->staging || priv->staging == priv->texture || + if (!priv->staging || !GST_MEMORY_FLAG_IS_SET (dmem, GST_D3D11_MEMORY_TRANSFER_NEED_UPLOAD)) return; @@ -358,7 +358,7 @@ gst_d3d11_memory_download (GstD3D11Memory * dmem) GstD3D11MemoryPrivate *priv = dmem->priv; ID3D11DeviceContext *device_context; - if (!priv->staging || priv->staging == priv->texture || + if (!priv->staging || !GST_MEMORY_FLAG_IS_SET (dmem, GST_D3D11_MEMORY_TRANSFER_NEED_DOWNLOAD)) return; @@ -1433,12 +1433,6 @@ gst_d3d11_allocator_alloc_wrapped (GstD3D11Allocator * self, mem->priv->native_type = GST_D3D11_MEMORY_NATIVE_TYPE_TEXTURE_2D; mem->device = (GstD3D11Device *) gst_object_ref (device); - /* This is staging texture as well */ - if (desc->Usage == D3D11_USAGE_STAGING) { - mem->priv->staging = texture; - texture->AddRef (); - } - return GST_MEMORY_CAST (mem); }