-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed as not planned
Labels
Description
The current setBindGroup shims in library_webgpu.js create an adhoc JS array object when called with dynamicOffsetCount > 0:
wgpuRenderPassEncoderSetBindGroup: (passId, groupIndex, groupId, dynamicOffsetCount, dynamicOffsetsPtr) => {
var pass = WebGPU.mgrRenderPassEncoder.get(passId);
var group = WebGPU.mgrBindGroup.get(groupId);
if (dynamicOffsetCount == 0) {
pass["setBindGroup"](groupIndex, group);
} else {
var offsets = [];
for (var i = 0; i < dynamicOffsetCount; i++, dynamicOffsetsPtr += 4) {
offsets.push({{{ gpu.makeGetU32('dynamicOffsetsPtr', 0) }}});
}
pass["setBindGroup"](groupIndex, group, offsets);
}
},By using a different setBindGroup overload, this can be simplified to:
wgpuRenderPassEncoderSetBindGroup: (passId, groupIndex, groupId, dynamicOffsetCount, dynamicOffsetsPtr) => {
var pass = WebGPU.mgrRenderPassEncoder.get(passId);
var group = WebGPU.mgrBindGroup.get(groupId);
if (dynamicOffsetCount == 0) {
pass["setBindGroup"](groupIndex, group);
} else {
pass["setBindGroup"](groupIndex, group, HEAPU32, dynamicOffsetsPtr>>2, dynamicOffsetCount);
}
},Tested on an M1 Mac on Chrome - I'm actually not sure if the previous code is just a leftover before this separate overload function existed, or whether this is because of compatibility with non-Chrome browsers - maybe their WebGPU implementation hasn't caught up yet).
Also, the same fix should be applied to the other setBindGroup variants:
- wgpuRenderBundleEncoderSetBindGroup
- wgpuComputePassEncoderSetBindGroup
(cc: @kainino0x)