Add __i53abi and __sig decorators for emwgpu functions.
This fixes a breakage for Emscripten builds due to stricter checks in Emscripten [added recently](https://github.com/emscripten-core/emscripten/commit/d0d9966daa064eef3281495d9168a5efbef3f692).
Bug: 374691288
Change-Id: I2c8697ada7cc7374a52a9bc7f69a817dda01a454
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/211675
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Nicolas Chavez <nickchavez@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/third_party/emdawnwebgpu/library_webgpu.js b/third_party/emdawnwebgpu/library_webgpu.js
index 1e5387e..cfdf8c0 100644
--- a/third_party/emdawnwebgpu/library_webgpu.js
+++ b/third_party/emdawnwebgpu/library_webgpu.js
@@ -565,11 +565,13 @@
// library_html5_html.js)
// ----------------------------------------------------------------------------
+ emwgpuDelete__sig: 'vp',
emwgpuDelete: (ptr) => {
delete WebGPU.Internals.jsObjects[ptr];
},
emwgpuSetLabel__deps: ['$UTF8ToString'],
+ emwgpuSetLabel__sig: 'vppp',
emwgpuSetLabel: (ptr, data, length) => {
var obj = WebGPU.getJsObject(ptr);
obj.label = UTF8ToString(data, length);
@@ -578,6 +580,8 @@
#if ASYNCIFY
// Returns a FutureID that was resolved, or kNullFutureId if timed out.
emwgpuWaitAny__async: true,
+ emwgpuWaitAny__i53abi: false,
+ emwgpuWaitAny__sig: 'jppp',
emwgpuWaitAny: (futurePtr, futureCount, timeoutNSPtr) => {
var promises = WebGPU.Internals.waitAnyPromisesList;
if (timeoutNSPtr) {
@@ -608,6 +612,7 @@
},
#endif
+ emwgpuGetPreferredFormat__sig: 'i',
emwgpuGetPreferredFormat: () => {
var format = navigator["gpu"]["getPreferredCanvasFormat"]();
return WebGPU.Int_PreferredFormat[format];
@@ -697,6 +702,7 @@
emwgpuAdapterRequestDevice__i53abi: false,
emwgpuAdapterRequestDevice__deps: ['emwgpuCreateQueue', 'emwgpuOnDeviceLostCompleted', 'emwgpuOnRequestDeviceCompleted', 'emwgpuOnUncapturedError'],
+ emwgpuAdapterRequestDevice__sig: 'vpjjppp',
emwgpuAdapterRequestDevice: (
adapterPtr,
futureIdL, futureIdH,
@@ -846,6 +852,7 @@
// Methods of Buffer
// --------------------------------------------------------------------------
+ emwgpuBufferDestroy__sig: 'vp',
emwgpuBufferDestroy: (bufferPtr) => {
var buffer = WebGPU.getJsObject(bufferPtr);
var onUnmap = WebGPU.Internals.bufferOnUnmaps[bufferPtr];
@@ -862,6 +869,7 @@
// In webgpu.h offset and size are passed in as size_t.
// And library_webgpu assumes that size_t is always 32bit in emscripten.
emwgpuBufferGetConstMappedRange__deps: ['$warnOnce', 'memalign', 'free'],
+ emwgpuBufferGetConstMappedRange__sig: 'pppp',
emwgpuBufferGetConstMappedRange: (bufferPtr, offset, size) => {
var buffer = WebGPU.getJsObject(bufferPtr);
@@ -888,6 +896,7 @@
// In webgpu.h offset and size are passed in as size_t.
// And library_webgpu assumes that size_t is always 32bit in emscripten.
emwgpuBufferGetMappedRange__deps: ['$warnOnce', 'memalign', 'free'],
+ emwgpuBufferGetMappedRange__sig: 'pppp',
emwgpuBufferGetMappedRange: (bufferPtr, offset, size) => {
var buffer = WebGPU.getJsObject(bufferPtr);
@@ -930,6 +939,7 @@
// And library_webgpu assumes that size_t is always 32bit in emscripten.
emwgpuBufferMapAsync__i53abi: false,
emwgpuBufferMapAsync__deps: ['emwgpuOnMapAsyncCompleted'],
+ emwgpuBufferMapAsync__sig: 'vpjjpp',
emwgpuBufferMapAsync: (bufferPtr, futureIdL, futureIdH, mode, offset, size) => {
var buffer = WebGPU.getJsObject(bufferPtr);
WebGPU.Internals.bufferOnUnmaps[bufferPtr] = [];
@@ -953,6 +963,7 @@
}));
},
+ emwgpuBufferUnmap__sig: 'vp',
emwgpuBufferUnmap: (bufferPtr) => {
var buffer = WebGPU.getJsObject(bufferPtr);
@@ -1447,6 +1458,7 @@
return ptr;
},
+ emwgpuDeviceCreateBuffer__sig: 'vppp',
emwgpuDeviceCreateBuffer: (devicePtr, descriptor, bufferPtr) => {
{{{ gpu.makeCheckDescriptor('descriptor') }}}
@@ -1494,6 +1506,7 @@
emwgpuDeviceCreateComputePipelineAsync__i53abi: false,
emwgpuDeviceCreateComputePipelineAsync__deps: ['emwgpuCreateComputePipeline', 'emwgpuOnCreateComputePipelineCompleted'],
+ emwgpuDeviceCreateComputePipelineAsync__sig: 'vpjp',
emwgpuDeviceCreateComputePipelineAsync: (devicePtr, futureIdL, futureIdH, descriptor) => {
var desc = WebGPU.makeComputePipelineDesc(descriptor);
var device = WebGPU.getJsObject(devicePtr);
@@ -1602,6 +1615,7 @@
emwgpuDeviceCreateRenderPipelineAsync__i53abi: false,
emwgpuDeviceCreateRenderPipelineAsync__deps: ['emwgpuCreateRenderPipeline', 'emwgpuOnCreateRenderPipelineCompleted'],
+ emwgpuDeviceCreateRenderPipelineAsync__sig: 'vpjp',
emwgpuDeviceCreateRenderPipelineAsync: (devicePtr, futureIdL, futureIdH, descriptor) => {
var desc = WebGPU.makeRenderPipelineDesc(descriptor);
var device = WebGPU.getJsObject(devicePtr);
@@ -1658,6 +1672,7 @@
return ptr;
},
+ emwgpuDeviceCreateShaderModule__sig: 'vppp',
emwgpuDeviceCreateShaderModule: (devicePtr, descriptor, shaderModulePtr) => {
{{{ gpu.makeCheck('descriptor') }}}
var nextInChainPtr = {{{ makeGetValue('descriptor', C_STRUCTS.WGPUShaderModuleDescriptor.nextInChain, '*') }}};
@@ -1749,6 +1764,7 @@
emwgpuDevicePopErrorScope__i53abi: false,
emwgpuDevicePopErrorScope__deps: ['emwgpuOnPopErrorScopeCompleted'],
+ emwgpuDevicePopErrorScope__sig: 'vpj',
emwgpuDevicePopErrorScope: (devicePtr, futureIdL, futureIdH) => {
var device = WebGPU.getJsObject(devicePtr);
{{{ runtimeKeepalivePush() }}}
@@ -1850,6 +1866,7 @@
emwgpuInstanceRequestAdapter__i53abi: false,
emwgpuInstanceRequestAdapter__deps: ['emwgpuCreateAdapter', 'emwgpuOnRequestAdapterCompleted'],
+ emwgpuInstanceRequestAdapter__sig: 'vpjp',
emwgpuInstanceRequestAdapter: (instancePtr, futureIdL, futureIdH, options) => {
var opts;
if (options) {
@@ -1920,6 +1937,7 @@
emwgpuQueueOnSubmittedWorkDone__i53abi: false,
emwgpuQueueOnSubmittedWorkDone__deps: ['emwgpuOnWorkDoneCompleted'],
+ emwgpuQueueOnSubmittedWorkDone__sig: 'vpj',
emwgpuQueueOnSubmittedWorkDone: (queuePtr, futureIdL, futureIdH) => {
var queue = WebGPU.getJsObject(queuePtr);
@@ -2210,6 +2228,7 @@
emwgpuShaderModuleGetCompilationInfo__i53abi: false,
emwgpuShaderModuleGetCompilationInfo__deps: ['emwgpuOnCompilationInfoCompleted', '$stringToUTF8', '$lengthBytesUTF8', 'malloc'],
+ emwgpuShaderModuleGetCompilationInfo__sig: 'vpjp',
emwgpuShaderModuleGetCompilationInfo: (shaderModulePtr, futureIdL, futureIdH, compilationInfoPtr) => {
var shaderModule = WebGPU.getJsObject(shaderModulePtr);
{{{ runtimeKeepalivePush() }}}
@@ -2429,12 +2448,14 @@
LibraryWebGPU.$WebGPU.FeatureNameString2Enum[LibraryWebGPU.$WebGPU.FeatureName[value]] = value;
}
+// Add and set __i53abi to true for functions with 64-bit value in their
+// signatures, if not explicitly set otherwise.
for (const key of Object.keys(LibraryWebGPU)) {
- if (typeof LibraryWebGPU[key] === 'function') {
- if (!(key + '__i53abi' in LibraryWebGPU)) {
- LibraryWebGPU[key + '__i53abi'] = true;
- }
- }
+ if (typeof LibraryWebGPU[key] !== 'function') continue;
+ if (key + '__i53abi' in LibraryWebGPU) continue;
+ const sig = LibraryWebGPU[key + '__sig'];
+ if (!sig?.includes('j')) continue;
+ LibraryWebGPU[key + '__i53abi'] = true;
}
// Based on autoAddDeps, this helper iterates the object and moves the