feat(agc): count replayed frames as presents for the performance trace #13984
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13984"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-31T14:28:14Z.
What
agc_frame_replaynever presents, so the performance trace never started in a replay:APS5_TRACE_FRAMES,APS5_TRACE_SECONDSandAPS5_TRACE_SUMMARY_EVERYwrote nothing. The trace session, its window and its summary intervals start and count inPerformanceTrace::Present(Execution/src/PerformanceTrace.cpp). Onmainits only caller outside tests isDriver::Present(Execution/src/Driver/Presentation.cpp), which runs when VideoOut presents a title's frame. A replayed flip ends inReplayFlip::GpuReady(tools/FrameReplay.cpp), which only records the frame's time.Driver::TracePresent(width, height)counts one present for the performance trace, as the first line ofDriver::Presentdoes, and nothing else; with no trace switch set it returns at once. It passes the driver's own device, so when the driver already has its device as the window opens, the trace gets itsgputrack and the summary itsgpuanddriverfields, as in a title run.agc_frame_replayreaches it through a new export,AgcDriverTracePresent, as it already reachesAgcDriverSerialProgressandAgcDriverAwaitedWaits.Frames::MarkReadycalls it for each flip the driver reports ready, before it takes the frame's time, with the size of the first display buffer the capture stored, or 0x0 when the capture stored none.agc_driver_frame_replay_trace_window, a new mode of the frame replay state test, replays three flips withAPS5_TRACE_DIR=<capture>-traceandAPS5_TRACE_FRAMES=0:2and expects the window's line inaps5-summary.jsonlwith"presents":2. Like the other trace-window tests, it unsetsAPS5_TRACE_SECONDSandAPS5_TRACE_SUMMARY_EVERY.docs/dev/BUILD.md, Performance trace: what a present is in a replay.A replay's trace differs from a title's in three ways:
Driver.Presentslices.resolutioncomes from the capture, not from a video output.gpu_busy_ms_per_presentis 0, because that time is counted as presentations retire. Thegputrack has the GPU time.As in a title run, a window that is still open at the end writes nothing, so a frame window needs more than
<start>+<count>replayed flips.This is not the in-flight-depth change discussed on #12568, which stays a separate PR stacked on #12568.
Tested
Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.16010, Ryzen 5 5600X, WinLibs GCC 15.2.0 r7, Release.
This head
fcdddc9899is373b38a1ecwithmainb11c7bf84fmerged in, and the merge had no conflicts. The linesgit diff b11c7bf84f fcdddc9899adds and removes are exactly those of373b38a1ec's own patch. Full builds of both trees, with submodules at their pins:frame_(replay|capture)tests passed, 3 runsVUID-linesmainb11c7bf84ffcdddc9899The one extra row is
agc_driver_frame_replay_trace_window.Red on
mainb11c7bf84f: I putmain's copies ofExecution/include/Driver.hpp,Execution/include/Driver/Driver.hpp,Execution/src/Driver/EntryPoints.cpp,Execution/src/Driver/Presentation.cppandtools/FrameReplay.cppintofcdddc9899, keeping this PR's test and registration.agc_driver_frame_replay_trace_windowthen failed in 3 of 3 runs withreplayed frames did not open and close the trace window.Earlier revisions.
373b38a1ecwas rebased ontomaindc9dc7eaaefor #12862's split of the test registration, with the same patch otherwise. It passed 12/12 in each of 3 runs, with 0VUID-lines;mainwas not rerun for it. The previous head0de943f892onmain50843f45d9:frame_(replay|capture)tests passed, 3 runsVUID-linesmain50843f45d90de943f892All arms ran
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R "frame_(replay|capture)" -V. Neither log has a layer insertion line, because none of these tests creates a Vulkan instance.main50843f45d9(head0de943f892): withmain'sExecution/include/Driver.hpp,Execution/include/Driver/Driver.hpp,Execution/src/Driver/EntryPoints.cpp,Execution/src/Driver/Presentation.cppandtools/FrameReplay.cpp, and this PR's test and registration,agc_driver_frame_replay_trace_windowfailed in 3 of 3 runs withreplayed frames did not open and close the trace window. With this PR it passed in 3 of 3.dc8621f997(the same production code at other insertion points, onmain50843f45d9): four replays of a 20-frame capture of PPSA05110 withAPS5_TRACE_FRAMES=2:16each printed[trace] recording frames 2:16 from present 2and[trace] closed at present 18, writing aps5-trace-dc8621f99705-<pid>.json.gz ..., wrote the trace and its summary line ("resolution":"3840x2160","gpu":"AMD Radeon RX 6700 XT","presents":16,"gpu_busy_ms_per_present":0.000,"trace_dropped":false) and exited 0. A fifth was stopped at the tool'spacing gave upmessage before its window opened.tools/trace_digest.pyreads the first trace (rows fortitle,queue worker 0x0,draw committerandgpu). In the three replays that ran without a build beside them, the replay's JSON interval ending at the closing flip was 406, 444 and 393 ms against medians of 195, 199 and 194 ms. Over the window, the JSON intervals add up to 192-252 ms more than the trace's window: that is about the time spent formatting 9.6-10.3 MB of trace JSON at the close, which the trace's own frame times leave out.0de943f892from an archive with submodules at their pins:agc_driver_frame_replay_trace_windowpassed 6 of 6 (3 runs with the default import path, 3 withAPS5_WRITE_WATCH_IMPORTS=unwatch). The capture-based tests in the set could not run there: this kernel has no asynchronous userfaultfd write protection, so the guest write watch is unavailable andagc_driver_frame_capture_eopstops withthe guest write watch is unavailable; thelinuxCI job covers them.--repeattogether with this change.Overlap
373b38a1ecmerged without conflicts with the current heads of #12318 (d3faa75d4a), #12565 (f360a4575c), #12567 (1126a888d9), #12568 (0e3d922b76) and #12696 (9f770fd8d1). #11435 (9392228b5c), #11436 (752958c135) and #12871 (ca858917b0) conflict only withmain's split oflibSceAgcDriver/CMakeLists.txt, not with this PR's files.tests/FrameReplayState.cpp; whichever lands second keeps both.--repeat, which replays the capture several times in one process and reports every pass's flips to the sameFrames. With both PRs, every pass's flips count as presents, so a window can include the warm-up pass and the memory restore before each later pass. With F flips per pass, a frame window inside one later pass (<start>≥ F and (<start>mod F) +<count>< F) leaves both out. I can add that toBUILD.mdonce #11435 has merged.APS5_TRACE_GPUand--trace-serialsprint submission serials on stderr and do not start the performance trace, so this PR complements them.envalso listsAPS5_FRAME_REPLAY_ATTEMPT.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T14:52:49Z.
Review: APPROVED
Reviewed — looks good
The exact head
0de943f8926ac967416209424b5122e72ddd42e3counts replayed flips when the driver reports them ready and includes a focused trace-window regression test.Locally,
git diff --checkand the repository convention check passed; the no-build precheck also confirmed a clean merge preview and unchanged head/base. Its ABI and test-quality helper steps could not run because those private local helper scripts are absent from the PR checkout, so those are unavailable checks rather than source failures. The hosted Windows job built and passedagc_driver_frame_replay_trace_window(run). The author reports the replay-window test passing 6/6 on WSL/Linux; I did not run that test locally. No local build or macOS test was run.