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:
@@ -1,5 +1,6 @@
|
||||
using Ghost.Core;
|
||||
using Ghost.Graphics.RHI;
|
||||
using Misaki.HighPerformance.Mathematics;
|
||||
using System.Diagnostics;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -12,8 +13,6 @@ internal sealed class RenderGraphExecutor
|
||||
private readonly RenderGraphResourceRegistry _resources;
|
||||
private readonly RenderGraphContext _context;
|
||||
|
||||
private uint _frameIndex;
|
||||
|
||||
public RenderGraphExecutor(
|
||||
ResourceManager resourceManager,
|
||||
IResourceDatabase resourceDatabase,
|
||||
@@ -89,7 +88,7 @@ internal sealed class RenderGraphExecutor
|
||||
var nativePassIndex = 0;
|
||||
var logicalPassIndex = 0;
|
||||
|
||||
_context.BeginNewFrame(_frameIndex++, commandBuffer);
|
||||
_context.BeginNewFrame(commandBuffer);
|
||||
|
||||
var pPassRTDescs = stackalloc PassRenderTargetDesc[8];
|
||||
var pRtFormats = stackalloc TextureFormat[8];
|
||||
@@ -218,10 +217,10 @@ internal sealed class RenderGraphExecutor
|
||||
|
||||
// Process all pre-compiled barriers for this pass
|
||||
// TODO: We can insert BarrierAccess.NoAccess to the resource that aliased with others after their last usage to reduce cache burden.
|
||||
while (barrierIndex < compiledBarriers.Count && compiledBarriers[barrierIndex].PassIndex == passIndex)
|
||||
while (barrierIndex < compiledBarriers.Count && compiledBarriers[barrierIndex].passIndex == passIndex)
|
||||
{
|
||||
var compiledBarrier = compiledBarriers[barrierIndex++];
|
||||
var resource = _resources.GetResource(compiledBarrier.Resource);
|
||||
var resource = _resources.GetResource(compiledBarrier.resource);
|
||||
var resourceHandle = resource.backingResource;
|
||||
|
||||
// Always query the before state from ResourceManager (single source of truth)
|
||||
@@ -232,21 +231,21 @@ internal sealed class RenderGraphExecutor
|
||||
}
|
||||
|
||||
var currentState = currentStateResult.Value;
|
||||
var target = compiledBarrier.TargetState;
|
||||
var target = compiledBarrier.targetState;
|
||||
|
||||
// Create barrier descriptor
|
||||
BarrierDesc desc;
|
||||
if (compiledBarrier.ResourceType == RenderGraphResourceType.Texture)
|
||||
if (compiledBarrier.resourceType == RenderGraphResourceType.Texture)
|
||||
{
|
||||
desc = BarrierDesc.Texture(resourceHandle, target.sync, target.access, target.layout,
|
||||
discard: compiledBarrier.Flags.HasFlag(BarrierFlags.Discard));
|
||||
discard: compiledBarrier.flags.HasFlag(BarrierFlags.Discard));
|
||||
}
|
||||
else
|
||||
{
|
||||
desc = BarrierDesc.Buffer(resourceHandle, target.sync, target.access);
|
||||
}
|
||||
|
||||
if (compiledBarrier.AliasingPredecessor.IsValid)
|
||||
if (compiledBarrier.aliasingPredecessor.IsValid)
|
||||
{
|
||||
desc.IsAliasing = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user