Skip to content

Commit dbfc594

Browse files
WebGPURenderer: Compute Shaders - Extend max workgroups capabilities (#28846)
1 parent e7fd8b9 commit dbfc594

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/renderers/webgpu/WebGPUBackend.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,30 @@ class WebGPUBackend extends Backend {
763763

764764
}
765765

766-
passEncoderGPU.dispatchWorkgroups( computeNode.dispatchCount );
766+
const maxComputeWorkgroupsPerDimension = this.device.limits.maxComputeWorkgroupsPerDimension;
767+
768+
const computeNodeData = this.get( computeNode );
769+
770+
if ( computeNodeData.dispatchSize === undefined ) computeNodeData.dispatchSize = { x: 0, y: 1, z: 1 };
771+
772+
const { dispatchSize } = computeNodeData;
773+
774+
if ( computeNode.dispatchCount > maxComputeWorkgroupsPerDimension ) {
775+
776+
dispatchSize.x = Math.min( computeNode.dispatchCount, maxComputeWorkgroupsPerDimension );
777+
dispatchSize.y = Math.ceil( computeNode.dispatchCount / maxComputeWorkgroupsPerDimension );
778+
779+
} else {
780+
781+
dispatchSize.x = computeNode.dispatchCount;
782+
783+
}
784+
785+
passEncoderGPU.dispatchWorkgroups(
786+
dispatchSize.x,
787+
dispatchSize.y,
788+
dispatchSize.z
789+
);
767790

768791
}
769792

0 commit comments

Comments
 (0)