SupaSim is a general purpose GPU and simulation toolkit, made in Rust, with kernels written in Slang.
SupaSim encompasses several libraries. The following libraries live on this repo:
The following additional libraries providing bindings to C++ libraries live on the supasim github organization:
Shaders are written in Slang. SupaSim provides some advice on how to avoid unintended behavior (aka bugs) in Slang code, which can be seen here. When compiling kernels, they may not be directly transpiled to the target language. For example, many languages first go through SPIR-V, enabling SPIRV-Opt to optimize code, as well as allowing use of SPIRV-Cross, which may be more mature and stable than Slang's direct output into the target language.
Once you have the dependencies installed, you can simply add supasim as a dependency to your project, with your desired features. The examples can be easily run like any other rust project, for example cargo run --example buddhabrot.
All requirements are part of the vulkan sdk. The only dynamically linked component is DXC for compiling DirectX shaders.
This is required to use the wgpu backend, or to compile DXIL code for the shader library. Therefore, users seeking this
functionality should plan to ship a copy of dxc.dll. If you wish to use older versions of DXC for whatever reason, you should also ship dxil.dll, which isn't part of the vulkan
sdk and must be downloaded separately, such as from DXC github releases.
If you choose to use the vulkan sdk, you must set the environment variable VULKAN_SDK to the path where it was installed to. It is
your responsibility to make sure that dxc.dll and dxil.dll are on the system library search path if you use them. A build configured
to use these that cannot find them may not function properly.
Otherwise, the full list of dependencies are as follows:
- Slang
- SPIRV-Cross (for most build configs, and for stable compilation to MSL)
- SPIRV-Tools (for optimizing and extra validation)
- DXC and DXIL (for aforementioned use cases)
Follow the setup instructions in the repositories corresponding to the used rust bindings for each of the above.
Features can be enabled by passing a command line argument of this form: --features="feature1,feature2". The available features for supasim are:
wgpu- enables thewgpubackend, which is the most cross platform backend, and also provides more error checkingvulkan- enables the raw vulkan backend for higher performancemetal- enables the metal backend
Features for supasim-kernels are:
msl-out- enables writing MSL output. Requires SPIRV-Crosswgsl-out- enables writingwgslfor WebGPUdxil-out- enables writingdxiloutput. Note that HLSL output is always supportedopt-valid- enables extra optimizations or validation. Requires SPIRV-Tools and SPIRV-Cross.
Note that supasim-kernels always supports writing SPIR-V. Also note that as wgpu and vulkan backends both only take
SPIR-V at the moment, no features need to be enabled for use with supasim.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.