Draft:Slang (Shader Language)
Submission declined on 24 September 2026 by Helpful Raccoon (talk). This draft's references do not show that the subject meets Wikipedia's criteria for inclusion. The draft requires multiple published secondary sources that:
Where to get help
How to improve a draft
You can also browse Wikipedia:Featured articles and Wikipedia:Good articles to find examples of Wikipedia's best writing on topics similar to your proposed article. Improving your odds of a speedy review To improve your odds of a faster review, tag your draft with relevant WikiProject tags using the button below. This will let reviewers know a new draft has been submitted in their area of interest. For instance, if you wrote about a female astronomer, you would want to add the Biography, Astronomy, and Women scientists tags. Editor resources
|
Comment: Zero independent sources are cited Helpful Raccoon (talk) 20:05, 24 September 2026 (UTC)
| Slang | |
|---|---|
| Family | Shading language |
| Designed by | Yong He, Kayvon Fatahalian, Tim Foley |
| Developer | Khronos Group, NVIDIA |
| First appeared | 2018 |
| Stable release | v2026.18
/ September 16, 2026 |
| Implementation language | C++ |
| Platform | x86-64, ARM64 |
| OS | Windows, Linux and macOS |
| License | Apache License 2.0 with LLVM Exception |
| Website | https://shader-slang.org |
| Influenced by | |
| HLSL, C++ | |
The Slang Shader Language or Slang is an open-source, high-level shading language with a syntax based on the HLSL and C++ programming languages.[1] Similar to how the C programming language historically abstracted varying hardware-level CPU architectures, Slang acts as a zero-overhead abstraction layer at the API level. It was designed to allow developers to author unified GPU shader programs that can be cross-compiled to execute across virtually any modern graphics API or rendering library without modifying the source code.
Originally introduced as an academic research project by Carnegie Mellon University, Stanford University, and NVIDIA in 2018,[2] Slang was transitioned to an open-governance model under the Khronos Group in 2024 to become a cross-industry standard.[3]
History
[edit]Slang originally began as an academic research project at Carnegie Mellon University and Stanford University, developed in collaboration with NVIDIA researchers to address scalability issues in large-scale shader codebases. The foundational architecture and language design were formally introduced in 2018 at the SIGGRAPH conference.[4]
In the beginning, Slang was primarily used within NVIDIA for internal rendering frameworks, such as the NVIDIA Falcor research engine and NVIDIA Omniverse production platforms.
In November 2024, NVIDIA and the original authors transitioned Slang to an open-governance model under the Khronos Group.[3] This transition was established to encourage multi-vendor governance, industry trust, and wider ecosystem collaboration for business-critical rendering applications. Development continues as an open-source project hosted on GitHub under the Apache 2.0 license with LLVM Exceptions.
Language
[edit]Data types
[edit]Slang features a type system that maintains complete compatibility with all basic data types from HLSL. These basic types include:
- float - a 32 bit floating point number
- half - a 16 bit floating point number
- int - a 32 bit integer
- uint - a 32 bit unsigned integer
- bool - a Boolean variable
Like HLSL, Slang also features vector and matrix data types based on the basic data types, such as float3 and float4x4. It also supports user-defined struct and array types.
API-level abstraction paradigm
[edit]Architecturally, Slang introduces a compilation model that mirrors early cross-platform CPU programming paradigms. Instead of targetting hardware instruction sets directly, the compiler framework abstracts the structural differences between software runtime environments and graphics libraries. Shaders written in Slang are compiled to an intermediate state that can be targeted downstream to execute within Vulkan, Direct3D 12, Metal and WebGPU contexts, ensuring cross-library execution portability from a single source specification.
Low-level hardware control and intrinsics
[edit]While Slang introduces high-level software engineering paradigms, it preserves explicit, low-level hardware control equivalent to raw HLSL and GLSL source authoring. The language specification guarantees direct, unabstracted access to underlying GPU hardware features:
- Hardware intrinsics – Direct invocation of hardware-specific operations including wave intrinsics (sub-group operations), explicit memory barriers, execution synchronization fence operations, and atomic operations.
- Modern pipeline targeting – Native compilation support for specialized hardware graphics pipelines, including hardware-accelerated ray tracing, inline ray tracing, mesh shaders, and tessellation stages.
- Target-specific interoperation – The language includes explicit escape hatches for low-level platform optimization, such as the `spirv_asm` construct, which permits developers to embed inline SPIR-V assembly instructions directly within Slang functions to utilize undocumented or cutting-edge vendor-specific GPU features.
Interfaces and generics
[edit]Unlike traditional shading languages that rely on the text-based C preprocessor for polymorphism, Slang introduces language-level abstractions designed around the principle of zero-overhead abstraction.
- Interfaces - define a set of methods or properties that a type must implement, serving as a formal contract.
- Checked generics - allow functions and structures to accept type parameters that are statically checked against interface constraints at definition time, eliminating cascading compiler errors.
To achieve zero runtime overhead on the GPU, the Slang compiler utilizes monomorphization. During the compilation pass, the compiler generates specialized, instruction-level optimized hardware code variants for each specific type instantiation. This guarantees that high-level abstractions do not introduce virtual function tables, dynamic dispatch, or performance penalties during shader execution.
Automatic differentiation
[edit]Slang features first-class support for forward-mode and backward-mode automatic differentiation natively on the GPU.[5] Functions marked with the differentiable attribute automatically generate derivative propagation code for neural graphics applications.
Features
[edit]Module system and compilation
[edit]Slang implements a distinct module system that facilitates the logical organization of shader code for independent, offline compilation:
- Separate offline compilation – Individual Slang modules can be compiled independently prior to application runtime into a custom, optimized Intermediate Representation (IR).
- Dynamic shader linking – The pre-compiled IR modules are linked dynamically at runtime to synthesize the final execution-ready target code, such as DXIL or SPIR-V.
- Textual code preservation – When targeting textual source backends like Metal Shading Language (MSL) or CUDA, the compiler outputs structured code that explicitly preserves the original source identifier names, type definitions, and call hierarchies to facilitate debugging within external diagnostic tools.
Platform interoperability and capability system
[edit]To address the functional variances between modern graphics hardware configurations, Slang utilizes a specialized target profiles management pipeline:
- Capability validation system – The compiler evaluates target platform feature differences during the static type-checking step. It verifies hardware feature availability before producing final code output, throwing syntax-level validation errors if a device lacks a required capability.
- Explicit code embedding – The language specification permits the direct embedding of foreign target source fragments or raw SPIR-V intermediate bytecode blocks into generated output shaders.
Machine learning and Python integration
[edit]Slang provides infrastructure designed to bridge real-time rendering pipelines with deep learning frameworks:
- Differentiable shader execution – The automatic differentiation framework supports complex math operations involving arbitrary control flow, non-uniform loops, and dynamic dispatch behaviors to generate forward and backward derivative propagation kernels.
- SlangPy ecosystem – The compiler includes a dedicated execution wrapper package (`SlangPy`) that allows Slang shader structures and specialized, control-divergent GPU algorithms to be executed directly inside Python training loops and PyTorch workloads without writing boilerplate interface layer code.
Language compatibility modules
[edit]To lower adoption friction from legacy shading frameworks, Slang provides built-in transition support:
- HLSL superset mapping – The compiler infrastructure accepts existing High-Level Shader Language source code directly with minimal syntax adjustments.
- GLSL intrinsic emulation – The language includes an explicit compatibility layer module that emulates standard GLSL parameter binding syntax and exposes core GLSL intrinsic functions to the compiler engine.
Environment
[edit]Slang programs are authored as high-level source code and are processed by the Slang compiler infrastructure (`slangc`). The compiler architecture translates the high-level source code into a specialized internal Intermediate Representation (IR).
The Slang compiler natively generates binary bytecode for SPIR-V and source code for NVIDIA CUDA (PTX). For other target platforms, such as Direct3D 12, the compiler translates the internal IR into the specific textual shading language of the target (such as HLSL), and subsequently utilizes the target platform's downstream compiler (such as the Microsoft DirectX Shader Compiler or `dxc`) to compile the code into its final binary format.
The Slang compiler infrastructure (`slangc`) is a C++ library and command-line compiler system that implements the language specifications. The source code of the compiler is primarily written in C++ to ensure high-performance code generation and intermediate representation optimization passes. The reference implementations of the Slang compiler architecture are designed for the x86-64 and ARM64 processor platforms. Official pre-compiled binaries and source-level compilations are actively supported on Windows (Windows 10 and later), Linux (including Ubuntu and Red Hat distributions), and macOS operating systems.
The Slang compiler infrastructure is distributed as free and open-source software under the terms of the Apache License 2.0 with LLVM Exceptions. This licensing model allows the software product to be integrated into both open-source and proprietary commercial software applications without requiring the source code of the host application to be disclosed.
Implementations and tooling
[edit]The primary implementation of the language is the open-source Slang compiler infrastructure (`slangc`), which serves as the reference compiler and language runtime.
Official developer tools and integrated development environments (IDEs) that implement support for Slang include:
- Visual Studio Code — Supported through an official extension that integrates the Slang Language Server Protocol (LSP) for real-time diagnostics and code completion.
- Visual Studio — Supported via specialized IDE integration packages providing syntax highlighting and build-system integration.
- Vulkan SDK — The software development kit natively bundles the Slang compiler toolset as a core component for Vulkan application development.
Target backends comparison
[edit]The compiler processes code using a two-tier compilation model depending on the targeted pipeline:
| Target Type | Output Format | Compilation Method | Associated Platform |
|---|---|---|---|
| Binary Bytecode | SPIR-V | Native compilation from Slang IR | Vulkan |
| DXIL / DXBC | Emits HLSL text; compiles via downstream `dxc`/`fxc` | Direct3D 12 / Direct3D 11 | |
| Textual Shading Languages | HLSL | Source-to-source translation from Slang IR | Direct3D ecosystems |
| GLSL | Source-to-source translation from Slang IR | OpenGL and Vulkan systems | |
| Metal Shading Language (MSL) | Source-to-source translation from Slang IR | Apple Metal API | |
| WebGPU Shading Language (WGSL) | Source-to-source translation from Slang IR | WebGPU standard | |
| GPGPU Compute | PTX source code | Native compilation from Slang IR | NVIDIA CUDA |
| C++ source code | Source-to-source translation from Slang IR | NVIDIA OptiX execution | |
| Host Execution | Native C++ | Source-to-source translation from Slang IR | CPU execution |
See also
[edit]References
[edit]- ↑ "The Slang Shading Language Official Website". shader-slang.org.
- ↑ "Slang: language mechanisms for extensible real-time shading". Carnegie Mellon University Graphics Lab. 2018.
- 1 2 "Khronos Group Establishes Open Governance for Slang Shading Language". GitHub - The Khronos Group. November 2024.
- ↑ He, Yong; Fatahalian, Kayvon; Foley, Tim (August 2018). "Slang: Language Mechanisms for Extensible Real-Time Shading Systems". ACM Transactions on Graphics (TOG). 37 (4): 1–13. doi:10.1145/3197517.3201380.
- ↑ He, Yong; Foley, Tim; Kessenich, John; Fatahalian, Kayvon (December 2023). "SLANG.D: Fast, Modular and Differentiable Shader Programming". ACM Transactions on Graphics (TOG). 42 (6): 1–16. doi:10.1145/3618388.

Please delete the portions which were LLM-generated, and summarize in your own words a range of independent, reliable, published sources that discuss the subject. If you have used an LLM but you believe that your use is covered by one of the two exceptions (basic copyediting and translation between two languages in which you are fully fluent), please provide a transcript of the prompt(s) you used while writing your draft (see the how-to guide). Reviewers can make mistakes. If you have not received any LLM assistance, you may seek a second opinion at the AfC Help Desk.
See the advice page on large language models for more information.