forked from Misaki/GhostEngine
Major architectural update to graphics/material/shader system: - Introduced strongly-typed key structs (Key64/Key128) for passes, variants, and pipelines; removed legacy key types. - Implemented robust hashing and key generation utilities for efficient variant and pipeline lookup/caching. - Shader compiler now compiles/caches all keyword variants using new key system; includes handled as lists. - Switched to push constant root signature for per-draw data; updated HLSL and C# codegen accordingly. - Refactored Material, Shader, and Pass data structures for cache efficiency and variant support. - Pipeline library and PSO management now use 128-bit keys and variant-specific caching. - Replaced WorldNode with SceneNode in editor/scene graph; introduced ComponentManager for archetype/query management. - Migrated math utilities to Misaki.HighPerformance.Mathematics; updated editor controls. - Updated all HLSL and codegen for new buffer/push constant layouts and macros. - Misc: project reference cleanup, D3D12 Work Graph support, doc updates, and code modernization.
72 lines
1.8 KiB
C#
72 lines
1.8 KiB
C#
namespace Ghost.DSL.ShaderCompiler.Parser;
|
|
|
|
internal static class ParseUtility
|
|
{
|
|
public static List<Token> ParseFunctionArguments(ref TokenStreamSlice stream, TokenType tokenType)
|
|
{
|
|
var args = new List<Token>();
|
|
stream.Expect(TokenType.LParen);
|
|
|
|
while (!stream.Peek().type.Equals(TokenType.RParen))
|
|
{
|
|
var argToken = stream.Expect(tokenType);
|
|
args.Add(argToken);
|
|
|
|
if (stream.Peek().type == TokenType.Comma)
|
|
{
|
|
stream.Consume();
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
stream.Expect(TokenType.RParen);
|
|
return args;
|
|
}
|
|
|
|
public static FunctionCallDeclaration ParseFunction(ref TokenStreamSlice stream, TokenType tokenType)
|
|
{
|
|
var functionToken = stream.Expect(TokenType.Identifier);
|
|
var args = ParseFunctionArguments(ref stream, tokenType);
|
|
stream.Expect(TokenType.Semicolon);
|
|
|
|
return new FunctionCallDeclaration
|
|
{
|
|
name = functionToken,
|
|
arguments = args
|
|
};
|
|
}
|
|
|
|
public static bool TrySliceLine(ref TokenStreamSlice stream, out TokenStreamSlice lineStream)
|
|
{
|
|
var length = 0;
|
|
if (!stream.TryPeek(out var nextToken))
|
|
{
|
|
lineStream = default;
|
|
return false;
|
|
}
|
|
|
|
while (!nextToken.Match(TokenType.Semicolon) && !nextToken.Match(TokenType.RBrace))
|
|
{
|
|
length++;
|
|
|
|
if (!stream.TryPeek(length, out nextToken))
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (length > 0)
|
|
{
|
|
lineStream = stream.Slice(length);
|
|
stream.Consume(); // Consume the semicolon
|
|
return true;
|
|
}
|
|
|
|
lineStream = default;
|
|
return false;
|
|
}
|
|
}
|