perf(shader): emit runtime V# byte writes through the looping helper #6706
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6706"
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 milescoviello on 2026-10-16T05:29:46Z.
What
#6372 (
70a884408) made BDA stores through a bound V# (EmitBdaStore) send their byte path through one looping helper,write_bda_bytes. Stores through a V# the shader computes (EmitBdaWrite, fromSpirvRuntimeBuffer.cpp) still emitted that path inline. Each 32-bit store had fourget_bda_write_pointerlookups, mapped checks, byte stores andnote_bda_writecalls for its unaligned case, plus one lookup for the aligned case. Each 8- or 16-bit store had one lookup and one note per byte.EmitBdaWritenow does the same overflow check as before and then callswrite_bda_bytes. The helper does the same lookup, store and note per byte, in order, so faults and written pages are recorded as before.Crimson Desert (PPSA25286) runs large compute programs whose stores go through computed V#s. On NVIDIA, how long a pipeline takes to create tracks how many calls its module makes. These modules make 500 to 2,000 calls, mostly fault, lookup and note calls, and on
mainthey take up to two minutes each to create. The title reaches them only with #6612 and #6613.In Crimson Desert, 900 s limit with scripted pad input,
APS5_PROFILE_DRAW=1(which logs every compute pipeline over 100,000 SPIR-V words with its creation time), #6612, #6613 and #6178 (for memory) on both sides:AGC graphics: fragment shader must export float4 colors to its attachmentsThe #6612 heads differ only in their tessellation hull code, which these compute programs don't use. That new stop is a separate change.
Tested
Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.
agc_driver_bda_device: its runtime write cases (byte, split short, split unaligned dword, read-only byte and suffix, unmapped middle byte, split aligned dword, each plain and coherent) already checked stored bytes, faults and written pages, and they pass with this change. A throwaway build that fails on this byte path shows that only this test reaches it in the 468 area tests. A new check inRunBdaContractTestsrequires a runtime V# write's byte path to go throughwrite_bda_bytes. A 32-bit write may then make twoget_bda_write_pointercalls (the helper's and the aligned store's), and an 8- or 16-bit write one. Withmain'sSpirvBdaRead.cppit fails witha runtime V# write of 8 bits has 2 write lookups and 0 byte-loop calls. It passes 3 of 3 with this change.^agc_driver_|^agc_vertex_barrier|recompiler|shader_cache|request_serializer|spirv, 468 tests): 467 pass.agc_driver_store_over_untrackedfails the same way onmain5d9dcc42dhere; #6385 addresses it.APS5_DUMP_SHADERSrequest files. Each was recompiled withagc_shader_replaybuilt frommainand from this PR. The SPIR-V was put into that program's own pipeline capture (APS5_DUMP_COMPUTE_PIPELINES, same layout and specialization), and creation was timed withagc_compute_pipeline_replay, with the NVIDIA shader disk cache off (__GL_SHADER_DISK_CACHE=0). The replay tool compiles for its own target, so the word counts differ a little from the title's. One run each:That's 680 s for the eight on
mainand 177 s with this change. Program H, the slowest per word, has 776 write lookups and 776 write notes onmain. The driver needs 8.6 GiB of memory to create its pipeline onmain, and 1.2 GiB with this change (peak RSS of the replay process). Program A's own captured module, as the title compiled it, took 34.5 s in the same replay.Validated on Windows 11 with an AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001) by @LeandroLP23 (comment), in one build of
main6efb7261bwith this head and 13 other pull requests:agc_driver_bda_deviceandagc_driver_store_over_untrackedpass 3 runs of 3. 713 of 716agc_*tests pass; the 3 that fail fail the same way onmainthere.Not checked on Intel or on a console.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T14:29:25Z.
Rebased onto
maina62c724c38(head2f3e71bae6). The only conflict was intests/BdaContracts.cpp: #5859 added includes and its ordered-ranges checks at the end ofRunBdaContractTests, next to this PR's helper-call checks. Both are kept.EmitBdaWriteis the same as before the rebase; #5859 didn't change it.Tests on the RTX 4070 Ti (NVIDIA 595.99.02): 7 of the 8 tests matching
bda|^shader_ir|request_serializer|agc_shader_replaypass.agc_driver_bda_devicestops in #5859's newRunBdaAnchorTestswithvkWaitForFences graphics: Vulkan result 2(a 5 s fence timeout). It does the same onmaina62c724c38and on #5859's merge644e384808, and passes on385ed71f2cjust before it, so it isn't from this PR. With that one call skipped locally, the rest ofagc_driver_bda_device, includingRunBdaStoreExecutionTestsand the contract checks for this PR's byte path, passes 3 of 3 on this head. I'll report the timeout separately.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T16:33:05Z.
AMD on Windows: the tests this PR names pass on an RDNA 3.5 GPU.
Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release.
main6efb7261bwith this PR (2f3e71bae) merged, together with #7296, #7446, #7377, #7445, #6708, #6748, #6785, #6613, #7449, #7391, #7489, #7484, #7514. They were built once, so the result is for the combination; each merge was clean.agc_driver_bda_device,agc_driver_store_over_untracked: pass, 3 runs of 3.agc_*test on the combined build: 713 of 716 pass. The 3 that fail,agc_driver_host_import_lifetime,agc_driver_quad_pixel_maskandagc_driver_layered_volume_vertex_no_gpl, fail the same way on unchangedmainhere, so none comes from these PRs.agc_compute_pipeline_replayandagc_shader_replayare not ctest names here; I did not replay captures.AI-assisted
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T18:45:50Z.
Thanks @LeandroLP23 for the AMD run on Windows. I added it to the description.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T00:47:27Z.
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.
core/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T09:48:42Z.
Checked that
EmitBdaWritenow matchesEmitBdaStore: the helper does the same per-byte lookup, store and note in order, the overflow check stays before the call, andwrite_bda_bytes/_coherentare defined together withget_bda_write_pointer. The newCallSitescheck fails onmain(no helper calls) and passes with the change; the runtime write cases ofagc_driver_bda_devicestill cover bytes, faults and written pages. Merged.