Refactor pipeline state and render output abstractions
- 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
This commit is contained in:
84
Ghost.Core/Graphics/PipelineState.cs
Normal file
84
Ghost.Core/Graphics/PipelineState.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
namespace Ghost.Core.Graphics;
|
||||
|
||||
public enum ZTest
|
||||
{
|
||||
Disabled,
|
||||
Less,
|
||||
LessEqual,
|
||||
Equal,
|
||||
GreaterEqual,
|
||||
Greater,
|
||||
NotEqual,
|
||||
Always
|
||||
}
|
||||
|
||||
public enum ZWrite
|
||||
{
|
||||
Off,
|
||||
On
|
||||
}
|
||||
|
||||
public enum Cull
|
||||
{
|
||||
Off,
|
||||
Front,
|
||||
Back
|
||||
}
|
||||
|
||||
public enum Blend
|
||||
{
|
||||
Opaque,
|
||||
Alpha,
|
||||
Additive,
|
||||
Multiply,
|
||||
PremultipliedAlpha
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ColorWriteMask
|
||||
{
|
||||
None = 0,
|
||||
Red = 1 << 0,
|
||||
Green = 1 << 1,
|
||||
Blue = 1 << 2,
|
||||
Alpha = 1 << 3,
|
||||
All = Red | Green | Blue | Alpha
|
||||
}
|
||||
|
||||
public struct PipelineState
|
||||
{
|
||||
public ZTest ZTest
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public ZWrite ZWrite
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public Cull Cull
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public Blend Blend
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public ColorWriteMask ColorMask
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
||||
public static PipelineState Default => new PipelineState
|
||||
{
|
||||
ZTest = ZTest.LessEqual,
|
||||
ZWrite = ZWrite.On,
|
||||
Cull = Cull.Back,
|
||||
Blend = Blend.Opaque,
|
||||
ColorMask = ColorWriteMask.All
|
||||
};
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
namespace Ghost.Core.Graphics;
|
||||
|
||||
public enum ZTestOptions
|
||||
{
|
||||
Disabled,
|
||||
Less,
|
||||
LessEqual,
|
||||
Equal,
|
||||
GreaterEqual,
|
||||
Greater,
|
||||
NotEqual,
|
||||
Always
|
||||
}
|
||||
|
||||
public enum ZWriteOptions
|
||||
{
|
||||
Off,
|
||||
On
|
||||
}
|
||||
|
||||
public enum CullOptions
|
||||
{
|
||||
Off,
|
||||
Front,
|
||||
Back
|
||||
}
|
||||
|
||||
public enum BlendOptions
|
||||
{
|
||||
Opaque,
|
||||
Alpha,
|
||||
Additive,
|
||||
Multiply,
|
||||
PremultipliedAlpha
|
||||
}
|
||||
@@ -33,24 +33,6 @@ public struct KeywordsGroup
|
||||
public List<string>? keywords;
|
||||
}
|
||||
|
||||
public struct PipelineDescriptor
|
||||
{
|
||||
public ZTestOptions zTest;
|
||||
public ZWriteOptions zWrite;
|
||||
public CullOptions cull;
|
||||
public BlendOptions blend;
|
||||
public uint colorMask;
|
||||
|
||||
public static PipelineDescriptor Default = new PipelineDescriptor
|
||||
{
|
||||
zTest = ZTestOptions.LessEqual,
|
||||
zWrite = ZWriteOptions.On,
|
||||
cull = CullOptions.Back,
|
||||
blend = BlendOptions.Opaque,
|
||||
colorMask = 0
|
||||
};
|
||||
}
|
||||
|
||||
public interface IPassDescriptor
|
||||
{
|
||||
public string Identifier
|
||||
@@ -81,7 +63,7 @@ public class FullPassDescriptor : IPassDescriptor
|
||||
public ShaderEntryPoint pixelShader;
|
||||
public List<string>? defines;
|
||||
public List<KeywordsGroup>? keywords;
|
||||
public PipelineDescriptor localPipeline;
|
||||
public PipelineState localPipeline;
|
||||
|
||||
public string Identifier => uniqueIdentifier;
|
||||
public string Name => name;
|
||||
|
||||
Reference in New Issue
Block a user