forked from Misaki/GhostEngine
Add render graph proof of concept and refactor graphics
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.
This commit is contained in:
36
Ghost.RenderGraph.Concept/RenderGraphBlackboard.cs
Normal file
36
Ghost.RenderGraph.Concept/RenderGraphBlackboard.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace Ghost.RenderGraph.Concept;
|
||||
|
||||
public class RenderGraphBlackboard
|
||||
{
|
||||
private readonly Dictionary<Type, object> _data = new();
|
||||
|
||||
public void Add<T>(T data) where T : class
|
||||
{
|
||||
_data[typeof(T)] = data;
|
||||
}
|
||||
|
||||
public T Get<T>() where T : class
|
||||
{
|
||||
if (_data.TryGetValue(typeof(T), out var data))
|
||||
{
|
||||
return (T)data;
|
||||
}
|
||||
throw new KeyNotFoundException($"Data of type {typeof(T).Name} not found in blackboard.");
|
||||
}
|
||||
|
||||
public bool TryGet<T>(out T? data) where T : class
|
||||
{
|
||||
if (_data.TryGetValue(typeof(T), out var obj))
|
||||
{
|
||||
data = (T)obj;
|
||||
return true;
|
||||
}
|
||||
data = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_data.Clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user