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

Open
danielsteman wants to merge 3 commits from upstream-pr/3974 into main
danielsteman commented 2026-11-30 13:19:51 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by danielsteman on 2026-11-30T13:19:51Z.


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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5566077639 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974). Originally posted by [danielsteman](https://github.com/danielsteman) on 2026-11-30T13:19:51Z. --- 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)
tyr0nsur commented 2026-11-30 13:41:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T13:41:56Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7280223744 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974#issuecomment-7280223744). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-11-30T13:41:56Z. --- 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.
dyshay commented 2026-11-30 14:53:41 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T14:53:41Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7282097903 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974#issuecomment-7282097903). Originally posted by [dyshay](https://github.com/dyshay) on 2026-11-30T14:53:41Z. --- 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.
danielsteman commented 2026-11-30 15:01:13 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by danielsteman on 2026-11-30T15:01:13Z.


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?

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7282299370 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974#issuecomment-7282299370). Originally posted by [danielsteman](https://github.com/danielsteman) on 2026-11-30T15:01:13Z. --- 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?
andrewpozdnakov7-jpg commented 2026-11-30 15:16:30 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-11-30T15:16:30Z.


@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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7282724181 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3974#issuecomment-7282724181). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-30T15:16:30Z. --- @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://github.com/trustno1-coder/VIctory-NVIDIA/pull/4018) unit-test build fix.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.

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

git switch 'main'
git merge --no-ff 'upstream-pr/3974'
git switch 'upstream-pr/3974'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3974'
git switch 'upstream-pr/3974'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3974'
git switch 'main'
git merge --squash 'upstream-pr/3974'
git switch 'main'
git merge --ff-only 'upstream-pr/3974'
git switch 'main'
git merge 'upstream-pr/3974'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!3974
No description provided.