Pick the discrete GPU on laptops; fix driver-dependent and wrong shader lowering #1483

Open
github-bot wants to merge 1 commit from github-bot/gh-1483 into main AGit
Owner

@⁠spy0eye-beep on GitHub · 2026-11-24 18:20 UTC · original
spy0eye-beep:fix/hybrid-gpu-and-driver-portable-shaders → main · +486 −66 · 8 files · 1 commits · open

What

Found on a hybrid laptop (Intel UHD Graphics + NVIDIA GeForce RTX 4060 Laptop GPU). One GPU-selection fix and six shader/runtime fixes. Each fix has a test that fails on main and passes here.

1. GPU: use the discrete GPU on laptops (victory-gpu, shader test host)

The host device was created with a null adapter, i.e. adapter 0, which on a laptop is the integrated GPU unless the user set a per-app preference in Windows. On this machine VIctory (and every "hardware" GPU test) ran on Intel UHD Graphics.
Now the first hardware adapter in DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE order that creates a D3D12 device is used, and its name is logged. Falls back to the old behaviour if DXGI cannot order adapters. Note: this overrides a user's "power saving" choice for VIctory in Windows graphics settings, which is the usual behaviour for games.
The shader test host does the same, and VICTORY_TEST_ADAPTER=n picks the n-th hardware adapter so the suite can be run on each GPU of a machine.

2. Shaders: SCC of s_min_* / s_max_* / s_lshlN_add_u32

SCC was set to result != 0. For s_min/s_max it is the comparison that picked the result (RDNA2 ISA); s_lshlN_add sets it to a carry, which is now Missing (fails loudly if read) instead of silently wrong.
Test: scalar_min_max_set_scc_to_the_comparison (on main: s_min_i32(2, 1) gives SCC = 1, want 0).

3. Shaders: a loop stopped by LOOP_LIMIT through a conditional back edge kept running

The limit was folded into the branch condition, so a lane at the limit took the loop's exit and continued through the program with unfinished values, possibly storing/exporting them, contrary to LOOP_LIMIT's doc ("leaves the program as killed"). Conditional back edges now go through a latch block that branches to the header below the limit and to the abort block at it (as Jump back edges already did); header phis take this edge's values from the latch via edges.
Test: loop_stopped_by_the_limit_stores_nothing (on main: stores 0x100000).

4. Shaders: NaN handling in v_cmp_*_f32/f16 independent of the driver

On Intel UHD Graphics, v_cmp_eq_f32 v1, v1 with a NaN gives true (the driver folds x == x). NaN operands are now found from the bits (|x| > 0x7F800000) and the float compare only orders numbers: ordered compares are false with a NaN, unordered ones true. No xor of a compare is emitted (see the old comment about the AMD driver hang): "not NaN" is its own compare (is_number). This also replaces the v_cmp_lg special case.
Test: v_cmp_f32_all_predicates_with_nan (all 13 non-constant predicates, two registers and one register against itself).

5. Shaders: v_med3_f32/f16

  • NaN detected from the bits: on Intel UHD v_med3_f32(1.0, 2.0, NaN) gave 2 (the existing v_med3_f32_matches_rdna2_with_nan fails there on main).
  • Built from max_min, so -0 orders below +0 like the hardware's min/max. On main WARP gives med3(+0, -0, 1) = -0, and Intel med3(+0, NaN, -0) = +0 (want -0).
    Test: v_med3_f32_orders_negative_zero_below_positive_zero.
    v_cvt_u16/i16_f16 also uses the bit test for NaN now (no failure observed; same pattern).

6. Shaders: comparison samplers

s.filter |= 0x80 on a filter that already holds a reduction in bits 7-8 turned a minimum sampler (0x100) into a maximum one (0x180). StaticSampler::make_comparison replaces the reduction.
Test: comparison_replaces_the_reduction.

7. HLE: XAsyncComplete race

For a call that ends (failure or no result) the call was unregistered before the status was published. A status check starting in between found no call, did not wait, and returned E_PENDING for a call that had ended. Status and unregistering are now done together under the CALLS lock (the call is removed only if it is still the same Arc, so a reused block is never touched). Behaviour change to note: the provider's OP_CLEANUP now runs while the call is still registered, before the status is published.
Test: waiting_never_sees_a_failed_call_still_pending (on main: returns E_PENDING).

Testing

Windows 11 Pro 26200, i7-13620H, 16 GB, NVIDIA GeForce RTX 4060 Laptop GPU + Intel UHD Graphics, Rust 1.98.1, MSVC 14.44.

RTX 4060 (VICTORY_TEST_ADAPTER=0) Intel UHD (VICTORY_TEST_ADAPTER=1)
cargo test --workspace --all-features 354 passed, 0 failed 354 passed, 0 failed
  • cargo clippy --workspace --all-features --all-targets -- -D warnings: clean
  • cargo xtask policy: 154 files ok
  • cargo build --release -p victory: ok
  • rustfmt: no new differences in the touched files

Not tested: an AMD GPU, and the title (no game data used).

AI-assisted (Claude).

🤖 Generated with Claude Code

**@⁠spy0eye-beep** on GitHub · 2026-11-24 18:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483) `spy0eye-beep:fix/hybrid-gpu-and-driver-portable-shaders` → `main` · +486 −66 · 8 files · 1 commits · open ## What Found on a hybrid laptop (Intel UHD Graphics + NVIDIA GeForce RTX 4060 Laptop GPU). One GPU-selection fix and six shader/runtime fixes. **Each fix has a test that fails on `main` and passes here.** ### 1. GPU: use the discrete GPU on laptops (`victory-gpu`, shader test host) The host device was created with a null adapter, i.e. adapter 0, which on a laptop is the **integrated GPU** unless the user set a per-app preference in Windows. On this machine VIctory (and every "hardware" GPU test) ran on Intel UHD Graphics. Now the first hardware adapter in `DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE` order that creates a D3D12 device is used, and its name is logged. Falls back to the old behaviour if DXGI cannot order adapters. Note: this overrides a user's "power saving" choice for VIctory in Windows graphics settings, which is the usual behaviour for games. The shader test host does the same, and `VICTORY_TEST_ADAPTER=n` picks the n-th hardware adapter so the suite can be run on each GPU of a machine. ### 2. Shaders: SCC of `s_min_*` / `s_max_*` / `s_lshlN_add_u32` SCC was set to `result != 0`. For `s_min`/`s_max` it is the comparison that picked the result (RDNA2 ISA); `s_lshlN_add` sets it to a carry, which is now `Missing` (fails loudly if read) instead of silently wrong. Test: `scalar_min_max_set_scc_to_the_comparison` (on `main`: `s_min_i32(2, 1)` gives SCC = 1, want 0). ### 3. Shaders: a loop stopped by `LOOP_LIMIT` through a conditional back edge kept running The limit was folded into the branch condition, so a lane at the limit took the loop's **exit** and continued through the program with unfinished values, possibly storing/exporting them, contrary to `LOOP_LIMIT`'s doc ("leaves the program as killed"). Conditional back edges now go through a latch block that branches to the header below the limit and to the abort block at it (as `Jump` back edges already did); header phis take this edge's values from the latch via `edges`. Test: `loop_stopped_by_the_limit_stores_nothing` (on `main`: stores `0x100000`). ### 4. Shaders: NaN handling in `v_cmp_*_f32/f16` independent of the driver On **Intel UHD Graphics**, `v_cmp_eq_f32 v1, v1` with a NaN gives **true** (the driver folds `x == x`). NaN operands are now found from the bits (`|x| > 0x7F800000`) and the float compare only orders numbers: ordered compares are false with a NaN, unordered ones true. No `xor` of a compare is emitted (see the old comment about the AMD driver hang): "not NaN" is its own compare (`is_number`). This also replaces the `v_cmp_lg` special case. Test: `v_cmp_f32_all_predicates_with_nan` (all 13 non-constant predicates, two registers and one register against itself). ### 5. Shaders: `v_med3_f32/f16` - NaN detected from the bits: on **Intel UHD** `v_med3_f32(1.0, 2.0, NaN)` gave 2 (the existing `v_med3_f32_matches_rdna2_with_nan` fails there on `main`). - Built from `max_min`, so -0 orders below +0 like the hardware's min/max. On `main` WARP gives `med3(+0, -0, 1) = -0`, and Intel `med3(+0, NaN, -0) = +0` (want -0). Test: `v_med3_f32_orders_negative_zero_below_positive_zero`. `v_cvt_u16/i16_f16` also uses the bit test for NaN now (no failure observed; same pattern). ### 6. Shaders: comparison samplers `s.filter |= 0x80` on a filter that already holds a reduction in bits 7-8 turned a minimum sampler (0x100) into a maximum one (0x180). `StaticSampler::make_comparison` replaces the reduction. Test: `comparison_replaces_the_reduction`. ### 7. HLE: `XAsyncComplete` race For a call that ends (failure or no result) the call was unregistered before the status was published. A status check starting in between found no call, did not wait, and returned `E_PENDING` for a call that had ended. Status and unregistering are now done together under the `CALLS` lock (the call is removed only if it is still the same `Arc`, so a reused block is never touched). Behaviour change to note: the provider's `OP_CLEANUP` now runs while the call is still registered, before the status is published. Test: `waiting_never_sees_a_failed_call_still_pending` (on `main`: returns `E_PENDING`). ## Testing Windows 11 Pro 26200, i7-13620H, 16 GB, NVIDIA GeForce RTX 4060 Laptop GPU + Intel UHD Graphics, Rust 1.98.1, MSVC 14.44. | | RTX 4060 (`VICTORY_TEST_ADAPTER=0`) | Intel UHD (`VICTORY_TEST_ADAPTER=1`) | |---|---|---| | `cargo test --workspace --all-features` | 354 passed, 0 failed | 354 passed, 0 failed | - `cargo clippy --workspace --all-features --all-targets -- -D warnings`: clean - `cargo xtask policy`: 154 files ok - `cargo build --release -p victory`: ok - rustfmt: no new differences in the touched files Not tested: an AMD GPU, and the title (no game data used). AI-assisted (Claude). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Found on a hybrid laptop (Intel UHD Graphics + NVIDIA RTX 4060 Laptop GPU).
Each fix has a test that fails without it.

- GPU: the host device was created on the default adapter, which on a
  laptop is the integrated GPU unless the user set a per-app preference.
  Take the first hardware adapter in high-performance order instead. The
  shader test host does the same; VICTORY_TEST_ADAPTER=n picks the n-th
  hardware adapter so the tests can run on each GPU of a machine.
- Shaders: s_min/s_max set SCC to result != 0 instead of the comparison;
  s_lshlN_add's SCC (a carry) is now unmodelled rather than wrong.
- Shaders: a loop stopped by LOOP_LIMIT through a conditional back edge
  went down the loop's exit and on through the program; it now leaves
  through the abort block, as a Jump back edge already did.
- Shaders: v_cmp_*_f32/f16 find NaN operands from the bits. Intel UHD's
  driver folds `x == x` to true; the float compare now only orders numbers.
  No xor of a compare (it hung the AMD driver in a loop exit).
- Shaders: v_med3 detects NaN from the bits (Intel UHD gave the median, not
  the minimum, with a NaN) and orders -0 below +0 via max_min.
- Shaders: a comparison sampler replaces the filter's reduction bits instead
  of OR-ing 0x80 in (a minimum sampler became a maximum one).
- HLE: XAsyncComplete publishes the status and unregisters an ended call
  under the CALLS lock, so a status check starting in between no longer
  returns E_PENDING for a call that already ended.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:33:33 +00:00
Author
Owner

@⁠matheusfermiano-source on GitHub · 2026-11-24 18:24 UTC · original

A Linux/Proton data point on AMD. With this PR, a main test makes the AMD driver crash under the vkd3d-proton that Proton Experimental ships today. A newer vkd3d-proton fixes it, and the PR's own tests pass.

Radeon 660M (RDNA2, RADV Mesa 26.3.1, waves 32..64), head 0daabcc:

main ffe310e this PR
waterfall_tests::lanes_load_from_the_buffer_their_nested_arms_chose, vkd3d-proton 3.1.0 (Proton Experimental 11.0-20261027b) pass process exits (code 3): 0xc0000005 inside libvulkan_radeon.so during vkCreateComputePipelines
the same test, vkd3d-proton 3.2.0 (GE-Proton11-14, cae8353) pass pass
whole victory-shader suite, vkd3d-proton 3.2.0 119 passed 125 passed, all 6 new tests included
  • On the RTX 3050 Laptop (NVIDIA 620.73.04) the same test passes with 3.1.0, so only RADV is affected.
  • Both suites also fail emit::tests::stub_pipeline_is_created, as on main: vkd3d-proton accepts a zeroed DXIL hash (see #1218).
  • I did not narrow it down to one of the seven changes. Change 3's new latch blocks alter how loops are shaped, so that is the first one I would check.
  • This is probably the same class of vkd3d-proton 3.1 problem as the one in #1433's comment and #144, so it is not a reason to hold the PR. But Linux users on today's Proton Experimental and an AMD GPU would hit it where main does not, and anyone testing this branch on Linux should use vkd3d-proton 3.2.

Built on Linux with llvm-mingw for x86_64-pc-windows-gnullvm (Rust 1.98.1); dxil.dll from DXC 1.9.2609 was loaded. Synthetic tests only, no game files. AI-assisted (Claude Code, Opus 5.5); every run was on this machine.

**@⁠matheusfermiano-source** on GitHub · 2026-11-24 18:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7140606346) A Linux/Proton data point on AMD. With this PR, a `main` test makes the AMD driver crash under the vkd3d-proton that Proton Experimental ships today. A newer vkd3d-proton fixes it, and the PR's own tests pass. Radeon 660M (RDNA2, RADV Mesa 26.3.1, waves 32..64), head `0daabcc`: | | `main` `ffe310e` | this PR | |---|---|---| | `waterfall_tests::lanes_load_from_the_buffer_their_nested_arms_chose`, vkd3d-proton 3.1.0 (Proton Experimental 11.0-20261027b) | pass | **process exits (code 3)**: 0xc0000005 inside `libvulkan_radeon.so` during `vkCreateComputePipelines` | | the same test, vkd3d-proton 3.2.0 (GE-Proton11-14, `cae8353`) | pass | pass | | whole `victory-shader` suite, vkd3d-proton 3.2.0 | 119 passed | 125 passed, all 6 new tests included | - On the RTX 3050 Laptop (NVIDIA 620.73.04) the same test passes with 3.1.0, so only RADV is affected. - Both suites also fail `emit::tests::stub_pipeline_is_created`, as on `main`: vkd3d-proton accepts a zeroed DXIL hash (see #1218). - I did not narrow it down to one of the seven changes. Change 3's new latch blocks alter how loops are shaped, so that is the first one I would check. - This is probably the same class of vkd3d-proton 3.1 problem as the one in #1433's comment and #144, so it is not a reason to hold the PR. But Linux users on today's Proton Experimental and an AMD GPU would hit it where `main` does not, and anyone testing this branch on Linux should use vkd3d-proton 3.2. Built on Linux with llvm-mingw for `x86_64-pc-windows-gnullvm` (Rust 1.98.1); `dxil.dll` from DXC 1.9.2609 was loaded. Synthetic tests only, no game files. AI-assisted (Claude Code, Opus 5.5); every run was on this machine.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-24 19:16 UTC · original

Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head 0daabcc on main ffe310e (clean merge). Desktop with this one GPU, so the adapter pick has a single candidate.

crate this PR main alone
victory-shader 126 passed, 0 failed, 1 ignored 120
victory-gpu 51 passed, 0 failed, 1 ignored 50
victory-hle 95 passed, 0 failed 94

All the new tests pass, including high_performance_adapter_is_hardware, v_med3_f32_orders_negative_zero_below_positive_zero, v_cmp_f32_all_predicates_with_nan, loop_stopped_by_the_limit_stores_nothing and waiting_never_sees_a_failed_call_still_pending.

On @⁠matheusfermiano-source's RADV crash: waterfall_tests::lanes_load_from_the_buffer_their_nested_arms_chose passes here with this PR, on AMD's own D3D12 driver. So on Windows AMD this PR doesn't crash the driver. That fits the crash being the vkd3d-proton 3.1 / RADV issue rather than something in this PR's DXIL.

Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).

**@⁠wwwwwwww3333333** on GitHub · 2026-11-24 19:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7141865735) Native Windows run on AMD RDNA2: RX 6750 XT (RDNA2, gfx1031), AMD driver 32.0.21045.29003, i5-13400F, Windows 11, Rust 1.98.1 MSVC. Head 0daabcc on main ffe310e (clean merge). Desktop with this one GPU, so the adapter pick has a single candidate. | crate | this PR | main alone | |---|---|---| | victory-shader | **126 passed**, 0 failed, 1 ignored | 120 | | victory-gpu | **51 passed**, 0 failed, 1 ignored | 50 | | victory-hle | **95 passed**, 0 failed | 94 | All the new tests pass, including `high_performance_adapter_is_hardware`, `v_med3_f32_orders_negative_zero_below_positive_zero`, `v_cmp_f32_all_predicates_with_nan`, `loop_stopped_by_the_limit_stores_nothing` and `waiting_never_sees_a_failed_call_still_pending`. On @⁠matheusfermiano-source's RADV crash: `waterfall_tests::lanes_load_from_the_buffer_their_nested_arms_chose` passes here with this PR, on AMD's own D3D12 driver. So on Windows AMD this PR doesn't crash the driver. That fits the crash being the vkd3d-proton 3.1 / RADV issue rather than something in this PR's DXIL. Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine).
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 20:13 UTC · original

Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head 0daabcc onto main ffe310e (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: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 126, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

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

**@⁠sinan-cmyk** on GitHub · 2026-11-24 20:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7143212995) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 0daabcc onto `main` ffe310e (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: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 126, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠aycow on GitHub · 2026-11-24 20:57 UTC · original

An independent Windows Agility 1.620 full-GBV test reproduced the MED3 signed-zero defect. The upstream original f32/f16 tests passed on both AMD Radeon Graphics and WARP. Across 90 operand/permutation rows, upstream WARP failed 11 asserted signed-zero cases, including (+0, -0, 1) returning -0. I extracted only the MED3 portion of your 0daabcc change onto ffe310e with your authorship. It passed the full asserted matrix on both devices and kept the signaling-NaN result classes identical to baseline. NVIDIA is currently absent from this machine's DXGI enumeration, so there is no result for the reported NVIDIA failure. The focused extraction is local; your existing work covers the fix.

AI-assisted using Codex.

**@⁠aycow** on GitHub · 2026-11-24 20:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7144276420) An independent Windows Agility 1.620 full-GBV test reproduced the MED3 signed-zero defect. The upstream original f32/f16 tests passed on both AMD Radeon Graphics and WARP. Across 90 operand/permutation rows, upstream WARP failed 11 asserted signed-zero cases, including (+0, -0, 1) returning -0. I extracted only the MED3 portion of your 0daabcc change onto ffe310e with your authorship. It passed the full asserted matrix on both devices and kept the signaling-NaN result classes identical to baseline. NVIDIA is currently absent from this machine's DXGI enumeration, so there is no result for the reported NVIDIA failure. The focused extraction is local; your existing work covers the fix. AI-assisted using Codex.
Author
Owner

@⁠KevinPratap on GitHub · 2026-11-24 21:18 UTC · original

Tested on NVIDIA: an RTX 4050 Laptop on Windows 11, with this pull request merged onto main (ffe310e).

  • cargo test -p victory-shader: 126 passed, 0 failed.
  • v_med3_f32_matches_rdna2_with_nan fails on main on this card: v_med3_f32(1.0, 2.0, NaN) = 2, where RDNA2 gives 1, because the driver folds the fcmp uno NaN test away. With this PR it passes, along with v_med3_f16_matches_rdna2_with_nan and v_med3_f32_orders_negative_zero_below_positive_zero.

I had opened #1689 with only the med3 part of this. I'm closing it in favour of this PR. AI-assisted.

**@⁠KevinPratap** on GitHub · 2026-11-24 21:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7144751021) Tested on NVIDIA: an RTX 4050 Laptop on Windows 11, with this pull request merged onto `main` (ffe310e). - `cargo test -p victory-shader`: **126 passed, 0 failed**. - `v_med3_f32_matches_rdna2_with_nan` fails on `main` on this card: `v_med3_f32(1.0, 2.0, NaN) = 2`, where RDNA2 gives 1, because the driver folds the `fcmp uno` NaN test away. With this PR it passes, along with `v_med3_f16_matches_rdna2_with_nan` and `v_med3_f32_orders_negative_zero_below_positive_zero`. I had opened #1689 with only the `med3` part of this. I'm closing it in favour of this PR. AI-assisted.
Author
Owner

@⁠KevinPratap on GitHub · 2026-11-24 21:20 UTC · original

Driver for the result above: NVIDIA GeForce RTX 4050 Laptop GPU, driver 621.24. In #1633, an RTX 4090 and an RTX 5070 Ti (driver 32.0.16.1742) did not reproduce the med3 failure on main. The folding seems to depend on the driver or the GPU, and this laptop shows it. Testing NaN from the bits, as this PR does, avoids it on all of them. AI-assisted.

**@⁠KevinPratap** on GitHub · 2026-11-24 21:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7144804732) Driver for the result above: NVIDIA GeForce RTX 4050 Laptop GPU, driver **621.24**. In #1633, an RTX 4090 and an RTX 5070 Ti (driver 32.0.16.1742) did not reproduce the `med3` failure on `main`. The folding seems to depend on the driver or the GPU, and this laptop shows it. Testing NaN from the bits, as this PR does, avoids it on all of them. AI-assisted.
Author
Owner

@⁠tumbubu on GitHub · 2026-11-24 21:51 UTC · original

RX 7900 XT (RDNA3, driver 32.0.31036.15, the machine's only GPU): green.

0daabcc, cargo test -p victory-shader -p victory-gpu -p victory-hle --locked -- --test-threads=1:

Crate 0daabcc main (ffe310e)
victory-shader 126 passed, 1 ignored 120
victory-gpu 51 passed, 1 ignored 50
victory-hle 95 passed 94
  • The new v_cmp/v_med3 NaN tests pass on the 7900 XT and on WARP.
  • No hang on AMD: the commit names a loop exit that once hung the AMD driver, and none of the shader tests here hung.
  • high_performance_adapter_is_hardware passes. With one GPU there is nothing else for it to pick, so this run does not test the laptop case.

AI-assisted (Claude Code); every run was on this machine.

**@⁠tumbubu** on GitHub · 2026-11-24 21:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7145488099) **RX 7900 XT (RDNA3, driver 32.0.31036.15, the machine's only GPU): green.** `0daabcc`, `cargo test -p victory-shader -p victory-gpu -p victory-hle --locked -- --test-threads=1`: | Crate | `0daabcc` | `main` (`ffe310e`) | |---|---|---| | `victory-shader` | 126 passed, 1 ignored | 120 | | `victory-gpu` | 51 passed, 1 ignored | 50 | | `victory-hle` | 95 passed | 94 | - The new `v_cmp`/`v_med3` NaN tests pass on the 7900 XT and on WARP. - No hang on AMD: the commit names a loop exit that once hung the AMD driver, and none of the shader tests here hung. - `high_performance_adapter_is_hardware` passes. With one GPU there is nothing else for it to pick, so this run does not test the laptop case. AI-assisted (Claude Code); every run was on this machine.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:29 UTC · original · edited 2026-11-25 22:23 UTC

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-gpu/src/host.rs, crates/victory-hle/src/modules/xasync.rs, crates/victory-shader/src/emit/host.rs, crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/sampler.rs). It will be reviewed once it is rebased onto the current main.

On your reply: splitting it into one PR per fix is the right call, thanks. #2812 (comparison sampler reduction) and #2813 (s_lshlN_add SCC) are separate PRs and will be triaged on their own. This PR stays as needs-rebase until you close it once the remaining parts (LOOP_LIMIT latch, is_nan part, xasync on complete_call, adapter selection) are up.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7149605879) · edited 2026-11-25 22:23 UTC <!-- victory-triage v1 head=0daabccbdec40b0b9d0f27122eda6a6de7e80b1c verdict=needs-rebase at=2026-11-25T22:23:40Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-gpu/src/host.rs`, `crates/victory-hle/src/modules/xasync.rs`, `crates/victory-shader/src/emit/host.rs`, `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/emit/sampler.rs`). It will be reviewed once it is rebased onto the current `main`. On your reply: splitting it into one PR per fix is the right call, thanks. #2812 (comparison sampler reduction) and #2813 (`s_lshlN_add` SCC) are separate PRs and will be triaged on their own. This PR stays as needs-rebase until you close it once the remaining parts (LOOP_LIMIT latch, `is_nan` part, xasync on `complete_call`, adapter selection) are up. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠rminzao on GitHub · 2026-11-25 12:14 UTC · original

Thanks, the tests that fail on main make each change easy to check. A few things from reading the head (0daabcc):

Adapter choice, crates/victory-gpu/src/host.rs

  • :183-187: on current main the default branch also runs crate::tdr::log(). When rebasing, the new high-performance branch needs it too, or the TDR warning goes away on almost every machine.
  • :236-259: only DXGI_ADAPTER_FLAG_SOFTWARE is filtered out. main's shader host (hardware_adapter, ccfb029) documents that GitHub's runner lists Microsoft Basic Render Driver without that flag. The probe here only checks FL 12_0 device creation. It does not check SM 6.6 or D3D12_OPTIONS1.WaveLaneCountMin/Max. So "first adapter that makes a device" may be one that later refuses the console's wave32 pipelines, while a capable adapter further down the list is skipped. Checking SM 6.6 and WaveLaneCountMax >= 32 (and WaveOps) before accepting would make the fallback meaningful.
  • :255: the probe device is created, dropped, then recreated at :184. Returning the probe device (or passing a null out pointer to test support) avoids the second creation.
  • :185: only the name is logged, and the fallback branch (:187) logs nothing. Vendor/device id, LUID, driver (UMD) version and the wave lane range would make bug reports from hybrid machines easy to read. #2053 adds that log on its own, without changing the selection, so it composes with whichever selector lands.
  • There is no override for the runtime: VICTORY_TEST_ADAPTER applies to the shader test host only. As the description says, this also overrides a user's per-app "power saving" choice in Windows. An env override (index or name substring, as #1630/#967 discuss) would let a user go back.
  • :289-298, high_performance_adapter_is_hardware: the function already drops software adapters, so the assertion cannot fail. It doesn't check that the high-performance adapter is the one picked.
  • #967 is the open PR for runtime adapter choice (the triage closed #208 as its duplicate). It may be worth taking this part there.

Shader test host, crates/victory-shader/src/emit/host.rs

  • :82-111: main now has hardware_adapter() with the DedicatedVideoMemory > 0 check (CI's unflagged Basic Render Driver). This version filters on the software flag only, so a straight rebase would bring back the CI failure ccfb029 fixed.
  • :97-103: the n-th adapter is taken without probing. If it fails D3D12CreateDevice or lacks SM 6.6, the whole hardware suite errors instead of trying the next one. An unparsable VICTORY_TEST_ADAPTER silently becomes 0. #1487 and #1889 change the same function; one shape would be easier for the maintainer.

LOOP_LIMIT latch, crates/victory-shader/src/emit/lower.rs

  • :6900-6908 with :6911-6922: every conditional back edge now gets a latch whose limit branch goes to the single, memoized abort_block. Before, only Jump back edges did that. Now nearly every loop in a program shares one exit block (a critical edge from each latch), and each latch is a second exit out of all enclosing loops. That is not the dedicated-exit shape the comment at :6844 aims for. It may be what trips RADV under vkd3d-proton 3.1 (matheusfermiano-source's comment) in waterfall_tests::lanes_load_from_the_buffer_their_nested_arms_chose. A fresh abort block per latch (discard + ret, so cheap) would keep exits dedicated. The SSA itself looks right: next and the compare are computed in the branching block, which dominates the latch, and the data, lane-mask and descriptor phis all look up edges for (b, header).

NaN from the bits (:1474-1511, :5366-5417, :4652)

  • The predicate table looks right to me: ordered = number compare AND both numbers; unordered = number compare OR either NaN, including o/u/f/tru. f16 operands arrive as f32 through legacyF16ToF32, so the i32 mask is valid there. On rebase, main's med3 now goes through ftz + max_min_flushed (77053a0), so only the is_nan part of this change is still new.

Comparison sampler

  • sampler.rs:79: filter & !0x180 | 0x80 is right for D3D12's reduction bits 7-8. main's immediate_sampler_slots_distinguish_comparison_uses (mod.rs:779) still builds its expectation with | 0x80, so it should use make_comparison too.

XAsync (crates/victory-hle/src/modules/xasync.rs:605-624)

  • OP_CLEANUP now runs while the call is still registered (and with call.done held). A provider whose cleanup calls XAsyncGetStatus(block, true) on its own block now finds the call and waits on the done lock its own thread holds, which deadlocks. Before, release() had already removed the call, so the wait returned. That is unlikely from a title, but release()'s comment ("it may call back into us") shows re-entry was considered. The Arc::ptr_eq guard is redundant on main (a call that is not done is always the registered one), though harmless. main now routes this through complete_call(&call, …) (#122/#1098/#247), so the change has to be redone there.
  • This part is HLE and independent of the GPU work, so on its own it would be a small, easy PR.

Scope: one commit with seven independent fixes across three crates, and five of the files conflict with main. Split into one PR per fix (each keeping its failing-on-main test), these would be much easier to review and land. Several are a few lines each (make_comparison, s_lshlN_add SCC).

Static review (AI-assisted), read against the PR head 0daabccbde; nothing was run on a GPU.

**@⁠rminzao** on GitHub · 2026-11-25 12:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7162100925) Thanks, the tests that fail on `main` make each change easy to check. A few things from reading the head (`0daabcc`): **Adapter choice, `crates/victory-gpu/src/host.rs`** - `:183-187`: on current `main` the default branch also runs `crate::tdr::log()`. When rebasing, the new high-performance branch needs it too, or the TDR warning goes away on almost every machine. - `:236-259`: only `DXGI_ADAPTER_FLAG_SOFTWARE` is filtered out. `main`'s shader host (`hardware_adapter`, ccfb029) documents that GitHub's runner lists `Microsoft Basic Render Driver` without that flag. The probe here only checks FL 12_0 device creation. It does not check SM 6.6 or `D3D12_OPTIONS1.WaveLaneCountMin/Max`. So "first adapter that makes a device" may be one that later refuses the console's wave32 pipelines, while a capable adapter further down the list is skipped. Checking SM 6.6 and `WaveLaneCountMax >= 32` (and `WaveOps`) before accepting would make the fallback meaningful. - `:255`: the probe device is created, dropped, then recreated at `:184`. Returning the probe device (or passing a null out pointer to test support) avoids the second creation. - `:185`: only the name is logged, and the fallback branch (`:187`) logs nothing. Vendor/device id, LUID, driver (UMD) version and the wave lane range would make bug reports from hybrid machines easy to read. #2053 adds that log on its own, without changing the selection, so it composes with whichever selector lands. - There is no override for the runtime: `VICTORY_TEST_ADAPTER` applies to the shader test host only. As the description says, this also overrides a user's per-app "power saving" choice in Windows. An env override (index or name substring, as #1630/#967 discuss) would let a user go back. - `:289-298`, `high_performance_adapter_is_hardware`: the function already drops software adapters, so the assertion cannot fail. It doesn't check that the high-performance adapter is the one picked. - #967 is the open PR for runtime adapter choice (the triage closed #208 as its duplicate). It may be worth taking this part there. **Shader test host, `crates/victory-shader/src/emit/host.rs`** - `:82-111`: `main` now has `hardware_adapter()` with the `DedicatedVideoMemory > 0` check (CI's unflagged Basic Render Driver). This version filters on the software flag only, so a straight rebase would bring back the CI failure ccfb029 fixed. - `:97-103`: the n-th adapter is taken without probing. If it fails `D3D12CreateDevice` or lacks SM 6.6, the whole hardware suite errors instead of trying the next one. An unparsable `VICTORY_TEST_ADAPTER` silently becomes 0. #1487 and #1889 change the same function; one shape would be easier for the maintainer. **LOOP_LIMIT latch, `crates/victory-shader/src/emit/lower.rs`** - `:6900-6908` with `:6911-6922`: every conditional back edge now gets a latch whose limit branch goes to the single, memoized `abort_block`. Before, only `Jump` back edges did that. Now nearly every loop in a program shares one exit block (a critical edge from each latch), and each latch is a second exit out of all enclosing loops. That is not the dedicated-exit shape the comment at `:6844` aims for. It may be what trips RADV under vkd3d-proton 3.1 (matheusfermiano-source's comment) in `waterfall_tests::lanes_load_from_the_buffer_their_nested_arms_chose`. A fresh abort block per latch (discard + ret, so cheap) would keep exits dedicated. The SSA itself looks right: `next` and the compare are computed in the branching block, which dominates the latch, and the data, lane-mask and descriptor phis all look up `edges` for `(b, header)`. **NaN from the bits (`:1474-1511`, `:5366-5417`, `:4652`)** - The predicate table looks right to me: ordered = number compare AND both numbers; unordered = number compare OR either NaN, including `o/u/f/tru`. f16 operands arrive as f32 through `legacyF16ToF32`, so the i32 mask is valid there. On rebase, `main`'s med3 now goes through `ftz` + `max_min_flushed` (77053a0), so only the `is_nan` part of this change is still new. **Comparison sampler** - `sampler.rs:79`: `filter & !0x180 | 0x80` is right for D3D12's reduction bits 7-8. `main`'s `immediate_sampler_slots_distinguish_comparison_uses` (`mod.rs:779`) still builds its expectation with `| 0x80`, so it should use `make_comparison` too. **XAsync (`crates/victory-hle/src/modules/xasync.rs:605-624`)** - `OP_CLEANUP` now runs while the call is still registered (and with `call.done` held). A provider whose cleanup calls `XAsyncGetStatus(block, true)` on its own block now finds the call and waits on the `done` lock its own thread holds, which deadlocks. Before, `release()` had already removed the call, so the wait returned. That is unlikely from a title, but `release()`'s comment ("it may call back into us") shows re-entry was considered. The `Arc::ptr_eq` guard is redundant on `main` (a call that is not done is always the registered one), though harmless. `main` now routes this through `complete_call(&call, …)` (#122/#1098/#247), so the change has to be redone there. - This part is HLE and independent of the GPU work, so on its own it would be a small, easy PR. **Scope:** one commit with seven independent fixes across three crates, and five of the files conflict with `main`. Split into one PR per fix (each keeping its failing-on-`main` test), these would be much easier to review and land. Several are a few lines each (`make_comparison`, `s_lshlN_add` SCC). _Static review (AI-assisted), read against the PR head 0daabccbdec40b0b9d0f27122eda6a6de7e80b1c; nothing was run on a GPU._
Author
Owner

@⁠spy0eye-beep on GitHub · 2026-11-25 21:14 UTC · original

Thanks for the thorough review. Splitting this up on current main as asked:

  • sampler reduction → #2812 (existing test updated rather than duplicated)
  • s_lshlN_add SCC → #2813 (s_min/s_max is already fixed on main, so only this part is left)

Still to come, each as its own PR: the LOOP_LIMIT latch with a fresh abort block per latch, so dedicated exits are kept; the is_nan part only, since med3 now has max_min_flushed; xasync rebuilt on complete_call so cleanup never runs while done is held; and adapter selection with the SM 6.6 and wave-lane checks, tdr::log, and an env override, coordinated with #967 and #2053. I'll close this one once those are up.

🤖 Generated with Claude Code

**@⁠spy0eye-beep** on GitHub · 2026-11-25 21:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1483#issuecomment-7174810486) Thanks for the thorough review. Splitting this up on current main as asked: - sampler reduction → #2812 (existing test updated rather than duplicated) - `s_lshlN_add` SCC → #2813 (s_min/s_max is already fixed on main, so only this part is left) Still to come, each as its own PR: the LOOP_LIMIT latch with a fresh abort block per latch, so dedicated exits are kept; the `is_nan` part only, since med3 now has `max_min_flushed`; xasync rebuilt on `complete_call` so cleanup never runs while `done` is held; and adapter selection with the SM 6.6 and wave-lane checks, `tdr::log`, and an env override, coordinated with #967 and #2053. I'll close this one once those are up. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-hle/src/modules/xasync.rs
  • crates/victory-shader/src/emit/host.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/sampler.rs
  • crates/victory-shader/src/emit/valu_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1483/head:github-bot/gh-1483'
git switch 'github-bot/gh-1483'

Merge

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