Skip to content

Defer WebGPU buffer destruction until submit#8652

Merged
mvaligursky merged 1 commit intoplaycanvas:mainfrom
slimbuck:webgpu-dev
Apr 27, 2026
Merged

Defer WebGPU buffer destruction until submit#8652
mvaligursky merged 1 commit intoplaycanvas:mainfrom
slimbuck:webgpu-dev

Conversation

@slimbuck
Copy link
Copy Markdown
Member

Summary

  • Defers GPUBuffer.destroy() in WebgpuBuffer.destroy() until pending command buffers have been submitted.
  • Matches the existing deferred-destroy behavior used for WebGPU textures.

Details

A GPUBuffer can still be referenced by recorded command buffers through bind groups even after the engine-side buffer wrapper is destroyed. Destroying the underlying WebGPU buffer immediately can invalidate a later queue.submit() with validation errors such as “buffer used in submit while destroyed”.

This change routes buffer destruction through device.deferDestroy(...), so the underlying GPUBuffer is destroyed only after pending command buffers are submitted.

Test Plan

  • Verified WebGPU picking no longer reports “Buffer used in submit while destroyed” during gsplat interaction.
  • Existing WebGPU texture destruction already follows this deferred lifetime pattern.

@slimbuck slimbuck requested review from a team and Copilot April 25, 2026 16:22
@slimbuck slimbuck self-assigned this Apr 25, 2026
@slimbuck slimbuck added the area: graphics Graphics related issue label Apr 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Defers destruction of underlying WebGPU buffers so they aren’t destroyed while still referenced by already-recorded command buffers (e.g., via bind groups), matching the existing deferred-destroy pattern used for WebGPU textures.

Changes:

  • Route WebgpuBuffer.destroy() through device.deferDestroy(...) instead of calling GPUBuffer.destroy() immediately.
  • Add clarifying inline comments explaining why destruction must be deferred.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mvaligursky mvaligursky merged commit 2d9ddb5 into playcanvas:main Apr 27, 2026
10 of 12 checks passed
mvaligursky pushed a commit that referenced this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants