mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
wgpu: device lost callback device by pointer in JS
This commit is contained in:
Vendored
+9
-4
@@ -1217,17 +1217,22 @@ class WebGPUInterface {
|
|||||||
.then((device) => {
|
.then((device) => {
|
||||||
const deviceIdx = this.devices.create(device);
|
const deviceIdx = this.devices.create(device);
|
||||||
|
|
||||||
const deviceLostCallbackInfo = off(this.sizes.CallbackInfo);
|
if (deviceLostCallbackInfo.callback !== null) {
|
||||||
if (descriptorPtr !== 0 && deviceLostCallbackInfo !== null) {
|
|
||||||
device.lost.then((info) => {
|
device.lost.then((info) => {
|
||||||
const reason = ENUMS.DeviceLostReason.indexOf(info.reason);
|
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);
|
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);
|
this.mem.exports.wgpu_free(messageAddr);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (descriptorPtr !== 0 && uncapturedErrorCallbackInfo !== null) {
|
if (uncapturedErrorCallbackInfo.callback !== null) {
|
||||||
device.onuncapturederror = (ev) => {
|
device.onuncapturederror = (ev) => {
|
||||||
let status;
|
let status;
|
||||||
if (ev.error instanceof GPUValidationError) {
|
if (ev.error instanceof GPUValidationError) {
|
||||||
|
|||||||
Reference in New Issue
Block a user