Files
rust-gpu/docs/src/building-rust-gpu.md
XAMPPRocky ca8b389b6a Update to use rust-toolchain toml (#284)
* Update to the new rust-toolchain format

* Remove unneeded docs

* Update CI for toolchain file

* Update ci.yaml

* Update ci.yaml

* Update deploy_docs.yml

* Update ci.yaml

* Update deploy_docs.yml

* Remove redundant `rustup component add` commands from ci.yaml.

* Shorten "Continuous integration" to "CI" in ci.yaml.

* Add a helpful message above the TOML in rust-toolchain.

* Don't update rustup in ci.yaml, GHA already has the right version.

Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
Co-authored-by: Eduard-Mihai Burtescu <eddyb@lyken.rs>
2020-12-09 17:43:00 +02:00

3.0 KiB

Building Rust-GPU

Getting started

  1. Clone the repository.

    git clone --recurse-submodules https://github.com/EmbarkStudios/rust-gpu
    
  2. optional Install SPIRV-Tools and add it to your PATH. You can skip this step if you just want to run examples with the defaults. See Using installed SPIRV-Tools if you decide to go with this option.

  3. Next, look at the examples folder. There are two kinds of targets here: [runners] and [shaders]. The projects inside shaders are "GPU crates", i.e. ones that will be compiled one or more SPIR-V modules. The runner projects are normal, CPU crates that use some graphics backend (currently, we have a wgpu runner, a Vulkan runner through ash, and a barebones pure software CPU runner) to actually run one of the "GPU crate" shaders.

    Run the example:

    cargo run --bin example-runner-wgpu
    

    This will build rustc_codegen_spirv, the compiler, then use that compiler to build sky-shader into a SPIR-V module, then finally, build a wgpu sample app (modified from wgpu's examples) using the built SPIR-V module to display the shader in a window.

Using installed SPIRV-Tools

By default, all of the crates and examples in this repo will compile the spirv-tools-sys crate, including a lot of C++ code from SPIRV-Tools. If you don't want to build the C++ code because you already have SPIRV-Tools installed, or just don't want to spend more time compiling, you can build/run the crate with the use-installed-tools feature.

cargo run \
    --manifest-path examples/example-runner/Cargo.toml \
    --features use-installed-tools \
    --no-default-features

You should see warning: use-installed-tools feature on, skipping compilation of C++ code during the compilation, but otherwise the build will function just the same as if you compiled the C++ code, with the exception that it will fail if you don't have SPIRV-Tools installed correctly.