Refactor GPU resource management and rendering pipeline

- Introduced `Handle<T>` and `Identifier<T>` for lightweight, strongly-typed resource identifiers.
- Replaced `BitSet` with `UnsafeBitSet` for improved performance and memory safety.
- Refactored `Mesh` and `Material` into `MeshClass` and `MaterialClass` for better GPU resource handling.
- Added `D3D12ResourceDatabase` to centralize GPU resource tracking and lifecycle management.
- Updated `D3D12ShaderCompiler` to load shaders from disk and dynamically populate constant buffers and textures.
- Enhanced `ICommandBuffer` with new upload operations for buffers and textures.
- Refactored `Vertex` struct for simplified memory layout and better performance.
- Updated `MeshBuilder` and rendering logic to align with new resource and shader structures.
- Added `BindlessDescriptor` support to `TextureHandle` and `BufferHandle`.
- Removed unused classes and performed general cleanup.
- Updated unit tests and demos to reflect the new architecture.
This commit is contained in:
2025-09-19 23:20:15 +09:00
parent 6a504cefc8
commit a39f377533
39 changed files with 1669 additions and 826 deletions

View File

@@ -34,7 +34,7 @@ internal class RenderSystem
private const uint _FRAME_COUNT = 2;
private readonly IGraphicsEngine _engine = null!;
private readonly IGraphicsEngine _graphicsEngine = null!;
private readonly FrameResource[] _frameResources = null!;
private readonly Thread _renderThread = null!;
private readonly AutoResetEvent _shutdownEvent = null!;
@@ -47,14 +47,14 @@ internal class RenderSystem
private bool _isRunning;
private bool _disposed;
public IGraphicsEngine GraphicsEngine => _engine;
public IGraphicsEngine GraphicsEngine => _graphicsEngine;
public uint CPUFenceValue => _cpuFenceValue;
public uint GPUFenceValue => _gpuFenceValue;
public bool IsRunning => _isRunning;
public RenderSystem(GraphicsAPI api)
{
_engine = api switch
_graphicsEngine = api switch
{
GraphicsAPI.Direct3D12 => new D3D12.D3D12GraphicsEngine(this),
_ => throw new NotSupportedException($"Graphics API {api} is not supported.")
@@ -84,7 +84,7 @@ internal class RenderSystem
{
ObjectDisposedException.ThrowIf(_disposed, this);
var renderer = _engine.CreateRenderer();
var renderer = _graphicsEngine.CreateRenderer();
ImmutableInterlocked.Update(ref _renderers, renderers => renderers.Add(renderer));
return renderer;
}
@@ -166,12 +166,16 @@ internal class RenderSystem
// Only proceed if CPU ready event was signaled
if (waitResult == 0)
{
_graphicsEngine.BeginFrame();
foreach (var renderer in _renderers)
{
renderer.ExecutePendingResize();
renderer.Render();
}
_graphicsEngine.EndFrame();
_gpuFenceValue++;
frameResource.gpuReadyEvent.Set();
}