Repository navigation
fix(recompiler): skip window narrowing when it adds too many switches - #10053
oneandonlydean merged 1 commit into
Conversation
Narrowing the vector window (30fab07) puts every slot the bound analysis did not reach into its own variable. Each relative access that is not a constant index then emits a switch over all of those variables, whether or not the analysis could bound its index. A shader with many relative accesses grew by one switch per access: a mesh shader of PPSA31371 came out at 4.2 MB of SPIR-V, and the NVIDIA driver spent minutes compiling it while the game waited at frame 23. IndexedWindowSlots now counts the dynamic accesses and keeps the whole window in the array when the switches would pass 4096 cases in all (accesses times slots outside the array times lanes). Shaders with a few relative accesses are narrowed as before. The vector window tests recompile a 32-register window with 2 and with 300 relative reads from a user data index, and check the narrowed shape and the switch case count.
65499ed to
8eec91e
Compare
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
OK. The cap logic, its wiring, and the test shape all check out from the branch:
One design note, non-blocking: 4096 is a judgment call rather than a measured threshold — it's documented inline next to the constant, which is the right place for it, but if a future title regresses compile times with windows just above the cap, this constant is the first knob to revisit. Envelope: current Disclosure: Windows host; I read the full diff and the touched functions' surroundings but did not build the shader backend or execute the narrowed/narrowed-off comparison — the fix's effect on the triggering shader is author-reported. |
|
Windows run on a second NVIDIA GPU and on Intel. Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 r7, Release. NVIDIA GeForce RTX 3060 Ti (driver 617.42) and Intel Arc Graphics (Meteor Lake, driver 101.9150), selected with
AI-assisted: yes (Claude Code) |
What
Window narrowing (30fab07) puts every vector window slot the bound analysis did not reach into its own variable. Each relative access that is not a constant index then emits a switch over all of those variables, whether or not its index could be bounded. A shader with many relative accesses therefore grew by one switch per access.
IndexedWindowSlotsnow counts the dynamic accesses and keeps the whole window in the array when the switches would pass 4096 cases in all (accesses, times slots outside the array, times lanes). Shaders with a few relative accesses are narrowed as before.APS5_NO_WINDOW_NARROWING=1still turns narrowing off.Why: TEKKEN: DARK RESURRECTION (PPSA31371) has a mesh shader with many relative accesses. With narrowing on, its cached SPIR-V was 4.2 MB, and the game stopped advancing at frame 23 for more than 10 minutes. Backtraces taken during the stall showed the NVIDIA driver's shader compiler working on that one shader. See discussion #10051.
Tested
agc_vector_window_tests: a 32-register window with 2 relative reads from a user data index stays narrowed (more than 8 function variables, switch cases present), and the same window with 300 reads does not grow a switch for each (at most 4096 cases, fewer function variables than the 2-read shader).agc_vector_window,agc_vector_window_stage_inputsand the GPU execution testsagc_driver_vector_window_narrowing,agc_driver_relative_indexing,agc_driver_relative_indexing_known_bits,agc_driver_relative_stage_inputs,agc_driver_relative_ancillary,agc_driver_vector_window_direct_access,agc_driver_vector_window_liveness,agc_driver_window_lane_spillandagc_driver_scalar_relative_indexingall pass (11 of 11).APS5_NO_WINDOW_NARROWING, with fix(libSceFont): render a glyph into a zero-extent surface to measure it #9992 and fix(libSceFont): resolve a default string direction at creation #10021 applied: it runs past frame 2677, where it previously stopped at frame 23.The 4096 limit is a judgment call, not a measured optimum. I did not measure the speed effect on the title that narrowing was written for (PPSA08427), so a shader like that with many unproven accesses would now keep its whole window in local memory.
Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryAPS5_NO_WINDOW_NARROWING)AI-assisted: yes. Written with AI assistance and reviewed by me.