d3d11: Log device removed reason

... and live objects. It could be useful hint for GPU debugging

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4170>
This commit is contained in:
Seungha Yang 2023-03-14 20:56:14 +09:00 committed by GStreamer Marge Bot
parent a9c5e5e239
commit a88d90b777
3 changed files with 55 additions and 16 deletions

View file

@ -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 (); \

View file

@ -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

View file

@ -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)