Skip to content

Bound explicit-frame render-pass snapshots - #1178

Open
oliverames wants to merge 3 commits into
seedds:mainfrom
oliverames:diagnostic-bounded-pass-snapshots
Open

oliverames wants to merge 3 commits into
seedds:mainfrom
oliverames:diagnostic-bounded-pass-snapshots

Conversation

@oliverames

@oliverames oliverames commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Variable pass numbers made it easy to miss DKB's AA outputs when selecting DM_NVN_TEXSNAP indices. This adds opt-in DM_NVN_TEXSNAP=all for one explicitly selected dump frame, with at most 256 snapshots and 512 MiB of retained texture allocations. Copies use the existing ordered Metal 4 pass-end stream. Normal rendering stays unchanged when capture is disabled.

Each copy records its frame, absolute pass, texture serial, level, format, dimensions and allocation. Unsupported formats, layered/nonzero-slice passes, discarded stores and allocation failures are reported as skips. Budget exhaustion is reported as truncation. A missed requested frame is explicitly incomplete, and a new selected frame resets the budget. These are pass outputs, not proof of the exact textures sampled by a draw.

@seedds, this supports the Switch 2 games running on iPhone investigation. The diagnostic may help other titles that reuse render targets within a frame. It does not establish a DKB shimmer fix, sustained warm stability, or complete draw-input equivalence. Exact-head device coverage and hosted checks are still pending. No game assets or shader sources are included.

Checked

  • Tests: the focused Metal-validation fixture passes 16 checks in RGBA8 and 16 in RG11B10Float, including GPU readback after a later overwrite, byte/count limits and repeated-frame budget reset. The absent-frame summary was inspected. 11 documentation tests, the environment-switch test and git diff --check pass. Scope is the opt-in snapshot path. To reproduce:

    make -C dm/gfx/tests GAME=040074A01BF12000 t_texsnap
    MTL_DEBUG_LAYER=1 dm/gfx/tests/t_texsnap
    TEXSNAP_TEST_HDR=1 MTL_DEBUG_LAYER=1 dm/gfx/tests/t_texsnap
  • Games run, with title ID and version: DKB (title ID and version not stated; the fixture command uses GAME=040074A01BF12000). With this patch adapted onto the existing combined DKB build, the physical iPhone completed 70 seconds of gameplay and preserved the pre-AA color plus edge, weight and resolve pass outputs at 1676×943. All four raw files transferred with validated headers and lengths. The capture logged 91 copies, 47 skips, 0 truncations and 333,300,096 retained bytes, and correctly marked the overall history incomplete. The drawable endpoints remained 2346×1320. This was an adapted combined build, not this exact branch head. Phone executable SHA-256: b1c5c25742e00fcddfe827fb10632f790e43757f4367be74201fe5b8097c9c43.

  • Devices and OS: iPhone 17 Pro Max (iOS version not stated). The fixture's Mac model and macOS version are not stated.

  • For a change to the shader chain, the host or a tool that every game uses, the scripts/regress.py check --games report: not stated, beyond "broad five-game regressions were not run."

  • Measurements before and after: not stated. The only memory figure is the 333,300,096 retained bytes of the phone capture, against the 512 MiB cap.

Front ends

None: no front end has to act on this.

Docs

  • The finding is in its game note or its docs/reference/<subsystem>.md entry, and python3 dm/tools/docs_symptoms.py was run (the symptom index). The diff changes docs/agents/04-graphics.md and docs/env_switches.tsv, not a game note or a docs/reference entry, and the description does not say the symptom index was run.
  • 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

Nov 14: rebased onto main bee218d97 (head 599f470d), with no merge commit. docs/env_switches.tsv and dm/tools/lint_c_baseline.tsv conflicted (this PR's NullablePassedToNonnull count kept, main's removed RetainCount row left out), and clang-tidy on nvn_mtl.m and t_texsnap.m has no pair above or below the baseline. t_texsnap passes 16 checks in RGBA8 and 16 with TEXSNAP_TEST_HDR=1, and test_lint_c and the documentation tests pass. Earlier: rebased onto main 6c676444 on 2026-11-09 (head 4c164773). t_texsnap's rule now sits after check_t_readback in dm/gfx/tests/Makefile instead of at the end of the file, where every new test on main conflicted with it. After the rebase t_texsnap passes 16 checks in RGBA8 and 16 with TEXSNAP_TEST_HDR=1, and test_docs.py (6 tests, where the Tests line above counts 11 from the earlier base) and test_env_switches.py pass.

@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) docs Documentation tools Tools and scripts (dm/tools, scripts) labels Nov 4, 2026
@oliverames

Copy link
Copy Markdown
Contributor Author

Head ad984ce4 fixes the clang-tidy failure this PR caused. The bounded snapshot code in nvn_mtl.m adds a nil check on the copy texture, which removes one clang-analyzer-nullability.NullablePassedToNonnull finding (15 to 14, confirmed locally with clang-tidy 23.1.4 on this branch merged with main: 46 findings against main's 47). The ratchet requires the baseline to shrink with it, so the commit lowers that one count in dm/tools/lint_c_baseline.tsv from 15 to 14 (dm/tools/tests/test_lint_c.py passes).

clang-tidy run 41840087538 on ad984ce4 now reports baseline 240 and no nvn_mtl.m finding. It fails only on four pairs from files this PR does not touch, which also fail on main: run 41819072419 at 0b8e0dc (dm/gfx/vk/hle_vk.m NullDereference, dm/host/hle_jit.c suspicious-realloc-usage, dm/host/hle_oe.c StdCLibraryFunctions, dm/host/web_apple.m NullablePassedToNonnull). No commit to dm/host or dm/gfx has landed on main since.

@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 exact-head device coverage and hosted checks. 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: exact-head device coverage and hosted checks. 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 diagnostic-bounded-pass-snapshots branch 2 times, most recently from b44f4f0 to 2d34096 Compare November 7, 2026 19:37
@oliverames

Copy link
Copy Markdown
Contributor Author

Rebased onto current main: one conflict in dm/gfx/tests/Makefile (kept main's new test targets plus t_texsnap). make GAME=040074A01BF12000 check_t_texsnap: 16 checks, 0 failed; test_docs.py OK.

@oliverames
oliverames force-pushed the diagnostic-bounded-pass-snapshots branch 4 times, most recently from 916d304 to 4c16477 Compare November 10, 2026 03:25
@oliverames
oliverames force-pushed the diagnostic-bounded-pass-snapshots branch from 29f5fbb to 599f470 Compare November 14, 2026 22:45
@oliverames

Copy link
Copy Markdown
Contributor Author

@seedds I merged current main into this branch in cd69dee. Main removed the DM_NVN_PASSGPU block that sat in the conflict in nvn_mtl.m, so I took main's side there and re-added the ts_discard call after main's new dead logic in sd_finish. env_switches.tsv keeps both the TEXSNAP row and main's DM_NVN_TEX_EVICT_IDLE row. t_texsnap passes all 16 checks with the Metal debug layer on, with HDR and without, and clang-tidy on the touched files matches main's baseline, though I ran a slightly newer LLVM than CI does.

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

Labels

docs Documentation 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