using Ghost.Graphics.Contracts; using Win32; using Win32.Graphics.Direct3D12; using Win32.Graphics.Dxgi; namespace Ghost.Graphics.D3D12; internal unsafe class D3D12DebugLayer : IDebugLayer { private readonly ComPtr _d3d12Debug; private readonly ComPtr _dxgiDebug; private readonly ComPtr _dxgiInfoQueue; public D3D12DebugLayer() { D3D12GetDebugInterface(__uuidof(), _d3d12Debug.GetVoidAddressOf()); _d3d12Debug.Get()->EnableDebugLayer(); DXGIGetDebugInterface1(0u, __uuidof(), _dxgiDebug.GetVoidAddressOf()); _dxgiDebug.Get()->EnableLeakTrackingForThread(); DXGIGetDebugInterface1(0u, __uuidof(), _dxgiInfoQueue.GetVoidAddressOf()); _dxgiInfoQueue.Get()->SetBreakOnSeverity(DXGI_DEBUG_ALL, InfoQueueMessageSeverity.Error, true); _dxgiInfoQueue.Get()->SetBreakOnSeverity(DXGI_DEBUG_ALL, InfoQueueMessageSeverity.Corruption, true); } public void Dispose() { _dxgiDebug.Get()->ReportLiveObjects(DXGI_DEBUG_ALL, ReportLiveObjectFlags.Detail | ReportLiveObjectFlags.IgnoreInternal); _d3d12Debug.Dispose(); _dxgiDebug.Dispose(); _dxgiInfoQueue.Dispose(); } }