Introduces a full-featured render graph system with pass culling, resource aliasing, and automatic barrier generation. Refactors resource and barrier APIs, improves error handling, and unifies result types. Renderer and render passes now use the new graph-based workflow. Updates shader includes, adds a blit shader, and improves HLSL parsing. Removes dynamic descriptor heaps in favor of persistent ones. Project file now includes the render graph module. Lays the foundation for advanced rendering features and improved memory efficiency.
86 lines
1.7 KiB
C#
86 lines
1.7 KiB
C#
using Ghost.Core;
|
|
using Ghost.Graphics.Contracts;
|
|
using Ghost.Graphics.RHI;
|
|
|
|
namespace Ghost.Graphics.Core;
|
|
|
|
internal class SwapChainRenderOutput : IRenderOutput
|
|
{
|
|
private readonly ISwapChain _swapChain;
|
|
|
|
public ViewportDesc Viewport
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
public RectDesc Scissor
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
public SwapChainRenderOutput(ISwapChain swapChain)
|
|
{
|
|
_swapChain = swapChain;
|
|
|
|
Viewport = new ViewportDesc { Width = swapChain.Width, Height = swapChain.Height, MinDepth = 0, MaxDepth = 1 };
|
|
Scissor = new RectDesc { Right = swapChain.Width, Bottom = swapChain.Height };
|
|
}
|
|
|
|
public Handle<Texture> GetRenderTarget()
|
|
{
|
|
return _swapChain.GetCurrentBackBuffer();
|
|
}
|
|
|
|
public void BeginRender(ICommandBuffer cmd)
|
|
{
|
|
cmd.TransitionBarrier(GetRenderTarget().AsResource(), ResourceState.Present, ResourceState.RenderTarget);
|
|
}
|
|
|
|
public void EndRender(ICommandBuffer cmd)
|
|
{
|
|
cmd.TransitionBarrier(GetRenderTarget().AsResource(), ResourceState.RenderTarget, ResourceState.Present);
|
|
}
|
|
|
|
public void Present()
|
|
{
|
|
_swapChain.Present();
|
|
}
|
|
}
|
|
|
|
internal class TextureRenderOutput : IRenderOutput
|
|
{
|
|
private readonly Handle<Texture> _texture;
|
|
|
|
public ViewportDesc Viewport
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
public RectDesc Scissor
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
public TextureRenderOutput(Handle<Texture> texture)
|
|
{
|
|
_texture = texture;
|
|
}
|
|
|
|
public Handle<Texture> GetRenderTarget()
|
|
{
|
|
return _texture;
|
|
}
|
|
|
|
public void BeginRender(ICommandBuffer cmd)
|
|
{
|
|
}
|
|
|
|
public void EndRender(ICommandBuffer cmd)
|
|
{
|
|
}
|
|
|
|
public void Present()
|
|
{
|
|
}
|
|
}
|