GPU: an unwritable shader cache still hands back its translation (port of upstream #2055) #1325

Closed
github-bot wants to merge 1 commit from github-bot/gh-1325 into main AGit
Owner

@⁠CwWwWwW on GitHub · 2026-11-26 15:29 UTC · original
CwWwWwW:port/shader-cache-unwritable → main · +61 −8 · 1 files · 1 commits · closed without merging

Problem

A shader cache entry that cannot be written - its folder replaced by a file, the disk full, a scanner holding the file - makes victory_pipeline::Cache::get_or_convert return an error after the translation has already run. shader_cache::cached propagated that error with ?, so the translation was made once and then lost: the shader never got a host pipeline for the run, and its draws were dropped even though the work had succeeded.

Upstream VIctory fixed this in commit bca3ecd (pull request #2055, by Flare); this is that fix ported and adapted to the fork.

Change

  • Translate keeps the HostShader its conversion made.
  • A cache error is logged and the entry left for a later run instead of failing the shader.
  • An entry that was just written is handed back from the converter rather than read back (the first read of a new file costs about as much as a small translation where a virus scanner looks at it: 0.5-3 ms here).
  • Fork difference: this fork's encode takes a HostShader (a refusal is not cached), so only a successful translation is kept.

Tests

  • New a_translation_is_made_once_when_its_entry_cannot_be_written: the cache root is replaced by a file, so create_dir_all fails. Before the change this test fails with Err(... os error 183); with it the translation is returned and the converter ran exactly once.
  • cargo test -p victory-gpu --lib --locked: 218 passed, 0 failed, 6 ignored.
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean.
  • No game or GPU needed: the test drives cached and a cache folder only.

(CI note: the check job on main is currently red on the asset-policy violation; #1322 fixes that, after which this can be rebased.)

**@⁠CwWwWwW** on GitHub · 2026-11-26 15:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/1325) `CwWwWwW:port/shader-cache-unwritable` → `main` · +61 −8 · 1 files · 1 commits · closed without merging ## Problem A shader cache entry that cannot be written - its folder replaced by a file, the disk full, a scanner holding the file - makes `victory_pipeline::Cache::get_or_convert` return an error after the translation has already run. `shader_cache::cached` propagated that error with `?`, so the translation was made once and then lost: the shader never got a host pipeline for the run, and its draws were dropped even though the work had succeeded. Upstream VIctory fixed this in [commit bca3ecd](https://github.com/Marvisak/VIctory/commit/bca3ecd) (pull request #2055, by **Flare**); this is that fix ported and adapted to the fork. ## Change - `Translate` keeps the `HostShader` its conversion made. - A cache error is logged and the entry left for a later run instead of failing the shader. - An entry that was just written is handed back from the converter rather than read back (the first read of a new file costs about as much as a small translation where a virus scanner looks at it: 0.5-3 ms here). - Fork difference: this fork's `encode` takes a `HostShader` (a refusal is not cached), so only a successful translation is kept. ## Tests - New `a_translation_is_made_once_when_its_entry_cannot_be_written`: the cache root is replaced by a file, so `create_dir_all` fails. Before the change this test fails with `Err(... os error 183)`; with it the translation is returned and the converter ran exactly once. - `cargo test -p victory-gpu --lib --locked`: **218 passed, 0 failed, 6 ignored**. - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: clean. - No game or GPU needed: the test drives `cached` and a cache folder only. (CI note: the `check` job on main is currently red on the asset-policy violation; #1322 fixes that, after which this can be rebased.)
Ported from upstream VIctory commit bca3ecd (pull request #2055, Flare):
a cache entry that cannot be written (its folder is a file, the disk is
full, a scanner holds it) made victory_pipeline::Cache::get_or_convert
fail, and cached propagated that error: the shader was translated once
and then lost for the run - every pipeline behind it dropped, though the
translation itself had been made.

The converter keeps the translation it just made (Translate.made), the
cache error leaves the entry for a later run instead of failing the
shader, and the caller gets the translation without reading the entry
back (the first read of a new file costs about as much as a small
translation where a virus scanner looks at it: 0.5-3 ms here).

Adapted to this fork: its encode takes a HostShader (a refusal is not
cached), so the made translation is stored only when the conversion
succeeds.

Test: a_translation_is_made_once_when_its_entry_cannot_be_written (the
cache root is a file). It fails before the change ("when the file
already exists ... os error 183") and passes after; the translation runs
once.

cargo test -p victory-gpu --lib: 218 passed, 0 failed, 6 ignored;
cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 15:35:16 +00:00
github-bot closed this pull request 2026-11-26 15:52:08 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.