GPU: the fifth dword of a root constants parameter is read as a constant #2293

Open
denkencar-sketch wants to merge 1 commit from upstream-pr/2295 into main
denkencar-sketch commented 2026-11-25 10:05:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T10:05:23Z.


Summary

Any user-data entry at the view-offset dword was taken for a root view's offset, so a draw reading that constant was dropped. Only a root view descriptor's entry is now read as a view offset; the fifth dword of a root constants parameter is a constant.

Testing

Test only_a_root_view_has_a_view_offset fails without the root-view check and passes with this change. It tests the helper is_view_offset, not the whole draw path. cargo test --workspace --locked passes apart from known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not tried: a run in the game.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5489188233 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2295). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T10:05:23Z. --- ## Summary Any user-data entry at the view-offset dword was taken for a root view's offset, so a draw reading that constant was dropped. Only a root view descriptor's entry is now read as a view offset; the fifth dword of a root constants parameter is a constant. ## Testing Test `only_a_root_view_has_a_view_offset` fails without the root-view check and passes with this change. It tests the helper `is_view_offset`, not the whole draw path. `cargo test --workspace --locked` passes apart from known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not tried: a run in the game. AI-assisted.
catminou4 commented 2026-11-25 10:19:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:19:13Z.

Review: COMMENTED


Root constants: the fifth dword check now requires RootType::Descriptor (is_view_offset) — a constants parameter no longer mistaken for a view offset. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055712531 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2295#pullrequestreview-6055712531). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:19:13Z. **Review:** COMMENTED --- Root constants: the fifth dword check now requires RootType::Descriptor (is_view_offset) — a constants parameter no longer mistaken for a view offset. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
steven-seagull27 commented 2026-11-25 11:05:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-25T10:44:54Z.


I reproduced the dropped draw on the parent and verified the fix on an RTX 5080 and Windows’ built-in WARP. With the fifth root constant, the parent dropped both draws and left all 256 pixels blue. On the PR, both adapters rendered the expected 128 red pixels on the left and 128 green on the right, with zero pixel mismatches.

Each row below was measured separately on both adapters. The four-dword control reads the last dword of a four-dword parameter.

Revision Constant read Draws issued / dropped Red / green / blue pixels Incorrect positions
Parent 940d32f Fourth 2 / 0 128 / 128 / 0 0/256
Parent 940d32f Fifth 0 / 2 0 / 0 / 256 256/256
PR 9d8a69b Fourth 2 / 0 128 / 128 / 0 0/256
PR 9d8a69b Fifth 2 / 0 128 / 128 / 0 0/256

The test translates a synthetic GFX10 pixel shader that reads s3 or s4, checks which root dword the translator requested, then submits two scissored draws through State::set_constants and State::draw. Only the selected constant changes between draws. It checks every RGBA8 pixel after submission against its expected position. The D3D12 device LUIDs resolved to NVIDIA GeForce RTX 5080 (10de:2c02) and Microsoft Basic Render Driver (1414:008c) using the system WARP DLL. This run used synthetic inputs.

The test-only commit applies to the PR head or its parent. It builds its shader fixtures locally with Windows SDK DXC. Regression test commit

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr-2295-root-constant-pixels
git cherry-pick 91231f99976d69e7edec00f3e616181d1c6f633f
$test = 'pipeline::host::root_constant_pixels::root_constants_draw_two_colors'
$env:VICTORY_D3D12_WARP = '0'
cargo test -p victory-gpu --all-features --lib --locked $test -- --exact --ignored --nocapture --test-threads=1
$env:VICTORY_D3D12_WARP = '1'
cargo test -p victory-gpu --all-features --lib --locked $test -- --exact --ignored --nocapture --test-threads=1
<!-- greyfinch-sync:Marvisak/VIctory:comment:7160118398 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2295#issuecomment-7160118398). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-25T10:44:54Z. --- I reproduced the dropped draw on the parent and verified the fix on an RTX 5080 and Windows’ built-in WARP. With the fifth root constant, the parent dropped both draws and left all 256 pixels blue. On the PR, both adapters rendered the expected 128 red pixels on the left and 128 green on the right, with zero pixel mismatches. Each row below was measured separately on both adapters. The four-dword control reads the last dword of a four-dword parameter. | Revision | Constant read | Draws issued / dropped | Red / green / blue pixels | Incorrect positions | |---|---|---:|---:|---:| | Parent `940d32f` | Fourth | 2 / 0 | 128 / 128 / 0 | 0/256 | | Parent `940d32f` | Fifth | 0 / 2 | 0 / 0 / 256 | 256/256 | | PR `9d8a69b` | Fourth | 2 / 0 | 128 / 128 / 0 | 0/256 | | PR `9d8a69b` | Fifth | 2 / 0 | 128 / 128 / 0 | 0/256 | The test translates a synthetic GFX10 pixel shader that reads `s3` or `s4`, checks which root dword the translator requested, then submits two scissored draws through `State::set_constants` and `State::draw`. Only the selected constant changes between draws. It checks every RGBA8 pixel after submission against its expected position. The D3D12 device LUIDs resolved to NVIDIA GeForce RTX 5080 (`10de:2c02`) and Microsoft Basic Render Driver (`1414:008c`) using the system WARP DLL. This run used synthetic inputs. The test-only commit applies to the PR head or its parent. It builds its shader fixtures locally with Windows SDK DXC. [Regression test commit](https://github.com/steven-seagull27/VIctory/commit/91231f99976d69e7edec00f3e616181d1c6f633f) ```powershell git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr-2295-root-constant-pixels git cherry-pick 91231f99976d69e7edec00f3e616181d1c6f633f $test = 'pipeline::host::root_constant_pixels::root_constants_draw_two_colors' $env:VICTORY_D3D12_WARP = '0' cargo test -p victory-gpu --all-features --lib --locked $test -- --exact --ignored --nocapture --test-threads=1 $env:VICTORY_D3D12_WARP = '1' cargo test -p victory-gpu --all-features --lib --locked $test -- --exact --ignored --nocapture --test-threads=1 ```
Marvisak commented 2026-11-25 15:04:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T14:52:50Z.


Automated triage for the maintainers.

Merge candidate (worth a look). The head 8cfd7aa drops the pixel test that ran dxc.exe, which was the only thing holding this back. What remains: in State (crates/victory-gpu/src/draw.rs), user-data dword ROOT_VIEW_OFFSET is taken as a root view's offset only when the parameter is a root descriptor (is_view_offset, matching is_root_view), so the fifth dword of a root constants parameter no longer drops the draw. The unit test only_a_root_view_has_a_view_offset covers it. A tester earlier reproduced the dropped draws on main and correct pixels with the fix on an RTX 5080 and WARP. CI check passes and it merges cleanly.

On your reply: confirmed, no process is spawned any more and the diff is only the fix and its unit test.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165959052 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2295#issuecomment-7165959052). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T14:52:50Z. --- <!-- victory-triage v1 head=8cfd7aa46cf1bb9169e140d08d6a1767c6128838 verdict=merge-candidate at=2026-11-26T00:23:30Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** The head `8cfd7aa` drops the pixel test that ran `dxc.exe`, which was the only thing holding this back. What remains: in `State` (`crates/victory-gpu/src/draw.rs`), user-data dword `ROOT_VIEW_OFFSET` is taken as a root view's offset only when the parameter is a root descriptor (`is_view_offset`, matching `is_root_view`), so the fifth dword of a root constants parameter no longer drops the draw. The unit test `only_a_root_view_has_a_view_offset` covers it. A tester earlier reproduced the dropped draws on `main` and correct pixels with the fix on an RTX 5080 and WARP. CI `check` passes and it merges cleanly. On your reply: confirmed, no process is spawned any more and the diff is only the fix and its unit test. --- _Generated by [Claude Code](https://claude.ai/code)_
denkencar-sketch commented 2026-11-26 00:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T23:15:34Z.


Dropped the \dxc.exe-spawning pixel test per triage (keeping the production fix and \only_a_root_view_has_a_view_offset\ unit test) and rebased onto current \main\ (\842b0cb). \cargo test, \cargo clippy, and \cargo xtask policy\ pass.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177325202 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2295#issuecomment-7177325202). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T23:15:34Z. --- Dropped the \dxc.exe\-spawning pixel test per triage (keeping the production fix and \only_a_root_view_has_a_view_offset\ unit test) and rebased onto current \main\ (\842b0cb\). \cargo test\, \cargo clippy\, and \cargo xtask policy\ pass.
fuzeofficlal commented 2026-11-26 19:44:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:44:46Z.

Review: APPROVED


Reviewed and verified 8cfd7aa46cf1bb9169e140d08d6a1767c6128838 merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, --features diagnostics with VICTORY_D3D12_DEBUG=1, Rust 1.98.1 MSVC).

Code Audit

  • Audited all ROOT_VIEW_OFFSET, is_root_view, and RootType::Constants uses across crates/victory-gpu/src/: State::bind (crates/victory-gpu/src/draw.rs:771), shared by both graphics and compute pipelines, was the only site matching u.dword == victory_shader::emit::ROOT_VIEW_OFFSET without verifying u.root == RootType::Descriptor.
  • Introducing is_view_offset (L2013-2015) mirrors is_root_view (L2018-2019) cleanly so the fifth dword (and beyond) of a RootType::Constants parameter falls through to self.user_value(...) instead of failing a root-view lookup and dropping the draw/dispatch.

Local Verification

  • cargo xtask policy — pass (191 files ok).
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) — 0 warnings.
  • cargo test --locked -p victory-gpu --features diagnostics --lib only_a_root_view_has_a_view_offset (RTX 5090 and WARP) — passed.
  • Additional synthetic probe binding 8-dword root constants on both graphics (compute = false) and compute (compute = true) slots: verified dwords 0..8 never match is_view_offset or is_root_view, RootType::Table with ROOT_VIEW_OFFSET is excluded, and State::user_value returns every dword verbatim on both RTX 5090 and WARP.

Looks good to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6079708008 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2295#pullrequestreview-6079708008). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T19:44:46Z. **Review:** APPROVED --- Reviewed and verified `8cfd7aa46cf1bb9169e140d08d6a1767c6128838` merged onto `origin/main` (`63bcca43c6a00a758510398fa43096ce7e4f7df0`) on Windows 11 x64 (RTX 5090 + Microsoft WARP, `--features diagnostics` with `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1 MSVC). ### Code Audit - Audited all `ROOT_VIEW_OFFSET`, `is_root_view`, and `RootType::Constants` uses across `crates/victory-gpu/src/`: `State::bind` (`crates/victory-gpu/src/draw.rs:771`), shared by both graphics and compute pipelines, was the only site matching `u.dword == victory_shader::emit::ROOT_VIEW_OFFSET` without verifying `u.root == RootType::Descriptor`. - Introducing `is_view_offset` (`L2013-2015`) mirrors `is_root_view` (`L2018-2019`) cleanly so the fifth dword (and beyond) of a `RootType::Constants` parameter falls through to `self.user_value(...)` instead of failing a root-view lookup and dropping the draw/dispatch. ### Local Verification - `cargo xtask policy` — pass (`191 files ok`). - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings. - `cargo test --locked -p victory-gpu --features diagnostics --lib only_a_root_view_has_a_view_offset` (RTX 5090 and WARP) — passed. - Additional synthetic probe binding 8-dword root constants on both graphics (`compute = false`) and compute (`compute = true`) slots: verified dwords `0..8` never match `is_view_offset` or `is_root_view`, `RootType::Table` with `ROOT_VIEW_OFFSET` is excluded, and `State::user_value` returns every dword verbatim on both RTX 5090 and WARP. Looks good to merge.
Dukestar69 commented 2026-11-26 22:09:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:09:52Z.

Review: APPROVED


LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Restricting is_view_offset to u.root == RootType::Descriptor prevents the fifth dword of a root constants parameter from being misinterpreted as ROOT_VIEW_OFFSET.
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 21 passed, 0 failed (including only_a_root_view_has_a_view_offset).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081010653 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2295#pullrequestreview-6081010653). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T22:09:52Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Restricting `is_view_offset` to `u.root == RootType::Descriptor` prevents the fifth dword of a root constants parameter from being misinterpreted as `ROOT_VIEW_OFFSET`. - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 21 passed, 0 failed (including `only_a_root_view_has_a_view_offset`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/2295:upstream-pr/2295'
git switch 'upstream-pr/2295'

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