From 2c3f3c0cb6dd7df572ad4c85fa8fe9752cf34879 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Tue, 9 Jan 2024 19:45:16 +0900 Subject: [PATCH] d3d12device: Print live objects on finalize() The report from debug layer can help tracing resource leak Part-of: --- .../sys/d3d12/gstd3d12device.cpp | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.cpp b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.cpp index 52614eccad..2bd539ff46 100644 --- a/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.cpp +++ b/subprojects/gst-plugins-bad/sys/d3d12/gstd3d12device.cpp @@ -83,6 +83,44 @@ struct _GstD3D12DevicePrivate gst_clear_object (©_ca_pool); gst_clear_object (©_cl_pool); + + factory = nullptr; + adapter = nullptr; + d3d11on12 = nullptr; + + if (info_queue && device) { + ComPtr debug_dev; + device.As (&debug_dev); + if (debug_dev) { + debug_dev->ReportLiveDeviceObjects (D3D12_RLDO_DETAIL | + D3D12_RLDO_IGNORE_INTERNAL); + + UINT64 num_msg = info_queue->GetNumStoredMessages (); + for (UINT64 i = 0; i < num_msg; i++) { + HRESULT hr; + SIZE_T msg_len; + D3D12_MESSAGE *msg; + + hr = info_queue->GetMessage (i, nullptr, &msg_len); + if (FAILED (hr) || msg_len == 0) + continue; + + msg = (D3D12_MESSAGE *) g_malloc0 (msg_len); + hr = info_queue->GetMessage (i, msg, &msg_len); + if (FAILED (hr) || msg_len == 0) { + g_free (msg); + continue; + } + + gst_debug_log (gst_d3d12_sdk_debug, GST_LEVEL_INFO, + __FILE__, GST_FUNCTION, __LINE__, nullptr, + "D3D12InfoQueue: %s", msg->pDescription); + g_free (msg); + } + + info_queue->ClearStoredMessages (); + } + } } ComPtr device;