Refactor error handling: use Error enum, update APIs

Replaces ErrorStatus with Error across all systems for consistency.
Renames ResourceBarrierData fields to camelCase.
Adds BindlessAccess enum and updates GetBindlessIndex API.
Updates method signatures, result types, and error checks.
Modernizes HLSL mesh shader syntax and fixes naming.
Improves code style and updates comments for clarity.
This commit is contained in:
2026-01-25 16:34:28 +09:00
parent e11a9ebb52
commit 364fbf9208
28 changed files with 282 additions and 252 deletions

View File

@@ -68,7 +68,6 @@ public sealed class RenderGraph : IDisposable
Blackboard = new RenderGraphBlackboard();
}
/// <summary>
/// Resets the render graph for a new frame.
/// Reuses existing allocations to minimize GC.
@@ -224,7 +223,7 @@ public sealed class RenderGraph : IDisposable
{
_compiler.Dispose();
// We need to reset the whole graph to return resources to the pool
// HACK: Ideally, we should have a Dispose method. But for now, we just reset to release resources.
Reset();
}
}

View File

@@ -50,8 +50,8 @@ internal struct ResourceBarrier
public override readonly string ToString()
{
return AliasingPredecessor.IsValid
? $"[Pass {PassIndex}] Aliasing Barrier: {AliasingPredecessor.Value}->{Resource.Value} Target: {TargetState.Layout}"
: $"[Pass {PassIndex}] Barrier: {Resource.Value} Target: {TargetState.Layout}";
? $"[Pass {PassIndex}] Aliasing Barrier: {AliasingPredecessor.Value}->{Resource.Value} Target: {TargetState.layout}"
: $"[Pass {PassIndex}] Barrier: {Resource.Value} Target: {TargetState.layout}";
}
}
@@ -88,8 +88,8 @@ internal struct CompiledBarrier
public override readonly string ToString()
{
return AliasingPredecessor.IsValid
? $"[Pass {PassIndex}] Aliasing: {AliasingPredecessor.Value}->{Resource.Value} -> {TargetState.Layout}"
: $"[Pass {PassIndex}] Transition: {Resource.Value} -> {TargetState.Layout}";
? $"[Pass {PassIndex}] Aliasing: {AliasingPredecessor.Value}->{Resource.Value} -> {TargetState.layout}"
: $"[Pass {PassIndex}] Transition: {Resource.Value} -> {TargetState.layout}";
}
}
@@ -254,7 +254,7 @@ internal static class RenderGraphBarriers
if (pass.colorAccess[i].id.IsValid)
{
var usage = pass.colorAccess[i].usage;
var targetState = new ResourceBarrierData(usage.Layout, usage.Access, usage.Sync);
var targetState = new ResourceBarrierData(usage.layout, usage.access, usage.sync);
AddTransition(pass.colorAccess[i].id.AsResource(), targetState);
}
}
@@ -263,7 +263,7 @@ internal static class RenderGraphBarriers
if (pass.depthAccess.id.IsValid)
{
var usage = pass.depthAccess.usage;
var targetState = new ResourceBarrierData(usage.Layout, usage.Access, usage.Sync);
var targetState = new ResourceBarrierData(usage.layout, usage.access, usage.sync);
AddTransition(pass.depthAccess.id.AsResource(), targetState);
}

View File

@@ -47,6 +47,7 @@ internal sealed class RenderGraphContext : IRasterRenderContext, IComputeRenderC
private readonly TextureFormat[] _rtvFormats;
private TextureFormat _dsvFormat;
private int _rtvCount;
private Handle<GraphicsBuffer> _activePerMaterialData;
private Handle<GraphicsBuffer> _activePerMeshData;
@@ -82,6 +83,7 @@ internal sealed class RenderGraphContext : IRasterRenderContext, IComputeRenderC
}
_dsvFormat = dsvFormat;
_rtvCount = rtvFormats.Length;
}
public Handle<GPUResource> GetActualResource(Identifier<RGResource> resource)
@@ -145,7 +147,7 @@ internal sealed class RenderGraphContext : IRasterRenderContext, IComputeRenderC
VariantKey = shaderVariantKey,
PipelineOption = materialPipeline,
RtvFormats = _rtvFormats,
RtvFormats = _rtvFormats.AsSpan(0, _rtvCount),
DsvFormat = _dsvFormat,
};

View File

@@ -173,22 +173,22 @@ internal sealed class RenderGraphExecutor
layoutBefore = BarrierLayout.Undefined;
accessBefore = BarrierAccess.NoAccess;
syncBefore = predState.Sync;
syncBefore = predState.sync;
}
else
{
layoutBefore = currentState.Layout;
accessBefore = currentState.Access;
syncBefore = currentState.Sync;
layoutBefore = currentState.layout;
accessBefore = currentState.access;
syncBefore = currentState.sync;
}
var target = compiledBarrier.TargetState;
// Skip if already in target state (optimization)
if (!compiledBarrier.AliasingPredecessor.IsValid &&
layoutBefore == target.Layout &&
accessBefore == target.Access &&
syncBefore == target.Sync)
layoutBefore == target.layout &&
accessBefore == target.access &&
syncBefore == target.sync)
{
continue;
}
@@ -198,16 +198,16 @@ internal sealed class RenderGraphExecutor
if (compiledBarrier.ResourceType == RenderGraphResourceType.Texture)
{
desc = BarrierDesc.Texture(resourceHandle,
syncBefore, target.Sync,
accessBefore, target.Access,
layoutBefore, target.Layout,
syncBefore, target.sync,
accessBefore, target.access,
layoutBefore, target.layout,
discard: compiledBarrier.Flags.HasFlag(BarrierFlags.Discard));
}
else
{
desc = BarrierDesc.Buffer(resourceHandle,
syncBefore, target.Sync,
accessBefore, target.Access);
syncBefore, target.sync,
accessBefore, target.access);
}
if (barrierCount >= MaxBatch)

View File

@@ -1,4 +1,5 @@
using Ghost.Core;
using Ghost.Graphics.RHI;
using System.Runtime.CompilerServices;
namespace Ghost.Graphics.RenderGraphModule;
@@ -27,7 +28,7 @@ internal abstract class RenderGraphPassBase
public bool asyncCompute;
public TextureAccess depthAccess;
public TextureAccess[] colorAccess = new TextureAccess[8];
public TextureAccess[] colorAccess = new TextureAccess[RHIUtility.MAX_RENDER_TARGETS];
public int maxColorIndex = -1;
public List<Identifier<RGResource>> randomAccess = new(8);