+0
日增长
5,816
stars
536
forks
56
watchers
8,447
prs
5,906
issues
605
releases
README
Slang !CI Status !CTS Status Slang is a shading language that makes it easier to build and maintain large shader codebases in a modular and extensible fashion, while also maintaining the highest possible performance on modern GPUs and graphics APIs. Slang is based on years of collaboration between researchers at NVIDIA, Carnegie Mellon University, Stanford, MIT, UCSD and the University of Washington. Why Slang? The Slang shading language is designed to enable real-time graphics developers to work with large-scale, high-performance shader code. Write Shaders Once, Run Anywhere The Slang compiler can generate code for a wide variety of targets: D3D12, Vulkan, Metal, D3D11, CUDA, and even generate code to run on a CPU. For textual targets, such as Metal Shading Language (MSL) and CUDA, Slang produces readable code that preserves original identifier names, as well as the type and call structure, making it easier to debug. Access the Latest GPU Features Slang code is highly portable, but can still leverage unique platform capabilities, including the latest features in Direct3D and Vulkan. For example, developers can make full use of pointers when generating SPIR-V. Slang's capability system helps applications manage feature set differences across target platforms by ensuring code only uses available features during the type-checking step, before generating final code. Additionally, Slang provides flexible interop features to enable directly embedding target code or SPIR-V into generated shaders. Leverage Neural Graphics with Automatic Differentiation Slang can automatically generate both forward and backward derivative propagation code for complex functions that involve arbitrary control flow and dynamic dispatch. This allows existing rendering codebases to easily become differentiable, or for Slang to serve as the kernel language in a PyTorch-driven machine learning framework via slangtorch. Scalable Software Development with Modules Slang provides a module system that enables logical organization of code for separate compilation. Slang modules can be independently compiled offline to a custom IR (with optional obfuscation) and then linked at runtime to generate code in formats such as DXIL or SPIR-V. Code Specialization that Works with Modules Slang supports generics and interfaces (a.k.a. type traits/protocols), allowing for clear expression of shader specialization without the need for preprocessor techniques or string-pasting. Unlike C++ templates, Slang's generics are pre-checked 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, entirely under application control. Easy On-ramp for HLSL and GLSL Codebases Slang's syntax is similar to HLSL, and most existing HLSL code can be compiled with the Slang compiler out-of-the-box, or with just minor modifications. This allows
Top issues
#7758Language server takes a long time to respond to requests31 comments · 2025-07-14#12714Resolve Slang's default/natural layout behavior and scrub layout claims in Slang + Khronos docs29 comments · 2026-08-24#11631Entry-point [require] capabilities do not update SPIR-V codegen capabilities25 comments · 2026-06-16#9580Returning an associated type of an extern/export struct crashes Slang19 comments · 2026-01-10#11599Clip-space z remapping option18 comments · 2026-06-13#12392slangc segfaults with no diagnostic when an entry point calls a function that is itself an entry point (null deref in translateEntryPointInParamToBorrow)17 comments · 2026-08-06#8774WGSL backend emits module-scope var<private> for builtins breaking uniformity analysis for subgroup ops17 comments · 2025-10-22#6441Change SPIR-V lowering of `switch` with non-trivial fallthrough to avoid undefined reconvergence behavior17 comments · 2025-02-24
Discussions
#14461torch-vulkan: a PyTorch backend with 300+ Slang compute kernels0 comments · 2026-11-12#14387undefined reference to `slang_createGlobalSession2' error when building Vulkan project1 comments · 2026-11-06#13422Creating a combined Sampler from Texture and SamplerState1 comments · 2026-10-03#13277Question about math intrinsics in the Slang host VM3 comments · 2026-09-28#12808how to support open existential type1 comments · 2026-08-28#12314Shader uniform variables registers/binding indices.2 comments · 2026-08-01#12135About array of ConstantBuffer0 comments · 2026-07-16#12087`constexpr` constants not recognized as compile-time constants2 comments · 2026-07-13