File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
apps/typegpu-docs/src/content/docs/fundamentals/functions Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,27 @@ const mainCompute = tgpu['~unstable'].computeFn({
171
171
} ` .$uses ({ particleData: particleDataStorage , deltaTime , time });
172
172
```
173
173
174
+ Resolved WGSL for the compute function above is equivalent (with respect to some cleanup) to the following:
175
+
176
+ ``` wgsl
177
+ @group(0) @binding(0) var<storage, read_write> particleData: array<u32, 100>;
178
+ @group(0) @binding(1) var<uniform> deltaTime: f32;
179
+ @group(0) @binding(2) var<storage, read_write> time: f32;
180
+
181
+ struct mainCompute_Input {
182
+ @builtin(global_invocation_id) gid: vec3u,
183
+ }
184
+
185
+ @compute @workgroup_size(1) fn mainCompute(in: mainCompute_Input) {
186
+ let index = in.gid.x;
187
+ if index == 0 {
188
+ time += deltaTime;
189
+ }
190
+ let phase = (time / 300) + particleData[index].seed;
191
+ particleData[index].position += particleData[index].velocity * deltaTime / 20 + vec2f(sin(phase) / 600, cos(phase) / 500);
192
+ }
193
+ ```
194
+
174
195
### Vertex and fragment
175
196
176
197
` TgpuVertexFn ` accepts an object with two properties:
You can’t perform that action at this time.
0 commit comments