forked from Misaki/GhostEngine
Implemented a transient render graph system as a proof of concept, including resource aliasing, pass culling, and typed pass data. Added new project `Ghost.RenderGraph.Concept` targeting `.NET 10.0`. Refactored graphics-related components: - Simplified resource state transitions in `RenderingContext`. - Improved resize handling in `GraphicsTestWindow`. - Updated `D3D12GraphicsEngine` to streamline frame rendering. - Enhanced `D3D12ResourceDatabase` and `D3D12SwapChain` for better resource management. Added detailed documentation: - `ALIASING.md` explains resource aliasing techniques. - `API_DESIGN.md` outlines the render graph API design. Updated solution to include the new render graph project.
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
namespace Ghost.RenderGraph.Concept;
|
|
|
|
public static class RenderGraphExtensions
|
|
{
|
|
public static RenderGraphPassBuilder<TPassData> AddRenderPass<TPassData>(
|
|
this RenderGraph renderGraph,
|
|
string name,
|
|
out TPassData passData,
|
|
Action<RenderGraphPassBuilder<TPassData>> setup)
|
|
where TPassData : class, new()
|
|
{
|
|
var builder = renderGraph.AddRenderPass<TPassData>(name, out passData);
|
|
setup(builder);
|
|
builder.Dispose();
|
|
return builder;
|
|
}
|
|
}
|
|
|
|
public sealed class RenderGraphPassScope<TPassData> : IDisposable
|
|
where TPassData : class, new()
|
|
{
|
|
private readonly RenderGraphPassBuilder<TPassData> _builder;
|
|
private readonly string _passName;
|
|
|
|
internal RenderGraphPassScope(RenderGraphPassBuilder<TPassData> builder, string passName)
|
|
{
|
|
_builder = builder;
|
|
_passName = passName;
|
|
}
|
|
|
|
public RenderGraphPassBuilder<TPassData> Builder => _builder;
|
|
|
|
public void Dispose()
|
|
{
|
|
// Commit the pass when the using block ends
|
|
if (_builder.RenderFunc != null)
|
|
{
|
|
_builder.Dispose();
|
|
}
|
|
}
|
|
}
|