Shaders: fix compute lane permutations on WARP #2997
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2997
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2997"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 02:58 UTC · original
andrewpozdnakov7-jpg:codex2/warp-compute-permute→main· +196 −93 · 9 files · 3 commits · openRefs #2949
WARP 1.0.22 can return the wrong source for a compute ds_bpermute_b32 lane gather. Read within four-lane groups on the software adapter and select the requested result. Every intermediate read uses an active source, including when a branch leaves a group partially active or empty. The existing guest EXEC rule still zeroes an inactive source, and Wave64 picks from its own 32-lane half.
The runtime selects this translation after identifying its host adapter. Software and hardware DXIL use distinct shader-cache keys. Hardware continues to emit the direct lane read.
Verification
The adapter selection overlaps the host field in #2646. Both paths can share the detected software adapter.
Issue reproduction · WaveReadLaneAt semantics
AI-assisted with Codex.
Cache warming uses the same initialized D3D12 adapter classification as runtime. A synthetic compute shader warmed with a default software adapter now hits the cache on runtime lookup. The previous head missed, with the explicit software override off in both runs.
@oni-swr on GitHub · 2026-11-26 03:22 UTC · original
Independent Windows verification of
92bfec2, compared with its exact parent63bcca4(currentmain). WARP only. Runtime-limited: nothing dispatched.Scope is the claim in #1633. I checked the head, the single parent, CLEAN state and green
checkbefore starting and again before posting. No overlapping run reports were found. All data is synthetic, with no game files.Host and runtime. Windows 11 Pro 10.0.26200, rustc and cargo 1.98.1. Every device in these runs was the software adapter. Each attempt asserted this through
EnumAdapterByLuidand loggedMicrosoft Basic Render Driver, vendor0x1414, device0x008c,DXGI_ADAPTER_FLAG_SOFTWARE, 0 dedicated VRAM, withC:\WINDOWS\SYSTEM32\d3d10warp.dllloaded. That is the inbox WARP 10.0.26100.9818, not the Agility WARP 1.0.22 used for the reproduction in the description. No Agility or redistributable WARP is installed here. The physical GPU was not used. Environment:VICTORY_WARP=1(so the harness'shardwareslot is also WARP, and both labels count as WARP),VICTORY_D3D12_WARP=1, andVICTORY_DXILset to the Windows SDK 10.0.26100.0dxil.dll(1.8.2502.11). Cargo ran with-j 4 --lockedand a dedicated target directory. Before each switch between worktrees I rancargo clean -pon the affected packages, because cargo had reused the other worktree's test binary when they shared a target directory.The main limitation. This inbox WARP refuses every fixed-
WaveSizecompute pipeline that these tests build, Wave32 and Wave64. So no permute shader dispatched on either revision, and the #2949 miscompare could not be reproduced or confirmed fixed at runtime here. The existing permute tests pass on the head only through theirno pipeline … skippedpath.Commands (
cargo test -j 4 --locked -p victory-shader --lib -- synthetic_tests::permute synthetic_tests::wave64_permute verification_probe --nocapture --test-threads=1, plus a temporary local probe that was not committed):63bcca492bfec2hardware: no pipeline for a wave of 32ds_bpermute_b32cases × 2 labels (details below)dxil.dll1.8.2502.11) of every probe shadervictory-gpu --features diagnosticsshader_cache::(4 tests, no device)the_key_covers_translator_encoding_and_settingsThe parent's two Wave32 failures come from forcing WARP, not from this PR. The parent asserts on the loop label (
assert!(warp, …)), so the forcedhardwareslot fails. The head assertshost.is_software(). This is the harness-label behaviour tracked separately on #1633 (#2225), and I did not change it.Probe cases: lane maps
(k·lane + c) & 31within each 32-lane half, using 6 odd-kpermutations. EXEC was full, contiguous partial (<13,<19,<40,<51), or non-contiguous (lane & 5,& 0x22,& 0x0Anonzero). Each partial EXEC ran both straight-line (s_and_saveexec) and behinds_cbranch_execz. The probe used Wave32 and Wave64, and expected 0 from inactive sources and preserved values on inactive lanes.Routing logic, checked on the CPU. Because nothing could dispatch, I modelled
read_lane_on_warpplus therunningselect exactly as emitted. DXIL op 32 is FirstbitLo, consistent with its other uses inlower.rs. The model assumes a correctWaveReadLaneAt, so it says nothing about WARP 1.0.22's behaviour. It used random host-active sets, guest EXEC subsets of them (including empty and partial four-lane groups), and random addresses, with 20,000 trials per wave size: 328,714 Wave32 and 657,737 Wave64 lane results, 0 mismatches against ISA semantics. It also found 0 intermediate reads from a host-inactive lane: the fallback is the group's lowest active lane, or the wave's first lane when the group is empty. Wave64 sources stayed within their own half.Not verified here: the runtime fix on Agility WARP 1.0.22 (I had no such runtime), any hardware adapter (not used on purpose), full shader or workspace suites, and Clippy. Someone with Agility WARP ≥ 1.0.22, which accepts fixed WaveSize, would need to confirm the dispatch-level result.
AI-assisted: verification run and written by Claude Code (Claude Opus 5.5). The figures above come from these runs on this host.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 03:47 UTC · original
14f3b63 makes cache warming classify the same D3D12 device that runtime translation uses. The first call can initialize that device. If D3D12 is unavailable, offline translation still uses the explicit setting.
I tested the same synthetic compute container with an empty cache in a non-diagnostics build. The temporary probe made the default device call select the actual Agility WARP adapter with the explicit WARP override off. At
92bfec2, the runtime lookup missed the warmed shader. At14f3b63, it hit. The probe and the temporary selection were removed after the comparison.The cache key tests, full Agility WARP GPU suite, strict workspace Clippy in both configurations, and asset policy passed.
@steven-seagull27 on GitHub · 2026-11-26 03:49 UTC · original
I ran the four
ds_bpermute_b32tests on the exact PR head92bfec2and ran the same fixtures through the parent translator (63bcca4). I verified the DXGI adapter and loadedd3d10warp.dllpath. With app-local Microsoft WARP 1.0.22, all three independent processes gave the following readbacks.That’s 82/224 → 0/224 per WARP 1.0.22 run. RTX 5080 (621.40) returned 0/96 → 0/96 at its supported Wave32 width. Windows WARP 10.0.26100.10068 skipped both fixed widths and produced no readback. The parent comparison kept reading after mismatches so the totals cover all five dispatches. This supplies the software-runtime check requested on #2949.
I also integrated your banked-read helper with #1737. On that separate branch all five DS dispatches still matched, and WARP now matches the tested full-wave permlane row-shuffle cases as well. Integration, per-wave counts and limits
AI-assisted with Codex. Synthetic shaders and real readbacks.
@Marvisak on GitHub · 2026-11-26 05:49 UTC · original · edited 2026-11-26 07:19 UTC
Automated triage for the maintainers.
Still a merge candidate. The new commit
a4484f5only gates thelower::lowerwrapper incrates/victory-shader/src/emit/lower.rswith#[cfg(any(test, all(windows, feature = "host")))], which fixes the default-library Clippy dead-code warning. I checked its callers: the test modules, the in-file tests, andemit/host.rs, which is compiled only underall(windows, any(test, feature = "host")), so every caller is still covered. No behaviour changes.The points from our previous comment still apply:
host_shadermay create the D3D12 device on first translation; an unidentified adapter falls back to the slower four-lane form; and #233 touches the sameemit::Optionscall sites.CI: passing.
Recommending a look, not approving.
Generated by Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 06:37 UTC · original
The default library warning reproduced on
14f3b63withcargo clippy --lib -- -D warnings. Commit a4484f5 compiles the wrapper for tests and the Windowshostfeature. The FMA capability probe underhoststill calls it.Strict library Clippy passes with default and all features. Strict all-targets Clippy with all features and asset policy pass too. All six permutation tests passed with app-local WARP SM 6.6 and the DXIL validator.
Please retain the Git author if moving this change. If it is folded into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.@kotekompotek on GitHub · 2026-11-26 03:03 UTC · original · approved these changes
LGTM — fixes #2949. Verified the workaround's mechanism: each bank iteration calls WaveReadLaneAt with a uniform group base (only the within-bank index diverges), which is precisely what avoids WARP 1.0.22's wrong four-lane-group selection;
requestedpicks the iteration matching the target's bank. Dead-bank reads use the wave's first lane (live source), dead in-bank targets use popcount(mask) — harmless sincerunningzeroes inactive sources downstream. Cache key covers warp_permute; uses_software_adapter() resolves pre-device via prefer_warp for offline translate. The active=19 test cuts through a bank — the discriminating case.@fuzeofficlal on GitHub · 2026-11-26 03:22 UTC · original · requested changes
Code review on
92bfec27(static source inspection; no runtime WARP/GPU execution):translate --cache) can warm the wrongwarp_permutevariant vs runtime (apps/victory/src/translate.rs:372,crates/victory-gpu/src/host.rs:56-69, 216,crates/victory-gpu/src/shader_cache.rs:84-98):uses_software_adapter()checksHOST.get(), falling back toprefer_warp()(cfg!(feature = "diagnostics") && switch::on("VICTORY_D3D12_WARP")) before a device exists.translate::warm), noHostis created, souses_software_adapter()always returnsfalseunlessdiagnostics+VICTORY_D3D12_WARPare both set. At runtime,Host::createsetshost.software = warp || on_software_adapter(&device).build(false)while runtime looks upbuild(true), missing every warmed shader (and forcing full re-translation on startup).@Dukestar69 on GitHub · 2026-11-26 06:12 UTC · original · reviewed
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):cargo test -p victory-shader permute -- --test-threads=1(RTX 5090 & WARP): 6 passed, 0 failed on both.cargo test -p victory-gpu shader_cache::tests: 4 passed, 0 failed.cargo xtask policy: 191 files ok.One small warning caught in non-test lib builds (
cargo test/cargo check --lib):lower::loweris now only called from#[cfg(test)]modules (emit/mod.rscallslower_with), so gatingpub(crate) fn lowerwith#[cfg(test)](or removing it) will keepcargo clippy --lib -- -D warningsclean.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 11:00 UTC · original · edited 2026-11-26 11:10 UTC
I tested the exact
a4484f5head with #2225 atd239815on63bcca4, keeping one executable per source tree across the three packages. Every run loaded Agility SDK 1.620.2 and the designated app-local WARP DLL, as verified by inspecting the loaded modules.The original varying-source and Wave64 readbacks passed in all three combined full-suite runs. The remaining permutation failure is intermittent in
permutes_mask_high_address_bits_and_divergent_branches. The 1.0.22 full run returned a nonzero value for lane 18 in the 19-active-lane case. Across the separate focused runs, lanes 14, 17, or 18 occasionally returned nonzero values where their selected source lanes were inactive and the expected value was zero. Each focused run used a fresh process. The existing edge-flagged mesh test failed on all three package versions in both trees.Native control. I compiled five CS 6.6 variants with DXC and ran 512 groups of 32 lanes per variant, with 16 through 19 participating lanes. Across three fresh runs on each listed WARP version, both the plain arithmetic control and the ballot taken before divergence matched all 147,456 values each. A ballot taken inside the divergent branch, with arithmetic in place of the lane reads, produced 198–530 mismatches per 16,384 values. The banked-read variants also reproduced mismatches with DXC optimizations on and off. This narrows the remaining behavior to a divergent wave operation on these WARP runtimes. The banked-read workaround still fixes the original permutation cases in the table.
@fuzeofficlal on GitHub · 2026-11-26 11:15 UTC · original · approved these changes
Reviewed the WARP compute lane-permutation lowering, shader cache keying, and adapter detection changes at
a4484f58.read_lane_on_warpsplitsds_bpermute_b32into 4-lane bank iterations using the active-lane ballot per bank, falling back toFirstbitLo(unaryBits.i32op 32) within nonempty banks andwaveReadLaneFirst(me)for empty banks so everyWaveReadLaneAtreads either a uniform lane or strictly within a single live 4-lane group.uses_software_adapter()keepsvictory translate --cachealigned with runtime cache lookups whilewarp_permutein the shader cache key cleanly separates hardware and software entries in the shared cache directory.a4484f58cleanly resolves the non-test dead-code warning on thelower()wrapper (cargo clippy -p victory-shader --lib -- -D warningspasses).Verified locally on Windows 11 with RTX 5090, WARP (
VICTORY_D3D12_WARP=1with--features diagnostics), D3D12 Debug Layer (VICTORY_D3D12_DEBUG=1), and Windows 11 SDKdxil.dll:cargo xtask policy(191 files ok) andcargo clippy -p victory-shader -p victory-gpu -p victory --tests -- -D warnings(default and--all-features): clean.victory-shaderpermutetests: 6/6 passed (covering both RTX 5090 and WARP, Wave32/Wave64 halves, and non-4-aligned divergent active counts16and19).victory-gpushader_cache::tests: 4/4 passed on RTX 5090 and 4/4 on WARP + Debug Layer;draw::tests::compute_view_marks_rebind_after_depth_twin_conversion: passed on WARP + Debug Layer.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.