Repository navigation
fix(texture): keep coordinate UVs out of atlas regions - #1734
Open
snowyukitty wants to merge 3 commits into
Open
snowyukitty wants to merge 3 commits into
snowyukitty wants to merge 3 commits into
Conversation
Member
|
Hi @snowyukitty, thanks for this one as well ! This is bit more tricky, so I'll keep it for the next 20.10 release as it needs proper testing and non regression test. |
Merged
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.
Current upstream integration at
6c5b8ee1c7af1d593becd3eed109f5536f93f2ffMerged current
masterthrough the 20.9.0 release to resolve the changelog conflict. All released changelog text is preserved verbatim; the pending atlas entry is under the unreleased 20.10 section. The UV implementation and regression tests are unchanged, and testing/release decisions remain with the maintainer.Fresh contained validation on Linux:
pnpm lint,pnpm build, andpnpm test --runpass. The main browser suite reports 8039 passed and 11 skipped across 329 test files, including all 81 texture/atlas cases. The same focused suite with this PR's tests on current unmodified upstream gives 10 failures and 71 passes.Original validation at
cdcbecb2d1f6925b189ff9c70d81acb46dce8941pnpm 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 test --runpasses on the integrated source; original adapter results and CPU benchmark remain separately anchored abovepnpm buildsucceedsRelated issues
Refs #1281. This addresses the remaining atlas lookup work on the current renderer, whose batchers already consume UVs directly.
The adapter-suite results and CPU microbenchmark above remain anchored to the original head named above; they were not rerun for this changelog-only conflict resolution. The current main-suite results are reported separately. Windows/macOS runtime and WebGPU pixel tests were not run locally.