Count a shader-cache hit from this call's flag, not the shared miss counter (#32) #175

Open
ri995410-art wants to merge 1 commit from upstream-pr/175 into main
ri995410-art commented 2026-11-26 10:24:33 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by ri995410-art on 2026-11-26T10:24:33Z.


Fixes #32.

victory translate --warm classifies each shader as "translated now" vs. "in the cache already" from victory_gpu::shader_cache::precompile's returned bool. Previously, precompile computed that bool by checking whether the process-wide MISSES counter changed around the call, so with the default four workers a miss on another thread between the two loads turned this thread's cache hit into "translated now".

Changes

  • crates/victory-gpu/src/shader_cache.rs:
    • cached and cached_by now return Result<(HostShader, bool), String>, exposing the converter's existing per-call ran flag.
    • precompile returns !ran when a cache is open, and false when no cache is open (where this call translated), removing the global MISSES diff and stale comment.
    • host_shader discards the flag so existing callers are unchanged.
    • Added a_cache_hit_is_not_a_miss_when_another_thread_misses, which verifies a cached lookup still reports a hit while another thread concurrently triggers misses and increments MISSES.

Verification

  • cargo clippy --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --locked -- -D warnings (both default and --all-features) passed.
  • Cross-compiled victory-gpu tests with x86_64-pc-windows-gnu and ran shader_cache::tests:: under Wine: 4 passed, 0 failed (including the new concurrency test).
  • cargo xtask policy: 262 files ok.
  • No game run; no game files touched.

Closes #32

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6624561658 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/175). Originally posted by [ri995410-art](https://github.com/ri995410-art) on 2026-11-26T10:24:33Z. --- Fixes #32. `victory translate --warm` classifies each shader as "translated now" vs. "in the cache already" from `victory_gpu::shader_cache::precompile`'s returned `bool`. Previously, `precompile` computed that `bool` by checking whether the process-wide `MISSES` counter changed around the call, so with the default four workers a miss on another thread between the two loads turned this thread's cache hit into "translated now". ## Changes - `crates/victory-gpu/src/shader_cache.rs`: - `cached` and `cached_by` now return `Result<(HostShader, bool), String>`, exposing the converter's existing per-call `ran` flag. - `precompile` returns `!ran` when a cache is open, and `false` when no cache is open (where this call translated), removing the global `MISSES` diff and stale comment. - `host_shader` discards the flag so existing callers are unchanged. - Added `a_cache_hit_is_not_a_miss_when_another_thread_misses`, which verifies a cached lookup still reports a hit while another thread concurrently triggers misses and increments `MISSES`. ## Verification - `cargo clippy --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --locked -- -D warnings` (both default and `--all-features`) passed. - Cross-compiled `victory-gpu` tests with `x86_64-pc-windows-gnu` and ran `shader_cache::tests::` under Wine: 4 passed, 0 failed (including the new concurrency test). - `cargo xtask policy`: `262 files ok`. - No game run; no game files touched. Closes #32
Calvix2k commented 2026-11-26 10:40:09 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Calvix2k on 2026-11-26T10:40:09Z.


Independent confirmation from the other side of the same bug: a warm run here logs "shader translated" 3,332 times while the pipeline library at the same moment reports made=0 loaded=2,287 - every cache hit was counted as a translation. That made the number useless exactly where it matters, deciding whether a first run was cold (a cold run is 2-3x slower until victory warm has run). The per-call flag is the right source.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7189672692 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/175#issuecomment-7189672692). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-26T10:40:09Z. --- Independent confirmation from the other side of the same bug: a warm run here logs "shader translated" 3,332 times while the pipeline library at the same moment reports `made=0 loaded=2,287` - every cache hit was counted as a translation. That made the number useless exactly where it matters, deciding whether a first run was cold (a cold run is 2-3x slower until `victory warm` has run). The per-call flag is the right source.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/175:upstream-pr/175'
git switch 'upstream-pr/175'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/175'
git switch 'upstream-pr/175'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/175'
git switch 'upstream-pr/175'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/175'
git switch 'main'
git merge --squash 'upstream-pr/175'
git switch 'main'
git merge --ff-only 'upstream-pr/175'
git switch 'main'
git merge 'upstream-pr/175'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
avatarmanz/VIctory-7900XTX!175
No description provided.