Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] WebGPU can give us async mapped buffer after the device was destroyed, handle it #5731

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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