Repository navigation
Pick the discrete GPU on laptops; fix driver-dependent and wrong shader lowering - #1483
spy0eye-beep wants to merge 1 commit into
Conversation
…er lowering 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 <noreply@anthropic.com>
|
A Linux/Proton data point on AMD. With this PR, a Radeon 660M (RDNA2, RADV Mesa 26.3.1, waves 32..64), head
Built on Linux with llvm-mingw for |
|
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.
All the new tests pass, including On @matheusfermiano-source's RADV crash: Synthetic tests only, no game files. AI-assisted (Claude picked the PRs and wrote the batch script; I ran it on my machine). |
Offline measurement on a retail dump, and the shader tests on AdaResult: no count change against Offline. I merged head 0daabcc onto No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on Tests: with the same merge, No shader names or data are included, per the asset policy. AI-assisted (Claude Code). |
…sing group barriers (watch item 111) Case 1 (Marvisak/VIctory#1483 fix 3): a conditional back edge folded the limit into its branch condition, so a lane at the limit took the loop's exit and stored what it had (WARP: 16384). Each back edge now goes through a latch of its own that sends a lane at the limit to the abort block. Ported from Marvisak/VIctory#1483 (head 0daabcc) by spy0eye-beep. Case 2 (VItoriaBr 808a209): a lane the limit stops returns, and a group barrier the others reach later would wait for it. In a compute or mesh program where a group barrier can follow a loop, every lane that ends (at the limit or at the end) counts itself ended in two group-shared counts, by the parity of the barriers it has passed (an SSA count, block to block), and passes group barriers until every thread has ended: all return after the same barrier (item 94's form, reimplemented; VItoriaBr's rule, dropping the sync, is not taken). Outside flow.rs: the `drain` field of `Lower` and its initialisation (lower/mod.rs, granted by the orchestrator), and the `mod` line of the new loop_limit_tests.rs (emit/mod.rs).
|
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. |
|
Tested on NVIDIA: an RTX 4050 Laptop on Windows 11, with this pull request merged onto
I had opened #1689 with only the |
|
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 |
|
RX 7900 XT (RDNA3, driver 32.0.31036.15, the machine's only GPU): green.
AI-assisted (Claude Code); every run was on this machine. |
|
Automated triage for the maintainers. Needs rebase. This pull request conflicts with On your reply: splitting it into one PR per fix is the right call, thanks. #2812 (comparison sampler reduction) and #2813 ( Generated by Claude Code |
|
Thanks, the tests that fail on Adapter choice,
Shader test host,
LOOP_LIMIT latch,
NaN from the bits (
Comparison sampler
XAsync (
Scope: one commit with seven independent fixes across three crates, and five of the files conflict with Static review (AI-assisted), read against the PR head 0daabcc; nothing was run on a GPU. |
|
Thanks for the thorough review. Splitting this up on current main as asked:
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 🤖 Generated with Claude Code |
The host device and the shader test host were made on the default adapter, the integrated GPU on a laptop with two. Now the first hardware adapter in DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE order that makes a D3D12 device is used, its name logged; software adapters (WARP, the Basic Render Driver) never. VICTORY_TEST_ADAPTER=n runs the tests on the n-th hardware adapter. Same change as PastiiJay/klbf-lab#22 and Marvisak/VIctory#1483. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comparison bit was OR-ed into a filter that already holds the reduction in bits 7-8, which turned a minimum sampler (0x100) into a maximum one (0x180). StaticSampler::make_comparison replaces the reduction; comparison_replaces_the_reduction covers standard, minimum and maximum reductions. immediate_sampler_slots_distinguish_comparison_uses builds its expectation with it too. Split out of Marvisak#1483. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
mainand 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_PERFORMANCEorder 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=npicks 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_u32SCC was set to
result != 0. Fors_min/s_maxit is the comparison that picked the result (RDNA2 ISA);s_lshlN_addsets it to a carry, which is nowMissing(fails loudly if read) instead of silently wrong.Test:
scalar_min_max_set_scc_to_the_comparison(onmain:s_min_i32(2, 1)gives SCC = 1, want 0).3. Shaders: a loop stopped by
LOOP_LIMITthrough a conditional back edge kept runningThe 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 (asJumpback edges already did); header phis take this edge's values from the latch viaedges.Test:
loop_stopped_by_the_limit_stores_nothing(onmain: stores0x100000).4. Shaders: NaN handling in
v_cmp_*_f32/f16independent of the driverOn Intel UHD Graphics,
v_cmp_eq_f32 v1, v1with a NaN gives true (the driver foldsx == 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. Noxorof a compare is emitted (see the old comment about the AMD driver hang): "not NaN" is its own compare (is_number). This also replaces thev_cmp_lgspecial 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/f16v_med3_f32(1.0, 2.0, NaN)gave 2 (the existingv_med3_f32_matches_rdna2_with_nanfails there onmain).max_min, so -0 orders below +0 like the hardware's min/max. OnmainWARP givesmed3(+0, -0, 1) = -0, and Intelmed3(+0, NaN, -0) = +0(want -0).Test:
v_med3_f32_orders_negative_zero_below_positive_zero.v_cvt_u16/i16_f16also uses the bit test for NaN now (no failure observed; same pattern).6. Shaders: comparison samplers
s.filter |= 0x80on a filter that already holds a reduction in bits 7-8 turned a minimum sampler (0x100) into a maximum one (0x180).StaticSampler::make_comparisonreplaces the reduction.Test:
comparison_replaces_the_reduction.7. HLE:
XAsyncCompleteraceFor 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_PENDINGfor a call that had ended. Status and unregistering are now done together under theCALLSlock (the call is removed only if it is still the sameArc, so a reused block is never touched). Behaviour change to note: the provider'sOP_CLEANUPnow runs while the call is still registered, before the status is published.Test:
waiting_never_sees_a_failed_call_still_pending(onmain: returnsE_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.
VICTORY_TEST_ADAPTER=0)VICTORY_TEST_ADAPTER=1)cargo test --workspace --all-featurescargo clippy --workspace --all-features --all-targets -- -D warnings: cleancargo xtask policy: 154 files okcargo build --release -p victory: okNot tested: an AMD GPU, and the title (no game data used).
AI-assisted (Claude).
🤖 Generated with Claude Code