Files
GhostEngine/Ghost.Core/Graphics/ShaderDescriptor.cs
Misaki d91d6f6e57 Refactor shader pipeline and improve modularity
- Added `generatedCodePath` to `FullPassDescriptor` for better shader code organization.
- Removed redundant `IID_PPV_ARGS` method and unused `Misaki.HighPerformance.Unsafe` reference.
- Refactored `Material` and `MaterialAccessor` to use `CBuffer` and updated buffer size handling.
- Renamed command buffer variables in `RenderingContext` for consistency.
- Updated `D3D12PipelineLibrary` to cache compiled shader results and added `ShaderPassKey`.
- Refactored `D3D12GraphicsEngine` to integrate `_copyCommandBuffer` lifecycle.
- Enhanced `D3D12ResourceAllocator` with shader pass creation using constant buffer info.
- Simplified `D3D12ShaderCompiler` with `GENERATED_CODE_PATH` support and improved reflection handling.
- Introduced `CBufferPropertyInfo` and `CBufferInfo` structs for better encapsulation.
- Updated HLSL shaders to use `g_PerMaterialData` and dynamic includes.
- Improved error handling in `SDLCompiler` with try-catch blocks and better messages.
- Refactored `test.gshader` to use dynamically generated includes.
- Fixed typos, improved code readability, and removed unused code.
2025-11-14 19:41:36 +09:00

105 lines
2.3 KiB
C#

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,
Texture2DBindless, Texture3DBindless, TextureCubeBindless,
Texture2DArrayBindless, TextureCubeArrayBindless,
}
public struct ShaderEntryPoint
{
public string entry;
public string shader;
public readonly bool IsCreated => !string.IsNullOrEmpty(entry) && !string.IsNullOrEmpty(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 string Name
{
get;
}
}
public struct PropertyDescriptor
{
public ShaderPropertyType type;
public string name;
public object? defaultValue;
}
public class FullPassDescriptor : IPassDescriptor
{
public string uniqueIdentifier = string.Empty;
public string name = string.Empty;
public ShaderEntryPoint taskShader;
public ShaderEntryPoint meshShader;
public ShaderEntryPoint pixelShader;
public string? generatedCodePath;
public List<string>? defines;
public List<string>? includes;
public List<KeywordsGroup>? keywords;
public List<PropertyDescriptor>? properties;
public PipelineDescriptor localPipeline;
public string Identifier => uniqueIdentifier;
public string Name => name;
}
public class FallbackPassDescriptor : IPassDescriptor
{
public string fallbackPassIdentifier = string.Empty;
public string name = string.Empty;
public string Identifier => fallbackPassIdentifier;
public string Name => name;
}
public class ShaderDescriptor
{
public string name = string.Empty;
public List<PropertyDescriptor> globalProperties = new();
public List<IPassDescriptor> passes = new();
}