Refactored and reorganized the codebase to improve readability, performance, and maintainability. Introduced new interfaces and structs for better resource management, updated project configuration files, and refactored shader and graphics pipeline management. Improved error handling, code formatting, and removed unused code and namespaces. Updated DLL references and method signatures for consistency and maintainability.
59 lines
1.2 KiB
C#
59 lines
1.2 KiB
C#
using Ghost.Shader.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 = ShaderCompiler.ParseShaders(stream);
|
|
var model = ShaderCompiler.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 = ShaderCompiler.ResolveShader(model);
|
|
ShaderCompiler.CompileShader(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,
|
|
} |