Explaining Stride's shading compilation and the issues with it #1308
ykafia
started this conversation in
Contributors
Replies: 1 comment
-
Updating my comment : More info on LLVM-SPIRV Going the LLVM way seems more suitable for our needs it seems |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Stride shader system
Linked issue : #14
Short list of references :
For reference, a comprehensive list of parser libraries in C# can be seen here.
SDSL
SDSL is a language on its own, it is parsed, it has its own grammar and parser (front end).
Lexer/Parser
SDSL is tokenized with GoldParser and parsed with Irony.
Stride includes the full source code of Irony possibly from before 2013.
As a backend, SDSL's AST is translated into other ASTs for either HLSL or GLSL, and after this translation, those ASTs are transformed into shader text files.
In that sense, Shader compilation goes through these 2 routes :
Shader mixins
SDSL Shaders are organized in mixins that are contained in files and then stored in a ShaderStorage.
When compiling, the shader compiler will go through all the mixins, parse them into their own ASTs and operate/mix them accordingly to create the final AST representation of the shader to compile (as can be seen in this folder of the source code).
Issues and possible Enhancement
On the parser level
Irony is a good fit because we need consistent performances while providing language error handling.
For this purpose, parser generators and recursive descent parsers are either too obscure or not performant enough.
We could probably squeeze some performance out of it by using languages/libraries that are faster in string processing, but i have no benchmarks or enough knowledge to be sure of it.
On the compiler level
Translating from SDSL to HLSL/GLSL in C# is very time consuming, we also have to maintain our own HLSL and GLSL parser.
We can make it more performant by compiling SDSL directly to spirv and using alternative shader translators like spirv-cross or naga.
Those tools are very performant, written in native code but have .NET bindings or can be used as an executable.
With these tools we would take 3 different routes depending our backend :
Our main issue here is the lack of support for processing SPIRV bytecode, and we have multiple solutions for that :
Beta Was this translation helpful? Give feedback.
All reactions