perf: heavy 3D titles are bound by per-draw work in the draw path; a direct path that reads descriptors on the GPU #17533
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 XatiX on 2026-11-08T20:41:00Z.
Measured 2026-11-03 to 2026-11-08 on an RTX 5080 (driver 617.42), Ryzen 7 9800X3D, Windows 11, Release builds. Estimates are marked as such.
Summary
Heavy 3D titles in AnyPS5 are limited by the CPU work done for each draw, on one queue worker thread. The work per draw grows with the guest data the draw's shaders read (descriptors, image tables), and correctness is kept by proving on the CPU, draw by draw, that this data has not changed. In the heaviest title measured, the GPU timeline is also nearly full, but mostly with overhead the same per-draw model creates (render pass breaks with full barriers, storage image copies), not with shader work. A week of tuning on Age of Mythology: Retold took the title screen from 7965 to about 324 ms per frame, but the remaining cost is spread over many steps that are all part of the design. Removing every CPU cost that has a known fix would leave an estimated 10 to 15 fps of CPU headroom in that title, and its GPU timeline would cap it near 4 fps until the pass and copy overhead goes too. 30 or 60 fps in heavy titles needs a different per-draw model, not further tuning.
What the titles show
main)main)In FF Resonance and LEGO the GPU has time to spare and the queue worker does not. In AoM both are near their limit, the GPU mostly with overhead (limit 6 below).
Where a draw's time goes
AoM, title screen, worker samples (about 390 µs per draw in all):
ResolveImageTables): about 27,000 image records per resolution, redone because the 14,000-entry table moves every frameShaderResources::Revalidate, table covers, per-texture proofs)ShaderMemory::Capture,TableSnapshotter)AppendContentKey)tagVariantRuns(variant relocation)writeDrawSets): about 36,500vkUpdateDescriptorSetsper 10 s, 267 million descriptors, each set rewritten wholerecordDraw) and the restNo step is above 12 %. Each one exists because of the same model.
The structural limits
Per-draw work scales with guest data, not with what changed. A draw captures the descriptors its shaders read, specializes the shader's resources to them (
Materialize), and keys its caches on them. A shader that indexes a 14,000-entry image table makes every draw read, hash, resolve or prove 14,000 entries. The caches avoid rebuilding, but a cache hit still has to prove the inputs current, and the proof touches the same data.Correctness is proven per draw on the CPU. Reuse is allowed only after write-watch stamps, collect epochs and proof serials show nothing changed. These proofs are invalidated broadly: until this week every GPU mutex hold by the queue worker (one per draw) dropped them (
GpuMutexType::acquired), so nearly every check was a full one. Narrowing that (local change, not in main) gained 5 %; the checks remain per draw.One thread does the work. The draw pipeline can hand recording to a committer and stage materialization to a finisher, but indirect draws mostly skip it (
APS5_NO_PIPELINED_INDIRECT, finisher hand-off requires!drawParameters.indirect), and AoM's draws are 98 %DRAW_INDEX_INDIRECT. Even fully pipelined, three threads divide the cost; they do not remove it.Descriptors are written on the CPU per draw. A draw that reuses a build while its fault record is busy, or whose snapshot buffers moved, gets a complete new descriptor set, including every image-table descriptor. A pool of pre-written sets cut a quarter of these writes and changed nothing measurable; the remaining writes come from per-draw buffer snapshots.
Guest memory is not cheap to read from the GPU on the most common platform. NVIDIA's Windows driver reads host imports far slower than its own buffers (164 against 45 ms of draws per frame, Astro Bot, ARCHITECTURE.md), so draw inputs are copied per draw instead of read in place.
The GPU timeline fills with per-draw overhead. AoM, per frame (
APS5_PROFILE_GPU;gpu_busy_ms_per_presentis the first-to-last-command span of each batch): 200 to 280 ms of batch time, of which about 40 ms is shader programs. About 300 render passes per frame each begin after a fullALL_COMMANDSbarrier; the draw ranges take about 108 ms, about 68 ms more than their shaders. Storage images are written back to guest memory and uploaded again, about 300 MiB of copies per frame (about 21 ms). Half of the pass breaks came from indirect draws that never needed one (fixed locally: 19,600 → 10,300 passes per 10 s), the rest from commands and hazards between draws.Batching and budgets add stalls. Example fixed this week: a depth plane copy counted its reused 32 MiB staging buffer against the batch's 512 MiB budget at every refresh, which forced 417 early submits and 336 GPU fence waits per 10 s (about 9 % of AoM's frame). Such issues are fixable one by one, but they come from the same per-draw bookkeeping.
Why tuning cannot reach the goal
What would reach it
The CPU must stop touching guest data per draw. Work has to follow memory changes (per page, per submission), and the GPU has to read descriptors and tables where the hardware does:
This is the model emulators that run comparable hardware at full speed use. I am prototyping it as a separate path beside the existing one, with a per-draw fallback to the existing path so every title keeps running, and will measure it on Divinity: Original Sin 2, FF Resonance, LEGO Builder's Journey and AoM. It is not meant as a pull request in its current form; the aim is to find out whether the model holds up in this codebase and to bring numbers back here.
Related
Feedback wanted
Summary line (AoM: Retold, title screen, the stack with 25 local commits)
The stack is listed in the bring-up discussion #15328. Worker samples and GPU profiles can be attached on request.
AI-assisted analysis and report: yes (Claude Code).