Refactor core systems and improve resource management

- 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.
This commit is contained in:
2025-11-23 15:02:37 +09:00
parent 5c4e1a3350
commit dfe786a2aa
46 changed files with 1193 additions and 733 deletions

View File

@@ -14,9 +14,9 @@ using static TerraFX.Aliases.DXGI_Alias;
namespace Ghost.Graphics.D3D12;
internal unsafe class D3D12CommandBuffer : D3D12RHIObject<ID3D12GraphicsCommandList10>, ICommandBuffer
internal unsafe class D3D12CommandBuffer : D3D12Object<ID3D12GraphicsCommandList10>, ICommandBuffer
{
private ComPtr<ID3D12CommandAllocator> _allocator;
private UniquePtr<ID3D12CommandAllocator> _allocator;
private readonly D3D12PipelineLibrary _pipelineLibrary;
private readonly D3D12ResourceDatabase _resourceDatabase;
@@ -282,8 +282,15 @@ internal unsafe class D3D12CommandBuffer : D3D12RHIObject<ID3D12GraphicsCommandL
ThrowIfNotRecording();
IncrementCommandCount();
var shaderPipeline = _pipelineLibrary.GetGraphicsPSO(pipelineKey).GetValueOrThrow();
nativeObject.Get()->SetPipelineState(shaderPipeline.value);
var psor = _pipelineLibrary.GetGraphicsPSO(pipelineKey);
if (psor.Status != ResultStatus.Success)
{
#if DEBUG || GHOST_EDITOR
Logger.LogError($"Failed to get graphics pipeline state object for key {pipelineKey}: {psor.Status}");
#endif
}
nativeObject.Get()->SetPipelineState(psor.Value);
}
public void SetConstantBufferView(uint slot, Handle<GraphicsBuffer> buffer)
@@ -479,7 +486,7 @@ internal unsafe class D3D12CommandBuffer : D3D12RHIObject<ID3D12GraphicsCommandL
protected override void Dispose(bool disposing)
{
if (IsDisposed)
if (Disposed)
{
return;
}
@@ -489,7 +496,7 @@ internal unsafe class D3D12CommandBuffer : D3D12RHIObject<ID3D12GraphicsCommandL
throw new InvalidOperationException("Command buffer is still recording");
}
MemoryLeakException.ThrowIfRefCountNonZero(_allocator.Reset());
_allocator.Dispose();
_commandCount = 0;
base.Dispose(disposing);