summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2024-04-27 20:23:32 +0900
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2024-04-28 12:49:07 +0000
commite29655e9cadea18c59b9f5ea4d48ea46e8e1c7d8 (patch)
treeabc8fcc7adc074c56b4bd40b767d50f8eacbefca
parent3e08cdeebe21886656144913e962c56fb0eefd3c (diff)
d3d12screencapturesrc: Release and flush d3d11 objects before d3d12
Fixing device-removed error when closing pipeline Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6749>
-rw-r--r--subprojects/gst-plugins-bad/sys/d3d12/gstd3d12dxgicapture.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12dxgicapture.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12dxgicapture.cpp
index d21bb24cc3..6d6b6c6530 100644
--- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12dxgicapture.cpp
+++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12dxgicapture.cpp
@@ -264,6 +264,14 @@ class DesktopDupCtx
public:
DesktopDupCtx () {}
+ ~DesktopDupCtx ()
+ {
+ if (context_) {
+ context_->ClearState ();
+ context_->Flush ();
+ }
+ }
+
GstFlowReturn Init (HMONITOR monitor, HANDLE fence_handle)
{
ComPtr<IDXGIAdapter1> adapter;
@@ -894,6 +902,7 @@ struct GstD3D12DxgiCapturePrivate
~GstD3D12DxgiCapturePrivate ()
{
WaitGPU ();
+ ctx = nullptr;
CloseHandle (event_handle);
if (shared_fence_handle)
CloseHandle (shared_fence_handle);
@@ -1469,7 +1478,6 @@ gst_d3d12_dxgi_capture_do_capture (GstD3D12DxgiCapture * capture,
ret = priv->ctx->Execute (texture, (D3D11_BOX *) crop_box, priv->fence_val);
if (ret != GST_FLOW_OK) {
priv->WaitGPU ();
-
priv->ctx = nullptr;
if (ret == GST_D3D12_SCREEN_CAPTURE_FLOW_EXPECTED_ERROR) {
GST_WARNING_OBJECT (self, "Couldn't capture frame, but expected failure");
@@ -1485,6 +1493,7 @@ gst_d3d12_dxgi_capture_do_capture (GstD3D12DxgiCapture * capture,
if (draw_mouse && !gst_d3d12_dxgi_capture_draw_mouse (self, buffer, crop_box)) {
priv->WaitGPU ();
+ priv->ctx = nullptr;
return GST_FLOW_ERROR;
}