feat(rendergraph): async queue, pool refactor, barrier cleanup

Refactor resource pool to use UnsafeQueue/UnsafeList for transient resources, improving memory management and performance.
Add async GPU wait support to ICommandQueue and D3D12.
Refactor render graph barrier system, streamline CompiledBarrier, and remove ResourceBarrier.
RenderGraphCompiler now returns Result<float2, Error> for dynamic resolution scaling.
Replace custom memory pools with Allocator.FreeList for temp allocations.
Add ResourceUploadBatch for async/sync resource uploads.
Fix D3D12 disposal and fence tracking bugs.
Update NuGet dependencies.
Numerous minor cleanups and code improvements.
This commit is contained in:
2026-04-05 17:54:23 +09:00
parent 92970f85ef
commit effd33b285
35 changed files with 472 additions and 494 deletions

View File

@@ -304,7 +304,7 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
BindlessAccess.ShaderResource => (uint)r.Value.viewGroup.srv.Value,
BindlessAccess.ConstantBuffer => (uint)r.Value.viewGroup.cbv.Value,
BindlessAccess.UnorderedAccess => (uint)r.Value.viewGroup.uav.Value,
_ => ~0u,
_ => uint.MaxValue,
};
}
@@ -414,7 +414,7 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
var rRange = readRange.HasValue ? new D3D12_RANGE { Begin = readRange.Value.Start, End = readRange.Value.End } : default;
var wRange = writeRange.HasValue ? new D3D12_RANGE { Begin = writeRange.Value.Start, End = writeRange.Value.End } : default;
void * mappedData = null;
void* mappedData = null;
resource.Get()->Map(subResource, readRange.HasValue ? &rRange : null, &mappedData);
MemoryUtility.MemCpy(mappedData, pData, size);
resource.Get()->Unmap(subResource, writeRange.HasValue ? &wRange : null);
@@ -433,26 +433,19 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
return GetRequiredIntermediateSize(r.Value.ResourcePtr.Get(), firstSubResource, numSubResources);
}
public void BeginFrame(ulong cpuFrame)
internal void BeginFrame(ulong cpuFrame)
{
Debug.Assert(!_disposed);
_cpuFrame = cpuFrame;
}
public void EndFrame(ulong gpuFrame)
internal void EndFrame(ulong gpuFrame)
{
Debug.Assert(!_disposed);
while (_releaseQueue.Count > 0)
while (_releaseQueue.TryPeek(out var toRelease) && toRelease.fenceValue < gpuFrame)
{
var toRelease = _releaseQueue.Peek();
if (toRelease.fenceValue > gpuFrame)
{
break;
}
_releaseQueue.Dequeue();
toRelease.record.Release(_descriptorAllocator);
}
}
@@ -461,6 +454,11 @@ internal unsafe class D3D12ResourceDatabase : IResourceDatabase
{
Debug.Assert(!_disposed);
foreach (ref var entry in _releaseQueue)
{
entry.record.Release(_descriptorAllocator);
}
foreach (ref var record in _resources)
{
record.Release(_descriptorAllocator);