Repository navigation
Shaders: fix compute lane permutations on WARP - #2997
andrewpozdnakov7-jpg wants to merge 3 commits into
Conversation
kotekompotek
left a comment
There was a problem hiding this comment.
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; requested picks 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 since running zeroes 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.
|
Independent Windows verification of Scope is the claim in #1633 (comment). I checked the head, the single parent, CLEAN state and green 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 The main limitation. This inbox WARP refuses every fixed- Commands (
The parent's two Wave32 failures come from forcing WARP, not from this PR. The parent asserts on the loop label ( Probe cases: lane maps Routing logic, checked on the CPU. Because nothing could dispatch, I modelled 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. |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Code review on 92bfec27 (static source inspection; no runtime WARP/GPU execution):
- P2 — Offline shader cache warm-up (
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.- During offline warm-up (
translate::warm), noHostis created, souses_software_adapter()always returnsfalseunlessdiagnostics+VICTORY_D3D12_WARPare both set. At runtime,Host::createsetshost.software = warp || on_software_adapter(&device). - On any machine where the default D3D12 device resolves to a software adapter (e.g., WARP-only host / VM, or when DXGI adapter lookup fails), warm-up populates cache entries under
build(false)while runtime looks upbuild(true), missing every warmed shader (and forcing full re-translation on startup). - Suggest determining adapter classification consistently between warm-up and runtime (or populating/detecting the software adapter in warm-up when applicable).
|
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 The cache key tests, full Agility WARP GPU suite, strict workspace Clippy in both configurations, and asset policy passed. |
|
I ran the four
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. |
|
Automated triage for the maintainers. Still a merge candidate. The new commit The points from our previous comment still apply: CI: passing. Recommending a look, not approving. Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
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):
warning: function `lower` is never used
--> crates\victory-shader\src\emit\lower.rs:98:15
lower::lower is now only called from #[cfg(test)] modules (emit/mod.rs calls lower_with), so gating pub(crate) fn lower with #[cfg(test)] (or removing it) will keep cargo clippy --lib -- -D warnings clean.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
The default library warning reproduced on 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 |
|
I tested the exact
The original varying-source and Wave64 readbacks passed in all three combined full-suite runs. The remaining permutation failure is intermittent in 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
left a comment
There was a problem hiding this comment.
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=1 with --features diagnostics), D3D12 Debug Layer (VICTORY_D3D12_DEBUG=1), and Windows 11 SDK dxil.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.
Refs #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.