Draw cache misses on almost every draw when a guest driver puts per-draw pointers in the user data (RADV titles) #4054
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 TheAggie on 2026-10-11T22:18:04Z.
Summary
Titles that render through RADV on the PS5 GPU (RetroArch PPSA99169 with the Flycast core here) get almost no draw-cache hits in moving scenes. The draw worker is then CPU-bound at about 48 µs per draw, and a scene with around 15,000 draws per second runs at a third of full speed.
The cause is narrow: the register key includes two user-data words that RADV fills with pointers it allocates again for each draw. The data behind those pointers repeats; only the addresses change.
Related open work
What follows is meant as data for that work and a possible extension on top of #494, not a competing design. I would rather build on #494 than beside it.
Measurements
Main at
a11c8f7f7, Windows 11, NVIDIA GPU (device 10de:2c05),APS5_PROFILE_DRAW=1. Scene: Crazy Taxi attract demo in Flycast, 1280x960 internal resolution,RADV_DEBUG=nonggcso the draws take the plain vertex path.Draw cache, one 10 s window:
Driver phases for the same window:
So the worker spends 7.9 s of every 10 s on draws, and about 23 µs of each draw is the miss path (decode, two captures, materialize, insert).
For comparison, a static menu in the same title hits on every lookup (23,960 of 23,960), because RADV's allocations then land on the same addresses every frame.
Which key words differ
I counted distinct keys over windows of 100,000 draws, once as built today and once leaving out two shader-bank user words:
Distinct values per user word in one window:
Words 0x08c and 0x00f are guest addresses. RADV allocates the block behind 0x08c from its command-buffer upload buffer for each draw, and Flycast allocates the descriptor set behind 0x00f from a pool it resets every frame. The same contents therefore show up at a different address on most draws.
An approach that works here
I have this running on a local branch based on
a11c8f7f7(so without #494) and would like your view on the shape, and on how to layer it over #494, before opening any PR.GetUserData. A word that is also evaluated as a value is marked. A word that was only ever a read base is relocatable for that capture: moving it and finding the same words at the shifted addresses reproduces the same evaluation.Same scene, same machine:
Three further steps got from 72% to 96% hits:
livemechanism, and a hit that differs only there patches the new address into a copy of the result, provided old and new are non-zero and agree in their low two bits (the only properties of that word the binding plan and specialization read). In this title the fragment uniform buffer's address changes every frame and was the only unique word in 99.7% of pixel-stage captures.AnyPendingOverlapsconsults the pending image range index, and draw snapshots are reused when nothing was written since they were last checked.Checks so far: with
APS5_VERIFY_DRAW_ENTRIES=1(extended to compare address-to-word contents, forwarded user words and binding descriptors) every hit is captured again; no difference in several hundred thousand hits on the vertex path, the mesh path, a static test suite and the frontend menu. 377 of 379 AGC and shader tests pass; the two failures are a provoking-vertex rejection I removed in an unrelated local commit andagc_driver_emulated_color_compare, which also fails on main on this GPU. Separately,agc_driver_prepared_shaders_debugexits with 0xc0000374 at thread exit in 2 of 20 runs on main here, which looks like #3171.Open points: there is no unit test for it yet, and the shader-set identity needed the program address registers mixed in because raw programs all resolve to one registry entry.
A smaller second finding from stack sampling the worker in the same scene: 27 of 119 busy samples were inside
RtlAllocateHeaporRtlFreeHeap, spread over the whole draw path with no single dominant caller.Reproducing
Any RADV-based homebrew with a moving scene should show it. With
APS5_PROFILE_DRAW=1, compare "no entry" against lookups in the[draw-cache]line. I can share the small counting patch used for the table above.I can split this into PRs (the evaluator reporting first, then the driver side) once the shape and the relation to #494 are settled.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-16T23:53:43Z.
#4943 (
f8d4ce340) is on main: a draw that differs from a cached one only in pointer words that are read through now finds the cached entry through an alias key. Closing this one. If[draw-cache]still shows "no entry" on most draws on RADV with current main, reopen with theAPS5_PROFILE_DRAW=1line.