Skip to content

regress.py usage / impact: which games a change can reach, from per-game usage manifests - #329

Closed
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:harness-usage
Closed

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:harness-usage

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

Stacked on #328 (all commits but the last are that PR; review the last one, "regress.py usage / impact"). Roadmap: #313, "Usage manifests".

regress.py check covers the games on your own Mac. For the others, the question before a chain or host change is which games it can reach at all. This adds two commands:

  • regress.py usage --games <id> --write, run once by someone who owns the game: writes dm/games/<id>/usage.tsv, its usage manifest. From the game's translated shaders: stages, binding kinds, image and buffer atomics (with or without a used result), transform feedback, layer and integer outputs, the translator's notes, texture types. From one quick run of its smoke route with DM_HLECOUNT and the NVN call rows: the NVN functions, HLE functions and SVCs it called, its present path, its profile keys. Names and counts only, no game data.
  • regress.py impact <base>..<head> (or one commit): maps the change to manifest rows and lists the games that use them, those reached only through a broad rule (every game of the API), and the profiles without a manifest as unknown. The mapping is the functions around the changed lines, followed through the host's callers to the NVN entry points and HLE functions that reach them (dm/tools/usage.py, a scanner over NVN(...), HLE(...) and symbol tables; static functions stay within their file), plus the rules of dm/tools/impact_map.tsv for what a call graph cannot see (a chain tool to the shader features it emits, the prepare step to the games that run it). A changed file no rule maps is listed, and test_usage.py checks that every rule matches a file.

Manifests for Breath of the Wild, Tears of the Kingdom and Hades (built on 89744da) come with it.

What it says on past changes

change Breath of the Wild Tears of the Kingdom Hades
c3a0880 (image atomics, broke SMT V and Yoshi, #173 / #218) affected: driver reads (c2 ×81), bindless handles; not for image atomics (it has none) affected: bindless handles (A ×316, C ×226), image bindings ×26, texture writes ×24; no image atomics not affected (Vulkan)
e6b800a^..f6bd56f (#135, the prepare step and pulling variants) affected: pulling vertex inputs ×8,888, readable tiles ×6,254, pipeline archive and prepare affected: pulling vertex inputs ×14,549, readable tiles ×8,380, pipeline archive and prepare broad only (the packing script and the front end)
ff44c59 (pad the vertex outputs of every prebuild pair, #283) affected: vertex shaders with padded outputs ×5, prepare step affected: padded vertex shaders ×387, prepare step broad only (the packing script)

On c3a0880 the two games it broke are "unknown": no one with those games has written a manifest yet. With one each, the same run would have named them for shader:image_atomic*, which is the point of asking owners to run usage once.

Limits: the call-graph scan is textual and over-approximates (a change in nvn_mtl.m reaches the present path of every NVN game through shared helpers); the rules are coarse by design and say why for every match. It tells you whom to ask, not whether something broke: that stays regress.py check on the games you have.

docs/agents/06-dev-loop.md gets a section on it and the pre-PR list adds regress.py impact main..HEAD.

Checked: dm/tools/tests (277 tests, new test_usage.py), lint_python.py (no new findings), the three impact runs above on an M2 Max, CI on the fork.

…ds#272)

A game's usage manifest, dm/games/<id>/usage.tsv, written by its owner with
regress.py usage: the features of its translated shaders (stages, binding
kinds, image and buffer atomics with or without a used result, transform
feedback, layer and integer outputs, translator notes, texture types) and,
from one run of its smoke route with DM_HLECOUNT and the NVN call rows, the
NVN functions, HLE functions and SVCs it called, its present path and its
profile keys. Names and counts only.

regress.py impact <base>..<head> maps the functions around the changed lines
through the host's callers (a scanner: NVN(...), HLE(...) and {"symbol", fn}
tables as roots, static functions kept to their file) and the rules of
dm/tools/impact_map.tsv to manifest rows, and lists the games that use them,
those reached only through a broad rule, and the profiles without a manifest.

Manifests for Breath of the Wild, Tears of the Kingdom and Hades (main
89744da). On c3a0880 (image atomics, seedds#178) it names neither Zelda for image
atomics (they have none) but both for the bindless and driver-read changes;
Hades is not affected. On seedds#135 (the prepare step) it names both Zeldas for
pipeline_prepare and Hades only through the front end's broad rule.
seedds added a commit that referenced this pull request Oct 27, 2026
From PR #329 (stacked on #328): a game's usage manifest, dm/games/<id>/usage.tsv,
written by its owner with regress.py usage (shader features of its chain build,
and the NVN / HLE functions, SVCs and present path of one smoke-route run;
names and counts only), and regress.py impact <base>..<head>, which maps the
functions around the changed lines through the host's callers and the rules of
dm/tools/impact_map.tsv to manifest rows. Manifests for Breath of the Wild,
Tears of the Kingdom and Hades.

Fixed on top of the PR:
- impact checked the head out as a git worktree under the harness root, so it
  stopped (PermissionError on /Volumes/NX) for exactly the contributors it is
  for, who have no games and no harness root. The call graph is now read from
  the git object store at the head revision, and the report is printed and
  written only to --out or an existing harness root.
- A hunk mapped only to the function at its first line: a hunk spanning two
  functions named one. Every added line is mapped now, and a pure deletion maps
  to the function around it (it was moved one line up).
- Functions defined in headers were not in the call graph: the frame step
  (nvn_fstep.h, static inline, called from nvnQueuePresentTexture) reached no
  entry point, so 4acde72 named no game. Headers are scanned, and their
  functions are visible to every file. 4acde72 now names both Zeldas through
  nvnQueuePresentTexture.

Co-authored-by: v0lumehi <aljic.zijad@gmail.com>
@seedds

seedds commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Thanks, merged as b3f97ef (rebased on main, one commit, you as co-author).

Confirmed first: the tests pass on main + this PR (298 with the new ones), and the three impact runs in the description reproduce. Three bugs fixed on top:

  1. impact needed a harness root. It checked the head out as a git worktree under <root>/trees, so with the default root it stopped with PermissionError: '/Volumes/NX'. That hits exactly the contributors it is for, who have no games and no harness. The call graph is now read straight from git at the head revision (usage.host_sources(rev=…): git ls-tree plus git cat-file --batch). The report is always printed, and written to --out or to an existing <root>/reports/.
  2. A hunk mapped only to the function at its first line. With @@ -2 +2,4 @@ spanning a and b, only a was reported. Every added line is mapped now. A pure deletion (+c,0) maps to line c (it was c-1, which could land in the function before).
  3. Header functions were missing from the call graph. The frame step (nvn_fstep.h, static inline, called from nvnQueuePresentTexture in hle_nvn.c) reached no entry point, so impact 4acde72 (Frame step: keep what held 60 fps across a 30 fps cap (movies, thermal cap) #253) named no game narrowly. Headers are scanned now, and their functions count as visible to every file. 4acde72 now names both Zeldas through nvn:nvnQueuePresentTexture.

test_usage.py gets a test for 2 and 3 (and for reading at a revision); it fails on the PR's original usage.py. 06-dev-loop.md says that impact needs no game files or harness root.

@seedds seedds closed this Oct 27, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
From PR seedds#329 (stacked on seedds#328): a game's usage manifest, dm/games/<id>/usage.tsv,
written by its owner with regress.py usage (shader features of its chain build,
and the NVN / HLE functions, SVCs and present path of one smoke-route run;
names and counts only), and regress.py impact <base>..<head>, which maps the
functions around the changed lines through the host's callers and the rules of
dm/tools/impact_map.tsv to manifest rows. Manifests for Breath of the Wild,
Tears of the Kingdom and Hades.

Fixed on top of the PR:
- impact checked the head out as a git worktree under the harness root, so it
  stopped (PermissionError on /Volumes/NX) for exactly the contributors it is
  for, who have no games and no harness root. The call graph is now read from
  the git object store at the head revision, and the report is printed and
  written only to --out or an existing harness root.
- A hunk mapped only to the function at its first line: a hunk spanning two
  functions named one. Every added line is mapped now, and a pure deletion maps
  to the function around it (it was moved one line up).
- Functions defined in headers were not in the call graph: the frame step
  (nvn_fstep.h, static inline, called from nvnQueuePresentTexture) reached no
  entry point, so 57eae66 named no game. Headers are scanned, and their
  functions are visible to every file. 57eae66 now names both Zeldas through
  nvnQueuePresentTexture.

Co-authored-by: v0lumehi <aljic.zijad@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants