Skip to content

Remove stale shader library folders after a build and offer them in Free space - #231

Merged
v0lumehi merged 2 commits into
mainfrom
v0lumehi/prune-stale-shaders
Oct 29, 2026
Merged

v0lumehi merged 2 commits into
mainfrom
v0lumehi/prune-stale-shaders

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

This is a fix. Every change to the shader chain translates all shaders again into a new b-<chain> folder, and nothing removed the old ones. A Breath of the Wild build folder held b-157e1b96c8da (2.1 GB) and b-a78f966a7b38 (2.3 GB) besides the current chain, 4.4 GB nothing reads, and each upstream update adds about 2 GB per game. The latest pin bump changes the chain again.

  • Patch 0032 carries the engine fix, forwarded as NSP script: remove the shader libraries of older chain versions after a successful build seedds/nxnative#682. After a successful shader build the NSP script removes the b-<other> folders in shader/cache and shader/ios and their keys, and logs removed old shader libraries b-… (N GB). A build that stops or fails keeps the old libraries. shader_regressions has run by then, and the next chain change compares with the folder that stays. The Metal compile cache is not touched. It is keyed by the MSL, shared across chains and never pruned, so it grows only with new MSL.
  • The Mac launcher's Free space sheet gets a separate row, "Old shader versions", for folders left before this change or by another checkout. It lists the b-<12 hex digits> folders and keys that are not the current chain, each with its size, and removing them costs nothing on the next build. The current chain is DMSH_CHAIN in the checkout's dm/gfx/nvn/dmsh_chain.h, read the way chain_of() in the NSP script reads it. Without a readable chain nothing counts as old. The Shader output row stays as it is, and picking both counts the old versions once.
  • Strings in Chinese, English and Swedish. The German table (l10n: add complete German localization #225) is not merged yet. The Qt front end has no Free space feature, its table is only regenerated.

Issue: none existed, this PR is the issue (as #219 was). Upstream: seedds/nxnative#682.

Checked

  • Tests: python3 scripts/patches.py check, python3 -m unittest discover -s scripts/tests, python3 -m unittest discover -s frontend-qt/tests, dm/tools/tests/test_nsp_mac.py and test_docs.py, cd frontend && swift build -c release && swift test (443 tests, 0 failures). New Swift tests cover the chain read from the header, old versions listed with sizes and the current one kept, removal keeping the current libraries, the compile cache and look-alike names, no removal without a chain or during a build, and Shader output still removing everything.
  • Visual QA: NX_LAUNCHER_CAPTURE_DIR=<dir> swift test captured the sheet with the new row (BotW sizes, two versions listed, row selected). The captures are free-space.png and free-space-running.png, kept locally.
  • Run on a device or Mac: nothing was removed in real game folders. The tests run on synthetic folders.

Screenshots

The sheet with the new row between Shader output and Xcode project (captures kept locally, GitHub takes no upload from the command line).

Scope

  • No vendored file is edited directly: the change is patch 0032 and patches.py check passes, status forwarded seedds/nxnative#682
  • A fix to the engine is also a PR at seedds/nxnative: this PR's patch says forwarded seedds/nxnative#682
  • No keys, game files or data extracted from a game in the change or the attachments

…Free space

Every change to the shader chain translates all shaders again into a new b-<chain> folder, and nothing removed the old ones. A Breath of the Wild build folder held two (2.1 GB and 2.3 GB, 4.4 GB together), and each upstream update adds another.

Patch 0032 (forwarded as seedds/nxnative#682): after a successful shader build the NSP script removes the b-<old> folders in shader/cache and shader/ios and their keys, and logs the freed size. A failed or stopped build keeps them.

The Mac launcher's Free space sheet gets an "Old shader versions" row for folders that were left before this change or by another checkout. It lists the b-<12 hex digits> folders (and keys) that are not the current chain, with their sizes, and removing them costs nothing on the next build. The current chain is DMSH_CHAIN in the checkout's dm/gfx/nvn/dmsh_chain.h, read as the NSP script's chain_of() does. Without it nothing counts as old. The Shader output row stays as it is, and choosing both counts the old versions once. Strings in zh, en and sv, and the Qt table regenerated (the Qt front end has no Free space feature).
@v0lumehi
v0lumehi merged commit 3d3fe65 into main Oct 29, 2026
17 of 18 checks passed
@v0lumehi
v0lumehi deleted the v0lumehi/prune-stale-shaders branch October 29, 2026 23:27
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.

1 participant