forked from Misaki/GhostEngine
Refactor render graph & DSL; remove material system
- Major optimization of Ghost.RenderGraph.Concept: pooled resources, zero-allocation hot paths, explicit queue types, and batch barrier APIs. - Migrated Ghost.DSL shader compiler to ANTLR4-based parser; removed hand-written parser, added grammar files and semantic model conversion. - Added CollectionPool/ListPool for pooled list management. - Updated documentation for new architecture and performance. - Removed Ghost.Shader.Concept (material/material system) from repo and solution. - README.md replaced with a brief project statement.
This commit is contained in:
33
Ghost.DSL/Grammar/GhostShaderLexer.g4
Normal file
33
Ghost.DSL/Grammar/GhostShaderLexer.g4
Normal file
@@ -0,0 +1,33 @@
|
||||
lexer grammar GhostShaderLexer;
|
||||
|
||||
// Keywords
|
||||
SHADER: 'shader';
|
||||
PROPERTIES: 'properties';
|
||||
PIPELINE: 'pipeline';
|
||||
PASS: 'pass';
|
||||
DEFINES: 'defines';
|
||||
KEYWORDS: 'keywords';
|
||||
INCLUDES: 'includes';
|
||||
GLOBAL: 'global';
|
||||
LOCAL: 'local';
|
||||
HLSL: 'hlsl';
|
||||
|
||||
// Punctuation
|
||||
LBRACE: '{';
|
||||
RBRACE: '}';
|
||||
LPAREN: '(';
|
||||
RPAREN: ')';
|
||||
SEMICOLON: ';';
|
||||
COMMA: ',';
|
||||
EQUALS: '=';
|
||||
COLON: ':';
|
||||
|
||||
// Literals
|
||||
STRING_LITERAL: '"' (~["\r\n] | '\\' .)* '"';
|
||||
NUMBER: [0-9]+ ('.' [0-9]+)? | '.' [0-9]+;
|
||||
IDENTIFIER: [a-zA-Z_][a-zA-Z0-9_]*;
|
||||
|
||||
// Whitespace and Comments
|
||||
WS: [ \t\r\n]+ -> skip;
|
||||
LINE_COMMENT: '//' ~[\r\n]* -> skip;
|
||||
BLOCK_COMMENT: '/*' .*? '*/' -> skip;
|
||||
94
Ghost.DSL/Grammar/GhostShaderParser.g4
Normal file
94
Ghost.DSL/Grammar/GhostShaderParser.g4
Normal file
@@ -0,0 +1,94 @@
|
||||
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
|
||||
hlslCode
|
||||
RBRACE;
|
||||
|
||||
hlslCode:
|
||||
.*? ; // Capture everything inside hlsl block
|
||||
|
||||
shaderEntry:
|
||||
IDENTIFIER STRING_LITERAL COLON STRING_LITERAL SEMICOLON;
|
||||
|
||||
functionCall:
|
||||
IDENTIFIER LPAREN functionArguments? RPAREN SEMICOLON;
|
||||
|
||||
functionArguments:
|
||||
functionArgument (COMMA functionArgument)*;
|
||||
|
||||
functionArgument:
|
||||
STRING_LITERAL | NUMBER | IDENTIFIER;
|
||||
Reference in New Issue
Block a user