diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2025-03-03 22:15:14 +0100 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2025-03-03 22:15:35 +0100 |
| commit | 52dd651aeda9a595b2b5b0b327d8312894cbe5c6 (patch) | |
| tree | 71563378abd65197c2e8b27a3ffa27cb7e3a8bf4 /vendor/wgpu | |
| parent | 19d176c2c78a3723741163e033a31b7dcc09d73d (diff) | |
wgpu: device lost callback device by pointer in JS
Diffstat (limited to 'vendor/wgpu')
| -rw-r--r-- | vendor/wgpu/wgpu.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/vendor/wgpu/wgpu.js b/vendor/wgpu/wgpu.js index 4816659f9..055f7abab 100644 --- a/vendor/wgpu/wgpu.js +++ b/vendor/wgpu/wgpu.js @@ -1217,17 +1217,22 @@ class WebGPUInterface { .then((device) => { const deviceIdx = this.devices.create(device); - const deviceLostCallbackInfo = off(this.sizes.CallbackInfo); - if (descriptorPtr !== 0 && deviceLostCallbackInfo !== null) { + if (deviceLostCallbackInfo.callback !== null) { device.lost.then((info) => { const reason = ENUMS.DeviceLostReason.indexOf(info.reason); + + const devicePtr = this.mem.exports.wgpu_alloc(4); + this.mem.storeI32(devicePtr, deviceIdx); + const messageAddr = this.makeMessageArg(info.message); - this.callCallback(deviceLostCallbackInfo, [deviceIdx, reason, messageAddr]); + this.callCallback(deviceLostCallbackInfo, [devicePtr, reason, messageAddr]); + + this.mem.exports.wgpu_free(devicePtr); this.mem.exports.wgpu_free(messageAddr); }); } - if (descriptorPtr !== 0 && uncapturedErrorCallbackInfo !== null) { + if (uncapturedErrorCallbackInfo.callback !== null) { device.onuncapturederror = (ev) => { let status; if (ev.error instanceof GPUValidationError) { |