[Web] Batch GPU-to-GPU copies, fix WebGPU synchronization, and add tests for command batching - #20059
Merged
Merged
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
guan404ming
reviewed
Jul 28, 2026
Keep pending readbacks separate from queue-tail tracking so sync waits for both host readback completion and later queue work when needed. Flush pending commands before canvas draws and extend the WebGPU command-batching tests.
Contributor
Author
|
Thanks @guan404ming, should be addressed now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch GPU-to-GPU buffer copies with pending compute dispatches in the same
GPUCommandEncoderinstead of finishing and submitting after every copy. SincecopyBufferToBufferrecords an encoder command, dependencies remain ordered while copies can be submitted at the next required synchronization boundary (see https://www.w3.org/TR/webgpu/#buffer-copies).Preserve pending GPU-to-CPU readbacks separately from their queue-tail status so
sync()waits for both host readback completion and any later queue work when necessary. Also flush pending commands before canvas drawing to prevent rendering stale buffer contents.Add WebGPU device mocks and tests covering:
deviceCopyFromGPUfollowed by a batched GPU copy andsync()Regarding importing from
../../src/webgpuinstead of../../dist:WebGPUContextis not re-exported fromindex.ts, so it is unavailable through the built package like for the other tests. Exporting it solely for this test would unnecessarily expand the public API. Importing../../src/webgpuis a relatively simple alternative.