Repository navigation
Shaders: lane masks spilled to VGPR lanes and read back - #298
permadiego wants to merge 1 commit into
Conversation
|
Tested with the title at
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.) |
|
Tested PR #298 at head
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. |
|
A combination finding, from
On 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 ( I can share the per-program No game data in this comment. AI-assisted (Claude Code); I ran the measurements on my machine. |
|
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,
(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 One integration note: merging #298 with #54-era code needed only two additive hunks in No game files; only counts and log lines. AI-assisted (DeepSeek V4.1 Flash coding agent). |
Brings in Marvisak#704/Marvisak#193 raw-view stride table and VSH3 cache, Marvisak#329 PSV record counts, and precise copy invalidation. Kept Marvisak#54's host wave range and Marvisak#298's spilled-mask resolution; Parts now carries psv, options and host_waves, and test initializers cover all three.
|
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. |
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 <noreply@anthropic.com>
d0261f1 to
54f97db
Compare
|
Rebased onto 🤖 Generated with Claude Code |
|
re-tested on the rebased head 54f97db on 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: |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 54f97db on Windows 11, RTX 5070, MSVC: cargo test -p victory-shader -- --test-threads=1 120 passed, and cargo clippy -p victory-shader --all-targets is clean.
Measured on the title's shaders.rpf with victory translate --list, counts only, against upstream main ffe310e (this PR's base):
- "a select on an untracked mask": 289 → 0.
- Emitted: vertex/pixel 12,231 → 12,258, compute 1,441 → 1,458, mesh unchanged (8,214).
- Most of the programs it unblocks now stop at the next refusal, "a descriptor read only as data", which #180 addresses (combined numbers on #180).
Code:
- Taking a
v_readlane_b32of a constant lane as the mask itself only when it reads back av_writelane_b32of that same mask matches the console compiler's spill pattern. The lookup follows writes of other lanes, and joins only when all arguments agree. - Accepting the spill write of a mask whose lanes are elsewhere, instead of reading it as data, fixes the complement case.
- Overlap: #309 (approved) forwards spilled SGPRs from VGPR lanes generally, in a pre-pass (
sgpr_spill::forward). It covers the same pattern by another route, so whichever lands second should be checked against the other. If #309 lands, this PR'sstructure.rslookup may become redundant for masks.
AI-assisted (Claude Code).
…anes and read back Conflict in emit/lower.rs (console_lanes): this PR's spill filter plus the fork's v_permlane entry (Marvisak#576). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges the PR's current head (54f97db). Conflicts: the Lower and Lanes fields keep both sides (`spin`/`spun` and `mask_spills`; `console` and `idom`); the compute console-lane test, split here into `whole` and `in_half`, leaves the spill writes and read-backs out of `whole` as the PR did. A structure test covers a wave64 mask spilled to two lanes and read back, and a read of a lane the spill did not write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream PR #298 (lane masks spilled to VGPR lanes and read back), the two mesh commits (a lane mask's "has lanes" test and reductions over the host's wave) and PR #269 (scalars leave divergent loops and branches as the wave's last path left them). #269's new tests pass here on the RTX 4060 Ti (32 lanes), so none is ignored. Conflicts: - lower.rs: both sides' fields and helpers (guard_slots and mask_sccs with #298's mask_spills, mask_set_op and only_scc_read); the lane-read test skips both our SGPR spills (`dead`) and #298's mask spills; the mask SCC arm and #298's LANE_MASK arm side by side; data joins try the lazy barycentric first, then take #269's loop finals. - structure.rs: our console_pending with #269's idom; paired_masks stays where our tree sets it last. - valu_tests.rs: both test sets. - sgpr_spill.rs: a spilled else-mask that the per-lane form refused unforwarded now lowers there, since #298 takes the reload for the mask itself; the test asks for that, and for the console flow or the per-lane form when the lowering may choose. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I tested
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. |
A lane mask the console compiler spills with v_writelane_b32 and reads back with v_readlane_b32 no longer stops the program: the structuriser reconstructs each lane's bit from the dominating write, and the emitter drops the spill and read-back, whose readers take the lanes' bits. Ported from Marvisak/VIctory Marvisak#298. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taken from try/wave64: - #189 Wave64Mode (native / wave32 / emulate) and its LDS emulation of 64-lane waves (its helpers in emit/lower/wave64.rs, keeping lower.rs under the 512 KiB policy limit), selected with VICTORY_WAVE64_EMULATE (emulate|1|force, wave32|32, native|0, auto). Default (auto) is Native, which keeps our Target-based path; the mode is part of the shader cache key. Their wave64 tests (wave64_tests.rs, host recommendation test). - #940 mesh lanes counted the host's way when an emulate mode is chosen. - Wave scalars and whole-wave sections: sections skip dead SGPR spills as ours did; wave scalars stay off under the emulate modes. - Translator inferences: a descriptor read only as data, and a scalar use point, infer the view (ported onto our descriptor_data). - 1 MiB windows for title memory outside buffers (shadow.rs). - Trace every mesh draw (draw.rs); WARP adapter check in the test host. - #737 mip drop floor: VICTORY_TEXTURE_MIP_DROP_MIN_SIZE now defaults to 2048 (spares the 1920x1080 artwork). Kept from our side: - Target (--host-lanes, host wave sizes), split halves, console flow, whole-wave sections with SGPR-spill (dead) filtering, lane-mask lowering, #298, #269, waterfall, wave scalars (off under emulate modes). - Our VICTORY_TEXTURE_MIP_DROP (#1296: auto for <= 8 GB, NPOT exemption, subresource mapping and copy routing around dropped mips, SRV mip adjustment): list.rs, resource.rs, texture.rs, descriptor/host.rs are ours apart from the floor default. - Shader cache: VSH3 magic, KeySpec/store for offline warming, cache errors after a good translation, target key (+ wave64 mode byte). - Write-watch journal, CommittedRegions, bindless plans, copystat counters, compute early start, #1388 queue thread, #1418, #704 raw view pool/stride table, the 16 MiB stack in build.rs. Left out: #729 Agility SDK opt-in (build.rs exports, agility.rs, README note): without D3D12Core.dll beside the exe the runtime throws D3D12_ERROR_INVALID_REDISTRIBUTABLE at startup, and Windows 11 needs none. Their host-recommended Wave32 default (it never remapped lanes on NVIDIA). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@permadiego results for Tree: Offline,
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 The In the title, Series X, cold cache, into the world until translation caught up:
Not tested: AMD, a release build, this PR on plain (AI-assisted: Claude Code ran the builds and compared both runs program by program.) |
What 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,mainffe310e against 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