diff options
| author | skallweitNV <64953474+skallweitNV@users.noreply.github.com> | 2023-01-25 17:48:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-25 08:48:55 -0800 |
| commit | ae11538f5d667b11d3b3191a827093f3727eed1b (patch) | |
| tree | 2670eaad8f6f46484f995ecb28b10883c412c3ea /tools/gfx/d3d/d3d-util.cpp | |
| parent | 951ad25e0a9c3b0089c6b996b8e821ac93cf5766 (diff) | |
GFX report live objects (#2609)
* Add utility to call D3D ReportLiveObjects
* Add gfxReportLiveObjects API call
* Only warn on swapchain image references
Diffstat (limited to 'tools/gfx/d3d/d3d-util.cpp')
| -rw-r--r-- | tools/gfx/d3d/d3d-util.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/gfx/d3d/d3d-util.cpp b/tools/gfx/d3d/d3d-util.cpp index dff93810c..05a948773 100644 --- a/tools/gfx/d3d/d3d-util.cpp +++ b/tools/gfx/d3d/d3d-util.cpp @@ -4,6 +4,7 @@ #include <d3d12.h> #include <d3dcompiler.h> #include <dxgi1_4.h> +#include <dxgidebug.h> // We will use the C standard library just for printing error messages. #include <stdio.h> @@ -836,6 +837,38 @@ D3D12_RESOURCE_STATES D3DUtil::getResourceState(ResourceState state) } } +/* static */SlangResult D3DUtil::reportLiveObjects() +{ + static IDXGIDebug* dxgiDebug = nullptr; + + if (!dxgiDebug) + { + HMODULE debugModule = LoadLibraryA("dxgidebug.dll"); + if (debugModule != INVALID_HANDLE_VALUE) + { + auto fun = reinterpret_cast<decltype(&DXGIGetDebugInterface)>(GetProcAddress(debugModule, "DXGIGetDebugInterface")); + if (fun) + { + fun(__uuidof(IDXGIDebug), (void**)&dxgiDebug); + } + } + } + + if (dxgiDebug) + { + const GUID DXGI_DEBUG_ALL_ = { 0xe48ae283, 0xda80, 0x490b, { 0x87, 0xe6, 0x43, 0xe9, 0xa9, 0xcf, 0xda, 0x8 } }; + dxgiDebug->ReportLiveObjects(DXGI_DEBUG_ALL_, DXGI_DEBUG_RLO_ALL); + return SLANG_OK; + } + + return SLANG_E_NOT_AVAILABLE; +} + +Result SLANG_MCALL reportD3DLiveObjects() +{ + return D3DUtil::reportLiveObjects(); +} + /* static */SlangResult D3DUtil::findAdapters(DeviceCheckFlags flags, const AdapterLUID* adapterLUID, IDXGIFactory* dxgiFactory, List<ComPtr<IDXGIAdapter>>& outDxgiAdapters) { outDxgiAdapters.clear(); |
