WIP: fix(game): what the game decided on this PC stays beside the settings, and a loose cache that cannot move is deleted #345

Draft
lndf wants to merge 1 commit from lndf/Longshot:fix/game-layout-followup into main
Contributor

Why

#321 put longshot_driver_faults.txt in cache/, which the README says can be deleted. A player who clears it to fix something would lose the record of the shaders their driver faulted on, and run into the driver fault again, which on AMD's Windows driver froze the game (issue 996). This follow-up to #321's review also fixes a loose cache that can never move, and docs whose commands point at the old place.

What changed

  • What the game decided on this PC stays beside the settings, not in cache/: longshot_driver_faults.txt, longshot_prepare_skipped and longshot_load_start.txt (with its .waited).
    • driver_faults_path and load_fallback_path in gpu/vk/vk_draw.cpp, and skipped_path in vk_main.cpp, now give the game folder.
    • host/game_layout.c no longer moves these into cache/. A folder #321 already moved has them moved back out (records).
  • A loose cache that can never move is deleted (host/game_layout.c move_as). When cache/ already has its own copy (the first move failed, the file held open, and the game then made a new one), the loose one is deleted, and the log says how many files and MB. Logs are never deleted; a loose log stays, as before.
  • Docs:
    • assets/pipeline_states/README.md and docs/development.md now give cache/longshot_pipeline_states.bin in the add command and steps, which failed with the old path.
    • The README says what cache holds besides caches (the pipeline list you can send in) and what stays out of it.
    • docs/development.md describes the layout and what switching one game folder between a build from before #321 and one after it costs.
    • The RX_VK_LOAD and RX_VK_DRIVER_FAULTS rows give the game folder again.
  • Comments that still said "beside the executable" now name the folder: vk_progcache.cpp, vk_draw.cpp, driver_faults.h, vk_main.cpp.
  • Tests:
    • tests/test_game_layout.py checks that the records stay and move back out of cache/, that a loose cache with a cache/ copy is deleted, and that a loose log stays.
    • tests/test_load_default.py checks that the marker is in the game folder.

Flags and settings

None.

Measurements

Not a performance change: files move between folders, and nothing is measured in frames. The checks below and a run in the game (Testing) are what count.

main: cf605c85 (2026-11-14)
this PR: fix/game-layout-followup @ d82f2026

Testing

Tested:

  • python -I -B tests/run_all.py on Linux (Fedora 45): 484 passed. The four failures fail on a clean main too: test_bake_portability, test_lift_cache (this PC's Python has no numpy), test_module_ids and test_pad_layout (#331 fixes it).
  • tests/test_game_layout.py: the new cases, plus those from #321.
  • Windows with llvm-mingw 20261104, tools.lock's, cross-built on Linux:
    • the Vulkan back end, longshot_vk.dll, builds (RX_TARGET=windows RX_VK_ONLY=1 nx2/build.py --standalone);
    • 44 of the 49 host/*.c compile with the build's host flags, among them hos_main.c, game_layout.c and prompts.c; game_layout.c also passes -Wall -Wextra -Werror;
    • the other 5 need headers a game-free build doesn't have (FFmpeg, dav1d, opus, a field of the game's generated a64 header), and none is touched here.
  • The Linux back end builds (Ubuntu 24.04).

Not tested:

  • A run in the game, on either system: this follow-up's moves back out of cache/ on a folder #321 moved, and the deletion of a loose cache that couldn't move.
  • Windows, end to end: renames on NTFS (MoveFileExA, FindFirstFileA with *.tmp-*), the log rotation into logs\ in game_main, a file held open while the game moves it. Not run on Windows yet, for #321 or this PR.

Needs other testers:

  • Windows: update a launcher-built game folder with --cli --update, then play it. Expect:

    • the caches in cache\ (longshot_vk_pipelines.bin), the logs in logs\, longshot_driver_faults.txt beside the game;
    • the shaders not prepared again;
    • a log written in logs\ when started by the launcher.

    (request to open)

Screenshots

Nothing on screen.

Risk and rollback

A loose cache file is deleted only when cache/ has a file of the same name. It's a cache, so the worst case is the game making it again (a shader preparation, minutes). Logs are never deleted. The records move only out of cache/ into the game folder, never over a file there. Reverting the commit puts them back in cache/ on the next start of a build with #321's list.

Reviewer notes

The rest of #321's review:

  • longshot_startup.log: nothing writes it on main, here or in the launcher. The Linux builder's play diagnostics that wrote it were removed (#171), so README line 195 is stale. host/game_layout.c only moves an old one into logs/.
  • Launcher PR 42 (Send report) reads longshot_log.txt from the game folder. With #321 it has to look in logs/ first, then the game folder; I'll say so on that PR.

Issues

See #321

Checklist

For everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description).
  • Rebased on current main.
  • python -I -B tests/run_all.py run and passing (any failure that also fails on main is named above).
  • Tested in the game, or what wasn't is named under Testing.
  • Testing filled in: what was tested, what wasn't, and what needs other testers (with test requests). (the Windows test request is still to open)
  • Measured: main and this PR at named commits, on the same PC, scene and settings, at least 2 interleaved runs each, the median reported. (not a performance change; an in-game run is still to do)
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

If applicable

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
<!-- Open as work in progress (a "WIP: " title; forge.py pr create does it) and mark it ready (forge.py pr ready) once every section and every For everyone box is done. Keep this description current, and post a comment for each new commit, measurement or test run: CONTRIBUTING.md, "Commits and pull requests". --> ## Why #321 put `longshot_driver_faults.txt` in `cache/`, which the README says can be deleted. A player who clears it to fix something would lose the record of the shaders their driver faulted on, and run into the driver fault again, which on AMD's Windows driver froze the game (issue 996). This follow-up to #321's review also fixes a loose cache that can never move, and docs whose commands point at the old place. ## What changed - **What the game decided on this PC stays beside the settings**, not in `cache/`: `longshot_driver_faults.txt`, `longshot_prepare_skipped` and `longshot_load_start.txt` (with its `.waited`). - `driver_faults_path` and `load_fallback_path` in `gpu/vk/vk_draw.cpp`, and `skipped_path` in `vk_main.cpp`, now give the game folder. - `host/game_layout.c` no longer moves these into `cache/`. A folder #321 already moved has them moved back out (`records`). - **A loose cache that can never move is deleted** (`host/game_layout.c` `move_as`). When `cache/` already has its own copy (the first move failed, the file held open, and the game then made a new one), the loose one is deleted, and the log says how many files and MB. Logs are never deleted; a loose log stays, as before. - **Docs:** - `assets/pipeline_states/README.md` and `docs/development.md` now give `cache/longshot_pipeline_states.bin` in the `add` command and steps, which failed with the old path. - The README says what `cache` holds besides caches (the pipeline list you can send in) and what stays out of it. - `docs/development.md` describes the layout and what switching one game folder between a build from before #321 and one after it costs. - The `RX_VK_LOAD` and `RX_VK_DRIVER_FAULTS` rows give the game folder again. - **Comments** that still said "beside the executable" now name the folder: `vk_progcache.cpp`, `vk_draw.cpp`, `driver_faults.h`, `vk_main.cpp`. - **Tests:** - `tests/test_game_layout.py` checks that the records stay and move back out of `cache/`, that a loose cache with a `cache/` copy is deleted, and that a loose log stays. - `tests/test_load_default.py` checks that the marker is in the game folder. ## Flags and settings None. ## Measurements Not a performance change: files move between folders, and nothing is measured in frames. The checks below and a run in the game (Testing) are what count. main: cf605c85 (2026-11-14) this PR: fix/game-layout-followup @ d82f2026 ## Testing **Tested:** - `python -I -B tests/run_all.py` on Linux (Fedora 45): 484 passed. The four failures fail on a clean `main` too: `test_bake_portability`, `test_lift_cache` (this PC's Python has no numpy), `test_module_ids` and `test_pad_layout` (#331 fixes it). - `tests/test_game_layout.py`: the new cases, plus those from #321. - Windows with llvm-mingw 20261104, tools.lock's, cross-built on Linux: - the Vulkan back end, `longshot_vk.dll`, builds (`RX_TARGET=windows RX_VK_ONLY=1 nx2/build.py --standalone`); - 44 of the 49 `host/*.c` compile with the build's host flags, among them `hos_main.c`, `game_layout.c` and `prompts.c`; `game_layout.c` also passes `-Wall -Wextra -Werror`; - the other 5 need headers a game-free build doesn't have (FFmpeg, dav1d, opus, a field of the game's generated a64 header), and none is touched here. - The Linux back end builds (Ubuntu 24.04). **Not tested:** - A run in the game, on either system: this follow-up's moves back out of `cache/` on a folder #321 moved, and the deletion of a loose cache that couldn't move. - Windows, end to end: renames on NTFS (`MoveFileExA`, `FindFirstFileA` with `*.tmp-*`), the log rotation into `logs\` in `game_main`, a file held open while the game moves it. Not run on Windows yet, for #321 or this PR. **Needs other testers:** - Windows: update a launcher-built game folder with `--cli --update`, then play it. Expect: - the caches in `cache\` (`longshot_vk_pipelines.bin`), the logs in `logs\`, `longshot_driver_faults.txt` beside the game; - the shaders not prepared again; - a log written in `logs\` when started by the launcher. (request to open) ## Screenshots Nothing on screen. ## Risk and rollback A loose cache file is deleted only when `cache/` has a file of the same name. It's a cache, so the worst case is the game making it again (a shader preparation, minutes). Logs are never deleted. The records move only out of `cache/` into the game folder, never over a file there. Reverting the commit puts them back in `cache/` on the next start of a build with #321's list. ## Reviewer notes The rest of #321's review: - **`longshot_startup.log`:** nothing writes it on `main`, here or in the launcher. The Linux builder's play diagnostics that wrote it were removed (#171), so README line 195 is stale. `host/game_layout.c` only moves an old one into `logs/`. - **Launcher PR 42** (Send report) reads `longshot_log.txt` from the game folder. With #321 it has to look in `logs/` first, then the game folder; I'll say so on that PR. ## Issues See #321 ## Checklist ### For everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`). - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` run and passing (any failure that also fails on `main` is named above). - [x] Tested in the game, or what wasn't is named under Testing. - [ ] Testing filled in: what was tested, what wasn't, and what needs other testers (with test requests). (the Windows test request is still to open) - [ ] Measured: main and this PR at named commits, on the same PC, scene and settings, at least 2 interleaved runs each, the median reported. (not a performance change; an in-game run is still to do) - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### If applicable - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated.
fix(game): what the game decided on this PC stays beside the settings, and a loose cache that cannot move is deleted
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 3s
Website / Website on Cloudflare (pull_request_target) Has been skipped
d82f2026a9
Review of #321. longshot_driver_faults.txt, longshot_prepare_skipped and
longshot_load_start.txt are no caches: the programs the driver faulted
on (re-asked, one froze AMD's Windows driver, issue 996), the player's
skipped preparation and the load mode this PC fell back to. In cache/,
which the README says can be deleted, a player clearing it would meet
the fault again. They are back in the game folder, and a folder #321
already moved has them moved back out (host/game_layout.c records).

A loose cache whose cache/ has its own could never move (its first move
failed, say a 7.8 GB longshot_programs.bin held open by an antivirus,
and the game then made a new one in cache/): it is deleted, and the log
says how much. A loose log is never deleted.

The docs whose commands named the state list's old place
(assets/pipeline_states/README.md, docs/development.md) give cache/;
the README says what cache/ holds besides caches and what stays out of
it; docs/development.md says what switching one game folder between a
build before #321 and one after it costs. Comments that still said
"beside the executable" name the folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 3s
Website / Website on Cloudflare (pull_request_target) Has been skipped
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/game-layout-followup:lndf-fix/game-layout-followup'
git switch 'lndf-fix/game-layout-followup'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!345
No description provided.