[Web] Batch GPU-to-GPU copy commands and add tests for command batching - #20059
[Web] Batch GPU-to-GPU copy commands and add tests for command batching#20059akaashrp wants to merge 2 commits into
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
| // A compute submission is now the last queue operation, so the | ||
| // A command submission is now the last queue operation, so the | ||
| // GPU→CPU copy fast path in sync() is no longer valid. | ||
| this.pendingGPUToCPUCopy = null; |
There was a problem hiding this comment.
Nice cleanup! One catch: flushing nulls the readback promise, so sync() no longer awaits it.
| * - CPU→GPU writes (deviceCopyToGPU, copyRawBytesToBuffer) | ||
| * - GPU↔GPU copies (deviceCopyWithinGPU) | ||
| * - Buffer deallocation (deviceFreeDataSpace) | ||
| * - Queue sync (sync) |
There was a problem hiding this comment.
Minor: worth adding drawImageFromBuffer to the "Must be called before" list as well.
|
|
||
| expect(queue.submit).toHaveBeenCalledTimes(1); | ||
| expect(events).toEqual(["copy", "finish", "submit", "destroy"]); | ||
| }); |
There was a problem hiding this comment.
Would you mind adding a case interleaving deviceCopyFromGPU, deviceCopyWithinGPU, then sync()?
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| const { WebGPUContext } = require("../../src/webgpu"); |
There was a problem hiding this comment.
Curious about importing src directly - other node tests use ../../dist. Maybe note the reason?
| module.exports = { | ||
| testEnvironment: "node", | ||
|
|
||
| transform: { |
There was a problem hiding this comment.
Small note: transform replaces the default map, so .js loses babel-jest here.
Extend existing batching behavior to avoid flushing after GPU-to-GPU copies. This is valid since the WebGPU spec explicitly describes
copyBufferToBufferas a buffered operation (see https://www.w3.org/TR/webgpu/#buffer-copies). Add WebGPU device mocking and tests covering flushing and ordering behavior in the context of WebGPU command batching.The WebGPU unit test imports
web/src/webgpu.tsdirectly becauseWebGPUContextis not exported from the public package entry point. The test-specific TypeScript transformer is only used to load that internal source for this white-box test.