Skip to content

Commit c512b60

Browse files
committed
Update README
1 parent eeaf4aa commit c512b60

1 file changed

Lines changed: 57 additions & 21 deletions

File tree

README.md

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,53 @@ Example `build.zig`:
2020
pub fn build(b: *std.Build) void {
2121
const exe = b.addExecutable(.{ ... });
2222
23-
@import("zgpu").addLibraryPathsTo(exe);
24-
2523
const zgpu = b.dependency("zgpu", .{});
2624
exe.root_module.addImport("zgpu", zgpu.module("root"));
2725
28-
if (target.result.os.tag != .emscripten) {
29-
exe.linkLibrary(zgpu.artifact("zdawn"));
30-
}
26+
// Adds platform-specific library search paths and links the
27+
// prebuilt dawn library to the executable.
28+
@import("zgpu").addLibraryPathsTo(exe);
29+
30+
// Link the zdawn C/C++ wrapper artifact.
31+
exe.linkLibrary(zgpu.artifact("zdawn"));
3132
}
3233
```
3334

35+
## Fetching prebuilt Dawn libraries
36+
37+
zgpu uses prebuilt Dawn binaries as lazy dependencies. You need to fetch the one matching your target platform:
38+
39+
**Windows (x86_64):**
40+
```sh
41+
zig fetch --save=dawn_x86_64_windows_gnu https://github.com/michal-z/webgpu_dawn-x86_64-windows-gnu/archive/d3a68014e6b6b53fd330a0ccba99e4dcfffddae5.tar.gz
42+
```
43+
44+
**Linux (x86_64):**
45+
```sh
46+
zig fetch --save=dawn_x86_64_linux_gnu https://github.com/michal-z/webgpu_dawn-x86_64-linux-gnu/archive/7d70db023bf254546024629cbec5ee6113e12a42.tar.gz
47+
```
48+
49+
**Linux (aarch64):**
50+
```sh
51+
zig fetch --save=dawn_aarch64_linux_gnu https://github.com/michal-z/webgpu_dawn-aarch64-linux-gnu/archive/c1f55e740a62f6942ff046e709ecd509a005dbeb.tar.gz
52+
```
53+
54+
**macOS (aarch64 / Apple Silicon):**
55+
```sh
56+
zig fetch --save=dawn_aarch64_macos https://github.com/michal-z/webgpu_dawn-aarch64-macos/archive/d2360cdfff0cf4a780cb77aa47c57aca03cc6dfe.tar.gz
57+
```
58+
59+
**macOS (x86_64):**
60+
```sh
61+
zig fetch --save=dawn_x86_64_macos https://github.com/michal-z/webgpu_dawn-x86_64-macos/archive/901716b10b31ce3e0d3fe479326b41e91d59c661.tar.gz
62+
```
63+
64+
You also need the system SDK dependency:
65+
66+
```sh
67+
zig fetch --save=system_sdk https://github.com/zig-gamedev/system_sdk/archive/c0dbf11cdc17da5904ea8a17eadc54dee26567ec.tar.gz
68+
```
69+
3470
## Sample applications
3571

3672
- [gui test (wgpu)](https://github.com/zig-gamedev/zig-gamedev/tree/main/samples/gui_test_wgpu)
@@ -46,29 +82,29 @@ Below you can find an overview of main `zgpu` features.
4682

4783
### Compile-time options
4884

49-
You can override default options in your `build.zig`:
85+
You can override default options by passing them to `b.dependency`:
5086

5187
```zig
5288
pub fn build(b: *std.Build) void {
5389
...
5490
55-
const zgpu = @import("zgpu").package(b, target, optimize, .{
56-
.options = .{
57-
.uniforms_buffer_size = 4 * 1024 * 1024,
58-
.dawn_skip_validation = false,
59-
.buffer_pool_size = 256,
60-
.texture_pool_size = 256,
61-
.texture_view_pool_size = 256,
62-
.sampler_pool_size = 16,
63-
.render_pipeline_pool_size = 128,
64-
.compute_pipeline_pool_size = 128,
65-
.bind_group_pool_size = 32,
66-
.bind_group_layout_pool_size = 32,
67-
.pipeline_layout_pool_size = 32,
68-
},
91+
const zgpu = b.dependency("zgpu", .{
92+
.uniforms_buffer_size = 4 * 1024 * 1024,
93+
.dawn_skip_validation = false,
94+
.buffer_pool_size = 256,
95+
.texture_pool_size = 256,
96+
.texture_view_pool_size = 256,
97+
.sampler_pool_size = 16,
98+
.render_pipeline_pool_size = 128,
99+
.compute_pipeline_pool_size = 128,
100+
.bind_group_pool_size = 32,
101+
.bind_group_layout_pool_size = 32,
102+
.pipeline_layout_pool_size = 32,
69103
});
70104
71-
zgpu.link(exe);
105+
exe.root_module.addImport("zgpu", zgpu.module("root"));
106+
@import("zgpu").addLibraryPathsTo(exe);
107+
exe.linkLibrary(zgpu.artifact("zdawn"));
72108
73109
...
74110
}

0 commit comments

Comments
 (0)