Repository navigation
perf(agc): draw finisher pipeline (APS5_DRAW_PIPELINE) - #6946
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
Tested on Minecraft Dungeons II (PPSA16064, UE). Setup
Draw pipeline. It doesn't speed up this title.
Rendering. Nothing renders wrong in either mode. We took screenshots every 3 s over 90 s of gameplay in each run: no missing textures, no flicker, and no red artefacts. Frames match the base build. First boot with an empty shader cache. With Unrelated failure in the base mode. The base mode ( Heap verify lines are in #6947. Summary lines (second run of each) |
CnRJay
left a comment
There was a problem hiding this comment.
Measurements are there and the numbers are good (469 to 807 presents in 10 s, p50 21.1 to 12.2 ms, p99 also lower). Three things before this can be judged.
- One run each, standing still in a menu, on a 4090 at 1080p. The A/A spread of this setup is not shown (compare #5353, where two identical captures differed by 6.4%), and a menu is the best case for draw-cache reuse. Please add a second pair in gameplay, and repeat the pair once to show the spread.
- This is one switch over seven unrelated changes (finisher thread, commit trims, epoch proofs, ordered metadata passes, shape refresh, straight-line walk, capture memory). The description says the finisher alone made the frame rate worse (105 fps on, 111 off) and that "only the combination" helps. That is a reason to measure each part against its predecessor and land them in order, not to bundle them: nobody can tell which part carries the gain or the risk. At minimum, split off the parts the finisher does not need (metadata passes, straight-line walk, capture memory).
- Known limit:
agc_driver_draw_cache_relocationfails with the switch on. A path that breaks an existing test should not become a default. Make the walk fall back to the relocatable capture when the cache has relocation enabled, or document which titles need relocation.
It is also stacked on #5656 and #6632, so the diff shown here includes their commits. Rebase after they land so only this PR's two commits remain.
|
@CnRJay thanks for the review. "Menu". That was a poor word on my side. The scene is not the main menu: it is the item pickup UI in a level, which is the heaviest scene I found in Hades II. The hub holds a steady 120 fps and normal gameplay runs at 100 to 120 fps, so the pickup screen is where the worker is the limit and where the difference shows. A gameplay trace with both switches (combat in a room, 15 s window, same machine, display at 120 Hz): So in combat it sits at the vblank; there is no headroom left to show a difference there on this machine. I have not yet repeated the pair to show the spread. Splitting. The parts depend on each other in Hades II:
So each part could be measured against its predecessor, but the first ones would land as regressions. That is why it is one switch. I will rebase so only the two commits remain once #5656 and #6632 land. LLM assistance used. |
|
@TideOPL's run is the first outside Hades II: on Minecraft Dungeons II at 4K the draw pipeline doesn't help (queue 0 waits about 53 ms per frame on the compute queue) and nothing renders wrong. @CnRJay's asks stand: a gameplay pair with its spread, each part measured against its predecessor so they can land in order, and |
There was a problem hiding this comment.
Linux, RTX 5080 (driver 615.78.08), Ryzen 7 7800X3D. Base is main 2fab88d with 5656 and 6632 as in the body, then 6946 at f8192a6, all with APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1, warm cache, two 10 s traces each.
| frames in 10 s | base | APS5_DRAW_PIPELINE=1 |
|---|---|---|
| Astro's Playroom (PPSA01325), first level gameplay | 109, 119 | 138, 135 |
| Hades II (PPSA36082), first area of a new game | 640, 646 | 1122, 1054 |
Captures match the base in both, and a burst of consecutive Playroom frames shows no glitch. On a Radeon 680M (RADV) Playroom is GPU-bound and the same: 42 base, 43 and 39 with the switch.
One test fails with the switch. In the full ctest (1364 tests) agc_driver_draw_cache_relocation fails 5 of 5 runs with APS5_DRAW_PIPELINE=1 on 6946 and passes 5 of 5 on the base:
with graphics pipeline libraries: the draws that teach the moved pointer and its contents made 0 hits and 1 inserts, expected 0 and 2
Without the switch the suite fails only where the base fails too: agc_driver_store_over_untracked fails 5 of 5 on the base itself, not from this PR. It passes 5 of 5 on current main 0906c64 with 5656 or 6632 merged alone, so it only shows on the older base.
|
007 First Light (PPSA11386 v01.018.000), 4K output, as asked on Discord. The heap runs are on #6947. Setup:
AI-assisted: yes (Claude Code) |
…its render pass recordDraw passed every address-based draw to the pass hazard tracker as both an unknown reader and an unknown writer of guest memory. An unknown writer conflicts with any earlier access in the pass, so no address-based draw ever continued the previous draw's pass: each one ended the pass and began a new one, which loads and stores the attachments again. At Resident Evil Village's menu about half of all draws are address-based, and about 590 render passes begin for about 850 draws per frame. A build whose programs only read through the BDA table now reports unknown reads only. The tracker already orders unknown reads behind any recorded range write in the pass and keeps later range writes behind them, so such a draw continues a pass whose earlier draws wrote no guest ranges. Builds with stores through the table, copied writes, or an address lease without a table keep both flags. APS5_NO_ADDRESS_READ_PASSES=1 restores the old behaviour. Render targets reach guest memory only by explicit write-backs, so a read through the table sees the same bytes whether or not the pass breaks. Raghav314's boykopovar#6947 makes the same change inside its GPU descriptor heap, with the read-only fact from boykopovar#6946's recompiler field; this one keeps it in the driver, without a shader cache format change. The idea also comes from fable-void's 5d57298 (wip/new-gpu-path), which orders address-based builds by their known access ranges; this takes the read-only half without his run-time pre-pass bounds.
|
A repeat on the current head (d63a804, with the Windows fix), next to #6949 which prepares draws on a thread pool. Hades II (PPSA36082), the level's item pickup UI, Linux, RTX 4090, 7800X3D, NVIDIA 615.78.08. All three builds are
The earlier run on the pre-rebase head gave 807 against a base of 469, so the gain repeats (+72% then, +65% now). In this scene #6949's pool keeps no draw in flight ( LLM assistance used. |
|
Besiege (PPSA20313), Windows, RTX 4070 SUPER, Ancient Grounds sandbox (about 1000 draws per frame), head f8192a6 with APS5_DRAW_PIPELINE=1 on top of current main: 17.0 -> 20.0 FPS (three alternating runs each: 17.3/17.2/16.6 before, 20.3/19.8/20.0 after). A 10 minute run in the level on top of other open perf PRs had no errors and the frame looks the same. |
|
Rebase handoff — rebased onto current Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
d63a804 to
d0779ad
Compare
d0779ad to
5e45089
Compare
|
We checked 5e45089: only 805774e changed, and it resolves correctly against the committer Stop from #6641. One low-priority follow-up, affecting |
|
A macOS build fix for this PR, as a ready commit in case it's useful. What fails. Apple clang's libc++ has no
The commit: 8a97b049c4 on
Runs on our fork. These use the full Build workflow on Windows and macOS. The fork has no Linux job; libstdc++ takes the
The commit also cherry-picks cleanly onto #6947's head cae12b7, so #6947 gets it through the stack. Take it as is, or fix it your own way. If either head moves again, we can redo it there. |
5e45089 to
b31be5a
Compare
|
@oneandonlydean thanks, you're right. The finisher is only drained at the end of a queue 0 submission, so a ProcessShutdown in the middle skipped it. LLM assistance used. |
…+ builds ResultKeyMemo declared std::atomic<std::shared_ptr<...>>. libc++ has no atomic<shared_ptr> specialization, so with Apple clang the recompiler headers stop at std::atomic's trivially-copyable static assertion (request_serializer_tests in the macOS relinker build). The memo now uses AtomicSharedPtr from libc, which is that specialization where the library provides it and a locked shared_ptr with the same load and store otherwise. The header joins the shader disk cache key's sources, and request_serializer_tests gets core/libs on its include path.
… finisher A WRITE_DATA or RELEASE_MEM label the worker queues for the committer drained the draw finisher first, so that it could not reach the committer before the draws the finisher still held. In Hades II nearly every drain of the finisher was one (81,762 of 82,467 per 10 s were WRITE_DATA). While the finisher holds draws, the label's enqueue now runs as a finisher job, so it reaches the committer after them, and its write range and value are a pending write of the finisher until then. A WAIT_REG_MEM that a pending label satisfies, in the finisher or behind it, stays beside the finisher as it did beside the committer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ice is destroyed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cc388f2 to
a9e2141
Compare
|
Independent Windows component validation after this merge, on literal main Full native libraries, relinker and selected real fixtures build with WinLibs GCC15.2 r7/UCRT Release, SPIRV-Tools enabled. 24/24 selected executions pass:18 physical-GPU processes and6 CPU processes.
The same24 checks also pass in our maintained Sonic composition GPUs tested:NVIDIA GeForce RTX508010de:2c02,610.62/32.0.16.1062;AMD Radeon(TM) Graphics1002:13c0,32.0.21036.18;Windows11 Enterprise26200. Driver caches uncontrolled. This is selected component coverage,not a title run,full suite or the requested matched performance/epoch-proof comparison. Existing Sonic title observations retain their pre-merge source pins. AI-assisted:yes (Codex);author responsible. |
Since the draw finisher (#6946), Driver::draw copies decode->programs into the draw tail for every draw: one outer vector, one userData vector per program and two shared_ptr reference bumps per program. Before it, the copy was made only when the draw writes user words (mesh index buffer words, indirect record words or relocated user patches), and every other draw read decode->programs in place. Keep the copy in DrawTail::writablePrograms and make DrawTail::programs a pointer to it or to decode->programs, as before. Every write goes through writablePrograms, and the draws that write are exactly the mesh, indirect and patched ones, so a const view of decode->programs can't be written. The queued commit closures now move writablePrograms. When it is empty the captured decode keeps decode->programs alive, and decode is only replaced (by the relocated copy) on draws with user patches, which take the copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
An opt-in draw path,
APS5_DRAW_PIPELINE=1, that takes per-draw work off the queue worker. Meant withAPS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1(both onmain). Based onmaina6dcea9; #9508 (descriptor heap) is stacked on it.main's second-sight admission is replaced in place when the same read user words are seen twice.WRITE_DATAandRELEASE_MEMlabels queued while the finisher holds draws go through its queue instead of draining it, and aWAIT_REG_MEMon them stays beside it.Always on, with the same results: the draw resource key is built in place with a per-result memo, a vertex stage's attribute and buffer table words are read in one read, and the pending storage-image check skips ranges the pending set cannot overlap.
APS5_VERIFY_DRAW_PIPELINE=1runs the full checks next to the reused proofs and counts differences ([epoch-proofs]).APS5_PROFILE_DRAW=1finishes every draw on the worker, so it cannot measure this switch.PPSA36082 (Hades II)
The hub, player standing still,
APS5_TRACE_SECONDS=120:10,APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1. Caches warm (each setting run once into the hub, then the title restarted), no otherAPS5_TRACE_*orAPS5_PROFILE_*switch, log not redirected. Currentmainstops Hades II while the hub loads, so both builds have #6300 merged locally. The switch-on build is the head of #9508, which contains this PR, with the heap switch off.maina6dcea9 + #6300APS5_DRAW_PIPELINE=1+25% frame rate.
Summary lines, traces and digests
main+ #6300:{"commit":"de49f41349a9","dirty":false,"env":{"APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:10"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.2.10-1-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31743,"title_id":"PPSA36082","title":"Hades II","content_version":"01.006.000","resolution":"1920x1080","window":{"spec":"seconds 120:10","first_present":8859,"ms":10001.243},"presents":706,"frame_ms":{"p50":13.955,"p90":15.665,"p99":18.680,"max":25.064},"gpu_busy_ms_per_present":2.224,"worker_busy_pct":{"queue worker 0x0":97.766},"top_phases_ms_per_frame":{"Driver.Packet":13.844,"Driver.Packet.draw":11.959,"Driver.Draw":11.850,"Driver.Draw.shader_compile_and_link":8.284,"Graphics.Draw":8.166,"Graphics.Draw.draw_and_resource_release":6.859,"Shader.DrawStage":5.206,"Shader.DrawStage.capture_resources":3.196},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":6.816,"events_lost":132221,"totals_full":false}},"trace":"aps5-trace-de49f41349a9-624652.json.gz"}APS5_DRAW_PIPELINE=1:{"commit":"568369d27a2e","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:10"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.2.10-1-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31743,"title_id":"PPSA36082","title":"Hades II","content_version":"01.006.000","resolution":"1920x1080","window":{"spec":"seconds 120:10","first_present":10851,"ms":10010.638},"presents":886,"frame_ms":{"p50":11.172,"p90":12.083,"p99":13.652,"max":41.180},"gpu_busy_ms_per_present":2.340,"worker_busy_pct":{"queue worker 0x0":96.015},"top_phases_ms_per_frame":{"Driver.Packet":10.838,"Driver.Packet.draw":8.115,"Graphics.Draw":8.087,"Driver.Draw":8.030,"Driver.DrawFinish":7.151,"Graphics.Draw.draw_and_resource_release":6.678,"Driver.Draw.prepare":4.793,"Driver.DrawFinish.shader_compile_and_link":4.199},"trace_dropped":false,"trace":"aps5-trace-568369d27a2e-626697.json.gz"}Traces:
aps5-trace-de49f41349a9-624652.json.gz
aps5-trace-568369d27a2e-626697.json.gz
seconds 120:10 from present 8859: 706 presents, frame p50 14.0 / p90 15.7 / p99 18.7 / max 25.1 ms, GPU busy 2.2 ms per present
NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.2.10-1-cachyos, 1920x1080, commit de49f41349a9, dropped: yes
{"commit":"de49f41349a9","dirty":false,"env":{"APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:10"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.2.10-1-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31743,"title_id":"PPSA36082","title":"Hades II","content_version":"01.006.000","resolution":"1920x1080","window":{"spec":"seconds 120:10","first_present":8859,"ms":10001.243},"presents":706,"frame_ms":{"p50":13.955,"p90":15.665,"p99":18.68,"max":25.064},"gpu_busy_ms_per_present":2.224,"worker_busy_pct":{"queue worker 0x0":97.766},"top_phases_ms_per_frame":{"Driver.Packet":13.844,"Driver.Packet.draw":11.959,"Driver.Draw":11.85,"Driver.Draw.shader_compile_and_link":8.284,"Graphics.Draw":8.166,"Graphics.Draw.draw_and_resource_release":6.859,"Shader.DrawStage":5.206,"Shader.DrawStage.capture_resources":3.196},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":6.816,"events_lost":132221,"totals_full":false}},"trace":"aps5-trace-de49f41349a9-624652.json.gz"}Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 3.6, Driver.Packet.draw 3.5, Driver.Draw 3.4, Graphics.Draw 2.5, batch 2.2, Graphics.Draw.draw_and_resource_release 1.6, Driver.Draw.shader_compile_and_link 1.4, Recorder.Sync 0.3, VideoOut.Flip 0.3, VideoOut.Flip.present 0.3
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
seconds 120:10 from present 10851: 886 presents, frame p50 11.2 / p90 12.1 / p99 13.7 / max 41.2 ms, GPU busy 2.3 ms per present
NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.2.10-1-cachyos, 1920x1080, commit 568369d27a2e, dropped: no
{"commit":"568369d27a2e","dirty":false,"env":{"APS5_DRAW_PIPELINE":"1","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:10"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.2.10-1-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31743,"title_id":"PPSA36082","title":"Hades II","content_version":"01.006.000","resolution":"1920x1080","window":{"spec":"seconds 120:10","first_present":10851,"ms":10010.638},"presents":886,"frame_ms":{"p50":11.172,"p90":12.083,"p99":13.652,"max":41.18},"gpu_busy_ms_per_present":2.34,"worker_busy_pct":{"queue worker 0x0":96.015},"top_phases_ms_per_frame":{"Driver.Packet":10.838,"Driver.Packet.draw":8.115,"Graphics.Draw":8.087,"Driver.Draw":8.03,"Driver.DrawFinish":7.151,"Graphics.Draw.draw_and_resource_release":6.678,"Driver.Draw.prepare":4.793,"Driver.DrawFinish.shader_compile_and_link":4.199},"trace_dropped":false,"trace":"aps5-trace-568369d27a2e-626697.json.gz"}Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Graphics.Draw 2.6, Driver.Packet 2.4, batch 2.3, Driver.Packet.draw 1.9, Driver.Draw 1.8, Graphics.Draw.draw_and_resource_release 1.8, Driver.DrawFinish 1.7, Driver.DrawFinish.draw_enqueued 1.0, Driver.Draw.prepare 0.9, Driver.Draw.draw_handed_off 0.5
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
Tested
Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090, NVIDIA 615.78.08, on
maina6dcea9.agc_driver_sample_order,agc_driver_sample_order_grid_referenceandagc_driver_sample_order_recipe_depth_locations, which fail the same way onmain. Conventions pass.*_draw_pipeline).agc_driver_pipelined_metadata_pass,agc_driver_program_writes_memory,agc_driver_draw_data_hit_user_words_refresh,agc_driver_draw_finisher_trace,agc_driver_finisher_label_order.agc_driver_address_passesexits cleanly again, as onmain.Known limits
Why this is one PR
In Hades II the parts on their own made the frame rate worse: the finisher alone made the committer the limit, which the commit trims and epoch proofs fix, and the faster worker dropped data-only stage reuse to 17% until the shape refresh brought it back to 83%.
Testing other titles
Please post:
APS5_TRACE_SECONDS=70:10, captured as the Performance report form describes) with and withoutAPS5_DRAW_PIPELINE=1, both withAPS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1and nothing else changed;APS5_VERIFY_DRAW_PIPELINE=1, the last[epoch-proofs]line (a nonzero "differed" or "failed" count is a bug).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)