Skip to content

Capture bound NVN2 push constants for shader diagnostics - #1160

Open
oliverames wants to merge 2 commits into
seedds:mainfrom
oliverames:nvn2-push-constant-capture
Open

oliverames wants to merge 2 commits into
seedds:mainfrom
oliverames:nvn2-push-constant-capture

Conversation

@oliverames

@oliverames oliverames commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What and why

NVN2 shaders bind c24 from push constants, so the existing uniform-buffer dump omitted the values needed to replay those shaders. This extends DM_NVN_CBDUMP to save the whole push block set copied into the argument arena (since main made it DMSH_PUSH_BLOCKS blocks of 0x100 bytes, 1,536 bytes; it was one 256-byte block when this PR was written), under the existing pass-dump gate and exact shader-key filter. Filenames include frame, pass, draw counter and stage. With diagnostics disabled, rendering behavior is unchanged.

@seedds: this supports the Switch 2 games running on iPhone investigation, specifically Donkey Kong Bananza on iPhone 17 Pro Max. Its earlier spatial-AA replay assumed reciprocal-dimension c24 values. Other NVN2 titles using push constants may benefit from the same diagnostic. This is not a fur-shimmer or pacing fix.

The actual DKB capture and CI are not yet verified. The existing installed DKB binary has not been replaced. Earlier Newt fixture evidence and the prepared combined DKB game candidate describe their recorded source versions, not this updated head.

Checked

  • Tests: the focused fixture exercises production encode_args, resolves the pointer in the encoded argument buffer, and compares all captured bytes against the referenced arena. It covers graphics/compute bank selection, filtering, disabled capture and the first-encode gate. It passed 28 checks on the Mac and on a physical iPhone 17 Pro Max with Metal validation enabled. This verifies host argument data, not GPU readback. Documentation tests (11), the environment-table test and whitespace checks pass; the table check keeps its existing advisory about historical DM_NVN_CUT_FIRST prose. Reproduce with make -C dm/gfx/tests GAME=040074A01BF12000 check_t_push_capture. For the CI prerequisite, targeted LLVM 23.1.4 analysis of the renderer and capture fixture has zero pairs above or below baseline, and the fixture passes 28 checks with Metal API validation on M2 Pro.
  • Games run, with title ID and version: no five-game gameplay regression was run for this opt-in diagnostic. The actual DKB capture is still pending; no title version is stated in the original description (the game note path uses title ID 040074A01BF12000).
  • Devices and OS: the iPhone fixture run was d2bb79f6-1c75-4b06-85b1-3d2216e482b8 on A19 Pro / iOS 27.2, a Debug build targeting iOS 26, on an iPhone 17 Pro Max. The Mac checks ran on an M2 Pro; the macOS version is not stated.
  • scripts/regress.py line: not stated. The description says only that no five-game gameplay regression was run.
  • Measurements before and after: not stated; this is an opt-in diagnostic with no speed, memory or power claim.

Front ends

None: no front end has to act on this.

Docs

  • The finding is in its game note and its docs/reference/shaders.md entry (both are in the diff), and docs/agents/symptoms.md is updated in the diff. The original description does not say python3 dm/tools/docs_symptoms.py was run, but the symptom index change is part of the diff.
  • A chain tool changed: dmsh_chain.py --header was run and dm/gfx/nvn/dmsh_chain.h is part of the change. Not applicable: no chain tool changed.
  • No game files, keys or data extracted from a game in the change or the attachments (source, a test, and docs only).

Nov 12: main 0c23e0b59 merged in (head 6dd2b93b). Main grew S.push[bank] to DMSH_PUSH_BLOCKS blocks, so the capture, its log line, its file and t_push_capture now take sizeof S.push[0] (1,536 bytes) instead of DMSH_PUSH_SIZE; check_t_push_capture passes its 28 checks on the Mac, and the iPhone run quoted above is from the old head. Earlier: rebased onto main 6c676444 on 2026-11-09 (head 2c69ce75). t_push_capture's rules now sit after check_t_present_crop in dm/gfx/tests/Makefile instead of at the end of the file, where every new test on main conflicted with them. After the rebase make check_t_push_capture passes 28 checks, and test_docs.py (6 tests) and test_env_switches.py pass; the symptom index is unchanged by docs_symptoms.py.

@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation game: 040074A01BF12000 Donkey Kong Bananza labels Nov 4, 2026
@github-actions github-actions Bot added host The Horizon host: SVCs, services, threads, memory (dm/host) tools Tools and scripts (dm/tools, scripts) labels Nov 4, 2026
@oliverames

Copy link
Copy Markdown
Contributor Author

@seedds, update on the AA investigation diagnostic for Switch 2 games running on iPhone: head ee418ef includes #1164's lint prerequisite, and the 28-check bound push-constant fixture passes with Metal validation on M2 Pro. The fixture verifies host argument bytes, not GPU readback. Earlier iPhone 17 Pro Max fixture evidence belongs to its recorded older source; actual DKB AA constants have not yet been captured. This stays draft and makes no shader-mismatch or fur-shimmer-fix claim. The capture is reusable for other titles' shader investigations.

@oliverames

Copy link
Copy Markdown
Contributor Author

@seedds Reconciled the Switch 2 / iPhone push-constant diagnostic with current upstream and repaired #1164 at 203e502. The Mac Metal-validation fixture passes 28 checks and all 11 documentation tests pass; new hosted CI is pending. A fresh adapted combined DKB build on iPhone 17 Pro Max captured actual AA constants at frame7684: five bound 256-byte banks begin with float32(1/1676), float32(1/943),1676,943. Six AA stages are present, but the edge fragment shader has no push binding. A 70-second gameplay route retained 1676x943 scene,2304x1296 MetalFX,2346x1320 drawable. This verifies diagnostic usefulness on the combined build, not exact-head gameplay or an AA fix. Raw replay still does not establish a translation mismatch or reduced shimmer. Keeping draft with those limits.

@oliverames

Copy link
Copy Markdown
Contributor Author

@seedds Flagging from my open-PR index of my 32 open PRs here: this one stays draft pending the real DKB capture, hosted CI, and #1164 landing so the prerequisite drops out. The description above is still the full picture, nothing new from me. Happy to rebase, split or retitle whenever review suits.

@oliverames
oliverames marked this pull request as ready for review November 5, 2026 22:15
@oliverames

Copy link
Copy Markdown
Contributor Author

@seedds Marking this ready for review now, so it stops waiting in draft on me. The remaining item from the description is still open: the real DKB capture and hosted CI; the #1164 prerequisite drops out of the diff once #1164 lands. It can carry on alongside a review instead of ahead of it. The description stays the source of truth; happy to rebase, split or retitle whenever review suits.

@oliverames
oliverames force-pushed the nvn2-push-constant-capture branch 3 times, most recently from d09c713 to f8d4527 Compare November 8, 2026 22:28
@oliverames

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (f8d45274): kept both sides in dm/gfx/tests/Makefile, symptoms.md and shaders.md, regenerated the symptom index. make GAME=040074A01BF12000 check_t_push_capture: 28 checks, 0 failed; test_docs.py OK.

@oliverames
oliverames force-pushed the nvn2-push-constant-capture branch 2 times, most recently from 79cb857 to 02b3ac4 Compare November 10, 2026 03:20
@oliverames
oliverames force-pushed the nvn2-push-constant-capture branch from 02b3ac4 to 2c69ce7 Compare November 10, 2026 03:25
Conflicts: dm/games/040074A01BF12000/README.md (both sides kept), dm/gfx/nvn/nvn_mtl.m (push-constant encode).
Adaptation: main grew S.push[bank] to DMSH_PUSH_BLOCKS blocks (6 x 0x100 bytes), so the c24 capture, its PD line and t_push_capture use sizeof S.push[0] instead of DMSH_PUSH_SIZE; shaders.md says the whole block set is saved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 040074A01BF12000 Donkey Kong Bananza host The Horizon host: SVCs, services, threads, memory (dm/host) nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant