[dawn][emscripten] Port of https://github.com/emscripten-core/emscripten/pull/22771
- Ports the fix for undefined features from the PR into the
new emdawnwebgpu implementation.
Change-Id: I1b58532a1de7d4fa52f84bc8f53680ee7867e7b8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/212334
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
diff --git a/third_party/emdawnwebgpu/library_webgpu.js b/third_party/emdawnwebgpu/library_webgpu.js
index 9e1d3fc..0958151 100644
--- a/third_party/emdawnwebgpu/library_webgpu.js
+++ b/third_party/emdawnwebgpu/library_webgpu.js
@@ -649,15 +649,20 @@
wgpuAdapterEnumerateFeatures: (adapterPtr, featuresOutPtr) => {
var adapter = WebGPU.getJsObject(adapterPtr);
- if (featuresOutPtr !== 0) {
- var offset = 0;
- adapter.features.forEach(feature => {
- var featureEnumValue = WebGPU.FeatureNameString2Enum[feature];
- {{{ makeSetValue('featuresOutPtr', 'offset', 'featureEnumValue', 'i32') }}};
- offset += 4;
- });
- }
- return adapter.features.size;
+
+ var offset = 0;
+ var numFeatures = 0;
+ adapter.features.forEach(feature => {
+ var featureEnumValue = WebGPU.FeatureNameString2Enum[feature];
+ if (featureEnumValue !== undefined) {
+ if (featuresOutPtr !== 0) {
+ {{{ makeSetValue('featuresOutPtr', 'offset', 'featureEnumValue', 'i32') }}};
+ offset += 4;
+ }
+ numFeatures++;
+ }
+ });
+ return numFeatures;
},
wgpuAdapterGetInfo__deps: ['$stringToNewUTF8', '$lengthBytesUTF8'],
@@ -1733,15 +1738,20 @@
wgpuDeviceEnumerateFeatures: (devicePtr, featuresOutPtr) => {
var device = WebGPU.getJsObject(devicePtr);
- if (featuresOutPtr !== 0) {
- var offset = 0;
- device.features.forEach(feature => {
- var featureEnumValue = WebGPU.FeatureNameString2Enum[feature];
- {{{ makeSetValue('featuresOutPtr', 'offset', 'featureEnumValue', 'i32') }}};
- offset += 4;
- });
- }
- return device.features.size;
+
+ var offset = 0;
+ var numFeatures = 0;
+ device.features.forEach(feature => {
+ var featureEnumValue = WebGPU.FeatureNameString2Enum[feature];
+ if (featureEnumValue !== undefined) {
+ if (featuresOutPtr !== 0) {
+ {{{ makeSetValue('featuresOutPtr', 'offset', 'featureEnumValue', 'i32') }}};
+ offset += 4;
+ }
+ numFeatures++;
+ }
+ });
+ return numFeatures;
},
wgpuDeviceGetLimits: (devicePtr, limitsOutPtr) => {