Skip to content

Commit

Permalink
[Fix] WebGPU can give us async mapped buffer after the device was des…
Browse files Browse the repository at this point in the history
…troyed, handle it (#5731)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Oct 9, 2023
1 parent 811bdad commit 08cdeec
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/platform/graphics/webgpu/webgpu-dynamic-buffers.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ class WebgpuDynamicBuffers extends DynamicBuffers {
for (let i = 0; i < count; i++) {
const stagingBuffer = this.pendingStagingBuffers[i];
stagingBuffer.buffer.mapAsync(GPUMapMode.WRITE).then(() => {
stagingBuffer.onAvailable();
this.stagingBuffers.push(stagingBuffer);
// the buffer can be mapped after the device has been destroyed, so test for that
if (this.stagingBuffers) {
stagingBuffer.onAvailable();
this.stagingBuffers.push(stagingBuffer);
}
});
}
this.pendingStagingBuffers.length = 0;
Expand Down

0 comments on commit 08cdeec

Please sign in to comment.