Repository navigation
fix(texture): keep coordinate UVs out of atlas regions - #1734
Open
snowyukitty wants to merge 1 commit into
Open
snowyukitty wants to merge 1 commit into
snowyukitty wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Description
Numeric source-rectangle lookups currently create named regions, while
addUVs()adds coordinate aliases for every frame. Cropped images and repeating patterns therefore change the same dictionary that animation consumers enumerate. Identical rectangles on different atlas pages can also reuse the previous page's UVs.This separates numeric UV caching from named regions. Parsed frames seed the private numeric cache with their existing UV arrays; arbitrary rectangles are cached without registering frames. The last-lookup cache checks the active atlas dictionary and is invalidated when
addUVs()replaces a rectangle. Both GPU pattern consumers now use numeric lookups. The batchers already receive UV values, so their interfaces stay the same.Compatibility:
getUVs(name)now throws a descriptive error for an unknown name. UsegetUVs(x, y, width, height)instead of a coordinate string, or explicitly define a named region withaddRegion(). Explicitly authored names containing commas still work.13 new browser regressions cover dictionary purity, frame UV reuse, alternating crops, missing names, named-coordinate collisions, atlas page changes, replacement, intrinsic video dimensions, packed rotated/trimmed frames, and both GPU pattern consumers. Real WebGL pixel checks cover cropped images and repeating patterns; WebGPU's changed consumer is exercised with the real atlas and a recording batcher, rather than a WebGPU pixel test.
Validation
pnpm lintpnpm buildpnpm test— 7933 passed, 11 skippedpnpm -F @melonjs/matter-adapter test— 226 passedpnpm -F @melonjs/planck-adapter test— 221 passedpnpm -F @melonjs/debug-plugin test— 23 passedA Chromium CPU microbenchmark interleaved the original and changed
TextureAtlas.getUVs()implementations for 20 rounds of 1,000,000 lookups per workload after warm-up, alternating run order and checking equal UV checksums. Median milliseconds per round:The same-frame path pays a few extra nanoseconds per lookup for the atlas check; alternating rectangles avoid string keys and region searches. These are lookup timings on one Chromium/Linux container, not an FPS measurement. Cache retention remains unchanged in principle: previously encountered rectangles stay cached for the atlas lifetime.
Type of change
Checklist
pnpm lintpassespnpm testpassespnpm buildsucceedsRelated issues
Refs #1281. This addresses the remaining atlas lookup work on the current renderer, whose batchers already consume UVs directly.