perf(agc): key large image tables and their maps by a hash of their content #17226
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17226"
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 XatiX on 2026-11-08T15:23:19Z.
What
A draw's resource cache key carried an image table's content whole: its
descriptor words, samplers, shapes and per-element flags, about 12 words
per element. A draw binding a 14k-entry table built, hashed and compared
a key of that size on every draw. A table over 8192 descriptor words now
enters the key as a marker and two 64-bit hashes of the same content,
computed in four independent lanes (the xxHash64 round), so equal tables
still key equal and a changed element changes the key.
ShaderRecompiler::ElementFlags gains ForEachSet, which visits the set
flags a word at a time, so the per-element flags enter the hash without
a lookup per element.
A draw's resource cache key carried the ImageTableMap binding's words
whole: 136,000 to 260,000 words per pixel stage for a 14k-entry table,
built, hashed and compared on every draw next to the table itself,
already keyed by a hash. A map over 8192 words now enters the key the
same way, as a marker and two 64-bit hashes of its words.
Tested
Windows 11 Pro 26300, NVIDIA GeForce RTX 5080, driver 617.42, MinGW-w64 GCC, Release.
Focused AGC tests (
ctest -R '^agc.*(image_table|table|reuse|template|revalid|variant|resource_cache|bda|texture_cache|storage|shader_memory|locks|draw_cache|depth_surface|snapshot|pending|per_use)' -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation), same machine and GPU:mainf5fe807353: 100% tests passed, 0 tests failed out of 148, 0VUID-lines, layer loaded (0 "was not found" lines) -main-focused.logVUID-lines, layer loaded (0 "was not found" lines) -H-focused.logAge of Mythology: Retold (PPSA18653), title screen, idle,
APS5_TRACE_SECONDS=60:120(about 16 presents) after a warm-up run.mainhere isupstream/mainwith #15327 and41f70c5e1cmerged, an earlier head of #16437 that fails clock id 20 withEINVAL; the title needs both to run past the title screen (a GPU hang, then an abort on clock 20). Runs alternated with runs of that build; each run of the change is compared with the mean of the runs just before and after it.main+ #15327 +41f70c5e1c, frame p50 (ms)Mean difference: -5.6 %.
Summary lines:
Digest,
main:Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 7834.5, Driver.Packet.draw 7719.6, Driver.Draw 7719.1, Driver.Draw.draw_and_resource_release 6614.2, Graphics.Draw 6589.3, Graphics.Draw.draw_and_resource_release 6284.6, Resources.Complete 6090.4, Driver.Draw.shader_compile_and_link 1080.6, batch 547.0, Graphics.Draw.validate 286.7
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
seconds 60:120 from present 531: 17 presents, frame p50 7394.9 / p90 7779.6 / p99 7975.7 / max 7975.7 ms, GPU busy 586.5 ms per present
NVIDIA GeForce RTX 5080, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit 4d213d56f93e, dropped: no
Slowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 7427.0, Driver.Packet.draw 7334.1, Driver.Draw 7333.6, Driver.Draw.draw_and_resource_release 6246.8, Graphics.Draw 6223.4, Graphics.Draw.draw_and_resource_release 6188.1, Resources.Complete 6135.5, Driver.Draw.shader_compile_and_link 1065.1, batch 589.1, Shader.DrawStage 172.4
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
The two traces and both test logs are attached.
main-focused.log
H-focused.log
main-aps5-trace-57be81439239-38472.json.gz
change-aps5-trace-4d213d56f93e-26756.json.gz
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)