“Slang: language mechanisms for extensible real-time shading systems” by He, Fatahalian and Foley

  • ©Yong He, Kayvon Fatahalian, and Tim Foley



Entry Number: 141


    Slang: language mechanisms for extensible real-time shading systems

Session/Category Title: Pipelines and Languages for the GPU




    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 Tenderer 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 Tenderer 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.


    1. Amazon. 2016. Lumberyard Engine, https://aws.amazon.com/lumberyard/. (2016).Google Scholar
    2. Apple Inc. 2014a. Metal, https://developer.apple.com/documentation/metalGoogle Scholar
    3. Apple Inc. 2014b. The Swift Programming Language. https://itunes.apple.com/us/book/the-swift-programming-language-swift-4-0-3/id881256329Google Scholar
    4. F. O. Bartell, E. L. Dereniak, and W. L Wolfe. 1981. The Theory And Measurement Of Bidirectional Reflectance Distribution Function (BRDF) And Bidirectional Transmittance Distribution Function (BTDF). (1981), 0257 – 0257 – 7 pages.Google Scholar
    5. Nir Benty, Kai-Hwa Yao, Tim Foley, Anton S. Kaplanyan, Conor Lavelle, Chris Wyman, and Ashwin Vijay 2017. The Falcor Rendering Framework. (07 2017). https://gir.hub.com/NVTDIAGameWorks/Falcor https://github.com/NVIDIAGameWorks/Falcor.Google Scholar
    6. ECMA International. 2017. C# Language Specification (ECMA-334:2017). (2017).Google Scholar
    7. Epic Games. 2015. Unreal Engine 4 Documentation, http://docs.unrealengine.com. (2015).Google Scholar
    8. Yong He, Tim Foley, Teguh Hofstee, Haomin Long, and Kayvon Fatahalian. 2017. Shader Components: Modular and High Performance Shader Development. ACM Trans. Graph. 36, 4, Article 100 (July 2017), 11 pages. Google ScholarDigital Library
    9. Eric Heitz, Jonathan Dupuy, Stephen Hill, and David Neubelt. 2016. Real-time Polygonal-light Shading with Linearly Transformed Cosines. ACM Trans. Graph. 35, 4, Article 41 (July 2016), 8 pages. Google ScholarDigital Library
    10. Sony Pictures Imageworks. 2017. Open Shading Language 1.9 Language Specification. https://github.com/imageworks/OpenShadingLanguage/blob/master/src/doc/osl-languagespec.pdf. (2017).Google Scholar
    11. Khronos Group, Inc. 2009. ARB_shader_subroutine, https://www.opengl.org/registry/specs/ARB/shader_subroutine.txt. (2009).Google Scholar
    12. Michael D. McCool and Stefanus Du Toit. 2004. Metaprogramming GPUs with Sh. A K Peters. I-XVII, 1–290 pages. Google ScholarDigital Library
    13. Michael D. McCool, Zheng Qin, and Tiberiu S. Popa. 2002. Shader Metaprogramming. In Proceedings of the ACM SIGGRAPH/EUROGRAPHICS Conference on Graphics Hardware (HWWS ’02). 57–68. http://dl.acm.org/citation.cfm?id=569046.569055 Google ScholarDigital Library
    14. John McDonald. 2016. High Performance Vulkan: Lessons Learned from Source 2. In GPU Technology Conference 2016 (GTC). http://on-demand.gputechconf.com/gtc/2016/events/vulkanday/High_Performance_Vulkan.pdf.Google Scholar
    15. Microsoft. 2011. Interfaces and Classes, https://msdn.microsoft.com/en-us/library/windows/desktop/ff471421.aspx. (2011).Google Scholar
    16. F. E. Nicodemus, J. C. Richmond, J. J. Hsia, I. W. Ginsberg, and T. Limperis. 1992. Radiometry Jones and Bartlett Publishers, Inc., USA, Chapter Geometrical Considerations and Nomenclature for Reflectance, 94–145. http://dl.acm.org/citation.cfm?id=136913.136929 Google ScholarDigital Library
    17. NVIDIA. 2017. ORCA: Open Research Content Archive. http://developer.nvidia.com/orca. (2017).Google Scholar
    18. Matt Pharr. 2004. An Introduction to Shader Interfaces. In GPU Gems: Programming Techniques, Tips and Tricks for Real-Time Graphics, Randima Fernando (Ed.). Pearson Higher Education.Google Scholar
    19. Aras Pranckevičius. 2015. Porting Unity to new APIs. In SIGGRAPH 2015 Course Notes: An Overview of Next-generation Graphics APIs. http://nextgenapis.realtimerendering.com/presentations/7_Pranckevicius_Unity.pptx.Google Scholar
    20. Rust Project Developers. 2015. The Rust Programming Language. https://doc.rust-lang.org/book/.Google Scholar
    21. Matt Sandy. 2018. DirectX Raytracing. Game Developers Conference 2018 slides.. (2018). https://msdnshared.blob.core.windows.net/media/2018/03/GDC_DXR_deck.pdfGoogle Scholar
    22. Natalya Tatarchuk and Chris Tchou. 2017. Destiny Shader Pipeline. (2017). http://advances.realtimerendering.com/destiny/gdc_2017/index.html.Google Scholar
    23. Unity Technologies. 2017. Unity 5.6 Users Manual. Available at https://docs.unity3d.com/. (2017).Google Scholar
    24. P. Wadler and S. Blott. 1989. How to Make Ad-hoc Polymorphism Less Ad Hoc. In Proceedings of the 16th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’89). ACM, New York, NY, USA, 60–76. Google ScholarDigital Library

ACM Digital Library Publication:

Overview Page: