Masked pixel twins are booked: warm --used and the prefetch can make them #3974

Open
github-bot wants to merge 3 commits from github-bot/gh-3974 into main AGit
Owner

@⁠danielsteman on GitHub · 2026-11-30 13:19 UTC · original
danielsteman:fix/known-book-masked-twins → main · +104 −3 · 2 files · 3 commits · open

Fixes #3860.

A draw under the console's sample mask uses its pixel shader's masked twin (Shader::masked), which is a pipeline with its own key. host_pipeline_masked made the twin through made_or_start but never noted it in the known-pipeline book. The book also could not tell the twin from its plain pipeline: an entry stores a stage and the container's hash, and the twin shares the plain shader's container. So warm --used and the recipe prefetch had nothing to build the twin from.

Change

  • host_pipeline_masked notes the twin with known::note and passes it through make::adopt, as hand_out does for a plain pipeline. Without adopt, a twin the in-run prefetch had already started from its recipe sat unused in PREFETCHED, and the draw made the twin a second time.
  • Book::note sets MASKED = 0x80 in a masked pixel shader's stage byte in known-pipelines.bin, and parse restores .masked() from that bit. If the bit is on any stage other than pixel, parse drops that entry.
  • known-shaders.bin is unchanged: each container is stored once, under its plain stage.

This is the stage-flag option the reporter proposed. A build from before this change skips a flagged entry by the stage table's bounds check and still reads the rest of the book. SergDi and andrewpozdnakov7-jpg each tested that on Windows against 41adb551 (see the issue thread).

Tests

  • a_masked_twin_comes_back_masked: a vertex/pixel pipeline and its twin, noted in either order, each come back with their own key. Each container is written once, under its plain stage.
  • a_mask_bit_on_a_stage_other_than_pixel_is_not_read: a book with the bit on a vertex stage loses only that entry.

I wrote this on macOS. cargo clippy --target x86_64-pc-windows-msvc -p victory-gpu --all-targets gives no new diagnostics: the 24 warnings in victory-gpu are already on main, and so are the 3 lint errors in victory-shader. The tests are cfg(windows), so I ran cargo test -p victory-gpu --lib on windows-latest in my fork's CI, before make::adopt was added; that commit has not been run on Windows. Clippy shows no new warnings for either commit when cross-compiled. Both new tests passed, along with the rest of pipeline::known (7/7). Overall 923 passed and 1 failed. The failure is shader_cache::tests::every_switch_of_the_translator_is_in_the_key ("VICTORY_SCALAR_SPLITS is not read by the translator any more"), which is in code this PR does not touch. The full CI Clippy step also fails on main, on an unused unwind_copy in victory-loader/src/crash.rs. I did not check an end-to-end warm --used run.

Co-authored-by: SergDi (prototype and pixel-only check)

🤖 Generated with Claude Code

**@⁠danielsteman** on GitHub · 2026-11-30 13:19 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974) `danielsteman:fix/known-book-masked-twins` → `main` · +104 −3 · 2 files · 3 commits · open Fixes #3860. A draw under the console's sample mask uses its pixel shader's masked twin (`Shader::masked`), which is a pipeline with its own key. `host_pipeline_masked` made the twin through `made_or_start` but never noted it in the known-pipeline book. The book also could not tell the twin from its plain pipeline: an entry stores a stage and the container's hash, and the twin shares the plain shader's container. So `warm --used` and the recipe prefetch had nothing to build the twin from. ## Change - `host_pipeline_masked` notes the twin with `known::note` and passes it through `make::adopt`, as `hand_out` does for a plain pipeline. Without `adopt`, a twin the in-run prefetch had already started from its recipe sat unused in `PREFETCHED`, and the draw made the twin a second time. - `Book::note` sets `MASKED = 0x80` in a masked pixel shader's stage byte in `known-pipelines.bin`, and `parse` restores `.masked()` from that bit. If the bit is on any stage other than pixel, `parse` drops that entry. - `known-shaders.bin` is unchanged: each container is stored once, under its plain stage. This is the stage-flag option the reporter proposed. A build from before this change skips a flagged entry by the stage table's bounds check and still reads the rest of the book. SergDi and andrewpozdnakov7-jpg each tested that on Windows against 41adb551 (see the issue thread). ## Tests - `a_masked_twin_comes_back_masked`: a vertex/pixel pipeline and its twin, noted in either order, each come back with their own key. Each container is written once, under its plain stage. - `a_mask_bit_on_a_stage_other_than_pixel_is_not_read`: a book with the bit on a vertex stage loses only that entry. I wrote this on macOS. `cargo clippy --target x86_64-pc-windows-msvc -p victory-gpu --all-targets` gives no new diagnostics: the 24 warnings in `victory-gpu` are already on main, and so are the 3 lint errors in `victory-shader`. The tests are `cfg(windows)`, so I ran `cargo test -p victory-gpu --lib` on `windows-latest` in my fork's CI, before `make::adopt` was added; that commit has not been run on Windows. Clippy shows no new warnings for either commit when cross-compiled. Both new tests passed, along with the rest of `pipeline::known` (7/7). Overall 923 passed and 1 failed. The failure is `shader_cache::tests::every_switch_of_the_translator_is_in_the_key` ("VICTORY_SCALAR_SPLITS is not read by the translator any more"), which is in code this PR does not touch. The full CI Clippy step also fails on main, on an unused `unwind_copy` in `victory-loader/src/crash.rs`. I did not check an end-to-end `warm --used` run. Co-authored-by: SergDi (prototype and pixel-only check) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A pipeline drawn under the console's sample mask uses its pixel shader's
masked twin (Shader::masked), a pipeline with a key of its own. It was
made through made_or_start, which lists the used key, but never noted in
the known-pipeline book, and the book could not have kept it apart from
its plain pipeline anyway: an entry stored a stage and the container's
hash, and the twin shares the plain shader's container. warm --used and
the recipe prefetch had nothing to make it from (#3860).

host_pipeline_masked now notes the twin like hand_out notes a plain
pipeline, and a pipeline entry sets 0x80 in a masked pixel shader's stage
byte; parse restores .masked() from it, and refuses the bit on any other
stage. The shaders file keeps each container once under its plain stage,
so it is unchanged. A build from before the bit skips such an entry alone
by the stage table's bounds and reads the rest, as the reporters checked
on Windows against 41adb551.

The design and its compatibility checks are the reporter's (prototype
and pixel-only check by SergDi, old-reader behaviour also confirmed by
andrewpozdnakov7-jpg). Two tests: a vertex/pixel pipeline and its twin
come back as themselves in either note order, each container written
once; and the bit on a vertex stage loses that entry alone.

Fixes #3860

Co-authored-by: SergDi <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 13:24:07 +00:00
The in-run prefetch describes the early list's pipelines from the book
and keeps each in PREFETCHED, where hand_out finds it through
make::adopt. host_pipeline_masked made its Pending directly, so a twin
the prefetch had started from its new recipe was never the one a draw
asked for, and the twin was made a second time. It now goes through
adopt as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠tyr0nsur on GitHub · 2026-11-30 13:41 UTC · original

I ran the Windows known-book tests at 4228850d. All 7 passed, including both new masked-entry cases.

I found one remaining gap in the online prefetch path. The recipe worker calls make::adopt, but host_pipeline_masked wraps its own Pending in a fresh Arc. At the first masked draw, made_or_start therefore sees a different task even when prefetch already created the same key. That can queue duplicate work or fall back to the plain pipeline while the separately queued task finishes.

The follow-up routes the masked draw through the same make::adopt path as the ordinary pipeline. The new Windows regression checks that the masked key is distinct from the plain key and that the first masked draw selects the exact prefetched task. It failed on pointer identity before the fix and passed after it. The patched pipeline suite passed 74 tests with 2 fixture-dependent tests ignored in each run, once on the RTX 4060 and once under WARP. I did not run the title or an end-to-end warm --used workload.

The tested cherry-pick is based directly on this PR.

**@⁠tyr0nsur** on GitHub · 2026-11-30 13:41 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974#issuecomment-7280223744) I ran the Windows known-book tests at 4228850d. All 7 passed, including both new masked-entry cases. I found one remaining gap in the online prefetch path. The recipe worker calls `make::adopt`, but `host_pipeline_masked` wraps its own `Pending` in a fresh `Arc`. At the first masked draw, `made_or_start` therefore sees a different task even when prefetch already created the same key. That can queue duplicate work or fall back to the plain pipeline while the separately queued task finishes. The follow-up routes the masked draw through the same `make::adopt` path as the ordinary pipeline. The new Windows regression checks that the masked key is distinct from the plain key and that the first masked draw selects the exact prefetched task. It failed on pointer identity before the fix and passed after it. The patched pipeline suite passed 74 tests with 2 fixture-dependent tests ignored in each run, once on the RTX 4060 and once under WARP. I did not run the title or an end-to-end `warm --used` workload. The [tested cherry-pick](https://github.com/tyr0nsur/VIctory-NVIDIA/commit/bcfe8a2d6ab2d239012bb441bbf40323e0cf6268) is based directly on this PR.
known.rs: main moved Book::note onto the byte-budgeted Pending queue;
the masked twin's MASKED bit now goes on that queue's pipeline stage
byte. Both test groups are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠dyshay on GitHub · 2026-11-30 14:53 UTC · original

Merged for testing into our integration branch dyshay/VIctory-NVIDIA janus-prs. Builds and the targeted CPU tests pass; a run on an RTX 4090 (Series S, hardware RT) is queued and I'll post the result here.

**@⁠dyshay** on GitHub · 2026-11-30 14:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974#issuecomment-7282097903) Merged for testing into our integration branch [dyshay/VIctory-NVIDIA `janus-prs`](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs). Builds and the targeted CPU tests pass; a run on an RTX 4090 (Series S, hardware RT) is queued and I'll post the result here.
Author
Owner

@⁠danielsteman on GitHub · 2026-11-30 15:01 UTC · original

Thanks. The make::adopt follow-up is in as 66bb0ac2. I merged main in 8fce73f4: main moved Book::note onto the byte-budgeted Pending queue, and the masked twin's MASKED bit now goes on that queue's pipeline stage byte. I couldn't build it off Windows. Could you re-run the known-book and pipeline tests at 8fce73f4?

**@⁠danielsteman** on GitHub · 2026-11-30 15:01 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974#issuecomment-7282299370) Thanks. The `make::adopt` follow-up is in as 66bb0ac2. I merged main in 8fce73f4: main moved `Book::note` onto the byte-budgeted `Pending` queue, and the masked twin's `MASKED` bit now goes on that queue's pipeline stage byte. I couldn't build it off Windows. Could you re-run the known-book and pipeline tests at 8fce73f4?
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-30 15:16 UTC · original

@⁠danielsteman, I reran the Windows tests on the exact 8fce73f4 merge head. The known-book suite passed 16/16, including both masked stage-byte tests. It passed 14/14 on current release main c71899d.

I also exercised the actual host_pipeline_masked path with a synthetic pixel-shader pair and a prefetched task. On main, the first masked draw created a different pending object. At 8fce73f4, the first draw took the exact prefetched object and the next draw reused it again. The probe checks pending-object identity and returns before compiler submission.

The full pipeline:: suite with WARP 1.0.22 and Agility 1.620.2 came to 104 passed / 2 ignored on main and 107 passed / 2 ignored at the PR head. The PR count includes the two masked book cases and the identity probe. Both builds had the same temporary #4018 unit-test build fix.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-30 15:16 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974#issuecomment-7282724181) @⁠danielsteman, I reran the Windows tests on the exact `8fce73f4` merge head. The known-book suite passed 16/16, including both masked stage-byte tests. It passed 14/14 on current release main `c71899d`. I also exercised the actual `host_pipeline_masked` path with a synthetic pixel-shader pair and a prefetched task. On main, the first masked draw created a different pending object. At `8fce73f4`, the first draw took the exact prefetched object and the next draw reused it again. The probe checks pending-object identity and returns before compiler submission. The full `pipeline::` suite with WARP 1.0.22 and Agility 1.620.2 came to 104 passed / 2 ignored on main and 107 passed / 2 ignored at the PR head. The PR count includes the two masked book cases and the identity probe. Both builds had the same temporary [#4018](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/4018) unit-test build fix.
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/3974/head:github-bot/gh-3974'
git switch 'github-bot/gh-3974'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3974'
git switch 'github-bot/gh-3974'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3974'
git switch 'github-bot/gh-3974'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3974'
git switch 'main'
git merge --squash 'github-bot/gh-3974'
git switch 'main'
git merge --ff-only 'github-bot/gh-3974'
git switch 'main'
git merge 'github-bot/gh-3974'
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!3974
No description provided.