fix: respect source.origin in copyExternalImageToTexture - #435
Open
Josema wants to merge 1 commit into
Open
Conversation
Owner
|
@Josema I see it marked as draft, let me know once it is ready for review 👍 |
Josema
marked this pull request as ready for review
July 27, 2026 10:39
Author
|
Ready. Again, this is a fix from Codex that works for me. Feel free to close the PR if you don't think the fix is good enough. |
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
The source descriptor already parsed and stored
origin, butcopyExternalImageToTexture()always uploaded pixels starting at the beginning of theImageBitmapbacking store.For example, given this 2×2 image:
Copying the right column:
should upload:
Instead, it uploaded:
This is especially visible when using texture atlases. Copies intended to generate padding from the last row or column could read pixels from the beginning of the image, producing a solid line along the right or bottom edge.
The existing
flipYpath had a related issue: it flipped the complete bitmap before applying the copy extent. For a subregion, WebGPU expects only the selected region to be flipped.Solution
The fix is intentionally limited to the existing
copyExternalImageToTexture()implementation:source.origin, defaulting to[0, 0].origin + copySizefits inside the source bitmap.flipYor alphaconversion is required.
flipYis enabled.The existing direct upload path remains unchanged for zero-origin copies that
do not require
flipYor alpha conversion.Validation
The regression suite covers:
source.origincombined with alpha conversion.source.origincombined withflipY.Verified with:
yarn workspace react-native-webgpu test:ref \ --runTestsByPath src/__tests__/ImageBitmapOrigin.spec.ts yarn workspace react-native-webgpu test:node \ --runTestsByPath src/__tests__/ImageBitmapOrigin.spec.ts yarn workspace react-native-webgpu test \ --runTestsByPath src/__tests__/ImageBitmapOrigin.spec.tsResults:
dawn.node: 7/7 passing.