Skip to content

Commit cfe586a

Browse files
committed
readme: final goal readme
1 parent 851bdb8 commit cfe586a

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

README.md

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,54 @@
11
# cargo-gpu
22

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.
44

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
68

7-
### Installation
9+
## 1. CLI Quickstart
810

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:
1012

1113
```
1214
cargo install --git https://github.com/rust-gpu/cargo-gpu cargo-gpu
1315
```
1416

15-
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:
1618

1719
```
1820
cargo gpu build
21+
cargo gpu check
22+
cargo gpu clippy
1923
```
2024

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
2326

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+
```
2534

26-
### Next Steps
35+
This plain invocation will compile the crate in the current directory and place the compiled shaders in the current directory.
2736

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 :)
3138

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()?;
3249
```
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.
3752

3853
## How it works
3954

@@ -52,7 +67,7 @@ the usage instructions the backend and nightly Rust version are referred to as "
5267
> 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
5368
> this is to either exclude the shader from the workspace, or upgrade the shader's `spirv-std` dependency to the latest.
5469
55-
## Usage
70+
## CLI Usage
5671

5772
All the following arguments for the `build` and `install` commands can also be set in the shader crate's `Cargo.toml`
5873
file. In general usage that would be the recommended way to set config. See `crates/shader-crate-template/Cargo.toml`

0 commit comments

Comments
 (0)