Sign up to save tools and stay up to date with the latest in AI
bg
bg
1

GitHub - ppenenko/metashade: An experimental GPU shading DSL embedded in Python.

Apr 22, 2024 - github.com
Metashade is an experimental GPU shading domain-specific language (DSL) embedded in Python that generates code in a target shading language, currently only supporting HLSL. It 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. It aims to replace traditional ubershader practice and offers greater flexibility in terms of language dialects, integration requirements, and more divergent languages.

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.
View Full Article

Comments (0)

Be the first to comment!