Refactored and renamed components related to D3D12 graphics programming, replacing "descriptor" with "viewGroup" to improve resource grouping and management. Updated `D3D12CommandBuffer`, `D3D12DescriptorAllocator`, and `D3D12PipelineLibrary` to reflect these changes. Simplified material and shader creation in `D3D12ResourceAllocator`. Enhanced `D3D12ResourceDatabase` with resource naming for debugging and improved management. Refactored `Shader` and `ShaderPass` to use modern C# features and `IResourceReleasable` interface. Introduced `D3D12Utility` for centralized utility methods. Updated `Material` class for efficient buffer creation. Renamed `ShaderCompiler` to `SDLCompiler` with improved error handling. Updated `MeshRenderPass` to use new shader compilation process. Various improvements in error handling, code readability, and utility methods.
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
namespace Ghost.Shader.Compiler.Parser;
|
|
|
|
internal class DefinesBlock : IBlockParser<List<Token>, List<string>>
|
|
{
|
|
public static bool ShouldEnter(Token token)
|
|
{
|
|
return token.Match(TokenType.Keyword, TokenLexicon.KnownKeywords.DEFINES);
|
|
}
|
|
|
|
public static List<Token> Parse(TokenStreamSlice stream)
|
|
{
|
|
stream.Expect(TokenType.Keyword);
|
|
stream.Expect(TokenType.LBrace);
|
|
|
|
var defines = new List<Token>();
|
|
|
|
var bodyStream = stream.Slice(stream.Remaining - 1);
|
|
while (bodyStream.HasMore)
|
|
{
|
|
var defineToken = bodyStream.Expect(TokenType.Identifier);
|
|
defines.Add(defineToken);
|
|
bodyStream.Expect(TokenType.Semicolon);
|
|
}
|
|
|
|
stream.Expect(TokenType.RBrace);
|
|
|
|
return defines;
|
|
}
|
|
|
|
public static List<string>? SemanticAnalysis(List<Token>? syntax, List<SDLError> errors)
|
|
{
|
|
if (syntax == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var defines = new List<string>(syntax.Count);
|
|
foreach (var defineToken in syntax)
|
|
{
|
|
defines.Add(defineToken.lexeme);
|
|
}
|
|
|
|
return defines;
|
|
}
|
|
}
|