Skip to content

Commit ca2f49e

Browse files
TheBlekKuklin Georgiy
andauthored
WebGPURenderer: Fix types for indirect compute and modify example to show usage (#32129)
* Fix type annotations, handle IndirectStorageBufferAttribute in webgl fallback renderer. * Modify webgpu_compute_particles example to utilize indirect compute dispatch * Respect dispatchSize when backend is not initialized * Revert "Modify webgpu_compute_particles example to utilize indirect compute dispatch" This reverts commit ca125d8. * Update puppeteer.js --------- Co-authored-by: Kuklin Georgiy <theblekbern@gmail.com>
1 parent 1dcf175 commit ca2f49e

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/renderers/common/Renderer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,10 +2420,10 @@ class Renderer {
24202420
* if the renderer has been initialized.
24212421
*
24222422
* @param {Node|Array<Node>} computeNodes - The compute node(s).
2423-
* @param {number|Array<number>|GPUBuffer} [dispatchSize=null]
2423+
* @param {number|Array<number>|IndirectStorageBufferAttribute} [dispatchSize=null]
24242424
* - A single number representing count, or
24252425
* - An array [x, y, z] representing dispatch size, or
2426-
* - A GPUBuffer for indirect dispatch size.
2426+
* - A IndirectStorageBufferAttribute for indirect dispatch size.
24272427
* @return {Promise|undefined} A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
24282428
*/
24292429
compute( computeNodes, dispatchSize = null ) {
@@ -2434,7 +2434,7 @@ class Renderer {
24342434

24352435
warn( 'Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead.' );
24362436

2437-
return this.computeAsync( computeNodes );
2437+
return this.computeAsync( computeNodes, dispatchSize );
24382438

24392439
}
24402440

@@ -2532,10 +2532,10 @@ class Renderer {
25322532
*
25332533
* @async
25342534
* @param {Node|Array<Node>} computeNodes - The compute node(s).
2535-
* @param {number|Array<number>|GPUBuffer} [dispatchSize=null]
2535+
* @param {number|Array<number>|IndirectStorageBufferAttribute} [dispatchSize=null]
25362536
* - A single number representing count, or
25372537
* - An array [x, y, z] representing dispatch size, or
2538-
* - A GPUBuffer for indirect dispatch size.
2538+
* - A IndirectStorageBufferAttribute for indirect dispatch size.
25392539
* @return {Promise} A Promise that resolve when the compute has finished.
25402540
*/
25412541
async computeAsync( computeNodes, dispatchSize = null ) {

src/renderers/webgl-fallback/WebGLBackend.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,12 @@ class WebGLBackend extends Backend {
852852

853853
count = count[ 0 ];
854854

855+
} else if ( count && typeof count === 'object' && count.isIndirectStorageBufferAttribute ) {
856+
857+
warnOnce( 'WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute' );
858+
859+
count = computeNode.count;
860+
855861
}
856862

857863
if ( attributes[ 0 ].isStorageInstancedBufferAttribute ) {

src/renderers/webgpu/WebGPUBackend.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,10 +1343,10 @@ class WebGPUBackend extends Backend {
13431343
* @param {Node} computeNode - The compute node.
13441344
* @param {Array<BindGroup>} bindings - The bindings.
13451345
* @param {ComputePipeline} pipeline - The compute pipeline.
1346-
* @param {number|Array<number>|GPUBuffer} [dispatchSize=null]
1346+
* @param {number|Array<number>|IndirectStorageBufferAttribute} [dispatchSize=null]
13471347
* - A single number representing count, or
13481348
* - An array [x, y, z] representing dispatch size, or
1349-
* - A GPUBuffer for indirect dispatch size.
1349+
* - A IndirectStorageBufferAttribute for indirect dispatch size.
13501350
*/
13511351
compute( computeGroup, computeNode, bindings, pipeline, dispatchSize = null ) {
13521352

test/e2e/puppeteer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const exceptionList = [
2222
'webgpu_postprocessing_traa',
2323
'webgpu_reflection',
2424
'webgpu_texturegrad',
25+
'webgpu_tsl_vfx_flames',
2526

2627
// Need more time
2728
'css3d_mixed',

0 commit comments

Comments
 (0)