fix(shader): forward vector window stores to loads within basic blocks #4213
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4213"
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?
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-12T01:33:21Z.
What
Forwards
StoreVectorWindowvalues to subsequentLoadVectorWindowinstructions with matching constant indices within the same basic block during shader simplification (Recompiler.cpp).In shaders with relative vector addressing (
v_movrels_b32/v_movreld_b32), vector registers are mapped into the function-scopevector_windowarray. When intra-wave reduction sequences (e.g.v_max_f32with DPP or Permlane16) write intermediate steps into windowed registers and immediately read them, the load previously remained as a separateLoadVectorWindowinstruction. This broke the SSA expression tree, preventingMatchHalfWaveScanandReadLaneEliminatorfrom optimizing the reduction and leading to illegal lane reads outside the host subgroup (e.g.v_readlane_b32of lane 63 on 32-lane host subgroups).core/libs/prx/libSceAgcDriver/tests/VectorWindow.cpp(agc_vector_window_tests) verifying:OpAccessChaininstructions (shape.accessChains == 2).shape.accessChains == 4).Tested
agc_vector_window_testspassed (100% inctest -R "^agc_vector_window$"). Full vector instruction suite passed (wave32_wide_subgroup,vector_min_max_med16, etc.).0x500798d00recompiled successfully into 302,178 SPIR-V words without throwing. Reached live 3D in-level gameplay past 320 seconds without crashing (1,322 frames presented, 77,600 dispatches executed).python3 tools/check_conventions.pypassed with zero errors.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-12T21:23:08Z.
Windows run, to go with the Linux one in the description.
Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head
26d03715cmerged intomain42496c5e5.agc_vector_windowandagc_vector_window_stage_inputspass with--repeat until-fail:3, and the full suite (ctest --timeout 120 --parallel 4) passes 1007 of 1007, on both GPUs.main'sRecompiler.cpp: the build recompiled it and relinkedagc_vector_window_tests, and both cases still see one array of length 2 with 2 and 4 access chains. So onmainthese two programs already compile to the shapes the checks expect, and the tests don't fail without the change. A program thatmaingets wrong, such as thev_readlane_b32of lane 63 on a 32-lane subgroup from the description, would pin it.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:19:04Z.
Does compute shader
0x500798d00still stop on main since #4162? That one follows a constant-slot window load to its last store when matching the half-wave reduction, which is the case described here. If it still stops, please quote the log line and add a test that fails on main: kr4y4's run shows both new checks pass with main'sRecompiler.cpp.Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-13T06:25:38Z.
Thanks @oneandonlydean and @kr4y4 for the verification and review. Indeed, with #4162 merged into
main, the half-wave reduction matcher inSpirvAluEmitterMath.cpp(StoredWindowValue) already tracks constant-slot window loads to their last store directly. On currentmain, compute shader0x500798d00compiles and runs without throwing, andagc_vector_window_testspasses onmainwithout this patch. Since #4162 resolves the underlying half-wave reduction issue cleanly and there is no differential failure onmain, closing this PR to keep the tree clean.Pull request closed