From ae11538f5d667b11d3b3191a827093f3727eed1b Mon Sep 17 00:00:00 2001 From: skallweitNV <64953474+skallweitNV@users.noreply.github.com> Date: Wed, 25 Jan 2023 17:48:55 +0100 Subject: GFX report live objects (#2609) * Add utility to call D3D ReportLiveObjects * Add gfxReportLiveObjects API call * Only warn on swapchain image references --- tools/gfx/d3d/d3d-util.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tools/gfx/d3d/d3d-util.cpp') 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 #include #include +#include // We will use the C standard library just for printing error messages. #include @@ -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(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>& outDxgiAdapters) { outDxgiAdapters.clear(); -- cgit v1.2.3