Slang supports [generics and interfaces](/slang/user-guide/interfaces-generics.html) (a.k.a. type traits/protocols) to allow clear expression of shader specialization without resorting to preprocessor techniques or string-pasting. Unlike C++ templates, Slang's generics are checked ahead of time and don't produce cascading error messages that are difficult to diagnose. The same generic shader can be specialized for a variety of different types to produce specialized code ahead of time, or on the fly, completely under application control.
0 commit comments