Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Making it easier to work with shaders

License

NotificationsYou must be signed in to change notification settings

shader-slang/slang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5,681 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI StatusCTS 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 ofpointers when generating SPIR-V.Slang'scapability 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 providesflexible interop features to enable directly embedding target code or SPIR-V into generated shaders.

Leverage Neural Graphics with Automatic Differentiation

Slang canautomatically 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 viaslangtorch.

Scalable Software Development with Modules

Slang provides amodule 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 supportsgenerics 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 existing shader codebases to immediately benefit from Slang without requiring a complete rewrite or port.

Slang provides a compatibility module that enables the use of most GLSL intrinsic functions and GLSL's parameter binding syntax.

Comprehensive Tooling Support

Slang comes with full support of IntelliSense editing features in Visual Studio Code and Visual Studio through the Language Server Protocol.Full debugging capabilities are also available through RenderDoc and SPIR-V based tools.

Getting Started

The fastest way to get started using Slang in your own development is to use a pre-built binary package, available through GitHubreleases.Slang binaries are also included in theVulkan SDK since version 1.3.296.0.

There are packages built for x86_64 and aarch64 Windows, Linux and macOS.Each binary release includes the command-lineslangc compiler, a shared library for the compiler, and theslang.h header.

See the user-guide for info on using theslangc command-line tool:Slang Command Line Usage.

If you want to try out the Slang language without installing anything, a fast and simple way is to use theSlang Playground. The playground allows you to compile Slang code to a variety of targets, and even run some simple shaders directly within the browser. The playground loads Slang compiler to your browser and runs all compilation locally. No data will be sent to any servers.

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

Documentation

The Slang project provides a variety of differentdocumentation, but most users would be well served starting with theUser's Guide.

For developers writing Slang code, theSlang Core Module Reference provides detailed documentation on Slang's built-in types and functions.

We also provide a fewexamples 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.GFX is being deprecated in favor ofslang-rhi.

Additionally, we recommend checking outVulkan 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:

  • Please follow the contributorCode of Conduct.
  • Bugs reports and feature requests should go through the GitHub issue tracker
  • Changes should ideally come in as small pull requests on top ofmaster, coming from your own personal fork of the project
  • Large features that will involve multiple contributors or a long development time should be discussed in issues, and broken down into smaller pieces that can be implemented and checked in in stages

Contribution guide describes the workflow for contributors at more detail.

Limitations and Support

Platform support

The Slang compiler and libraries can be built on the following platforms:

WindowsLinuxMacOSWebAssembly
supportedsupportedsupportedexperimental

Bothx86_64 andaarch64 architectures are supported on Windows, Linux and MacOS platforms.

Target support

Slang can compile shader code to the following targets:

TargetStatusOutput Formats
Direct3D 11supportedHLSL
Direct3D 12supportedHLSL
VulkansupportedSPIRV, GLSL
Metalexperimental*Metal Shading Language
WebGPUexperimental**WGSL
CUDAsupportedC++ (compute only)
OptixexperimentalC++ (WIP)
CPUexperimentalC++ (kernel), C++ (host), standalone executable, dynamic library

*Slang currently supports generating vertex, fragment, compute, task and meshshaders for Metal.

**WGSL support is still work in-progress.

For greater detail, see theSupported CompilationTargets section of theUser Guide

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

License

The Slang code itself is under the Apache 2.0 with LLVM Exception license (seeLICENSE).

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

Slang releases may includeLLVM under the license:

  • llvm (Apache 2.0 License with LLVM exceptions)

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

  • glm (MIT)
  • stb_image andstb_image_write from thestb collection of single-file libraries (Public Domain)
  • tinyobjloader (MIT)

[8]ページ先頭

©2009-2026 Movatter.jp