perf(agc): trap CPU reads of label readbacks on macOS instead of storing them #13499

Merged
Gonic0 merged 7 commits from upstream-pr/13499 into main 2026-11-01 10:09:35 +00:00
Gonic0 commented 2026-10-30 17:03:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Gonic0 on 2026-10-30T17:03:47Z.


What

Builds on #13442. Until it merges, this branch carries its commits; only 2cf5b41ec8 and 0fdd66d900 are new here.

StorageTexture::StoreReadbackBeforeLabel writes back every pending linear or small storage image before each label, whether or not the CPU reads it. On macOS this PR traps CPU reads of such an image with #13442's write-watch read traps instead of storing it, so the store happens only when something reads or writes its memory.

  • Label: under the pending registry's mutex, an image that shares no page with another pending or storing image, and is not direct memory mapped at a second address, gets GuestWriteWatchTrapReads over its exact range instead of its store. The alias check is a new libkernel export, DirectMemoryAliased_nid_postfix, which tells whether any of a range's physical memory is mapped by another direct mapping. If the trap cannot be set (unwatched memory, a host write in progress), the image is stored as before. #13442 makes a trap of an already trapped range a no-op, so the same range can be trapped at every label without the driver tracking it.
  • Resolver: the first access to a trapped page runs GuestMemory::FlushGpuWrites over the trap's range on the write watch's resolver thread. That is the host-read hook every other reader of guest memory uses: it stores the pending results and waits until they are in memory. While a queued draw still holds reads of the range (DrawPipeline::HeldReads, which makes the store wait), it retries.
  • Release: every store releases the trap in writeBackLayers, so FlushPending, cache eviction (Flush), WriteBack and refreshes all do. A store that copies into the import on the GPU releases it once the copy is recorded, so a read that faults before then waits for the store. A store through the CPU releases it before its first access to guest memory, together with the traps of other images on the same pages; those images stay pending and are trapped again at the next label. A trapped image is stored whole.
  • Opt-out: APS5_NO_LABEL_READ_TRAP=1 keeps the store at the label. Linux and Windows are unchanged.

Gaps, in the new entry of docs/dev/debt/libSceAgcDriver.md:

  • a read after a store released the trap and before its GPU copy lands sees the old bytes;
  • a thread that holds GpuMutex and touches a trapped image waits for the resolver forever;
  • a system call that reads a trapped image without the host-read hook fails with EFAULT;
  • memory mapped twice other than direct memory is not detected.

The page rule keeps the storing thread from faulting on a page another image's trap covers. If it did, the resolver would wait for that store while the store waits for the resolver.

Tested

Apple M5 Pro, macOS 27.2, MoltenVK from Vulkan SDK 1.4.363, x86-64 Release under Rosetta 2. main alone does not build on macOS, so the tests and the game ran in a tree with the open macOS port PRs, where these files are identical.

agc_small_tiled_shadow_label (agc_driver_recorder_tests --small-tiled-shadow-label-only) gets a trap check on macOS. After the image is written again on the GPU:

  • two labels in a row leave its page without access (the second trap of the same range is a no-op), and a read from another thread sees the new results;
  • after the next write, a label traps it again, and FlushPending stores it and gives the page back;
  • after the next one, a thread calls FlushPending while the test holds GpuMutex, which takes the image out of the pending registry and waits. The page is still without access; a read started then sees the stored results once the test releases the mutex.

Two 8x8 linear images on one page (both architectures' page size):

  • a label traps the first while it is the only one pending;
  • with both pending, a label stores both and gives the page back;
  • with the first trapped again, a store of the second through the CPU (FlushPending with the reason idle, which takes the CPU path) completes, stores the second and gives the page back. The next label traps the first again, and a read sees its results.

The test thread releases GpuMutex around the read, since the resolver needs it. The test passes with and without APS5_NO_LABEL_READ_TRAP=1.

Negative controls, each of which fails it:

  • no release in writeBackLayers: "storing a trapped image did not release its trap";
  • the release where FlushPending takes the image out of the registry, as before: "a trapped image taken for a store gave back its pages before the store";
  • the CPU path not releasing the traps of other images on its pages: "a CPU store next to a trapped image did not store through its page";
  • the label storing instead of trapping: "a label stored a pending small tiled image instead of trapping its reads";
  • a resolver that calls FlushPending without waiting: "a read of a trapped image did not see its pending results".

The 82 CTest entries of agc_driver_recorder_tests pass, except one skip and agc_recorder_failed_check, which fails the same way with APS5_NO_LABEL_READ_TRAP=1. The write-watch tests pass on x86-64 and arm64 (#13442). The whole-image store of a trapped image and the alias check are not covered by a test: these images have one layer, the recorder test's memory is not direct memory, and guest_memory_tests does not build on macOS (sceKernelMunmap).

PPSA21564 (ASTRO BOT 01.007.000), the logos before the intro. main does not build on macOS without the open port PRs, so the base is that tree with #13220 and #13442 (5b2b0eb50830), and the change is the same tree with this commit's Texture.cpp (1f0553384a68). Captures with APS5_TRACE_FRAMES=150:240 and no other trace or profile switch, alternated base, change, base, change:

capture commit frame p50 / p90 / p99 (ms) 240 presents in
base 1 5b2b0eb50830 29.3 / 32.5 / 35.4 7.11 s
change 1 1f0553384a68 21.7 / 24.7 / 26.1 5.30 s
base 2 5b2b0eb50830 26.0 / 28.1 / 30.3 6.30 s
change 2 1f0553384a68 20.6 / 22.6 / 25.1 5.04 s

Summary lines of the second round. Base:

{"commit":"5b2b0eb50830","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_DUMP_FRAMES":"200","APS5_DUMP_FRAMES_EVERY":"60","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"150:240"},"gpu":"Apple M5 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 150:240","first_present":150,"ms":6300.896},"presents":240,"frame_ms":{"p50":26.029,"p90":28.079,"p99":30.286,"max":55.441},"gpu_busy_ms_per_present":19.524,"worker_busy_pct":{"queue worker 0x0":98.610,"queue worker 0x40":99.662,"queue worker 0x48":97.088,"queue worker 0x3a":0.060},"top_phases_ms_per_frame":{"Driver.Packet":76.611,"Driver.Packet.memory_wait":46.970,"Driver.Packet.dispatch":15.657,"Driver.Dispatch":14.064,"VideoOut.Flip":6.645,"Vulkan.DispatchRecipe":5.770,"Vulkan.DispatchRecipe.command_record":5.765,"Driver.Present":5.472},"trace_dropped":false,"trace":"aps5-trace-5b2b0eb50830-47155.json.gz"}

This PR:

{"commit":"1f0553384a68","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_DUMP_FRAMES":"200","APS5_DUMP_FRAMES_EVERY":"60","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"150:240"},"gpu":"Apple M5 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 150:240","first_present":150,"ms":5043.434},"presents":240,"frame_ms":{"p50":20.649,"p90":22.565,"p99":25.074,"max":42.485},"gpu_busy_ms_per_present":11.920,"worker_busy_pct":{"queue worker 0x0":98.392,"queue worker 0x40":99.649,"queue worker 0x48":86.217,"queue worker 0x3a":0.058},"top_phases_ms_per_frame":{"Driver.Packet":59.510,"Driver.Packet.memory_wait":36.905,"Driver.Packet.dispatch":12.250,"Driver.Dispatch":11.379,"Vulkan.DispatchRecipe":6.837,"Vulkan.DispatchRecipe.command_record":6.833,"VideoOut.Flip":6.486,"Driver.Present":5.521},"trace_dropped":false,"trace":"aps5-trace-1f0553384a68-47301.json.gz"}

Traces: base, this PR.

trace_digest.py, base (second round)

frames 150:240 from present 150: 240 presents, frame p50 26.0 / p90 28.1 / p99 30.3 / max 55.4 ms, GPU busy 19.5 ms per present
Apple M5 Pro, MoltenVK 1.4.2, Darwin 27.2.0, 3840x2160, commit 5b2b0eb50830, dropped: no

{"commit":"5b2b0eb50830","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_DUMP_FRAMES":"200","APS5_DUMP_FRAMES_EVERY":"60","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"150:240"},"gpu":"Apple M5 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 150:240","first_present":150,"ms":6300.896},"presents":240,"frame_ms":{"p50":26.029,"p90":28.079,"p99":30.286,"max":55.441},"gpu_busy_ms_per_present":19.524,"worker_busy_pct":{"queue worker 0x0":98.61,"queue worker 0x40":99.662,"queue worker 0x48":97.088,"queue worker 0x3a":0.06},"top_phases_ms_per_frame":{"Driver.Packet":76.611,"Driver.Packet.memory_wait":46.97,"Driver.Packet.dispatch":15.657,"Driver.Dispatch":14.064,"VideoOut.Flip":6.645,"Vulkan.DispatchRecipe":5.77,"Vulkan.DispatchRecipe.command_record":5.765,"Driver.Present":5.472},"trace_dropped":false,"trace":"aps5-trace-5b2b0eb50830-47155.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 344: 55.4 ms at 4989 ms: Driver.WorkerWait (queue worker 0x3a) 55.3, Driver.Packet (queue worker 0x48) 54.8, Driver.Packet (queue worker 0x40) 54.8, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 53.1
  • present 347: 30.3 ms at 5101 ms: Driver.WorkerWait (queue worker 0x3a) 30.2, Driver.Packet (queue worker 0x40) 29.5, Driver.Packet (queue worker 0x48) 29.4, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 28.5
  • present 380: 30.3 ms at 6017 ms: Driver.WorkerWait (queue worker 0x3a) 30.3, Driver.Packet (queue worker 0x40) 29.0, Driver.Packet (queue worker 0x48) 28.3, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 28.0
  • present 383: 30.2 ms at 6101 ms: Driver.WorkerWait (queue worker 0x3a) 30.2, Driver.Packet (queue worker 0x40) 29.4, Driver.Packet (queue worker 0x48) 28.9, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 28.5
  • present 359: 29.9 ms at 5435 ms: Driver.WorkerWait (queue worker 0x3a) 29.9, Driver.Packet (queue worker 0x48) 29.6, Driver.Packet (queue worker 0x40) 29.0, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 28.3

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 16.1 (61 %) 7.2 (27 %) 3.0 5.4 Driver.Packet 23.0, Driver.EndSubmission 0.1
title 0.1 (0 %) 0.0 (0 %) 26.2 0.1 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 26.2 0.0 Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 26.2 0.1 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 26.2 0.2 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
queue worker 0x40 8.2 (31 %) 17.3 (66 %) 0.7 2.2 Driver.Packet 25.5, Driver.EndSubmission 0.1
queue worker 0x48 0.8 (3 %) 25.3 (96 %) 0.2 0.2 Driver.Packet 24.7, Driver.EndSubmission 0.6
draw committer 2.4 (9 %) 1.9 (7 %) 22.0 0.6 Graphics.Draw 1.6, Recorder.Reap 0.5
presenter 1.4 (5 %) 5.3 (20 %) 19.6 0.1 VideoOut.Flip 6.6, Driver.Present 0.0
queue worker 0x3a 0.0 (0 %) 5.5 (21 %) 20.7 0.0 Driver.Packet 0.0, Driver.Completion 0.0
gpu 19.5 (74 %) 0.0 (0 %) 6.7 0.0 batch 19.5

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 73.1, Driver.Packet.memory_wait 46.9, batch 19.5, Driver.Packet.dispatch 15.3, Driver.Dispatch 13.6, VideoOut.Flip 6.6, Driver.WorkerWait 6.3, Vulkan.DispatchRecipe 5.7, Vulkan.DispatchRecipe.command_record 5.7, Driver.Present 5.5

Longest waits

  • Driver.WorkerWait (queue worker 0x3a) 55.2 ms at 4989 ms, present 344
  • Driver.Packet.memory_wait (queue worker 0x48) 42.7 ms at 5004 ms, present 344
  • Driver.Packet.memory_wait (queue worker 0x40) 34.4 ms at 5017 ms, present 344
  • Driver.Packet.memory_wait (queue worker 0x48) 32.8 ms at 4968 ms, present 343
  • Driver.WorkerWait (queue worker 0x3a) 30.4 ms at 6017 ms, present 379
  • Driver.WorkerWait (queue worker 0x3a) 30.2 ms at 6101 ms, present 383
  • Driver.WorkerWait (queue worker 0x3a) 30.2 ms at 5101 ms, present 347
  • Driver.WorkerWait (queue worker 0x3a) 30.0 ms at 5435 ms, present 358
  • Driver.WorkerWait (queue worker 0x3a) 29.6 ms at 5268 ms, present 352
  • Driver.WorkerWait (queue worker 0x3a) 29.3 ms at 5768 ms, present 371

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 4839: 3.4 ms at 2529 ms, present 248: GPU no ranges; recorded by Recorder.Reap (draw committer) 0.1, GpuMutex.wait.label (draw committer) 0.1, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1
  • batch 4547: 3.0 ms at 2370 ms, present 242: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Resources.Complete (draw committer) 0.0, GpuMutex.wait.flush (draw committer) 0.0
  • batch 10277: 2.9 ms at 5446 ms, present 359: GPU no ranges; recorded by GpuMutex.wait.draw (draw committer) 0.1, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Reap (draw committer) 0.0
  • batch 6489: 2.9 ms at 3403 ms, present 282: GPU no ranges; recorded by GpuMutex.wait.flush (draw committer) 0.1, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1
  • batch 7420: 2.8 ms at 3886 ms, present 301: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.2, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Reap (draw committer) 0.1, GpuMutex.wait.flush (draw committer) 0.0
trace_digest.py, this PR (second round)

frames 150:240 from present 150: 240 presents, frame p50 20.6 / p90 22.6 / p99 25.1 / max 42.5 ms, GPU busy 11.9 ms per present
Apple M5 Pro, MoltenVK 1.4.2, Darwin 27.2.0, 3840x2160, commit 1f0553384a68, dropped: no

{"commit":"1f0553384a68","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_DUMP_FRAMES":"200","APS5_DUMP_FRAMES_EVERY":"60","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"150:240"},"gpu":"Apple M5 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 150:240","first_present":150,"ms":5043.434},"presents":240,"frame_ms":{"p50":20.649,"p90":22.565,"p99":25.074,"max":42.485},"gpu_busy_ms_per_present":11.92,"worker_busy_pct":{"queue worker 0x0":98.392,"queue worker 0x40":99.649,"queue worker 0x48":86.217,"queue worker 0x3a":0.058},"top_phases_ms_per_frame":{"Driver.Packet":59.51,"Driver.Packet.memory_wait":36.905,"Driver.Packet.dispatch":12.25,"Driver.Dispatch":11.379,"Vulkan.DispatchRecipe":6.837,"Vulkan.DispatchRecipe.command_record":6.833,"VideoOut.Flip":6.486,"Driver.Present":5.521},"trace_dropped":false,"trace":"aps5-trace-1f0553384a68-47301.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 357: 42.5 ms at 4262 ms: Driver.WorkerWait (queue worker 0x3a) 42.5, Driver.Packet (queue worker 0x48) 42.4, Driver.Packet (queue worker 0x40) 41.8, Driver.Packet.memory_wait (queue worker 0x48) 40.9
  • present 379: 26.0 ms at 4783 ms: Driver.WorkerWait (queue worker 0x3a) 25.9, Driver.Packet (queue worker 0x40) 25.2, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 23.9, Driver.Packet (queue worker 0x48) 22.6
  • present 386: 25.1 ms at 4948 ms: Driver.WorkerWait (queue worker 0x3a) 24.8, Driver.Packet (queue worker 0x40) 24.3, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 23.2, Driver.Packet (queue worker 0x48) 22.6
  • present 378: 24.9 ms at 4758 ms: Driver.WorkerWait (queue worker 0x3a) 24.7, Driver.Packet (queue worker 0x40) 24.2, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 22.8, Driver.Packet (queue worker 0x48) 22.3
  • present 383: 24.7 ms at 4876 ms: Driver.WorkerWait (queue worker 0x3a) 24.6, Driver.Packet (queue worker 0x40) 23.9, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 22.7, Driver.Packet (queue worker 0x48) 21.8

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 10.2 (48 %) 8.0 (38 %) 2.9 5.2 Driver.Packet 17.9, Driver.EndSubmission 0.1
title 0.1 (0 %) 0.0 (0 %) 20.9 0.1 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.1 (0 %) 0.0 (0 %) 21.0 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
title 0.1 (0 %) 0.0 (0 %) 21.0 0.0 Shader.ResolveGraphicsStagesAbi 0.1
title 0.0 (0 %) 0.0 (0 %) 21.0 0.2 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
queue worker 0x40 8.8 (42 %) 11.5 (55 %) 0.7 2.2 Driver.Packet 20.3, Driver.EndSubmission 0.1
queue worker 0x48 0.2 (1 %) 20.6 (98 %) 0.1 0.2 Driver.Packet 18.0, Driver.EndSubmission 0.0
draw committer 1.8 (9 %) 1.1 (5 %) 18.1 0.6 Graphics.Draw 1.4, Recorder.Reap 0.2
presenter 1.1 (5 %) 5.4 (26 %) 14.5 0.1 VideoOut.Flip 6.5, Driver.Present 0.0
queue worker 0x3a 0.0 (0 %) 3.4 (16 %) 17.6 0.0 Driver.Packet 0.0, Driver.Completion 0.0
gpu 11.9 (57 %) 0.0 (0 %) 9.1 0.0 batch 11.9

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 56.2, Driver.Packet.memory_wait 36.9, batch 11.9, Driver.Packet.dispatch 11.9, Driver.Dispatch 10.9, Vulkan.DispatchRecipe 6.7, Vulkan.DispatchRecipe.command_record 6.7, VideoOut.Flip 6.5, Driver.WorkerWait 6.3, Driver.Present 5.5

Longest waits

  • Driver.WorkerWait (queue worker 0x3a) 42.6 ms at 4262 ms, present 356
  • Driver.Packet.memory_wait (queue worker 0x48) 32.9 ms at 4273 ms, present 357
  • Driver.WorkerWait (queue worker 0x3a) 25.9 ms at 4783 ms, present 379
  • Driver.Packet.memory_wait (queue worker 0x40) 25.8 ms at 4281 ms, present 357
  • Driver.WorkerWait (queue worker 0x3a) 24.8 ms at 4948 ms, present 386
  • Driver.WorkerWait (queue worker 0x3a) 24.7 ms at 4758 ms, present 378
  • Driver.WorkerWait (queue worker 0x3a) 24.6 ms at 4876 ms, present 383
  • Driver.Packet.memory_wait (queue worker 0x48) 24.5 ms at 4247 ms, present 356
  • Driver.WorkerWait (queue worker 0x3a) 24.3 ms at 4551 ms, present 368
  • Driver.WorkerWait (queue worker 0x3a) 24.2 ms at 4996 ms, present 388

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 8769: 2.6 ms at 3677 ms, present 328: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.2, Graphics.Draw.draw_and_resource_release (draw committer) 0.2
  • batch 3648: 2.6 ms at 1517 ms, present 224: GPU no ranges; recorded by GpuMutex.wait.label (draw committer) 0.2, GpuMutex.wait.flush (draw committer) 0.1, Graphics.Draw (draw committer) 0.0, Graphics.Draw.draw_and_resource_release (draw committer) 0.0
  • batch 9556: 2.5 ms at 4012 ms, present 344: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.2, Graphics.Draw.draw_and_resource_release (draw committer) 0.2
  • batch 7495: 2.5 ms at 3135 ms, present 302: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.2, Graphics.Draw.draw_and_resource_release (draw committer) 0.2
  • batch 9384: 2.5 ms at 3936 ms, present 341: GPU no ranges; recorded by Driver.Packet (queue worker 0x40) 0.6, Driver.Packet.dispatch (queue worker 0x40) 0.5, Driver.Dispatch (queue worker 0x40) 0.4, Vulkan.DispatchRecipe (queue worker 0x40) 0.2

Over whole 120 s runs, counting the frames dumped every 60 presents, the same comparison gives 44.0 and 44.3 FPS against 38.1 and 37.1 with APS5_NO_LABEL_READ_TRAP=1. With 0fdd66d900 it gives 44.2 and 44.7 against 38.2, 37.8 and 37.8; one more run with the traps, the first after the rebuild, gave 22.3. The image is the same. In an earlier instrumented run of this design, no trap was resolved by a read in that scene: the emulator itself stored every trapped image, about 65 times a second, before any guest read.

Validation: the 82 CTest entries of agc_driver_recorder_tests with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1 (ctest -V) on the base and on this PR report the same 152 VUID-VkDeviceCreateInfo-pProperties-04451 lines (the test device does not enable VK_KHR_portability_subset on MoltenVK, #10920) and no other VUID-. Neither log reports the layer as not found.

Not tested on a title that reads these images from the CPU.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #13442
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Apple M5 Pro, MoltenVK (Vulkan SDK 1.4.363), macOS 27.2
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5088109656 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13499). Originally posted by [Gonic0](https://github.com/Gonic0) on 2026-10-30T17:03:47Z. --- ### What **Builds on #13442.** Until it merges, this branch carries its commits; only `2cf5b41ec8` and `0fdd66d900` are new here. `StorageTexture::StoreReadbackBeforeLabel` writes back every pending linear or small storage image before each label, whether or not the CPU reads it. On macOS this PR traps CPU reads of such an image with #13442's write-watch read traps instead of storing it, so the store happens only when something reads or writes its memory. - **Label:** under the pending registry's mutex, an image that shares no page with another pending or storing image, and is not direct memory mapped at a second address, gets `GuestWriteWatchTrapReads` over its exact range instead of its store. The alias check is a new libkernel export, `DirectMemoryAliased_nid_postfix`, which tells whether any of a range's physical memory is mapped by another direct mapping. If the trap cannot be set (unwatched memory, a host write in progress), the image is stored as before. #13442 makes a trap of an already trapped range a no-op, so the same range can be trapped at every label without the driver tracking it. - **Resolver:** the first access to a trapped page runs `GuestMemory::FlushGpuWrites` over the trap's range on the write watch's resolver thread. That is the host-read hook every other reader of guest memory uses: it stores the pending results and waits until they are in memory. While a queued draw still holds reads of the range (`DrawPipeline::HeldReads`, which makes the store wait), it retries. - **Release:** every store releases the trap in `writeBackLayers`, so `FlushPending`, cache eviction (`Flush`), `WriteBack` and refreshes all do. A store that copies into the import on the GPU releases it once the copy is recorded, so a read that faults before then waits for the store. A store through the CPU releases it before its first access to guest memory, together with the traps of other images on the same pages; those images stay pending and are trapped again at the next label. A trapped image is stored whole. - **Opt-out:** `APS5_NO_LABEL_READ_TRAP=1` keeps the store at the label. Linux and Windows are unchanged. Gaps, in the new entry of `docs/dev/debt/libSceAgcDriver.md`: - a read after a store released the trap and before its GPU copy lands sees the old bytes; - a thread that holds `GpuMutex` and touches a trapped image waits for the resolver forever; - a system call that reads a trapped image without the host-read hook fails with `EFAULT`; - memory mapped twice other than direct memory is not detected. The page rule keeps the storing thread from faulting on a page another image's trap covers. If it did, the resolver would wait for that store while the store waits for the resolver. ### Tested Apple M5 Pro, macOS 27.2, MoltenVK from Vulkan SDK 1.4.363, x86-64 Release under Rosetta 2. `main` alone does not build on macOS, so the tests and the game ran in a tree with the open macOS port PRs, where these files are identical. `agc_small_tiled_shadow_label` (`agc_driver_recorder_tests --small-tiled-shadow-label-only`) gets a trap check on macOS. After the image is written again on the GPU: - two labels in a row leave its page without access (the second trap of the same range is a no-op), and a read from another thread sees the new results; - after the next write, a label traps it again, and `FlushPending` stores it and gives the page back; - after the next one, a thread calls `FlushPending` while the test holds `GpuMutex`, which takes the image out of the pending registry and waits. The page is still without access; a read started then sees the stored results once the test releases the mutex. Two 8x8 linear images on one page (both architectures' page size): - a label traps the first while it is the only one pending; - with both pending, a label stores both and gives the page back; - with the first trapped again, a store of the second through the CPU (`FlushPending` with the reason `idle`, which takes the CPU path) completes, stores the second and gives the page back. The next label traps the first again, and a read sees its results. The test thread releases `GpuMutex` around the read, since the resolver needs it. The test passes with and without `APS5_NO_LABEL_READ_TRAP=1`. Negative controls, each of which fails it: - no release in `writeBackLayers`: "storing a trapped image did not release its trap"; - the release where `FlushPending` takes the image out of the registry, as before: "a trapped image taken for a store gave back its pages before the store"; - the CPU path not releasing the traps of other images on its pages: "a CPU store next to a trapped image did not store through its page"; - the label storing instead of trapping: "a label stored a pending small tiled image instead of trapping its reads"; - a resolver that calls `FlushPending` without waiting: "a read of a trapped image did not see its pending results". The 82 CTest entries of `agc_driver_recorder_tests` pass, except one skip and `agc_recorder_failed_check`, which fails the same way with `APS5_NO_LABEL_READ_TRAP=1`. The write-watch tests pass on x86-64 and arm64 (#13442). The whole-image store of a trapped image and the alias check are not covered by a test: these images have one layer, the recorder test's memory is not direct memory, and `guest_memory_tests` does not build on macOS (`sceKernelMunmap`). PPSA21564 (ASTRO BOT 01.007.000), the logos before the intro. `main` does not build on macOS without the open port PRs, so the base is that tree with #13220 and #13442 (`5b2b0eb50830`), and the change is the same tree with this commit's `Texture.cpp` (`1f0553384a68`). Captures with `APS5_TRACE_FRAMES=150:240` and no other trace or profile switch, alternated base, change, base, change: | capture | commit | frame p50 / p90 / p99 (ms) | 240 presents in | |---|---|---|---| | base 1 | `5b2b0eb50830` | 29.3 / 32.5 / 35.4 | 7.11 s | | change 1 | `1f0553384a68` | 21.7 / 24.7 / 26.1 | 5.30 s | | base 2 | `5b2b0eb50830` | 26.0 / 28.1 / 30.3 | 6.30 s | | change 2 | `1f0553384a68` | 20.6 / 22.6 / 25.1 | 5.04 s | Summary lines of the second round. Base: ```json {"commit":"5b2b0eb50830","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_DUMP_FRAMES":"200","APS5_DUMP_FRAMES_EVERY":"60","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"150:240"},"gpu":"Apple M5 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 150:240","first_present":150,"ms":6300.896},"presents":240,"frame_ms":{"p50":26.029,"p90":28.079,"p99":30.286,"max":55.441},"gpu_busy_ms_per_present":19.524,"worker_busy_pct":{"queue worker 0x0":98.610,"queue worker 0x40":99.662,"queue worker 0x48":97.088,"queue worker 0x3a":0.060},"top_phases_ms_per_frame":{"Driver.Packet":76.611,"Driver.Packet.memory_wait":46.970,"Driver.Packet.dispatch":15.657,"Driver.Dispatch":14.064,"VideoOut.Flip":6.645,"Vulkan.DispatchRecipe":5.770,"Vulkan.DispatchRecipe.command_record":5.765,"Driver.Present":5.472},"trace_dropped":false,"trace":"aps5-trace-5b2b0eb50830-47155.json.gz"} ``` This PR: ```json {"commit":"1f0553384a68","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_DUMP_FRAMES":"200","APS5_DUMP_FRAMES_EVERY":"60","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"150:240"},"gpu":"Apple M5 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 150:240","first_present":150,"ms":5043.434},"presents":240,"frame_ms":{"p50":20.649,"p90":22.565,"p99":25.074,"max":42.485},"gpu_busy_ms_per_present":11.920,"worker_busy_pct":{"queue worker 0x0":98.392,"queue worker 0x40":99.649,"queue worker 0x48":86.217,"queue worker 0x3a":0.058},"top_phases_ms_per_frame":{"Driver.Packet":59.510,"Driver.Packet.memory_wait":36.905,"Driver.Packet.dispatch":12.250,"Driver.Dispatch":11.379,"Vulkan.DispatchRecipe":6.837,"Vulkan.DispatchRecipe.command_record":6.833,"VideoOut.Flip":6.486,"Driver.Present":5.521},"trace_dropped":false,"trace":"aps5-trace-1f0553384a68-47301.json.gz"} ``` Traces: [base](https://github.com/user-attachments/files/34194092/aps5-trace-5b2b0eb50830-47155.json.gz), [this PR](https://github.com/user-attachments/files/34194090/aps5-trace-1f0553384a68-47301.json.gz). <details><summary><code>trace_digest.py</code>, base (second round)</summary> **frames 150:240** from present 150: 240 presents, frame p50 26.0 / p90 28.1 / p99 30.3 / max 55.4 ms, GPU busy 19.5 ms per present Apple M5 Pro, MoltenVK 1.4.2, Darwin 27.2.0, 3840x2160, commit 5b2b0eb50830, dropped: no ```json {"commit":"5b2b0eb50830","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_DUMP_FRAMES":"200","APS5_DUMP_FRAMES_EVERY":"60","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"150:240"},"gpu":"Apple M5 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 150:240","first_present":150,"ms":6300.896},"presents":240,"frame_ms":{"p50":26.029,"p90":28.079,"p99":30.286,"max":55.441},"gpu_busy_ms_per_present":19.524,"worker_busy_pct":{"queue worker 0x0":98.61,"queue worker 0x40":99.662,"queue worker 0x48":97.088,"queue worker 0x3a":0.06},"top_phases_ms_per_frame":{"Driver.Packet":76.611,"Driver.Packet.memory_wait":46.97,"Driver.Packet.dispatch":15.657,"Driver.Dispatch":14.064,"VideoOut.Flip":6.645,"Vulkan.DispatchRecipe":5.77,"Vulkan.DispatchRecipe.command_record":5.765,"Driver.Present":5.472},"trace_dropped":false,"trace":"aps5-trace-5b2b0eb50830-47155.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 344: 55.4 ms at 4989 ms: Driver.WorkerWait (queue worker 0x3a) 55.3, Driver.Packet (queue worker 0x48) 54.8, Driver.Packet (queue worker 0x40) 54.8, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 53.1 - present 347: 30.3 ms at 5101 ms: Driver.WorkerWait (queue worker 0x3a) 30.2, Driver.Packet (queue worker 0x40) 29.5, Driver.Packet (queue worker 0x48) 29.4, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 28.5 - present 380: 30.3 ms at 6017 ms: Driver.WorkerWait (queue worker 0x3a) 30.3, Driver.Packet (queue worker 0x40) 29.0, Driver.Packet (queue worker 0x48) 28.3, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 28.0 - present 383: 30.2 ms at 6101 ms: Driver.WorkerWait (queue worker 0x3a) 30.2, Driver.Packet (queue worker 0x40) 29.4, Driver.Packet (queue worker 0x48) 28.9, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 28.5 - present 359: 29.9 ms at 5435 ms: Driver.WorkerWait (queue worker 0x3a) 29.9, Driver.Packet (queue worker 0x48) 29.6, Driver.Packet (queue worker 0x40) 29.0, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 28.3 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 16.1 (61 %) | 7.2 (27 %) | 3.0 | 5.4 | Driver.Packet 23.0, Driver.EndSubmission 0.1 | | title | 0.1 (0 %) | 0.0 (0 %) | 26.2 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 26.2 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 26.2 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 26.2 | 0.2 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | queue worker 0x40 | 8.2 (31 %) | 17.3 (66 %) | 0.7 | 2.2 | Driver.Packet 25.5, Driver.EndSubmission 0.1 | | queue worker 0x48 | 0.8 (3 %) | 25.3 (96 %) | 0.2 | 0.2 | Driver.Packet 24.7, Driver.EndSubmission 0.6 | | draw committer | 2.4 (9 %) | 1.9 (7 %) | 22.0 | 0.6 | Graphics.Draw 1.6, Recorder.Reap 0.5 | | presenter | 1.4 (5 %) | 5.3 (20 %) | 19.6 | 0.1 | VideoOut.Flip 6.6, Driver.Present 0.0 | | queue worker 0x3a | 0.0 (0 %) | 5.5 (21 %) | 20.7 | 0.0 | Driver.Packet 0.0, Driver.Completion 0.0 | | gpu | 19.5 (74 %) | 0.0 (0 %) | 6.7 | 0.0 | batch 19.5 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 73.1, Driver.Packet.memory_wait 46.9, batch 19.5, Driver.Packet.dispatch 15.3, Driver.Dispatch 13.6, VideoOut.Flip 6.6, Driver.WorkerWait 6.3, Vulkan.DispatchRecipe 5.7, Vulkan.DispatchRecipe.command_record 5.7, Driver.Present 5.5 **Longest waits** - Driver.WorkerWait (queue worker 0x3a) 55.2 ms at 4989 ms, present 344 - Driver.Packet.memory_wait (queue worker 0x48) 42.7 ms at 5004 ms, present 344 - Driver.Packet.memory_wait (queue worker 0x40) 34.4 ms at 5017 ms, present 344 - Driver.Packet.memory_wait (queue worker 0x48) 32.8 ms at 4968 ms, present 343 - Driver.WorkerWait (queue worker 0x3a) 30.4 ms at 6017 ms, present 379 - Driver.WorkerWait (queue worker 0x3a) 30.2 ms at 6101 ms, present 383 - Driver.WorkerWait (queue worker 0x3a) 30.2 ms at 5101 ms, present 347 - Driver.WorkerWait (queue worker 0x3a) 30.0 ms at 5435 ms, present 358 - Driver.WorkerWait (queue worker 0x3a) 29.6 ms at 5268 ms, present 352 - Driver.WorkerWait (queue worker 0x3a) 29.3 ms at 5768 ms, present 371 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 4839: 3.4 ms at 2529 ms, present 248: GPU no ranges; recorded by Recorder.Reap (draw committer) 0.1, GpuMutex.wait.label (draw committer) 0.1, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1 - batch 4547: 3.0 ms at 2370 ms, present 242: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Resources.Complete (draw committer) 0.0, GpuMutex.wait.flush (draw committer) 0.0 - batch 10277: 2.9 ms at 5446 ms, present 359: GPU no ranges; recorded by GpuMutex.wait.draw (draw committer) 0.1, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Reap (draw committer) 0.0 - batch 6489: 2.9 ms at 3403 ms, present 282: GPU no ranges; recorded by GpuMutex.wait.flush (draw committer) 0.1, Graphics.Draw (draw committer) 0.1, Graphics.Draw.draw_and_resource_release (draw committer) 0.1 - batch 7420: 2.8 ms at 3886 ms, present 301: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.2, Graphics.Draw.draw_and_resource_release (draw committer) 0.1, Recorder.Reap (draw committer) 0.1, GpuMutex.wait.flush (draw committer) 0.0 </details> <details><summary><code>trace_digest.py</code>, this PR (second round)</summary> **frames 150:240** from present 150: 240 presents, frame p50 20.6 / p90 22.6 / p99 25.1 / max 42.5 ms, GPU busy 11.9 ms per present Apple M5 Pro, MoltenVK 1.4.2, Darwin 27.2.0, 3840x2160, commit 1f0553384a68, dropped: no ```json {"commit":"1f0553384a68","dirty":null,"env":{"APS5_ASYNC_PIPELINES":"1","APS5_DUMP_FRAMES":"200","APS5_DUMP_FRAMES_EVERY":"60","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_FRAMES":"150:240"},"gpu":"Apple M5 Pro","driver":"MoltenVK 1.4.2","os":"Darwin 27.2.0","cpu":"VirtualApple @ 2.50GHz","cpu_threads":18,"memory_mib":49152,"title_id":"PPSA21564","title":"ASTRO BOT","content_version":"01.007.000","resolution":"3840x2160","window":{"spec":"frames 150:240","first_present":150,"ms":5043.434},"presents":240,"frame_ms":{"p50":20.649,"p90":22.565,"p99":25.074,"max":42.485},"gpu_busy_ms_per_present":11.92,"worker_busy_pct":{"queue worker 0x0":98.392,"queue worker 0x40":99.649,"queue worker 0x48":86.217,"queue worker 0x3a":0.058},"top_phases_ms_per_frame":{"Driver.Packet":59.51,"Driver.Packet.memory_wait":36.905,"Driver.Packet.dispatch":12.25,"Driver.Dispatch":11.379,"Vulkan.DispatchRecipe":6.837,"Vulkan.DispatchRecipe.command_record":6.833,"VideoOut.Flip":6.486,"Driver.Present":5.521},"trace_dropped":false,"trace":"aps5-trace-1f0553384a68-47301.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 357: 42.5 ms at 4262 ms: Driver.WorkerWait (queue worker 0x3a) 42.5, Driver.Packet (queue worker 0x48) 42.4, Driver.Packet (queue worker 0x40) 41.8, Driver.Packet.memory_wait (queue worker 0x48) 40.9 - present 379: 26.0 ms at 4783 ms: Driver.WorkerWait (queue worker 0x3a) 25.9, Driver.Packet (queue worker 0x40) 25.2, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 23.9, Driver.Packet (queue worker 0x48) 22.6 - present 386: 25.1 ms at 4948 ms: Driver.WorkerWait (queue worker 0x3a) 24.8, Driver.Packet (queue worker 0x40) 24.3, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 23.2, Driver.Packet (queue worker 0x48) 22.6 - present 378: 24.9 ms at 4758 ms: Driver.WorkerWait (queue worker 0x3a) 24.7, Driver.Packet (queue worker 0x40) 24.2, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 22.8, Driver.Packet (queue worker 0x48) 22.3 - present 383: 24.7 ms at 4876 ms: Driver.WorkerWait (queue worker 0x3a) 24.6, Driver.Packet (queue worker 0x40) 23.9, Driver.WorkerWait.dequeue_order (queue worker 0x3a) 22.7, Driver.Packet (queue worker 0x48) 21.8 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 10.2 (48 %) | 8.0 (38 %) | 2.9 | 5.2 | Driver.Packet 17.9, Driver.EndSubmission 0.1 | | title | 0.1 (0 %) | 0.0 (0 %) | 20.9 | 0.1 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 21.0 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 21.0 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.1 | | title | 0.0 (0 %) | 0.0 (0 %) | 21.0 | 0.2 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | queue worker 0x40 | 8.8 (42 %) | 11.5 (55 %) | 0.7 | 2.2 | Driver.Packet 20.3, Driver.EndSubmission 0.1 | | queue worker 0x48 | 0.2 (1 %) | 20.6 (98 %) | 0.1 | 0.2 | Driver.Packet 18.0, Driver.EndSubmission 0.0 | | draw committer | 1.8 (9 %) | 1.1 (5 %) | 18.1 | 0.6 | Graphics.Draw 1.4, Recorder.Reap 0.2 | | presenter | 1.1 (5 %) | 5.4 (26 %) | 14.5 | 0.1 | VideoOut.Flip 6.5, Driver.Present 0.0 | | queue worker 0x3a | 0.0 (0 %) | 3.4 (16 %) | 17.6 | 0.0 | Driver.Packet 0.0, Driver.Completion 0.0 | | gpu | 11.9 (57 %) | 0.0 (0 %) | 9.1 | 0.0 | batch 11.9 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 56.2, Driver.Packet.memory_wait 36.9, batch 11.9, Driver.Packet.dispatch 11.9, Driver.Dispatch 10.9, Vulkan.DispatchRecipe 6.7, Vulkan.DispatchRecipe.command_record 6.7, VideoOut.Flip 6.5, Driver.WorkerWait 6.3, Driver.Present 5.5 **Longest waits** - Driver.WorkerWait (queue worker 0x3a) 42.6 ms at 4262 ms, present 356 - Driver.Packet.memory_wait (queue worker 0x48) 32.9 ms at 4273 ms, present 357 - Driver.WorkerWait (queue worker 0x3a) 25.9 ms at 4783 ms, present 379 - Driver.Packet.memory_wait (queue worker 0x40) 25.8 ms at 4281 ms, present 357 - Driver.WorkerWait (queue worker 0x3a) 24.8 ms at 4948 ms, present 386 - Driver.WorkerWait (queue worker 0x3a) 24.7 ms at 4758 ms, present 378 - Driver.WorkerWait (queue worker 0x3a) 24.6 ms at 4876 ms, present 383 - Driver.Packet.memory_wait (queue worker 0x48) 24.5 ms at 4247 ms, present 356 - Driver.WorkerWait (queue worker 0x3a) 24.3 ms at 4551 ms, present 368 - Driver.WorkerWait (queue worker 0x3a) 24.2 ms at 4996 ms, present 388 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 8769: 2.6 ms at 3677 ms, present 328: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.2, Graphics.Draw.draw_and_resource_release (draw committer) 0.2 - batch 3648: 2.6 ms at 1517 ms, present 224: GPU no ranges; recorded by GpuMutex.wait.label (draw committer) 0.2, GpuMutex.wait.flush (draw committer) 0.1, Graphics.Draw (draw committer) 0.0, Graphics.Draw.draw_and_resource_release (draw committer) 0.0 - batch 9556: 2.5 ms at 4012 ms, present 344: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.2, Graphics.Draw.draw_and_resource_release (draw committer) 0.2 - batch 7495: 2.5 ms at 3135 ms, present 302: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.2, Graphics.Draw.draw_and_resource_release (draw committer) 0.2 - batch 9384: 2.5 ms at 3936 ms, present 341: GPU no ranges; recorded by Driver.Packet (queue worker 0x40) 0.6, Driver.Packet.dispatch (queue worker 0x40) 0.5, Driver.Dispatch (queue worker 0x40) 0.4, Vulkan.DispatchRecipe (queue worker 0x40) 0.2 </details> Over whole 120 s runs, counting the frames dumped every 60 presents, the same comparison gives 44.0 and 44.3 FPS against 38.1 and 37.1 with `APS5_NO_LABEL_READ_TRAP=1`. With `0fdd66d900` it gives 44.2 and 44.7 against 38.2, 37.8 and 37.8; one more run with the traps, the first after the rebuild, gave 22.3. The image is the same. In an earlier instrumented run of this design, no trap was resolved by a read in that scene: the emulator itself stored every trapped image, about 65 times a second, before any guest read. Validation: the 82 CTest entries of `agc_driver_recorder_tests` with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1` (`ctest -V`) on the base and on this PR report the same 152 `VUID-VkDeviceCreateInfo-pProperties-04451` lines (the test device does not enable `VK_KHR_portability_subset` on MoltenVK, #10920) and no other `VUID-`. Neither log reports the layer as not found. Not tested on a title that reads these images from the CPU. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #13442 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: Apple M5 Pro, MoltenVK (Vulkan SDK 1.4.363), macOS 27.2 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-30 17:06:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T17:06:13Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The PR reports a performance improvement against its opt-out mode, but the repository requires captures from main and the change before that claim can be checked.

What I ran

Reviewed head a485eb515e3021a565d66222bfe3eceb883e933d against base a026562629da7bcc7af781639a11ab0647a524dd. The dependency stack preview reports a clean merge preview for this head against the current base. Environment: Linux x86-64, Debian 12, Python 3.11.2, GCC 12.2.0.

git diff --check a026562629da7bcc7af781639a11ab0647a524dd...a485eb515e3021a565d66222bfe3eceb883e933d
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13499
python3 tools/pr_stack_check.py 13499 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13499-a485eb515e30/stack
gh pr checks 13499 --repo boykopovar/AnyPS5

Results

Check Result
Diff whitespace check Passed
Repository conventions and PR template Passed
Dependency and merge preview Passed; #13220 → #13442 → #13499, with a clean preview against current base
Hosted checks Pending when checked
Performance evidence required by repository rules Missing: the description has no paired main/change summary lines, attached traces, or trace_digest.py output
Raw output
All conventions checks passed.

PR stack check — fresh

Target: https://github.com/boykopovar/AnyPS5/pull/13499
Target branch tip: `a026562629da7bcc7af781639a11ab0647a524dd`
All heads unchanged: **True**
Dependency order: #13220 → #13442 → #13499

## Individual merge previews

- PR #13220: **clean** against current base; head `e9f09f54fabb6408d3e2711b8df10c10112ab00e`; changed paths: none reported
- PR #13442: **clean** against current base; head `bd49ace09e78998c8da23033ff0e3fa9b1d9237e`; changed paths: none reported
- PR #13499: **clean** against current base; head `a485eb515e3021a565d66222bfe3eceb883e933d`; changed paths: none reported

## Dependency relationships

- PR #13220 → #13442: current dependency head not included; overlapping path: `core/libs/tests/write_watch/CMakeLists.txt`
- PR #13442 → #13499: dependency head included

conventions	pending	0
eligibility	pending	0
intake	pending	0
labels	pending	0
library-portability	pending	0
report	pending	0

The precheck's ABI-audit and test-quality helper steps were not executable in its isolated PR snapshot because those local helper scripts are absent there; these are not reported as repository failures.

Findings

Blocking

  • Required performance comparison is incomplete. The description reports 44.0/44.3 FPS with traps and 38.1/37.1 FPS with APS5_NO_LABEL_READ_TRAP=1, both on the PR stack. It does not provide captures from main and the change, nor the required trace artifacts and digest. The repository rule requires those paired captures for a speed claim. After dependency #13442 is in the baseline tree, add summary lines from the same title, scene, and machine, attach both traces, and include the tools/trace_digest.py output. Repository performance-report rule · Performance report form

Non-blocking

  • No additional blocking source defect was established by this no-build pass.

Not verified

  • I did not build or run C++/CTest. The 82 CTest results, negative controls, and Apple M5 Pro/MoltenVK measurements in the PR description are author-reported and were not independently reproduced.
  • Hosted checks were pending at the time checked. The reported measurements do not cover a title that reads these images from the CPU.

To get this to a good state

After #13442 is in the baseline tree, add the matched main and change captures and the required artifacts. I’ll re-check the updated head and its evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5715856703 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13499#pullrequestreview-5715856703). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T17:06:13Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The PR reports a performance improvement against its opt-out mode, but the repository requires captures from `main` and the change before that claim can be checked. ## What I ran Reviewed head `a485eb515e3021a565d66222bfe3eceb883e933d` against base `a026562629da7bcc7af781639a11ab0647a524dd`. The dependency stack preview reports a clean merge preview for this head against the current base. Environment: Linux x86-64, Debian 12, Python 3.11.2, GCC 12.2.0. ```sh git diff --check a026562629da7bcc7af781639a11ab0647a524dd...a485eb515e3021a565d66222bfe3eceb883e933d python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13499 python3 tools/pr_stack_check.py 13499 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13499-a485eb515e30/stack gh pr checks 13499 --repo boykopovar/AnyPS5 ``` ## Results | Check | Result | |---|---| | Diff whitespace check | Passed | | Repository conventions and PR template | Passed | | Dependency and merge preview | Passed; #13220 → #13442 → #13499, with a clean preview against current base | | Hosted checks | Pending when checked | | Performance evidence required by repository rules | Missing: the description has no paired `main`/change summary lines, attached traces, or `trace_digest.py` output | <details><summary>Raw output</summary> ```text All conventions checks passed. ``` ```text PR stack check — fresh Target: https://github.com/boykopovar/AnyPS5/pull/13499 Target branch tip: `a026562629da7bcc7af781639a11ab0647a524dd` All heads unchanged: **True** Dependency order: #13220 → #13442 → #13499 ## Individual merge previews - PR #13220: **clean** against current base; head `e9f09f54fabb6408d3e2711b8df10c10112ab00e`; changed paths: none reported - PR #13442: **clean** against current base; head `bd49ace09e78998c8da23033ff0e3fa9b1d9237e`; changed paths: none reported - PR #13499: **clean** against current base; head `a485eb515e3021a565d66222bfe3eceb883e933d`; changed paths: none reported ## Dependency relationships - PR #13220 → #13442: current dependency head not included; overlapping path: `core/libs/tests/write_watch/CMakeLists.txt` - PR #13442 → #13499: dependency head included ``` ```text conventions pending 0 eligibility pending 0 intake pending 0 labels pending 0 library-portability pending 0 report pending 0 ``` The precheck's ABI-audit and test-quality helper steps were not executable in its isolated PR snapshot because those local helper scripts are absent there; these are not reported as repository failures. </details> ## Findings ### Blocking - **Required performance comparison is incomplete.** The description reports 44.0/44.3 FPS with traps and 38.1/37.1 FPS with `APS5_NO_LABEL_READ_TRAP=1`, both on the PR stack. It does not provide captures from `main` and the change, nor the required trace artifacts and digest. The repository rule requires those paired captures for a speed claim. After dependency #13442 is in the baseline tree, add summary lines from the same title, scene, and machine, attach both traces, and include the `tools/trace_digest.py` output. [Repository performance-report rule](https://github.com/boykopovar/AnyPS5/blob/a485eb515e3021a565d66222bfe3eceb883e933d/CONTRIBUTING.md#L71) · [Performance report form](https://github.com/boykopovar/AnyPS5/blob/a485eb515e3021a565d66222bfe3eceb883e933d/.github/ISSUE_TEMPLATE/performance.yml) ### Non-blocking - No additional blocking source defect was established by this no-build pass. ## Not verified - I did not build or run C++/CTest. The 82 CTest results, negative controls, and Apple M5 Pro/MoltenVK measurements in the PR description are author-reported and were not independently reproduced. - Hosted checks were pending at the time checked. The reported measurements do not cover a title that reads these images from the CPU. ## To get this to a good state After #13442 is in the baseline tree, add the matched `main` and change captures and the required artifacts. I’ll re-check the updated head and its evidence.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!13499
No description provided.