Skip to content

packing: the shader step's progress follows it past the last shader - #2684

Closed
UserDerezzed wants to merge 1 commit into
seedds:mainfrom
UserDerezzed:shader-progress-tail
Closed

UserDerezzed wants to merge 1 commit into
seedds:mainfrom
UserDerezzed:shader-progress-tail

Conversation

@UserDerezzed

Copy link
Copy Markdown
Contributor

What and why

On a build that restores every shader from the compile cache, the shader step's progress line stops just short of its total (42,811 of 42,848 for Ocarina of Time) and stays there for about two minutes before the step ends. It looks like a hang.

ShaderWatch reads only dmsh_build.py's progress file, which is written at most every half second, so its last count can be up to half a second old. A reuse build finishes a few dozen shaders in that time. After the last shader, dmsh_build.py writes the library images and then runs c1_guard.py and cb_extent.py (95 s for Ocarina of Time on an M3 Max), and writes no more progress.

ShaderWatch now follows those steps without any change to dmsh_build.py, which is a chain input:

  1. While a library image is written (<library>.img.part), it shows writing the library image with the bytes so far.
  2. In a full build, once dmsh_build.py removes the progress file, it shows c1 bounds (c1_guard.py) until dmsh_build.py prints its c1_full.tsv: line.
  3. It then shows uniform read extents (cb_extent.py) until the cb_extent.tsv: line. The lines come from run's on_line.

A --seen-shaders build makes no tables, so it shows no table steps.

Reference entry: The shader step stands at 99% for minutes before it ends.

Checked

  • Tests: dm/tools/tests/test_nsp_mac.py (test_shader_watch_follows_the_steps_after_the_last_shader, test_shader_watch_partial_build_has_no_tables, test_the_build_follows_dmsh_builds_lines). The whole of dm/tools/tests: 1,589 tests, one failure: test_tree_tar PackQuiet, which fails the same on main 5a4e23a2.

  • Game: Ocarina of Time 0400486024DEC000 v131072, M3 Max (36 GB), macOS 27.2, --platform mac-app, on my branch that carries this commit with other PRs. I watched the first build after a chain change, which translated every shader. After the last shader, the line showed:

    • writing the library image up to 10.7 GB, for 2:38;
    • c1 bounds (c1_guard.py) for 23 s;
    • uniform read extents (cb_extent.py) for 64 s;
    • then the step's end.

    A build that restores every shader from the cache wasn't watched. It runs the same steps in the same order.

  • regress.py: not run. Only the progress line changes.

  • dm/tools/lint_python.py --against origin/main with the pinned ruff 0.17.2 and pyright 1.1.414 (Python 3.14): 0 new findings.

  • Not run: an iOS build (two library images).

Docs

  • The finding is in its docs/reference/packing.md entry (and the game note's "Found on this game"), and python3 dm/tools/docs_symptoms.py was run (the symptom index)
  • No game files, keys or data extracted from a game in the change or the attachments

On a build that restores every shader from the cache, the shader step's line stopped
just short of its total (42,811 of 42,848 for Ocarina of Time) for about two minutes:
ShaderWatch read only dmsh_build.py's progress file, written at most every half second,
and after the last shader dmsh_build.py writes the library images and runs c1_guard.py
and cb_extent.py (95 s on an M3 Max) with no more progress.

ShaderWatch now follows those steps without a change to dmsh_build.py, a chain input: an
image being written (<library>.img.part, its bytes so far), then, once the progress file
is removed in a full build, c1 bounds until dmsh_build.py prints its c1_full.tsv: line
and uniform read extents until its cb_extent.tsv: line (run's on_line). A --seen-shaders
build makes no tables and shows none.

Checked with test_nsp_mac. Not run: an iOS build (two library images).
@github-actions github-actions Bot added packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts) docs Documentation game: 0400486024DEC000 A game labels Nov 14, 2026
@UserDerezzed

Copy link
Copy Markdown
Contributor Author

This PR currently has no failing checks on the branch as it stands. A maintainer review would help move it along. If anything in the checks changes after a new main, a comment here will say so.

Please stop responding to my PRs with unhelpful and nagging replies, thank you. The maintainer is fully capable of reviewing these pull requests themself.

seedds added a commit that referenced this pull request Nov 23, 2026
…2684)

After the last regular shader, dmsh_build.py wrote no more progress to DMSH_PROGRESS, leaving ShaderWatch frozen at a stale ~99% count through mesh-library compilation, library-image publishing, and the c1_guard.py and cb_extent.py table passes. ShaderWatch also mapped every step other than cache check back to compiling, hiding compiling RT library.

Have dmsh_build.py report all of its phases directly through DMSH_PROGRESS: flush the final counts of cache check and compiling, flush immediately on step changes, report compiling mesh libraries across _mesh, pass an optional on_progress callback through publish_library to shader_lib.write for writing the library image (or writing the Mac / iOS library image on dual-image builds, with file counts and bytes written), and report c1 guard and uniform read extents before unlinking DMSH_PROGRESS at exit. Simplify ShaderWatch to forward step, counts, unit, and formatted byte notes straight from DMSH_PROGRESS. Regenerate dm/gfx/nvn/dmsh_chain.h.

Checked: 159 tests across test_nsp_mac, test_shader_lib, test_shader_toolchain_cache, test_nsp_chain, test_dmsh_abi, test_dmsh_code_fp, test_pr_areas, test_usage, and test_docs; ruff check (0 new findings).

Co-authored-by: UserDerezzed <25561419+UserDerezzed@users.noreply.github.com>
@seedds

seedds commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks @UserDerezzed for tracking down why the shader progress line appeared frozen near 99% after the last shader!

Landed on main in d2939c1 with a slightly different approach: instead of inferring the late stages from .img.part files and stdout lines to avoid changing the shader chain version, the shader builder now reports each phase directly through its existing progress file. It flushes the final shader count, reports mesh-library builds, reports library-image writing with file counts and bytes written (distinguishing the Mac and iOS images on dual-image builds), reports both table passes (c1 guard and uniform read extents), and preserves the RT library label. The docs were also updated to reflect the current post-memo and parallel-writer timings.

Checked with unit and documentation tests covering single-image Mac builds, dual-image iOS builds, partial (--seen-shaders) builds, mesh libraries, progress throttling, and the updated chain header, plus ruff. A live full-cache or dual-image iOS build has not been run yet — if anything looks off on a real build, please let us know.

@seedds seedds closed this Nov 23, 2026
Kayyluhh added a commit to Kayyluhh/nxnative that referenced this pull request Nov 23, 2026
… and seedds#3156 reverted first (on main in its own form / superseded by seedds#3174); chain 6cc6fc49af97 -> 3fe2e3787fdf

Conflicts, both sides kept:
- hle_nvn.c: main's deferred acquire wait (c17a549, acq_wait bound to the sync) takes the batch's
  acquire fence (seedds#1847's 81c6189: the image's own last present, pfence, snapshotted with the ticket
  under acq_mu; DM_NVN_ACQ_FENCE=last the old one) as aw->gpu_fence, and DM_NVN_FRAME_LAG's wait at
  the acquire's start; the present notes the lag ring before publishing its ticket, and @lag_ms
  stays beside main's atomic @wait_ms / @pq_wait_ms. nvn_obj.h win_t has pfence and pending_acq.
- nvn_mtl.m: the pool cache keeps seedds#1847's last-hit entry in front of main's 64 KB region table
  (a359f9e); ubd_conflict_scan's partial look walks main's buffer binding list (e49e481).
- shader_lib.py: seedds#2140's shared payloads with main's on_progress (seedds#2684).
- hle_fs.c: the profile's RomFS files beside main's releasable mounts (seedds#3217).
- game.py (main's mem_map_limit default), pack_app.py (--tweaks and --mesh-pairs), env_switches.tsv,
  frame-rate.md, services.md, Ocarina's note: both entries.
- dm/host/tests/Makefile: t_crash_diag (new on main) links memstat.m, which seedds#2261's GPU share line
  makes use IOKit: -framework IOKit.
Chain header is main's (dmsh_chain.py --header agrees); symptom index, game-patches.md and
env_switches.tsv order regenerated.
Aznracer pushed a commit to Aznracer/Mighty-Green-Kokiri-Kid that referenced this pull request Nov 25, 2026
…eedds#2684)

After the last regular shader, dmsh_build.py wrote no more progress to DMSH_PROGRESS, leaving ShaderWatch frozen at a stale ~99% count through mesh-library compilation, library-image publishing, and the c1_guard.py and cb_extent.py table passes. ShaderWatch also mapped every step other than cache check back to compiling, hiding compiling RT library.

Have dmsh_build.py report all of its phases directly through DMSH_PROGRESS: flush the final counts of cache check and compiling, flush immediately on step changes, report compiling mesh libraries across _mesh, pass an optional on_progress callback through publish_library to shader_lib.write for writing the library image (or writing the Mac / iOS library image on dual-image builds, with file counts and bytes written), and report c1 guard and uniform read extents before unlinking DMSH_PROGRESS at exit. Simplify ShaderWatch to forward step, counts, unit, and formatted byte notes straight from DMSH_PROGRESS. Regenerate dm/gfx/nvn/dmsh_chain.h.

Checked: 159 tests across test_nsp_mac, test_shader_lib, test_shader_toolchain_cache, test_nsp_chain, test_dmsh_abi, test_dmsh_code_fp, test_pr_areas, test_usage, and test_docs; ruff check (0 new findings).

Co-authored-by: UserDerezzed <25561419+UserDerezzed@users.noreply.github.com>
(cherry picked from commit d2939c1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0400486024DEC000 A game packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants