You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-17Lines changed: 32 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,39 +1,54 @@
1
1
# cargo-gpu
2
2
3
-
Command line tool for building Rust shaders using rust-gpu.
3
+
`cargo-gpu` is an installation manager and command line tool for [rust-gpu](https://github.com/Rust-GPU/rust-gpu/). `cargo-gpu` is not an essential requirement, it should just make working with `rust-gpu` easier.
4
4
5
-
## Getting Started
5
+
There are 2 ways to use it:
6
+
1. Through a CLI, ie `cargo gpu ...`
7
+
2. As a crate included in your build scripts or executables
6
8
7
-
### Installation
9
+
##1. CLI Quickstart
8
10
9
-
To install the tool ensure you have`rustup`. Then run:
11
+
To install the command line tool, ensure you are using`rustup`. Then run:
After that you can use `cargo gpu` to compile your shader crates with:
17
+
You can then use `cargo gpu` to compile your shader crates or use any of the other commands you're used to:
16
18
17
19
```
18
20
cargo gpu build
21
+
cargo gpu check
22
+
cargo gpu clippy
19
23
```
20
24
21
-
This plain invocation will compile the crate in the current directory and
22
-
place the compiled shaders in the current directory.
25
+
### Example project
23
26
24
-
Use `cargo gpu help` to see other options :)
27
+
To create an example project from our [templates](https://github.com/Rust-GPU/rust-gpu-template), use the command below:
28
+
```
29
+
cargo gpu new
30
+
# choose any template you want, then select cargo-gpu cmdline integration
31
+
# you may have to adjust the crate name
32
+
cargo gpu build -p mygraphics-shaders
33
+
```
25
34
26
-
### Next Steps
35
+
This plain invocation will compile the crate in the current directory and place the compiled shaders in the current directory.
27
36
28
-
You can try this out using the example repo at <https://github.com/rust-GPU/cargo-gpu/crates/shader-crate-template>.
29
-
Keep in mind <https://github.com/rust-GPU/cargo-gpu/crates/shader-crate-template> is _not_ yet a cargo generate template,
30
-
it's just a normal repo.
37
+
Use `cargo gpu help` to see more options :)
31
38
39
+
## 2. Crate Quickstart
40
+
41
+
Add `cargo-gpu-install` as a regular or build dependency to your project, and use it like this:
42
+
43
+
```rust,no_run
44
+
let shader_crate = PathBuf::from("./shaders");
45
+
let backend = cargo_gpu_install::Install::from_shader_crate(shader_crate.clone()).run()?;
46
+
let mut builder = backend.to_spirv_builder(shader_crate, "spirv-unknown-vulkan1.2");
47
+
// configure the builder...
48
+
let spv_result = builder.build()?;
32
49
```
33
-
git clone https://github.com/rust-GPU/cargo-gpu
34
-
cd cargo-gpu/crates/shader-crate-template
35
-
cargo gpu build
36
-
```
50
+
51
+
For more detail, see the [readme of `cargo-gpu-install`](crates/cargo-gpu-install/README.md) or use any of our [templates](https://github.com/Rust-GPU/rust-gpu-template) as reference and choosing the `cargo-gpu-install` integration.
37
52
38
53
## How it works
39
54
@@ -52,7 +67,7 @@ the usage instructions the backend and nightly Rust version are referred to as "
52
67
> workspace might use a newer `Cargo.lock` layout not supported by the pinned version of the shader crate's custom codegen backend. The solution to
53
68
> this is to either exclude the shader from the workspace, or upgrade the shader's `spirv-std` dependency to the latest.
54
69
55
-
## Usage
70
+
## CLI Usage
56
71
57
72
All the following arguments for the `build` and `install` commands can also be set in the shader crate's `Cargo.toml`
58
73
file. In general usage that would be the recommended way to set config. See `crates/shader-crate-template/Cargo.toml`
0 commit comments