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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2375>
This commit is contained in:
Seungha Yang 2022-05-06 01:46:36 +09:00 committed by GStreamer Marge Bot
parent e0a9a73adf
commit 47ff41bcd2

View 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);
}