From eedc8f993f9b69db3e3d5540be55c5774b836342 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 18 Oct 2019 18:20:53 +0200 Subject: [PATCH] Examples: DX12: Using IDXGIDebug1::ReportLiveObjects() when DX12_ENABLE_DEBUG_LAYER is enabled. --- docs/CHANGELOG.txt | 1 + examples/example_win32_directx12/main.cpp | 29 ++++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index bed35ef38..c941f2cda 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -53,6 +53,7 @@ Other Changes: - Docs: Improved and moved FAQ to docs/FAQ.md so it can be readable on the web. [@ButternCream, @ocornut] - Docs: Added permanent redirect from https://www.dearimgui.org/faq to FAQ page. - Demo: Added simple item reordering demo in Widgets -> Drag and Drop section. (#2823, #143) [@rokups] +- Examples: DX12: Using IDXGIDebug1::ReportLiveObjects() when DX12_ENABLE_DEBUG_LAYER is enabled. - Backends: OSX: Fix using Backspace key. (#2578, #2817, #2818) [@DiligentGraphics] - Backends: GLFW: Previously installed user callbacks are now restored on shutdown. (#2836) [@malte-v] diff --git a/examples/example_win32_directx12/main.cpp b/examples/example_win32_directx12/main.cpp index 90631e852..e555051cd 100644 --- a/examples/example_win32_directx12/main.cpp +++ b/examples/example_win32_directx12/main.cpp @@ -9,7 +9,12 @@ #include #include -#define DX12_ENABLE_DEBUG_LAYER 0 +//#define DX12_ENABLE_DEBUG_LAYER + +#ifdef DX12_ENABLE_DEBUG_LAYER +#include +#pragma comment(lib, "dxguid.lib") +#endif struct FrameContext { @@ -233,15 +238,14 @@ bool CreateDeviceD3D(HWND hWnd) sd.Stereo = FALSE; } - if (DX12_ENABLE_DEBUG_LAYER) +#ifdef DX12_ENABLE_DEBUG_LAYER + ID3D12Debug* pdx12Debug = NULL; + if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&pdx12Debug)))) { - ID3D12Debug* dx12Debug = NULL; - if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&dx12Debug)))) - { - dx12Debug->EnableDebugLayer(); - dx12Debug->Release(); - } + pdx12Debug->EnableDebugLayer(); + pdx12Debug->Release(); } +#endif D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0; if (D3D12CreateDevice(NULL, featureLevel, IID_PPV_ARGS(&g_pd3dDevice)) != S_OK) @@ -329,6 +333,15 @@ void CleanupDeviceD3D() if (g_fence) { g_fence->Release(); g_fence = NULL; } if (g_fenceEvent) { CloseHandle(g_fenceEvent); g_fenceEvent = NULL; } if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } + +#ifdef DX12_ENABLE_DEBUG_LAYER + IDXGIDebug1* pDebug = NULL; + if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&pDebug)))) + { + pDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_SUMMARY); + pDebug->Release(); + } +#endif } void CreateRenderTarget()