forked from Misaki/GhostEngine
Introduces a full-featured render graph system with pass culling, resource aliasing, and automatic barrier generation. Refactors resource and barrier APIs, improves error handling, and unifies result types. Renderer and render passes now use the new graph-based workflow. Updates shader includes, adds a blit shader, and improves HLSL parsing. Removes dynamic descriptor heaps in favor of persistent ones. Project file now includes the render graph module. Lays the foundation for advanced rendering features and improved memory efficiency.
100 lines
1.9 KiB
ANTLR
100 lines
1.9 KiB
ANTLR
parser grammar GhostShaderParser;
|
|
|
|
options {
|
|
tokenVocab = GhostShaderLexer;
|
|
}
|
|
|
|
// Top-level rule
|
|
shaderFile: shader+ EOF;
|
|
|
|
shader:
|
|
SHADER STRING_LITERAL LBRACE
|
|
shaderBody
|
|
RBRACE;
|
|
|
|
shaderBody:
|
|
(propertiesBlock | pipelineBlock | passBlock | functionCall)*;
|
|
|
|
// Properties block
|
|
propertiesBlock:
|
|
PROPERTIES LBRACE
|
|
propertyDeclaration*
|
|
RBRACE;
|
|
|
|
propertyDeclaration:
|
|
scope? IDENTIFIER IDENTIFIER (EQUALS LBRACE propertyInitializer RBRACE)? SEMICOLON;
|
|
|
|
scope:
|
|
GLOBAL | LOCAL;
|
|
|
|
propertyInitializer:
|
|
(NUMBER | IDENTIFIER) (COMMA (NUMBER | IDENTIFIER))*;
|
|
|
|
// Pipeline block
|
|
pipelineBlock:
|
|
PIPELINE LBRACE
|
|
pipelineStatement*
|
|
RBRACE;
|
|
|
|
pipelineStatement:
|
|
IDENTIFIER EQUALS IDENTIFIER SEMICOLON;
|
|
|
|
// Pass block
|
|
passBlock:
|
|
PASS STRING_LITERAL LBRACE
|
|
passBody
|
|
RBRACE;
|
|
|
|
// Template
|
|
passBody:
|
|
(definesBlock | includesBlock | keywordsBlock | pipelineBlock | hlslBlock | shaderEntry)*;
|
|
|
|
definesBlock:
|
|
DEFINES LBRACE
|
|
defineStatement*
|
|
RBRACE;
|
|
|
|
defineStatement:
|
|
IDENTIFIER SEMICOLON;
|
|
|
|
includesBlock:
|
|
INCLUDES LBRACE
|
|
includeStatement*
|
|
RBRACE;
|
|
|
|
includeStatement:
|
|
STRING_LITERAL SEMICOLON;
|
|
|
|
keywordsBlock:
|
|
KEYWORDS LBRACE
|
|
keywordStatement*
|
|
RBRACE;
|
|
|
|
keywordStatement:
|
|
scope? IDENTIFIER (COMMA IDENTIFIER)* SEMICOLON;
|
|
|
|
hlslBlock:
|
|
HLSL LBRACE
|
|
hlslBody
|
|
RBRACE;
|
|
|
|
// Recursively matches content, ensuring braces are balanced.
|
|
hlslBody:
|
|
(
|
|
~(LBRACE | RBRACE) // Match ANY token except open/close braces
|
|
|
|
|
LBRACE hlslBody RBRACE // Or match a nested block recursively
|
|
)*;
|
|
|
|
shaderEntry:
|
|
IDENTIFIER STRING_LITERAL COLON STRING_LITERAL SEMICOLON;
|
|
|
|
functionCall:
|
|
IDENTIFIER LPAREN functionArguments? RPAREN SEMICOLON;
|
|
|
|
functionArguments:
|
|
functionArgument (COMMA functionArgument)*;
|
|
|
|
functionArgument:
|
|
STRING_LITERAL | NUMBER | IDENTIFIER;
|