d3d11memory: Protect against concurrent access from GPU and CPU to staging texture
authorSeungha Yang <seungha@centricular.com>
Thu, 5 May 2022 16:46:36 +0000 (01:46 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 5 May 2022 18:59:05 +0000 (18:59 +0000)
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2375>

subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11memory.cpp

index a0d41e8..21262d1 100644 (file)
@@ -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);
 }