Shaders: the fused multiply-add probe binds a sampler heap #2039

Open
0xkn0wh3r3 wants to merge 2 commits from upstream-pr/2041 into main
0xkn0wh3r3 commented 2026-11-25 03:58:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T03:58:02Z.


The sampler-heap fix to Host::fuses_fmad (the first commit here) is now also in #2922, split out at the triage's suggestion so it can land on its own. This PR is the debug-layer test harness. Once #2922 lands, this branch will be rebased to drop the fix commit, leaving only the harness and its test.

The problem

With the D3D12 debug layer on, every start reports an error before any title work runs. It is the first error of the run, so when a later failure happens, the debug layer's report of that failure can lead with this unrelated one.

The cause is emit::host::Host::fuses_fmad. It runs once as the host is made, to tell whether the GPU fuses mad. It records its dispatch with the root signature a translated program gets, which indexes the sampler heap directly, but it bound only a view heap. D3D12 requires a sampler heap bound before such a root signature is set. The debug layer reports:

id 1419: SetDescriptorHeaps must be called to bind a sampler descriptor before
setting a root signature with D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED

The other probes in the file bind one already.

How it was found

Running cargo test -p victory-gpu --features diagnostics with VICTORY_D3D12_DEBUG=1 and printing what Host::log_messages reads. The same run also reports barrier errors from a depth twin's copies in a list's prelude (draw::tests::a_depth_texture_written_through_unordered_views_reads_as_depth, second round). #1803 already fixes those, so that part is not here.

The fix

  • The probe now binds a one-slot sampler heap with its view heap. It samples nothing; the heap is only there because the root signature requires it.
  • Tests can now run under the debug layer. host::rerun_with_debug_layer runs a test again in a child process with VICTORY_D3D12_DEBUG=1 (diagnostics builds only; the host is made once per process, so it can only get the layer at its start). The errors Host::log_messages reads are kept for the test. The child prints its outcome (checked once it has read the layer's messages, or skipped: and why); the parent fails if it says neither, and fails a skip when VICTORY_REQUIRE_DEBUG_LAYER=1 is set.

Testing

  • New test host::tests::making_the_host_leaves_no_debug_layer_errors: makes the host under the debug layer and finds no errors. Without the fix it fails with the error above.
  • cargo test -p victory-gpu --features diagnostics --lib on an RTX 5070 Ti (driver 621.24, debug layer installed): the new test passes; it fails on main with the error above. All other tests pass except descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views, which fail the same way on main (#1835). Without diagnostics, the new test is not built.
  • cargo test --release -p victory-shader --lib: 244 passed. The 3 failures (emit::stride_tests::* x2, emit::synthetic_tests::gathers_at_a_level_match_the_hardware) fail the same way on main on this GPU (#1835).
  • cargo clippy -p victory-gpu --all-targets with and without --features diagnostics, and cargo clippy -p victory-shader --all-targets --features host: clean.

#1803 fixes the depth twin's barrier errors seen in the same run. rerun_with_debug_layer would give #1803 a regression test the same way.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6596879315 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2041). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T03:58:02Z. --- > The sampler-heap fix to `Host::fuses_fmad` (the first commit here) is now also in #2922, split out at the triage's suggestion so it can land on its own. This PR is the debug-layer test harness. Once #2922 lands, this branch will be rebased to drop the fix commit, leaving only the harness and its test. ## The problem With the D3D12 debug layer on, every start reports an error before any title work runs. It is the first error of the run, so when a later failure happens, the debug layer's report of that failure can lead with this unrelated one. The cause is `emit::host::Host::fuses_fmad`. It runs once as the host is made, to tell whether the GPU fuses `mad`. It records its dispatch with the root signature a translated program gets, which indexes the sampler heap directly, but it bound only a view heap. D3D12 requires a sampler heap bound before such a root signature is set. The debug layer reports: ``` id 1419: SetDescriptorHeaps must be called to bind a sampler descriptor before setting a root signature with D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED ``` The other probes in the file bind one already. ### How it was found Running `cargo test -p victory-gpu --features diagnostics` with `VICTORY_D3D12_DEBUG=1` and printing what `Host::log_messages` reads. The same run also reports barrier errors from a depth twin's copies in a list's prelude (`draw::tests::a_depth_texture_written_through_unordered_views_reads_as_depth`, second round). #1803 already fixes those, so that part is not here. ## The fix - The probe now binds a one-slot sampler heap with its view heap. It samples nothing; the heap is only there because the root signature requires it. - Tests can now run under the debug layer. `host::rerun_with_debug_layer` runs a test again in a child process with `VICTORY_D3D12_DEBUG=1` (diagnostics builds only; the host is made once per process, so it can only get the layer at its start). The errors `Host::log_messages` reads are kept for the test. The child prints its outcome (`checked` once it has read the layer's messages, or `skipped:` and why); the parent fails if it says neither, and fails a skip when `VICTORY_REQUIRE_DEBUG_LAYER=1` is set. ## Testing - New test `host::tests::making_the_host_leaves_no_debug_layer_errors`: makes the host under the debug layer and finds no errors. Without the fix it fails with the error above. - `cargo test -p victory-gpu --features diagnostics --lib` on an RTX 5070 Ti (driver 621.24, debug layer installed): the new test passes; it fails on `main` with the error above. All other tests pass except `descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views`, which fail the same way on `main` (#1835). Without `diagnostics`, the new test is not built. - `cargo test --release -p victory-shader --lib`: 244 passed. The 3 failures (`emit::stride_tests::*` x2, `emit::synthetic_tests::gathers_at_a_level_match_the_hardware`) fail the same way on `main` on this GPU (#1835). - `cargo clippy -p victory-gpu --all-targets` with and without `--features diagnostics`, and `cargo clippy -p victory-shader --all-targets --features host`: clean. ## Related #1803 fixes the depth twin's barrier errors seen in the same run. `rerun_with_debug_layer` would give #1803 a regression test the same way.
DenRakEiw commented 2026-11-25 05:05:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:06:52Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib making_the_host_leaves_no_debug_layer_errors — passed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-gpu -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean fix binding a sampler heap for the FMA probe so host initialization produces zero D3D12 debug layer errors. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6051715506 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2041#pullrequestreview-6051715506). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T04:06:52Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-shader --lib making_the_host_leaves_no_debug_layer_errors` — passed on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-gpu -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean fix binding a sampler heap for the FMA probe so host initialization produces zero D3D12 debug layer errors. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 05:05:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:26:00Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. Fused multiply-add probe binds a sampler heap — probe-path fix; mixed gpu+shader, gpu half Windows-only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051847565 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2041#pullrequestreview-6051847565). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T04:26:00Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 144 passed / 0 failed / 2 ignored. Fused multiply-add probe binds a sampler heap — probe-path fix; mixed gpu+shader, gpu half Windows-only.
jeremygold02 commented 2026-11-25 05:06:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:08:45Z.


Triage verdict — Keep the binding fix, make debug-layer coverage observable (8c23a7b)

Evidence

  • @0xkn0wh3r3’s sampler-heap binding matches D3D12’s requirement to bind the corresponding heap before setting a directly indexed root signature. This startup fix is independent of #1803’s depth-twin barriers. Probe binding · DirectX binding rule

Checks and limits

  • The exact-head startup test reported one passed with cargo test -p victory-gpu --features diagnostics --lib making_the_host_leaves_no_debug_layer_errors under WARP. In a disposable variant requiring device initialization and a debug InfoQueue, the device initialized but the InfoQueue assertion failed. The hardware selection showed the same result. This confirms a green result can occur without reading debug messages. The before/after result with the debug layer active is author-reported. Skip and assertion path

Next step

  • Keep the sampler binding. Give the fixture an explicit skipped outcome on unsupported setups and a must-run mode for deliberate debug-layer verification, so success in that mode establishes that the InfoQueue was actually checked.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152570755 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2041#issuecomment-7152570755). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:08:45Z. --- **Triage verdict — Keep the binding fix, make debug-layer coverage observable** (`8c23a7b`) **Evidence** - @0xkn0wh3r3’s sampler-heap binding matches D3D12’s requirement to bind the corresponding heap before setting a directly indexed root signature. This startup fix is independent of #1803’s depth-twin barriers. [Probe binding](https://github.com/Marvisak/VIctory/blob/8c23a7b04e74a3584e337ee4c3a2ff62a427b9f0/crates/victory-shader/src/emit/host.rs#L611-L627) · [DirectX binding rule](https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_DynamicResources.html#setdescriptorheaps-and-setrootsignature) **Checks and limits** - The exact-head startup test reported **one passed** with `cargo test -p victory-gpu --features diagnostics --lib making_the_host_leaves_no_debug_layer_errors` under WARP. In a disposable variant requiring device initialization and a debug InfoQueue, the device initialized but the InfoQueue assertion failed. The hardware selection showed the same result. This confirms a green result can occur without reading debug messages. The before/after result with the debug layer active is author-reported. [Skip and assertion path](https://github.com/Marvisak/VIctory/blob/8c23a7b04e74a3584e337ee4c3a2ff62a427b9f0/crates/victory-gpu/src/host.rs#L322-L337) **Next step** - Keep the sampler binding. Give the fixture an explicit skipped outcome on unsupported setups and a must-run mode for deliberate debug-layer verification, so success in that mode establishes that the InfoQueue was actually checked. This verification was AI-assisted.
0xkn0wh3r3 commented 2026-11-25 07:03:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T06:25:45Z.


Thanks @jeremygold02, done in e54d51d. The child process now prints its outcome: checked once it has read the debug layer's messages, or skipped: with the reason (no device, or no debug layer installed). The parent prints a skip as a skip and fails if the child says neither. With VICTORY_REQUIRE_DEBUG_LAYER=1 set, a skip fails, so a green run in that mode means the InfoQueue really was read.

On an RTX 5070 Ti with the layer installed it reports checked. With the layer check forced off it prints the skip and passes, and fails once the switch is set. (Part of the miss was that, with one test thread, libtest prints test <name> ... before the test runs, so the parent matches the outcome anywhere in a line.)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154780554 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2041#issuecomment-7154780554). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T06:25:45Z. --- Thanks @jeremygold02, done in `e54d51d`. The child process now prints its outcome: `checked` once it has read the debug layer's messages, or `skipped:` with the reason (no device, or no debug layer installed). The parent prints a skip as a skip and fails if the child says neither. With `VICTORY_REQUIRE_DEBUG_LAYER=1` set, a skip fails, so a green run in that mode means the InfoQueue really was read. On an RTX 5070 Ti with the layer installed it reports `checked`. With the layer check forced off it prints the skip and passes, and fails once the switch is set. (Part of the miss was that, with one test thread, libtest prints `test <name> ... ` before the test runs, so the parent matches the outcome anywhere in a line.)
Marvisak commented 2026-11-25 10:07:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:19:22Z.


Automated triage for the maintainers.

Needs work: needs the maintainer's decision.

  • The Host::fuses_fmad fix (crates/victory-shader/src/emit/host.rs, commit c8ada18) is still right and is now also split out as #2922, which can land on its own.
  • The rest is the debug-layer harness in crates/victory-gpu/src/host.rs: rerun_with_debug_layer re-runs the test binary through std::process::Command::new(current_exe()), with the checked/skipped: outcome protocol and VICTORY_REQUIRE_DEBUG_LAYER. Because it spawns a process, only the maintainer can decide whether to take it.

On your reply: agreed with the plan. Once #2922 lands, rebasing to drop c8ada18 leaves a harness-only PR for the maintainer to decide on; nothing else is needed from you meanwhile.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158175057 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2041#issuecomment-7158175057). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T09:19:22Z. --- <!-- victory-triage v1 head=f42add1f6567038bea1731fc65c9df21ef270114 verdict=needs-work at=2026-11-26T00:26:06Z --> Automated triage for the maintainers. **Needs work: needs the maintainer's decision.** - The `Host::fuses_fmad` fix (`crates/victory-shader/src/emit/host.rs`, commit `c8ada18`) is still right and is now also split out as #2922, which can land on its own. - The rest is the debug-layer harness in `crates/victory-gpu/src/host.rs`: `rerun_with_debug_layer` re-runs the test binary through `std::process::Command::new(current_exe())`, with the `checked`/`skipped:` outcome protocol and `VICTORY_REQUIRE_DEBUG_LAYER`. Because it spawns a process, only the maintainer can decide whether to take it. On your reply: agreed with the plan. Once #2922 lands, rebasing to drop `c8ada18` leaves a harness-only PR for the maintainer to decide on; nothing else is needed from you meanwhile. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
sinan-cmyk commented 2026-11-25 10:07:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:37:56Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head e54d51df onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158592131 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2041#issuecomment-7158592131). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T09:37:56Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head e54d51df onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
0xkn0wh3r3 commented 2026-11-26 01:03:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T00:11:12Z.


Thanks for the triage.

  • The fuses_fmad fix: split out into #2922 (one commit, cc785ae, on current main; only crates/victory-shader/src/emit/host.rs). Without the harness there is no new test in it. I checked it by applying this PR's harness locally on top of it: host::tests::making_the_host_leaves_no_debug_layer_errors with VICTORY_REQUIRE_DEBUG_LAYER=1 passes, and fails with the id 1419 sampler-heap error once the fix is reverted.
  • The child-process harness (rerun_with_debug_layer, DEBUG_ERRORS, the outcome marker, VICTORY_REQUIRE_DEBUG_LAYER): understood, that's your call. This PR stays open as just the harness. Once #2922 lands I'll rebase it to drop the fix commit. If you'd rather not take the harness, I'll close it.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7178489547 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2041#issuecomment-7178489547). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T00:11:12Z. --- Thanks for the triage. - The `fuses_fmad` fix: split out into #2922 (one commit, `cc785ae`, on current `main`; only `crates/victory-shader/src/emit/host.rs`). Without the harness there is no new test in it. I checked it by applying this PR's harness locally on top of it: `host::tests::making_the_host_leaves_no_debug_layer_errors` with `VICTORY_REQUIRE_DEBUG_LAYER=1` passes, and fails with the id 1419 sampler-heap error once the fix is reverted. - The child-process harness (`rerun_with_debug_layer`, `DEBUG_ERRORS`, the outcome marker, `VICTORY_REQUIRE_DEBUG_LAYER`): understood, that's your call. This PR stays open as just the harness. Once #2922 lands I'll rebase it to drop the fix commit. If you'd rather not take the harness, I'll close it.
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/2041:upstream-pr/2041'
git switch 'upstream-pr/2041'

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/2041'
git switch 'upstream-pr/2041'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2041'
git switch 'upstream-pr/2041'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2041'
git switch 'main'
git merge --squash 'upstream-pr/2041'
git switch 'main'
git merge --ff-only 'upstream-pr/2041'
git switch 'main'
git merge 'upstream-pr/2041'
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
Marvisak/VIctory!2039
No description provided.