Files
GhostEngine/Ghost.Shader.Test/Program.cs
Misaki bd97d233cb Refactor and optimize rendering pipeline
- Added `<IsTrimmable>` property in project files for trimming.
- Replaced bindless texture types with non-bindless equivalents.
- Refactored `ShaderDescriptor` and `ShaderPass` for better modularity.
- Introduced `ShaderDescriptorExtensions` for property size calculations.
- Simplified constant buffer handling in `Material.cs`.
- Improved resource management in `D3D12` components.
- Added support for static meshes and optimized resource barriers.
- Refactored shader code generation and property merging in `SDLCompiler`.
- Removed unused or redundant code (e.g., `IncludesBlock` parser).
- Updated comments, documentation, and error handling for clarity.
2025-11-28 18:58:50 +09:00

59 lines
1.2 KiB
C#

using Ghost.SDL.Compiler;
using Misaki.HighPerformance.Mathematics;
using System.Numerics;
//ShaderStructGenerator.GenerateHLSL([typeof(TestStruct), typeof(TestEnum), typeof(TestEnumFlags)], PackingRules.Exact, "C:/Users/Misaki/Downloads/Archive/Test.cs.hlsl");
//return;
var source = File.ReadAllText("F:/csharp/GhostEngine/Ghost.Graphics/test.gshader");
var lexer = new Lexer(source);
var stream = new TokenStream(lexer.Tokenize());
var shaderInfo = SDLCompiler.ParseShaders(stream);
var model = SDLCompiler.SemanticAnalysis(shaderInfo[0], out var errors);
foreach (var error in errors)
{
Console.WriteLine(error);
}
if (errors.Count != 0)
{
return;
}
if (model == null)
{
Console.WriteLine("Failed to compile shader due to errors.");
return;
}
var descriptor = SDLCompiler.ResolveShader(model);
SDLCompiler.GenerateShaderCode(descriptor, "C:/Users/Misaki/Downloads/Archive");
Console.WriteLine("Shader compiled successfully:");
public struct TestStruct
{
public int A;
public float B;
public Vector3 C;
public float3x4 D;
}
public enum TestEnum
{
First,
Second,
Third
}
public enum TestEnumFlags
{
None = 0,
First = 1 << 0,
Second = 1 << 1,
Third = 1 << 2,
}