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.
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
namespace Ghost.DSL.ShaderCompiler.Parser;
|
|
|
|
internal class IncludesBlock : IBlockParser<List<Token>, List<string>>
|
|
{
|
|
public static bool ShouldEnter(Token token)
|
|
{
|
|
return token.Match(TokenType.Keyword, TokenLexicon.KnownKeywords.INCLUDES);
|
|
}
|
|
|
|
public static List<Token> Parse(TokenStreamSlice stream)
|
|
{
|
|
stream.Expect(TokenType.Keyword);
|
|
stream.Expect(TokenType.LBrace);
|
|
|
|
var includes = new List<Token>();
|
|
|
|
var bodyStream = stream.Slice(stream.Remaining - 1);
|
|
while (bodyStream.HasMore)
|
|
{
|
|
var includeToken = bodyStream.Expect(TokenType.StringLiteral);
|
|
includes.Add(includeToken);
|
|
bodyStream.Expect(TokenType.Semicolon);
|
|
}
|
|
|
|
stream.Expect(TokenType.RBrace);
|
|
|
|
return includes;
|
|
}
|
|
|
|
public static List<string>? SemanticAnalysis(List<Token>? syntax, List<DSLShaderError> errors)
|
|
{
|
|
if (syntax == null || syntax.Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var includes = new List<string>(syntax.Count);
|
|
foreach (var includeToken in syntax)
|
|
{
|
|
var path = includeToken.lexeme;
|
|
if (File.Exists(path))
|
|
{
|
|
includes.Add(path);
|
|
}
|
|
else
|
|
{
|
|
errors.Add(new DSLShaderError
|
|
{
|
|
message = $"Included file '{path}' not found.",
|
|
line = includeToken.line,
|
|
column = includeToken.column
|
|
});
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return includes;
|
|
}
|
|
}
|