Unlike other Python DSLs, Metashade does not rely on introspection to translate the Python AST to the target language but uses more straightforward mechanisms. It requires the creation of a generator object for a specific target shading language profile. Metashade function definition syntax is used to define the function name, return type, and parameter declarations. Shader entry points are a special case of functions in Metashade. It also allows for the generation of C-like scopes and local variables, addressing the differences between Python and C-like languages.
Key takeaways:
- Metashade is an experimental GPU shading domain-specific language (DSL) embedded in Python, which generates code in a target shading language, currently only supporting HLSL.
- Metashade allows programming at a more abstract level than the target language, offering metaprogramming, stricter typing, multi-language/cross-platform support, and easy integration with Python scripts and ecosystem.
- Unlike other Python DSLs, Metashade doesn't rely on introspection to translate the Python AST to the target language, instead using more straightforward mechanisms.
- Metashade uses Python variables to represent variables in target C-like shading languages, but requires explicit emulation in Python code to address differences in behavior, such as lifetimes of variables and assignment by value.