From 47ff41bcd2519257b275b191cd93284269344bd8 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 6 May 2022 01:46:36 +0900 Subject: [PATCH] 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: --- .../gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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); } -- 2.7.4