Refactor and enhance rendering pipeline
- Added new C# formatting rules in .editorconfig. - Introduced `IKeyType`, `Key<T>`, and `Ptr<T>` structs. - Updated `Result` and `Result<T>` for implicit conversions. - Added AOT compatibility to project files. - Introduced a `Camera` class and refactored namespaces. - Enhanced rendering with bindless support and pipeline state management. - Refactored `D3D12CommandBuffer` for new rendering features. - Improved `D3D12PipelineLibrary` with disk caching methods. - Added support for UAVs and raw buffers in `D3D12ResourceAllocator`. - Improved shader compilation and reflection in `D3D12ShaderCompiler`. - Refactored descriptor heap and swap chain initialization. - Added enums and structs for rendering configurations. - Expanded `ICommandBuffer` and `IPipelineLibrary` interfaces. - Updated `MeshRenderPass` to align with the new pipeline. - Consolidated namespaces and improved code maintainability.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using Ghost.Graphics.D3D12.Utilities;
|
||||
using Ghost.Core;
|
||||
using Ghost.Core.Graphics;
|
||||
using Ghost.Graphics.D3D12.Utilities;
|
||||
using Misaki.HighPerformance.Utilities;
|
||||
using System.IO.Hashing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using Ghost.Graphics.Core;
|
||||
|
||||
namespace Ghost.Graphics.RHI;
|
||||
|
||||
@@ -35,6 +38,8 @@ public readonly struct ShaderPassKey
|
||||
|
||||
public readonly struct GraphicsPipelineKey
|
||||
{
|
||||
public const int KEY_STRING_LENGTH = 17; // 16 chars + null terminator
|
||||
|
||||
public readonly ulong value;
|
||||
|
||||
public GraphicsPipelineKey(ulong value)
|
||||
@@ -42,6 +47,17 @@ public readonly struct GraphicsPipelineKey
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Result GetString(Span<char> destination)
|
||||
{
|
||||
if (!value.TryFormat(destination, out _, "X16"))
|
||||
{
|
||||
return Result.Fail("Failed to format GraphicsPipelineKey to string.");
|
||||
}
|
||||
|
||||
destination[16] = '\0';
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return value.ToString("X16");
|
||||
@@ -55,14 +71,14 @@ public readonly struct GraphicsPipelineKey
|
||||
|
||||
internal struct GraphicsPipelineHash
|
||||
{
|
||||
[InlineArray(8)]
|
||||
[InlineArray(D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT)]
|
||||
public struct rtv_array
|
||||
{
|
||||
public TextureFormat rtvFormats;
|
||||
}
|
||||
|
||||
public rtv_array rtvFormats;
|
||||
public ShaderPassKey id;
|
||||
public rtv_array rtvFormats;
|
||||
public uint rtvCount;
|
||||
public TextureFormat dsvFormat;
|
||||
// Do we need to store blend state?
|
||||
@@ -70,12 +86,12 @@ internal struct GraphicsPipelineHash
|
||||
|
||||
public readonly GraphicsPipelineKey GetKey()
|
||||
{
|
||||
Span<ulong> data = stackalloc ulong[3 + 8];
|
||||
Span<ulong> data = stackalloc ulong[3 + D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT];
|
||||
data[0] = id.value;
|
||||
data[1] = rtvCount;
|
||||
data[2] = (ulong)dsvFormat;
|
||||
|
||||
for (var i = 0; i < 8; i++)
|
||||
for (var i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
|
||||
{
|
||||
data[3 + i] = (ulong)rtvFormats[i];
|
||||
}
|
||||
@@ -85,6 +101,18 @@ internal struct GraphicsPipelineHash
|
||||
}
|
||||
}
|
||||
|
||||
public ref struct GraphicsPSODescriptor
|
||||
{
|
||||
public ShaderPassKey passId;
|
||||
public ZTestOptions zTest;
|
||||
public ZWriteOptions zWrite;
|
||||
public CullOptions cull;
|
||||
public BlendOptions blend;
|
||||
public uint colorMask;
|
||||
|
||||
public ReadOnlySpan<TextureFormat> rtvFormats;
|
||||
public TextureFormat dsvFormat;
|
||||
}
|
||||
|
||||
|
||||
public struct ViewportDesc
|
||||
@@ -112,6 +140,20 @@ public struct SubResourceData
|
||||
public nint slicePitch;
|
||||
}
|
||||
|
||||
public struct PassRenderTargetDesc
|
||||
{
|
||||
public Handle<Texture> texture;
|
||||
public Color128 clearColor;
|
||||
}
|
||||
|
||||
public struct PassDepthStencilDesc
|
||||
{
|
||||
public Handle<Texture> texture;
|
||||
public float clearDepth;
|
||||
public byte clearStencil;
|
||||
}
|
||||
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct ResourceDesc
|
||||
{
|
||||
@@ -501,9 +543,6 @@ public struct SwapChainTarget
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swap chain target types
|
||||
/// </summary>
|
||||
public enum SwapChainTargetType
|
||||
{
|
||||
WindowHandle,
|
||||
@@ -627,6 +666,13 @@ public enum IndexType
|
||||
UInt32
|
||||
}
|
||||
|
||||
public enum PrimitiveTopology
|
||||
{
|
||||
Point,
|
||||
Line,
|
||||
Triangle,
|
||||
}
|
||||
|
||||
// SDL compiler
|
||||
|
||||
internal ref struct CompilerConfig
|
||||
@@ -671,4 +717,4 @@ internal enum ShaderStage
|
||||
MeshShader,
|
||||
PixelShader,
|
||||
ComputeShader
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user