Skip to content

Commit b8cea94

Browse files
XAMPPRockyeddyb
andauthored
Add step about copying rust-toolchain into your project (#357)
* Add step about copying rust-toolchain into your project * Update docs/src/writing-shader-crates.md Co-authored-by: Eduard-Mihai Burtescu <[email protected]> * Update writing-shader-crates.md Co-authored-by: Eduard-Mihai Burtescu <[email protected]>
1 parent 8acde75 commit b8cea94

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

docs/src/writing-shader-crates.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ There are two main ways to setup your shader project.
2424
If you're writing a bigger application and you want to integrate SPIR-V shader
2525
crates to display, it's recommended to use `spirv-builder` in a build script.
2626

27+
1. Copy the [`rust-toolchain`] file to your project. (You must use the same version of Rust as `rust-gpu`.)
28+
2. Create a `build.rs` in your project root.
29+
2730
#### `build.rs`
31+
Paste the following into the `main` for your build script.
2832
```rust,no_run
2933
SpirvBuilder::new(path_to_shader)
3034
.spirv_version(1, 0)
@@ -38,13 +42,17 @@ const SHADER: &[u8] = include_bytes!(env!("<shader_name>.spv"));
3842
```
3943

4044
### Using `.cargo/config`
45+
46+
> **Note** This method will require manually rebuilding `rust-gpu` each
47+
time there has been changes to the repository.
48+
4149
If you just want to compile a build a shader crate, and don't need to
4250
automatically compile the SPIR-V binary at build time, you can use
4351
`.cargo/config` to set the necessary flags. Before you can do that however you
4452
need to do a couple of steps first to build the compiler backend.
4553

4654
1. Clone the `rust-gpu` repository
47-
2. `cargo build --release`
55+
3. `cargo build --release` in `rust-gpu`.
4856

4957
Now you should have a `librustc_codegen_spirv` dynamic library available in
5058
`target/release`. You'll need to keep this somewhere stable that you can
@@ -56,7 +64,6 @@ that target. We have to also provide `-Zbuild-std` as the
5664
`spirv-unknown-unknown` sysroot is not currently available in the
5765
default installation.
5866

59-
6067
```toml
6168
[build]
6269
target = "spirv-unknown-unknown"
@@ -76,3 +83,5 @@ cargo build
7683

7784
Now you should have `<project_name>.spv` SPIR-V file in `target/debug` that you
7885
can give to a renderer.
86+
87+
[`rust-toolchain`]: https://github.com/EmbarkStudios/rust-gpu/blob/main/rust-toolchain

0 commit comments

Comments
 (0)