perf(agc): resolve a resident depth surface's view without rebuilding its geometry #17007

Merged
chitters2004 merged 1 commit from upstream-pr/17007 into main 2026-11-08 18:08:12 +00:00
chitters2004 commented 2026-11-08 05:15:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by chitters2004 on 2026-11-08T05:15:25Z.


What

DepthSurfaceViewWithStencilWriteIntent finds the resident depth surface of a draw and returns its image view. The view is created once with the surface; what a repeated draw paid for was the bookkeeping around that lookup. Each call described the mirrored depth and stencil plane layouts again with DescribeSurface, which builds a mip-layout vector, up to four times (WrittenUnits, SyncStencilFromMemory, stalePlaneRange/staleStencilRange, the stale marking), and the mirror sync built a per-unit change vector even when no unit had changed. On the GTA V replay that is 4.69 heap allocations per draw inside this call.

  • DepthSurface holds the guest size of its mirrored depth and stencil planes after the first use (MirrorBytes, StencilMirrorBytes). The surface's target is const, so the sizes cannot go stale; a new image, extent, format or aliasing target is a new DepthSurface.
  • WrittenUnits builds its per-unit vector only when a unit is found written; an empty result means that nothing changed. Both callers already guard on anyUnit or the size.

Behaviour is unchanged. One source file plus a test. About 4 us per draw of guest-memory coherence checking remains in the same call (HTILE store-back check, owner map updates, claim and settle checks); skipping those needs an epoch gate and is a separate design change, not part of this PR.

Overlap, rechecked on 2026-11-08 against main 78976e2657 (this branch still merges cleanly, and no commit on main since f9c96f23f0 touches DepthSurface.cpp) and earlier against main 0f147e329f with tools/pr_overlap.py (it fails closed: it cannot confirm 21 open pull requests that touch DepthSurface.cpp, so they were compared by hand, and #15058 is still open) and, on 2026-11-07 against main 87473937d3, by hand: #15058 (lgqdaxia, "refresh depth planes over compared shared memory") rewrites WrittenUnits (it adds a parameter and a compare step to the same function) and conflicts textually with the WrittenUnits hunks here; the two are independent in behaviour, and whichever lands second needs a mechanical rebase. #16644 (freneza, partially resident depth and stencil planes) adds its own test next to ours in tests/DepthSurfaceReuse.cpp, a one-line textual conflict with no shared behaviour. The other open pull requests that touch DepthSurface.cpp (native multisample depth, #15707, #16365, #16364 and others) change other functions.

Tested

Head 8603023ab599 on main f9c96f23f024 (one commit; the GTA V A/B timing below was measured on this head and on this base). The mutant and Windows lavapipe runs below ran on c4773b6018, whose two changed files are byte-identical to the head's (only its parent 210676ad86 differs). Windows 11, RTX 3080 (driver 621.14), Ryzen 7 5800X. No other GPU.

Tests (agc_graphics_profile_draw, tests/DepthSurfaceReuse.cpp), all with the real driver code over the mocked Vulkan device and guest memory that the write watch tracks:

  • TestRepeatedDepthViewAllocations: 16 repeated draws into a resident D32S8 surface reuse its image and view and allocate nothing. glibc only (it counts operator new); other platforms skip the allocation assertion.
  • TestStencilWriteBeyondPlane (every platform with a write-watched arena): a CPU write one byte past the stencil plane, inside memory that the depth plane size would cover, must not refresh the stencil mirror. This pins StencilMirrorBytes to the stencil plane.
  • TestRetireStaleSurfaceWithoutWrittenUnits (same condition): a stale surface whose depth memory was unmapped and whose stencil was written by the CPU is retired by a lookup it cannot serve, with an empty written-unit vector; the lookup returns no texture and the surface's image is freed once the next surface is created. This pins the empty-vector handling of WrittenUnits in retireStoringStale.

Mutants (one change each, built on the head by the fork CI mutants job, ctest regex of the focused AGC set plus depth):

mutant killed by the tests that existed before this PR killed by the new tests
M1 WrittenUnits never reports a written unit agc_driver_depth_plane_cpu_write_after_page_unwatch, ..._partial_unwatch, ..._memo, agc_driver_depth_plane_partial_store_unimported, ..._image_copy, ..._buffer_copy (run 42425319720) not by the new tests
M2 mark sizes the vector to unit + 1 agc_driver_depth_plane_partial_store_unimported, ..._image_copy, ..._buffer_copy (same run) not by the new tests
M3 StencilMirrorBytes sized from the depth plane none (survived, same run) agc_graphics_profile_draw fails in TestStencilWriteBeyondPlane (run 42432952297)
M4 the unit < written.size() guard removed none (survived, same run) agc_graphics_profile_draw segfaults in TestRetireStaleSurfaceWithoutWrittenUnits (same run)

Red and green locally on Windows with the same test: M3 fails with "a CPU write just past the stencil plane must not refresh the stencil mirror", M4 crashes with an access violation, and the unmutated head passes (Graphics validation tests passed).

Fork CI (Linux lavapipe on the head, run 42436384999, head vs main f9c96f23f024: 286 of 286 passed on both, no VUID- line. Windows lavapipe on c4773b6018, run 42432994805, against its parent): the same tests fail on main and on the head (agc_driver_frame_replay_cold_pipelines, agc_driver_recorder, guest_memory exit code 0xc0000409; agc_driver_native_depth_separate_stencil times out at 30 s on the head and did so on main in an earlier run of the same kind) and the same 8 VUID-vkCmdDispatch-groupCountX-00386 lines appear in both logs, so the change adds none.

Vulkan gate, RTX 3080 (local builds in one tree, Release, BUILD_TESTING=ON; ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -R the focused AGC set plus depth and agc_graphics_profile_draw): the head 8603023ab5 292 of 292 passed, and its exact parent main f9c96f23f0 292 of 292 passed, both on the same machine and GPU. No VUID- line in either log or sub-log, no missing-layer line, no new failure. (CI bundle gates on the earlier bases 0f147e329f and 210676ad86 also passed 292 of 292.)

Frame replay, identical frames (3-frame GTA V capture, 9,364 draws, agc_frame_replay --repeat 5, passes 2 to 5, template-hit rows, per-scope timers in the replay kit, the fix toggled by an environment variable inside one binary): heap allocations inside depth view resolution 4.69 per draw -> 0.97 (0.74 of the 0.97 is the caller's targetViews vector growth, 0.21 the HTILE check, 0.02 the owner maps); the call's instrumented time 6.16 -> 4.00 us per draw. The unchanged scopes also moved between the two runs (claim 0.47/0.34 us), so about 25 % run-to-run drift applies; the directly changed scopes account for about 1.2 us. pixels_identical 1.0, max_channel_diff 0, frames_compared 3 for both arms (the replay prints the comparison of the last pass only).

Performance, GTA V (PPSA04263, content 01.011.001), standing scene, 3840x2160, default settings, pipelined draws (APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1), 30 s trace window from 235 s after launch (APS5_TRACE_SECONDS=235:30), after one discarded warm-up boot of each build on its shader cache. Interleaved A, B, A, B, one machine, 2026-11-08, save play1-first-autosave. A is main f9c96f23f0, B is the head 8603023ab5; each was configured and built separately (libs target, Release, ccache), so each summary line carries its own commit and none is dirty (prx hashes over the whole set: A 5897c7a78f86e975, B 0a5fe2dfef67c001). This replaces the earlier 2026-11-07 captures, whose two lines both named 8a720bde3320.

capture commit presents in 30 s mean ms/frame p50 p90 p99 max GPU busy ms/present queue worker busy Graphics.Draw ms/frame Driver.Draw.prepare ms/frame
A (main), pair 1 f9c96f23f024 224 134.1 133.3 138.9 156.4 160.1 33.4 95.1 % 102.8 71.6
B (change), pair 1 8603023ab599 226 133.0 132.4 138.0 159.5 174.5 33.5 95.0 % 101.9 70.0
A (main), pair 2 f9c96f23f024 231 130.2 129.7 134.0 141.2 154.3 33.0 95.1 % 99.1 68.9
B (change), pair 2 8603023ab599 227 132.3 131.9 137.0 146.0 164.9 33.4 94.7 % 101.2 70.0

The two lines of each pair, as tools/performance_compare.py reads them (A, B, A, B):

{"commit":"f9c96f23f024","dirty":false,"env":{"APS5_ADDRESS_COPY_MAX_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"80","APS5_DUMP_FRAMES_EVERY":"300","APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"","APS5_TRACE_SECONDS":"235:30","APS5_TRACE_SUMMARY_EVERY":"10","APS5_VIDEOOUT_TELEMETRY_DIR":""},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 621.14","os":"Windows 10.0.26320","cpu":"AMD Ryzen 7 5800X 8-Core Processor","cpu_threads":16,"memory_mib":32676,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 235:30","first_present":4079,"ms":30033.609},"presents":224,"frame_ms":{"p50":133.269,"p90":138.937,"p99":156.360,"max":160.064},"gpu_busy_ms_per_present":33.398,"worker_busy_pct":{"queue worker 0x0":95.056},"top_phases_ms_per_frame":{"Driver.Packet":121.113,"Graphics.Draw":102.771,"Driver.Packet.draw":91.378,"Driver.Draw":90.773,"Driver.DrawFinish":78.483,"Graphics.Draw.draw_and_resource_release":77.972,"Driver.Draw.prepare":71.607,"Driver.DrawFinish.draw_enqueued":42.913},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.375,"events_lost":1208577,"totals_full":false},"draw committer":{"events_full_after_s":11.139,"events_lost":442239,"totals_full":false},"draw finisher":{"events_full_after_s":14.910,"events_lost":264149,"totals_full":false}},"trace":"aps5-trace-f9c96f23f024-18488.json.gz"}

{"commit":"8603023ab599","dirty":false,"env":{"APS5_ADDRESS_COPY_MAX_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"80","APS5_DUMP_FRAMES_EVERY":"300","APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"","APS5_TRACE_SECONDS":"235:30","APS5_TRACE_SUMMARY_EVERY":"10","APS5_VIDEOOUT_TELEMETRY_DIR":""},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 621.14","os":"Windows 10.0.26320","cpu":"AMD Ryzen 7 5800X 8-Core Processor","cpu_threads":16,"memory_mib":32676,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 235:30","first_present":4103,"ms":30047.327},"presents":226,"frame_ms":{"p50":132.359,"p90":137.969,"p99":159.538,"max":174.549},"gpu_busy_ms_per_present":33.473,"worker_busy_pct":{"queue worker 0x0":95.006},"top_phases_ms_per_frame":{"Driver.Packet":119.920,"Graphics.Draw":101.871,"Driver.Packet.draw":89.664,"Driver.Draw":89.048,"Driver.DrawFinish":77.192,"Graphics.Draw.draw_and_resource_release":77.077,"Driver.Draw.prepare":70.016,"Driver.DrawFinish.draw_enqueued":41.387},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.373,"events_lost":1200833,"totals_full":false},"draw committer":{"events_full_after_s":11.227,"events_lost":437413,"totals_full":false},"draw finisher":{"events_full_after_s":15.019,"events_lost":259820,"totals_full":false}},"trace":"aps5-trace-8603023ab599-4264.json.gz"}

{"commit":"f9c96f23f024","dirty":false,"env":{"APS5_ADDRESS_COPY_MAX_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"80","APS5_DUMP_FRAMES_EVERY":"300","APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"","APS5_TRACE_SECONDS":"235:30","APS5_TRACE_SUMMARY_EVERY":"10","APS5_VIDEOOUT_TELEMETRY_DIR":""},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 621.14","os":"Windows 10.0.26320","cpu":"AMD Ryzen 7 5800X 8-Core Processor","cpu_threads":16,"memory_mib":32676,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 235:30","first_present":4069,"ms":30080.770},"presents":231,"frame_ms":{"p50":129.740,"p90":134.007,"p99":141.250,"max":154.310},"gpu_busy_ms_per_present":33.037,"worker_busy_pct":{"queue worker 0x0":95.071},"top_phases_ms_per_frame":{"Driver.Packet":117.353,"Graphics.Draw":99.146,"Driver.Packet.draw":88.009,"Driver.Draw":87.424,"Driver.DrawFinish":75.749,"Graphics.Draw.draw_and_resource_release":75.491,"Driver.Draw.prepare":68.914,"Driver.DrawFinish.draw_enqueued":41.568},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.384,"events_lost":1193114,"totals_full":false},"draw committer":{"events_full_after_s":11.217,"events_lost":437923,"totals_full":false},"draw finisher":{"events_full_after_s":15.347,"events_lost":249237,"totals_full":false}},"trace":"aps5-trace-f9c96f23f024-28812.json.gz"}

{"commit":"8603023ab599","dirty":false,"env":{"APS5_ADDRESS_COPY_MAX_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"80","APS5_DUMP_FRAMES_EVERY":"300","APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"","APS5_TRACE_SECONDS":"235:30","APS5_TRACE_SUMMARY_EVERY":"10","APS5_VIDEOOUT_TELEMETRY_DIR":""},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 621.14","os":"Windows 10.0.26320","cpu":"AMD Ryzen 7 5800X 8-Core Processor","cpu_threads":16,"memory_mib":32676,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 235:30","first_present":4133,"ms":30042.016},"presents":227,"frame_ms":{"p50":131.867,"p90":137.003,"p99":145.960,"max":164.884},"gpu_busy_ms_per_present":33.388,"worker_busy_pct":{"queue worker 0x0":94.735},"top_phases_ms_per_frame":{"Driver.Packet":119.103,"Graphics.Draw":101.231,"Driver.Packet.draw":89.484,"Driver.Draw":88.876,"Driver.DrawFinish":77.212,"Graphics.Draw.draw_and_resource_release":76.525,"Driver.Draw.prepare":70.012,"Driver.DrawFinish.draw_enqueued":41.684},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.376,"events_lost":1205302,"totals_full":false},"draw committer":{"events_full_after_s":11.152,"events_lost":442662,"totals_full":false},"draw finisher":{"events_full_after_s":15.105,"events_lost":255695,"totals_full":false}},"trace":"aps5-trace-8603023ab599-24348.json.gz"}

Change minus main, mean ms/frame: pair 1 -1.1, pair 2 +2.1, mean +0.5 (+0.4 %); Driver.Draw.prepare -1.6 and +1.1 ms/frame, mean -0.2. The sign flips between the pairs and the spread between the two main captures is 3.9 ms (the two head captures differ by 0.6 ms), so this capture shows no frame-time change that can be told apart from run-to-run variation; it does not reproduce the -6.5 ms/frame of the 2026-11-07 captures (those ran on the earlier base 87473937d3; main itself is now 3 to 10 ms/frame faster in this scene). Per draw, at about 3,040 draws per frame (the replay's count; the boots did not count draws, to keep profiling off): -0.4 us in pair 1, +0.7 us in pair 2, mean +0.2 us, against the 1.2 to 2.2 us the replay measured on the same call; 1.2 us per draw would be 3.6 ms per frame, which this A/B can only resolve if the main spread were smaller than it is. The draw count per frame was not measured in these boots, so the per-draw figures assume the replay's count. The scene is CPU-bound on the draw committer (queue worker 95 % busy in all four captures, GPU busy 33 ms per present of 130 to 134), so a per-draw saving would show in frame time if it were large enough. The allocation count is the provable part of this PR, not the frame time. tools/performance_compare.py output for both pairs and the full tools/trace_digest.py output of each capture are attached. Traces dropped events (queue worker buffer full after about 5 s), as in earlier captures of this scene; phase totals come from the summary, not the event trace.

Deviations from the Performance report form: APS5_DUMP_FRAMES=80, APS5_DUMP_FRAMES_EVERY=300, APS5_NO_PAD_INPUT=1, the pad input file, APS5_LOG_TIMESTAMPS=1, APS5_TRACE_SUMMARY_EVERY=10 and APS5_ADDRESS_COPY_MAX_MIB=512 were set, and a navigation script drove the title to the standing scene; the shader cache directories were per build hash; no boot was repeated and none was discarded except the two warm-ups, which are not samples.

Traces and summary lines: https://github.com/chitters2004/AnyPS5/releases/tag/pr-dview-traces.

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
  • Fixes: none
  • Unblocks: PPSA04263 (Grand Theft Auto V) per-draw cost, no discussion number
  • GPUs tested: NVIDIA GeForce RTX 3080, driver 621.14, Windows 11 (10.0.26320); Mesa lavapipe with the Khronos validation layer on Linux and Windows CI
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5208873929 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17007). Originally posted by [chitters2004](https://github.com/chitters2004) on 2026-11-08T05:15:25Z. --- ### What `DepthSurfaceViewWithStencilWriteIntent` finds the resident depth surface of a draw and returns its image view. The view is created once with the surface; what a repeated draw paid for was the bookkeeping around that lookup. Each call described the mirrored depth and stencil plane layouts again with `DescribeSurface`, which builds a mip-layout vector, up to four times (`WrittenUnits`, `SyncStencilFromMemory`, `stalePlaneRange`/`staleStencilRange`, the stale marking), and the mirror sync built a per-unit change vector even when no unit had changed. On the GTA V replay that is 4.69 heap allocations per draw inside this call. - `DepthSurface` holds the guest size of its mirrored depth and stencil planes after the first use (`MirrorBytes`, `StencilMirrorBytes`). The surface's `target` is `const`, so the sizes cannot go stale; a new image, extent, format or aliasing target is a new `DepthSurface`. - `WrittenUnits` builds its per-unit vector only when a unit is found written; an empty result means that nothing changed. Both callers already guard on `anyUnit` or the size. Behaviour is unchanged. One source file plus a test. About 4 us per draw of guest-memory coherence checking remains in the same call (HTILE store-back check, owner map updates, claim and settle checks); skipping those needs an epoch gate and is a separate design change, not part of this PR. Overlap, rechecked on 2026-11-08 against `main` `78976e2657` (this branch still merges cleanly, and no commit on `main` since `f9c96f23f0` touches `DepthSurface.cpp`) and earlier against `main` `0f147e329f` with `tools/pr_overlap.py` (it fails closed: it cannot confirm 21 open pull requests that touch `DepthSurface.cpp`, so they were compared by hand, and #15058 is still open) and, on 2026-11-07 against `main` `87473937d3`, by hand: #15058 (lgqdaxia, "refresh depth planes over compared shared memory") rewrites `WrittenUnits` (it adds a parameter and a compare step to the same function) and conflicts textually with the `WrittenUnits` hunks here; the two are independent in behaviour, and whichever lands second needs a mechanical rebase. #16644 (freneza, partially resident depth and stencil planes) adds its own test next to ours in `tests/DepthSurfaceReuse.cpp`, a one-line textual conflict with no shared behaviour. The other open pull requests that touch `DepthSurface.cpp` (native multisample depth, #15707, #16365, #16364 and others) change other functions. ### Tested Head `8603023ab599` on `main` `f9c96f23f024` (one commit; the GTA V A/B timing below was measured on this head and on this base). The mutant and Windows lavapipe runs below ran on `c4773b6018`, whose two changed files are byte-identical to the head's (only its parent `210676ad86` differs). Windows 11, RTX 3080 (driver 621.14), Ryzen 7 5800X. No other GPU. **Tests** (`agc_graphics_profile_draw`, `tests/DepthSurfaceReuse.cpp`), all with the real driver code over the mocked Vulkan device and guest memory that the write watch tracks: - `TestRepeatedDepthViewAllocations`: 16 repeated draws into a resident D32S8 surface reuse its image and view and allocate nothing. glibc only (it counts `operator new`); other platforms skip the allocation assertion. - `TestStencilWriteBeyondPlane` (every platform with a write-watched arena): a CPU write one byte past the stencil plane, inside memory that the depth plane size would cover, must not refresh the stencil mirror. This pins `StencilMirrorBytes` to the stencil plane. - `TestRetireStaleSurfaceWithoutWrittenUnits` (same condition): a stale surface whose depth memory was unmapped and whose stencil was written by the CPU is retired by a lookup it cannot serve, with an empty written-unit vector; the lookup returns no texture and the surface's image is freed once the next surface is created. This pins the empty-vector handling of `WrittenUnits` in `retireStoringStale`. **Mutants** (one change each, built on the head by the fork CI `mutants` job, `ctest` regex of the focused AGC set plus `depth`): | mutant | killed by the tests that existed before this PR | killed by the new tests | |---|---|---| | M1 `WrittenUnits` never reports a written unit | `agc_driver_depth_plane_cpu_write_after_page_unwatch`, `..._partial_unwatch`, `..._memo`, `agc_driver_depth_plane_partial_store_unimported`, `..._image_copy`, `..._buffer_copy` ([run 42425319720](https://github.com/chitters2004/AnyPS5/actions/runs/42425319720)) | not by the new tests | | M2 `mark` sizes the vector to `unit + 1` | `agc_driver_depth_plane_partial_store_unimported`, `..._image_copy`, `..._buffer_copy` (same run) | not by the new tests | | M3 `StencilMirrorBytes` sized from the depth plane | none (survived, same run) | `agc_graphics_profile_draw` fails in `TestStencilWriteBeyondPlane` ([run 42432952297](https://github.com/chitters2004/AnyPS5/actions/runs/42432952297)) | | M4 the `unit < written.size()` guard removed | none (survived, same run) | `agc_graphics_profile_draw` segfaults in `TestRetireStaleSurfaceWithoutWrittenUnits` (same run) | Red and green locally on Windows with the same test: M3 fails with "a CPU write just past the stencil plane must not refresh the stencil mirror", M4 crashes with an access violation, and the unmutated head passes (`Graphics validation tests passed`). **Fork CI** (Linux lavapipe on the head, run [42436384999](https://github.com/chitters2004/AnyPS5/actions/runs/42436384999), head vs `main` `f9c96f23f024`: 286 of 286 passed on both, no `VUID-` line. Windows lavapipe on `c4773b6018`, run [42432994805](https://github.com/chitters2004/AnyPS5/actions/runs/42432994805), against its parent): the same tests fail on `main` and on the head (`agc_driver_frame_replay_cold_pipelines`, `agc_driver_recorder`, `guest_memory` exit code 0xc0000409; `agc_driver_native_depth_separate_stencil` times out at 30 s on the head and did so on `main` in an earlier run of the same kind) and the same 8 `VUID-vkCmdDispatch-groupCountX-00386` lines appear in both logs, so the change adds none. **Vulkan gate, RTX 3080** (local builds in one tree, Release, `BUILD_TESTING=ON`; `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ctest -R` the focused AGC set plus `depth` and `agc_graphics_profile_draw`): the head `8603023ab5` 292 of 292 passed, and its exact parent `main` `f9c96f23f0` 292 of 292 passed, both on the same machine and GPU. No `VUID-` line in either log or sub-log, no missing-layer line, no new failure. (CI bundle gates on the earlier bases `0f147e329f` and `210676ad86` also passed 292 of 292.) **Frame replay, identical frames** (3-frame GTA V capture, 9,364 draws, `agc_frame_replay --repeat 5`, passes 2 to 5, template-hit rows, per-scope timers in the replay kit, the fix toggled by an environment variable inside one binary): heap allocations inside depth view resolution 4.69 per draw -> 0.97 (0.74 of the 0.97 is the caller's `targetViews` vector growth, 0.21 the HTILE check, 0.02 the owner maps); the call's instrumented time 6.16 -> 4.00 us per draw. The unchanged scopes also moved between the two runs (claim 0.47/0.34 us), so about 25 % run-to-run drift applies; the directly changed scopes account for about 1.2 us. `pixels_identical` 1.0, `max_channel_diff` 0, `frames_compared` 3 for both arms (the replay prints the comparison of the last pass only). **Performance, GTA V** (PPSA04263, content 01.011.001), standing scene, 3840x2160, default settings, pipelined draws (`APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1`), 30 s trace window from 235 s after launch (`APS5_TRACE_SECONDS=235:30`), after one discarded warm-up boot of each build on its shader cache. Interleaved A, B, A, B, one machine, 2026-11-08, save `play1-first-autosave`. A is `main` `f9c96f23f0`, B is the head `8603023ab5`; each was configured and built separately (`libs` target, Release, ccache), so each summary line carries its own commit and none is dirty (`prx` hashes over the whole set: A `5897c7a78f86e975`, B `0a5fe2dfef67c001`). This replaces the earlier 2026-11-07 captures, whose two lines both named `8a720bde3320`. | capture | commit | presents in 30 s | mean ms/frame | p50 | p90 | p99 | max | GPU busy ms/present | queue worker busy | `Graphics.Draw` ms/frame | `Driver.Draw.prepare` ms/frame | |---|---|---|---|---|---|---|---|---|---|---|---| | A (main), pair 1 | `f9c96f23f024` | 224 | 134.1 | 133.3 | 138.9 | 156.4 | 160.1 | 33.4 | 95.1 % | 102.8 | 71.6 | | B (change), pair 1 | `8603023ab599` | 226 | 133.0 | 132.4 | 138.0 | 159.5 | 174.5 | 33.5 | 95.0 % | 101.9 | 70.0 | | A (main), pair 2 | `f9c96f23f024` | 231 | 130.2 | 129.7 | 134.0 | 141.2 | 154.3 | 33.0 | 95.1 % | 99.1 | 68.9 | | B (change), pair 2 | `8603023ab599` | 227 | 132.3 | 131.9 | 137.0 | 146.0 | 164.9 | 33.4 | 94.7 % | 101.2 | 70.0 | The two lines of each pair, as `tools/performance_compare.py` reads them (A, B, A, B): {"commit":"f9c96f23f024","dirty":false,"env":{"APS5_ADDRESS_COPY_MAX_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"80","APS5_DUMP_FRAMES_EVERY":"300","APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"235:30","APS5_TRACE_SUMMARY_EVERY":"10","APS5_VIDEOOUT_TELEMETRY_DIR":"<path>"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 621.14","os":"Windows 10.0.26320","cpu":"AMD Ryzen 7 5800X 8-Core Processor","cpu_threads":16,"memory_mib":32676,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 235:30","first_present":4079,"ms":30033.609},"presents":224,"frame_ms":{"p50":133.269,"p90":138.937,"p99":156.360,"max":160.064},"gpu_busy_ms_per_present":33.398,"worker_busy_pct":{"queue worker 0x0":95.056},"top_phases_ms_per_frame":{"Driver.Packet":121.113,"Graphics.Draw":102.771,"Driver.Packet.draw":91.378,"Driver.Draw":90.773,"Driver.DrawFinish":78.483,"Graphics.Draw.draw_and_resource_release":77.972,"Driver.Draw.prepare":71.607,"Driver.DrawFinish.draw_enqueued":42.913},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.375,"events_lost":1208577,"totals_full":false},"draw committer":{"events_full_after_s":11.139,"events_lost":442239,"totals_full":false},"draw finisher":{"events_full_after_s":14.910,"events_lost":264149,"totals_full":false}},"trace":"aps5-trace-f9c96f23f024-18488.json.gz"} {"commit":"8603023ab599","dirty":false,"env":{"APS5_ADDRESS_COPY_MAX_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"80","APS5_DUMP_FRAMES_EVERY":"300","APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"235:30","APS5_TRACE_SUMMARY_EVERY":"10","APS5_VIDEOOUT_TELEMETRY_DIR":"<path>"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 621.14","os":"Windows 10.0.26320","cpu":"AMD Ryzen 7 5800X 8-Core Processor","cpu_threads":16,"memory_mib":32676,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 235:30","first_present":4103,"ms":30047.327},"presents":226,"frame_ms":{"p50":132.359,"p90":137.969,"p99":159.538,"max":174.549},"gpu_busy_ms_per_present":33.473,"worker_busy_pct":{"queue worker 0x0":95.006},"top_phases_ms_per_frame":{"Driver.Packet":119.920,"Graphics.Draw":101.871,"Driver.Packet.draw":89.664,"Driver.Draw":89.048,"Driver.DrawFinish":77.192,"Graphics.Draw.draw_and_resource_release":77.077,"Driver.Draw.prepare":70.016,"Driver.DrawFinish.draw_enqueued":41.387},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.373,"events_lost":1200833,"totals_full":false},"draw committer":{"events_full_after_s":11.227,"events_lost":437413,"totals_full":false},"draw finisher":{"events_full_after_s":15.019,"events_lost":259820,"totals_full":false}},"trace":"aps5-trace-8603023ab599-4264.json.gz"} {"commit":"f9c96f23f024","dirty":false,"env":{"APS5_ADDRESS_COPY_MAX_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"80","APS5_DUMP_FRAMES_EVERY":"300","APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"235:30","APS5_TRACE_SUMMARY_EVERY":"10","APS5_VIDEOOUT_TELEMETRY_DIR":"<path>"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 621.14","os":"Windows 10.0.26320","cpu":"AMD Ryzen 7 5800X 8-Core Processor","cpu_threads":16,"memory_mib":32676,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 235:30","first_present":4069,"ms":30080.770},"presents":231,"frame_ms":{"p50":129.740,"p90":134.007,"p99":141.250,"max":154.310},"gpu_busy_ms_per_present":33.037,"worker_busy_pct":{"queue worker 0x0":95.071},"top_phases_ms_per_frame":{"Driver.Packet":117.353,"Graphics.Draw":99.146,"Driver.Packet.draw":88.009,"Driver.Draw":87.424,"Driver.DrawFinish":75.749,"Graphics.Draw.draw_and_resource_release":75.491,"Driver.Draw.prepare":68.914,"Driver.DrawFinish.draw_enqueued":41.568},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.384,"events_lost":1193114,"totals_full":false},"draw committer":{"events_full_after_s":11.217,"events_lost":437923,"totals_full":false},"draw finisher":{"events_full_after_s":15.347,"events_lost":249237,"totals_full":false}},"trace":"aps5-trace-f9c96f23f024-28812.json.gz"} {"commit":"8603023ab599","dirty":false,"env":{"APS5_ADDRESS_COPY_MAX_MIB":"512","APS5_DRAW_PIPELINE":"1","APS5_DUMP_FRAMES":"80","APS5_DUMP_FRAMES_EVERY":"300","APS5_LOG_TIMESTAMPS":"1","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_PIPELINED_DRAWS":"32","APS5_PIPELINE_DISPATCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"235:30","APS5_TRACE_SUMMARY_EVERY":"10","APS5_VIDEOOUT_TELEMETRY_DIR":"<path>"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 621.14","os":"Windows 10.0.26320","cpu":"AMD Ryzen 7 5800X 8-Core Processor","cpu_threads":16,"memory_mib":32676,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.011.001","resolution":"3840x2160","window":{"spec":"seconds 235:30","first_present":4133,"ms":30042.016},"presents":227,"frame_ms":{"p50":131.867,"p90":137.003,"p99":145.960,"max":164.884},"gpu_busy_ms_per_present":33.388,"worker_busy_pct":{"queue worker 0x0":94.735},"top_phases_ms_per_frame":{"Driver.Packet":119.103,"Graphics.Draw":101.231,"Driver.Packet.draw":89.484,"Driver.Draw":88.876,"Driver.DrawFinish":77.212,"Graphics.Draw.draw_and_resource_release":76.525,"Driver.Draw.prepare":70.012,"Driver.DrawFinish.draw_enqueued":41.684},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.376,"events_lost":1205302,"totals_full":false},"draw committer":{"events_full_after_s":11.152,"events_lost":442662,"totals_full":false},"draw finisher":{"events_full_after_s":15.105,"events_lost":255695,"totals_full":false}},"trace":"aps5-trace-8603023ab599-24348.json.gz"} Change minus main, mean ms/frame: pair 1 -1.1, pair 2 +2.1, mean +0.5 (+0.4 %); `Driver.Draw.prepare` -1.6 and +1.1 ms/frame, mean -0.2. The sign flips between the pairs and the spread between the two `main` captures is 3.9 ms (the two head captures differ by 0.6 ms), so this capture shows no frame-time change that can be told apart from run-to-run variation; it does not reproduce the -6.5 ms/frame of the 2026-11-07 captures (those ran on the earlier base `87473937d3`; `main` itself is now 3 to 10 ms/frame faster in this scene). Per draw, at about 3,040 draws per frame (the replay's count; the boots did not count draws, to keep profiling off): -0.4 us in pair 1, +0.7 us in pair 2, mean +0.2 us, against the 1.2 to 2.2 us the replay measured on the same call; 1.2 us per draw would be 3.6 ms per frame, which this A/B can only resolve if the `main` spread were smaller than it is. The draw count per frame was not measured in these boots, so the per-draw figures assume the replay's count. The scene is CPU-bound on the draw committer (queue worker 95 % busy in all four captures, GPU busy 33 ms per present of 130 to 134), so a per-draw saving would show in frame time if it were large enough. The allocation count is the provable part of this PR, not the frame time. `tools/performance_compare.py` output for both pairs and the full `tools/trace_digest.py` output of each capture are attached. Traces dropped events (queue worker buffer full after about 5 s), as in earlier captures of this scene; phase totals come from the summary, not the event trace. Deviations from the Performance report form: `APS5_DUMP_FRAMES=80`, `APS5_DUMP_FRAMES_EVERY=300`, `APS5_NO_PAD_INPUT=1`, the pad input file, `APS5_LOG_TIMESTAMPS=1`, `APS5_TRACE_SUMMARY_EVERY=10` and `APS5_ADDRESS_COPY_MAX_MIB=512` were set, and a navigation script drove the title to the standing scene; the shader cache directories were per build hash; no boot was repeated and none was discarded except the two warm-ups, which are not samples. Traces and summary lines: https://github.com/chitters2004/AnyPS5/releases/tag/pr-dview-traces. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 - [x] Fixes: none - [x] Unblocks: PPSA04263 (Grand Theft Auto V) per-draw cost, no discussion number - [x] GPUs tested: NVIDIA GeForce RTX 3080, driver 621.14, Windows 11 (10.0.26320); Mesa lavapipe with the Khronos validation layer on Linux and Windows CI - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!17007
No description provided.