@@ -24,7 +24,11 @@ There are two main ways to setup your shader project.
24
24
If you're writing a bigger application and you want to integrate SPIR-V shader
25
25
crates to display, it's recommended to use ` spirv-builder ` in a build script.
26
26
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
+
27
30
#### ` build.rs `
31
+ Paste the following into the ` main ` for your build script.
28
32
``` rust,no_run
29
33
SpirvBuilder::new(path_to_shader)
30
34
.spirv_version(1, 0)
@@ -38,13 +42,17 @@ const SHADER: &[u8] = include_bytes!(env!("<shader_name>.spv"));
38
42
```
39
43
40
44
### 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
+
41
49
If you just want to compile a build a shader crate, and don't need to
42
50
automatically compile the SPIR-V binary at build time, you can use
43
51
` .cargo/config ` to set the necessary flags. Before you can do that however you
44
52
need to do a couple of steps first to build the compiler backend.
45
53
46
54
1 . Clone the ` rust-gpu ` repository
47
- 2 . ` cargo build --release `
55
+ 3 . ` cargo build --release ` in ` rust-gpu ` .
48
56
49
57
Now you should have a ` librustc_codegen_spirv ` dynamic library available in
50
58
` 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
56
64
` spirv-unknown-unknown ` sysroot is not currently available in the
57
65
default installation.
58
66
59
-
60
67
``` toml
61
68
[build ]
62
69
target = " spirv-unknown-unknown"
@@ -76,3 +83,5 @@ cargo build
76
83
77
84
Now you should have ` <project_name>.spv ` SPIR-V file in ` target/debug ` that you
78
85
can give to a renderer.
86
+
87
+ [ `rust-toolchain` ] : https://github.com/EmbarkStudios/rust-gpu/blob/main/rust-toolchain
0 commit comments