forked from Misaki/GhostEngine
Refactor descriptor handling and shader compilation
Refactored descriptor allocation and release logic by introducing `IDescriptorAllocator` and replacing `DescriptorHeapAllocator` with `D3D12DescriptorHeap`. Updated descriptor structs to include validation properties and improved memory management with `ReadOnlySpan`. Enhanced shader compilation by introducing `ShaderStage` and `CompilerVersion` enums, enabling more flexible and maintainable shader handling. Refactored `Mesh` to use `IBuffer` for vertex and index buffers, added bindless descriptor support, and improved resource cleanup. Updated `RenderSystem` and other components for better initialization, error handling, and disposal logic. General improvements to code readability and maintainability.
This commit is contained in:
78
Ghost.Graphics/Data/Descriptors.cs
Normal file
78
Ghost.Graphics/Data/Descriptors.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using Win32.Graphics.Direct3D12;
|
||||
|
||||
namespace Ghost.Graphics.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Render target view (RTV) descriptor.
|
||||
/// </summary>
|
||||
public readonly struct RenderTargetDescriptor
|
||||
{
|
||||
public uint Index
|
||||
{
|
||||
get; init;
|
||||
}
|
||||
|
||||
public static RenderTargetDescriptor Invalid => new() { Index = ~0u };
|
||||
|
||||
public bool IsValid => Index != ~0u;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Depth stencil view (DSV) descriptor.
|
||||
/// </summary>
|
||||
public readonly struct DepthStencilDescriptor
|
||||
{
|
||||
public uint Index
|
||||
{
|
||||
get; init;
|
||||
}
|
||||
|
||||
public static DepthStencilDescriptor Invalid => new() { Index = ~0u };
|
||||
|
||||
public bool IsValid => Index != ~0u;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shader resource view (SRV) descriptor.
|
||||
/// </summary>
|
||||
public readonly struct ShaderResourceDescriptor
|
||||
{
|
||||
public uint Index
|
||||
{
|
||||
get; init;
|
||||
}
|
||||
|
||||
public static ShaderResourceDescriptor Invalid => new() { Index = ~0u };
|
||||
|
||||
public bool IsValid => Index != ~0u;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sampler descriptor.
|
||||
/// </summary>
|
||||
public readonly struct SamplerDescriptor
|
||||
{
|
||||
public uint Index
|
||||
{
|
||||
get; init;
|
||||
}
|
||||
|
||||
public static SamplerDescriptor Invalid => new() { Index = ~0u };
|
||||
|
||||
public bool IsValid => Index != ~0u;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bindless descriptor
|
||||
/// </summary>
|
||||
public readonly struct BindlessDescriptor
|
||||
{
|
||||
public uint Index
|
||||
{
|
||||
get; init;
|
||||
}
|
||||
|
||||
public static BindlessDescriptor Invalid => new() { Index = ~0u };
|
||||
|
||||
public bool IsValid => Index != ~0u;
|
||||
}
|
||||
Reference in New Issue
Block a user