forked from Misaki/GhostEngine
- Updated dependencies, including `Misaki.HighPerformance` and `TerraFX.Interop`. - Refactored `Result` struct for better error handling and chaining. - Removed `Ptr<T>` struct as it was no longer necessary. - Enhanced `Win32Utility` with `Attach` and `Dispose` methods. - Improved `ProjectService` and `AppStateMachine` with `Result` integration. - Refactored `IShaderCompiler` to support SPIR-V cross-compilation and pass-level compilation. - Standardized Direct3D12 resource management with `UniquePtr` and added `D3D12Object` base class. - Improved shader reflection validation and pipeline creation in `D3D12PipelineLibrary`. - Updated `SDLCompiler` for better error handling during shader generation. - Enhanced logging, debugging, and code readability across the codebase. - Performed general code cleanup, including unused namespace removal and naming consistency.
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using Ghost.Core.Utilities;
|
|
using Misaki.HighPerformance.LowLevel;
|
|
using TerraFX.Interop.DirectX;
|
|
using TerraFX.Interop.Windows;
|
|
|
|
using static TerraFX.Aliases.DXGI_Alias;
|
|
|
|
namespace Ghost.Graphics.D3D12;
|
|
|
|
internal unsafe class D3D12DebugLayer
|
|
{
|
|
private UniquePtr<ID3D12Debug6> _d3d12Debug;
|
|
private UniquePtr<IDXGIDebug1> _dxgiDebug;
|
|
private UniquePtr<IDXGIInfoQueue> _dxgiInfoQueue;
|
|
|
|
public D3D12DebugLayer()
|
|
{
|
|
ID3D12Debug6* pDebug = default;
|
|
ThrowIfFailed(D3D12GetDebugInterface(__uuidof(pDebug), (void**)&pDebug));
|
|
pDebug->EnableDebugLayer();
|
|
|
|
IDXGIDebug1* pDxgiDebug = default;
|
|
ThrowIfFailed(DXGIGetDebugInterface1(0u, __uuidof(pDxgiDebug), (void**)&pDxgiDebug));
|
|
pDxgiDebug->EnableLeakTrackingForThread();
|
|
|
|
IDXGIInfoQueue* pDxgiInfoQueue = default;
|
|
ThrowIfFailed(DXGIGetDebugInterface1(0u, __uuidof(pDxgiInfoQueue), (void**)&pDxgiInfoQueue));
|
|
ThrowIfFailed(pDxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, true));
|
|
ThrowIfFailed(pDxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, true));
|
|
|
|
_d3d12Debug.Attach(pDebug);
|
|
_dxgiDebug.Attach(pDxgiDebug);
|
|
_dxgiInfoQueue.Attach(pDxgiInfoQueue);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
ThrowIfFailed(_dxgiDebug.Get()->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL | DXGI_DEBUG_RLO_IGNORE_INTERNAL));
|
|
|
|
_d3d12Debug.Dispose();
|
|
_dxgiDebug.Dispose();
|
|
_dxgiInfoQueue.Dispose();
|
|
}
|
|
} |