GPU: fix 3 encoding, fallback, and slice-panic bugs in shader_cache.rs with unit tests #1034

Open
opened 2026-11-26 04:17:46 +00:00 by github-bot · 1 comment
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 15:14 UTC · original

Summary

Fixes 3 real bugs in crates/victory-gpu/src/shader_cache.rs and expands deterministic synthetic unit tests from 2 to 12 passing tests.

Because external PR creation is currently restricted (collaborators_only), the CI-green branch is ready on my fork for cherry-pick / review:

  • Branch: geiyiliyabumo/VIctory@test/gpu-shader-cache
  • Commit: geiyiliyabumo/VIctory@f4c4bd4 (based on main ffe310e)

Bugs Fixed (crates/victory-gpu/src/shader_cache.rs)

  1. RootType::Other(x) was encoded as 6 + x, causing Other(u32::MAX) to panic in debug and wrap into a named tag in release. Now encoded as tag word OTHER_ROOT = 6 followed by the raw u32 value (lossless, unknown tags rejected).
  2. An unwritable/full-disk cache previously failed get_or_convert even after translation succeeded. Cache publication is now best-effort, reusing the translated result via OnceLock without translating twice.
  3. convert sliced &input[32..] unconditionally (panicking on short input); now uses split_at_checked(BUILD_LEN) and returns an error.

Verification (Windows 11 x64 MSVC)

  • rustfmt --edition 2024 --check crates/victory-gpu/src/shader_cache.rs: PASS
  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default + --features diagnostics): PASS (0 warnings)
  • cargo test -p victory-gpu --locked -- shader_cache::: 12 passed, 0 failed

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 15:14 UTC · [original](https://github.com/Marvisak/VIctory/issues/1034) ### Summary Fixes 3 real bugs in `crates/victory-gpu/src/shader_cache.rs` and expands deterministic synthetic unit tests from 2 to **12 passing tests**. Because external PR creation is currently restricted (`collaborators_only`), the CI-green branch is ready on my fork for cherry-pick / review: - **Branch**: `geiyiliyabumo/VIctory@test/gpu-shader-cache` - **Commit**: `geiyiliyabumo/VIctory@f4c4bd4` (based on `main` `ffe310e`) ### Bugs Fixed (`crates/victory-gpu/src/shader_cache.rs`) 1. `RootType::Other(x)` was encoded as `6 + x`, causing `Other(u32::MAX)` to panic in debug and wrap into a named tag in release. Now encoded as tag word `OTHER_ROOT = 6` followed by the raw `u32` value (lossless, unknown tags rejected). 2. An unwritable/full-disk cache previously failed `get_or_convert` even after translation succeeded. Cache publication is now best-effort, reusing the translated result via `OnceLock` without translating twice. 3. `convert` sliced `&input[32..]` unconditionally (panicking on short input); now uses `split_at_checked(BUILD_LEN)` and returns an error. ### Verification (Windows 11 x64 MSVC) - `rustfmt --edition 2024 --check crates/victory-gpu/src/shader_cache.rs`: **PASS** - `cargo xtask policy`: **PASS** (`154 files ok`) - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default + `--features diagnostics`): **PASS** (0 warnings) - `cargo test -p victory-gpu --locked -- shader_cache::`: **12 passed, 0 failed** *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:17:46 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 07:00 UTC · original

Automated triage for the maintainers.

Fixed in main: a failed cache write no longer fails the translation. cached in crates/victory-gpu/src/shader_cache.rs (rewritten in c47b529, "Shader warm-up (translate --cache), a cache keyed by the translator") logs "shader cache entry not written" and translates without the cache. The other two cases cannot happen there: cached always prepends the 32-byte build fingerprint before convert slices it, and no root type tag comes near u32::MAX. The pull request for this branch, #1200, was closed for the same reasons.

This issue will be closed in 48 hours unless the reporter replies or a maintainer removes the label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 07:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/1034#issuecomment-7155388062) <!-- victory-issue-triage v1 verdict=proposed-close seen=2026-11-24T15:14:32Z at=2026-11-25T07:00:31Z --> Automated triage for the maintainers. Fixed in `main`: a failed cache write no longer fails the translation. `cached` in `crates/victory-gpu/src/shader_cache.rs` (rewritten in `c47b529`, "Shader warm-up (translate --cache), a cache keyed by the translator") logs "shader cache entry not written" and translates without the cache. The other two cases cannot happen there: `cached` always prepends the 32-byte build fingerprint before `convert` slices it, and no root type tag comes near `u32::MAX`. The pull request for this branch, #1200, was closed for the same reasons. This issue will be closed in 48 hours unless the reporter replies or a maintainer removes the label. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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/Marvisak--VIctory#1034
No description provided.