diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11-private.h b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11-private.h index 35182500e9..892416cf07 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11-private.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11-private.h @@ -61,6 +61,11 @@ void gst_d3d11_device_dxgi_debug (GstD3D11Device * device, const gchar * function, gint line); +void gst_d3d11_device_log_live_objects (GstD3D11Device * device, + const gchar * file, + const gchar * function, + gint line); + #define GST_D3D11_CLEAR_COM(obj) G_STMT_START { \ if (obj) { \ (obj)->Release (); \ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp index 2a5c77b9df..01627087f9 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11device.cpp @@ -698,6 +698,31 @@ gst_d3d11_device_get_property (GObject * object, guint prop_id, } } +void +gst_d3d11_device_log_live_objects (GstD3D11Device * device, + const gchar * file, const gchar * function, gint line) +{ +#if HAVE_D3D11SDKLAYERS_H + if (device->priv->d3d11_debug) { + device->priv->d3d11_debug->ReportLiveDeviceObjects ((D3D11_RLDO_FLAGS) + GST_D3D11_RLDO_FLAGS); + } + + if (device->priv->d3d11_info_queue) + gst_d3d11_device_d3d11_debug (device, file, function, line); +#endif + +#if HAVE_DXGIDEBUG_H + if (device->priv->dxgi_debug) { + device->priv->dxgi_debug->ReportLiveObjects (DXGI_DEBUG_ALL, + (DXGI_DEBUG_RLO_FLAGS) GST_D3D11_RLDO_FLAGS); + } + + if (device->priv->dxgi_info_queue) + gst_d3d11_device_dxgi_debug (device, file, function, line); +#endif +} + static void gst_d3d11_device_dispose (GObject * object) { @@ -713,29 +738,15 @@ gst_d3d11_device_dispose (GObject * object) GST_D3D11_CLEAR_COM (priv->device); GST_D3D11_CLEAR_COM (priv->device_context); GST_D3D11_CLEAR_COM (priv->factory); + gst_d3d11_device_log_live_objects (self, __FILE__, GST_FUNCTION, __LINE__); + #if HAVE_D3D11SDKLAYERS_H - if (priv->d3d11_debug) { - priv->d3d11_debug->ReportLiveDeviceObjects ((D3D11_RLDO_FLAGS) - GST_D3D11_RLDO_FLAGS); - } GST_D3D11_CLEAR_COM (priv->d3d11_debug); - - if (priv->d3d11_info_queue) - gst_d3d11_device_d3d11_debug (self, __FILE__, GST_FUNCTION, __LINE__); - GST_D3D11_CLEAR_COM (priv->d3d11_info_queue); #endif #if HAVE_DXGIDEBUG_H - if (priv->dxgi_debug) { - priv->dxgi_debug->ReportLiveObjects (DXGI_DEBUG_ALL, - (DXGI_DEBUG_RLO_FLAGS) GST_D3D11_RLDO_FLAGS); - } GST_D3D11_CLEAR_COM (priv->dxgi_debug); - - if (priv->dxgi_info_queue) - gst_d3d11_device_dxgi_debug (self, __FILE__, GST_FUNCTION, __LINE__); - GST_D3D11_CLEAR_COM (priv->dxgi_info_queue); #endif diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11utils.cpp b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11utils.cpp index 23ad2cbd08..5458a75c7b 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11utils.cpp +++ b/subprojects/gst-plugins-bad/gst-libs/gst/d3d11/gstd3d11utils.cpp @@ -550,6 +550,21 @@ gst_d3d11_luid_to_int64 (const LUID * luid) return val.QuadPart; } +static void +gst_d3d11_log_gpu_remove_reason (HRESULT hr, GstD3D11Device * device, + GstDebugCategory * cat, const gchar * file, const gchar * function, + gint line) +{ + gchar *error_text = g_win32_error_message ((guint) hr); + + gst_debug_log (cat, GST_LEVEL_ERROR, file, function, line, + NULL, "DeviceRemovedReason: 0x%x, %s", (guint) hr, + GST_STR_NULL (error_text)); + g_free (error_text); + + gst_d3d11_device_log_live_objects (device, file, function, line); +} + /** * _gst_d3d11_result: * @result: HRESULT D3D11 API return code @@ -584,6 +599,14 @@ _gst_d3d11_result (HRESULT hr, GstD3D11Device * device, GstDebugCategory * cat, GST_STR_NULL (error_text)); g_free (error_text); + if (device) { + ID3D11Device *device_handle = gst_d3d11_device_get_device_handle (device); + hr = device_handle->GetDeviceRemovedReason (); + if (hr != S_OK) { + gst_d3d11_log_gpu_remove_reason (hr, device, cat, file, function, line); + } + } + ret = FALSE; } #if (HAVE_D3D11SDKLAYERS_H || HAVE_DXGIDEBUG_H)