ACM Transactions on Graphics, 37(4), Aug 2018
Proceedings of ACM SIGGRAPH 2018
Designers of real-time rendering engines must balance the conflicting goals of maintaining clear, extensible shading systems and achieving high rendering performance. In response, engine architects have established effective design patterns for authoring shading systems, and developed engine-specific code synthesis tools, ranging from preprocessor hacking to domain-specific shading languages, to productively implement these patterns. The problem is that proprietary tools add significant complexity to modern engines, lack advanced language features, and create additional challenges for learning and adoption. We argue that the advantages of engine-specific code generation tools can be achieved using the underlying GPU shading language directly, provided the shading language is extended with a small number of best-practice principles from modern, well-established programming languages. We identify that adding generics with interface constraints, associated types, and interface/structure extensions to existing C-like GPU shading languages enables real-time renderer developers to build shading systems that are extensible, maintainable, and execute efficiently on modern GPUs without the need for additional domain-specific tools. We embody these ideas in an extension of HLSL called Slang, and provide a reference design for a large, extensible shader library implemented using Slang's features. We rearchitect an open source renderer to use this library and Slang's compiler services, and demonstrate the resulting shading system is substantially simpler, easier to extend with new features, and achieves higher rendering performance than the original HLSL-based implementation.
Download Paper (3 MB)
You may also wish to see our SIGGRAPH 2017 paper on shader components, which was a major motivation for Slang.
Note: The most thorough documentation of the design decisions underlying Slang, and their relationship to the shader components design pattern can be found in Yong He's CMU Ph.D. dissertation, linked below:
The Slang compiler is available on Github.
Slang is now the default shader compiler for NVIDIA's Falcor research rendering framework.