Skip to content

Commit c3d405b

Browse files
committed
Use 32-bit element size for making heap view of requiredFeatures
- This commit fixes adapter.requestDevice for wasm64 by using the correct factor to calculate the end of the view in HEAPU32 from requiredFeaturesPtr. Earlier, the returned array was twice the actual size.
1 parent 6e2417b commit c3d405b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/library_webgpu.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2645,7 +2645,8 @@ var LibraryWebGPU = {
26452645
var requiredFeatureCount = {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUDeviceDescriptor.requiredFeatureCount) }}};
26462646
if (requiredFeatureCount) {
26472647
var requiredFeaturesPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUDeviceDescriptor.requiredFeatures, '*') }}};
2648-
desc["requiredFeatures"] = Array.from({{{ makeHEAPView('32', 'requiredFeaturesPtr', `requiredFeaturesPtr + requiredFeatureCount * ${POINTER_SIZE}`) }}},
2648+
// requiredFeaturesPtr is a pointer to an array of FeatureName which is an enum of size uint32_t
2649+
desc["requiredFeatures"] = Array.from({{{ makeHEAPView('U32', 'requiredFeaturesPtr', `requiredFeaturesPtr + requiredFeatureCount * 4`) }}},
26492650
(feature) => WebGPU.FeatureName[feature]);
26502651
}
26512652
var requiredLimitsPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUDeviceDescriptor.requiredLimits, '*') }}};

0 commit comments

Comments
 (0)