File tree Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Expand file tree Collapse file tree 1 file changed +32
-6
lines changed Original file line number Diff line number Diff line change 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.
13-
14- <div align =" center " >
15- <video autoplay muted loop playsinline src =" https://github.com/user-attachments/assets/5bca716d-477d-44a1-a839-5df0c8d9044c " ></video >
16- </div >
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+ ```
1743
1844## Documentation
1945
You can’t perform that action at this time.
0 commit comments