Shader tests: use the selected adapter for the native gather check #3265

Open
andrewpozdnakov7-jpg wants to merge 1 commit from upstream-pr/3267 into main
andrewpozdnakov7-jpg commented 2026-11-26 15:06:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T15:06:22Z.


Fixes #3261.

Host::new(false) can select WARP when VICTORY_WARP=1. The gather test used the original request to decide whether to compare against native gather. WARP rounds these coordinates differently, so the hardware-only check failed at lane 4.

Use the selected host's WARP flag for that one comparison. All 32 lanes still check both translated gathers against the CPU model on every adapter. The native gather comparison still runs on hardware.

Verification

On Windows with app-local WARP 1.0.22, Agility 1.620.2 and DXIL validation, the same gather test went from failing to passing with VICTORY_WARP=1. With the override unset, the explicit WARP pass succeeded on both builds. There was no SM 6.6 hardware adapter for the local run.

Full shader lib run, forced WARP Passed Failed Ignored
Main 63bcca4 298 4 3
This PR 299 3 3

Both runs failed the two existing lane-permutation tests and edge_flagged_triangles_draw_as_unflagged_ones. Strict shader Clippy and asset policy passed.

Synthetic fixtures only. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5512456800 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3267). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T15:06:22Z. --- Fixes #3261. `Host::new(false)` can select WARP when `VICTORY_WARP=1`. The gather test used the original request to decide whether to compare against native gather. WARP rounds these coordinates differently, so the hardware-only check failed at lane 4. Use the selected host's WARP flag for that one comparison. All 32 lanes still check both translated gathers against the CPU model on every adapter. The native gather comparison still runs on hardware. ## Verification On Windows with app-local WARP 1.0.22, Agility 1.620.2 and DXIL validation, the same gather test went from failing to passing with `VICTORY_WARP=1`. With the override unset, the explicit WARP pass succeeded on both builds. There was no SM 6.6 hardware adapter for the local run. | Full shader lib run, forced WARP | Passed | Failed | Ignored | | --- | ---: | ---: | ---: | | Main `63bcca4` | 298 | 4 | 3 | | This PR | 299 | 3 | 3 | Both runs failed the two existing lane-permutation tests and `edge_flagged_triangles_draw_as_unflagged_ones`. Strict shader Clippy and asset policy passed. Synthetic fixtures only. AI-assisted with Codex.
Dukestar69 commented 2026-11-26 15:29:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T15:29:45Z.

Review: APPROVED


Reviewed the diff and verified locally on Windows 11 x64:

  • Checking !host.is_warp() instead of !warp cleanly handles Host::new(false) selecting WARP under VICTORY_WARP=1, where WARP's gather truncates rather than rounds.
  • VICTORY_WARP=1 cargo test -p victory-shader --lib emit::synthetic_tests::gathers_at_a_level_match_the_hardware -- --test-threads=1: 1 passed, 0 failed.
  • cargo clippy -p victory-shader --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:6076780263 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3267#pullrequestreview-6076780263). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T15:29:45Z. **Review:** APPROVED --- Reviewed the diff and verified locally on Windows 11 x64: - Checking `!host.is_warp()` instead of `!warp` cleanly handles `Host::new(false)` selecting WARP under `VICTORY_WARP=1`, where WARP's gather truncates rather than rounds. - `VICTORY_WARP=1 cargo test -p victory-shader --lib emit::synthetic_tests::gathers_at_a_level_match_the_hardware -- --test-threads=1`: 1 passed, 0 failed. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
andrewpozdnakov7-jpg commented 2026-11-26 16:21:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T16:21:26Z.


I merged this exact 010381c with #2997 at a4484f5 on the shared 63bcca43 base. Both sides added a software-adapter accessor in emit/host.rs. The integration b1ff815 reuses Host::is_software() in the native gather comparison and keeps the production permute change.

With forced app-local Agility 1.620.2, WARP 1.0.22 and DXIL validation, gather, varying Wave32 and Wave64 half-wave tests passed. Two full shader runs each had 301 passed, 1 failed, 3 ignored. The failure was edge_flagged_triangles_draw_as_unflagged_ones, also seen on 63bcca43. Separate fresh-process repeats of the divergent permute test still failed 1/48 in each of two series on the integration. The 19-active-lane case sometimes returned nonzero data on lanes 16–18 that should read zero. Strict shader and GPU Clippy passed with default and all features, and policy passed.

Maintainers can use this resolution if both PRs land. The intermittent divergent permute case remains open in #2997. If you reuse the merge resolution, please retain its Git author or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it into another commit. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7197535089 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3267#issuecomment-7197535089). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T16:21:26Z. --- I merged this exact `010381c` with #2997 at `a4484f5` on the shared `63bcca43` base. Both sides added a software-adapter accessor in `emit/host.rs`. The [integration `b1ff815`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/b1ff8152fe631d6266cacb29a61e3660e038f035) reuses `Host::is_software()` in the native gather comparison and keeps the production permute change. With forced app-local Agility 1.620.2, WARP 1.0.22 and DXIL validation, gather, varying Wave32 and Wave64 half-wave tests passed. Two full shader runs each had 301 passed, 1 failed, 3 ignored. The failure was `edge_flagged_triangles_draw_as_unflagged_ones`, also seen on `63bcca43`. Separate fresh-process repeats of the divergent permute test still failed 1/48 in each of two series on the integration. The 19-active-lane case sometimes returned nonzero data on lanes 16–18 that should read zero. Strict shader and GPU Clippy passed with default and all features, and policy passed. Maintainers can use this resolution if both PRs land. The intermittent divergent permute case remains open in #2997. If you reuse the merge resolution, please retain its Git author or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it into another commit. AI-assisted with Codex.
upipibi commented 2026-11-26 16:39:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-26T16:39:42Z.


Verified Marvisak/VIctory #3267 at 010381cc9f, main 63bcca43 as control. RTX 3070 8 GB, driver 616.56, Windows 11. Synthetic tests only.
gathers_at_a_level_match_the_hardware, 3 runs each:

  • VICTORY_WARP=1: PR passes 3/3; main fails 3/3 at lane 4 "against its gather" (left [66,67,35,34], right [65,66,34,33]). Confirms the fix.
  • Default adapter (DXGI adapter 0, the RTX 3070 here; the log does not print its name): fails 3/3 on both PR and main, identically, at lane 0 vs the CPU model (got [0,1,0,0], expected [0,0,0,0]), before the native-gather check is reached. So the PR does not change the NVIDIA result; this is the NVIDIA failure tracked in #1835 (Stride::Structured views read with rawBufferLoad), with runtime fixes proposed in #2178 and #2885.
    cargo xtask policy: 191 files ok. clippy -p victory-shader --all-targets --locked -D warnings: clean.

AI-assisted (Claude Code, Claude Opus 5.5): ran the tests and wrote this.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7197934872 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3267#issuecomment-7197934872). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-26T16:39:42Z. --- Verified Marvisak/VIctory #3267 at 010381cc9f5ff440c6ad4faec5810b2b6cf06e85, main 63bcca43 as control. RTX 3070 8 GB, driver 616.56, Windows 11. Synthetic tests only. gathers_at_a_level_match_the_hardware, 3 runs each: - VICTORY_WARP=1: PR passes 3/3; main fails 3/3 at lane 4 "against its gather" (left [66,67,35,34], right [65,66,34,33]). Confirms the fix. - Default adapter (DXGI adapter 0, the RTX 3070 here; the log does not print its name): fails 3/3 on both PR and main, identically, at lane 0 vs the CPU model (got [0,1,0,0], expected [0,0,0,0]), before the native-gather check is reached. So the PR does not change the NVIDIA result; this is the NVIDIA failure tracked in #1835 (`Stride::Structured` views read with `rawBufferLoad`), with runtime fixes proposed in #2178 and #2885. cargo xtask policy: 191 files ok. clippy -p victory-shader --all-targets --locked -D warnings: clean. AI-assisted (Claude Code, Claude Opus 5.5): ran the tests and wrote this.
upipibi commented 2026-11-26 16:47:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-26T16:47:50Z.


Corrected (16:53Z): the first version of this comment called the NVIDIA failure a test bug and offered a one-line test change (Stride::Raw). That change is #2357, which was closed on 2026-11-25 because the test fixtures are the faithful ones and the fix belongs in the runtime. The failure is the one tracked in #1835 (a Stride::Structured view read with rawBufferLoad on NVIDIA); runtime fixes are proposed in #2178 and #2885. I withdraw the suggestion.

What our run shows, for #1835: on the RTX 3070 (driver 616.56, Windows 11) all 32 lanes gathered as if u = v = 0 at level 0 ([0,1,0,0]; lanes 5-7 read a junk level), because the per-lane records read as 0 through the structured descriptor; even the native image_gather4_lz gave [0,1,0,0] on every lane. With the views made raw locally (the #2357 change, not proposed), every lane matched the CPU model on the 3070 and on WARP. Synthetic tests only.

AI-assisted (Claude Code, Claude Opus 5.5).

Added 17:19Z: the Stride::Raw test change hides #1835; it is not a fix. Please don't adopt it (see my reply below).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7198106638 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3267#issuecomment-7198106638). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-26T16:47:50Z. --- **Corrected (16:53Z):** the first version of this comment called the NVIDIA failure a test bug and offered a one-line test change (`Stride::Raw`). That change is #2357, which was closed on 2026-11-25 because the test fixtures are the faithful ones and the fix belongs in the runtime. The failure is the one tracked in #1835 (a `Stride::Structured` view read with `rawBufferLoad` on NVIDIA); runtime fixes are proposed in #2178 and #2885. I withdraw the suggestion. What our run shows, for #1835: on the RTX 3070 (driver 616.56, Windows 11) all 32 lanes gathered as if `u = v = 0` at level 0 (`[0,1,0,0]`; lanes 5-7 read a junk level), because the per-lane records read as 0 through the structured descriptor; even the native `image_gather4_lz` gave `[0,1,0,0]` on every lane. With the views made raw locally (the #2357 change, not proposed), every lane matched the CPU model on the 3070 and on WARP. Synthetic tests only. AI-assisted (Claude Code, Claude Opus 5.5). **Added 17:19Z:** the `Stride::Raw` test change hides #1835; it is not a fix. Please don't adopt it (see my reply below).
andrewpozdnakov7-jpg commented 2026-11-26 17:01:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T17:01:05Z.


Thanks @upipibi for tracking down the descriptor mismatch and testing the raw view on the RTX 3070. 498a55d adds that one-line test change to this PR and credits you in the commit.

I reran gathers_at_a_level_match_the_hardware locally with default adapter selection and forced WARP 1.0.22. It passed in both modes. The translated results are still compared against the CPU model for all 32 lanes. Your RTX 3070 report confirms the native comparison on that adapter. The same two unrelated permute tests fail on WARP before and after this change (tracked in #2997). Both Clippy configurations and the asset policy check passed.

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7198384134 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3267#issuecomment-7198384134). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T17:01:05Z. --- Thanks @upipibi for tracking down the descriptor mismatch and testing the raw view on the RTX 3070. [498a55d](https://github.com/Marvisak/VIctory/commit/498a55d92f2fe8989509601cf2663bdaef02ada9) adds that one-line test change to this PR and credits you in the commit. I reran `gathers_at_a_level_match_the_hardware` locally with default adapter selection and forced WARP 1.0.22. It passed in both modes. The translated results are still compared against the CPU model for all 32 lanes. Your [RTX 3070 report](https://github.com/Marvisak/VIctory/pull/3267#issuecomment-7198106638) confirms the native comparison on that adapter. The same two unrelated permute tests fail on WARP before and after this change (tracked in #2997). Both Clippy configurations and the asset policy check passed. AI-assisted with Codex.
upipibi commented 2026-11-26 17:19:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-26T17:19:13Z.


@andrewpozdnakov7-jpg thanks, but please drop 498a55d and keep 010381c as it was. I also decline the credit. That one-line Stride::Raw change is #2357, which Marvisak closed on 2026-11-25: the test fixtures are the faithful ones, and the fix belongs in the runtime. My comment above was corrected at 16:53Z to withdraw it. With the change in place, the test passes on NVIDIA because it no longer exercises what #1835 is about. It hides the bug rather than fixing it.

The runtime fix does make the test pass. On the same RTX 3070, #2885 at 767f228 passes gathers_at_a_level_match_the_hardware 3/3 on the hardware adapter, while main fails 3/3 (report: https://github.com/Marvisak/VIctory/pull/2885#issuecomment-7198796380). So on NVIDIA this test should go green once #2885 or #2178 lands, not through a test change. Your 010381c fix of the WARP comparison stands on its own (PR 3/3 vs main 0/3 on WARP in my report above).

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7198822329 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3267#issuecomment-7198822329). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-26T17:19:13Z. --- @andrewpozdnakov7-jpg thanks, but please drop 498a55d and keep 010381c as it was. I also decline the credit. That one-line `Stride::Raw` change is #2357, which Marvisak closed on 2026-11-25: the test fixtures are the faithful ones, and the fix belongs in the runtime. My comment above was corrected at 16:53Z to withdraw it. With the change in place, the test passes on NVIDIA because it no longer exercises what #1835 is about. It hides the bug rather than fixing it. The runtime fix does make the test pass. On the same RTX 3070, #2885 at `767f228` passes `gathers_at_a_level_match_the_hardware` 3/3 on the hardware adapter, while `main` fails 3/3 (report: https://github.com/Marvisak/VIctory/pull/2885#issuecomment-7198796380). So on NVIDIA this test should go green once #2885 or #2178 lands, not through a test change. Your 010381c fix of the WARP comparison stands on its own (PR 3/3 vs `main` 0/3 on WARP in my report above). AI-assisted (Claude Code, Claude Opus 5.5).
fuzeofficlal commented 2026-11-26 22:28:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T22:28:59Z.

Review: APPROVED


Verified on 498a55d9:

  • cargo xtask policy: 191 files ok.
  • rustfmt --edition 2024 --check: clean on the modified hunks in crates/victory-shader/src/emit/host.rs and synthetic_tests.rs.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features): clean.
  • cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::synthetic_tests::: 11 passed, 0 failed under VICTORY_WARP=0; under VICTORY_WARP=1, gathers_at_a_level_match_the_hardware passes (8/11 overall, with the 3 pre-existing fixed-Wave32 tests at synthetic_tests.rs:347, 411, 580 failing because they still check !warp instead of !host.is_warp()).

Gating Host::is_warp() behind #[cfg(test)] keeps non-test/release builds untouched, and switching the input buffer view to Stride::Raw matches the shader's byte-offset reads. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6081128750 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3267#pullrequestreview-6081128750). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T22:28:59Z. **Review:** APPROVED --- Verified on `498a55d9`: - `cargo xtask policy`: `191 files ok`. - `rustfmt --edition 2024 --check`: clean on the modified hunks in `crates/victory-shader/src/emit/host.rs` and `synthetic_tests.rs`. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--all-features`): clean. - `cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::synthetic_tests::`: **11 passed, 0 failed** under `VICTORY_WARP=0`; under `VICTORY_WARP=1`, `gathers_at_a_level_match_the_hardware` passes (**8/11** overall, with the 3 pre-existing fixed-Wave32 tests at `synthetic_tests.rs:347, 411, 580` failing because they still check `!warp` instead of `!host.is_warp()`). Gating `Host::is_warp()` behind `#[cfg(test)]` keeps non-test/release builds untouched, and switching the input buffer view to `Stride::Raw` matches the shader's byte-offset reads. LGTM.
andrewpozdnakov7-jpg commented 2026-11-27 00:23:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T00:23:44Z.


Thanks for correcting the earlier report, @upipibi. I restored this PR to 010381c. The structured-buffer fixture is back, and the withdrawn change and its attribution are out of the PR branch.

The gather test passed in three fresh forced-WARP 1.0.22 processes at the restored head. The WARP comparison fix is ready for maintainer review. Your RTX 3070 results in #2885 cover the separate runtime change.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7206424260 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3267#issuecomment-7206424260). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T00:23:44Z. --- Thanks for correcting the earlier report, @upipibi. I restored this PR to [`010381c`](https://github.com/Marvisak/VIctory/commit/010381cc9f5ff440c6ad4faec5810b2b6cf06e85). The structured-buffer fixture is back, and the withdrawn change and its attribution are out of the PR branch. The gather test passed in three fresh forced-WARP 1.0.22 processes at the restored head. The WARP comparison fix is ready for maintainer review. Your RTX 3070 results in #2885 cover the separate runtime change.
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/3267:upstream-pr/3267'
git switch 'upstream-pr/3267'

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