fix(shader): read lane 63 of half-wave reductions whose keys exclude helper lanes #5189
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5189"
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 EagleBearerYS on 2026-10-13T14:10:09Z.
What
On a 32-lane host subgroup (NVIDIA), a wave64 pixel program's
v_readlane_b32of lane 63 is emitted only when its half-wave scan's keys are proven zero for lanes that did not enter (EntryLaneWalk,SpirvAluEmitterMath.cpp). Resident Evil Village (PPSA01556, content 01.210.000) has 8 pixel programs with a wave-wide OR reduction: DPProw_shrORs,v_permlanex16_b32, thenv_readlane_b32of lanes 31 and 63. They fail with:The keys' mask is
exec & ~vccfrom entry inside a loop:LogicalAnd(loop exec, LogicalAnd(IEqual32(HelperInvocation, 0), ...)). The proof failed for two reasons:Now the helper test is a lane bit, and a
LogicalAndfirst looks for a false or helper conjunct before it walks an operand. The scan then maps to a subgroup reduction for lane 31 and the identity for lane 63 (MatchHalfWaveScan), as it already did for keys the proof accepted.Related: #5398 (the same message on NHL 26; a replay of the program dumped there still fails with this change, so it isn't fixed here).
Tested
maina252fcd75: two newverifyHalfWaveReductioncases inagc_shader_memory. Withmain'sSpirvAluEmitterMath.cpp,agc_shader_memoryfails with the title's message.v_cmp_gt_f32 vcc, 0, v0ands_andn2_b64 s[24:25], exec, vcc. It fails with the title's message onmainand passes with the change.LogicalAndchain. On the branch's base,6d7b87370, it fails with only the search-order half reverted and passes with the full change.agc_shader_memory,agc_shader_bindless,agc_shader_srt_read_patching,agc_shader_frontend_pair,agc_shader_frontend_pair_offandagc_shader_disk_cachepass, also with the other two Resident Evil Village fixes (listed in #5169) merged in.maina252fcd75: the same six tests pass.ReadLanefailure, and the run goes on about 160 s to a different stop (static bindless image capacity exceeded).python3 tools/check_conventions.py --base origin/main: passed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by johandavidcm on 2026-10-13T22:30:30Z.
Cross-vendor validation on one Windows machine: Windows 11 26200, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON, this PR (b6bc7218f) merged intomainc7601b797(plus #5301, a relinker resource build fix my checkout path needs).ANYPS5_REQUIRE_VULKAN=1,ctest --timeout 120 --parallel 4over the 502 agc/shader/video_out tests, then the 44 lane, wave, DPP, permlane, readlane, reduction and subgroup tests (includingagc_shader_memory,_bindless,_srt_read_patching,_frontend_pair,_frontend_pair_off,_disk_cache) with--repeat until-fail:3.ANYPS5_GPU)0x164e, subgroup 64)The 4 AMD failures (
agc_driver_pixel_interlock,agc_driver_layered_volume_draw,agc_driver_layered_volume_vertex,agc_driver_lds_mixed_width_atomics) fail identically onmainc7601b797without this PR on the same machine (#2009, #5271), so no regression on the 64-lane host, where the changed path is not taken. Not tested: PPSA01556.Imported from boykopovar/AnyPS5. Originally posted by cookie42073-cmd on 2026-10-14T04:26:43Z.
Hey everyone, I followed the NHL26 capture in #5398 through the compiler and have a small follow-up to #5189 ready locally.
Thanks to @milchgeldkassierer for the capture and @EagleBearerYS for the helper-lane proof work in #5189. With that PR applied, the capture still hit the lane-63 refusal because EntryLaneWalk kept rechecking the same loop-carried mask until it used up its budget. The follow-up reuses completed proofs, keeps proof kinds and mask halves separate, and avoids saving results that depend on unresolved Phi-cycle assumptions. The budget stays at 512.
Before/after on the same capture: pinned main
a5f493f9plus #5189 atb6bc7218fails with the lane-63 error; adding the follow-up compiles and validates 69,230 SPIR-V words. The new CPU and GPU regressions fail with the original compiler and pass with the fix. Full Windows build and all 62 selected tests passed on Windows 11 build 26300 with an NVIDIA RTX 4070 SUPER, driver 617.42. The GPU regression compares rendered reduction values with CPU expectations and covers partial waves through a saved-EXEC loop.This verifies the captured compiler failure and the synthetic tests. I haven't run NHL26 itself, tested native 64-lane hardware, or verified this on another GPU vendor. The loop test doesn't cover arbitrary changing execution masks.
The local follow-up is 9456e863e4cd4bb88ac77aa6871e86ad23a7349f, on main
a5f493f9plus #5189 atb6bc7218. @EagleBearerYS, would you prefer a separate PR depending on #5189, or a follow-up after yours merges?Once we agree on a test branch, the useful next check is a fresh NHL26 run on PPSA26785 v01.060.000: tested commit, GPU/driver/OS, and the log through its next stopping point. If another shader fails, its full RecompileRequest would let us investigate that next. We already have the capture needed for this fix; no additional game dump is needed.
AI-assisted implementation and independent review; I've checked the final commit against the saved before/after evidence.
Patch and test logs: Blazing-Cook-NHL26-proof-cache-evidence.zip
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T04:28:50Z.
Thanks, and nice find. That explains why #5189 alone still refused the #5398 capture.
A separate PR that depends on #5189 sounds best to me. It can name NHL 26 as its title now instead of waiting for #5189 to merge. Put
Depends on: #5189in it and keep #5189's commit as it is under yours.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T07:43:39Z.
Title evidence for this pull request and #5398: PRAGMATA (PPSA02530), Windows 10 (19045), RTX 4080 SUPER (NVIDIA), one run per state, no picture checked.
a57296147=main+ #5457 + #5620 + #5550): the run ends after about 45 s withwhat(): shader 0x2111516000 stage 5: ShaderRecompiler::Recompile: SPIR-V emission failed: hash=0x142024466432 stage=2 opcode=ReadLane reason=v_readlane_b32 of lane 63 is outside the 32-lane host subgroup that runs this wave64 program at one lane per invocation,PPSA02530_rR/run_093132.errlines 117 and 121.b6bc7218f, whose last commit is from 2026-10-13, so it was the head at test time; local merge tree9aea9a660): noReadLaneline inPPSA02530_rR/run_093702.err(677 lines); the run goes on for about 160 s and ends with a different stop,what(): shader 0x2111d38400 stage 5: ShaderRecompiler::Recompile: static bindless image capacity exceeded(line 128).Not established: whether the lane-63 shader of the first run is the one that compiles now (the second stop is a different shader hash; one run per state), so the link to this change is indirect.
Test conditions: the merge trees are local and not pushed (the base
maincommit was not recorded by me).ninja -j 8 libsexit 0 for each run, 128.prx;libSceConvertKeycode.prxreplaced by a local stub; title executableapp.exeof 2026-10-14 07:36:44 relinked by another session (relinker version and relink command not recorded by me); run withrun_title.ps1, 300 s limit, one game at a time.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T07:51:31Z.
Thanks for the PRAGMATA runs. I've added them to the description's Tested section and the Unblocks line, with your caveats (one run per state, indirect link).
The second stop looks like a separate limit. On current
mainthat message comes from a single check inResourceMaterializer.cpp, which throws when a bindless image's static expansion (BindlessSlots()entries) would take the shader pastShaderInfo::MaxImages(64). This PR doesn't touch that path.