[vlc-commits] d3d11_fmt: allow logging DXGI/D3D11 resources at any time

Steve Lhomme git at videolan.org
Tue Jan 7 10:22:55 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jan  7 09:55:46 2020 +0100| [9d7a6264cbbd8387a4772d665f4949f1d081b8a7] | committer: Steve Lhomme

d3d11_fmt: allow logging DXGI/D3D11 resources at any time

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9d7a6264cbbd8387a4772d665f4949f1d081b8a7
---

 modules/video_chroma/d3d11_fmt.c | 40 ++++++++++++++++++++++++++++------------
 modules/video_chroma/d3d11_fmt.h |  2 ++
 2 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/modules/video_chroma/d3d11_fmt.c b/modules/video_chroma/d3d11_fmt.c
index dddbfbb86b..7c6a1ede1e 100644
--- a/modules/video_chroma/d3d11_fmt.c
+++ b/modules/video_chroma/d3d11_fmt.c
@@ -721,28 +721,44 @@ int D3D11_Create(vlc_object_t *obj, d3d11_handle_t *hd3d, bool with_shaders)
             return VLC_EGENERIC;
         }
     }
+# if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
+    if (IsDebuggerPresent())
+    {
+        hd3d->dxgidebug_dll = LoadLibrary(TEXT("DXGIDEBUG.DLL"));
+        if (hd3d->dxgidebug_dll)
+        {
+            hd3d->pf_DXGIGetDebugInterface =
+                    (void *)GetProcAddress(hd3d->dxgidebug_dll, "DXGIGetDebugInterface");
+            if (unlikely(!hd3d->pf_DXGIGetDebugInterface))
+            {
+                FreeLibrary(hd3d->dxgidebug_dll);
+                hd3d->dxgidebug_dll = NULL;
+            }
+        }
+    }
+# endif // !NDEBUG && HAVE_DXGIDEBUG_H
 #endif
     return VLC_SUCCESS;
 }
 
-void D3D11_Destroy(d3d11_handle_t *hd3d)
+void D3D11_LogResources(d3d11_handle_t *hd3d)
 {
 #if !VLC_WINSTORE_APP
 # if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
-    if (IsDebuggerPresent())
+    if (hd3d->pf_DXGIGetDebugInterface)
     {
-        hd3d->dxgidebug_dll = LoadLibrary(TEXT("DXGIDEBUG.DLL"));
-        HRESULT (WINAPI * pf_DXGIGetDebugInterface)(const GUID *riid, void **ppDebug) = NULL;
-        if (hd3d->dxgidebug_dll)
-            pf_DXGIGetDebugInterface =
-                    (void *)GetProcAddress(hd3d->dxgidebug_dll, "DXGIGetDebugInterface");
-        if (pf_DXGIGetDebugInterface) {
-            IDXGIDebug *pDXGIDebug;
-            if (SUCCEEDED(pf_DXGIGetDebugInterface(&IID_IDXGIDebug, (void**)&pDXGIDebug)))
-                IDXGIDebug_ReportLiveObjects(pDXGIDebug, DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL);
-        }
+        IDXGIDebug *pDXGIDebug;
+        if (SUCCEEDED(hd3d->pf_DXGIGetDebugInterface(&IID_IDXGIDebug, (void**)&pDXGIDebug)))
+            IDXGIDebug_ReportLiveObjects(pDXGIDebug, DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL);
     }
 # endif
+#endif
+}
+
+void D3D11_Destroy(d3d11_handle_t *hd3d)
+{
+    D3D11_LogResources(hd3d);
+#if !VLC_WINSTORE_APP
     if (hd3d->hdll)
         FreeLibrary(hd3d->hdll);
 
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index f1350f84e7..da0a69a46e 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -61,6 +61,7 @@ typedef struct
     pD3DCompile               OurD3DCompile;
 #if !defined(NDEBUG) && defined(HAVE_DXGIDEBUG_H)
     HINSTANCE                 dxgidebug_dll;
+    HRESULT (WINAPI * pf_DXGIGetDebugInterface)(const GUID *riid, void **ppDebug);
 #endif
 #endif
 } d3d11_handle_t;
@@ -163,6 +164,7 @@ int D3D11_Create(vlc_object_t *, d3d11_handle_t *, bool with_shaders);
 #define D3D11_Create(a,b,c) D3D11_Create( VLC_OBJECT(a), b, c )
 
 void D3D11_Destroy(d3d11_handle_t *);
+void D3D11_LogResources(d3d11_handle_t *);
 
 bool isXboxHardware(ID3D11Device *d3ddev);
 IDXGIAdapter *D3D11DeviceAdapter(ID3D11Device *d3ddev);



More information about the vlc-commits mailing list