From c86cf0eb97d5da217662d218df488d56929ff967 Mon Sep 17 00:00:00 2001 From: Laurin Agostini Date: Tue, 5 May 2020 18:19:52 +0200 Subject: [PATCH] Fixed review #2 issues --- src/library_webgpu.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/library_webgpu.js b/src/library_webgpu.js index 6b0cf41400122..c24ba296b2b8b 100644 --- a/src/library_webgpu.js +++ b/src/library_webgpu.js @@ -69,9 +69,9 @@ // there is no nextInChain pointer but a ChainedStruct object named chain. // So we need to check if chain.nextInChain is null. As long as nextInChain and chain are both the // first member in the struct, descriptor.nextInChain and descriptor.chain.nextInChain should have the same offset (0) - // to the descriptor pointer and we can check it as a general u32 value. Don't know of a better solution at the moment. + // to the descriptor pointer and we can check it to be null. var OffsetOfNextInChainMember = 0; - return this.makeCheck(descriptor) + this.makeCheck(this.makeGetU32(descriptor, OffsetOfNextInChainMember) + ' === 0'); + return this.makeCheck(descriptor) + this.makeCheck(makeGetValue(descriptor, OffsetOfNextInChainMember, '*') + ' === 0'); }, // Must be in sync with webgpu.h. @@ -509,11 +509,19 @@ var LibraryWebGPU = { // wgpuDevice wgpuDeviceGetDefaultQueue: function(deviceId) { - if(WebGPU.mgrQueue.objects.length === 1) { + var queueId = WebGPU.defaultQueues[deviceId]; +#if ASSERTIONS + assert(queueId != 0, 'got invalid queue'); +#endif + if(queueId === undefined) { var device = WebGPU["mgrDevice"].get(deviceId); WebGPU.defaultQueues[deviceId] = WebGPU.mgrQueue.create(device["defaultQueue"]); + queueId = WebGPU.defaultQueues[deviceId]; + } + else { + WebGPU.mgrQueue.reference(queueId); } - return WebGPU.defaultQueues[deviceId]; + return queueId; }, // wgpuDeviceCreate*