Repository navigation
fix(j2k-metal): fall back one rejected tile group through hooks - #382
Merged
Merged
Conversation
jcwal1516
force-pushed
the
stage/17-metal-tiled-fallback
branch
from
December 2, 2026 04:14
1b49ed8 to
c837089
Compare
jcwal1516
force-pushed
the
stage/16-metal-tiled-operations
branch
from
December 2, 2026 04:14
f62efab to
ec2ad5e
Compare
jcwal1516
force-pushed
the
stage/17-metal-tiled-fallback
branch
2 times, most recently
from
December 2, 2026 19:04
dcafebe to
97a8131
Compare
jcwal1516
force-pushed
the
stage/16-metal-tiled-operations
branch
from
December 2, 2026 19:04
8a97b7f to
f885233
Compare
…rough the hooks When the Metal kernels rejected the code blocks of one group of a tiled decode (for example a block with more coding passes than its bit planes allow, from a damaged packet header), the grouped route gave up on the whole image, which then decoded through the native decoder's hooks. That route holds every component of the image on the host, so a large image failed with AllocationTooLarge (native decoder context retained components, 512 MiB cap) where the CPU decodes it: the malformed-input harness found it on 9472 x 9472 12-bit RGB images in 1024 x 1024 tiles. Decode only the rejected group's rectangle through the hooks, on the (reduced) image the groups are planned on, and copy it into the output; the other groups keep the grouped route. A caller's destination still takes only the direct route, so decode_into_metal returns MetalDirectFallback as documented. tiled_decodes_take_the_hooks_for_a_rejected_group_alone makes one group of full, region, reduced and RGBA8 requests fail as rejected through a test hook and checks the pixels and that only that group took the hooks; it failed before (the whole image took them). The ignored tiled_decode_over_the_native_limit_takes_the_hooks_for_a_rejected_group_alone decodes such an image over the native limit; it failed with AllocationTooLarge. tiled_decode_into_metal_of_a_rejected_group_is_a_direct_fallback pins the destination behaviour.
14bd0040 and the tile-group fix added two ignored correctness tests, a tiled decode whose output is over 512 MiB and one over the native decoder's working-memory limit, without listing them, so release-metal's ignored-test inventory check failed. Both are now required, so release-metal runs them.
jcwal1516
force-pushed
the
stage/16-metal-tiled-operations
branch
from
December 2, 2026 19:06
f885233 to
eac5193
Compare
jcwal1516
force-pushed
the
stage/17-metal-tiled-fallback
branch
from
December 2, 2026 19:06
97a8131 to
0c66df0
Compare
jcwal1516
marked this pull request as ready for review
December 2, 2026 23:56
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.
What and why
When one group of a tiled Metal decode is rejected by the device kernels, the
grouped route currently gives up on the whole image. The full native-hook
fallback can exceed the host decode limit even though decoding only the
rejected tile group would fit.
This layer decodes only the rejected group through the existing native hooks
and copies it into the grouped output. Other groups stay on the Metal path.
Caller-owned destination requests keep their documented strict direct-fallback
error. The release-Metal command now includes the large tiled hardware tests.
Impact
!to the title)Supported tiled surface requests can complete when one group needs the
slower hooks; caller-owned direct destinations keep returning a typed
direct-fallback error.
The fallback is limited to the rejected group rectangle instead of keeping
every component of a large image on the host.
Only rejected groups take the slower hook path.
data, source noted in a README and NOTICES.md)
Testing
cargo fmt --all -- --checkcargo check --locked -p j2k-metal --all-targets --all-featuresOn a real M5 Max, 26 focused tiled tests passed. They cover full, reduced,
region, RGBA8, destination, batch, budgets, classic/HT, and CPU parity.
The ignored 538 MB rejected-group test and 512 MiB output test both passed
separately with
J2K_REQUIRE_METAL_RUNTIME=1.Exact-head CUDA and Metal validation: pending.
Bug fix: added tests that fail without the fixes
User-visible change: added a
CHANGELOG.mdentry underUnreleased