forked from Misaki/GhostEngine
Refactor and enhance graphics and audio systems
Updated target frameworks to .NET 10.0 across multiple projects for compatibility with the latest features. Refactored namespaces and introduced new classes for shader descriptors, FMOD integration, and DirectX 12 utilities using TerraFX. Replaced `Win32` bindings with TerraFX equivalents for DirectX 12. Added a C# wrapper for FMOD Studio API, including DSP and error handling. Enhanced entity queries, component storage, and query filters for better performance and type safety. Introduced new test projects and updated the solution structure. Added `meshoptimizer` bindings and integrated `meshoptimizer_native.dll`. Improved code readability, maintainability, and performance.
This commit is contained in:
35
Ghost.Core/Graphics/PsoOptions.cs
Normal file
35
Ghost.Core/Graphics/PsoOptions.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
||||
35
Ghost.Core/Graphics/RootSignatureLayout.cs
Normal file
35
Ghost.Core/Graphics/RootSignatureLayout.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
namespace Ghost.Core.Graphics;
|
||||
|
||||
/// <summary>
|
||||
/// The layout of the root signature is:
|
||||
/// <list type="bullet">
|
||||
/// <item>
|
||||
/// Global buffer (b0)
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// Per-view buffer (b1)
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// Per-object buffer (b2)
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// Per-material buffer (b3)
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// Descriptor table for bindless textures (t0)
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// Descriptor table for bindless samplers (s0)
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public static class RootSignatureLayout
|
||||
{
|
||||
public const int GLOBAL_BUFFER_SLOT = 0;
|
||||
public const int PER_VIEW_BUFFER_SLOT = 1;
|
||||
public const int PER_OBJECT_BUFFER_SLOT = 2;
|
||||
public const int PER_MATERIAL_BUFFER_SLOT = 3;
|
||||
|
||||
public const int TEXTURE_HEAP_SLOT = 0;
|
||||
public const int SAMPLER_HEAP_SLOT = 0;
|
||||
}
|
||||
90
Ghost.Core/Graphics/ShaderDescriptor.cs
Normal file
90
Ghost.Core/Graphics/ShaderDescriptor.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
namespace Ghost.Core.Graphics;
|
||||
public enum KeywordType
|
||||
{
|
||||
Static,
|
||||
Dynamic,
|
||||
}
|
||||
|
||||
public enum ShaderPropertyType
|
||||
{
|
||||
None,
|
||||
Float, Float2, Float3, Float4,
|
||||
Int, Int2, Int3, Int4,
|
||||
UInt, UInt2, UInt3, UInt4,
|
||||
Bool, Bool2, Bool3, Bool4,
|
||||
Texture2D, Texture3D, TextureCube,
|
||||
Texture2DArray, TextureCubeArray,
|
||||
}
|
||||
|
||||
public struct ShaderEntryPoint
|
||||
{
|
||||
public string entry;
|
||||
public string shader;
|
||||
}
|
||||
|
||||
public struct KeywordsGroup
|
||||
{
|
||||
public KeywordType type;
|
||||
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
|
||||
{
|
||||
get;
|
||||
}
|
||||
}
|
||||
|
||||
public class FullPassDescriptor : IPassDescriptor
|
||||
{
|
||||
public string uniqueIdentifier = string.Empty;
|
||||
public ShaderEntryPoint vertexShader;
|
||||
public ShaderEntryPoint pixelShader;
|
||||
public List<string>? defines;
|
||||
public List<string>? includes;
|
||||
public List<KeywordsGroup>? keywords;
|
||||
public List<PropertyDescriptor>? properties;
|
||||
public PipelineDescriptor localPipeline;
|
||||
|
||||
public string Identifier => uniqueIdentifier;
|
||||
}
|
||||
|
||||
public class FallbackPassDescriptor : IPassDescriptor
|
||||
{
|
||||
public string fallbackPassIdentifier = string.Empty;
|
||||
|
||||
public string Identifier => fallbackPassIdentifier;
|
||||
}
|
||||
|
||||
public struct PropertyDescriptor
|
||||
{
|
||||
public ShaderPropertyType type;
|
||||
public string name;
|
||||
public object? defaultValue;
|
||||
}
|
||||
|
||||
public class ShaderDescriptor
|
||||
{
|
||||
public string name = string.Empty;
|
||||
public List<PropertyDescriptor> globalProperties = new();
|
||||
public List<IPassDescriptor> passes = new();
|
||||
}
|
||||
Reference in New Issue
Block a user