Skip to content

patches: fix CPU BC texture uploads and views - #888

Merged
thehobbit85 merged 1 commit into
LNPANDY:mainfrom
class-undefined:fix/a15-decoded-bc-uploads-views
Nov 7, 2026
Merged

thehobbit85 merged 1 commit into
LNPANDY:mainfrom
class-undefined:fix/a15-decoded-bc-uploads-views

Conversation

@class-undefined

Copy link
Copy Markdown
Contributor

Fix or feature

  • Fix
  • Feature

What and why

Addresses #732. With the existing CPU BC compatibility option enabled on an A15, the texture descriptor allocates unpacked pixels but the GPU upload paths still copy compressed blocks. Wonder's character-selection screen becomes striped/noisy. Registered views can then request BC formats on R8/RG8/RGBA8 backing textures and abort in Metal validation.

This patch keeps CPU-decoded BC textures on the existing decode/upload path and resolves sampled, render-target and clear views to the corresponding decoded Metal formats. It preserves format-specific channel mapping, the compatibility opt-in and the native BC path.

This overlaps the upload/view portion of #446 as a small, independently tested fix on the current main pin. Raw compressed-block views, GPU BC block encoding, decoded-to-compressed readback and broader copy-path changes remain outside this PR.

Upstream status is fork-only (declined seedds/nxnative#488), following the maintainer's explicit acceptance of that exception. This repairs the fork's existing decoder rather than submitting the declined feature upstream again.

Checked

  • Patch queue: python3 tools/engine.py check passes, 56 patches apply to upstream b2d46b86d03f.
  • New regression: make -C dm/gfx/tests GAME=010015100B514000 check_t_bc_cpu, 349 checks, 0 failures, Metal API validation enabled on an Apple M4. The test includes the production implementation and forces its CPU BC path without adding production test hooks or using game assets. It checks pooled uploads/reuploads, partial blocks, three mips, two array layers, both direct-upload settings, all 16 BC format views, attachments and clears.
  • Red before green: without the fix, t_bc_cpu uploads aborts with sourceBytesPerRow(16) must be >= (28) and t_bc_cpu views aborts because RGBA8Unorm storage is incompatible with a BC1_RGBA view. Both modes pass after the fix.
  • Existing GPU regressions pass: view swizzle (554 checks), view levels (45), texture clears (51), direct uploads (26,384, including the dropped-upload recovery run).
  • Texture layout/copy suite: 5,344/5,344 checks pass. The CPU BC reference test also passes ASan/UBSan. Device capability tests (1) and documentation tests (11) pass.
  • iOS compile check: 265 files in the default mode and 265 in DM_FRAMEWORK_BUILD=1, 0 failures in either.
  • Two-game static regression: PASS, scripts/regress.py check --baseline HEAD --candidate worktree --games 010015100B514000,0100646009FBE000 --quick --no-smoke. Wonder: 12,811/12,811 shaders, Dead Cells: 1,262/1,262, zero new failures, changed MSL or interface mismatches. These are the two available local NVN builds. The narrower game set is complemented by the format-level GPU regression above. This was a static comparison, not fresh full-game smoke runs.
  • Device/gameplay evidence: historical 2026-11-05 captures of Super Mario Bros. Wonder (010015100B514000, 1.0.0) on iPhone 13 Pro Max / A15, iOS 27.0.1, before and after the equivalent local upload/view fix. The fixed character-selection screen ran at about 60 fps. These images are from the earlier engine, not a new full-game validation of this PR's current pin. Later levels, raw BC block encoders/readback and a fresh current-pin phone run were not tested.
  • Launcher UI: no change, so no launcher localization/capture tests apply.

Screenshots

No launcher UI changes. Historical gameplay evidence for the equivalent local fix:

Before (striped rectangles around the characters):

Before: A15 CPU BC texture corruption

After (same character-selection screen):

After: A15 decoded textures render correctly

Scope

  • Engine changes are carried only as a patch in patches/, exported with tools/engine.py export and checked with tools/engine.py check.
  • Upstream disposition is documented as fork-only because upstream declined CPU BC support in Decode BC textures on the CPU when the Metal device cannot sample them seedds/nxnative#488, an exception already accepted by the maintainer.
  • No launcher view changes. Before/after gameplay evidence is provided above.
  • No keys, game files, extracted shaders, saves, credentials or unredacted device logs are included.

Keep decoded textures off the GPU block-copy paths and map views to their unpacked formats. Add production GPU regression tests and document A15 evidence and compatibility limits.
@github-actions github-actions Bot added the patch-queue Changes the patch queue or the upstream pin label Nov 7, 2026
@thehobbit85 thehobbit85 added this to the v1.2.4 milestone Nov 7, 2026
@thehobbit85

Copy link
Copy Markdown
Contributor

Reviewed d3249e0 and obtained an independent code review. No actionable code finding remains for this focused upload/view fix.

Local validation on Apple M2 Max: python3 tools/engine.py check passes with 56 patches on the pinned engine, and make -C dm/gfx/tests GAME=010015100B514000 check_t_bc_cpu passes all 349 checks with Metal API validation enabled. This covers the actual production CPU-BC upload and view paths. The native BC path stays behind its existing capability gate.

The reported historical A15 gameplay is useful supporting evidence, but I am not treating it as a current-pin phone run. Raw compressed-block views, encoding/readback and broader copy behavior remain outside this fix.

Assigned v1.2.4 and approved the three held CI runs after review. Merge still waits for those exact-head checks and the required CI-built Mac app trial. Patch 0088 is currently the next free number on main and will be checked again at merge time. I will compare the overlapping #776 after this lands, while #446 still contains separate work.

@thehobbit85 thehobbit85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved d3249e0. Independent code review found no actionable issue in this focused CPU-BC upload/view repair. Local patch validation passed (56 patches), and the actual production GPU regression passed 349 checks on Apple M2 Max with Metal API validation enabled. Native BC retains its existing capability/opt-in gate.

All current-head CI checks passed, including the engine/host/tool/iOS tests and app build. Maintainer app trial used tools/try-pr 888 and build 42350521347 at this exact head. NX2Apple 1.2.3 launched with bundled engine b2d46b86d03f4b03afe11ea61c67cdf00d7a5345-5e5456d86c7d. Library/Settings/Builds navigation and the manual app update check worked, and the app quit normally.

This is not a fresh current-pin phone gameplay run. The reported historical A15 evidence remains attributed to the contributor. The new local GPU regression checks this patch's current-pin production paths, while raw compressed-block views, encoding/readback and broader copy behavior remain outside the change.

Patch 0088 is the next free number on current main, so no renumbering is needed. Milestone v1.2.4. Ready for a normal GitHub merge.

@simonflore

Copy link
Copy Markdown

Independent corroboration from an A15 Apple TV 4K (third generation, 64 GB), tvOS 27.2, using a custom tvOS frontend and Mario Kart 8 Deluxe 4.0.1 (0100152000022000).

In an earlier NX2Apple-derived engine, menus rendered with severe blue/striped corruption. We independently traced the same upload issue: GPU deswizzle copied compressed BC blocks into CPU-expanded textures. A synthetic Mac reproduction forced the production CPU BC path and aborted under Metal validation with sourceBytesPerRow 16 below the decoded minimum 32. Gating the GPU upload routes for decoded BC textures fixed that reproduction (46 known-pixel checks across BC1/BC3/BC4, two mips and two array layers). The native/direct-upload suite passed 26,384 checks.

After the equivalent local upload fix plus decoded view-format handling, the player confirmed that both menus and a race rendered correctly on the Apple TV. This was a separate backport against the older engine (88c7e03f51e3 plus fork patches), not a device run of #888's exact merged revision. The tvOS frontend is custom, so this is evidence for the shared texture path, not a claim of stock NX2Apple Apple TV support.

We checked #888 and patch 0088 and found the same upload/view mechanism already covered, with broader regression coverage. No duplicate code PR is proposed. This report was prepared with Codex from local reproduction logs and the player's device confirmation.

Validation limit: menus and race visuals only; no completed-race, all-course or long-session benchmark is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch-queue Changes the patch queue or the upstream pin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants