File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2388,7 +2388,7 @@ function renderer3D(p5, fn) {
23882388 ) ;
23892389 return ;
23902390 }
2391- return this . baseComputeShader ( ) . modify ( cb , context , { hook : 'iteration ' } ) ;
2391+ return this . baseComputeShader ( ) . modify ( cb , context , { hook : 'computeIteration ' } ) ;
23922392 } ;
23932393
23942394 /**
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ function rendererWebGPU(p5, fn) {
181181 * Copies data from the GPU to the CPU using a temporary buffer,
182182 * so it must be awaited. Returns a `Float32Array` for number
183183 * buffers, or an array of plain objects for struct buffers.
184- *
184+ *
185185 * Note: This is a GPU -> CPU read, so calling it often (like every frame)
186186 * can be slow.
187187 *
@@ -4027,7 +4027,7 @@ ${hookUniformFields}}
40274027 baseComputeShader ,
40284028 {
40294029 compute : {
4030- 'void iteration ' : '(index: vec3<i32> ) {}' ,
4030+ 'void computeIteration ' : '(inputs: ComputeInputs ) {}' ,
40314031 } ,
40324032 }
40334033 ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,14 @@ struct ComputeUniforms {
55}
66@group(0) @binding(0) var<uniform> uniforms: ComputeUniforms;
77
8+ struct ComputeInputs {
9+ index: vec3<i32>,
10+ globalID: vec3<i32>,
11+ localIndex: i32,
12+ localID: vec3<i32>,
13+ workgroupID: vec3<i32>,
14+ }
15+
816@compute @workgroup_size(8, 8, 1)
917fn main(
1018 @builtin(global_invocation_id) globalId: vec3<u32>,
@@ -19,12 +27,20 @@ fn main(
1927 return;
2028 }
2129
30+ var inputs: ComputeInputs;
31+
2232 var index = vec3<i32>(0);
2333 index.x = i32(physicalId % u32(uniforms.uTotalCount.x));
2434 let remainingY = physicalId / u32(uniforms.uTotalCount.x);
2535 index.y = i32(remainingY % u32(uniforms.uTotalCount.y));
2636 index.z = i32(remainingY / u32(uniforms.uTotalCount.y));
2737
28- HOOK_iteration(index);
38+ inputs.index = index;
39+ inputs.localID = vec3<i32>(localId);
40+ inputs.workgroupID = vec3<i32>(workgroupId);
41+ inputs.localIndex = i32(localIndex);
42+ inputs.globalID = vec3<i32>(globalId);
43+
44+ HOOK_computeIteration(inputs);
2945}
3046` ;
You can’t perform that action at this time.
0 commit comments