Shaders: forward SGPRs reloaded from VGPR lanes as the spilled value #309
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!309
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/309/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?
@AntoninMichelq on GitHub · 2026-11-24 02:13 UTC · original
AntoninMichelq:up/sgpr-spill-lanes→main· +649 −15 · 6 files · 1 commits · closed without mergingRequested by 4nto · project thread
Summary
When it runs short of SGPRs, the console compiler spills a dword, often a lane mask, into one lane of a VGPR with
v_writelane_b32. It reloads the dword later withv_readlane_b32at the same lane. Reads of such a reload now read the spilled value directly, so a reloaded lane mask is again the same mask for the structurer and the lowering. This is a port of the spill resolution from #54 by alessiodeia, on its own and without #54's Wave64/host-wave changes.What changed
victory_shader::sgpr_spillmodule:forward(&mut Program)replaces every read of a reload whose VGPR lane provably holds one scalar value with that value. "Provably" covers other lanes' writes, agreeing joins, lane bits masked to the wave size, and the value being available wherever the reload runs.dead(&Program)names the spills and reloads that nothing reads any more.forwardruns right afterir::build, inemit::translateand invictory translate.s_cselect), it now lowers as "some lane is set", meaning the mask's ballot is not zero. This applies where masks may be read as data (compute). Before, it failed with "a lane mask read as data".No dependency on other open PRs.
How it was tested
cargo test -p victory-shaderon Linux: all tests pass. New tests insgpr_spill::tests:a_reloaded_mask_is_the_spilled_maska_spilled_mask_holding_lanes_elsewhere_is_used_as_a_mask_againonly_the_same_lane_written_by_a_lane_write_is_forwardeda_reload_needs_the_value_wherever_it_runsthe_scc_of_a_mask_operation_is_whether_a_lane_is_setAlso
emit::wave::tests::a_section_restores_exec_from_a_reload_of_the_saved_mask.cargo checkfor Windows (x86_64-pc-windows-msvc) passes, forvictory-shaderand forvictorywithCARGO_FEATURE_PURE=1.On the game's 26,148 programs, "a lane mask holding lanes elsewhere read as data" went from 276 to 42. This was measured with
victory translateon the integration stack.Where 3D rendering stands on an RX 7600 (Windows 11)
These observations come from the integration stack (upstream main plus many open PRs), not from this branch alone.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AZ9pSB4ZoXYUifuXg8gm66
@ifBars on GitHub · 2026-11-24 02:31 UTC · original
Tested the spill forwarding as a retry on Causeway's 32-lane translation path with the saved shaders from our RTX 3060 Ti story trace. The Windows SDK validator accepted 44 more compute shaders (53 → 97 successes out of 177 previously rejected shaders). All prior successful outputs stayed byte-identical across this set, 118 controls and a separate historical set of 50.
I sampled five of the 44 newly validated programs for compute pipeline creation on Microsoft WARP. Four created pipelines in 89–101 ms. The fifth reached our process memory guard during compilation. This measured pipeline creation only. The two mesh shaders responsible for most dropped draws in our trace still stop at sampler reconstruction.
@ifBars on GitHub · 2026-11-24 02:58 UTC · original
Correction to our earlier 44-shader result. During review we found that a separate descriptor matcher on our branch equated first-lane offsets across different active masks. Once I restricted that matcher to provable identity, only two of the 177 previously rejected shaders still validated on the combined branch. The earlier 44 additional outputs passed the DXIL validator, but they depended on the unsafe matcher and should not be counted as recovered story programs. The forwarding fixtures still pass. This issue was in our descriptor matching, separate from this PR's spill forwarding.
@SpaghettiMaster545 on GitHub · 2026-11-24 03:48 UTC · original
Tested with the title at
64c7188.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. 0 programs that ran onmainstop.main(a select on an untracked mask3,a lane mask holding lanes elsewhere read as data3,a lane-mask join of an untracked mask1) translate with this PR, but the driver refuses their pipelines withE_INVALIDARG. That is the same refusal as the 119 wave64 compute programsmainalready has on this 32-lane card, the class #233 / #320 deal with. So on NVIDIA they only run together with that stack.Not tested: this PR together with #320, 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.)
@Mesrine67 on GitHub · 2026-11-24 04:09 UTC · original
Local DXIL translation/validation comparison for this PR head
64c7188a17against its exact based2a4bae1f4, using the same local shaders.rpf, Windows SDK 10.0.26100.0 dxil.dll, and translate --validate --jobs 4:The translator's lane mask holding lanes elsewhere read as data rejection bucket fell from 276 to 20. Both runs processed 26,084 programs after skipping the same 614 duplicate containers.
This was CPU-side translation plus DXIL validation only: zero D3D12 pipelines were created, and no title code was executed. The RX 6750 XT in this Windows 11 PC was not exercised by this scan, so these numbers do not establish GPU acceptance or a rendered in-game scene. Logs are available locally if a reproducer is useful.
@EduAzevedo on GitHub · 2026-11-24 04:13 UTC · original
Measured
64c7188on the retail shaders (v1.0.2.1, Series X package), offline withvictory translate --jobs 8 --listagainstmaind2a4bae, same 26,148 programs. This was asked for in #160's thread: the 4 cubeimage_sample_d_clprograms #160 leaves ata cross-lane operation outside compute.main25e917b)f30734f)image_sample_d_clprograms translatingmainand stopBoth merges were clean (no conflicts). On its own, this PR clears
a select on an untracked mask(288 → 0),a cross-lane operation outside compute(46 → 0),an opaque lane mask(29 → 0) anda conditional export(8 → 0), and cutsa lane mask holding lanes elsewhere read as datafrom 276 to 20. Most of the programs that get further now stop ata descriptor read only as data(183 → 692).AI-assisted.
@iurysf on GitHub · 2026-11-24 04:55 UTC · original
Tested offline against main
d2a4baewithvictory translate --list --validateover the title'sshaders.rpf+ executable (26,096 programs), dxil.dll 1.9.2602.17 (DXC v1.9.2602):Entry function performs some operation that is incompatible with the shader stage or other entry properties. No program that validated on main fails now.@justlovett0 on GitHub · 2026-11-24 17:32 UTC · original
Runtime verification, Win10/RTX 3080 (driver 621.24): this PR clears the lane-mask classes at runtime — "a select on an untracked mask" (102) and "a lane mask holding lanes elsewhere read as data" (97) disappear from the captured-failure census. Those shaders then translate past masks and fail deeper (mostly "a descriptor read only as data", since cleared by #1067). Net in-game effect with #1067 stacked: untranslated 444 → 100.
Merge note for whoever integrates this with the newer main: the wave-form decision in
lower.rs(console_lanes/split/wants_console_flow) must be computed on every instruction (insts()), not on the dead-spill-filtered set. Filtering the resolved spill reloads out of that analysis picks wrong wave forms and stalls the title at boot (we hit this and bisected it). The lowering still skips dead spills viaself.dead; only the wave-form analysis needs the full set. With that, boot/menus/world all run normally.AI use: Qwen Code (underlying model name not disclosed by the tool); the boot-stall finding is from a local bisect on this machine.
Pull request closed