fix(gpu): find target\shader-replace from target\release\larp.exe #586

Open
github-bot wants to merge 1 commit from github-bot/gh-586 into main AGit
Owner

@⁠eipastel on GitHub · 2026-12-06 03:21 UTC · original
eipastel:fix/shader-replace-build-folder → main · +40 −7 · 1 files · 1 commits · open

Fixes #585.

Related: #584 documents setting LARP_SHADER_REPLACE to target\shader-replace for source builds, which this PR makes unnecessary; whichever merges second, I'll update #584 to match.

Root cause

folder() (crates/larp-gpu/src/shader_replace.rs) tried <exe folder>\shader-replace and <exe folder>\..\..\shader-replace. Two levels up from the exe is target only for cargo build --target ... (target\<target>\<profile>\larp.exe). The documented cargo build --release -p larp writes target\release\larp.exe, so two levels up is the repo root and target\shader-replace, where build.rs writes the compiled replacements, was never tried: larp run stopped with no replacement shaders unless LARP_SHADER_REPLACE was set.

Change

Also try <exe folder>\..\shader-replace, between the two. The order is otherwise unchanged, so a distribution's bin\shader-replace still wins and --target builds still find theirs. The candidate list moved into looked_for, with a unit test for both build layouts; module and function docs updated.

How it was tested

  • cargo test -p larp-gpu: 32 passed, 7 ignored (includes the new shader_replace::tests::looks_in_target_shader_replace_from_a_plain_cargo_build).
  • cargo clippy -p larp-gpu: no warning in the changed lines (the crate has 47 existing warnings).
  • cargo fmt: rustfmt --check shows no diff in the changed lines. I did not run cargo fmt on the crate: on main it rewrites 107 files of larp-gpu.
  • cargo build --release -p larp, then target\release\larp.exe run "<game>" --execute --console series-s with LARP_SHADER_REPLACE unset, on Windows 11 build 26300 / RTX 5060: before, Error: no replacement shaders: none of these folders exists: ...\target\release\shader-replace, ...\shader-replace; after, shader replacements: folder read folder=...\target\shader-replace usable=85 with_structure_views=64 with_interface=5 refused=0. I ran it to the menu (60 s), not into the world.
  • Not tested: a distribution layout (Larp\bin\larp.exe) or a --target build in a real run (covered by the unit test only).

Written with AI assistance (Claude Code).

**@⁠eipastel** on GitHub · 2026-12-06 03:21 UTC · [original](https://github.com/gamingwithhomie/larp/pull/586) `eipastel:fix/shader-replace-build-folder` → `main` · +40 −7 · 1 files · 1 commits · open Fixes #585. Related: #584 documents setting `LARP_SHADER_REPLACE` to `target\shader-replace` for source builds, which this PR makes unnecessary; whichever merges second, I'll update #584 to match. ## Root cause `folder()` (`crates/larp-gpu/src/shader_replace.rs`) tried `<exe folder>\shader-replace` and `<exe folder>\..\..\shader-replace`. Two levels up from the exe is `target` only for `cargo build --target ...` (`target\<target>\<profile>\larp.exe`). The documented `cargo build --release -p larp` writes `target\release\larp.exe`, so two levels up is the repo root and `target\shader-replace`, where `build.rs` writes the compiled replacements, was never tried: `larp run` stopped with `no replacement shaders` unless `LARP_SHADER_REPLACE` was set. ## Change Also try `<exe folder>\..\shader-replace`, between the two. The order is otherwise unchanged, so a distribution's `bin\shader-replace` still wins and `--target` builds still find theirs. The candidate list moved into `looked_for`, with a unit test for both build layouts; module and function docs updated. ## How it was tested - `cargo test -p larp-gpu`: 32 passed, 7 ignored (includes the new `shader_replace::tests::looks_in_target_shader_replace_from_a_plain_cargo_build`). - `cargo clippy -p larp-gpu`: no warning in the changed lines (the crate has 47 existing warnings). - `cargo fmt`: `rustfmt --check` shows no diff in the changed lines. I did not run `cargo fmt` on the crate: on `main` it rewrites 107 files of `larp-gpu`. - `cargo build --release -p larp`, then `target\release\larp.exe run "<game>" --execute --console series-s` with `LARP_SHADER_REPLACE` unset, on Windows 11 build 26300 / RTX 5060: before, `Error: no replacement shaders: none of these folders exists: ...\target\release\shader-replace, ...\shader-replace`; after, `shader replacements: folder read folder=...\target\shader-replace usable=85 with_structure_views=64 with_interface=5 refused=0`. I ran it to the menu (60 s), not into the world. - Not tested: a distribution layout (`Larp\bin\larp.exe`) or a `--target` build in a real run (covered by the unit test only). Written with AI assistance (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 03:23:58 +00:00
Author
Owner

@⁠wagney on GitHub · 2026-12-06 03:39 UTC · original · reviewed

Reviewed \crates/larp-gpu/src/shader_replace.rs. Checking \t.parent()\ between the executable's own folder and ..\..\shader-replace\ cleanly covers \ arget\\larp.exe\ while preserving distribution and --target\ layouts, and \looks_in_target_shader_replace_from_a_plain_cargo_build\ verifies both paths.

**@⁠wagney** on GitHub · 2026-12-06 03:39 UTC · [original](https://github.com/gamingwithhomie/larp/pull/586#pullrequestreview-6208126964) · **reviewed** Reviewed \crates/larp-gpu/src/shader_replace.rs\. Checking \t.parent()\ between the executable's own folder and \..\\..\\shader-replace\ cleanly covers \ arget\\<profile>\\larp.exe\ while preserving distribution and \--target\ layouts, and \looks_in_target_shader_replace_from_a_plain_cargo_build\ verifies both paths.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/586/head:github-bot/gh-586'
git switch 'github-bot/gh-586'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-586'
git switch 'github-bot/gh-586'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-586'
git switch 'github-bot/gh-586'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-586'
git switch 'main'
git merge --squash 'github-bot/gh-586'
git switch 'main'
git merge --ff-only 'github-bot/gh-586'
git switch 'main'
git merge 'github-bot/gh-586'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.