perf(shader): keep the BDA byte loops rolled #21131
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21131"
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 Ketz7 on 2026-11-15T20:59:48Z.
What
read_bda_dword_bytes*(the byte path of a guest read) andwrite_bda_bytes*(the byte path of a guest write) loop over the bytes of an access, and every iteration looks the byte up in the BDA range table. Both loops now carryDontUnroll; the code they run is unchanged.DontInline), each unrolled iteration gets its own copy of the range lookup, at every call site.0x20c60f400, 152,566 SPIR-V words), that makes the pipeline take over a minute to create on an RX 7900 XT. vkQuake shows no frame until it is done.ShaderMemory's BDA read-function check andBdaContracts' runtime V# write check now fail if either loop losesDontUnroll.Tested
APS5_DUMP_COMPUTE_PIPELINESand edited by hand. Each variant was timed withagc_compute_pipeline_replay, with AMD's driver cache moved aside before every compile. The edited variants differ from the capture only in loop-control operands:DontUnrollon all 18 loops of the BDA helpers: 26.1 s and 28.0 s, against 55.8 s and 53.4 s unchanged.note_bda_write's loop: 52.7 s;r_rtshadows 1), AMD's driver cache moved aside,APS5_PROFILE_DRAW=1, the driver's line for the shadow pipeline:main7085a08145:[dispatch] created a pipeline for 152566 SPIR-V words in 100822 ms3a78eef0e8:[dispatch] created a pipeline for 152566 SPIR-V words in 35475 msmainthe title exited by itself after 7.8 s with no present (guest-exit, exit code 1). On this PR it rendered (1,795 presents in 40 s). On this machine,mainrendered that cold start in earlier runs too, so this is one observation, not a claim.APS5_TRACE_SECONDS=10:20and no otherAPS5_TRACE_*orAPS5_PROFILE_*switch, 1,199 presents each at 60 Hz:mainand 16.678/16.926/16.997/17.064 ms here;ANYPS5_REQUIRE_VULKAN=1, every test fromagc_driver_bda_device_tests,agc_shader_memory_tests,agc_driver_graphics_tests,agc_rect_list_position_invariant_tests,agc_spirv_lds_atomic_lock_testsandagc_bda_atomics_tests:SpirvBdaRead.cppchange, the two new checks fail and name the unrolled loop.tools/check_conventions.pypasses.main(7085a08145):This PR (
3a78eef0e8):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 MarcZX10 on 2026-11-15T21:03:50Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code and author-reported checks support merging.
What I ran
Reviewed head
3a78eef0e890a78c2bd9cd19c8632e56ee01d7f0. No commands or tests were run in this review. The author reports Vulkan test runs and a conventions check indescription.md; those results were not independently run here.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the review folder because it was too large; only lines 10877–10990 around the changed code were read through the repository reader. The other changed files,core/libs/prx/libSceAgcDriver/tests/BdaContracts.cppandcore/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cpp, were read in relevant ranges. No files fromfiles.jsonwere excluded; that path was not available in the review folder. No tests, performance captures, physical-console behavior, or author-reported results were independently verified.To get this to a good state
Nothing is required.