perf(agc): compile uncached draws ahead of queue 0 #6188

Open
mitul72 wants to merge 5 commits from upstream-pr/6188 into main
mitul72 commented 2026-10-15 01:19:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mitul72 on 2026-10-15T01:19:49Z.


What

Six commits. Draws whose register key is new (per-frame ring addresses in user data make most keys new every frame) captured and recompiled their stages on the queue-0 thread, and each draw snapshotted its small inputs through the full buffer path.

  • Read-only draw inputs of up to 4 KiB are copied into slices of a 4 MiB host-visible chunk owned by the recorder (one bump allocation and one copy), on top of main's snapshot reuse: an unchanged input in the same collect epoch rebinds its slice, larger inputs keep main's caches. Chunks are never rewound; a draw's bindings hold its chunk until its batch completes.
  • The device's graphics context is passed to draws by reference.
  • The scan publishes draw keys, parameters and prechecks ahead of queue 0.
  • Worker threads compile the stages of every such draw with a Proceed precheck, using the same request as the queue-0 miss path (DrawStageRequest, DrawStageVariant), and insert the variants into the draw cache. Queue 0 validates them as any cached variant, against current memory.
  • Graphics::PrepareDraw computes the vertex input layout, pipeline stage mask and resource content key on the worker; they are stored on the entry, tied by weak reference to the exact variants compiled. Queue 0 uses them only for a non-indirect draw whose stages refreshed no data words; otherwise it builds them as before.

Worker count: a quarter of the hardware threads, clamped to 1-4. Without a working kernel copy no workers run. Draws whose compilation consumes packet-derived inputs (mesh draws, instanced tessellation, indirect draws) are not compiled ahead.

Validation of cache hits now dominates queue 0's lookup cost, since nearly every draw hits; the last commit tests validated runs against the pending images' merged range index, takes the shadow registry's mutex once per run list, and checks a run list against queued pipelined commits under one lock (DrawPipeline::OverlapsAny, same answer as the per-run check).

Admission follows the driver's own rule: every entry compiled ahead goes on probation, in its own list bounded by the cache size, so it pushes out only other probation entries. Promotion happens only through queue 0's own sighting under main's admission rule and exclusions, in one step with queue 0's insert decision, so a key is admitted at the same execution that would admit it without compile-ahead. Worker variants record their stage capture and pure-data word positions, so they take part in stage data hits.

Speculative reads: under GuestMemory::SpeculativeReadScope, Read copies through the kernel (process_vm_readv / ReadProcessMemory) into the capture's private buffer, so a concurrent store is not a data race and an unmapped page fails the copy instead of faulting. All other guest memory access in that scope throws (SpeculativeReadRefused). The variant records the words it was compiled from; queue 0 compares them with memory after its waits and flushes. Every guest read and cache insertion of a job is pinned to its draw; queue 0 passes a draw before executing it and retires the submission when it ends.

Speculative failures never surface: any exception in the scan, resolve, decode, capture, compile or PrepareDraw only means the draw has no precomputed result. Queue 0 then performs the draw as without draw-ahead on current memory. The serial path remains authoritative and throws on genuine errors; what the speculation saw (stale, torn or unmapped memory, an unfollowable context stack) is not an error of the draw.

Tests: DrawAhead, DrawAheadRaw, DrawAheadScan, Recorder additions. They include a draw with an invalid buffer descriptor repaired before the draw, a table mapped only after the worker's read, a draw after a CONTEXT_STATE push in a skipped COND_EXEC, an indexed draw of restart indices only with a stride beyond the device limit, and a refused read of an inaccessible range.

Tested

Linux, RX 9060 XT (RADV GFX12, local Mesa). Full ctest passes except agc_driver_tessellation, which segfaults inside RADV while linking pipeline libraries on unmodified upstream main as well.

Astro Bot crash-site hub on main 4eb91eacd (pipelined draws on), 3 x 10 s windows, gamescope headless, one run each, nothing else running:

fps CPU per draw packet capture recompile key/lookup/validate record phase per draw GPU busy / idle per frame
base 8.07 36.6 us 6.8 us 6.4 us 1.7 us 9.07 us 97 / 27 ms
draw-ahead 9.07 29.9 us 0.3 us 0.1 us 3.5 us 5.07 us 90 / 20 ms

Per 10 s: 196k draw records published, 196k used, 186k draws compiled ahead, 1.3k jobs dropped. With APS5_PROFILE_DRAW=1 a [draw-ahead] line reports these counts. Single runs of the base varied by about 0.3 fps.

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: none (#6359 composes with it in either order)
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 9060 XT (RADV GFX12, local Mesa build), Linux
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4866790084 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188). Originally posted by [mitul72](https://github.com/mitul72) on 2026-10-15T01:19:49Z. --- ### What Six commits. Draws whose register key is new (per-frame ring addresses in user data make most keys new every frame) captured and recompiled their stages on the queue-0 thread, and each draw snapshotted its small inputs through the full buffer path. - Read-only draw inputs of up to 4 KiB are copied into slices of a 4 MiB host-visible chunk owned by the recorder (one bump allocation and one copy), on top of main's snapshot reuse: an unchanged input in the same collect epoch rebinds its slice, larger inputs keep main's caches. Chunks are never rewound; a draw's bindings hold its chunk until its batch completes. - The device's graphics context is passed to draws by reference. - The scan publishes draw keys, parameters and prechecks ahead of queue 0. - Worker threads compile the stages of every such draw with a Proceed precheck, using the same request as the queue-0 miss path (`DrawStageRequest`, `DrawStageVariant`), and insert the variants into the draw cache. Queue 0 validates them as any cached variant, against current memory. - `Graphics::PrepareDraw` computes the vertex input layout, pipeline stage mask and resource content key on the worker; they are stored on the entry, tied by weak reference to the exact variants compiled. Queue 0 uses them only for a non-indirect draw whose stages refreshed no data words; otherwise it builds them as before. Worker count: a quarter of the hardware threads, clamped to 1-4. Without a working kernel copy no workers run. Draws whose compilation consumes packet-derived inputs (mesh draws, instanced tessellation, indirect draws) are not compiled ahead. Validation of cache hits now dominates queue 0's lookup cost, since nearly every draw hits; the last commit tests validated runs against the pending images' merged range index, takes the shadow registry's mutex once per run list, and checks a run list against queued pipelined commits under one lock (`DrawPipeline::OverlapsAny`, same answer as the per-run check). Admission follows the driver's own rule: every entry compiled ahead goes on probation, in its own list bounded by the cache size, so it pushes out only other probation entries. Promotion happens only through queue 0's own sighting under main's admission rule and exclusions, in one step with queue 0's insert decision, so a key is admitted at the same execution that would admit it without compile-ahead. Worker variants record their stage capture and pure-data word positions, so they take part in stage data hits. Speculative reads: under `GuestMemory::SpeculativeReadScope`, `Read` copies through the kernel (`process_vm_readv` / `ReadProcessMemory`) into the capture's private buffer, so a concurrent store is not a data race and an unmapped page fails the copy instead of faulting. All other guest memory access in that scope throws (`SpeculativeReadRefused`). The variant records the words it was compiled from; queue 0 compares them with memory after its waits and flushes. Every guest read and cache insertion of a job is pinned to its draw; queue 0 passes a draw before executing it and retires the submission when it ends. Speculative failures never surface: any exception in the scan, resolve, decode, capture, compile or `PrepareDraw` only means the draw has no precomputed result. Queue 0 then performs the draw as without draw-ahead on current memory. The serial path remains authoritative and throws on genuine errors; what the speculation saw (stale, torn or unmapped memory, an unfollowable context stack) is not an error of the draw. Tests: `DrawAhead`, `DrawAheadRaw`, `DrawAheadScan`, `Recorder` additions. They include a draw with an invalid buffer descriptor repaired before the draw, a table mapped only after the worker's read, a draw after a CONTEXT_STATE push in a skipped COND_EXEC, an indexed draw of restart indices only with a stride beyond the device limit, and a refused read of an inaccessible range. ### Tested Linux, RX 9060 XT (RADV GFX12, local Mesa). Full `ctest` passes except `agc_driver_tessellation`, which segfaults inside RADV while linking pipeline libraries on unmodified upstream main as well. Astro Bot crash-site hub on main 4eb91eacd (pipelined draws on), 3 x 10 s windows, gamescope headless, one run each, nothing else running: | | fps | CPU per draw packet | capture | recompile | key/lookup/validate | record phase per draw | GPU busy / idle per frame | |---|---|---|---|---|---|---|---| | base | 8.07 | 36.6 us | 6.8 us | 6.4 us | 1.7 us | 9.07 us | 97 / 27 ms | | draw-ahead | 9.07 | 29.9 us | 0.3 us | 0.1 us | 3.5 us | 5.07 us | 90 / 20 ms | Per 10 s: 196k draw records published, 196k used, 186k draws compiled ahead, 1.3k jobs dropped. With `APS5_PROFILE_DRAW=1` a `[draw-ahead]` line reports these counts. Single runs of the base varied by about 0.3 fps. ### 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: none (#6359 composes with it in either order) - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 9060 XT (RADV GFX12, local Mesa build), Linux - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jotitadev commented 2026-10-15 01:29:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T01:29:51Z.

Review: COMMENTED


macOS portability note on head b7798715d (static review, no full build).

Two calls in the non-Windows branches are Linux-only, so they will not compile for macOS (the port in #1 builds this driver with Apple clang):

  • Execution/src/Driver/Draw/DrawAhead.cpp:28: pthread_setname_np(pthread_self(), name); -- macOS only has the one-argument form, which names the calling thread.
  • Execution/src/GuestMemory.cpp:2014: process_vm_readv(getpid(), ...) -- not available on macOS.

Neither is used anywhere else in main today, so these would be the first ones. Checked with Apple clang 21 (clang++ -std=c++20 -arch x86_64 -c) on the two functions copied as they are:

snip6188.cpp:8:5: error: no matching function for call to 'pthread_setname_np'
snip6188.cpp:13:12: error: use of undeclared identifier 'process_vm_readv'

A drop-in for macOS that keeps the same semantics, verified on the same machine for arm64 and x86_64:

#elif defined(__APPLE__)
    pthread_setname_np(name);
#elif defined(__APPLE__)
    mach_vm_size_t copied = 0;
    return mach_vm_read_overwrite(mach_task_self(), address, destination.size(), reinterpret_cast<mach_vm_address_t>(destination.data()), &copied) == KERN_SUCCESS && copied == destination.size();

(<mach/mach.h>, <mach/mach_vm.h>). With it, the SpeculativeReadsSupported() probe succeeds, and a read of a PROT_NONE page, of an unmapped page, and of a range that straddles into a PROT_NONE page each fails cleanly instead of faulting, which is what SpeculativeReadRefused relies on. If you prefer not to add a macOS branch here, guarding both with __linux__ and letting copyThroughKernel return false elsewhere would just turn the draw-ahead workers off on macOS.

Written with AI assistance (Claude Code). I ran the checks above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5526935738 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#pullrequestreview-5526935738). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T01:29:51Z. **Review:** COMMENTED --- macOS portability note on head b7798715d (static review, no full build). Two calls in the non-Windows branches are Linux-only, so they will not compile for macOS (the port in #1 builds this driver with Apple clang): - `Execution/src/Driver/Draw/DrawAhead.cpp:28`: `pthread_setname_np(pthread_self(), name);` -- macOS only has the one-argument form, which names the calling thread. - `Execution/src/GuestMemory.cpp:2014`: `process_vm_readv(getpid(), ...)` -- not available on macOS. Neither is used anywhere else in `main` today, so these would be the first ones. Checked with Apple clang 21 (`clang++ -std=c++20 -arch x86_64 -c`) on the two functions copied as they are: ``` snip6188.cpp:8:5: error: no matching function for call to 'pthread_setname_np' snip6188.cpp:13:12: error: use of undeclared identifier 'process_vm_readv' ``` A drop-in for macOS that keeps the same semantics, verified on the same machine for arm64 and x86_64: ```cpp #elif defined(__APPLE__) pthread_setname_np(name); ``` ```cpp #elif defined(__APPLE__) mach_vm_size_t copied = 0; return mach_vm_read_overwrite(mach_task_self(), address, destination.size(), reinterpret_cast<mach_vm_address_t>(destination.data()), &copied) == KERN_SUCCESS && copied == destination.size(); ``` (`<mach/mach.h>`, `<mach/mach_vm.h>`). With it, the `SpeculativeReadsSupported()` probe succeeds, and a read of a `PROT_NONE` page, of an unmapped page, and of a range that straddles into a `PROT_NONE` page each fails cleanly instead of faulting, which is what `SpeculativeReadRefused` relies on. If you prefer not to add a macOS branch here, guarding both with `__linux__` and letting `copyThroughKernel` return false elsewhere would just turn the draw-ahead workers off on macOS. Written with AI assistance (Claude Code). I ran the checks above on my machine.
mitul72 commented 2026-10-15 01:34:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mitul72 on 2026-10-15T01:34:08Z.


Thanks, applied both macOS branches as suggested (pthread_setname_np(name) and mach_vm_read_overwrite) in 15647ffa9. Linux builds and the draw-ahead tests pass; I can't build for macOS here, so a check on your side would be welcome.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6182346856 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6182346856). Originally posted by [mitul72](https://github.com/mitul72) on 2026-10-15T01:34:08Z. --- Thanks, applied both macOS branches as suggested (`pthread_setname_np(name)` and `mach_vm_read_overwrite`) in 15647ffa9. Linux builds and the draw-ahead tests pass; I can't build for macOS here, so a check on your side would be welcome.
jotitadev commented 2026-10-15 02:31:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T02:31:41Z.

Review: COMMENTED


Checked on 15647ffa9 (Apple M2 Max, macOS 27.2, Apple clang 21): NameThread and copyThroughKernel copied verbatim from this head, with the include block, compile cleanly for arm64 and x86_64. On both, the thread gets its name, the SpeculativeReadsSupported() probe succeeds, and reads of a PROT_NONE page, an unmapped page and a range straddling into PROT_NONE return false without faulting. Not a full driver build (main doesn't link on macOS yet), but the two macOS branches look good.

Written with AI assistance (Claude Code). I ran the checks above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5527348760 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#pullrequestreview-5527348760). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T02:31:41Z. **Review:** COMMENTED --- Checked on 15647ffa9 (Apple M2 Max, macOS 27.2, Apple clang 21): `NameThread` and `copyThroughKernel` copied verbatim from this head, with the include block, compile cleanly for arm64 and x86_64. On both, the thread gets its name, the `SpeculativeReadsSupported()` probe succeeds, and reads of a `PROT_NONE` page, an unmapped page and a range straddling into `PROT_NONE` return false without faulting. Not a full driver build (`main` doesn't link on macOS yet), but the two macOS branches look good. Written with AI assistance (Claude Code). I ran the checks above on my machine.
fma-rc commented 2026-10-15 03:59:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T03:59:29Z.


I measured head 15647ffa9 against its base ab9a47684 in Astro's Playroom on Linux (RTX 5080, heavy in-game scene, three alternating runs of 20 s each, APS5_PROFILE_DRAW=1). Frame rate does not move here: 7.78 / 7.64 / 7.68 FPS with the PR against 7.88 / 7.52 / 7.59 without.

The work does leave queue 0, but about as much comes back in the lookup:

us per draw packet base PR
capture 7.0-7.7 5.1-5.3
recompile 4.2 1.3-1.4
key/lookup/validate 1.4 4.2-4.3
decode 1.6-3.7 3.1-3.2
Graphics::Draw 22.1-22.3 22.6-23.8

Memo hits go from 1-3% to 42%, so the entries compiled ahead are being used; capture staying at about 5 us suggests many draws still capture on queue 0. Frame dumps from both builds show the same picture in the scene. Its draw-ahead tests, with the recorder and draw-cache tests (8 in all), pass on NVIDIA, RADV (Ryzen 7800X3D integrated Radeon) and lavapipe.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6184074123 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6184074123). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-15T03:59:29Z. --- I measured head 15647ffa9 against its base ab9a47684 in Astro's Playroom on Linux (RTX 5080, heavy in-game scene, three alternating runs of 20 s each, `APS5_PROFILE_DRAW=1`). Frame rate does not move here: 7.78 / 7.64 / 7.68 FPS with the PR against 7.88 / 7.52 / 7.59 without. The work does leave queue 0, but about as much comes back in the lookup: | us per draw packet | base | PR | |---|---|---| | capture | 7.0-7.7 | 5.1-5.3 | | recompile | 4.2 | 1.3-1.4 | | key/lookup/validate | 1.4 | 4.2-4.3 | | decode | 1.6-3.7 | 3.1-3.2 | | `Graphics::Draw` | 22.1-22.3 | 22.6-23.8 | Memo hits go from 1-3% to 42%, so the entries compiled ahead are being used; capture staying at about 5 us suggests many draws still capture on queue 0. Frame dumps from both builds show the same picture in the scene. Its draw-ahead tests, with the recorder and draw-cache tests (8 in all), pass on NVIDIA, RADV (Ryzen 7800X3D integrated Radeon) and lavapipe.
mitul72 commented 2026-10-15 04:50:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mitul72 on 2026-10-15T04:50:50Z.


Thanks for measuring. 15647ffa9 had dropped the small-snapshot arena in a rebase; it is back in 0eb0d8903, and hit validation got cheaper (the pending-image check now uses the pending list's range index; key/lookup/validate 4.4 -> 3.0 us per draw in Astro Bot). With APS5_PROFILE_DRAW=1 a new [draw-ahead] line shows published, used, compiled and dropped counts. If you can rerun Playroom on the new head, that line (with [draw-cache]) would show why capture still costs ~5 us per draw there; my guess is that queue 0 reaches many draws before their worker compile commits.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6184679529 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6184679529). Originally posted by [mitul72](https://github.com/mitul72) on 2026-10-15T04:50:50Z. --- Thanks for measuring. 15647ffa9 had dropped the small-snapshot arena in a rebase; it is back in 0eb0d8903, and hit validation got cheaper (the pending-image check now uses the pending list's range index; key/lookup/validate 4.4 -> 3.0 us per draw in Astro Bot). With `APS5_PROFILE_DRAW=1` a new `[draw-ahead]` line shows published, used, compiled and dropped counts. If you can rerun Playroom on the new head, that line (with `[draw-cache]`) would show why capture still costs ~5 us per draw there; my guess is that queue 0 reaches many draws before their worker compile commits.
fma-rc commented 2026-10-15 05:22:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T05:22:43Z.


Reran Playroom on 0eb0d8903 against its base d92a8dad3, same scene and setup, one run each: 8.37 FPS against 7.33, and the frames match where both reach the scene.

us per draw packet d92a8dad3 0eb0d8903
capture 7.4 5.2
recompile 4.3 1.3
key/lookup/validate 1.4 3.9
decode 3.5 3.1
Graphics::Draw 22.9 19.6

Per 10 s, [draw-ahead] reads 243-245k records published, 243-244k used, 231-233k entries compiled ahead, 166-217 jobs dropped. [draw-cache] register key: 243,038 lookups, 83,313 hits, 159,468 partial (state, pixel and programs from the entry).

So queue 0 does find nearly every entry; it does not seem to arrive before the compile. About two thirds are partial hits, and those still capture. On main, nearly every register-key miss in this scene differs only in user-data words (per-frame pointers, APS5_TRACE_DRAW_CACHE), so most of the remaining capture looks like stages whose user words moved after the entry was compiled.

Update: with #5656 (8267abd21) stacked on 0eb0d8903, same scene, one run: 12.77 FPS, against 8.37 for 0eb0d8903 alone and 7.57 for d92a8dad3. The frames match. Register-key hits go to 372k of 373k lookups per 10 s, and capture, recompile and decode on queue 0 drop to 0.1, 0.0 and 0.4 us per draw, so Graphics::Draw (16.2 us) is what is left. In the merge I also applied 5656's user-word mask in compileDrawAhead.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6185070839 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6185070839). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-15T05:22:43Z. --- Reran Playroom on 0eb0d8903 against its base d92a8dad3, same scene and setup, one run each: 8.37 FPS against 7.33, and the frames match where both reach the scene. | us per draw packet | d92a8dad3 | 0eb0d8903 | |---|---|---| | capture | 7.4 | 5.2 | | recompile | 4.3 | 1.3 | | key/lookup/validate | 1.4 | 3.9 | | decode | 3.5 | 3.1 | | `Graphics::Draw` | 22.9 | 19.6 | Per 10 s, `[draw-ahead]` reads 243-245k records published, 243-244k used, 231-233k entries compiled ahead, 166-217 jobs dropped. `[draw-cache]` register key: 243,038 lookups, 83,313 hits, 159,468 partial (state, pixel and programs from the entry). So queue 0 does find nearly every entry; it does not seem to arrive before the compile. About two thirds are partial hits, and those still capture. On main, nearly every register-key miss in this scene differs only in user-data words (per-frame pointers, `APS5_TRACE_DRAW_CACHE`), so most of the remaining capture looks like stages whose user words moved after the entry was compiled. Update: with #5656 (8267abd21) stacked on 0eb0d8903, same scene, one run: 12.77 FPS, against 8.37 for 0eb0d8903 alone and 7.57 for d92a8dad3. The frames match. Register-key hits go to 372k of 373k lookups per 10 s, and capture, recompile and decode on queue 0 drop to 0.1, 0.0 and 0.4 us per draw, so `Graphics::Draw` (16.2 us) is what is left. In the merge I also applied 5656's user-word mask in `compileDrawAhead`.
fma-rc commented 2026-10-15 06:44:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T06:44:47Z.

Review: CHANGES_REQUESTED


agc_draw_snapshots fails here on NVIDIA (RTX 5080, driver 615.78.08, Linux) at 0eb0d8903, and at every commit of the PR from 1aee516ed on, where it is added:

AGC graphics: a draw snapshot does not hold the guest bytes of its draw

That is tests/Recorder.cpp:2711: after the CPU rewrites the element with 0x22, the snapshot still holds 0x11. agc_draw_snapshots_no_collect_memo passes, and so does --draw-snapshots-only with APS5_NO_COLLECT_MEMO=1, so the write collect memo seems to hide that CPU write from the snapshot reuse check. On RADV the case is skipped (storage buffer offset alignment 4: misaligned draw snapshots not tested), and on lavapipe too (host imports are compared, not watched: draw snapshot reuse not tested), so CI on llvmpipe would not see it. The linux job on this PR was skipped anyway.

If the test is right, a draw can read stale bytes after a CPU write on a GPU with watched host imports, the GPU my Playroom numbers above were measured on.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5529185802 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#pullrequestreview-5529185802). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-15T06:44:47Z. **Review:** CHANGES_REQUESTED --- `agc_draw_snapshots` fails here on NVIDIA (RTX 5080, driver 615.78.08, Linux) at 0eb0d8903, and at every commit of the PR from 1aee516ed on, where it is added: ``` AGC graphics: a draw snapshot does not hold the guest bytes of its draw ``` That is `tests/Recorder.cpp:2711`: after the CPU rewrites the element with 0x22, the snapshot still holds 0x11. `agc_draw_snapshots_no_collect_memo` passes, and so does `--draw-snapshots-only` with `APS5_NO_COLLECT_MEMO=1`, so the write collect memo seems to hide that CPU write from the snapshot reuse check. On RADV the case is skipped (`storage buffer offset alignment 4: misaligned draw snapshots not tested`), and on lavapipe too (`host imports are compared, not watched: draw snapshot reuse not tested`), so CI on llvmpipe would not see it. The linux job on this PR was skipped anyway. If the test is right, a draw can read stale bytes after a CPU write on a GPU with watched host imports, the GPU my Playroom numbers above were measured on.
SoRadGaming commented 2026-10-15 09:54:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SoRadGaming on 2026-10-15T09:54:22Z.


Windows / AMD results for this head (0eb0d8903), in the scene from the description: ASTRO BOT (PPSA21564 01.007.000), -lvl hub_crashsite.

Host: Windows 11 Pro 26200, Ryzen 7 5800X3D (8 cores, 16 threads, so 4 draw-ahead workers), Radeon RX 9070 XT (AMD proprietary driver 32.0.23033.1002), 32 GB, WinLibs GCC 15.2.0 r7, Release.

Builds.

  • C is main c0be1f69b, plus #6060 (head 290be5626, which keeps Windows imports of resident direct memory watched) and #6273.
  • D is C with this PR merged. The only conflict was the libSceAgcDriver source list in CMakeLists.txt, where both sides add a file.
  • Both use one relinked executable. D's libraries are its own build, because the GuestMemory.hpp change rebuilds the libraries that include it.

Method. No input, warm shader cache (1,904 hits, 0 misses), APS5_NO_SNAPSHOT_CHECK=1 APS5_RESOURCE_CACHE_ENTRIES=4096, no profiling switches. FPS is the window's present counter over 120 s, after a 120 s settle once Level has started: hub_crashsite is logged. Runs alternate.

hub FPS 10 s samples after the settle
C 3.17 / 3.20 3.1-3.3
D (this PR) 5.64 / 5.73 (+78 %) 4.8-5.9

So on this machine and scene the gain is larger than on your RX 9060 XT (+43 %) or JJenkx's RX 6650 XT (+54 %). Queue worker 0 is the limit in this scene. In traces of main ab9a47684 + #6060, it was 99 % busy, with the GPU busy about 150 of 330 ms per frame.

Frames. I took GPU frame dumps (APS5_DUMP_FRAMES, every 100th present) through the hub in both builds. Both show the same sequence: the arrival, the level banner's shape wipe, a clean CRASH SITE title card, then Astro idling. I saw no missing or stale geometry, textures or text in D.

No stops or errors in 4 launches with the PR.

One note for anyone combining this with #1201: they do not merge mechanically. Both restructure Driver::draw, and the queue-0 validation of entries compiled ahead reads guest memory where the pipeline's drain hooks don't look. I kept the two apart.

AI-assisted (Claude Code); the builds and runs are on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6189356122 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6189356122). Originally posted by [SoRadGaming](https://github.com/SoRadGaming) on 2026-10-15T09:54:22Z. --- Windows / AMD results for this head (`0eb0d8903`), in the scene from the description: ASTRO BOT (PPSA21564 01.007.000), `-lvl hub_crashsite`. Host: Windows 11 Pro 26200, Ryzen 7 5800X3D (8 cores, 16 threads, so 4 draw-ahead workers), Radeon RX 9070 XT (AMD proprietary driver 32.0.23033.1002), 32 GB, WinLibs GCC 15.2.0 r7, Release. **Builds.** - C is `main` c0be1f69b, plus #6060 (head 290be5626, which keeps Windows imports of resident direct memory watched) and #6273. - D is C with this PR merged. The only conflict was the `libSceAgcDriver` source list in `CMakeLists.txt`, where both sides add a file. - Both use one relinked executable. D's libraries are its own build, because the `GuestMemory.hpp` change rebuilds the libraries that include it. **Method.** No input, warm shader cache (1,904 hits, 0 misses), `APS5_NO_SNAPSHOT_CHECK=1 APS5_RESOURCE_CACHE_ENTRIES=4096`, no profiling switches. FPS is the window's present counter over 120 s, after a 120 s settle once `Level has started: hub_crashsite` is logged. Runs alternate. | | hub FPS | 10 s samples after the settle | |---|---|---| | C | 3.17 / 3.20 | 3.1-3.3 | | D (this PR) | **5.64 / 5.73** (+78 %) | 4.8-5.9 | So on this machine and scene the gain is larger than on your RX 9060 XT (+43 %) or JJenkx's RX 6650 XT (+54 %). Queue worker 0 is the limit in this scene. In traces of `main` ab9a47684 + #6060, it was 99 % busy, with the GPU busy about 150 of 330 ms per frame. **Frames.** I took GPU frame dumps (`APS5_DUMP_FRAMES`, every 100th present) through the hub in both builds. Both show the same sequence: the arrival, the level banner's shape wipe, a clean `CRASH SITE` title card, then Astro idling. I saw no missing or stale geometry, textures or text in D. No stops or errors in 4 launches with the PR. One note for anyone combining this with #1201: they do not merge mechanically. Both restructure `Driver::draw`, and the queue-0 validation of entries compiled ahead reads guest memory where the pipeline's drain hooks don't look. I kept the two apart. AI-assisted (Claude Code); the builds and runs are on my machine.
Amoenus commented 2026-10-15 13:22:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-15T13:22:40Z.


@mitul72 #6359 corrects the RunSecondStore wait that your range-list assertions extend. The old predicate can return while FindPending does not identify the expected live image (#6347).

Proposed order: merge #6359 first, then keep your assertions inside its stricter identity gate. I tested that fixture-only compositiona12910c4e: target rebuilt,5/5 fresh-process runs on RTX5080/610.62 and AMD Radeon Graphics/32.0.21036.18, Windows11 Enterprise26200, GCC15.2 Release, shader cache disabled, max0.591s. The four internal watch-transition omissions remain. This does not validate your full production stack.

Your published head and my submission are unchanged. The overlap and exact pins are now in #6359's description. AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6193107798 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6193107798). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-15T13:22:40Z. --- @mitul72 #6359 corrects the `RunSecondStore` wait that your range-list assertions extend. The old predicate can return while `FindPending` does not identify the expected live image (#6347). Proposed order: merge #6359 first, then keep your assertions inside its stricter identity gate. I tested [that fixture-only compositiona12910c4e](https://github.com/Amoenus/AnyPS5/commit/a12910c4ee340e0e51182fc8a506de7f387c39b8): target rebuilt,5/5 fresh-process runs on RTX5080/610.62 and AMD Radeon Graphics/32.0.21036.18, Windows11 Enterprise26200, GCC15.2 Release, shader cache disabled, max0.591s. The four internal watch-transition omissions remain. This does not validate your full production stack. Your published head and my submission are unchanged. The overlap and exact pins are now in #6359's description. AI-assisted: Codex. <!-- codex-6188-6359-overlap-v1 -->
mitul72 commented 2026-10-15 21:50:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mitul72 on 2026-10-15T21:50:46Z.


@fma-rc thanks, reproduced on RADV with APS5_WRITE_WATCH_IMPORTS=watch. It is a test-order problem, not stale bytes reaching a draw: the failing check takes main's own reuse path (8 KiB input), and the arena test before it left a collect epoch open, so the CPU store in the reuse test was not collected until a new epoch, which is main's documented rule for both paths. The arena test now runs last, and a new ctest (agc_draw_snapshots_watched_imports) runs the reuse test with watched imports so RADV covers it. Rebased onto 4eb91eacd; that rebase also fixed compile-ahead against main's lazy shader pages, and the description has fresh numbers on that main.

@SoRadGaming thanks for the Windows/RX 9070 XT run and the frame dumps.

@Amoenus our assertions now sit after the heldLive gate, so this PR and #6359 merge cleanly in either order.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6203018335 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6203018335). Originally posted by [mitul72](https://github.com/mitul72) on 2026-10-15T21:50:46Z. --- @fma-rc thanks, reproduced on RADV with `APS5_WRITE_WATCH_IMPORTS=watch`. It is a test-order problem, not stale bytes reaching a draw: the failing check takes main's own reuse path (8 KiB input), and the arena test before it left a collect epoch open, so the CPU store in the reuse test was not collected until a new epoch, which is main's documented rule for both paths. The arena test now runs last, and a new ctest (`agc_draw_snapshots_watched_imports`) runs the reuse test with watched imports so RADV covers it. Rebased onto 4eb91eacd; that rebase also fixed compile-ahead against main's lazy shader pages, and the description has fresh numbers on that main. @SoRadGaming thanks for the Windows/RX 9070 XT run and the frame dumps. @Amoenus our assertions now sit after the `heldLive` gate, so this PR and #6359 merge cleanly in either order.
fma-rc commented 2026-10-15 22:00:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T22:00:55Z.

Review: APPROVED


Rechecked a4a4e2201 on main 5d9dcc42d: agc_draw_snapshots and the new agc_draw_snapshots_watched_imports pass on an RTX 5080, on a Radeon 610M (RADV) and on lavapipe, so the NVIDIA failure from my earlier review is gone. Together with the Playroom numbers from before, that clears what I had against it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5540461318 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#pullrequestreview-5540461318). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-15T22:00:55Z. **Review:** APPROVED --- Rechecked a4a4e2201 on `main` 5d9dcc42d: `agc_draw_snapshots` and the new `agc_draw_snapshots_watched_imports` pass on an RTX 5080, on a Radeon 610M (RADV) and on lavapipe, so the NVIDIA failure from my earlier review is gone. Together with the Playroom numbers from before, that clears what I had against it.
SP4C3B4R-8 commented 2026-10-16 11:42:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-16T11:42:36Z.


@mitul72 a measurement on Windows with this PR's head (95ddd71bd, merged onto main 5d9dcc42d together with #6763 and #6764), Astro Bot (PPSA21564) -lvl hub_crashsite, RTX 5070 Ti / 7800X3D: thanks to the draw-ahead the frame is now limited by queue 0's committer, and PrepareDrawBindings takes 7.6 us of its ~34 us per draw, 6 us of it in the snapshot loop (about 7 snapshots per draw).

Of 1.1 M slice paths per 10 s, 154 k were epoch-memo hits, 208 k ReusableDrawSlice hits and 731 k fresh copies; the average slice is 251 bytes. Per slice: CollectWrites 0.31 us, ReusableDrawSlice 0.09, KeepDrawSlice 0.04, but the copy itself (AllocateSnapshot + memcpy) 0.07. So for small slices the collect and the generation memo cost more than copying again.

The change below copies a slice of up to 1 KiB directly (no collect, no generation memo), and still notes the epoch memo when the tracker generation is unchanged. With APS5_VERIFY_DRAW_SNAPSHOTS=1, 1.4 M fast slice answers were checked with 0 differing; the 16 snapshot/slice/draw-input/recorder ctests pass. record went 2030 -> 1666 ms per 10 s, and the scene 9.12-9.30 -> 9.42-9.53 fps (two 60 s windows each, no profiling). Since the arena is yours, feel free to take it into this PR if it fits:

diff --git a/core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp b/core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
index f93dc2bd5..952c622b0 100644
--- a/core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
+++ b/core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
@@ -29,6 +29,7 @@ class Buffer;
 class SnapshotArena {
 public:
     static constexpr std::size_t InputLimit = 4096;
+    static constexpr std::size_t CopiedSliceLimit = 1024;
     static constexpr std::size_t ChunkBytes = std::size_t{4} << 20u;
     struct Slice {
         std::shared_ptr<Buffer> chunk;
diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
index 91b787a9a..92b818151 100644
--- a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
+++ b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
@@ -4568,6 +4568,11 @@ std::shared_ptr<ShaderResources::DrawBindings> ShaderResources::PrepareDrawBindi
                     if (std::memcmp(slice.bytes.data(), reinterpret_cast<const void*>(begin), bytes) != 0) differing.fetch_add(1);
                     if (checked.fetch_add(1) % 200000 == 199999) std::fprintf(stderr, "[draw-snapshots] verify: %llu fast slice answers checked, %llu differing%c", static_cast<unsigned long long>(checked.load()), static_cast<unsigned long long>(differing.load()), 10);
                 }
+            } else if (bytes <= SnapshotArena::CopiedSliceLimit) {
+                slice = recorder.AllocateSnapshot(bytes);
+                std::memcpy(slice.bytes.data(), reinterpret_cast<const void*>(begin), bytes);
+                if (epochMemo && GuestMemory::TrackerGeneration() == stamp[0]) recorder.NoteUnwrittenDrawSlice(begin, stamp, slice);
+                else if (epochMemo) stamped = false;
             } else {
                 const auto generation = GuestMemory::CollectWrites(begin, bytes);
                 if (const auto* kept = recorder.ReusableDrawSlice(begin, bytes, registryGeneration)) {
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6214723584 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6214723584). Originally posted by [SP4C3B4R-8](https://github.com/SP4C3B4R-8) on 2026-10-16T11:42:36Z. --- @mitul72 a measurement on Windows with this PR's head (`95ddd71bd`, merged onto `main` 5d9dcc42d together with #6763 and #6764), Astro Bot (PPSA21564) `-lvl hub_crashsite`, RTX 5070 Ti / 7800X3D: thanks to the draw-ahead the frame is now limited by queue 0's committer, and `PrepareDrawBindings` takes 7.6 us of its ~34 us per draw, 6 us of it in the snapshot loop (about 7 snapshots per draw). Of 1.1 M slice paths per 10 s, 154 k were epoch-memo hits, 208 k `ReusableDrawSlice` hits and 731 k fresh copies; the average slice is 251 bytes. Per slice: `CollectWrites` 0.31 us, `ReusableDrawSlice` 0.09, `KeepDrawSlice` 0.04, but the copy itself (`AllocateSnapshot` + `memcpy`) 0.07. So for small slices the collect and the generation memo cost more than copying again. The change below copies a slice of up to 1 KiB directly (no collect, no generation memo), and still notes the epoch memo when the tracker generation is unchanged. With `APS5_VERIFY_DRAW_SNAPSHOTS=1`, 1.4 M fast slice answers were checked with 0 differing; the 16 snapshot/slice/draw-input/recorder ctests pass. `record` went 2030 -> 1666 ms per 10 s, and the scene 9.12-9.30 -> 9.42-9.53 fps (two 60 s windows each, no profiling). Since the arena is yours, feel free to take it into this PR if it fits: ```diff diff --git a/core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp b/core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp index f93dc2bd5..952c622b0 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp @@ -29,6 +29,7 @@ class Buffer; class SnapshotArena { public: static constexpr std::size_t InputLimit = 4096; + static constexpr std::size_t CopiedSliceLimit = 1024; static constexpr std::size_t ChunkBytes = std::size_t{4} << 20u; struct Slice { std::shared_ptr<Buffer> chunk; diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp index 91b787a9a..92b818151 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp @@ -4568,6 +4568,11 @@ std::shared_ptr<ShaderResources::DrawBindings> ShaderResources::PrepareDrawBindi if (std::memcmp(slice.bytes.data(), reinterpret_cast<const void*>(begin), bytes) != 0) differing.fetch_add(1); if (checked.fetch_add(1) % 200000 == 199999) std::fprintf(stderr, "[draw-snapshots] verify: %llu fast slice answers checked, %llu differing%c", static_cast<unsigned long long>(checked.load()), static_cast<unsigned long long>(differing.load()), 10); } + } else if (bytes <= SnapshotArena::CopiedSliceLimit) { + slice = recorder.AllocateSnapshot(bytes); + std::memcpy(slice.bytes.data(), reinterpret_cast<const void*>(begin), bytes); + if (epochMemo && GuestMemory::TrackerGeneration() == stamp[0]) recorder.NoteUnwrittenDrawSlice(begin, stamp, slice); + else if (epochMemo) stamped = false; } else { const auto generation = GuestMemory::CollectWrites(begin, bytes); if (const auto* kept = recorder.ReusableDrawSlice(begin, bytes, registryGeneration)) { ```
Scramblrrrr commented 2026-10-18 09:06:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-18T09:06:52Z.


A 007 First Light cross-test lead on Windows: our current integration 8bdc43094f996d1334776dac7dc71ca2092915f7 (base main e5c2b3c325, #6454 a508aa03c + required public boot/resource fixes) reaches the correctly rendered offline menu. Before #6763, six fully contained periodic trace intervals gave 114 presents / 61.21878 s = 1.86217 FPS at 3840x2160. GPU busy averaged 176.97 ms/present. Shader.DrawStage was about 177–192 ms/frame and Driver.Draw.shader_compile_and_link about 257–310 ms/frame in the nearby menu intervals. Those phases are nested, not additive. No isolated PR speed claim.

I am finishing an imported/copied-input A/B first. Your 95ddd71bd8 is a promising next CPU experiment; a read-only merge preview against this stack has 11 conflicts, chiefly the current draw/cache/capture interfaces, lifecycle, VulkanDevice, ShaderResources and Recorder/CMake. I have not forced a partial port or tested it on 007. If you have a newer current-main/shared-table integration, please point me at it; otherwise I can resolve the integration after this A/B while retaining your ownership of the change. The exact current stack is on Scramblrrrr/AnyPS5 branch codex/first-light-oct18-current. Raw title data stays local. AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6248033385 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6248033385). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-18T09:06:52Z. --- A 007 First Light cross-test lead on Windows: our current integration 8bdc43094f996d1334776dac7dc71ca2092915f7 (base main e5c2b3c325, #6454 a508aa03c + required public boot/resource fixes) reaches the correctly rendered offline menu. Before #6763, six fully contained periodic trace intervals gave 114 presents / 61.21878 s = 1.86217 FPS at 3840x2160. GPU busy averaged 176.97 ms/present. `Shader.DrawStage` was about 177–192 ms/frame and `Driver.Draw.shader_compile_and_link` about 257–310 ms/frame in the nearby menu intervals. Those phases are nested, not additive. No isolated PR speed claim. I am finishing an imported/copied-input A/B first. Your 95ddd71bd8 is a promising next CPU experiment; a read-only merge preview against this stack has 11 conflicts, chiefly the current draw/cache/capture interfaces, lifecycle, VulkanDevice, ShaderResources and Recorder/CMake. I have not forced a partial port or tested it on 007. If you have a newer current-main/shared-table integration, please point me at it; otherwise I can resolve the integration after this A/B while retaining your ownership of the change. The exact current stack is on Scramblrrrr/AnyPS5 branch codex/first-light-oct18-current. Raw title data stays local. AI-assisted: Codex.
Scramblrrrr commented 2026-10-18 11:08:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-18T11:08:55Z.


WIP integration for your review/cross-test: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-drawahead-oct18 at c774f5f742e8c89d100c8189251baca82d0227fe, merging exact95ddd71bd8 onto our ad3586f18 007 stack. Source conventions pass and tree is clean/pushed, but it is still BUILDING and UNTESTED/UNSTAGED; no title or speed result.

The eleven conflict files are resolved retaining both topics: queue-0 relocation learning and aliases stay; the published plain register key is used only when aliasFirst is false. The new shapeHasOtherEntry probation rule stays in admission alongside existing relocation sightings. insertDrawEntry uses your resolved/present accounting and SameCapturedWords for shared columns. DrawStageVariant now calls Driver::tagVariantRuns rather than flattening the captures; both ordinary and ahead capture populate userDataUse/supplied blocks, retaining the shared-word references and relocation partitions (#6454 + sparse tagging #7508). Capture verification retains our existing relocation-aware content/forwarded-word comparison. Shutdown resets drawAhead before stopping Queue0. New prepared draw/context and arena paths retained, plus main's journal replay start and movedOnly argument. Both sets of tests stay, including copied inputs, pipelined dispatch, table snapshots and the arena.

Please flag any semantic concern in that combination. I have not taken SP4C3B4R-8's additional small-slice proposal; this is your published head's behavior. Preparing focused DrawAhead/Raw/Scan, probation/verify, snapshots, cache/relocation/shared-table, indirect and lifecycle checks before a title run. Runtime remains the tested ad358 modules and no game process is active while building. The current 007 level fault is #6172's streaming class; no claim this PR fixes it. Raw title data stays local. AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249142592 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6249142592). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-18T11:08:55Z. --- WIP integration for your review/cross-test: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-drawahead-oct18 at c774f5f742e8c89d100c8189251baca82d0227fe, merging exact95ddd71bd8 onto our ad3586f18 007 stack. Source conventions pass and tree is clean/pushed, but it is still BUILDING and UNTESTED/UNSTAGED; no title or speed result. The eleven conflict files are resolved retaining both topics: queue-0 relocation learning and aliases stay; the published plain register key is used only when aliasFirst is false. The new shapeHasOtherEntry probation rule stays in admission alongside existing relocation sightings. insertDrawEntry uses your resolved/present accounting and SameCapturedWords for shared columns. DrawStageVariant now calls Driver::tagVariantRuns rather than flattening the captures; both ordinary and ahead capture populate userDataUse/supplied blocks, retaining the shared-word references and relocation partitions (#6454 + sparse tagging #7508). Capture verification retains our existing relocation-aware content/forwarded-word comparison. Shutdown resets drawAhead before stopping Queue0. New prepared draw/context and arena paths retained, plus main's journal replay start and movedOnly argument. Both sets of tests stay, including copied inputs, pipelined dispatch, table snapshots and the arena. Please flag any semantic concern in that combination. I have not taken SP4C3B4R-8's additional small-slice proposal; this is your published head's behavior. Preparing focused DrawAhead/Raw/Scan, probation/verify, snapshots, cache/relocation/shared-table, indirect and lifecycle checks before a title run. Runtime remains the tested ad358 modules and no game process is active while building. The current 007 level fault is #6172's streaming class; no claim this PR fixes it. Raw title data stays local. AI-assisted: Codex.
Scramblrrrr commented 2026-10-18 11:14:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-18T11:14:09Z.


WIP c774f5f742e8c89d100c8189251baca82d0227fe now builds on Windows11Pro26200 / WinLibsGCC15.2 / RTX5070Ti617.42. 85/85 selected controls PASS39.66s, zero skips, ANYPS5_REQUIRE_VULKAN=1. Includes all five DrawAhead/Raw/Scan/verify/small-cache modes, four snapshot modes (including watched imports and no collect memo), shared table/image-table/shader-memory checks, draw-cache relocation/mesh relocation, sparse indirect indices, the new #7476 texel regression and the driver shutdown/wait/preparation/committer/helper/cache-writer cases. The full source-built native test executables were rebuilt against this candidate. Conventions pass, source remains clean/pushed.

Matched patched AgcDriver/Agc/VideoOut modules are now staged in the separate Oct18 runtime; previous tested modules are backed up. Starting 007 with your default draw-ahead behavior, drawcache1024, imported inputs, resourcecache16 and unchanged RAM guards. APS5_SYNC_DRAWS and spanned mode are off. No title/FPS claim yet; the recompiler header change selects a new shader-cache source version, so cold preparation will be excluded from any later menu comparison. No builds/native tests while the title runs. AI-assisted: Codex; raw title data stays local.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249210805 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6249210805). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-18T11:14:09Z. --- WIP c774f5f742e8c89d100c8189251baca82d0227fe now builds on Windows11Pro26200 / WinLibsGCC15.2 / RTX5070Ti617.42. 85/85 selected controls PASS39.66s, zero skips, ANYPS5_REQUIRE_VULKAN=1. Includes all five DrawAhead/Raw/Scan/verify/small-cache modes, four snapshot modes (including watched imports and no collect memo), shared table/image-table/shader-memory checks, draw-cache relocation/mesh relocation, sparse indirect indices, the new #7476 texel regression and the driver shutdown/wait/preparation/committer/helper/cache-writer cases. The full source-built native test executables were rebuilt against this candidate. Conventions pass, source remains clean/pushed. Matched patched AgcDriver/Agc/VideoOut modules are now staged in the separate Oct18 runtime; previous tested modules are backed up. Starting 007 with your default draw-ahead behavior, drawcache1024, imported inputs, resourcecache16 and unchanged RAM guards. APS5_SYNC_DRAWS and spanned mode are off. No title/FPS claim yet; the recompiler header change selects a new shader-cache source version, so cold preparation will be excluded from any later menu comparison. No builds/native tests while the title runs. AI-assisted: Codex; raw title data stays local.
Scramblrrrr commented 2026-10-18 11:27:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-18T11:27:39Z.


Pausing after the current milestone at the user's request. Integration c774f5f742e8c89d100c8189251baca82d0227fe renders the title/offline menu correctly, but shows no FPS gain in this 007 scene. Six fully contained no-input intervals:105presents/61.648018s=1.70322FPS, GPU busy177.406ms/present. Preceding 8e0bd2cc6 menu:121/61.639091s=1.96304FPS, GPU177.998ms/present. This is one moving-menu sample per arm on the public integration stack, not an isolated main comparison or repeated same-binary A/B; the candidate includes my merge adaptations. Startup/cold compilation excluded.

Draw-ahead is actually active: recent10s windows published8.4k–8.8k records, the queue used8.4k–8.8k, and6.3k–6.5k entries compiled ahead. Cache hits were6.9k–7.1k of~8.4k–8.8klookups, but this does not translate into a faster frame here. A bounded350-PC sample AFTER the measurement found40in the driver/267in ntdll;13driver samples were in ResolveImageTables' fill loop. This is a wall-PC sample, not exact CPU attribution or proof of contention. GPU time is similar; next work should distinguish worker overhead and resolution reuse, rather than call the cache-hit rate a speed result.

85/85nativecontrolsPASS39.66s, zero skips as above. Owned stop11:26:41.146UTC, exit-1record11:26:41.294UTC, not a crash/guard. Peak sampled private24.67GiB/minfree3.96GiB, one bounded trim. Resume/gameplay NOT attempted on this candidate; #6172 remains unresolved. Same budgets/settings otherwise, no title/time patch. Source clean/pushed; old tested source/modules retained. Raw title data stays local. AI-assisted: Codex.

Official trace_digest outputs follow; raw traces remain local.

Baseline8e0bd2cc6:

6 intervals, 257.4 to 319.1 s, 121 presents
NVIDIA GeForce RTX 5070 Ti, NVIDIA 617.42, Windows 10.0.26200, 3840x2160, commit 8e0bd2cc640e

# seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
1 257-268 21 504.9 527.5 558.6 558.6 176.2 100 % Driver.Packet 2446.6
2 268-278 20 501.6 559.0 559.5 559.5 181.7 100 % Driver.Packet 2507.2
3 278-288 20 522.1 555.2 641.1 641.1 175.5 100 % Driver.Packet 2557.1
4 288-298 20 519.2 565.3 600.3 600.3 176.7 101 % Driver.Packet 2583.5
5 298-309 20 512.6 645.3 702.6 702.6 181.4 100 % Driver.Packet 2550.3
6 309-319 20 522.5 555.1 557.5 557.5 176.6 100 % Driver.Packet 2564.8
p99 ms  ##%%@#  0-702.6
gpu ms  @@@@@@  0-181.7

Candidatec774f5f74:

6 intervals, 307.7 to 369.4 s, 105 presents
NVIDIA GeForce RTX 5070 Ti, NVIDIA 617.42, Windows 10.0.26200, 3840x2160, commit c774f5f742e8

# seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
1 308-318 17 603.6 646.8 656.6 656.6 181.6 100 % Driver.Packet 3010.7
2 318-328 17 595.2 616.6 662.7 662.7 168.7 100 % Driver.Packet 2954.8
3 328-338 17 591.1 620.4 644.0 644.0 181.2 100 % Driver.Packet 2963.8
4 338-349 18 582.1 598.4 637.0 637.0 173.7 101 % Driver.Packet 2874.2
5 349-359 18 588.8 626.8 648.7 648.7 175.9 100 % Driver.Packet 2893.1
6 359-369 18 589.1 613.6 617.8 617.8 183.3 100 % Driver.Packet 2879.4
p99 ms  @@@@@%  0-662.7
gpu ms  @%@@@@  0-183.3
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249364384 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6249364384). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-18T11:27:39Z. --- Pausing after the current milestone at the user's request. Integration c774f5f742e8c89d100c8189251baca82d0227fe renders the title/offline menu correctly, but shows no FPS gain in this 007 scene. Six fully contained no-input intervals:105presents/61.648018s=1.70322FPS, GPU busy177.406ms/present. Preceding 8e0bd2cc6 menu:121/61.639091s=1.96304FPS, GPU177.998ms/present. This is one moving-menu sample per arm on the public integration stack, not an isolated main comparison or repeated same-binary A/B; the candidate includes my merge adaptations. Startup/cold compilation excluded. Draw-ahead is actually active: recent10s windows published~8.4k–8.8k records, the queue used~8.4k–8.8k, and~6.3k–6.5k entries compiled ahead. Cache hits were~6.9k–7.1k of~8.4k–8.8klookups, but this does not translate into a faster frame here. A bounded350-PC sample AFTER the measurement found40in the driver/267in ntdll;13driver samples were in ResolveImageTables' fill loop. This is a wall-PC sample, not exact CPU attribution or proof of contention. GPU time is similar; next work should distinguish worker overhead and resolution reuse, rather than call the cache-hit rate a speed result. 85/85nativecontrolsPASS39.66s, zero skips as above. Owned stop11:26:41.146UTC, exit-1record11:26:41.294UTC, not a crash/guard. Peak sampled private24.67GiB/minfree3.96GiB, one bounded trim. Resume/gameplay NOT attempted on this candidate; #6172 remains unresolved. Same budgets/settings otherwise, no title/time patch. Source clean/pushed; old tested source/modules retained. Raw title data stays local. AI-assisted: Codex. Official trace_digest outputs follow; raw traces remain local. Baseline8e0bd2cc6: **6 intervals**, 257.4 to 319.1 s, 121 presents NVIDIA GeForce RTX 5070 Ti, NVIDIA 617.42, Windows 10.0.26200, 3840x2160, commit 8e0bd2cc640e | # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase | |---|---|---|---|---|---|---|---|---|---| | 1 | 257-268 | 21 | 504.9 | 527.5 | 558.6 | 558.6 | 176.2 | 100 % | Driver.Packet 2446.6 | | 2 | 268-278 | 20 | 501.6 | 559.0 | 559.5 | 559.5 | 181.7 | 100 % | Driver.Packet 2507.2 | | 3 | 278-288 | 20 | 522.1 | 555.2 | 641.1 | 641.1 | 175.5 | 100 % | Driver.Packet 2557.1 | | 4 | 288-298 | 20 | 519.2 | 565.3 | 600.3 | 600.3 | 176.7 | 101 % | Driver.Packet 2583.5 | | 5 | 298-309 | 20 | 512.6 | 645.3 | 702.6 | 702.6 | 181.4 | 100 % | Driver.Packet 2550.3 | | 6 | 309-319 | 20 | 522.5 | 555.1 | 557.5 | 557.5 | 176.6 | 100 % | Driver.Packet 2564.8 | ``` p99 ms ##%%@# 0-702.6 gpu ms @@@@@@ 0-181.7 ``` Candidatec774f5f74: **6 intervals**, 307.7 to 369.4 s, 105 presents NVIDIA GeForce RTX 5070 Ti, NVIDIA 617.42, Windows 10.0.26200, 3840x2160, commit c774f5f742e8 | # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase | |---|---|---|---|---|---|---|---|---|---| | 1 | 308-318 | 17 | 603.6 | 646.8 | 656.6 | 656.6 | 181.6 | 100 % | Driver.Packet 3010.7 | | 2 | 318-328 | 17 | 595.2 | 616.6 | 662.7 | 662.7 | 168.7 | 100 % | Driver.Packet 2954.8 | | 3 | 328-338 | 17 | 591.1 | 620.4 | 644.0 | 644.0 | 181.2 | 100 % | Driver.Packet 2963.8 | | 4 | 338-349 | 18 | 582.1 | 598.4 | 637.0 | 637.0 | 173.7 | 101 % | Driver.Packet 2874.2 | | 5 | 349-359 | 18 | 588.8 | 626.8 | 648.7 | 648.7 | 175.9 | 100 % | Driver.Packet 2893.1 | | 6 | 359-369 | 18 | 589.1 | 613.6 | 617.8 | 617.8 | 183.3 | 100 % | Driver.Packet 2879.4 | ``` p99 ms @@@@@% 0-662.7 gpu ms @%@@@@ 0-183.3 ```
adriadam10 commented 2026-10-18 17:03:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-18T17:03:49Z.

Review: CHANGES_REQUESTED


This PR now conflicts with main in ten files, and the conflicts are in logic, not adjacency:

  • core/libs/prx/libSceAgcDriver/CMakeLists.txt
  • Execution/include/Driver/Driver.hpp, Execution/include/VulkanDevice.hpp, Execution/src/VulkanDevice.cpp
  • Execution/src/Driver/Draw/Draw.cpp, DrawCache.cpp, DrawCapture.cpp, Execution/src/Driver/Lifecycle.cpp
  • Graphics/src/ShaderResources.cpp
  • tests/Recorder.cpp

The change adds worker threads, speculative guest reads and a probation list in the draw cache, so a rebase done by someone else would be guesswork. Please rebase onto current main, then rerun the DrawAhead* and agc_draw_snapshots* tests and the Astro Bot comparison on the new base, since the draw cache changed under you. The full Build will run on the rebased head when it is queued.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5563981398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#pullrequestreview-5563981398). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-18T17:03:49Z. **Review:** CHANGES_REQUESTED --- This PR now conflicts with `main` in ten files, and the conflicts are in logic, not adjacency: - `core/libs/prx/libSceAgcDriver/CMakeLists.txt` - `Execution/include/Driver/Driver.hpp`, `Execution/include/VulkanDevice.hpp`, `Execution/src/VulkanDevice.cpp` - `Execution/src/Driver/Draw/Draw.cpp`, `DrawCache.cpp`, `DrawCapture.cpp`, `Execution/src/Driver/Lifecycle.cpp` - `Graphics/src/ShaderResources.cpp` - `tests/Recorder.cpp` The change adds worker threads, speculative guest reads and a probation list in the draw cache, so a rebase done by someone else would be guesswork. Please rebase onto current `main`, then rerun the `DrawAhead*` and `agc_draw_snapshots*` tests and the Astro Bot comparison on the new base, since the draw cache changed under you. The full Build will run on the rebased head when it is queued.
SoRadGaming commented 2026-10-19 03:10:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SoRadGaming on 2026-10-19T03:10:31Z.


Draw keys in ASTRO BOT change every frame, so draw-ahead compiles every draw every frame

Measured on main a62c724c3 with this PR at 95ddd71bd (plus #6273 #6266 #6505 #6503 #6617 #6609 #6566 #6292 #6615 and some local experiments, all switched off for these counters), ASTRO BOT (PPSA21564) Crash Site hub, Windows 11, Ryzen 7 5800X3D, RX 9070 XT, Adrenalin 26.8.1. Counters per 10 s of the hub (~83 frames, ~3,000 draws per frame):

  • [draw-ahead]: 182,092 draw records published, 181,043 used by the queue, 172,175 entries compiled ahead, 1,049 jobs dropped. That is every draw, every frame.
  • [draw-cache]: 181,315 lookups, 178,186 hits, 174,192 inserts, 8,192 entries, about 150k evictions per 10 s. With APS5_DRAW_CACHE_ENTRIES=32768 the cache fills to 46,072 entries at the same insert rate, so this is not a capacity problem.
  • APS5_TRACE_DRAW_CACHE=1: of the register-key misses, 161-173k per 10 s changed in user data, ~12k in stable registers, ~2.5k in auxiliary registers, 0 in the device and ~0 in the shader set. The user SGPR words (per-frame ring-buffer pointers, by the look of it) are mixed into the exact key raw, so a draw's key is new each frame.
  • As a result nothing keyed by the draw key or by its variants' identity is reused across frames: with draw recipes built for these draws (a local experiment that also builds them for moved read-only buffers), ~175k recipes per 10 s are attached and ~176k findDrawRecipe calls find the entry without records, because the entry is the one compiled ahead for this frame's key. Prepared draws are in the same position.
  • The hub still runs fine and the ahead compiles stay on the worker threads (queue 0 sees hits), so the cost is the compile-ahead work itself and the per-frame cache churn rather than queue-0 stalls.

Main's draw relocation (#4943) is meant for moving user words, but in this run it never reported ([draw-relocate] only prints after 100,000 alias lookups with relocated patches, so its absence does not say why). It learns in the queue-0 miss branch, which draw-ahead makes rare; with draw-ahead disabled locally it still did not engage, so there is more to it than that.

A key that leaves out user words whose content the stage variants already validate (or an alias like #4943's that draw-ahead also consults) would let the cache, recipes and prepared draws survive across frames for titles like this one. Happy to run any counters or a branch on this title.

Written with AI assistance (Claude); measured on the machine above.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6258809482 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6258809482). Originally posted by [SoRadGaming](https://github.com/SoRadGaming) on 2026-10-19T03:10:31Z. --- ### Draw keys in ASTRO BOT change every frame, so draw-ahead compiles every draw every frame Measured on main a62c724c3 with this PR at 95ddd71bd (plus #6273 #6266 #6505 #6503 #6617 #6609 #6566 #6292 #6615 and some local experiments, all switched off for these counters), ASTRO BOT (PPSA21564) Crash Site hub, Windows 11, Ryzen 7 5800X3D, RX 9070 XT, Adrenalin 26.8.1. Counters per 10 s of the hub (~83 frames, ~3,000 draws per frame): - `[draw-ahead]`: 182,092 draw records published, 181,043 used by the queue, **172,175 entries compiled ahead**, 1,049 jobs dropped. That is every draw, every frame. - `[draw-cache]`: 181,315 lookups, 178,186 hits, **174,192 inserts**, 8,192 entries, about 150k evictions per 10 s. With `APS5_DRAW_CACHE_ENTRIES=32768` the cache fills to 46,072 entries at the same insert rate, so this is not a capacity problem. - `APS5_TRACE_DRAW_CACHE=1`: of the register-key misses, 161-173k per 10 s changed in **user data**, ~12k in stable registers, ~2.5k in auxiliary registers, 0 in the device and ~0 in the shader set. The user SGPR words (per-frame ring-buffer pointers, by the look of it) are mixed into the exact key raw, so a draw's key is new each frame. - As a result nothing keyed by the draw key or by its variants' identity is reused across frames: with draw recipes built for these draws (a local experiment that also builds them for moved read-only buffers), ~175k recipes per 10 s are attached and ~176k `findDrawRecipe` calls find the entry without records, because the entry is the one compiled ahead for this frame's key. Prepared draws are in the same position. - The hub still runs fine and the ahead compiles stay on the worker threads (queue 0 sees hits), so the cost is the compile-ahead work itself and the per-frame cache churn rather than queue-0 stalls. Main's draw relocation (#4943) is meant for moving user words, but in this run it never reported (`[draw-relocate]` only prints after 100,000 alias lookups with relocated patches, so its absence does not say why). It learns in the queue-0 miss branch, which draw-ahead makes rare; with draw-ahead disabled locally it still did not engage, so there is more to it than that. A key that leaves out user words whose content the stage variants already validate (or an alias like #4943's that draw-ahead also consults) would let the cache, recipes and prepared draws survive across frames for titles like this one. Happy to run any counters or a branch on this title. Written with AI assistance (Claude); measured on the machine above.
mitul72 commented 2026-10-20 18:02:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mitul72 on 2026-10-20T18:02:16Z.


Thanks everyone for the measurements and cross-tests, and @adriadam10 for the review. I've been a little busy lately, but I'll work on this today: rebase onto current main, resolve the conflicts you listed, and go through the comments.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6297649448 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6297649448). Originally posted by [mitul72](https://github.com/mitul72) on 2026-10-20T18:02:16Z. --- Thanks everyone for the measurements and cross-tests, and @adriadam10 for the review. I've been a little busy lately, but I'll work on this today: rebase onto current `main`, resolve the conflicts you listed, and go through the comments.
github-actions[bot] commented 2026-10-21 01:23:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T01:23:21Z.


This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6305674694 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6305674694). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T01:23:21Z. --- <!-- pr-labels-perf --> This pull request is labeled `perf`, so it needs the summary line of a capture on `main` and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both `aps5-summary.jsonl` lines, attach the two traces and add the output of `tools/trace_digest.py`.
mitul72 commented 2026-10-21 01:23:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mitul72 on 2026-10-21T01:23:23Z.


@adriadam10 Rebased onto main d97361bd0 and went through the conflicts myself. Notes on the result:

  • Dropped the snapshot arena commit. Main's per-recorder upload chunk (3518eb8de) now does the same job, so SnapshotArena and its agc_draw_snapshots* tests are gone.
  • Ahead path follows main's queue 0. Capture goes through CaptureInvocation/tagVariantRuns. Depth remap and user-data masks are handled. Lists with invalid indirect registers stop the scan. Under speculation, the table memo returns no stamp, so workers fall back to comparing.
  • Admission is main's rule again. Entries compiled ahead are held outside the draw cache and only inserted when admitDrawKey admits the key. The old probation list is gone. Inserts went from ~237k to ~4k per 10 s on Astro Bot, which matches main.
  • Correctness fixes from stress testing and review:
    • Draw-ahead retires before the submission's completion can be signalled. This fixes a race on pipelined queue 0.
    • Speculative range checks take the lifetime pin before verify() can copy guest bytes.
    • Each REWIND segment has its own speculation id, so continuations are compiled ahead too.
    • Threads start only for submissions that contain draws.

Tests: the DrawAhead* tests pass 30 repeats under -j8. Of the agc tests, 836/839 pass. The three failures (guest_memory_lifetime, image_array_window_past_layer_limit, tessellation) fail the same way on plain main here (RX 9060 XT, RADV).

Astro Bot hub, one run each:

fps µs/draw capture + recompile
main d97361bd0 11.77 23.8 12.8
this PR 11.77 19.9 0.4

The CPU saving per draw holds, but there's no fps change: on current main this scene is GPU-bound (GPU busy ~66 ms of an ~85 ms frame). @SoRadGaming's per-frame keys are real. The user SGPRs carry buffer and texture descriptors whose contents change every frame, so relocation can't match them, and fixing that needs recompiler analysis of which descriptor fields only affect bindings. That would be a separate PR. Up to you whether the CPU saving alone is worth the complexity.

Thanks @SP4C3B4R-8 for the small-slice patch. The arena it touched is gone after the rebase, so it would need porting to main's upload chunk as a separate change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6305675302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#issuecomment-6305675302). Originally posted by [mitul72](https://github.com/mitul72) on 2026-10-21T01:23:23Z. --- @adriadam10 Rebased onto `main` d97361bd0 and went through the conflicts myself. Notes on the result: - **Dropped the snapshot arena commit.** Main's per-recorder upload chunk (3518eb8de) now does the same job, so `SnapshotArena` and its `agc_draw_snapshots*` tests are gone. - **Ahead path follows main's queue 0.** Capture goes through `CaptureInvocation`/`tagVariantRuns`. Depth remap and user-data masks are handled. Lists with invalid indirect registers stop the scan. Under speculation, the table memo returns no stamp, so workers fall back to comparing. - **Admission is main's rule again.** Entries compiled ahead are held outside the draw cache and only inserted when `admitDrawKey` admits the key. The old probation list is gone. Inserts went from ~237k to ~4k per 10 s on Astro Bot, which matches `main`. - **Correctness fixes from stress testing and review:** - Draw-ahead retires before the submission's completion can be signalled. This fixes a race on pipelined queue 0. - Speculative range checks take the lifetime pin before `verify()` can copy guest bytes. - Each REWIND segment has its own speculation id, so continuations are compiled ahead too. - Threads start only for submissions that contain draws. Tests: the `DrawAhead*` tests pass 30 repeats under `-j8`. Of the `agc` tests, 836/839 pass. The three failures (`guest_memory_lifetime`, `image_array_window_past_layer_limit`, `tessellation`) fail the same way on plain `main` here (RX 9060 XT, RADV). Astro Bot hub, one run each: | | fps | µs/draw | capture + recompile | |---|---|---|---| | `main` d97361bd0 | 11.77 | 23.8 | 12.8 | | this PR | 11.77 | 19.9 | 0.4 | The CPU saving per draw holds, but there's no fps change: on current `main` this scene is GPU-bound (GPU busy ~66 ms of an ~85 ms frame). @SoRadGaming's per-frame keys are real. The user SGPRs carry buffer and texture descriptors whose contents change every frame, so relocation can't match them, and fixing that needs recompiler analysis of which descriptor fields only affect bindings. That would be a separate PR. Up to you whether the CPU saving alone is worth the complexity. Thanks @SP4C3B4R-8 for the small-slice patch. The arena it touched is gone after the rebase, so it would need porting to main's upload chunk as a separate change.
adriadam10 commented 2026-10-23 13:19:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T13:19:38Z.

Review: CHANGES_REQUESTED


Thanks for the rebase and for dropping the arena and the probation list. main has moved again and the PR conflicts with it in logic, not adjacency (git merge-tree against current main):

  • Execution/include/Driver/Draw/DrawCache.hpp, DrawPipeline.hpp, Execution/include/Driver/Driver.hpp
  • Execution/src/Driver/Draw/Draw.cpp, DrawCache.cpp, DrawCapture.cpp, DrawPipeline.cpp, DrawPrecheck.cpp, Execution/src/Driver/Lifecycle.cpp
  • Graphics/src/Draw.cpp, Texture.cpp, UnitShadow.cpp

With worker threads and speculative guest reads involved, please resolve these yourself and rerun the DrawAhead* tests on the new base.

Two more points before this can merge:

  • The PR carries the perf label, and the numbers so far are one run in a table. Please paste the aps5-summary.jsonl lines of main and of the change from the same title, scene and machine, and the tools/trace_digest.py output, as the label bot asks.
  • You report no fps change (GPU-bound scene) and 23.8 → 19.9 µs/draw. Please show a scene or setting where the frame is CPU-bound and the saving shows up in frame time; otherwise ~3000 lines of threaded code buy a number nobody sees. If the cost per draw is the claim, give several runs (median), not one.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5628792042 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#pullrequestreview-5628792042). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-23T13:19:38Z. **Review:** CHANGES_REQUESTED --- Thanks for the rebase and for dropping the arena and the probation list. `main` has moved again and the PR conflicts with it in logic, not adjacency (`git merge-tree` against current `main`): - `Execution/include/Driver/Draw/DrawCache.hpp`, `DrawPipeline.hpp`, `Execution/include/Driver/Driver.hpp` - `Execution/src/Driver/Draw/Draw.cpp`, `DrawCache.cpp`, `DrawCapture.cpp`, `DrawPipeline.cpp`, `DrawPrecheck.cpp`, `Execution/src/Driver/Lifecycle.cpp` - `Graphics/src/Draw.cpp`, `Texture.cpp`, `UnitShadow.cpp` With worker threads and speculative guest reads involved, please resolve these yourself and rerun the `DrawAhead*` tests on the new base. Two more points before this can merge: - The PR carries the `perf` label, and the numbers so far are one run in a table. Please paste the `aps5-summary.jsonl` lines of `main` and of the change from the same title, scene and machine, and the `tools/trace_digest.py` output, as the label bot asks. - You report no fps change (GPU-bound scene) and 23.8 → 19.9 µs/draw. Please show a scene or setting where the frame is CPU-bound and the saving shows up in frame time; otherwise ~3000 lines of threaded code buy a number nobody sees. If the cost per draw is the claim, give several runs (median), not one.
MarcZX10 commented 2026-11-23 02:58:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:58:37Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected draw-ahead paths show no verified blocking defect, but the review is incomplete because not all changed files were read and no checks were run.

What I ran

Reviewed head aa699de9126da33d654d20c27553138549269546 using the prepared diff and pinned repository reader. No build or tests were run.

Results

Check Result Note
Diff and targeted code review passed Inspected draw scan, speculation, cache, memory, and prepared draw paths
Build and tests not run No commands run

Findings

Blocking

None verified in the code inspected.

Non-blocking

None.

Not verified

The review folder listed 36 changed files. I read the description, commits, manifest, and portions of the diff, and inspected targeted code around draw scanning, speculative reads, cache admission, and prepared draw state. I did not read every changed file or every changed hunk. core/libs/prx/libSceAgcDriver/tests/Recorder.cpp was excluded from the review folder; I did not inspect it through the reader. Build and test results reported in the PR description were not independently verified.

To get this to a good state

Nothing is required. Optional: complete review of the remaining changed code and run the relevant build and tests before making a formal approval decision.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6016082493 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6188#pullrequestreview-6016082493). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T02:58:37Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected draw-ahead paths show no verified blocking defect, but the review is incomplete because not all changed files were read and no checks were run. ## What I ran Reviewed head `aa699de9126da33d654d20c27553138549269546` using the prepared diff and pinned repository reader. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted code review | passed | Inspected draw scan, speculation, cache, memory, and prepared draw paths | | Build and tests | not run | No commands run | ## Findings ### Blocking None verified in the code inspected. ### Non-blocking None. ## Not verified The review folder listed 36 changed files. I read the description, commits, manifest, and portions of the diff, and inspected targeted code around draw scanning, speculative reads, cache admission, and prepared draw state. I did not read every changed file or every changed hunk. `core/libs/prx/libSceAgcDriver/tests/Recorder.cpp` was excluded from the review folder; I did not inspect it through the reader. Build and test results reported in the PR description were not independently verified. ## To get this to a good state Nothing is required. Optional: complete review of the remaining changed code and run the relevant build and tests before making a formal approval decision.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/6188:upstream-pr/6188'
git switch 'upstream-pr/6188'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/6188'
git switch 'upstream-pr/6188'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/6188'
git switch 'upstream-pr/6188'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/6188'
git switch 'main'
git merge --squash 'upstream-pr/6188'
git switch 'main'
git merge --ff-only 'upstream-pr/6188'
git switch 'main'
git merge 'upstream-pr/6188'
git push origin 'main'
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!6188
No description provided.