forked from Misaki/GhostEngine
- Replace old pipeline enums/structs with new strongly-typed PipelineState and enums (ZTest, ZWrite, Cull, Blend, ColorWriteMask) - Redesign pipeline keying: introduce 128-bit GraphicsPipelineKey, MaterialPipelineKey, and PassPipelineKey for robust PSO caching - Replace IRenderTargetStrategy with IRenderOutput; add SwapChainRenderOutput and TextureRenderOutput - Update renderer and window code to use new render output abstraction and handle viewport/scissor updates - Make ShaderPass a readonly struct and Shader a struct; use ID-based pass lookup for efficiency - Materials now support per-pass pipeline overrides with new keying - Add defensive checks in D3D12CommandBuffer; update D3D12PipelineLibrary for new keying/state - Move test shader to test.gsdef and update for new pipeline state syntax - Remove obsolete files/interfaces and perform general code cleanups - Update all usages and parsing logic for new pipeline state system
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.ResourceBarrier(GetRenderTarget().AsResource(), ResourceState.Present, ResourceState.RenderTarget);
|
|
}
|
|
|
|
public void EndRender(ICommandBuffer cmd)
|
|
{
|
|
cmd.ResourceBarrier(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()
|
|
{
|
|
}
|
|
}
|