Slang: Language Mechanisms for Extensible Real-time Shading Systems
Yong HeKayvon FatahalianTim Foley
ACM Trans. Graph. (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.

Yong He, Kayvon Fatahalian, Tim Foley (2018). Slang: Language Mechanisms for Extensible Real-time Shading Systems. ACM Trans. Graph., 37(4), 141:1--141:13.

author = {Yong He and Kayvon Fatahalian and Tim Foley},
title = {Slang: Language Mechanisms for Extensible Real-time Shading Systems},
journal = {ACM Trans. Graph.},
issue_date = {August 2018},
volume = {37},
number = {4},
month = aug,
year = {2018},
pages = {141:1--141:13},
articleno = {141},
numpages = {13},
publisher = {ACM},