Pipeline book loses masked pixel variants, leaving warm --used without twin recipes #3860

Open
opened 2026-11-30 09:34:56 +00:00 by github-bot · 5 comments
Owner

@⁠SergDi on GitHub · 2026-11-30 09:32 UTC · original

Problem

On 41adb55167fa778fcaa5dc36fa18a1fa8dacd657 (v2026.11.29.05), masked pixel-shader twins do not have reconstructible recipes in the known-pipeline book. Consequently warm --used and recipe-based prefetch cannot prepare those variants ahead of their first runtime request.

This is a code-level cache/serialization reproduction, not a claim of measured FPS loss or disappearing geometry. I searched existing issues/PRs for masked twins, known-book serialization and warm coverage; #1407 introduces sample-mask behavior, but I did not find a report of this recipe gap.

Code path

  1. host_pipeline_masked creates a Pending with Shader::masked() and goes through made_or_start, which records the used key. It does not call known::note; the ordinary hand_out path does.
  2. Adding that note alone is insufficient: Book::note stores stage plus container hash, without the masked flag. The twin and plain shader share the container.
  3. known::parse reconstructs the ordinary shader. A manually noted masked recipe therefore comes back with the plain Pending key.

Pinned locations: masked creation, book serialization, recipe reconstruction.

Synthetic reproduction

The test-only patch below explicitly notes a plain pixel pipeline and its twin in a scratch book, flushes it, reads both recipes and reconstructs their Pending keys. Input is an arbitrary synthetic byte string; it does not translate or dispatch a title shader and needs no game data.

# On a clean checkout of 41adb551, apply masked-test.patch, then:
cargo test --locked --release -p victory-gpu --lib pipeline::known::tests::a_masked_twin_comes_back_masked -- --test-threads=1 --nocapture

Expected: both distinct keys survive. Observed RED: the masked twin comes back as the plain pipeline (only the plain reconstructed key remains). Windows 11 26200, pinned toolchain, RTX 4080 system; this is a serialization test, not a GPU execution test.

Proposal for maintainer input

A local, undeployed prototype records the twin at creation and preserves a MASKED=0x80 bit in each pipeline entry's stage byte, restoring .masked() on read. It makes this test pass; pipeline::known passes 6 tests and pipeline::make passes 30. This is not a production-ready compatibility claim: old/new reader combinations, graphics/mesh recipes and an end-to-end warm run still need tests. An older reader would skip an entry with the flagged stage rather than reconstruct it, by the current parser's bounds check; that behavior has not been tested as a compatibility contract.

Would a stage flag be acceptable, or should this be a versioned recipe field? I have a test and local prototype; I have not deployed a format change or opened a fix PR.

Runtime limits

This does not mean a twin is driver-compiled on every launch. The persistent host pipeline library can load a previously created twin; the driver cache may also accelerate creation. The demonstrated defect is missing recipe coverage. While a twin is unavailable the draw falls back to the ordinary pipeline, so missing geometry is not established here. Measuring benefit requires separating first requests, library hits, actual creations and guard deferrals for masked variants.

AI assistance: Claude prepared the synthetic reproduction and prototype and ran the Windows tests; Codex reviewed the evidence and wording. No game assets, screenshots, memory dumps or raw runtime logs are included.

masked-test.patch (test only)
diff --git a/crates/victory-gpu/src/pipeline/known.rs b/crates/victory-gpu/src/pipeline/known.rs
index 38e09261..b092b366 100644
--- a/crates/victory-gpu/src/pipeline/known.rs
+++ b/crates/victory-gpu/src/pipeline/known.rs
@@ -668,6 +668,40 @@ mod tests {
         let _ = std::fs::remove_dir_all(&dir);
     }
 
+    /// A pipeline drawn under the console's sample mask (its pixel shader's
+    /// twin, hash "-mask") noted next to its plain pipeline comes back from
+    /// the files as itself: warm and the in-run prefetch build what was read.
+    #[test]
+    fn a_masked_twin_comes_back_masked() {
+        let dir = scratch("masked");
+        let plain = super::super::shader("pixel", b"known test masked twin");
+        let twin = plain.masked();
+        let id = |key: &str| {
+            let mut id = [0u8; 16];
+            for (at, b) in id.iter_mut().enumerate() {
+                *b = key.get(2 * at..2 * at + 2).and_then(|x| u8::from_str_radix(x, 16).ok()).unwrap_or(0);
+            }
+            id
+        };
+        let plain_key = super::super::make::Pending::new(vec![plain.clone()], None).key().to_owned();
+        let twin_key = super::super::make::Pending::new(vec![twin.clone()], None).key().to_owned();
+        assert_ne!(plain_key, twin_key, "the twin is a pipeline of its own");
+        let mut book = Book::new(dir.clone());
+        book.read(HashSet::new(), HashSet::new());
+        book.note(id(&plain_key), std::slice::from_ref(&plain), None);
+        book.note(id(&twin_key), std::slice::from_ref(&twin), None);
+        flush(&Mutex::new(book));
+        let wanted: HashSet<String> = [&plain_key, &twin_key].iter().map(|k| k[..32].to_owned()).collect();
+        assert_eq!(keys(&dir).len(), 2, "both noted");
+        let back: HashSet<String> = recipes(&dir, &wanted)
+            .into_iter()
+            .map(|(shaders, g)| super::super::make::Pending::new(shaders, g).key().to_owned())
+            .collect();
+        let _ = std::fs::remove_dir_all(&dir);
+        assert!(back.contains(&plain_key), "the plain pipeline comes back");
+        assert!(back.contains(&twin_key), "the masked twin comes back as the plain pipeline: {back:?}");
+    }
+
     #[test]
     fn a_torn_end_is_cut_before_anything_is_added() {
         let dir = scratch("cut");
**@⁠SergDi** on GitHub · 2026-11-30 09:32 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3860) ## Problem On `41adb55167fa778fcaa5dc36fa18a1fa8dacd657` (v2026.11.29.05), masked pixel-shader twins do not have reconstructible recipes in the known-pipeline book. Consequently `warm --used` and recipe-based prefetch cannot prepare those variants ahead of their first runtime request. This is a code-level cache/serialization reproduction, not a claim of measured FPS loss or disappearing geometry. I searched existing issues/PRs for masked twins, known-book serialization and warm coverage; #1407 introduces sample-mask behavior, but I did not find a report of this recipe gap. ## Code path 1. `host_pipeline_masked` creates a Pending with `Shader::masked()` and goes through `made_or_start`, which records the used key. It does not call `known::note`; the ordinary `hand_out` path does. 2. Adding that note alone is insufficient: `Book::note` stores stage plus container hash, without the masked flag. The twin and plain shader share the container. 3. `known::parse` reconstructs the ordinary shader. A manually noted masked recipe therefore comes back with the plain Pending key. Pinned locations: [masked creation](https://github.com/trustno1-coder/VIctory-NVIDIA/blob/41adb55167fa778fcaa5dc36fa18a1fa8dacd657/crates/victory-gpu/src/pipeline.rs#L575), [book serialization](https://github.com/trustno1-coder/VIctory-NVIDIA/blob/41adb55167fa778fcaa5dc36fa18a1fa8dacd657/crates/victory-gpu/src/pipeline/known.rs#L88), [recipe reconstruction](https://github.com/trustno1-coder/VIctory-NVIDIA/blob/41adb55167fa778fcaa5dc36fa18a1fa8dacd657/crates/victory-gpu/src/pipeline/known.rs#L385). ## Synthetic reproduction The test-only patch below explicitly notes a plain pixel pipeline and its twin in a scratch book, flushes it, reads both recipes and reconstructs their Pending keys. Input is an arbitrary synthetic byte string; it does not translate or dispatch a title shader and needs no game data. ```powershell # On a clean checkout of 41adb551, apply masked-test.patch, then: cargo test --locked --release -p victory-gpu --lib pipeline::known::tests::a_masked_twin_comes_back_masked -- --test-threads=1 --nocapture ``` Expected: both distinct keys survive. Observed RED: `the masked twin comes back as the plain pipeline` (only the plain reconstructed key remains). Windows 11 26200, pinned toolchain, RTX 4080 system; this is a serialization test, not a GPU execution test. ## Proposal for maintainer input A local, undeployed prototype records the twin at creation and preserves a `MASKED=0x80` bit in each pipeline entry's stage byte, restoring `.masked()` on read. It makes this test pass; `pipeline::known` passes 6 tests and `pipeline::make` passes 30. This is not a production-ready compatibility claim: old/new reader combinations, graphics/mesh recipes and an end-to-end warm run still need tests. An older reader would skip an entry with the flagged stage rather than reconstruct it, by the current parser's bounds check; that behavior has not been tested as a compatibility contract. Would a stage flag be acceptable, or should this be a versioned recipe field? I have a test and local prototype; I have not deployed a format change or opened a fix PR. ## Runtime limits This does **not** mean a twin is driver-compiled on every launch. The persistent host pipeline library can load a previously created twin; the driver cache may also accelerate creation. The demonstrated defect is missing recipe coverage. While a twin is unavailable the draw falls back to the ordinary pipeline, so missing geometry is not established here. Measuring benefit requires separating first requests, library hits, actual creations and guard deferrals for masked variants. AI assistance: Claude prepared the synthetic reproduction and prototype and ran the Windows tests; Codex reviewed the evidence and wording. No game assets, screenshots, memory dumps or raw runtime logs are included. <details> <summary>masked-test.patch (test only)</summary> ```diff diff --git a/crates/victory-gpu/src/pipeline/known.rs b/crates/victory-gpu/src/pipeline/known.rs index 38e09261..b092b366 100644 --- a/crates/victory-gpu/src/pipeline/known.rs +++ b/crates/victory-gpu/src/pipeline/known.rs @@ -668,6 +668,40 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + /// A pipeline drawn under the console's sample mask (its pixel shader's + /// twin, hash "-mask") noted next to its plain pipeline comes back from + /// the files as itself: warm and the in-run prefetch build what was read. + #[test] + fn a_masked_twin_comes_back_masked() { + let dir = scratch("masked"); + let plain = super::super::shader("pixel", b"known test masked twin"); + let twin = plain.masked(); + let id = |key: &str| { + let mut id = [0u8; 16]; + for (at, b) in id.iter_mut().enumerate() { + *b = key.get(2 * at..2 * at + 2).and_then(|x| u8::from_str_radix(x, 16).ok()).unwrap_or(0); + } + id + }; + let plain_key = super::super::make::Pending::new(vec![plain.clone()], None).key().to_owned(); + let twin_key = super::super::make::Pending::new(vec![twin.clone()], None).key().to_owned(); + assert_ne!(plain_key, twin_key, "the twin is a pipeline of its own"); + let mut book = Book::new(dir.clone()); + book.read(HashSet::new(), HashSet::new()); + book.note(id(&plain_key), std::slice::from_ref(&plain), None); + book.note(id(&twin_key), std::slice::from_ref(&twin), None); + flush(&Mutex::new(book)); + let wanted: HashSet<String> = [&plain_key, &twin_key].iter().map(|k| k[..32].to_owned()).collect(); + assert_eq!(keys(&dir).len(), 2, "both noted"); + let back: HashSet<String> = recipes(&dir, &wanted) + .into_iter() + .map(|(shaders, g)| super::super::make::Pending::new(shaders, g).key().to_owned()) + .collect(); + let _ = std::fs::remove_dir_all(&dir); + assert!(back.contains(&plain_key), "the plain pipeline comes back"); + assert!(back.contains(&twin_key), "the masked twin comes back as the plain pipeline: {back:?}"); + } + #[test] fn a_torn_end_is_cut_before_anything_is_added() { let dir = scratch("cut"); ``` </details>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 09:34:56 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-30 09:32 UTC · original

Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

**@⁠github-actions[bot]** on GitHub · 2026-11-30 09:32 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3860#issuecomment-7274354178) Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-30 10:03 UTC · original

finding: the masked-twin recipe gap in #3860 is a small, synthetic-only, locally testable serialization case, but the fix is a persisted-format change (stage bit vs versioned recipe field) whose old-reader contract is untested, and the reporter already has a local prototype awaiting maintainer input. Holding off implementation to avoid a conflicting format PR; no game data involved. (AI-assisted: Hy4 flash)

**@⁠cloph-dsp** on GitHub · 2026-11-30 10:03 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3860#issuecomment-7275064018) finding: the masked-twin recipe gap in #3860 is a small, synthetic-only, locally testable serialization case, but the fix is a persisted-format change (stage bit vs versioned recipe field) whose old-reader contract is untested, and the reporter already has a local prototype awaiting maintainer input. Holding off implementation to avoid a conflicting format PR; no game data involved. (AI-assisted: Hy4 flash)
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-30 10:08 UTC · original

I checked the old/new reader interaction on Windows with the proposal's 0x80 bit in the pipeline entry's pixel stage byte. The shader-blob table stayed in the existing format. The fixture uses generated byte strings and serializes a graphics state, then calls known::recipes and compares the reconstructed Pending keys.

Book contents Main reader 41adb551 Reader with the pixel-stage flag
Three legacy recipes, including graphics and mesh 3/3 exact keys 3/3 exact keys
Mixed book with both masked variants and a plain recipe appended after reopen 4/6 exact keys 6/6 exact keys

The old reader skipped the two flagged recipes and continued reading later plain records. The old writer preserved every existing byte when it appended an ordinary record to the mixed book. The new reader rebuilt the exact masked key for both vertex/pixel and mesh/pixel recipes. The temporary reader also passed all six pipeline::known tests, including this fixture.

This supports the stage flag if the expected downgrade behavior is to leave masked warm recipes unavailable to the old release. Runtime recording of masked recipes and a full warm --used run remain to be checked.

If you reuse this compatibility regression case, please retain its authorship with Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-30 10:08 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3860#issuecomment-7275174803) I checked the old/new reader interaction on Windows with the proposal's `0x80` bit in the **pipeline entry's pixel stage byte**. The shader-blob table stayed in the existing format. The fixture uses generated byte strings and serializes a graphics state, then calls `known::recipes` and compares the reconstructed `Pending` keys. | Book contents | Main reader `41adb551` | Reader with the pixel-stage flag | | --- | --- | --- | | Three legacy recipes, including graphics and mesh | 3/3 exact keys | 3/3 exact keys | | Mixed book with both masked variants and a plain recipe appended after reopen | 4/6 exact keys | 6/6 exact keys | The old reader skipped the two flagged recipes and continued reading later plain records. The old writer preserved every existing byte when it appended an ordinary record to the mixed book. The new reader rebuilt the exact masked key for both vertex/pixel and mesh/pixel recipes. The temporary reader also passed all six `pipeline::known` tests, including this fixture. This supports the stage flag if the expected downgrade behavior is to leave masked warm recipes unavailable to the old release. Runtime recording of masked recipes and a full `warm --used` run remain to be checked. If you reuse this compatibility regression case, please retain its authorship with `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Author
Owner

@⁠SergDi on GitHub · 2026-11-30 10:38 UTC · original

Thanks @⁠andrewpozdnakov7-jpg — my independently prepared Windows compatibility tests agree with the old-reader behavior you reported. They also found one malformed-record check missing from my original local prototype.

Pinned reader/writer: 41adb551. All fixtures use generated byte strings; frozen record bytes are checked against the actual old and proposed writers, not taken from a title.

Tested case Observation
Proposed reader, legacy plain graphics/compute/amplification+mesh+pixel recipes Same keys and order; plain writer layout unchanged
Old reader, flagged pixel entry 0x81 inside a mixed book Skips that recipe only; preserves the rest and reads later appends
Old known::make on the flagged recipe Reports no host pipeline without calling the driver; the warm loop would keep listing it as to-make
Plain and masked twins, either note order Distinct exact keys; shared container written once
Unknown stages, short records, missing container, torn tail Tested entries skipped or torn tail repaired as appropriate; later valid recipes remain readable
Mask bit on vertex/mesh (0x80 / 0x87) Original prototype incorrectly accepts them; pixel-only validation rejects them

Windows results: old-reader tests 8/8; original prototype + compatibility tests 11 passed / 1 expected failure, a_mask_bit_on_a_stage_other_than_pixel_is_not_read; adding the pixel-only check gives 12/12. This correction concerns malformed-record robustness, not an observed gameplay defect.

cargo test --locked --release -p victory-gpu --lib pipeline::known -- --test-threads=1

Below are two separate patches, each applied independently to clean 41adb551: the old-reader experiment, and the combined local proposal with compatibility tests and pixel-only correction. Neither is deployed. The stage-bit/versioning choice remains with the maintainer. My tests do not establish compatibility with every older release, alternating old/new writers in a full application run, or end-to-end warm --used benefit. The persistent host pipeline library may already load a twin.

Strict Clippy reported 24 diagnostics with none in the changed regions; I did not rerun a matched clean baseline for this task, so I do not claim a clean/no-new-lint gate.

AI assistance: Claude prepared the fixtures/proposal and ran the Windows tests; Codex reviewed the results. These patches contain synthetic data only.

old-reader-observed.patch — experiment on clean 41adb551
diff --git a/crates/victory-gpu/src/pipeline/known.rs b/crates/victory-gpu/src/pipeline/known.rs
index 38e09261..0acef32f 100644
--- a/crates/victory-gpu/src/pipeline/known.rs
+++ b/crates/victory-gpu/src/pipeline/known.rs
@@ -688,4 +688,163 @@ mod tests {
         assert_eq!(walk_shaders(&dir, |_, _, _, _| ()), 37 + 12);
         let _ = std::fs::remove_dir_all(&dir);
     }
+
+    // The book's records written byte by byte from the layout in the module
+    // docs, not by `Book::note`: readers are checked against the layout, and
+    // `the_book_writes_the_frozen_layout` checks the writer against it.
+
+    /// A `known-shaders.bin` record: stage, BLAKE3 of the container, length,
+    /// container.
+    fn frozen_shader(stage: u8, container: &[u8]) -> Vec<u8> {
+        let mut out = vec![stage];
+        out.extend(blake3::hash(container).as_bytes());
+        out.extend((container.len() as u32).to_le_bytes());
+        out.extend(container);
+        out
+    }
+
+    /// A `known-pipelines.bin` record: length, key, shader count, a stage byte
+    /// and BLAKE3 per shader, whether a graphics state follows, the state.
+    fn frozen_pipeline(id: [u8; 16], parts: &[(u8, &[u8])], state: Option<&[u8]>) -> Vec<u8> {
+        let mut entry = id.to_vec();
+        entry.push(parts.len() as u8);
+        for (stage, container) in parts {
+            entry.push(*stage);
+            entry.extend(blake3::hash(container).as_bytes());
+        }
+        entry.push(u8::from(state.is_some()));
+        entry.extend(state.unwrap_or_default());
+        let mut out = (entry.len() as u32).to_le_bytes().to_vec();
+        out.extend(entry);
+        out
+    }
+
+    fn default_state() -> Vec<u8> {
+        let mut bytes = Vec::new();
+        GraphicsState::default().put(&mut bytes);
+        bytes
+    }
+
+    /// The key a run gives these shaders under the default graphics state
+    /// (`None`: a compute pipeline).
+    fn key_of(shaders: &[Arc<Shader>], graphics: bool) -> String {
+        let g = graphics.then(|| Box::new(GraphicsState::default()));
+        super::super::make::Pending::new(shaders.to_vec(), g).key().to_owned()
+    }
+
+    /// The keys of what `recipes` reads back for every key in `dir`, in order.
+    fn read_back(dir: &Path) -> Vec<String> {
+        let wanted: HashSet<String> = keys(dir).into_iter().collect();
+        recipes(dir, &wanted)
+            .into_iter()
+            .map(|(shaders, g)| super::super::make::Pending::new(shaders, g).key().to_owned())
+            .collect()
+    }
+
+    /// The frozen records are what this build's book writes for plain
+    /// pipelines (provenance of the bytes the other tests read).
+    #[test]
+    fn the_book_writes_the_frozen_layout() {
+        let dir = scratch("frozen");
+        let (v, p): (&[u8], &[u8]) = (b"compat frozen vertex", b"compat frozen pixel");
+        let state = default_state();
+        let mut book = Book::new(dir.clone());
+        book.read(HashSet::new(), HashSet::new());
+        book.note([6; 16], &[super::super::shader("vertex", v), super::super::shader("pixel", p)], Some(&state));
+        book.note([7; 16], &[super::super::shader("pixel", p)], None);
+        let (_, new, added) = book.take().expect("two new pipelines");
+        let _ = std::fs::remove_dir_all(&dir);
+        assert_eq!(added, 2);
+        assert_eq!(new[0], [frozen_shader(0, v), frozen_shader(1, p)].concat());
+        assert_eq!(
+            new[1],
+            [frozen_pipeline([6; 16], &[(0, v), (1, p)], Some(&state)), frozen_pipeline([7; 16], &[(1, p)], None)].concat()
+        );
+    }
+
+    /// Observed on a build without the mask bit: a book from a build that
+    /// writes a masked pixel shader's stage byte as 0x81 (the twin of a mesh
+    /// pipeline, between two plain ones). Listed, read and added to as
+    /// before; only the flagged entry is never described or made.
+    #[test]
+    fn an_entry_flagged_by_a_newer_build_is_skipped_alone() {
+        let dir = scratch("flagged");
+        let (v, p, a, m, o, later): (&[u8], &[u8], &[u8], &[u8], &[u8], &[u8]) = (
+            b"compat flagged vertex",
+            b"compat flagged pixel",
+            b"compat flagged amplification",
+            b"compat flagged mesh",
+            b"compat flagged other",
+            b"compat flagged later",
+        );
+        let state = default_state();
+        let shaders = [(0, v), (1, p), (6, a), (7, m), (1, o)].map(|(s, c)| frozen_shader(s, c)).concat();
+        let pipelines = [
+            frozen_pipeline([1; 16], &[(0, v), (1, p)], Some(&state)),
+            frozen_pipeline([2; 16], &[(6, a), (7, m), (0x81, p)], Some(&state)),
+            frozen_pipeline([3; 16], &[(1, o)], Some(&state)),
+        ]
+        .concat();
+        std::fs::write(dir.join(SHADERS), &shaders).unwrap();
+        std::fs::write(dir.join(PIPELINES), &pipelines).unwrap();
+        let sh = super::super::shader;
+
+        // Listed (`victory warm`'s count and keys): all three.
+        assert_eq!(count(&dir), 3);
+        assert_eq!(keys(&dir), ["01".repeat(16), "02".repeat(16), "03".repeat(16)]);
+        // Read at a run's start: nothing cut, the flagged key known.
+        let (known, held) = read(&dir);
+        assert_eq!(known, HashSet::from([[1; 16], [2; 16], [3; 16]]));
+        assert_eq!(held.len(), 5);
+        assert_eq!(std::fs::metadata(dir.join(SHADERS)).unwrap().len(), shaders.len() as u64);
+        assert_eq!(std::fs::metadata(dir.join(PIPELINES)).unwrap().len(), pipelines.len() as u64);
+        // Described (the in-run prefetch): the flagged entry alone is missing, in order.
+        let plain = key_of(&[sh("vertex", v), sh("pixel", p)], true);
+        let other = key_of(&[sh("pixel", o)], true);
+        assert_eq!(read_back(&dir), [plain.clone(), other.clone()]);
+        // Made (a `victory warm` child): no host pipeline, told so, nothing else.
+        let mut told = Vec::new();
+        make(&dir, &[1], |n, came| told.push((n, came.map(|(_, there)| there))));
+        assert_eq!(told, [(1, None), (1, Some(false))]);
+        // Added to: the flagged key is not noted again; what comes after reads.
+        let mut book = Book::new(dir.clone());
+        book.read(known, held);
+        book.note([2; 16], &[sh("pixel", p)], Some(&state));
+        book.note([4; 16], &[sh("pixel", later)], Some(&state));
+        flush(&Mutex::new(book));
+        let shaders_after = std::fs::read(dir.join(SHADERS)).unwrap();
+        let pipelines_after = std::fs::read(dir.join(PIPELINES)).unwrap();
+        assert_eq!(shaders_after, [shaders, frozen_shader(1, later)].concat());
+        assert_eq!(pipelines_after, [pipelines, frozen_pipeline([4; 16], &[(1, later)], Some(&state))].concat());
+        assert_eq!(read_back(&dir), [plain, other, key_of(&[sh("pixel", later)], true)]);
+        let _ = std::fs::remove_dir_all(&dir);
+    }
+
+    /// Observed on a build without the mask bit: stage numbers past the
+    /// table, an entry shorter than its count, a cut state and a container
+    /// missing from the shaders file each lose their entry alone.
+    #[test]
+    fn a_damaged_entry_is_skipped_alone() {
+        let dir = scratch("damaged-old");
+        let (a, b): (&[u8], &[u8]) = (b"compat damaged-old a", b"compat damaged-old b");
+        let state = default_state();
+        let mut short = frozen_pipeline([4; 16], &[(1, a)], None);
+        short[4 + 16] = 2; // Two shaders counted, one there.
+        let pipelines = [
+            frozen_pipeline([1; 16], &[(1, a)], None),
+            frozen_pipeline([2; 16], &[(8, a)], None),
+            frozen_pipeline([3; 16], &[(0x88, a)], None),
+            short,
+            frozen_pipeline([5; 16], &[(1, a)], Some(&state[..state.len() - 1])),
+            frozen_pipeline([6; 16], &[(1, b"compat damaged-old never written")], None),
+            frozen_pipeline([7; 16], &[(1, b)], None),
+        ]
+        .concat();
+        std::fs::write(dir.join(SHADERS), [frozen_shader(1, a), frozen_shader(1, b)].concat()).unwrap();
+        std::fs::write(dir.join(PIPELINES), &pipelines).unwrap();
+        let sh = super::super::shader;
+        assert_eq!(count(&dir), 7);
+        assert_eq!(read_back(&dir), [key_of(&[sh("pixel", a)], false), key_of(&[sh("pixel", b)], false)]);
+        let _ = std::fs::remove_dir_all(&dir);
+    }
 }
combined-fix-tests-correction.patch — undeployed proposal on clean 41adb551
diff --git a/crates/victory-gpu/src/pipeline.rs b/crates/victory-gpu/src/pipeline.rs
index fd41ce0f..f9908ca0 100644
--- a/crates/victory-gpu/src/pipeline.rs
+++ b/crates/victory-gpu/src/pipeline.rs
@@ -584,7 +584,9 @@ pub(crate) fn host_pipeline_masked<'a>(this: This) -> Option<&'a host::HostPipel
             let mut shaders = p.shaders.clone();
             shaders[ps] = shaders[ps].masked();
             let graphics = p.host.graphics.as_deref().map(|g| Box::new(g.clone()));
-            Some(Arc::new(make::Pending::new(shaders, graphics)))
+            let masked = make::Pending::new(shaders.clone(), graphics);
+            known::note(masked.key(), &shaders, masked.graphics.as_deref());
+            Some(Arc::new(masked))
         })
         .as_ref()?;
     make::made_or_start(masked)
diff --git a/crates/victory-gpu/src/pipeline/known.rs b/crates/victory-gpu/src/pipeline/known.rs
index 38e09261..4768e5a7 100644
--- a/crates/victory-gpu/src/pipeline/known.rs
+++ b/crates/victory-gpu/src/pipeline/known.rs
@@ -37,6 +37,10 @@ const PIPELINES: &str = "known-pipelines.bin";
 const STAGES: [&str; 8] =
     ["vertex", "pixel", "domain", "hull", "geometry", "compute", "amplification", "mesh"];
 
+/// Set in a pipeline entry's stage byte for a pixel shader drawn under the
+/// console's sample mask (`Shader::masked`); the shaders file has the plain one.
+const MASKED: u8 = 0x80;
+
 /// `VICTORY_PIPELINE_BOOK=1`: the pipelines the title creates are kept.
 fn on() -> bool {
     static ON: OnceLock<bool> = OnceLock::new();
@@ -88,7 +92,7 @@ impl Book {
         for s in shaders {
             let hash = *blake3::hash(&s.container).as_bytes();
             let stage = STAGES.iter().position(|&x| x == s.stage).unwrap_or(0) as u8;
-            entry.push(stage);
+            entry.push(stage | if s.masked { MASKED } else { 0 });
             entry.extend(hash);
             if self.shaders.insert(hash) {
                 let new = &mut self.new[0];
@@ -385,7 +389,13 @@ fn parse(
         rest = after;
         let mut hash = [0; 32];
         hash.copy_from_slice(&head[1..]);
-        shaders.push(super::shader(STAGES.get(usize::from(head[0]))?, &read(&hash)?));
+        let (stage, masked) = (*STAGES.get(usize::from(head[0] & !MASKED))?, head[0] & MASKED != 0);
+        // Only a pixel shader has a masked twin: the bit elsewhere is not this build's.
+        if masked && stage != "pixel" {
+            return None;
+        }
+        let shader = super::shader(stage, &read(&hash)?);
+        shaders.push(if masked { shader.masked() } else { shader });
     }
     let (&graphics, rest) = rest.split_first()?;
     let g = match graphics {
@@ -668,6 +678,40 @@ mod tests {
         let _ = std::fs::remove_dir_all(&dir);
     }
 
+    /// A pipeline drawn under the console's sample mask (its pixel shader's
+    /// twin, hash "-mask") noted next to its plain pipeline comes back from
+    /// the files as itself: warm and the in-run prefetch build what was read.
+    #[test]
+    fn a_masked_twin_comes_back_masked() {
+        let dir = scratch("masked");
+        let plain = super::super::shader("pixel", b"known test masked twin");
+        let twin = plain.masked();
+        let id = |key: &str| {
+            let mut id = [0u8; 16];
+            for (at, b) in id.iter_mut().enumerate() {
+                *b = key.get(2 * at..2 * at + 2).and_then(|x| u8::from_str_radix(x, 16).ok()).unwrap_or(0);
+            }
+            id
+        };
+        let plain_key = super::super::make::Pending::new(vec![plain.clone()], None).key().to_owned();
+        let twin_key = super::super::make::Pending::new(vec![twin.clone()], None).key().to_owned();
+        assert_ne!(plain_key, twin_key, "the twin is a pipeline of its own");
+        let mut book = Book::new(dir.clone());
+        book.read(HashSet::new(), HashSet::new());
+        book.note(id(&plain_key), std::slice::from_ref(&plain), None);
+        book.note(id(&twin_key), std::slice::from_ref(&twin), None);
+        flush(&Mutex::new(book));
+        let wanted: HashSet<String> = [&plain_key, &twin_key].iter().map(|k| k[..32].to_owned()).collect();
+        assert_eq!(keys(&dir).len(), 2, "both noted");
+        let back: HashSet<String> = recipes(&dir, &wanted)
+            .into_iter()
+            .map(|(shaders, g)| super::super::make::Pending::new(shaders, g).key().to_owned())
+            .collect();
+        let _ = std::fs::remove_dir_all(&dir);
+        assert!(back.contains(&plain_key), "the plain pipeline comes back");
+        assert!(back.contains(&twin_key), "the masked twin comes back as the plain pipeline: {back:?}");
+    }
+
     #[test]
     fn a_torn_end_is_cut_before_anything_is_added() {
         let dir = scratch("cut");
@@ -688,4 +732,241 @@ mod tests {
         assert_eq!(walk_shaders(&dir, |_, _, _, _| ()), 37 + 12);
         let _ = std::fs::remove_dir_all(&dir);
     }
+
+    // The book's records written byte by byte from the layout in the module
+    // docs, not by `Book::note`: readers are checked against the layout, and
+    // `the_book_writes_the_frozen_layout` checks the writer against it.
+
+    /// A `known-shaders.bin` record: stage, BLAKE3 of the container, length,
+    /// container.
+    fn frozen_shader(stage: u8, container: &[u8]) -> Vec<u8> {
+        let mut out = vec![stage];
+        out.extend(blake3::hash(container).as_bytes());
+        out.extend((container.len() as u32).to_le_bytes());
+        out.extend(container);
+        out
+    }
+
+    /// A `known-pipelines.bin` record: length, key, shader count, a stage byte
+    /// and BLAKE3 per shader, whether a graphics state follows, the state.
+    fn frozen_pipeline(id: [u8; 16], parts: &[(u8, &[u8])], state: Option<&[u8]>) -> Vec<u8> {
+        let mut entry = id.to_vec();
+        entry.push(parts.len() as u8);
+        for (stage, container) in parts {
+            entry.push(*stage);
+            entry.extend(blake3::hash(container).as_bytes());
+        }
+        entry.push(u8::from(state.is_some()));
+        entry.extend(state.unwrap_or_default());
+        let mut out = (entry.len() as u32).to_le_bytes().to_vec();
+        out.extend(entry);
+        out
+    }
+
+    fn default_state() -> Vec<u8> {
+        let mut bytes = Vec::new();
+        GraphicsState::default().put(&mut bytes);
+        bytes
+    }
+
+    /// The key a run gives these shaders under the default graphics state
+    /// (`None`: a compute pipeline).
+    fn key_of(shaders: &[Arc<Shader>], graphics: bool) -> String {
+        let g = graphics.then(|| Box::new(GraphicsState::default()));
+        super::super::make::Pending::new(shaders.to_vec(), g).key().to_owned()
+    }
+
+    /// The keys of what `recipes` reads back for every key in `dir`, in order.
+    fn read_back(dir: &Path) -> Vec<String> {
+        let wanted: HashSet<String> = keys(dir).into_iter().collect();
+        recipes(dir, &wanted)
+            .into_iter()
+            .map(|(shaders, g)| super::super::make::Pending::new(shaders, g).key().to_owned())
+            .collect()
+    }
+
+    /// The frozen records are what the book writes: plain pipelines as before
+    /// the mask bit, a masked twin with 0x81 for its pixel shader, and the
+    /// container once, under its plain stage, even when the twin came first.
+    #[test]
+    fn the_book_writes_the_frozen_layout() {
+        let dir = scratch("frozen");
+        let (v, p): (&[u8], &[u8]) = (b"compat frozen vertex", b"compat frozen pixel");
+        let (vertex, pixel) = (super::super::shader("vertex", v), super::super::shader("pixel", p));
+        let state = default_state();
+        let mut book = Book::new(dir.clone());
+        book.read(HashSet::new(), HashSet::new());
+        book.note([5; 16], &[vertex.clone(), pixel.masked()], Some(&state));
+        book.note([6; 16], &[vertex, pixel.clone()], Some(&state));
+        book.note([7; 16], &[pixel], None);
+        let (_, new, added) = book.take().expect("three new pipelines");
+        let _ = std::fs::remove_dir_all(&dir);
+        assert_eq!(added, 3);
+        assert_eq!(new[0], [frozen_shader(0, v), frozen_shader(1, p)].concat());
+        assert_eq!(
+            new[1],
+            [
+                frozen_pipeline([5; 16], &[(0, v), (0x81, p)], Some(&state)),
+                frozen_pipeline([6; 16], &[(0, v), (1, p)], Some(&state)),
+                frozen_pipeline([7; 16], &[(1, p)], None),
+            ]
+            .concat()
+        );
+    }
+
+    /// A book written before the mask bit (frozen records: graphics, compute
+    /// and a three-stage mesh pipeline) is read as before: the same keys, in
+    /// order, and no shader comes back masked.
+    #[test]
+    fn a_book_from_before_the_mask_bit_reads_as_before() {
+        let dir = scratch("before");
+        let (v, p, c, a, m): (&[u8], &[u8], &[u8], &[u8], &[u8]) = (
+            b"compat before vertex",
+            b"compat before pixel",
+            b"compat before compute",
+            b"compat before amplification",
+            b"compat before mesh",
+        );
+        let state = default_state();
+        let shaders = [(0, v), (1, p), (5, c), (6, a), (7, m)].map(|(s, x)| frozen_shader(s, x)).concat();
+        let pipelines = [
+            frozen_pipeline([1; 16], &[(0, v), (1, p)], Some(&state)),
+            frozen_pipeline([2; 16], &[(5, c)], None),
+            frozen_pipeline([3; 16], &[(6, a), (7, m), (1, p)], Some(&state)),
+        ]
+        .concat();
+        std::fs::write(dir.join(SHADERS), shaders).unwrap();
+        std::fs::write(dir.join(PIPELINES), pipelines).unwrap();
+        let sh = super::super::shader;
+        let wanted: HashSet<String> = keys(&dir).into_iter().collect();
+        let back = recipes(&dir, &wanted);
+        assert!(back.iter().flat_map(|(s, _)| s).all(|s| !s.masked), "nothing masked");
+        assert_eq!(
+            read_back(&dir),
+            [
+                key_of(&[sh("vertex", v), sh("pixel", p)], true),
+                key_of(&[sh("compute", c)], false),
+                key_of(&[sh("amplification", a), sh("mesh", m), sh("pixel", p)], true),
+            ]
+        );
+        let _ = std::fs::remove_dir_all(&dir);
+    }
+
+    /// A three-stage mesh pipeline and its masked twin, noted in either order,
+    /// come back as themselves (the very shaders a run has), three containers
+    /// written once; a later run noting them again adds nothing.
+    #[test]
+    fn plain_and_masked_twins_stay_apart_in_either_order() {
+        let (a, m, p): (&[u8], &[u8], &[u8]) =
+            (b"compat twins amplification", b"compat twins mesh", b"compat twins pixel");
+        let sh = super::super::shader;
+        let pixel = sh("pixel", p);
+        let plain = vec![sh("amplification", a), sh("mesh", m), pixel.clone()];
+        let twin = vec![plain[0].clone(), plain[1].clone(), pixel.masked()];
+        let (plain_key, twin_key) = (key_of(&plain, true), key_of(&twin, true));
+        assert_ne!(plain_key, twin_key);
+        let id = |key: &str| -> [u8; 16] { std::array::from_fn(|at| u8::from_str_radix(&key[2 * at..2 * at + 2], 16).unwrap()) };
+        let state = default_state();
+        for (name, order) in [("twin-first", [(&twin_key, &twin), (&plain_key, &plain)]), ("plain-first", [(&plain_key, &plain), (&twin_key, &twin)])] {
+            let dir = scratch(name);
+            let mut book = Book::new(dir.clone());
+            book.read(HashSet::new(), HashSet::new());
+            for (key, shaders) in order {
+                book.note(id(key.as_str()), shaders, Some(&state));
+            }
+            flush(&Mutex::new(book));
+            assert_eq!(walk_shaders(&dir, |_, _, _, _| ()), [a, m, p].iter().map(|x| 37 + x.len() as u64).sum::<u64>());
+            assert_eq!(read_back(&dir), order.map(|(key, _)| key.clone()), "{name}");
+            let wanted: HashSet<String> = keys(&dir).into_iter().collect();
+            for (shaders, _) in recipes(&dir, &wanted) {
+                let expected = if shaders[2].masked { &twin } else { &plain };
+                assert!(shaders.iter().zip(expected).all(|(s, e)| Arc::ptr_eq(s, e)), "{name}: {shaders:?}");
+            }
+            let mut again = Book::new(dir.clone());
+            let (known, held) = read(&dir);
+            again.read(known, held);
+            for (key, shaders) in order {
+                again.note(id(key.as_str()), shaders, Some(&state));
+            }
+            assert!(again.take().is_none(), "{name}: noted again");
+            let _ = std::fs::remove_dir_all(&dir);
+        }
+    }
+
+    /// Stage numbers past the table (with or without the mask bit), an entry
+    /// shorter than its count, a cut state and a container missing from the
+    /// shaders file each lose their entry alone; a masked twin after them reads.
+    #[test]
+    fn a_damaged_entry_is_skipped_alone() {
+        let dir = scratch("damaged");
+        let (a, b): (&[u8], &[u8]) = (b"compat damaged a", b"compat damaged b");
+        let state = default_state();
+        let mut short = frozen_pipeline([4; 16], &[(0x81, a)], None);
+        short[4 + 16] = 2; // Two shaders counted, one there.
+        let pipelines = [
+            frozen_pipeline([1; 16], &[(1, a)], None),
+            frozen_pipeline([2; 16], &[(8, a)], None),
+            frozen_pipeline([3; 16], &[(0x88, a)], None),
+            short,
+            frozen_pipeline([5; 16], &[(0x81, a)], Some(&state[..state.len() - 1])),
+            frozen_pipeline([6; 16], &[(0x81, b"compat damaged never written")], None),
+            frozen_pipeline([7; 16], &[(0x81, b)], None),
+        ]
+        .concat();
+        std::fs::write(dir.join(SHADERS), [frozen_shader(1, a), frozen_shader(1, b)].concat()).unwrap();
+        std::fs::write(dir.join(PIPELINES), &pipelines).unwrap();
+        let sh = super::super::shader;
+        assert_eq!(count(&dir), 7);
+        assert_eq!(read_back(&dir), [key_of(&[sh("pixel", a)], false), key_of(&[sh("pixel", b).masked()], false)]);
+        let _ = std::fs::remove_dir_all(&dir);
+    }
+
+    /// Only a pixel shader has a masked twin: the bit on another stage is not
+    /// this build's, and its entry is skipped rather than read as a masked
+    /// vertex or mesh shader.
+    #[test]
+    fn a_mask_bit_on_a_stage_other_than_pixel_is_not_read() {
+        let dir = scratch("not-pixel");
+        let (v, m, p): (&[u8], &[u8], &[u8]) = (b"compat not-pixel vertex", b"compat not-pixel mesh", b"compat not-pixel pixel");
+        let state = default_state();
+        let shaders = [(0, v), (7, m), (1, p)].map(|(s, x)| frozen_shader(s, x)).concat();
+        let pipelines = [
+            frozen_pipeline([1; 16], &[(0x80, v), (1, p)], Some(&state)),
+            frozen_pipeline([2; 16], &[(0x87, m), (1, p)], Some(&state)),
+            frozen_pipeline([3; 16], &[(0, v), (0x81, p)], Some(&state)),
+        ]
+        .concat();
+        std::fs::write(dir.join(SHADERS), shaders).unwrap();
+        std::fs::write(dir.join(PIPELINES), pipelines).unwrap();
+        let sh = super::super::shader;
+        let back = read_back(&dir);
+        let _ = std::fs::remove_dir_all(&dir);
+        assert_eq!(back, [key_of(&[sh("vertex", v), sh("pixel", p).masked()], true)]);
+    }
+
+    /// A masked twin's entry torn at the file's end is cut at the next run's
+    /// start and noted again whole.
+    #[test]
+    fn a_torn_masked_entry_is_cut_and_noted_again() {
+        let dir = scratch("torn-twin");
+        let p = super::super::shader("pixel", b"compat torn-twin pixel");
+        let mut book = Book::new(dir.clone());
+        book.read(HashSet::new(), HashSet::new());
+        book.note([1; 16], std::slice::from_ref(&p), None);
+        book.note([2; 16], &[p.masked()], None);
+        flush(&Mutex::new(book));
+        let whole = std::fs::metadata(dir.join(PIPELINES)).unwrap().len();
+        let f = std::fs::OpenOptions::new().write(true).open(dir.join(PIPELINES)).unwrap();
+        f.set_len(whole - 5).unwrap();
+        drop(f);
+        let (known, held) = read(&dir);
+        assert_eq!(known, HashSet::from([[1; 16]]));
+        let mut book = Book::new(dir.clone());
+        book.read(known, held);
+        book.note([2; 16], &[p.masked()], None);
+        flush(&Mutex::new(book));
+        assert_eq!(std::fs::metadata(dir.join(PIPELINES)).unwrap().len(), whole);
+        assert_eq!(read_back(&dir), [key_of(std::slice::from_ref(&p), false), key_of(&[p.masked()], false)]);
+        let _ = std::fs::remove_dir_all(&dir);
+    }
 }
pixel-only-correction.patch — reverse on combined proposal to reproduce RED
diff --git a/crates/victory-gpu/src/pipeline/known.rs b/crates/victory-gpu/src/pipeline/known.rs
index ac8230fd..4768e5a7 100644
--- a/crates/victory-gpu/src/pipeline/known.rs
+++ b/crates/victory-gpu/src/pipeline/known.rs
@@ -389,8 +389,13 @@ fn parse(
         rest = after;
         let mut hash = [0; 32];
         hash.copy_from_slice(&head[1..]);
-        let shader = super::shader(STAGES.get(usize::from(head[0] & !MASKED))?, &read(&hash)?);
-        shaders.push(if head[0] & MASKED != 0 { shader.masked() } else { shader });
+        let (stage, masked) = (*STAGES.get(usize::from(head[0] & !MASKED))?, head[0] & MASKED != 0);
+        // Only a pixel shader has a masked twin: the bit elsewhere is not this build's.
+        if masked && stage != "pixel" {
+            return None;
+        }
+        let shader = super::shader(stage, &read(&hash)?);
+        shaders.push(if masked { shader.masked() } else { shader });
     }
     let (&graphics, rest) = rest.split_first()?;
     let g = match graphics {
**@⁠SergDi** on GitHub · 2026-11-30 10:38 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3860#issuecomment-7275887723) Thanks @⁠andrewpozdnakov7-jpg — my independently prepared Windows compatibility tests agree with the old-reader behavior you reported. They also found one malformed-record check missing from my original local prototype. Pinned reader/writer: `41adb551`. All fixtures use generated byte strings; frozen record bytes are checked against the actual old and proposed writers, not taken from a title. | Tested case | Observation | |---|---| | Proposed reader, legacy plain graphics/compute/amplification+mesh+pixel recipes | Same keys and order; plain writer layout unchanged | | Old reader, flagged pixel entry `0x81` inside a mixed book | Skips that recipe only; preserves the rest and reads later appends | | Old `known::make` on the flagged recipe | Reports no host pipeline without calling the driver; the warm loop would keep listing it as to-make | | Plain and masked twins, either note order | Distinct exact keys; shared container written once | | Unknown stages, short records, missing container, torn tail | Tested entries skipped or torn tail repaired as appropriate; later valid recipes remain readable | | Mask bit on vertex/mesh (`0x80` / `0x87`) | Original prototype incorrectly accepts them; pixel-only validation rejects them | **Windows results:** old-reader tests **8/8**; original prototype + compatibility tests **11 passed / 1 expected failure**, `a_mask_bit_on_a_stage_other_than_pixel_is_not_read`; adding the pixel-only check gives **12/12**. This correction concerns malformed-record robustness, not an observed gameplay defect. ```powershell cargo test --locked --release -p victory-gpu --lib pipeline::known -- --test-threads=1 ``` Below are two separate patches, each applied independently to clean `41adb551`: the old-reader experiment, and the combined local proposal with compatibility tests and pixel-only correction. **Neither is deployed.** The stage-bit/versioning choice remains with the maintainer. My tests do not establish compatibility with every older release, alternating old/new writers in a full application run, or end-to-end `warm --used` benefit. The persistent host pipeline library may already load a twin. Strict Clippy reported 24 diagnostics with none in the changed regions; I did not rerun a matched clean baseline for this task, so I do not claim a clean/no-new-lint gate. AI assistance: Claude prepared the fixtures/proposal and ran the Windows tests; Codex reviewed the results. These patches contain synthetic data only. <details> <summary>old-reader-observed.patch — experiment on clean 41adb551</summary> ```diff diff --git a/crates/victory-gpu/src/pipeline/known.rs b/crates/victory-gpu/src/pipeline/known.rs index 38e09261..0acef32f 100644 --- a/crates/victory-gpu/src/pipeline/known.rs +++ b/crates/victory-gpu/src/pipeline/known.rs @@ -688,4 +688,163 @@ mod tests { assert_eq!(walk_shaders(&dir, |_, _, _, _| ()), 37 + 12); let _ = std::fs::remove_dir_all(&dir); } + + // The book's records written byte by byte from the layout in the module + // docs, not by `Book::note`: readers are checked against the layout, and + // `the_book_writes_the_frozen_layout` checks the writer against it. + + /// A `known-shaders.bin` record: stage, BLAKE3 of the container, length, + /// container. + fn frozen_shader(stage: u8, container: &[u8]) -> Vec<u8> { + let mut out = vec![stage]; + out.extend(blake3::hash(container).as_bytes()); + out.extend((container.len() as u32).to_le_bytes()); + out.extend(container); + out + } + + /// A `known-pipelines.bin` record: length, key, shader count, a stage byte + /// and BLAKE3 per shader, whether a graphics state follows, the state. + fn frozen_pipeline(id: [u8; 16], parts: &[(u8, &[u8])], state: Option<&[u8]>) -> Vec<u8> { + let mut entry = id.to_vec(); + entry.push(parts.len() as u8); + for (stage, container) in parts { + entry.push(*stage); + entry.extend(blake3::hash(container).as_bytes()); + } + entry.push(u8::from(state.is_some())); + entry.extend(state.unwrap_or_default()); + let mut out = (entry.len() as u32).to_le_bytes().to_vec(); + out.extend(entry); + out + } + + fn default_state() -> Vec<u8> { + let mut bytes = Vec::new(); + GraphicsState::default().put(&mut bytes); + bytes + } + + /// The key a run gives these shaders under the default graphics state + /// (`None`: a compute pipeline). + fn key_of(shaders: &[Arc<Shader>], graphics: bool) -> String { + let g = graphics.then(|| Box::new(GraphicsState::default())); + super::super::make::Pending::new(shaders.to_vec(), g).key().to_owned() + } + + /// The keys of what `recipes` reads back for every key in `dir`, in order. + fn read_back(dir: &Path) -> Vec<String> { + let wanted: HashSet<String> = keys(dir).into_iter().collect(); + recipes(dir, &wanted) + .into_iter() + .map(|(shaders, g)| super::super::make::Pending::new(shaders, g).key().to_owned()) + .collect() + } + + /// The frozen records are what this build's book writes for plain + /// pipelines (provenance of the bytes the other tests read). + #[test] + fn the_book_writes_the_frozen_layout() { + let dir = scratch("frozen"); + let (v, p): (&[u8], &[u8]) = (b"compat frozen vertex", b"compat frozen pixel"); + let state = default_state(); + let mut book = Book::new(dir.clone()); + book.read(HashSet::new(), HashSet::new()); + book.note([6; 16], &[super::super::shader("vertex", v), super::super::shader("pixel", p)], Some(&state)); + book.note([7; 16], &[super::super::shader("pixel", p)], None); + let (_, new, added) = book.take().expect("two new pipelines"); + let _ = std::fs::remove_dir_all(&dir); + assert_eq!(added, 2); + assert_eq!(new[0], [frozen_shader(0, v), frozen_shader(1, p)].concat()); + assert_eq!( + new[1], + [frozen_pipeline([6; 16], &[(0, v), (1, p)], Some(&state)), frozen_pipeline([7; 16], &[(1, p)], None)].concat() + ); + } + + /// Observed on a build without the mask bit: a book from a build that + /// writes a masked pixel shader's stage byte as 0x81 (the twin of a mesh + /// pipeline, between two plain ones). Listed, read and added to as + /// before; only the flagged entry is never described or made. + #[test] + fn an_entry_flagged_by_a_newer_build_is_skipped_alone() { + let dir = scratch("flagged"); + let (v, p, a, m, o, later): (&[u8], &[u8], &[u8], &[u8], &[u8], &[u8]) = ( + b"compat flagged vertex", + b"compat flagged pixel", + b"compat flagged amplification", + b"compat flagged mesh", + b"compat flagged other", + b"compat flagged later", + ); + let state = default_state(); + let shaders = [(0, v), (1, p), (6, a), (7, m), (1, o)].map(|(s, c)| frozen_shader(s, c)).concat(); + let pipelines = [ + frozen_pipeline([1; 16], &[(0, v), (1, p)], Some(&state)), + frozen_pipeline([2; 16], &[(6, a), (7, m), (0x81, p)], Some(&state)), + frozen_pipeline([3; 16], &[(1, o)], Some(&state)), + ] + .concat(); + std::fs::write(dir.join(SHADERS), &shaders).unwrap(); + std::fs::write(dir.join(PIPELINES), &pipelines).unwrap(); + let sh = super::super::shader; + + // Listed (`victory warm`'s count and keys): all three. + assert_eq!(count(&dir), 3); + assert_eq!(keys(&dir), ["01".repeat(16), "02".repeat(16), "03".repeat(16)]); + // Read at a run's start: nothing cut, the flagged key known. + let (known, held) = read(&dir); + assert_eq!(known, HashSet::from([[1; 16], [2; 16], [3; 16]])); + assert_eq!(held.len(), 5); + assert_eq!(std::fs::metadata(dir.join(SHADERS)).unwrap().len(), shaders.len() as u64); + assert_eq!(std::fs::metadata(dir.join(PIPELINES)).unwrap().len(), pipelines.len() as u64); + // Described (the in-run prefetch): the flagged entry alone is missing, in order. + let plain = key_of(&[sh("vertex", v), sh("pixel", p)], true); + let other = key_of(&[sh("pixel", o)], true); + assert_eq!(read_back(&dir), [plain.clone(), other.clone()]); + // Made (a `victory warm` child): no host pipeline, told so, nothing else. + let mut told = Vec::new(); + make(&dir, &[1], |n, came| told.push((n, came.map(|(_, there)| there)))); + assert_eq!(told, [(1, None), (1, Some(false))]); + // Added to: the flagged key is not noted again; what comes after reads. + let mut book = Book::new(dir.clone()); + book.read(known, held); + book.note([2; 16], &[sh("pixel", p)], Some(&state)); + book.note([4; 16], &[sh("pixel", later)], Some(&state)); + flush(&Mutex::new(book)); + let shaders_after = std::fs::read(dir.join(SHADERS)).unwrap(); + let pipelines_after = std::fs::read(dir.join(PIPELINES)).unwrap(); + assert_eq!(shaders_after, [shaders, frozen_shader(1, later)].concat()); + assert_eq!(pipelines_after, [pipelines, frozen_pipeline([4; 16], &[(1, later)], Some(&state))].concat()); + assert_eq!(read_back(&dir), [plain, other, key_of(&[sh("pixel", later)], true)]); + let _ = std::fs::remove_dir_all(&dir); + } + + /// Observed on a build without the mask bit: stage numbers past the + /// table, an entry shorter than its count, a cut state and a container + /// missing from the shaders file each lose their entry alone. + #[test] + fn a_damaged_entry_is_skipped_alone() { + let dir = scratch("damaged-old"); + let (a, b): (&[u8], &[u8]) = (b"compat damaged-old a", b"compat damaged-old b"); + let state = default_state(); + let mut short = frozen_pipeline([4; 16], &[(1, a)], None); + short[4 + 16] = 2; // Two shaders counted, one there. + let pipelines = [ + frozen_pipeline([1; 16], &[(1, a)], None), + frozen_pipeline([2; 16], &[(8, a)], None), + frozen_pipeline([3; 16], &[(0x88, a)], None), + short, + frozen_pipeline([5; 16], &[(1, a)], Some(&state[..state.len() - 1])), + frozen_pipeline([6; 16], &[(1, b"compat damaged-old never written")], None), + frozen_pipeline([7; 16], &[(1, b)], None), + ] + .concat(); + std::fs::write(dir.join(SHADERS), [frozen_shader(1, a), frozen_shader(1, b)].concat()).unwrap(); + std::fs::write(dir.join(PIPELINES), &pipelines).unwrap(); + let sh = super::super::shader; + assert_eq!(count(&dir), 7); + assert_eq!(read_back(&dir), [key_of(&[sh("pixel", a)], false), key_of(&[sh("pixel", b)], false)]); + let _ = std::fs::remove_dir_all(&dir); + } } ``` </details> <details> <summary>combined-fix-tests-correction.patch — undeployed proposal on clean 41adb551</summary> ```diff diff --git a/crates/victory-gpu/src/pipeline.rs b/crates/victory-gpu/src/pipeline.rs index fd41ce0f..f9908ca0 100644 --- a/crates/victory-gpu/src/pipeline.rs +++ b/crates/victory-gpu/src/pipeline.rs @@ -584,7 +584,9 @@ pub(crate) fn host_pipeline_masked<'a>(this: This) -> Option<&'a host::HostPipel let mut shaders = p.shaders.clone(); shaders[ps] = shaders[ps].masked(); let graphics = p.host.graphics.as_deref().map(|g| Box::new(g.clone())); - Some(Arc::new(make::Pending::new(shaders, graphics))) + let masked = make::Pending::new(shaders.clone(), graphics); + known::note(masked.key(), &shaders, masked.graphics.as_deref()); + Some(Arc::new(masked)) }) .as_ref()?; make::made_or_start(masked) diff --git a/crates/victory-gpu/src/pipeline/known.rs b/crates/victory-gpu/src/pipeline/known.rs index 38e09261..4768e5a7 100644 --- a/crates/victory-gpu/src/pipeline/known.rs +++ b/crates/victory-gpu/src/pipeline/known.rs @@ -37,6 +37,10 @@ const PIPELINES: &str = "known-pipelines.bin"; const STAGES: [&str; 8] = ["vertex", "pixel", "domain", "hull", "geometry", "compute", "amplification", "mesh"]; +/// Set in a pipeline entry's stage byte for a pixel shader drawn under the +/// console's sample mask (`Shader::masked`); the shaders file has the plain one. +const MASKED: u8 = 0x80; + /// `VICTORY_PIPELINE_BOOK=1`: the pipelines the title creates are kept. fn on() -> bool { static ON: OnceLock<bool> = OnceLock::new(); @@ -88,7 +92,7 @@ impl Book { for s in shaders { let hash = *blake3::hash(&s.container).as_bytes(); let stage = STAGES.iter().position(|&x| x == s.stage).unwrap_or(0) as u8; - entry.push(stage); + entry.push(stage | if s.masked { MASKED } else { 0 }); entry.extend(hash); if self.shaders.insert(hash) { let new = &mut self.new[0]; @@ -385,7 +389,13 @@ fn parse( rest = after; let mut hash = [0; 32]; hash.copy_from_slice(&head[1..]); - shaders.push(super::shader(STAGES.get(usize::from(head[0]))?, &read(&hash)?)); + let (stage, masked) = (*STAGES.get(usize::from(head[0] & !MASKED))?, head[0] & MASKED != 0); + // Only a pixel shader has a masked twin: the bit elsewhere is not this build's. + if masked && stage != "pixel" { + return None; + } + let shader = super::shader(stage, &read(&hash)?); + shaders.push(if masked { shader.masked() } else { shader }); } let (&graphics, rest) = rest.split_first()?; let g = match graphics { @@ -668,6 +678,40 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } + /// A pipeline drawn under the console's sample mask (its pixel shader's + /// twin, hash "-mask") noted next to its plain pipeline comes back from + /// the files as itself: warm and the in-run prefetch build what was read. + #[test] + fn a_masked_twin_comes_back_masked() { + let dir = scratch("masked"); + let plain = super::super::shader("pixel", b"known test masked twin"); + let twin = plain.masked(); + let id = |key: &str| { + let mut id = [0u8; 16]; + for (at, b) in id.iter_mut().enumerate() { + *b = key.get(2 * at..2 * at + 2).and_then(|x| u8::from_str_radix(x, 16).ok()).unwrap_or(0); + } + id + }; + let plain_key = super::super::make::Pending::new(vec![plain.clone()], None).key().to_owned(); + let twin_key = super::super::make::Pending::new(vec![twin.clone()], None).key().to_owned(); + assert_ne!(plain_key, twin_key, "the twin is a pipeline of its own"); + let mut book = Book::new(dir.clone()); + book.read(HashSet::new(), HashSet::new()); + book.note(id(&plain_key), std::slice::from_ref(&plain), None); + book.note(id(&twin_key), std::slice::from_ref(&twin), None); + flush(&Mutex::new(book)); + let wanted: HashSet<String> = [&plain_key, &twin_key].iter().map(|k| k[..32].to_owned()).collect(); + assert_eq!(keys(&dir).len(), 2, "both noted"); + let back: HashSet<String> = recipes(&dir, &wanted) + .into_iter() + .map(|(shaders, g)| super::super::make::Pending::new(shaders, g).key().to_owned()) + .collect(); + let _ = std::fs::remove_dir_all(&dir); + assert!(back.contains(&plain_key), "the plain pipeline comes back"); + assert!(back.contains(&twin_key), "the masked twin comes back as the plain pipeline: {back:?}"); + } + #[test] fn a_torn_end_is_cut_before_anything_is_added() { let dir = scratch("cut"); @@ -688,4 +732,241 @@ mod tests { assert_eq!(walk_shaders(&dir, |_, _, _, _| ()), 37 + 12); let _ = std::fs::remove_dir_all(&dir); } + + // The book's records written byte by byte from the layout in the module + // docs, not by `Book::note`: readers are checked against the layout, and + // `the_book_writes_the_frozen_layout` checks the writer against it. + + /// A `known-shaders.bin` record: stage, BLAKE3 of the container, length, + /// container. + fn frozen_shader(stage: u8, container: &[u8]) -> Vec<u8> { + let mut out = vec![stage]; + out.extend(blake3::hash(container).as_bytes()); + out.extend((container.len() as u32).to_le_bytes()); + out.extend(container); + out + } + + /// A `known-pipelines.bin` record: length, key, shader count, a stage byte + /// and BLAKE3 per shader, whether a graphics state follows, the state. + fn frozen_pipeline(id: [u8; 16], parts: &[(u8, &[u8])], state: Option<&[u8]>) -> Vec<u8> { + let mut entry = id.to_vec(); + entry.push(parts.len() as u8); + for (stage, container) in parts { + entry.push(*stage); + entry.extend(blake3::hash(container).as_bytes()); + } + entry.push(u8::from(state.is_some())); + entry.extend(state.unwrap_or_default()); + let mut out = (entry.len() as u32).to_le_bytes().to_vec(); + out.extend(entry); + out + } + + fn default_state() -> Vec<u8> { + let mut bytes = Vec::new(); + GraphicsState::default().put(&mut bytes); + bytes + } + + /// The key a run gives these shaders under the default graphics state + /// (`None`: a compute pipeline). + fn key_of(shaders: &[Arc<Shader>], graphics: bool) -> String { + let g = graphics.then(|| Box::new(GraphicsState::default())); + super::super::make::Pending::new(shaders.to_vec(), g).key().to_owned() + } + + /// The keys of what `recipes` reads back for every key in `dir`, in order. + fn read_back(dir: &Path) -> Vec<String> { + let wanted: HashSet<String> = keys(dir).into_iter().collect(); + recipes(dir, &wanted) + .into_iter() + .map(|(shaders, g)| super::super::make::Pending::new(shaders, g).key().to_owned()) + .collect() + } + + /// The frozen records are what the book writes: plain pipelines as before + /// the mask bit, a masked twin with 0x81 for its pixel shader, and the + /// container once, under its plain stage, even when the twin came first. + #[test] + fn the_book_writes_the_frozen_layout() { + let dir = scratch("frozen"); + let (v, p): (&[u8], &[u8]) = (b"compat frozen vertex", b"compat frozen pixel"); + let (vertex, pixel) = (super::super::shader("vertex", v), super::super::shader("pixel", p)); + let state = default_state(); + let mut book = Book::new(dir.clone()); + book.read(HashSet::new(), HashSet::new()); + book.note([5; 16], &[vertex.clone(), pixel.masked()], Some(&state)); + book.note([6; 16], &[vertex, pixel.clone()], Some(&state)); + book.note([7; 16], &[pixel], None); + let (_, new, added) = book.take().expect("three new pipelines"); + let _ = std::fs::remove_dir_all(&dir); + assert_eq!(added, 3); + assert_eq!(new[0], [frozen_shader(0, v), frozen_shader(1, p)].concat()); + assert_eq!( + new[1], + [ + frozen_pipeline([5; 16], &[(0, v), (0x81, p)], Some(&state)), + frozen_pipeline([6; 16], &[(0, v), (1, p)], Some(&state)), + frozen_pipeline([7; 16], &[(1, p)], None), + ] + .concat() + ); + } + + /// A book written before the mask bit (frozen records: graphics, compute + /// and a three-stage mesh pipeline) is read as before: the same keys, in + /// order, and no shader comes back masked. + #[test] + fn a_book_from_before_the_mask_bit_reads_as_before() { + let dir = scratch("before"); + let (v, p, c, a, m): (&[u8], &[u8], &[u8], &[u8], &[u8]) = ( + b"compat before vertex", + b"compat before pixel", + b"compat before compute", + b"compat before amplification", + b"compat before mesh", + ); + let state = default_state(); + let shaders = [(0, v), (1, p), (5, c), (6, a), (7, m)].map(|(s, x)| frozen_shader(s, x)).concat(); + let pipelines = [ + frozen_pipeline([1; 16], &[(0, v), (1, p)], Some(&state)), + frozen_pipeline([2; 16], &[(5, c)], None), + frozen_pipeline([3; 16], &[(6, a), (7, m), (1, p)], Some(&state)), + ] + .concat(); + std::fs::write(dir.join(SHADERS), shaders).unwrap(); + std::fs::write(dir.join(PIPELINES), pipelines).unwrap(); + let sh = super::super::shader; + let wanted: HashSet<String> = keys(&dir).into_iter().collect(); + let back = recipes(&dir, &wanted); + assert!(back.iter().flat_map(|(s, _)| s).all(|s| !s.masked), "nothing masked"); + assert_eq!( + read_back(&dir), + [ + key_of(&[sh("vertex", v), sh("pixel", p)], true), + key_of(&[sh("compute", c)], false), + key_of(&[sh("amplification", a), sh("mesh", m), sh("pixel", p)], true), + ] + ); + let _ = std::fs::remove_dir_all(&dir); + } + + /// A three-stage mesh pipeline and its masked twin, noted in either order, + /// come back as themselves (the very shaders a run has), three containers + /// written once; a later run noting them again adds nothing. + #[test] + fn plain_and_masked_twins_stay_apart_in_either_order() { + let (a, m, p): (&[u8], &[u8], &[u8]) = + (b"compat twins amplification", b"compat twins mesh", b"compat twins pixel"); + let sh = super::super::shader; + let pixel = sh("pixel", p); + let plain = vec![sh("amplification", a), sh("mesh", m), pixel.clone()]; + let twin = vec![plain[0].clone(), plain[1].clone(), pixel.masked()]; + let (plain_key, twin_key) = (key_of(&plain, true), key_of(&twin, true)); + assert_ne!(plain_key, twin_key); + let id = |key: &str| -> [u8; 16] { std::array::from_fn(|at| u8::from_str_radix(&key[2 * at..2 * at + 2], 16).unwrap()) }; + let state = default_state(); + for (name, order) in [("twin-first", [(&twin_key, &twin), (&plain_key, &plain)]), ("plain-first", [(&plain_key, &plain), (&twin_key, &twin)])] { + let dir = scratch(name); + let mut book = Book::new(dir.clone()); + book.read(HashSet::new(), HashSet::new()); + for (key, shaders) in order { + book.note(id(key.as_str()), shaders, Some(&state)); + } + flush(&Mutex::new(book)); + assert_eq!(walk_shaders(&dir, |_, _, _, _| ()), [a, m, p].iter().map(|x| 37 + x.len() as u64).sum::<u64>()); + assert_eq!(read_back(&dir), order.map(|(key, _)| key.clone()), "{name}"); + let wanted: HashSet<String> = keys(&dir).into_iter().collect(); + for (shaders, _) in recipes(&dir, &wanted) { + let expected = if shaders[2].masked { &twin } else { &plain }; + assert!(shaders.iter().zip(expected).all(|(s, e)| Arc::ptr_eq(s, e)), "{name}: {shaders:?}"); + } + let mut again = Book::new(dir.clone()); + let (known, held) = read(&dir); + again.read(known, held); + for (key, shaders) in order { + again.note(id(key.as_str()), shaders, Some(&state)); + } + assert!(again.take().is_none(), "{name}: noted again"); + let _ = std::fs::remove_dir_all(&dir); + } + } + + /// Stage numbers past the table (with or without the mask bit), an entry + /// shorter than its count, a cut state and a container missing from the + /// shaders file each lose their entry alone; a masked twin after them reads. + #[test] + fn a_damaged_entry_is_skipped_alone() { + let dir = scratch("damaged"); + let (a, b): (&[u8], &[u8]) = (b"compat damaged a", b"compat damaged b"); + let state = default_state(); + let mut short = frozen_pipeline([4; 16], &[(0x81, a)], None); + short[4 + 16] = 2; // Two shaders counted, one there. + let pipelines = [ + frozen_pipeline([1; 16], &[(1, a)], None), + frozen_pipeline([2; 16], &[(8, a)], None), + frozen_pipeline([3; 16], &[(0x88, a)], None), + short, + frozen_pipeline([5; 16], &[(0x81, a)], Some(&state[..state.len() - 1])), + frozen_pipeline([6; 16], &[(0x81, b"compat damaged never written")], None), + frozen_pipeline([7; 16], &[(0x81, b)], None), + ] + .concat(); + std::fs::write(dir.join(SHADERS), [frozen_shader(1, a), frozen_shader(1, b)].concat()).unwrap(); + std::fs::write(dir.join(PIPELINES), &pipelines).unwrap(); + let sh = super::super::shader; + assert_eq!(count(&dir), 7); + assert_eq!(read_back(&dir), [key_of(&[sh("pixel", a)], false), key_of(&[sh("pixel", b).masked()], false)]); + let _ = std::fs::remove_dir_all(&dir); + } + + /// Only a pixel shader has a masked twin: the bit on another stage is not + /// this build's, and its entry is skipped rather than read as a masked + /// vertex or mesh shader. + #[test] + fn a_mask_bit_on_a_stage_other_than_pixel_is_not_read() { + let dir = scratch("not-pixel"); + let (v, m, p): (&[u8], &[u8], &[u8]) = (b"compat not-pixel vertex", b"compat not-pixel mesh", b"compat not-pixel pixel"); + let state = default_state(); + let shaders = [(0, v), (7, m), (1, p)].map(|(s, x)| frozen_shader(s, x)).concat(); + let pipelines = [ + frozen_pipeline([1; 16], &[(0x80, v), (1, p)], Some(&state)), + frozen_pipeline([2; 16], &[(0x87, m), (1, p)], Some(&state)), + frozen_pipeline([3; 16], &[(0, v), (0x81, p)], Some(&state)), + ] + .concat(); + std::fs::write(dir.join(SHADERS), shaders).unwrap(); + std::fs::write(dir.join(PIPELINES), pipelines).unwrap(); + let sh = super::super::shader; + let back = read_back(&dir); + let _ = std::fs::remove_dir_all(&dir); + assert_eq!(back, [key_of(&[sh("vertex", v), sh("pixel", p).masked()], true)]); + } + + /// A masked twin's entry torn at the file's end is cut at the next run's + /// start and noted again whole. + #[test] + fn a_torn_masked_entry_is_cut_and_noted_again() { + let dir = scratch("torn-twin"); + let p = super::super::shader("pixel", b"compat torn-twin pixel"); + let mut book = Book::new(dir.clone()); + book.read(HashSet::new(), HashSet::new()); + book.note([1; 16], std::slice::from_ref(&p), None); + book.note([2; 16], &[p.masked()], None); + flush(&Mutex::new(book)); + let whole = std::fs::metadata(dir.join(PIPELINES)).unwrap().len(); + let f = std::fs::OpenOptions::new().write(true).open(dir.join(PIPELINES)).unwrap(); + f.set_len(whole - 5).unwrap(); + drop(f); + let (known, held) = read(&dir); + assert_eq!(known, HashSet::from([[1; 16]])); + let mut book = Book::new(dir.clone()); + book.read(known, held); + book.note([2; 16], &[p.masked()], None); + flush(&Mutex::new(book)); + assert_eq!(std::fs::metadata(dir.join(PIPELINES)).unwrap().len(), whole); + assert_eq!(read_back(&dir), [key_of(std::slice::from_ref(&p), false), key_of(&[p.masked()], false)]); + let _ = std::fs::remove_dir_all(&dir); + } } ``` </details> <details> <summary>pixel-only-correction.patch — reverse on combined proposal to reproduce RED</summary> ```diff diff --git a/crates/victory-gpu/src/pipeline/known.rs b/crates/victory-gpu/src/pipeline/known.rs index ac8230fd..4768e5a7 100644 --- a/crates/victory-gpu/src/pipeline/known.rs +++ b/crates/victory-gpu/src/pipeline/known.rs @@ -389,8 +389,13 @@ fn parse( rest = after; let mut hash = [0; 32]; hash.copy_from_slice(&head[1..]); - let shader = super::shader(STAGES.get(usize::from(head[0] & !MASKED))?, &read(&hash)?); - shaders.push(if head[0] & MASKED != 0 { shader.masked() } else { shader }); + let (stage, masked) = (*STAGES.get(usize::from(head[0] & !MASKED))?, head[0] & MASKED != 0); + // Only a pixel shader has a masked twin: the bit elsewhere is not this build's. + if masked && stage != "pixel" { + return None; + } + let shader = super::shader(stage, &read(&hash)?); + shaders.push(if masked { shader.masked() } else { shader }); } let (&graphics, rest) = rest.split_first()?; let g = match graphics { ``` </details>
Author
Owner

@⁠danielsteman on GitHub · 2026-11-30 14:04 UTC · original

I opened #3974 with the stage-flag design from @⁠SergDi's prototype, including the pixel-only check, with SergDi as co-author. It adds one thing beyond the prototype: the masked pipeline is now picked up from the prefetch through make::adopt. Without that, a masked pipeline the prefetch had already started was built a second time.

On the stage flag versus a versioned field: the flag leaves known-shaders.bin and every plain entry unchanged, byte for byte. Two independent Windows tests here showed that older builds skip only the flagged entries and keep reading and appending to the rest. A versioned field would change every entry, for a single bit.

@⁠SergDi, if you'd rather open your own PR, I'll close mine.

**@⁠danielsteman** on GitHub · 2026-11-30 14:04 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3860#issuecomment-7280784871) I opened #3974 with the stage-flag design from @⁠SergDi's prototype, including the pixel-only check, with SergDi as co-author. It adds one thing beyond the prototype: the masked pipeline is now picked up from the prefetch through `make::adopt`. Without that, a masked pipeline the prefetch had already started was built a second time. On the stage flag versus a versioned field: the flag leaves `known-shaders.bin` and every plain entry unchanged, byte for byte. Two independent Windows tests here showed that older builds skip only the flagged entries and keep reading and appending to the rest. A versioned field would change every entry, for a single bit. @⁠SergDi, if you'd rather open your own PR, I'll close mine.
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/trustno1-coder--VIctory-NVIDIA#3860
No description provided.