shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 159 forks source link
cuda d3d12 glsl hlsl shaders vulkan

Slang

Linux Build Status Windows Build Status macOS Build 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.

Key Features

The Slang system is designed to provide developers of real-time graphics applications with the services they need when working with shader code.

Getting Started

If you want to try out the Slang language without installing anything, a fast and simple way is to use the Shader Playground.

The fastest way to get started using Slang in your own development is to use a pre-built binary package, available through GitHub releases. There are packages built for 32- and 64-bit Windows, as well as 64-bit Ubuntu. Each binary release includes the command-line slangc compiler, a shared library for the compiler, and the slang.h header.

If you would like to build Slang from source, please consult the build instructions.

Documentation

The Slang project provides a variety of different documentation, but most users would be well served starting with the User's Guide.

We also provide a few examples of how to integrate Slang into a rendering application.

These examples use a graphics layer that we include with Slang called "GFX" which is an abstraction library of various graphics APIs (D3D11, D2D12, OpenGL, Vulkan, CUDA, and the CPU) to support cross-platform applications using GPU graphics and compute capabilities. If you'd like to learn more about GFX, see the GFX User Guide.

Additionally, we recommend checking out Vulkan Mini Examples for more examples of using Slang's language features available on Vulkan, such as pointers and the ray tracing intrinsics.

Contributing

If you'd like to contribute to the project, we are excited to have your input. The following guidelines should be observed by contributors:

Contribution guide describes the workflow for contributors at more detail.

Limitations and Support

Platform support

Windows Linux MacOS
supported supported unofficial

Target support

Direct3D 11 Direct3D 12 Vulkan CUDA OptiX CPU Compute
HLSL HLSL GLSL & SPIR-V C++ (compute-only) C++ (WIP) C++ (compute-only)

*for greater detail, see the Supported Compilation Targets section of the User Guide

The Slang project has been used for production applications and large shader codebases, but it is still under active development. Support is currently focused on the platforms (Windows, Linux) and target APIs (Direct3D 12, Vulkan) where Slang is used most heavily. Users who are looking for support on other platforms or APIs should coordinate with the development team via the issue tracker to make sure that their use case(s) can be supported.

License

The Slang code itself is under the MIT license (see LICENSE).

Builds of the core Slang tools depend on the following projects, either automatically or optionally, which may have their own licenses:

Slang releases may include slang-llvm which includes LLVM under the license:

Some of the tests and example programs that build with Slang use the following projects, which may have their own licenses: