Repository navigation
fix(webgpu): wait on each 2D canvas copy's own Metal event - #292
Merged
Merged
Conversation
copyExternalImageToTexture from a Metal 2D canvas signalled one shared MTLEvent with a global counter, from each canvas's own command queue. Queues finish in any order, so a later canvas's signal could satisfy the wait for an earlier copy and wgpu sampled the intermediate texture before it was written (magenta / blank PixiJS text on iOS). Each copy now gets its own event, kept alive until wgpu's submission completes. Android (per-copy SYNC_FD) and Linux (per-frame fd) already sync per copy. Specs: a slow canvas copied before a quick one, and many resized text canvases compared against getImageData.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
Problem
GPUQueue.copyExternalImageToTexturewith a Metal-backed 2D canvas sometimes produced a texture that was never written (magenta on the iOS simulator, blank elsewhere). PixiJS's WebGPU text rendering hits this because it uploads every Text's canvas this way.Every copy signalled one shared
MTLEventwith a global counter, and each canvas signals it from its own command queue. Those queues can finish in any order. A later canvas could signal value N+1 first, which satisfied wgpu's wait for copy N, so the blit sampled copy N's intermediate texture before it was written.Fix
MTLEvent, and wgpu's queue waits on exactly that event.Android (a SYNC_FD semaphore per copy) and Linux (an fd per frame) already sync each copy separately, so they don't have this problem.
Specs (
canvassource.webgpu)got [255, 0, 255, 255]) and passes with it.getImageData.