Shaders: lane masks spilled to VGPR lanes and read back #298
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!298
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/298/head"
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?
@permadiego on GitHub · 2026-11-24 02:08 UTC · original
permadiego:shader/lane-mask-spills→main· +289 −35 · 2 files · 1 commits · closed without mergingWhat changed
The console compiler spills lane masks like any other SGPR:
v_writelane_b32to a constant lane, thenv_readlane_b32of that lane later. InCS_RaytracingResolve, for example, a compare result (v_cmp_eq_f32 s7, 0, v21) is spilled to lane 1 ofv128. Thousands of instructions later it is read back and fed tos_and_saveexec.Two things failed on that pattern:
s_xor_b32 s8, s1, -1: "a lane mask holding lanes elsewhere read as data".Changes:
v_readlane_b32of a constant lane is taken as the mask itself when it reads back av_writelane_b32of that mask. The lookup follows writes of other lanes and joins whose arguments agree, and only applies where the mask's value dominates the read. Each lane's bit is then the one it had when spilled. A wave64 mask needs both dwords read back from the same mask.mask_spills): a read-back of this kind leaves its value to the mask's readers. The spill write is left out (the VGPR keeps its old value) when that VGPR lane is read only by such reads; no vector instruction or computed-lane read sees it. Neither instruction counts as reading the console's lanes.This no longer depends on #54, which was closed. It applies on
mainalone.Measured
victory translate --validateover the title'sshaders.rpf,mainffe310eagainst this branch (54f97db):main34 programs gain, 0 lose. Most
CS_RaytracingResolvevariants now stop at "a descriptor read only as data", which #180 covers.cargo test -p victory-shader -- --skip valu_tests --skip wave_tests: 105 passed. The skipped tests and the twowaterfall_testsneed an SM 6.6 device, which this machine lacks (sampled()returns nothing). Clippy is clean.Not verified
No GPU run here. @qntic's lane-spill hardware test and @Nixitov's world run were done on the earlier, #54-based head d0261f1, so they need a re-run on this head.
🤖 Generated with Claude Code
The console compiler spills lane masks like other SGPRs: v_writelane_b32 to a constant lane, v_readlane_b32 of that lane later. The lane pass took the read-back value for an opaque mask, and the spill write read the mask as data, which fails for a mask holding lanes not running there ("a lane mask holding lanes elsewhere read as data"). structure: a v_readlane_b32 of a constant lane that reads back a v_writelane_b32 of a mask (through writes of other lanes and agreeing joins), where the mask's value dominates the read, is that mask: each lane's bit is the one it had when spilled. Wave64 masks need both dwords read back from the same mask. lower: such a read leaves its value to the mask's readers, and a spill write of a mask is left out where that VGPR lane is read only by such reads (no vector instruction or computed-lane read sees it). Neither counts as reading the console's lanes. Co-Authored-By: Claude Opus 5.5 <[email protected]>@SpaghettiMaster545 on GitHub · 2026-11-24 03:48 UTC · original
Tested with the title at
d0261f1. The branch also carries #54's three commits, so this measures #54 + this PR together.maind2a4bae(clean), its own emptyVICTORY_CACHE_DIR,VICTORY_KEYSinto story mode, until the host GPU failure (#71, unrelated); compared program by program with amainrun made the same way (#400 has the setup).maintranslate and run, 4 of them compute programs whose pipelines the driver refused onmain. 0 programs that ran onmainstop.main's 59–111 s).Not tested: #54 alone, AMD GPUs, a release build, image results.
(Claude Code, Claude Opus 5.5: ran the title on both builds and compared the logs program by program.)
@jeremygold02 on GitHub · 2026-11-24 04:18 UTC · original
Tested PR #298 at head
d0261f1174368e2c203b42942e19b24f8f8d7787(state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged atd0261f1174368e2c203b42942e19b24f8f8d7787.cargo test --locked -p victory-shader wave64_64thread_sgpr_spills_run_on_wave32_host— passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 73 filtered out; finished in 0.59s ); cases: emit::wave_tests::wave64_64thread_sgpr_spills_run_on_wave32_host.cargo test --locked -p victory-shader pixel_shader_sgpr_spill_lowers_and_draws— passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 73 filtered out; finished in 0.32s ); cases: emit::wave_tests::pixel_shader_sgpr_spill_lowers_and_draws.Behavior covered: Checks wave64 SGPR spill lowering on a wave32 host and pixel-shader SGPR spill drawing behavior; the latter cases require a supported host GPU.
Code: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/wave_tests.rs, crates/victory-gpu/src/host.rs
@GamingRipperDoc on GitHub · 2026-11-24 05:26 UTC · original
A combination finding, from
victory translate <dump> --validate(offline, dxil.dll validator) on Windows 10 + RX 9070 XT, based2a4bae+ #175 + #336. Counts are compute programs, out of 2,581.Entry function performs some operation that is incompatible with the shader stage or other entry propertiesOn its own this PR is clean (+38 emitted, +10 of these errors). But together with #136, or with #437 (both let more scalar buffer loads through), ~540 more compute programs get through this PR's path and come out failing validation with the error above. So it looks like a shape #136/#437 expose that this PR's lowering doesn't handle validly in compute. The validator only prints the summary line here ("See other errors for details" without others).
Why it matters: VIctory doesn't validate at run time, so in game these programs go to the driver. In a play run with this PR + #136 + #305 + #385 + #302 + #193 + #437 + #54 on the stack, AMD's shader compiler crashed (
amdxc64.dll+0x85fd0f, access violation reading 0x8) after ~1 min in the world, with 250–1,000 pipelines still compiling. I can't say which program it was compiling, but this stack sends ~1,200 non-validating programs to it (these, plus #305's).I can share the per-program
--listoutput for the combination privately if it helps (it names the title's shaders, so not here).No game data in this comment.
AI-assisted (Claude Code); I ran the measurements on my machine.
@Nixitov on GitHub · 2026-11-24 06:49 UTC · original
Big effect on the RTX 5070 world run — this is the single most valuable shader PR I have tested.
Setup: Windows 11 Pro 26200.9974, RTX 5070, driver 617.14,
d2a4bae+ the GPU stack #493 + #483 + #581 + #595, release build. Same scene (first mission intro), same run length.a lane mask holding lanes elsewhere read as data(399 → 952 dropped draws is not a like-for-like ratio; the two dropped-draw numbers are the last frame line of runs at the same scene, with and without the stack.)
The count of the reason this PR targets drops from 85 to 10; the 97
a select on an untracked maskentries disappear with #585 on top. Nothing regressed in the run: still 2 fps, no device removals, and the frame log reaches the same intro scene.One integration note: merging #298 with #54-era code needed only two additive hunks in
lower.rs(guard_slotsnext toresolved_reads/pure_spill_writes, and both in the constructor), plus derivingguard_slotfromcount + dynamicwhen stacked on #483.No game files; only counts and log lines.
AI-assisted (DeepSeek V4.1 Flash coding agent).
@qntic on GitHub · 2026-11-24 11:12 UTC · original
tested on rx 6600 xt with my compute regression harness. the vgpr lane mask spill test gives 24 incorrect lanes out of 64 on main. with this pr all 64 lanes produce the expected values.
hardware tests:
https://github.com/qntic/VIctory/tree/hwtest/compute-lanes
@permadiego on GitHub · 2026-11-24 11:42 UTC · original
Rebased onto
mainffe310eas54f97db, now standalone: #54 was closed, so the spill handling this needs for masks is in this PR (mask_spillsinlower.rs). Overshaders.rpfagainstmain: +34 validated, 0 lost, "a lane mask holding lanes elsewhere read as data" 273 → 13. Tests done on d0261f1 (thanks @qntic, @Nixitov, @jeremygold02) were on the #54-based head.🤖 Generated with Claude Code
@qntic on GitHub · 2026-11-24 13:25 UTC · original
re-tested on the rebased head
54f97dbon my rx 6600 xt.the mask spill test still produces correct values, but the select pattern after vcc_hi = 0 still silently produces incorrect values in 16 of 64 lanes.
#660 is still needed to safely reject that pattern.
harness:
https://github.com/qntic/VIctory/tree/hwtest/compute-lanes
@rafaconvaitis on GitHub · 2026-11-24 18:36 UTC · original
I tested
54f97dbindependently on the 45 mesh programs that reacheda lane-mask join of an untracked maskonly after the narrow descriptor-field experiments in #798. The common base was #12698c3092fplus #953c42cbb0, with the same experimental descriptor-bit and offline stride settings in both runs. The candidate applied only the official #298 patch. I matched the same program records across both conditions.54f97db: all 45 passed Microsoft DXIL validation with the 1.8.2502.8 validator.In one representative the two restored halves both trace to a single dominating conditional EXEC mask, saved in two constant lanes of the same VGPR. That matches the spill recovery this PR implements. I only tested these 45 offline. In-title binding, draws, and the separate high-half correctness case in the RX 6600 XT report remain unverified by this test.
AI-assisted testing. No title files, shader containers or disassembly are attached.
@Sil3ntGam3r on GitHub · 2026-11-24 21:07 UTC · original
@permadiego results for
54f97dbon top of the #439 stack. It gains programs there too and loses none.Tree:
main+ #180aa69258+ #439bf0f951(with #223/#233/#320) + #431 + #876 + #334, then this PR, then #66019b02ec. The merge conflicts were all additive: both sides' fields inlower.rs, and one duplicatepaired_masksinitialiser instructure.rs. All 433 tests pass. RTX 3070, driver 621.14, Windows 11, diag build.Offline,
victory translate --validate --host-lanes 32-32overshaders.rpf, the stack without and with this PR:82 programs gain and 0 lose. Before this PR they stopped at:
On this stack, "a lane-mask join of an untracked mask" goes from 62 programs to 0. Your PR's own reason, "a lane mask holding lanes elsewhere read as data", stays at 4 both ways, so the stack already took most of those. The 47 mesh programs fit @rafaconvaitis's 45 above. Adding #660 on top changes no program's outcome, as @rpmaster2 found on
mainin #660.The
CS_RaytracingResolvevariants on this stack: 27 move from "a lane mask read as data" to "a program the console structure cannot hold" (at0x0). That refusal comes from #439's console flow, not frommain. They are refused either way. With #180 on the stack, they don't reach "a descriptor read only as data" as they do onmain.In the title, Series X, cold cache, into the world until translation caught up:
b37565055f2f7d3b,cc6def9058a4bc0a,d642969b6ff7579e) and 2 compute (015832d72477fb26,e81277c8be37103b).Not tested: AMD, a release build, this PR on plain
main.(AI-assisted: Claude Code ran the builds and compared both runs program by program.)
Pull request closed