Skip to content

Commit d10e108

Browse files
authored
docs: Modernize README.md
Updated the description of TypeGPU and added usage examples.
1 parent e0f26ee commit d10e108

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,40 @@
88

99
</div>
1010

11-
**TypeGPU** is a TypeScript library that enhances the WebGPU API, allowing
12-
resource management in a type-safe, declarative way.
11+
**TypeGPU** is a modular and open-ended toolkit for WebGPU, with advanced type inference and the ability to write shaders in TypeScript.
12+
13+
```ts
14+
const neighborhood = (a: number, r: number) => {
15+
'use gpu';
16+
return d.vec2f(a - r, a + r);
17+
};
18+
19+
//
20+
// #1) Can be called in JS
21+
//
22+
const range = neighborhood(1.1, 0.5);
23+
// ^? d.v2f
24+
25+
//
26+
// #2) Used to generate WGSL
27+
//
28+
const main = () => {
29+
'use gpu';
30+
return neighborhood(1.1, 0.5);
31+
};
32+
33+
const wgsl = tgpu.resolve({ externals: { main } });
34+
// ^? string
35+
36+
//
37+
// #3) Executed on the GPU (generates WGSL underneath)
38+
//
39+
root['~unstable']
40+
.createGuardedComputePipeline(main)
41+
.dispatchThreads();
42+
```
1343

1444
<div align="center">
15-
<video width="512" autoplay muted loop playsinline src="https://github.com/user-attachments/assets/5bca716d-477d-44a1-a839-5df0c8d9044c"></video>
1645

1746
<!-- automd:badges color="plum" license name="typegpu" bundlephobia no-npmDownloads -->
1847

0 commit comments

Comments
 (0)