fix(shader): give the frontend's call analysis the dispatch's wave size #7816
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7816"
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 Capmare on 2026-10-19T08:43:44Z.
What
AcquireFrontendbuilds the frontend'sSwappcInfowith a wave size of0u, while the driver'sLinkUserDataCalleespassesrequest.context.waveSize(ShaderRegistry.cpp). The call analysis uses that value in three places:writesScalarandoverwritesScalar(how many SGPRs a VOPC or VOP3 mask write covers) andreadsScalarDword(how many av_cndmaskmask read covers). With 0, a mask write is counted as one SGPR and a mask read as two. In wave64, av_cmp_e64that reuses a call's link pair after the return, followed by av_cndmask_b32_e64that reads it, is then refused as escaping the call/return model, because the second link SGPR still looks like it holds the return address.AcquireFrontendnow passesrequest.context.waveSize.PreparedControlFlow::Matchescompares the wave size, since the analysis depends on it. A frontend built for one wave size is not reused for another.ShaderMemory.cpptreated the wave size as translation-only state that must not change the frontend identity. They now expect a different wave size to miss (the case reported on #6191).verifyFrontendWaveSizeCalls: a call whose link pairs[14:15]is overwritten by av_cmp_eq_u32_e64and then read by av_cndmask_b32_e64, acquired as wave32 and wave64.Marvel's Wolverine (PPSA03671), the refusal this fixes (Linux,
mainc4c2b3aa7with #7395 and local patches, this change reverted):Header of that request (
agc_shader_replay): 816 code words, 16 user data, 2 memory regions, wave64; compute threads 64x1x1, partial groups 36x1x1.Tested
BUILD_TESTING=ON, onmain408455bda. The test is a CPU test, no GPU is involved.agc_shader_memory_tests --frontend-pair, run directly:APS5_NO_PERF_FRONTEND_PAIR=1;verifyFrontendWaveSizeCallsrun first: fails withscalar call link register s[14] written at program counter 0x00000000 escapes the constant-offset call/return model (used at program counter 0x0000000c), the same refusal as the title's.^agcsuite; AMD and Intel hardware; Windows.Checklist
main(408455bda); no other open PR implements the same functions (#7413 changes the call analysis and its tests inGraphBuilder, not this wiring)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file (none added).mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by Capmare on 2026-10-19T08:58:37Z.
About the overlap with #6679: it shares only the neighbouring condition in
PreparedControlFlow::Matches. #6679 addsmergedHull == MergedHullStage(request)and this PR addsswappc.waveSize == swappcInfo.waveSize. The two do not depend on each other and neither implements the other's behaviour. Whichever merges second keeps both conditions in that expression.Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T14:34:32Z.
AMD and Intel Windows data: with this PR's test changes, three
ShaderMemorytests fail onmainand pass with the PR, on an AMD RX 9070 XT and an Intel UHD 770.Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This headf976e2202merged intomain85029a00f. "Without" means only this PR's diff totests/ShaderMemory.cpp, applied tomain85029a00f.tests/ShaderMemory.cppagc_shader_frontend_pairandagc_shader_memoryfail:frontend pair: a different wave size reused the frontend.agc_shader_frontend_pair_offfails:scalar call link register s[14] written at program counter 0x00000000 escapes the constant-offset call/return model (used at program counter 0x0000000c). The other 12 passAI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Capmare on 2026-10-19T14:42:47Z.
Thanks for testing this on AMD and Intel Windows. That covers the hardware and OS my description listed as not tested, and the three failures without the change match the ones I saw.
Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T18:23:56Z.
First AMD-on-Linux (RADV) run of this PR. Merged onto
main8d5d4df96(clean merge), built in full and compared with the samemain, on the same machine.AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.
Full suite (
ANYPS5_REQUIRE_VULKAN=1 ctest -j8) at8f59bf4bd: 1638/1640 with this PR, against 1638/1640 onmain. The two failures are the same on both, so this PR adds none:agc_driver_image_table_vouched_lookups(#7766, fixed by #7916) andagc_driver_guest_memory_lifetime(#7784).Comparing the JUnit output with
main: this PR adds no ctest entry, and none is skipped or removed.This checks correctness only; I did not measure performance.
GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38
AI-assisted: yes