Shaders: wave-uniformity proof: values from loops the lanes leave apart, and writes in part (follow-up to #173) #184
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!184
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-184"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@HamudL on GitHub · 2026-11-26 10:43 UTC · original
HamudL:fix/lane-uniform-soundness→main· +476 −29 · 4 files · 4 commits · openFollow-up to #173 (#101). Independent of it: it merges cleanly with #173 in either order.
What was wrong
lane_uniformdecides whether a value is the same in every lane of a console wave. On a host of 32-lane waves, av_readfirstlaneof such a value lets each host wave take its own first lane instead of exchanging halves. WithVICTORY_FIRSTLANE_OWNretired in #173, this proof is the only thing that allows that. Even before #173 it decided whether the exchange happens in blocks every lane runs. Two holes made it call values alike that are not:Example (new test): lanes 0..31 leave after one turn, lanes 32..63 after two, and v8 is the turn's number. After the loop the console's
v_readfirstlanegives lane 0's 1. The upper host wave took its own lane 32 and got 2.368293eonly swaps andmacaccumulators read their old destination. But 16-bit results keep the other half of the destination (write_half),v_fma_mixlo/hido too, andv_dot2c/v_dot4caccumulate into it.What changes
LaneUniform::alike_at(value, block)replaces the plain set. A value made in a loop the lanes may leave at different turns is alike only in blocks inside that loop. A loop counts as left apart when one of its exits branches on a lane condition not shown alike, or lies in the region of such a branch inside the loop. These loops are natural loops, fromir::idoms.v_cmpxjoins the VALU rule. On alike operands its EXEC keeps or drops every lane of the console wave together, so a loop the console wave leaves together keeps its values alike after it. This is the case for the builder's prefix scans (wave_prefix_programstill lowers for waves of 32).keeps_old(name): accumulators, swaps and 16-bit results read their old destination again. Whole writes still leave it only to the lanes outside EXEC.TRANSLATOR_VERSIONgoes from 1 to 2: programs with such reads now translate differently (the exact exchange instead of each host wave's own lane). This also covers the change to #142's proof inmain, which came without a bump.Checked
cargo test -p victory-shaderon Linux: 213 passed (209 before, plus 4 new lowering tests oflane_uniform). Together with #173: 216.cargo clippy -p victory-shader -p victory-gpu --all-targets [--all-features] --target x86_64-pc-windows-msvc -- -D warnings: clean. This was a cross-check from Linux, withCARGO_FEATURE_PURE=1for blake3.Needs a run
cargo test -p victory-shader --locked a_first_lane_read_after_a_loop -- --nocaptureIt should pass. On
mainit should fail, with threads 32..63 storing 2.VICTORY_HOST_WAVE=32 victory translate --list <game folder>before and after. The builder's 53 programs should still get host pipelines withVICTORY_BVH_BUILDER=1on a wave32 host.@ArturoWolff on GitHub · 2026-11-26 11:40 UTC · original
Confirmed the requested divergent-loop regression on physical NVIDIA wave32 hardware. The original behavior reproduced exactly, and the correction gives the console-wide lane-0 value in both host waves.
Matched source comparison (November 26, 2026):
9576c45f1d551be0cfde154da027707658ce031e(the tested shader change's direct parent).6e4cf83da5c36b16d869ee635b4cd974214f36b8, without #173 or unrelated main changes.82396e7dd7ba038cbe6d880d3cf5aee0645631a1differs from the tested candidate only by a type-annotation correction in the loader's descriptor-sites test. I did not rebuild that later head.Environment: Linux, RTX 4060 (8188 MiB dedicated VRAM; NVIDIA 620.73.04), GE-Proton 11-14 / Wine 11.0 Staging, vkd3d-proton build
71cae091b06571e, D3D12 shader model 6.6, actual wave-lane limits 32..32. Separate locked/offline Cargo targets and fresh test processes, separate copies of the same game-free prefix, initially empty private driver-cache directories, matching runtime/DXC DLLs. Windows-target shader library tests were cross-built with LLVM MinGW (x86_64-pc-windows-gnullvm) and executed under Proton, not native Windows.a_first_lane_read_after_a_loop_the_lanes_left_at_different_turnsa_first_lane_read_of_a_wave_alike_sum_under_a_wave_alike_loopa_lane_dependent_prefix_cannot_take_its_own_first_lanevictory-shader --libsuiteBoth physical tests in each arm actually validated the emitted DXIL, created the compute PSO, submitted the dispatch, waited for its fence, read the entire result and checked the device afterward. The divergent test's emitted DXIL was 2432 bytes before and 2492 after (translator version 1 -> 2); the existing prefix control was 2588 bytes in both. No hardware/validator skip counted as a pass. The four additional native lowering tests also passed. In total: four physical readbacks, five passing focused invocations including the two rejection controls, and the one intended baseline failure. No new monitored kernel GPU fault or host OOM kill occurred; all guarded test scopes retired. The successful child results are distinct from a local evidence parser that initially rejected interleaved driver diagnostic lines; the original logs and exits were preserved and reconciled without repeating completed hardware tests.
For reproduction, cross-build each isolated tree with
cargo test --locked --offline --profile diag -p victory-shader --lib --no-run --target x86_64-pc-windows-gnullvm, then run the resulting shader test executable under the matching Proton/runtime environment withemit::wave64_tests::<test name> --exact --test-threads=1 --nocapture. The driver's physical readback is the discriminator, not merely a successful translation or test count.This answers the first requested GPU check. The existing accepted prefix behavior is preserved on this device. I have not checked the second requested title-wide translation counts or all 53 builder program pipelines, nor exercised a separate physical writes-in-part regression or the combination with #173. The result supports the shader correction, but it does not yet demonstrate a retail lighting fix, gameplay stability, FPS, or AMD/native Windows behavior. No game data, captures, executable bytes or extracted shaders are included.
AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).
@HamudL on GitHub · 2026-11-26 13:25 UTC · original
Thanks for running it on real wave32 hardware. That is exactly the readback the test was written for (32 × 1 then 32 × 2 on main, 64 × 1 with the fix), and the prefix control staying identical is the important no-regression part.
For the second hole (writes in part) there is now a hardware test in this PR as well:
a_first_lane_read_of_a_register_a_16_bit_result_wrote_in_part(acb01d0). v1 holds the lane's number in its high half, av_add_f16writes only the low half, and every thread stores the first lane's v1. Expected: 64 ×0x4200; on main the upper host wave stores0x0020_4200. It follows the loop test's pattern (explicit wave32 check, the PSO must be created). If you can run it the same way, that covers the translator side. The translation counts and the 53 builder pipelines still need a game run.@ArturoWolff on GitHub · 2026-11-26 14:02 UTC · original
The new writes-in-part regression also reproduces exactly on the RTX 4060 / Proton setup from the earlier test. Thanks for adding the explicit hardware oracle.
Matched physical wave32 comparison (November 26, 2026)
9576c45f1d551be0cfde154da027707658ce031e, the parent of the translator correction.acb01d0eda3d77bf29f0c3d8d1b4fe2b748b55c3, containing the new authored test and the correction in6e4cf83da5c36b16d869ee635b4cd974214f36b8.a_first_lane_read_of_a_register_a_16_bit_result_wrote_in_partfixture, with matching test-only instrumentation to require validation, the physical wave32 device, PSO creation, and a completed full-buffer readback. No production translator changes were added locally.0x0000_42000x0000_42000x0020_42000x0000_4200Both Windows-target shader test builds completed successfully. Each arm actually validated the emitted DXIL, created the compute pipeline, waited for the submitted dispatch to finish, read all 64 words, and checked for device removal afterward. The result is not a skipped hardware test. The retained divergent-loop control executable also passed again, with all 64 words equal to 1.
Conditions: Linux, NVIDIA RTX 4060, 8188 MiB VRAM, driver 620.73.04, SM 6.6 and wave-lane limits 32..32; GE-Proton 11-14 / Wine 11.0 Staging, vkd3d-proton
71cae091b06571e. Separate locked/offline Cargo targets, separate fresh copies of the same starting prefix and matching DLLs, initially empty private driver-cache directories. The isolated no-display prerequisite attempt timed out during graphics initialization; a fresh private Xvfb session enabled the known-good control and both new arms. No game, desktop capture, or input was involved. External host-memory guard at 512 MiB; no guard stops, host OOM kills, or monitored kernel GPU faults in the successful qualification arms.For reproduction, cross-build with
cargo test --profile diag -p victory-shader --lib --no-run --locked --offline --target x86_64-pc-windows-gnullvm, then execute the resulting test binary under matching Proton withemit::wave64_tests::a_first_lane_read_of_a_register_a_16_bit_result_wrote_in_part --exact --test-threads=1 --nocapture. Use the same authored fixture on the parent, and require the actual fenced readback on both sides.This extends the earlier divergent-loop qualification to the second reported translator hole. The title-wide wave32 translation counts and the 53 builder pipelines remain untested here. No claim of retail rendering correctness, FPS, AMD behavior, or native Windows validation follows from this fixture.
AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol Max).
@HamudL on GitHub · 2026-11-26 16:35 UTC · original
Hardware check on AMD under native Windows, the item left open above.
Setup: AMD Radeon RX 7800 XT (Navi 32,
VEN_1002&DEV_747E, the only GPU in the system), Adrenalin 26.8.1 (driver 32.0.31041.1004), Windows 11 Pro 26H2 (build 26300.10075), D3D12 wave lanes 32..64. rustc 1.98.1, MSVC 14.44, Windows SDK 10.0.26100.0 withdxil.dll1.9.2602.17, so every shader also passed the official validator before its dispatch.Trees:
acb01d0(this PR), and the same tree withlower.rsfrom9576c45(the translator before this PR, tests unchanged). Thelower.rsblob was checked before every run.a_first_lane_read_after_a_loop_the_lanes_left_at_different_turnsa_first_lane_read_of_a_register_a_16_bit_result_wrote_in_part0x4200, threads 32–63 store0x204200a_first_lane_read_of_a_wave_alike_sum_under_a_wave_alike_loopThese are the same readbacks as on the RTX 4060 under Proton.
The whole
victory-shadersuite onacb01d0: 307 passed, 0 failed, 4 ignored. With--nocapture, 11 tests report a hardware run, and none reports "not run", "no SM 6.6" or "does not support wave32". The only skips are the fourdiff_teststhat need the console's dxc and two WARP sub-passes.#173 (
b3b6f2b) on the same PC: the 15first_lanetests pass, the prefix-scan test on the GPU.Not covered: a game run (the wave32 translation counts and the 53 builder pipelines).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.