Shader cache: fingerprint the running build’s source tree #3799

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

@⁠akimfomin on GitHub · 2026-11-30 07:29 UTC · original
akimfomin:codex/shader-fingerprint-source-root → main · +3 −1 · 1 files · 1 commits · open

What it changes

The shader fingerprint build script now reads Cargo’s source directory when the script runs. A shared target directory can reuse the compiled script across worktrees. A path captured at compile time can then scan the earlier checkout and publish the wrong shader fingerprint and switch list.

How it was tested

  • This build-script check uses generated source and does not need a game or GPU.
  • I compiled the original and patched scripts with the same first source directory, then ran them with a second directory containing a different marker. The original printed the first marker. The patched script printed the second.
  • The 12 shader-cache tests passed in VIctory-NVIDIA-Lab after the fix, including the switch-list test that exposed it. A full upstream workspace run is pending.

Checked for overlap

  • Searched open PRs for the manifest-directory lookup and shader fingerprint. The closest RT work is #3706. This patch applies independently of it.

Found in the Lab’s RT investigation. Prepared with Codex.

Fixes #

What it changes

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing):
  • Before:
  • After:
  • For shader changes, the wave sizes tested (32 and/or 64 lanes):
  • cargo test passed for the crates it touches: yes / no

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #
**@⁠akimfomin** on GitHub · 2026-11-30 07:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3799) `akimfomin:codex/shader-fingerprint-source-root` → `main` · +3 −1 · 1 files · 1 commits · open ## What it changes The shader fingerprint build script now reads Cargo’s source directory when the script runs. A shared target directory can reuse the compiled script across worktrees. A path captured at compile time can then scan the earlier checkout and publish the wrong shader fingerprint and switch list. ## How it was tested - This build-script check uses generated source and does not need a game or GPU. - I compiled the original and patched scripts with the same first source directory, then ran them with a second directory containing a different marker. The original printed the first marker. The patched script printed the second. - The 12 shader-cache tests passed in VIctory-NVIDIA-Lab after the fix, including the switch-list test that exposed it. A full upstream workspace run is pending. ## Checked for overlap - [x] Searched open PRs for the manifest-directory lookup and shader fingerprint. The closest RT work is #3706. This patch applies independently of it. Found in the [Lab’s RT investigation](https://github.com/akimfomin/VIctory-NVIDIA-Lab/issues/8). Prepared with Codex.<!-- Thanks for the pull request. Please label it (pr-fix, pr-feature, pr-performance, pr-diagnostics, pr-refactor, pr-docs or pr-tests, plus the area labels), or put the label in the title, like [pr-fix]. --> Fixes # ## What it changes <!-- What was wrong, and what this does about it. --> ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): - Before: - After: - For shader changes, the wave sizes tested (32 and/or 64 lanes): - `cargo test` passed for the crates it touches: yes / no ## Checked for overlap - [ ] I searched the open pull requests for the same issue and for the files this touches. Related: #
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 07:34:34 +00:00
Author
Owner

@⁠babuakhil on GitHub · 2026-11-30 17:16 UTC · original

Checked on Windows 11 with Cargo 1.98.1 (pinned), on main (84bd61e2), alone and together with #4001, which touches the same build.rs. The bug is real, and this fixes it.

Two git worktrees of the same commit, one shared CARGO_TARGET_DIR, and cargo check -p victory-shader in each. The first worktree is left clean and the second has a comment appended to src/emit/lower.rs. A one-checkout build with that same edit fingerprints 605158a35e43…; clean is 34c7428dd60d…:

first worktree second worktree (edited) build-script directory
main 34c7428dd60d 34c7428dd60d, the first worktree's the same victory-shader-a7c8c7faba94125b for both
#4001 only 34c7428dd60d 34c7428dd60d, and its run now watches D:\zz-wt1\…\emit\lower.rs, the first worktree's file the same
this PR 34c7428dd60d 605158a35e43, correct the same
this PR + #4001 34c7428dd60d 605158a35e43, correct, and watches D:\zz-wt2\… the same

So Cargo does reuse the compiled build script across the two checkouts (same build directory each time), and env!("CARGO_MANIFEST_DIR") then scans the first one. Reading the variable when the script runs fixes it. In the one-checkout case, this PR fingerprints exactly as main does. Clippy reports nothing in build.rs.

Since #4001 alone would make the script watch the other checkout's files, if both are taken this one should go first. Together they behave correctly.

**@⁠babuakhil** on GitHub · 2026-11-30 17:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3799#issuecomment-7286004579) Checked on Windows 11 with Cargo 1.98.1 (pinned), on `main` (`84bd61e2`), alone and together with #4001, which touches the same `build.rs`. The bug is real, and this fixes it. Two git worktrees of the same commit, one shared `CARGO_TARGET_DIR`, and `cargo check -p victory-shader` in each. The first worktree is left clean and the second has a comment appended to `src/emit/lower.rs`. A one-checkout build with that same edit fingerprints `605158a35e43…`; clean is `34c7428dd60d…`: | | first worktree | second worktree (edited) | build-script directory | |---|---|---|---| | `main` | `34c7428dd60d` | **`34c7428dd60d`**, the first worktree's | the same `victory-shader-a7c8c7faba94125b` for both | | #4001 only | `34c7428dd60d` | **`34c7428dd60d`**, and its run now watches `D:\zz-wt1\…\emit\lower.rs`, the *first* worktree's file | the same | | this PR | `34c7428dd60d` | `605158a35e43`, correct | the same | | this PR + #4001 | `34c7428dd60d` | `605158a35e43`, correct, and watches `D:\zz-wt2\…` | the same | So Cargo does reuse the compiled build script across the two checkouts (same build directory each time), and `env!("CARGO_MANIFEST_DIR")` then scans the first one. Reading the variable when the script runs fixes it. In the one-checkout case, this PR fingerprints exactly as `main` does. Clippy reports nothing in `build.rs`. Since #4001 alone would make the script watch the other checkout's files, if both are taken this one should go first. Together they behave correctly.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/3799/head:github-bot/gh-3799'
git switch 'github-bot/gh-3799'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3799'
git switch 'github-bot/gh-3799'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3799'
git switch 'github-bot/gh-3799'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3799'
git switch 'main'
git merge --squash 'github-bot/gh-3799'
git switch 'main'
git merge --ff-only 'github-bot/gh-3799'
git switch 'main'
git merge 'github-bot/gh-3799'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
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
github/trustno1-coder--VIctory-NVIDIA!3799
No description provided.