fix(agc): store resident linear color targets at completion points, limited to their drawn rectangles #9685

Merged
thuanquang merged 15 commits from upstream-pr/9685 into main 2026-10-25 16:44:22 +00:00
thuanquang commented 2026-10-22 08:29:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-22T08:29:16Z.


What

A recorded draw into a resident linear color target stored the whole image to guest memory right after the draw (keepRecordedDraw's FlushPending(..., "linear target")). Every draw copied the full surface and waited for the previous draw's store in the open batch (the pending-writer check of FlushPending). The recorded copy also landed over CPU stores made after Draw returned (#8152).

A draw now records its scissor, clipped to the image, in the target, and lists the target as drawn. The target keeps the rectangles themselves; two merge only when their union is a rectangle. The listed targets are stored before each point where the guest can first observe that the draws completed:

  • a flip, inside its locked block and before the flip's submit, so the flip's end-of-pipe interrupt and the presenter follow the store;
  • a drain, which covers APS5_SYNC_FLIP=1;
  • VulkanDevice::WaitIdle;
  • a label the GPU writes for the graphics queue (WriteLabelOnGpu);
  • an interrupt-only RELEASE_MEM in preparePacketMemory and in commitLabel, which submit the store's batch before the interrupt can be delivered.

The idle store, the access hooks and the eviction store run as before, and they also store by rectangles. The CPU-kept access hook no longer skips or evicts a drawn target, because that target's store writes CPU-written blocks inside its rectangles. This is the synchronization contract with regression coverage that @MarcZX10 asked for on #9217 (proposal).

A store of a drawn target copies the rectangles' bounding box out of the image and writes, row by row at the guest pitch, only the union of the rectangles' column runs on each row into the host import. Each run of 64 KiB blocks gets one MarkWritten.

  • A block that only other driver stores wrote since the target's generation keeps the old rule.
  • In a block the CPU wrote, or that changed outside the write watch, only those row spans are stored. CPU stores outside the rectangles stay, and the target re-uploads at its next use.
  • At most 16 rectangles wait for a completion point: the draw that brings a 17th stores the target right after it, with all of them.
  • A target with an attachment proxy, several mips or layers, a 3D or DCC surface, or results of a dispatch, fill or copy is stored after each draw, as before. One that a fill or copy writes after its draws is stored whole at the next completion point and keeps main's rule that CPU-written 64 KiB blocks stay the CPU's.

A store no longer waits for the same target's previous store: when the target has a host import, the pending-writer check skips the write notes of the target's own stores. APS5_PROFILE_DRAW adds the drawn targets' stores by reason, and the pending drawn targets (count, MiB, oldest), to the [storage] line.

With stores at completion points, #8126's rule that keeps newer image results over a direct write's completion stamp (StampKeepingNewerResults) also covers targets with drawn results and images that are already being flushed. A dispatch that writes a drawn target's memory through its host import and has completion work can complete inside that target's store, and its second stamp made the draws recorded after it look older than the dispatch, so the store dropped them all. A drawn target is tracked as one unit, so after a change anywhere else in it (a CPU store into another 64 KiB block) the whole-image check fails; the stamped 64 KiB blocks are then checked one by one. A block with no change since the image's generation keeps its draws past the stamp (completionKept, which writeBackLayers reads), and a block the CPU wrote keeps the CPU's bytes outside the drawn rectangles. Whole-image keeps of drawn targets are rechecked for CPU stores after the stamp.

Why

PPSA14363 (METAL GEAR SOLID - Master Collection Version, own dump) draws its PS1 game into three linear 3072x2048 RGBA8 color targets. With them resident (#1191's import-creating case, applied locally for these runs), main's per-draw store copies up to 69.7 GB per 10 s out of the images, and the PS1 part runs slower than on the synchronous path. In MGS1's PS1 part every store of these targets covers one rectangle (a local counter over a 300 s run: no fallback to a whole or per-draw store). Bring-up thread: #9615.

Tested

Windows 11 26200, Radeon RX 6700 XT (gfx1031), AMD driver 32.0.21045.16010, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON.

Current head d6d8966bba: main b930da950d merged in, for @oneandonlydean (comment). Only core/libs/prx/libSceAgcDriver/CMakeLists.txt conflicted: main's new agc_submit_progress tests and this PR's completion-point tests went into the same if(BUILD_TESTING) block, and both are kept. It still merges cleanly with main f595326943. On this head, on the RX 6700 XT, the build is clean. The focused set plus agc_driver_bda_* (54 ctest entries) passes 3 of 3. With the Khronos validation layer, 54 of 54 pass with 0 VUID- lines (the layer was inserted 73 times, no "was not found" line). ctest -R "^(agc|shader)_" passes 1011 of 1014; the 3 failures are the sample_order tests main fails on this GPU.

Earlier head d36311d661: the per-block keep at the end of What, for @oneandonlydean's review (comment). agc_driver_linear_target_direct_write_completion gains that ordering as a third case, on write-watched and on unwatched memory: a fill over block 0 with completion work, a draw into block 0, a CPU store into block 1 made under the GPU mutex while the fill's completion is still pending (the test reads the fill's copied buffer in the same hold, and again at the label, so each run reports whether the completion was pending at the store and had run by the label), then the label. Red on 5b5dcaeaff: the write-watched case fails, with 9984 of the 9984 pixels the draw covered holding the fill's pattern, the completion pending at the store and run by the label; the other three cases pass. Green on this head: 20 of 20, and 10 of 10 with the output kept, each write-watched run with the completion pending at the CPU store and run by the label. On unwatched memory the keep rule does not apply and the fill's completion had already run when the CPU store landed, so that variant passes before and after the change. The same test on main 8a85a5c848 fails as well: the fill-then-draws case loses 9856 of the 19712 drawn pixels (the first draw), and in the third case the draw's own store on main runs the fill's completion first, drops the draw's 9984 pixels, and its whole-target store writes the target's old bytes (0x5a5a5a5a) over the block-1 CPU store. Also on this head: the focused set above plus agc_driver_bda_* (53 ctest entries) 3 of 3; with the Khronos validation layer 53 of 53, 0 VUID- lines, the layer inserted 70 times; ctest -R "^(agc|shader)_" 997 of 1000, with the same 3 sample_order failures as main.

Earlier head 5b5dcaeaff: main 11d6efa06c merged in (eefe6d1380; only core/libs/prx/libSceAgcDriver/CMakeLists.txt conflicted, resolved as in @oneandonlydean's merge on #9879), then 5b5dcaeaff, the keep-rule change at the end of What, with a new test. A review of the merge against #8126 found the dropped draws. agc_driver_linear_target_direct_write_completion has two cases: a direct fill with completion work and then two draws, and the reverse order. It skips without a host import, and when the device does not keep the import write-watched. With the new test on 7ad5d33a66 (the same commits rebased onto 11d6efa06c, without the change), the first case fails: at the label after the draws, 19712 of the 19712 pixels the draws covered hold the fill's pattern. With it, the test passes 20 of 20. The runs below are on 605de8157c, the same change rebased onto 11d6efa06c. Its tree differs from this head only in the position of one add_test block in CMakeLists.txt and in the debt entry on this gap:

  • the focused set plus #8126's agc_driver_direct_write_completion, main's agc_driver_copied_writer_*, agc_driver_draw_cache_* and label-order entries: 46 ctest entries, 3 of 3. agc_driver_copied_writer_label_order and its _drain entry skip on this GPU (minStorageBufferOffsetAlignment 4), as on main;
  • with the Khronos validation layer: 46 of 46, 0 VUID- lines, the layer inserted 64 times, no "was not found" line;
  • ctest -R "^(agc|shader)_": 997 of 1000 pass; the 3 failures are main's agc_driver_sample_order, _grid_reference and _recipe_depth_locations on this GPU.

Other devices, on cee2512ef8: @Dextroid17 on lavapipe (comment), and @BKlaasWerkman on Intel Arc with the validation layer (comment).

Previous head cee2512ef8, rebased onto main ff191e29d1 because #6948 and #6682 made it conflict; it still merges cleanly with 513ca7e558. RX 6700 XT, AMD driver 32.0.21045.16010: the focused set plus main's agc_driver_linear_readback_label and agc_recorder_* entries, 25 ctest entries, pass 3 of 3. With the Khronos validation layer on the same set, main 513ca7e558 passes 16 of 16 (the entries that exist there; layer inserted 19 times) and this head 25 of 25 (32 times), with 0 VUID- lines and no "was not found" line on either. The rebase keeps #6948's StoreReadbackBeforeLabel next to this PR's StoreDrawnLinear at labels and end-of-pipe interrupts, this PR's first, so its stored count still sets workOpen for the interrupt submit; the readback store then finds queue 0's drawn targets already stored, and on other queues it stores them limited to their drawn rectangles. e5edf0cd4a fixed agc_driver_linear_target_draw_bindings for memory outside the write watch (llvmpipe CI): the test runs its scenario watched and with the block taken out of the write watch, and expects no submission from the second copying draw in the first case and exactly one in the second. The older results below are from the commits they name.

New tests (4 executables, 6 ctest entries), on this branch on main d6eafa54d0:

  • agc_driver_linear_target_completion_points (with _sync_flip and _unpipelined variants): a flip, a drain, a label and an interrupt-only RELEASE_MEM through AgcDriver::Submit, with the queue held by a WAIT_REG_MEM, inside and outside the write watch. They pass on main too, because main stores after every draw. They pin the contract, so a label-only policy would fail them. They skip on a device without host import, where the target is never resident.
  • agc_driver_linear_target_completion_stores: a target stays pending across draws and labels until WaitIdle, without a submission.
  • agc_driver_linear_target_cpu_writes: #8152's CPU stores after Draw, seeded and unseeded, inside and outside the write watch, each also with a driver read of the target (GuestMemory::Read) between the CPU stores and the store. Ported from @MarcZX10's LinearTargetCpuWrites in #8246.
  • agc_driver_linear_target_rectangle_bound: after one seeding draw and wait, two draws with different scissors, then CPU stores outside both rectangles, between them inside their bounding box, and in the gap before a target that starts past a 64 KiB boundary; and a second case with 17 one-row scissors and a CPU store between two of them.
  • agc_driver_linear_target_draw_bindings, agc_driver_linear_target_dispatch_access and the agc_driver_address_passes_draw_transitions entry (with AddressPasses --synchronous-target-read) come with the last three commits: a draw's snapshot bindings prepared after its drawn-target store, the store before an address-based dispatch, and the store before a synchronous draw that reads a drawn target.
  • Green: all of them pass 3 of 3, and so do the other tests of the focused set below (18 ctest entries on 10a8319a94).
  • Red: with main's production files (at d6eafa54d0) and the new tests, completion_stores, cpu_writes and rectangle_bound fail; the three completion_points entries pass, as above. Without the AccessKeptByCpu check, cpu_writes fails at the driver read. With the bounding box of the third commit, rectangle_bound fails with both sentinels between the rectangles lost.

Khronos validation layer, ctest -V on the focused set (15 tests at e430b0d07a; on 10a8319a94 the 18 entries pass with 0 VUID- lines and the layer inserted 29 times) (the 6 above, agc_driver_linear_target_resident, agc_driver_address_passes and _targets_split, agc_driver_clamped_global_fill, agc_driver_flip_stores_small_results, agc_driver_storage_flush_ordering, agc_driver_storage_read_during_idle_store, agc_driver_store_idle_results and agc_driver_store_over_untracked): 15 of 15 pass on this branch, and 12 of 15 with main's production files at d6eafa54d0 (the three red tests above). Both sides have 0 VUID- lines; VK_LOADER_DEBUG=layer shows the layer inserted 25 times, with no "was not found" line.

ctest -R "^agc_" (896 tests, -j 1) on e430b0d07a: 891 pass; on 10a8319a94 (899 tests, run by huy): 894 pass. The 5 failures are the ones main d6eafa54d0 has on this GPU and toolchain:

  • agc_driver_sample_order, _grid_reference, _recipe_depth_locations and agc_driver_tessellation (#9313 for the sample order; #8861 for tessellation, fixed by #8884);
  • agc_driver_image_array_window_past_layer_limit (its 64 KiB alignas with this MinGW toolchain).

agc_driver_address_passes and its _targets_split variant failed on the first commit: the linear-target case reads, through the address table, the target the previous draw rendered in the same submission, and with the store deferred that read saw the bytes from before the draw. The second commit stores drawn targets before a draw or dispatch that reads their memory in place or writes it, and all of them for address-based work.

PPSA14363, MGS1's PS1 part, with the targets resident through #1191's import line, applied locally on both sides (so both summary lines show dirty): main d6eafa54d0 against e430b0d07a, only libSceAgcDriver.prx swapped, both with #9115's trophy fix. Same scripted route, 300 s, APS5_TRACE_SUMMARY_EVERY=10, frame dumps only in the first 50 s, a trace window at 200 s, GPU and build locks held. Per 10 s window from 80 s, when the PS1 part starts, without the window that ends with the trace write:

MGS1's PS1 part, 20 windows main + import line this change + import line
presents per 10 s 46 to 169 600
frame p99 127.7 to 574.4 ms 17.2 to 17.4 ms
frame max 132.4 to 574.4 ms 17.3 to 18.9 ms

Summary lines of the trace window (200 to 220 s), main first:

{"commit":"d6eafa54d046","dirty":true,"env":{"APS5_DUMP_FRAMES":"100","APS5_DUMP_FRAMES_EVERY":"30","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"200:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32690,"title_id":"PPSA14363","title":"METAL GEAR SOLID - Master Collection Version","content_version":"03.000.000","resolution":"1920x1080","window":{"spec":"seconds 200:20","first_present":5724,"ms":20187.184},"presents":170,"frame_ms":{"p50":17.361,"p90":286.919,"p99":338.727,"max":339.723},"gpu_busy_ms_per_present":95.308,"worker_busy_pct":{"queue worker 0x0":90.450},"top_phases_ms_per_frame":{"Driver.Packet":107.404,"Graphics.Draw":106.712,"Graphics.Draw.draw_and_resource_release":106.333,"Recorder.Sync":102.637,"Driver.Packet.draw":100.244,"Driver.Draw":100.203,"Driver.Draw.draw_enqueued":98.609,"VideoOut.Flip":5.066},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-7736.json.gz"}
{"commit":"e430b0d07ab2","dirty":true,"env":{"APS5_DUMP_FRAMES":"100","APS5_DUMP_FRAMES_EVERY":"30","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"200:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32690,"title_id":"PPSA14363","title":"METAL GEAR SOLID - Master Collection Version","content_version":"03.000.000","resolution":"1920x1080","window":{"spec":"seconds 200:20","first_present":11855,"ms":20003.149},"presents":1199,"frame_ms":{"p50":16.684,"p90":16.920,"p99":17.372,"max":17.645},"gpu_busy_ms_per_present":1.676,"worker_busy_pct":{"queue worker 0x0":6.284},"top_phases_ms_per_frame":{"VideoOut.Flip":13.315,"VideoOut.Flip.vblank_wait":12.638,"Driver.Packet":1.046,"Driver.Packet.draw":0.705,"Driver.Draw":0.691,"Graphics.Draw":0.618,"VideoOut.Flip.present":0.594,"Driver.Present":0.591},"trace_dropped":false,"trace":"aps5-trace-e430b0d07ab2-1592.json.gz"}

In that window main spends 102.6 ms per frame in Recorder.Sync, behind the whole-target stores, and the GPU is busy 95.3 ms per present against 1.68 ms with this change. tools/performance_compare.py on these lines and the tools/trace_digest.py tables of both runs are in this comment. Traces are not attached, because these runs come from a commercial title. An earlier 600 s run of the first commit on main 6ef5a1c4c9 + #9115, #9188, #9202 and #9373, with the same import line, reached Dock gameplay with no stop at 591 to 600 presents per 10 s.

Overlap:

  • #8246 (@MarcZX10, changes requested, conflicting) also targets #8152, with a byte-exact merge of the drawn rectangle against CPU stores. As proposed on #9217, the two can split by ownership: this change decides when the store happens and keeps the bytes outside the drawn rectangles; #8246 keeps the merge inside them. This PR ports #8246's LinearTargetCpuWrites test with credit.
  • #6948 (@alfalfa-star) changes PacketMemory.cpp, VulkanDevice.cpp and Texture.cpp for label readback stores. Neither builds on the other, and whichever merges second rebases.
  • #1191 (@MichonGoddijn231849, draft) creates the host import that PPSA14363's targets need to become resident. That case is now #9879, stacked on this PR.

Left for a follow-up, with a debt entry: a CPU store into a 64 KiB block of a drawn target that lands in the window while the direct write's completion checks and stamps that same block drops the draws in that block (the stamp's own collect records the store per page only, so the block reads as written by the driver). The CPU store itself survives.

Not tested: GPUs other than the RX 6700 XT, Linux, a title whose linear targets are resident on main without the import case.

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: #8152, outside the drawn rectangles (#8246 keeps the byte-exact merge inside them)
  • Unblocks: #9879 (the host import of PPSA14363's linear color targets, stacked on this PR)
  • GPUs tested: AMD Radeon RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.16010, Windows 11 26200
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4964434888 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9685). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-22T08:29:16Z. --- ### What A recorded draw into a resident linear color target stored the whole image to guest memory right after the draw (`keepRecordedDraw`'s `FlushPending(..., "linear target")`). Every draw copied the full surface and waited for the previous draw's store in the open batch (the pending-writer check of `FlushPending`). The recorded copy also landed over CPU stores made after `Draw` returned (#8152). A draw now records its scissor, clipped to the image, in the target, and lists the target as drawn. The target keeps the rectangles themselves; two merge only when their union is a rectangle. The listed targets are stored before each point where the guest can first observe that the draws completed: - a flip, inside its locked block and before the flip's submit, so the flip's end-of-pipe interrupt and the presenter follow the store; - a drain, which covers `APS5_SYNC_FLIP=1`; - `VulkanDevice::WaitIdle`; - a label the GPU writes for the graphics queue (`WriteLabelOnGpu`); - an interrupt-only `RELEASE_MEM` in `preparePacketMemory` and in `commitLabel`, which submit the store's batch before the interrupt can be delivered. The idle store, the access hooks and the eviction store run as before, and they also store by rectangles. The CPU-kept access hook no longer skips or evicts a drawn target, because that target's store writes CPU-written blocks inside its rectangles. This is the synchronization contract with regression coverage that @MarcZX10 asked for on #9217 ([proposal](https://github.com/boykopovar/AnyPS5/issues/9217#issuecomment-6333318801)). A store of a drawn target copies the rectangles' bounding box out of the image and writes, row by row at the guest pitch, only the union of the rectangles' column runs on each row into the host import. Each run of 64 KiB blocks gets one `MarkWritten`. - A block that only other driver stores wrote since the target's generation keeps the old rule. - In a block the CPU wrote, or that changed outside the write watch, only those row spans are stored. CPU stores outside the rectangles stay, and the target re-uploads at its next use. - At most 16 rectangles wait for a completion point: the draw that brings a 17th stores the target right after it, with all of them. - A target with an attachment proxy, several mips or layers, a 3D or DCC surface, or results of a dispatch, fill or copy is stored after each draw, as before. One that a fill or copy writes after its draws is stored whole at the next completion point and keeps `main`'s rule that CPU-written 64 KiB blocks stay the CPU's. A store no longer waits for the same target's previous store: when the target has a host import, the pending-writer check skips the write notes of the target's own stores. `APS5_PROFILE_DRAW` adds the drawn targets' stores by reason, and the pending drawn targets (count, MiB, oldest), to the `[storage]` line. With stores at completion points, #8126's rule that keeps newer image results over a direct write's completion stamp (`StampKeepingNewerResults`) also covers targets with drawn results and images that are already being flushed. A dispatch that writes a drawn target's memory through its host import and has completion work can complete inside that target's store, and its second stamp made the draws recorded after it look older than the dispatch, so the store dropped them all. A drawn target is tracked as one unit, so after a change anywhere else in it (a CPU store into another 64 KiB block) the whole-image check fails; the stamped 64 KiB blocks are then checked one by one. A block with no change since the image's generation keeps its draws past the stamp (`completionKept`, which `writeBackLayers` reads), and a block the CPU wrote keeps the CPU's bytes outside the drawn rectangles. Whole-image keeps of drawn targets are rechecked for CPU stores after the stamp. ### Why PPSA14363 (METAL GEAR SOLID - Master Collection Version, own dump) draws its PS1 game into three linear 3072x2048 RGBA8 color targets. With them resident (#1191's import-creating case, applied locally for these runs), `main`'s per-draw store copies up to 69.7 GB per 10 s out of the images, and the PS1 part runs slower than on the synchronous path. In MGS1's PS1 part every store of these targets covers one rectangle (a local counter over a 300 s run: no fallback to a whole or per-draw store). Bring-up thread: #9615. ### Tested Windows 11 26200, Radeon RX 6700 XT (gfx1031), AMD driver 32.0.21045.16010, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`. **Current head `d6d8966bba`**: `main` `b930da950d` merged in, for @oneandonlydean ([comment](https://github.com/boykopovar/AnyPS5/pull/9879#issuecomment-6383356780)). Only `core/libs/prx/libSceAgcDriver/CMakeLists.txt` conflicted: `main`'s new `agc_submit_progress` tests and this PR's completion-point tests went into the same `if(BUILD_TESTING)` block, and both are kept. It still merges cleanly with `main` `f595326943`. On this head, on the RX 6700 XT, the build is clean. The focused set plus `agc_driver_bda_*` (54 `ctest` entries) passes 3 of 3. With the Khronos validation layer, 54 of 54 pass with 0 `VUID-` lines (the layer was inserted 73 times, no "was not found" line). `ctest -R "^(agc|shader)_"` passes 1011 of 1014; the 3 failures are the `sample_order` tests `main` fails on this GPU. **Earlier head `d36311d661`**: the per-block keep at the end of What, for @oneandonlydean's review ([comment](https://github.com/boykopovar/AnyPS5/pull/9685#issuecomment-6381196744)). `agc_driver_linear_target_direct_write_completion` gains that ordering as a third case, on write-watched and on unwatched memory: a fill over block 0 with completion work, a draw into block 0, a CPU store into block 1 made under the GPU mutex while the fill's completion is still pending (the test reads the fill's copied buffer in the same hold, and again at the label, so each run reports whether the completion was pending at the store and had run by the label), then the label. Red on `5b5dcaeaff`: the write-watched case fails, with 9984 of the 9984 pixels the draw covered holding the fill's pattern, the completion pending at the store and run by the label; the other three cases pass. Green on this head: 20 of 20, and 10 of 10 with the output kept, each write-watched run with the completion pending at the CPU store and run by the label. On unwatched memory the keep rule does not apply and the fill's completion had already run when the CPU store landed, so that variant passes before and after the change. The same test on `main` `8a85a5c848` fails as well: the fill-then-draws case loses 9856 of the 19712 drawn pixels (the first draw), and in the third case the draw's own store on `main` runs the fill's completion first, drops the draw's 9984 pixels, and its whole-target store writes the target's old bytes (0x5a5a5a5a) over the block-1 CPU store. Also on this head: the focused set above plus `agc_driver_bda_*` (53 `ctest` entries) 3 of 3; with the Khronos validation layer 53 of 53, 0 `VUID-` lines, the layer inserted 70 times; `ctest -R "^(agc|shader)_"` 997 of 1000, with the same 3 `sample_order` failures as `main`. **Earlier head `5b5dcaeaff`**: `main` `11d6efa06c` merged in (`eefe6d1380`; only `core/libs/prx/libSceAgcDriver/CMakeLists.txt` conflicted, resolved as in @oneandonlydean's merge on #9879), then `5b5dcaeaff`, the keep-rule change at the end of What, with a new test. A review of the merge against #8126 found the dropped draws. `agc_driver_linear_target_direct_write_completion` has two cases: a direct fill with completion work and then two draws, and the reverse order. It skips without a host import, and when the device does not keep the import write-watched. With the new test on `7ad5d33a66` (the same commits rebased onto `11d6efa06c`, without the change), the first case fails: at the label after the draws, 19712 of the 19712 pixels the draws covered hold the fill's pattern. With it, the test passes 20 of 20. The runs below are on `605de8157c`, the same change rebased onto `11d6efa06c`. Its tree differs from this head only in the position of one `add_test` block in `CMakeLists.txt` and in the debt entry on this gap: - the focused set plus #8126's `agc_driver_direct_write_completion`, `main`'s `agc_driver_copied_writer_*`, `agc_driver_draw_cache_*` and label-order entries: 46 `ctest` entries, 3 of 3. `agc_driver_copied_writer_label_order` and its `_drain` entry skip on this GPU (minStorageBufferOffsetAlignment 4), as on `main`; - with the Khronos validation layer: 46 of 46, 0 `VUID-` lines, the layer inserted 64 times, no "was not found" line; - `ctest -R "^(agc|shader)_"`: 997 of 1000 pass; the 3 failures are `main`'s `agc_driver_sample_order`, `_grid_reference` and `_recipe_depth_locations` on this GPU. Other devices, on `cee2512ef8`: @Dextroid17 on lavapipe ([comment](https://github.com/boykopovar/AnyPS5/pull/9685#issuecomment-6374875107)), and @BKlaasWerkman on Intel Arc with the validation layer ([comment](https://github.com/boykopovar/AnyPS5/pull/9685#issuecomment-6375059054)). **Previous head `cee2512ef8`**, rebased onto `main` `ff191e29d1` because #6948 and #6682 made it conflict; it still merges cleanly with `513ca7e558`. RX 6700 XT, AMD driver 32.0.21045.16010: the focused set plus `main`'s `agc_driver_linear_readback_label` and `agc_recorder_*` entries, 25 `ctest` entries, pass 3 of 3. With the Khronos validation layer on the same set, `main` `513ca7e558` passes 16 of 16 (the entries that exist there; layer inserted 19 times) and this head 25 of 25 (32 times), with 0 `VUID-` lines and no "was not found" line on either. The rebase keeps #6948's `StoreReadbackBeforeLabel` next to this PR's `StoreDrawnLinear` at labels and end-of-pipe interrupts, this PR's first, so its stored count still sets `workOpen` for the interrupt submit; the readback store then finds queue 0's drawn targets already stored, and on other queues it stores them limited to their drawn rectangles. `e5edf0cd4a` fixed `agc_driver_linear_target_draw_bindings` for memory outside the write watch (llvmpipe CI): the test runs its scenario watched and with the block taken out of the write watch, and expects no submission from the second copying draw in the first case and exactly one in the second. The older results below are from the commits they name. **New tests** (4 executables, 6 `ctest` entries), on this branch on `main` `d6eafa54d0`: - `agc_driver_linear_target_completion_points` (with `_sync_flip` and `_unpipelined` variants): a flip, a drain, a label and an interrupt-only `RELEASE_MEM` through `AgcDriver::Submit`, with the queue held by a `WAIT_REG_MEM`, inside and outside the write watch. They pass on `main` too, because `main` stores after every draw. They pin the contract, so a label-only policy would fail them. They skip on a device without host import, where the target is never resident. - `agc_driver_linear_target_completion_stores`: a target stays pending across draws and labels until `WaitIdle`, without a submission. - `agc_driver_linear_target_cpu_writes`: #8152's CPU stores after `Draw`, seeded and unseeded, inside and outside the write watch, each also with a driver read of the target (`GuestMemory::Read`) between the CPU stores and the store. Ported from @MarcZX10's `LinearTargetCpuWrites` in #8246. - `agc_driver_linear_target_rectangle_bound`: after one seeding draw and wait, two draws with different scissors, then CPU stores outside both rectangles, between them inside their bounding box, and in the gap before a target that starts past a 64 KiB boundary; and a second case with 17 one-row scissors and a CPU store between two of them. - `agc_driver_linear_target_draw_bindings`, `agc_driver_linear_target_dispatch_access` and the `agc_driver_address_passes_draw_transitions` entry (with `AddressPasses --synchronous-target-read`) come with the last three commits: a draw's snapshot bindings prepared after its drawn-target store, the store before an address-based dispatch, and the store before a synchronous draw that reads a drawn target. - Green: all of them pass 3 of 3, and so do the other tests of the focused set below (18 `ctest` entries on `10a8319a94`). - Red: with `main`'s production files (at `d6eafa54d0`) and the new tests, `completion_stores`, `cpu_writes` and `rectangle_bound` fail; the three `completion_points` entries pass, as above. Without the `AccessKeptByCpu` check, `cpu_writes` fails at the driver read. With the bounding box of the third commit, `rectangle_bound` fails with both sentinels between the rectangles lost. **Khronos validation layer**, `ctest -V` on the focused set (15 tests at `e430b0d07a`; on `10a8319a94` the 18 entries pass with 0 `VUID-` lines and the layer inserted 29 times) (the 6 above, `agc_driver_linear_target_resident`, `agc_driver_address_passes` and `_targets_split`, `agc_driver_clamped_global_fill`, `agc_driver_flip_stores_small_results`, `agc_driver_storage_flush_ordering`, `agc_driver_storage_read_during_idle_store`, `agc_driver_store_idle_results` and `agc_driver_store_over_untracked`): 15 of 15 pass on this branch, and 12 of 15 with `main`'s production files at `d6eafa54d0` (the three red tests above). Both sides have 0 `VUID-` lines; `VK_LOADER_DEBUG=layer` shows the layer inserted 25 times, with no "was not found" line. **`ctest -R "^agc_"`** (896 tests, `-j 1`) on `e430b0d07a`: 891 pass; on `10a8319a94` (899 tests, run by huy): 894 pass. The 5 failures are the ones `main` `d6eafa54d0` has on this GPU and toolchain: - `agc_driver_sample_order`, `_grid_reference`, `_recipe_depth_locations` and `agc_driver_tessellation` (#9313 for the sample order; #8861 for tessellation, fixed by #8884); - `agc_driver_image_array_window_past_layer_limit` (its 64 KiB `alignas` with this MinGW toolchain). `agc_driver_address_passes` and its `_targets_split` variant failed on the first commit: the linear-target case reads, through the address table, the target the previous draw rendered in the same submission, and with the store deferred that read saw the bytes from before the draw. The second commit stores drawn targets before a draw or dispatch that reads their memory in place or writes it, and all of them for address-based work. **PPSA14363**, MGS1's PS1 part, with the targets resident through #1191's import line, applied locally on both sides (so both summary lines show `dirty`): `main` `d6eafa54d0` against `e430b0d07a`, only `libSceAgcDriver.prx` swapped, both with #9115's trophy fix. Same scripted route, 300 s, `APS5_TRACE_SUMMARY_EVERY=10`, frame dumps only in the first 50 s, a trace window at 200 s, GPU and build locks held. Per 10 s window from 80 s, when the PS1 part starts, without the window that ends with the trace write: | MGS1's PS1 part, 20 windows | `main` + import line | this change + import line | |---|---|---| | presents per 10 s | 46 to 169 | 600 | | frame p99 | 127.7 to 574.4 ms | 17.2 to 17.4 ms | | frame max | 132.4 to 574.4 ms | 17.3 to 18.9 ms | Summary lines of the trace window (200 to 220 s), `main` first: ```json {"commit":"d6eafa54d046","dirty":true,"env":{"APS5_DUMP_FRAMES":"100","APS5_DUMP_FRAMES_EVERY":"30","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"200:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32690,"title_id":"PPSA14363","title":"METAL GEAR SOLID - Master Collection Version","content_version":"03.000.000","resolution":"1920x1080","window":{"spec":"seconds 200:20","first_present":5724,"ms":20187.184},"presents":170,"frame_ms":{"p50":17.361,"p90":286.919,"p99":338.727,"max":339.723},"gpu_busy_ms_per_present":95.308,"worker_busy_pct":{"queue worker 0x0":90.450},"top_phases_ms_per_frame":{"Driver.Packet":107.404,"Graphics.Draw":106.712,"Graphics.Draw.draw_and_resource_release":106.333,"Recorder.Sync":102.637,"Driver.Packet.draw":100.244,"Driver.Draw":100.203,"Driver.Draw.draw_enqueued":98.609,"VideoOut.Flip":5.066},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-7736.json.gz"} ``` ```json {"commit":"e430b0d07ab2","dirty":true,"env":{"APS5_DUMP_FRAMES":"100","APS5_DUMP_FRAMES_EVERY":"30","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"200:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32690,"title_id":"PPSA14363","title":"METAL GEAR SOLID - Master Collection Version","content_version":"03.000.000","resolution":"1920x1080","window":{"spec":"seconds 200:20","first_present":11855,"ms":20003.149},"presents":1199,"frame_ms":{"p50":16.684,"p90":16.920,"p99":17.372,"max":17.645},"gpu_busy_ms_per_present":1.676,"worker_busy_pct":{"queue worker 0x0":6.284},"top_phases_ms_per_frame":{"VideoOut.Flip":13.315,"VideoOut.Flip.vblank_wait":12.638,"Driver.Packet":1.046,"Driver.Packet.draw":0.705,"Driver.Draw":0.691,"Graphics.Draw":0.618,"VideoOut.Flip.present":0.594,"Driver.Present":0.591},"trace_dropped":false,"trace":"aps5-trace-e430b0d07ab2-1592.json.gz"} ``` In that window `main` spends 102.6 ms per frame in `Recorder.Sync`, behind the whole-target stores, and the GPU is busy 95.3 ms per present against 1.68 ms with this change. `tools/performance_compare.py` on these lines and the `tools/trace_digest.py` tables of both runs are in [this comment](https://github.com/boykopovar/AnyPS5/pull/9685#issuecomment-6339066525). Traces are not attached, because these runs come from a commercial title. An earlier 600 s run of the first commit on `main` `6ef5a1c4c9` + #9115, #9188, #9202 and #9373, with the same import line, reached Dock gameplay with no stop at 591 to 600 presents per 10 s. **Overlap:** - #8246 (@MarcZX10, changes requested, conflicting) also targets #8152, with a byte-exact merge of the drawn rectangle against CPU stores. As proposed on #9217, the two can split by ownership: this change decides when the store happens and keeps the bytes outside the drawn rectangles; #8246 keeps the merge inside them. This PR ports #8246's `LinearTargetCpuWrites` test with credit. - #6948 (@alfalfa-star) changes `PacketMemory.cpp`, `VulkanDevice.cpp` and `Texture.cpp` for label readback stores. Neither builds on the other, and whichever merges second rebases. - #1191 (@MichonGoddijn231849, draft) creates the host import that PPSA14363's targets need to become resident. That case is now #9879, stacked on this PR. Left for a follow-up, with a debt entry: a CPU store into a 64 KiB block of a drawn target that lands in the window while the direct write's completion checks and stamps that same block drops the draws in that block (the stamp's own collect records the store per page only, so the block reads as written by the driver). The CPU store itself survives. Not tested: GPUs other than the RX 6700 XT, Linux, a title whose linear targets are resident on `main` without the import case. ### 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: #8152, outside the drawn rectangles (#8246 keeps the byte-exact merge inside them) - [x] Unblocks: #9879 (the host import of PPSA14363's linear color targets, stacked on this PR) - [x] GPUs tested: AMD Radeon RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.16010, Windows 11 26200 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-22 08:39:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T08:39:56Z.

Review: CHANGES_REQUESTED


The focused code review found a correctness gap in rectangle tracking. I ran python3 tools/check_conventions.py --base upstream/main --head refs/review/9685 with the PR title/body; it passed. GitHub’s product build/test jobs are skipped for this draft. I could not run the new AGC runtime tests in this checkout: there is no build configured for this head, and this host is the Xeon E5-1620 v2 used in prior Vulkan attempts that lacks the required CPU features. I did not treat the author’s Windows/Radeon runs as locally reproduced.

Please preserve the exact union of drawn row spans (or otherwise ensure the store cannot cover pixels between disjoint scissors), and add a regression that CPU-writes into such an internal gap after both draws. The present test’s two scissors have a bounding-box gap, but its sentinels are outside the bounding box; it therefore does not check that case. The repository performance-report rule also calls for the actual matching main and change summary lines with traces attached; the table is useful, but the traces/raw report are not attached here.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5611456569 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9685#pullrequestreview-5611456569). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T08:39:56Z. **Review:** CHANGES_REQUESTED --- The focused code review found a correctness gap in rectangle tracking. I ran `python3 tools/check_conventions.py --base upstream/main --head refs/review/9685` with the PR title/body; it passed. GitHub’s product build/test jobs are skipped for this draft. I could not run the new AGC runtime tests in this checkout: there is no build configured for this head, and this host is the Xeon E5-1620 v2 used in prior Vulkan attempts that lacks the required CPU features. I did not treat the author’s Windows/Radeon runs as locally reproduced. Please preserve the exact union of drawn row spans (or otherwise ensure the store cannot cover pixels between disjoint scissors), and add a regression that CPU-writes into such an internal gap after both draws. The present test’s two scissors have a bounding-box gap, but its sentinels are outside the bounding box; it therefore does not check that case. The repository performance-report rule also calls for the actual matching `main` and change summary lines with traces attached; the table is useful, but the traces/raw report are not attached here.
jotitadev commented 2026-10-22 09:53:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T09:53:41Z.

Review: COMMENTED


Ran this on NVIDIA and lavapipe on Linux, which the PR lists as not tested. One part of the new coverage only runs on the NVIDIA card here, so CI's lavapipe doesn't guard it.

Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON, head c95a0fd31 (base d6eafa54d). The green and mutation rows were run on both 9d5263767 and c95a0fd31 with the same result; the red row on 9d5263767, whose tests c95a0fd31 does not change, ANYPS5_REQUIRE_VULKAN=1. GPUs: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), each picked with ANYPS5_GPU and checked in the Selected GPU line.

RTX 3070 lavapipe
the 6 new agc_driver_linear_target_* entries, this PR 3/3 3/3
9 related (agc_driver_linear_target*, agc_driver_address_passes*), this PR 3/3 3/3
red: d6eafa54d production files + the new tests completion_stores, cpu_writes, rectangle_bound fail; the 3 completion_points pass same
mutation: ownNotes.clear() right before the PendingWriterSerial check in StorageTexture::FlushPending completion_stores fails 6/6 pass

The two devices take different branches of the tests:

  • lavapipe: [write-watch] host imports resolve write protection: yes, so the target is not write-watched. completion_stores prints the target is outside the write watch ... the submission checks are skipped, and the flip, write-watched memory case of completion_points runs with watched at the store: 0.
  • RTX 3070: host imports resolve write protection: no ... imported ranges stay watched, so the target stays watched, the watched at the store: 1 case runs, and completion_stores makes its recorder->Submissions() checks.

With the mutation, a store waits for the target's previous store again, which is the "a store no longer waits for the same target's previous store" part of this PR. On the 3070 completion_stores catches it with the second label: storing the drawn linear target before the label waited for recorded work (1 submissions). On lavapipe all six pass, because those checks are skipped there. So a regression of that part would pass CI.

ctest -R "^agc" -j1 on the 3070 (867 tests, without the flip, DCC display and 64-bit LDS atomics tests): everything passes except agc_driver_sample_order, _grid_reference and _recipe_depth_locations, which fail the same way on d6eafa54d here (#9313).

GPUs tested: NVIDIA GeForce RTX 3070, driver 595.99.02, Ubuntu 26.04; lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5612363712 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9685#pullrequestreview-5612363712). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T09:53:41Z. **Review:** COMMENTED --- Ran this on NVIDIA and lavapipe on Linux, which the PR lists as not tested. One part of the new coverage only runs on the NVIDIA card here, so CI's lavapipe doesn't guard it. Ubuntu 26.04, i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`, head `c95a0fd31` (base `d6eafa54d`). The green and mutation rows were run on both `9d5263767` and `c95a0fd31` with the same result; the red row on `9d5263767`, whose tests `c95a0fd31` does not change, `ANYPS5_REQUIRE_VULKAN=1`. GPUs: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), each picked with `ANYPS5_GPU` and checked in the `Selected GPU` line. | | RTX 3070 | lavapipe | |---|---|---| | the 6 new `agc_driver_linear_target_*` entries, this PR | 3/3 | 3/3 | | 9 related (`agc_driver_linear_target*`, `agc_driver_address_passes*`), this PR | 3/3 | 3/3 | | red: `d6eafa54d` production files + the new tests | `completion_stores`, `cpu_writes`, `rectangle_bound` fail; the 3 `completion_points` pass | same | | mutation: `ownNotes.clear()` right before the `PendingWriterSerial` check in `StorageTexture::FlushPending` | `completion_stores` fails | 6/6 pass | The two devices take different branches of the tests: - lavapipe: `[write-watch] host imports resolve write protection: yes`, so the target is not write-watched. `completion_stores` prints `the target is outside the write watch ... the submission checks are skipped`, and the `flip, write-watched memory` case of `completion_points` runs with `watched at the store: 0`. - RTX 3070: `host imports resolve write protection: no ... imported ranges stay watched`, so the target stays watched, the `watched at the store: 1` case runs, and `completion_stores` makes its `recorder->Submissions()` checks. With the mutation, a store waits for the target's previous store again, which is the "a store no longer waits for the same target's previous store" part of this PR. On the 3070 `completion_stores` catches it with `the second label: storing the drawn linear target before the label waited for recorded work (1 submissions)`. On lavapipe all six pass, because those checks are skipped there. So a regression of that part would pass CI. `ctest -R "^agc" -j1` on the 3070 (867 tests, without the flip, DCC display and 64-bit LDS atomics tests): everything passes except `agc_driver_sample_order`, `_grid_reference` and `_recipe_depth_locations`, which fail the same way on `d6eafa54d` here (#9313). GPUs tested: NVIDIA GeForce RTX 3070, driver 595.99.02, Ubuntu 26.04; lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
thuanquang commented 2026-10-22 10:57:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-22T10:57:32Z.


@MarcZX10 thanks, both points hold.

Bounding box replaced by the exact union (e430b0d07a). A target now keeps the clipped scissor rectangles of its draws instead of their bounding box. Two rectangles merge only when their union is itself a rectangle: one inside the other, or the same columns that overlap or touch in rows, or the same rows that overlap or touch in columns. The store copies the rectangles' bounding box out of the image into its scratch buffer, as before, but writes to guest memory only, for each row, the union of the column runs of the rectangles that cover that row. So no pixel between two disjoint scissors is stored. At most 16 rectangles wait for a completion point: a draw that brings a 17th stores the target right after it, with all 17, and the next draw starts a new list. A target that the rectangle store does not cover (an attachment proxy, several mips or layers, a 3D or DCC surface, or results of a dispatch, fill or copy) is now stored after each draw, as on main, instead of whole at the next completion point.

The regression is in agc_driver_linear_target_rectangle_bound: CPU sentinels at (30, 6) and (10, 25), inside the bounding box of the two scissors but outside both, written after both draws, and a second case with 17 one-row scissors and a CPU store between two of them. On a27273ab06 (still the bounding box) it fails with "a drawn linear target's store overwrote CPU stores between two draws' scissor rectangles" (2 of the 2 sentinels lost); on e430b0d07a it passes. The case draws and waits once before its draws: without that, the target's upload ran in the same batch as the draws, after the CPU stores, so the bounding-box store wrote the CPU's own bytes back and the old test could not see it.

Review fixes since your review. Two independent reviews of the first commit (huy's, and a four-dimension review on my side with an adversarial check of each finding) agree on these. c95a0fd316:

  • A flush racing a completion point. A flush from a thread that does not hold the GPU lock, such as the flush hook behind an HLE read, moved a drawn target out of the pending set before taking the lock. A flip, label or interrupt on the queue worker could then run in between: it found no pending target and recorded its signal ahead of the store. That flush now takes the GPU lock before it takes a drawn target out of the pending set. When nothing overlaps, the lock is released before the existing wait for other threads' flushes, so that wait is unchanged.
  • An EOP interrupt with a label. workOpen was computed before the label's store, so the interrupt could wait in an unsubmitted batch until a later submission. Both label paths, preparePacketMemory and commitLabel, now store the drawn targets before WriteLabelOnGpu and submit that store with the label, as the interrupt-only branch already does.
  • The own-store exception. The pending-writer check skips a target's own earlier stores only when the flush stores that target alone. With two pending images over the same bytes, the second still waits for the first's store.
  • Debt entry. Every store the draw pipeline's committer makes (for a label, an end-of-pipe interrupt or a device wait) skips a target whose range a queued draw still reads (DrawPipeline::HeldReads). The entry named labels only.

a27273ab06:

  • A draw's scissor lost to a concurrent flush. MarkDrawn checked dirty in a second critical section after MarkSliceDirty. A flush on another thread could take the image out of the pending set in between, and the draw's scissor was then never added, so its pixels outside the earlier area were neither stored nor pending. It now checks layerPending, which changes only under the GPU lock; the flusher reads the drawn area after taking that lock, so it stores the widened area.
  • The CPU-kept hook. AccessKeptByCpu and its eviction still assumed that a store leaves CPU-written blocks alone, but a drawn target's store writes CPU-stamped blocks inside its rectangles. A hooked read of up to 1 MiB after the CPU wrote every block of the target dropped the draw's results. The hook no longer skips or evicts a drawn target; the access flushes it instead. agc_driver_linear_target_cpu_writes adds a GuestMemory::Read of row 0 between the CPU stores and the store, which returns the drawn pixels only with the fix.
  • A target no longer cached is stored after its draw, as on main, because the pending registry holds raw pointers.
  • agc_driver_linear_target_completion_points skips on a device without host import, where the target is never resident, instead of passing without testing anything.

Left as they are:

  • CPU store between the collect and the stamp. A CPU store that lands in a stamped block, outside the rectangles, between the store's write-watch collect and its MarkWritten can later be overwritten by a stale texel. That is the same collect-to-stamp window main's whole-target store has.
  • A fill or copy after the draws. Draws and dispatches that touch a drawn target's memory store it first (9d52637676); a fill or copy does not. A target that a fill or copy writes after its draws were listed is stored whole at the next completion point and keeps main's rule that CPU-written 64 KiB blocks stay the CPU's. The debt entry says so.

Summary lines. PPSA14363, MGS1's PS1 part, with the targets resident through #1191's import line, applied locally on both sides (so both lines show dirty): main d6eafa54d0, this PR's base, against this head e430b0d07a. Only libSceAgcDriver.prx is swapped, both sides have #9115's trophy fix, and both runs use the same scripted route, 300 s, APS5_TRACE_SUMMARY_EVERY=10, frame dumps only in the first 50 s and a trace window at 200 s, with the GPU and build locks held. Per 10 s window from 80 s, when the PS1 part starts, leaving out the window that ends with the trace write:

MGS1's PS1 part, 20 windows main d6eafa54d0 + import line this PR e430b0d07a + import line
presents per 10 s 46 to 169 600
frame p99 127.7 to 574.4 ms 17.2 to 17.4 ms
frame max 132.4 to 574.4 ms 17.3 to 18.9 ms

The summary lines of the trace window (200 to 220 s), main first:

{"commit":"d6eafa54d046","dirty":true,"env":{"APS5_DUMP_FRAMES":"100","APS5_DUMP_FRAMES_EVERY":"30","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"200:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32690,"title_id":"PPSA14363","title":"METAL GEAR SOLID - Master Collection Version","content_version":"03.000.000","resolution":"1920x1080","window":{"spec":"seconds 200:20","first_present":5724,"ms":20187.184},"presents":170,"frame_ms":{"p50":17.361,"p90":286.919,"p99":338.727,"max":339.723},"gpu_busy_ms_per_present":95.308,"worker_busy_pct":{"queue worker 0x0":90.450},"top_phases_ms_per_frame":{"Driver.Packet":107.404,"Graphics.Draw":106.712,"Graphics.Draw.draw_and_resource_release":106.333,"Recorder.Sync":102.637,"Driver.Packet.draw":100.244,"Driver.Draw":100.203,"Driver.Draw.draw_enqueued":98.609,"VideoOut.Flip":5.066},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-7736.json.gz"}
{"commit":"e430b0d07ab2","dirty":true,"env":{"APS5_DUMP_FRAMES":"100","APS5_DUMP_FRAMES_EVERY":"30","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"200:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32690,"title_id":"PPSA14363","title":"METAL GEAR SOLID - Master Collection Version","content_version":"03.000.000","resolution":"1920x1080","window":{"spec":"seconds 200:20","first_present":11855,"ms":20003.149},"presents":1199,"frame_ms":{"p50":16.684,"p90":16.920,"p99":17.372,"max":17.645},"gpu_busy_ms_per_present":1.676,"worker_busy_pct":{"queue worker 0x0":6.284},"top_phases_ms_per_frame":{"VideoOut.Flip":13.315,"VideoOut.Flip.vblank_wait":12.638,"Driver.Packet":1.046,"Driver.Packet.draw":0.705,"Driver.Draw":0.691,"Graphics.Draw":0.618,"VideoOut.Flip.present":0.594,"Driver.Present":0.591},"trace_dropped":false,"trace":"aps5-trace-e430b0d07ab2-1592.json.gz"}

tools/performance_compare.py on these two lines: mean frame 118.748 to 16.683 ms, p99 338.727 to 17.372 ms, GPU busy per present 95.308 to 1.676 ms. Driver.Draw goes from 100.2 to 0.69 ms per frame; on main, 102.6 ms per frame is Recorder.Sync, the wait behind every draw's whole-target store.

tools/trace_digest.py on both runs' summary files

main d6eafa54d0 + import line:

29 intervals, 0.0 to 292.6 s, 6556 presents
AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1 (AMD proprietary shader compiler), Windows 10.0.26200, 1920x1080, commit d6eafa54d0 (dirty)

# seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
1 0-10 502 16.7 17.1 40.4 841.9 1.3 2 % VideoOut.Flip 12.1
2 10-20 594 16.7 17.0 19.6 80.3 1.5 3 % VideoOut.Flip 5.4
3 20-30 576 16.7 16.9 20.2 304.6 5.2 8 % VideoOut.Flip 13.7
4 30-40 600 16.7 17.0 23.8 24.6 3.3 9 % VideoOut.Flip 10.5
5 40-50 600 16.7 16.9 23.4 24.1 3.6 13 % VideoOut.Flip 11.0
6 50-60 509 16.7 41.3 41.8 42.3 6.2 27 % VideoOut.Flip 10.0
7 60-70 436 20.1 43.9 44.6 44.7 11.1 47 % Driver.Packet 10.8
8 70-80 562 16.7 21.1 47.7 48.2 6.3 32 % VideoOut.Flip 10.2
9 80-90 169 17.0 128.6 225.0 230.4 44.6 82 % Driver.Packet 48.8
10 90-100 168 68.0 120.5 127.7 132.4 44.8 82 % Driver.Packet 49.0
11 100-110 138 98.7 127.3 461.5 480.0 53.8 85 % Driver.Packet 61.6
12 110-120 70 186.1 342.8 435.4 435.4 121.0 91 % Driver.Packet 132.4
13 120-130 153 16.3 162.8 202.7 205.8 49.6 82 % Driver.Packet 53.8
14 130-140 129 88.8 168.6 182.6 183.0 61.1 85 % Driver.Packet 67.0
15 140-151 108 147.7 188.9 204.0 206.1 73.1 88 % Driver.Packet 81.8
16 151-161 126 16.8 184.4 542.9 567.7 61.0 87 % Driver.Packet 69.7
17 161-171 46 366.7 481.7 520.1 520.1 189.0 94 % Driver.Packet 210.8
18 171-181 50 362.6 421.5 444.9 444.9 174.3 94 % Driver.Packet 194.0
19 181-191 74 207.8 297.5 367.2 367.2 114.0 91 % Driver.Packet 124.8
20 191-202 134 82.2 167.0 193.2 201.2 58.7 86 % Driver.Packet 64.7
21 202-212 88 17.4 249.6 286.9 286.9 92.0 90 % Driver.Packet 103.9
22 212-222 70 214.0 314.9 339.7 339.7 115.7 90 % Driver.Packet 130.2
23 222-232 60 283.8 345.4 370.2 370.2 139.6 93 % Driver.Packet 156.2
24 232-242 74 195.6 313.6 329.6 329.6 113.8 91 % Driver.Packet 124.6
25 242-252 82 16.8 276.7 300.8 300.8 99.5 90 % Driver.Packet 110.9
26 252-262 83 16.9 273.7 300.3 300.3 98.8 90 % Driver.Packet 108.4
27 262-272 156 85.0 137.3 143.3 145.2 48.5 82 % Driver.Packet 53.0
28 272-282 145 16.8 112.3 546.6 559.0 51.4 84 % Driver.Packet 59.2
29 282-293 54 16.7 556.9 574.4 574.4 155.0 92 % Driver.Packet 174.4
p99 ms  _....___=:##---@%#*-=+*+++:@@  0-574.4
gpu ms  ......_.::-*:---@%+-=*#+++::#  0-189.0

This PR e430b0d07a + import line:

29 intervals, 0.0 to 290.3 s, 17255 presents
AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1 (AMD proprietary shader compiler), Windows 10.0.26200, 1920x1080, commit e430b0d07ab2 (dirty)

# seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
1 0-10 503 16.7 17.0 30.5 801.0 1.3 2 % VideoOut.Flip 12.6
2 10-20 594 16.7 17.0 22.4 77.9 1.8 3 % VideoOut.Flip 3.3
3 20-30 574 16.7 16.9 24.4 304.1 4.9 8 % VideoOut.Flip 12.6
4 30-40 598 16.7 17.3 19.0 40.3 1.4 2 % VideoOut.Flip 4.0
5 40-50 598 16.7 17.3 18.3 36.4 1.4 2 % VideoOut.Flip 2.5
6 50-60 600 16.7 17.7 18.2 18.9 1.5 2 % VideoOut.Flip 2.3
7 60-70 600 16.8 17.6 18.0 18.7 1.7 3 % VideoOut.Flip 2.3
8 70-80 600 16.7 17.3 18.1 19.6 2.4 2 % VideoOut.Flip 7.4
9 80-90 600 16.7 16.9 17.3 17.4 3.4 6 % VideoOut.Flip 13.7
10 90-100 600 16.7 16.9 17.2 17.3 1.9 8 % VideoOut.Flip 12.8
11 100-110 600 16.7 16.9 17.4 17.6 1.7 9 % VideoOut.Flip 12.3
12 110-120 600 16.7 16.9 17.2 18.9 1.7 6 % VideoOut.Flip 13.2
13 120-130 600 16.7 16.9 17.2 17.4 1.7 5 % VideoOut.Flip 13.8
14 130-140 600 16.7 16.9 17.2 17.3 1.6 3 % VideoOut.Flip 14.7
15 140-150 600 16.7 16.9 17.4 17.6 3.0 3 % VideoOut.Flip 15.0
16 150-160 600 16.7 16.9 17.2 17.8 5.4 4 % VideoOut.Flip 14.5
17 160-170 600 16.7 16.9 17.2 17.5 5.4 4 % VideoOut.Flip 14.6
18 170-180 600 16.7 16.9 17.2 17.5 5.4 4 % VideoOut.Flip 14.5
19 180-190 600 16.7 16.9 17.3 17.6 5.3 4 % VideoOut.Flip 14.6
20 190-200 600 16.7 16.9 17.2 17.4 1.6 6 % VideoOut.Flip 13.5
21 200-210 600 16.7 16.9 17.4 17.6 1.7 6 % VideoOut.Flip 13.3
22 210-220 588 16.7 16.9 17.4 217.1 1.7 6 % VideoOut.Flip 13.7
23 220-230 600 16.7 16.9 17.2 17.4 1.7 6 % VideoOut.Flip 13.3
24 230-240 600 16.7 16.9 17.2 17.7 1.7 6 % VideoOut.Flip 13.4
25 240-250 600 16.7 16.9 17.3 17.4 1.7 6 % VideoOut.Flip 13.4
26 250-260 600 16.7 16.9 17.3 17.7 1.7 6 % VideoOut.Flip 13.3
27 260-270 600 16.7 16.9 17.3 17.8 1.7 6 % VideoOut.Flip 13.4
28 270-280 600 16.7 16.9 17.3 17.4 1.7 6 % VideoOut.Flip 13.3
29 280-290 600 16.7 16.9 17.3 17.4 1.7 6 % VideoOut.Flip 13.4
p99 ms  @##*+++++++++++++++++++++++++  0-30.5
gpu ms  :-%::--=*-----+@@@@----------  0-5.4

The trace files stay local, because the runs come from a commercial title; I asked on #9373 whether summary lines plus the tools' output are enough for such a title (comment).

A local counter over a 300 s run of the PS1 part (not committed) shows every store of these targets covering one rectangle, with no store at a draw and no fallback, so the 16-rectangle limit costs this title nothing.

Tested on e430b0d07a, RX 6700 XT, AMD Windows driver 32.0.21045.16010:

  • The focused set of 15 tests passes 3 of 3: the 4 new executables (6 ctest entries), agc_driver_linear_target_resident, agc_driver_address_passes and _targets_split, agc_driver_clamped_global_fill, agc_driver_flip_stores_small_results, agc_driver_storage_flush_ordering, agc_driver_storage_read_during_idle_store, agc_driver_store_idle_results and agc_driver_store_over_untracked.
  • Khronos validation layer, the same 15 tests: 15 of 15 pass on e430b0d07a. With main's production files at d6eafa54d0 and these tests, 12 of 15 pass: completion_stores, cpu_writes and rectangle_bound fail, the last with all 3 outside sentinels and both sentinels between the rectangles lost. Both sides have 0 VUID- lines, and VK_LOADER_DEBUG=layer shows the layer inserted 25 times with no "was not found".
  • Red, one fix at a time: without the AccessKeptByCpu check, cpu_writes fails at the new driver read ("a driver read of row 0 before the store: pixel (0, 0) holds (0.000000, 0.000000, 0.000000, 1.000000), not the second draw's"). With a27273ab06's bounding box, rectangle_bound fails as above.
  • ctest -R "^agc_" (896 tests): 891 pass. The 5 failures are the ones main d6eafa54d0 has on this GPU and toolchain: agc_driver_sample_order, _grid_reference, _recipe_depth_locations, agc_driver_tessellation and agc_driver_image_array_window_past_layer_limit.
  • tools/check_conventions.py passes.

The description is updated to match.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339066525 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9685#issuecomment-6339066525). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-22T10:57:32Z. --- @MarcZX10 thanks, both points hold. **Bounding box replaced by the exact union** (`e430b0d07a`). A target now keeps the clipped scissor rectangles of its draws instead of their bounding box. Two rectangles merge only when their union is itself a rectangle: one inside the other, or the same columns that overlap or touch in rows, or the same rows that overlap or touch in columns. The store copies the rectangles' bounding box out of the image into its scratch buffer, as before, but writes to guest memory only, for each row, the union of the column runs of the rectangles that cover that row. So no pixel between two disjoint scissors is stored. At most 16 rectangles wait for a completion point: a draw that brings a 17th stores the target right after it, with all 17, and the next draw starts a new list. A target that the rectangle store does not cover (an attachment proxy, several mips or layers, a 3D or DCC surface, or results of a dispatch, fill or copy) is now stored after each draw, as on `main`, instead of whole at the next completion point. The regression is in `agc_driver_linear_target_rectangle_bound`: CPU sentinels at (30, 6) and (10, 25), inside the bounding box of the two scissors but outside both, written after both draws, and a second case with 17 one-row scissors and a CPU store between two of them. On `a27273ab06` (still the bounding box) it fails with "a drawn linear target's store overwrote CPU stores between two draws' scissor rectangles" (2 of the 2 sentinels lost); on `e430b0d07a` it passes. The case draws and waits once before its draws: without that, the target's upload ran in the same batch as the draws, after the CPU stores, so the bounding-box store wrote the CPU's own bytes back and the old test could not see it. **Review fixes since your review.** Two independent reviews of the first commit (huy's, and a four-dimension review on my side with an adversarial check of each finding) agree on these. `c95a0fd316`: - **A flush racing a completion point.** A flush from a thread that does not hold the GPU lock, such as the flush hook behind an HLE read, moved a drawn target out of the pending set before taking the lock. A flip, label or interrupt on the queue worker could then run in between: it found no pending target and recorded its signal ahead of the store. That flush now takes the GPU lock before it takes a drawn target out of the pending set. When nothing overlaps, the lock is released before the existing wait for other threads' flushes, so that wait is unchanged. - **An EOP interrupt with a label.** `workOpen` was computed before the label's store, so the interrupt could wait in an unsubmitted batch until a later submission. Both label paths, `preparePacketMemory` and `commitLabel`, now store the drawn targets before `WriteLabelOnGpu` and submit that store with the label, as the interrupt-only branch already does. - **The own-store exception.** The pending-writer check skips a target's own earlier stores only when the flush stores that target alone. With two pending images over the same bytes, the second still waits for the first's store. - **Debt entry.** Every store the draw pipeline's committer makes (for a label, an end-of-pipe interrupt or a device wait) skips a target whose range a queued draw still reads (`DrawPipeline::HeldReads`). The entry named labels only. `a27273ab06`: - **A draw's scissor lost to a concurrent flush.** `MarkDrawn` checked `dirty` in a second critical section after `MarkSliceDirty`. A flush on another thread could take the image out of the pending set in between, and the draw's scissor was then never added, so its pixels outside the earlier area were neither stored nor pending. It now checks `layerPending`, which changes only under the GPU lock; the flusher reads the drawn area after taking that lock, so it stores the widened area. - **The CPU-kept hook.** `AccessKeptByCpu` and its eviction still assumed that a store leaves CPU-written blocks alone, but a drawn target's store writes CPU-stamped blocks inside its rectangles. A hooked read of up to 1 MiB after the CPU wrote every block of the target dropped the draw's results. The hook no longer skips or evicts a drawn target; the access flushes it instead. `agc_driver_linear_target_cpu_writes` adds a `GuestMemory::Read` of row 0 between the CPU stores and the store, which returns the drawn pixels only with the fix. - **A target no longer cached** is stored after its draw, as on `main`, because the pending registry holds raw pointers. - **`agc_driver_linear_target_completion_points` skips** on a device without host import, where the target is never resident, instead of passing without testing anything. Left as they are: - **CPU store between the collect and the stamp.** A CPU store that lands in a stamped block, outside the rectangles, between the store's write-watch collect and its `MarkWritten` can later be overwritten by a stale texel. That is the same collect-to-stamp window `main`'s whole-target store has. - **A fill or copy after the draws.** Draws and dispatches that touch a drawn target's memory store it first (`9d52637676`); a fill or copy does not. A target that a fill or copy writes after its draws were listed is stored whole at the next completion point and keeps `main`'s rule that CPU-written 64 KiB blocks stay the CPU's. The debt entry says so. **Summary lines.** PPSA14363, MGS1's PS1 part, with the targets resident through #1191's import line, applied locally on both sides (so both lines show `dirty`): `main` `d6eafa54d0`, this PR's base, against this head `e430b0d07a`. Only `libSceAgcDriver.prx` is swapped, both sides have #9115's trophy fix, and both runs use the same scripted route, 300 s, `APS5_TRACE_SUMMARY_EVERY=10`, frame dumps only in the first 50 s and a trace window at 200 s, with the GPU and build locks held. Per 10 s window from 80 s, when the PS1 part starts, leaving out the window that ends with the trace write: | MGS1's PS1 part, 20 windows | `main` `d6eafa54d0` + import line | this PR `e430b0d07a` + import line | |---|---|---| | presents per 10 s | 46 to 169 | 600 | | frame p99 | 127.7 to 574.4 ms | 17.2 to 17.4 ms | | frame max | 132.4 to 574.4 ms | 17.3 to 18.9 ms | The summary lines of the trace window (200 to 220 s), `main` first: ```json {"commit":"d6eafa54d046","dirty":true,"env":{"APS5_DUMP_FRAMES":"100","APS5_DUMP_FRAMES_EVERY":"30","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"200:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32690,"title_id":"PPSA14363","title":"METAL GEAR SOLID - Master Collection Version","content_version":"03.000.000","resolution":"1920x1080","window":{"spec":"seconds 200:20","first_present":5724,"ms":20187.184},"presents":170,"frame_ms":{"p50":17.361,"p90":286.919,"p99":338.727,"max":339.723},"gpu_busy_ms_per_present":95.308,"worker_busy_pct":{"queue worker 0x0":90.450},"top_phases_ms_per_frame":{"Driver.Packet":107.404,"Graphics.Draw":106.712,"Graphics.Draw.draw_and_resource_release":106.333,"Recorder.Sync":102.637,"Driver.Packet.draw":100.244,"Driver.Draw":100.203,"Driver.Draw.draw_enqueued":98.609,"VideoOut.Flip":5.066},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-7736.json.gz"} ``` ```json {"commit":"e430b0d07ab2","dirty":true,"env":{"APS5_DUMP_FRAMES":"100","APS5_DUMP_FRAMES_EVERY":"30","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"200:20","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"AMD Radeon RX 6700 XT","driver":"AMD proprietary driver 26.10.1 (AMD proprietary shader compiler)","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600X 6-Core Processor","cpu_threads":12,"memory_mib":32690,"title_id":"PPSA14363","title":"METAL GEAR SOLID - Master Collection Version","content_version":"03.000.000","resolution":"1920x1080","window":{"spec":"seconds 200:20","first_present":11855,"ms":20003.149},"presents":1199,"frame_ms":{"p50":16.684,"p90":16.920,"p99":17.372,"max":17.645},"gpu_busy_ms_per_present":1.676,"worker_busy_pct":{"queue worker 0x0":6.284},"top_phases_ms_per_frame":{"VideoOut.Flip":13.315,"VideoOut.Flip.vblank_wait":12.638,"Driver.Packet":1.046,"Driver.Packet.draw":0.705,"Driver.Draw":0.691,"Graphics.Draw":0.618,"VideoOut.Flip.present":0.594,"Driver.Present":0.591},"trace_dropped":false,"trace":"aps5-trace-e430b0d07ab2-1592.json.gz"} ``` `tools/performance_compare.py` on these two lines: mean frame 118.748 to 16.683 ms, p99 338.727 to 17.372 ms, GPU busy per present 95.308 to 1.676 ms. `Driver.Draw` goes from 100.2 to 0.69 ms per frame; on `main`, 102.6 ms per frame is `Recorder.Sync`, the wait behind every draw's whole-target store. <details><summary><code>tools/trace_digest.py</code> on both runs' summary files</summary> `main` `d6eafa54d0` + import line: **29 intervals**, 0.0 to 292.6 s, 6556 presents AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1 (AMD proprietary shader compiler), Windows 10.0.26200, 1920x1080, commit d6eafa54d046 (dirty) | # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase | |---|---|---|---|---|---|---|---|---|---| | 1 | 0-10 | 502 | 16.7 | 17.1 | 40.4 | 841.9 | 1.3 | 2 % | VideoOut.Flip 12.1 | | 2 | 10-20 | 594 | 16.7 | 17.0 | 19.6 | 80.3 | 1.5 | 3 % | VideoOut.Flip 5.4 | | 3 | 20-30 | 576 | 16.7 | 16.9 | 20.2 | 304.6 | 5.2 | 8 % | VideoOut.Flip 13.7 | | 4 | 30-40 | 600 | 16.7 | 17.0 | 23.8 | 24.6 | 3.3 | 9 % | VideoOut.Flip 10.5 | | 5 | 40-50 | 600 | 16.7 | 16.9 | 23.4 | 24.1 | 3.6 | 13 % | VideoOut.Flip 11.0 | | 6 | 50-60 | 509 | 16.7 | 41.3 | 41.8 | 42.3 | 6.2 | 27 % | VideoOut.Flip 10.0 | | 7 | 60-70 | 436 | 20.1 | 43.9 | 44.6 | 44.7 | 11.1 | 47 % | Driver.Packet 10.8 | | 8 | 70-80 | 562 | 16.7 | 21.1 | 47.7 | 48.2 | 6.3 | 32 % | VideoOut.Flip 10.2 | | 9 | 80-90 | 169 | 17.0 | 128.6 | 225.0 | 230.4 | 44.6 | 82 % | Driver.Packet 48.8 | | 10 | 90-100 | 168 | 68.0 | 120.5 | 127.7 | 132.4 | 44.8 | 82 % | Driver.Packet 49.0 | | 11 | 100-110 | 138 | 98.7 | 127.3 | 461.5 | 480.0 | 53.8 | 85 % | Driver.Packet 61.6 | | 12 | 110-120 | 70 | 186.1 | 342.8 | 435.4 | 435.4 | 121.0 | 91 % | Driver.Packet 132.4 | | 13 | 120-130 | 153 | 16.3 | 162.8 | 202.7 | 205.8 | 49.6 | 82 % | Driver.Packet 53.8 | | 14 | 130-140 | 129 | 88.8 | 168.6 | 182.6 | 183.0 | 61.1 | 85 % | Driver.Packet 67.0 | | 15 | 140-151 | 108 | 147.7 | 188.9 | 204.0 | 206.1 | 73.1 | 88 % | Driver.Packet 81.8 | | 16 | 151-161 | 126 | 16.8 | 184.4 | 542.9 | 567.7 | 61.0 | 87 % | Driver.Packet 69.7 | | 17 | 161-171 | 46 | 366.7 | 481.7 | 520.1 | 520.1 | 189.0 | 94 % | Driver.Packet 210.8 | | 18 | 171-181 | 50 | 362.6 | 421.5 | 444.9 | 444.9 | 174.3 | 94 % | Driver.Packet 194.0 | | 19 | 181-191 | 74 | 207.8 | 297.5 | 367.2 | 367.2 | 114.0 | 91 % | Driver.Packet 124.8 | | 20 | 191-202 | 134 | 82.2 | 167.0 | 193.2 | 201.2 | 58.7 | 86 % | Driver.Packet 64.7 | | 21 | 202-212 | 88 | 17.4 | 249.6 | 286.9 | 286.9 | 92.0 | 90 % | Driver.Packet 103.9 | | 22 | 212-222 | 70 | 214.0 | 314.9 | 339.7 | 339.7 | 115.7 | 90 % | Driver.Packet 130.2 | | 23 | 222-232 | 60 | 283.8 | 345.4 | 370.2 | 370.2 | 139.6 | 93 % | Driver.Packet 156.2 | | 24 | 232-242 | 74 | 195.6 | 313.6 | 329.6 | 329.6 | 113.8 | 91 % | Driver.Packet 124.6 | | 25 | 242-252 | 82 | 16.8 | 276.7 | 300.8 | 300.8 | 99.5 | 90 % | Driver.Packet 110.9 | | 26 | 252-262 | 83 | 16.9 | 273.7 | 300.3 | 300.3 | 98.8 | 90 % | Driver.Packet 108.4 | | 27 | 262-272 | 156 | 85.0 | 137.3 | 143.3 | 145.2 | 48.5 | 82 % | Driver.Packet 53.0 | | 28 | 272-282 | 145 | 16.8 | 112.3 | 546.6 | 559.0 | 51.4 | 84 % | Driver.Packet 59.2 | | 29 | 282-293 | 54 | 16.7 | 556.9 | 574.4 | 574.4 | 155.0 | 92 % | Driver.Packet 174.4 | ``` p99 ms _....___=:##---@%#*-=+*+++:@@ 0-574.4 gpu ms ......_.::-*:---@%+-=*#+++::# 0-189.0 ``` This PR `e430b0d07a` + import line: **29 intervals**, 0.0 to 290.3 s, 17255 presents AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1 (AMD proprietary shader compiler), Windows 10.0.26200, 1920x1080, commit e430b0d07ab2 (dirty) | # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase | |---|---|---|---|---|---|---|---|---|---| | 1 | 0-10 | 503 | 16.7 | 17.0 | 30.5 | 801.0 | 1.3 | 2 % | VideoOut.Flip 12.6 | | 2 | 10-20 | 594 | 16.7 | 17.0 | 22.4 | 77.9 | 1.8 | 3 % | VideoOut.Flip 3.3 | | 3 | 20-30 | 574 | 16.7 | 16.9 | 24.4 | 304.1 | 4.9 | 8 % | VideoOut.Flip 12.6 | | 4 | 30-40 | 598 | 16.7 | 17.3 | 19.0 | 40.3 | 1.4 | 2 % | VideoOut.Flip 4.0 | | 5 | 40-50 | 598 | 16.7 | 17.3 | 18.3 | 36.4 | 1.4 | 2 % | VideoOut.Flip 2.5 | | 6 | 50-60 | 600 | 16.7 | 17.7 | 18.2 | 18.9 | 1.5 | 2 % | VideoOut.Flip 2.3 | | 7 | 60-70 | 600 | 16.8 | 17.6 | 18.0 | 18.7 | 1.7 | 3 % | VideoOut.Flip 2.3 | | 8 | 70-80 | 600 | 16.7 | 17.3 | 18.1 | 19.6 | 2.4 | 2 % | VideoOut.Flip 7.4 | | 9 | 80-90 | 600 | 16.7 | 16.9 | 17.3 | 17.4 | 3.4 | 6 % | VideoOut.Flip 13.7 | | 10 | 90-100 | 600 | 16.7 | 16.9 | 17.2 | 17.3 | 1.9 | 8 % | VideoOut.Flip 12.8 | | 11 | 100-110 | 600 | 16.7 | 16.9 | 17.4 | 17.6 | 1.7 | 9 % | VideoOut.Flip 12.3 | | 12 | 110-120 | 600 | 16.7 | 16.9 | 17.2 | 18.9 | 1.7 | 6 % | VideoOut.Flip 13.2 | | 13 | 120-130 | 600 | 16.7 | 16.9 | 17.2 | 17.4 | 1.7 | 5 % | VideoOut.Flip 13.8 | | 14 | 130-140 | 600 | 16.7 | 16.9 | 17.2 | 17.3 | 1.6 | 3 % | VideoOut.Flip 14.7 | | 15 | 140-150 | 600 | 16.7 | 16.9 | 17.4 | 17.6 | 3.0 | 3 % | VideoOut.Flip 15.0 | | 16 | 150-160 | 600 | 16.7 | 16.9 | 17.2 | 17.8 | 5.4 | 4 % | VideoOut.Flip 14.5 | | 17 | 160-170 | 600 | 16.7 | 16.9 | 17.2 | 17.5 | 5.4 | 4 % | VideoOut.Flip 14.6 | | 18 | 170-180 | 600 | 16.7 | 16.9 | 17.2 | 17.5 | 5.4 | 4 % | VideoOut.Flip 14.5 | | 19 | 180-190 | 600 | 16.7 | 16.9 | 17.3 | 17.6 | 5.3 | 4 % | VideoOut.Flip 14.6 | | 20 | 190-200 | 600 | 16.7 | 16.9 | 17.2 | 17.4 | 1.6 | 6 % | VideoOut.Flip 13.5 | | 21 | 200-210 | 600 | 16.7 | 16.9 | 17.4 | 17.6 | 1.7 | 6 % | VideoOut.Flip 13.3 | | 22 | 210-220 | 588 | 16.7 | 16.9 | 17.4 | 217.1 | 1.7 | 6 % | VideoOut.Flip 13.7 | | 23 | 220-230 | 600 | 16.7 | 16.9 | 17.2 | 17.4 | 1.7 | 6 % | VideoOut.Flip 13.3 | | 24 | 230-240 | 600 | 16.7 | 16.9 | 17.2 | 17.7 | 1.7 | 6 % | VideoOut.Flip 13.4 | | 25 | 240-250 | 600 | 16.7 | 16.9 | 17.3 | 17.4 | 1.7 | 6 % | VideoOut.Flip 13.4 | | 26 | 250-260 | 600 | 16.7 | 16.9 | 17.3 | 17.7 | 1.7 | 6 % | VideoOut.Flip 13.3 | | 27 | 260-270 | 600 | 16.7 | 16.9 | 17.3 | 17.8 | 1.7 | 6 % | VideoOut.Flip 13.4 | | 28 | 270-280 | 600 | 16.7 | 16.9 | 17.3 | 17.4 | 1.7 | 6 % | VideoOut.Flip 13.3 | | 29 | 280-290 | 600 | 16.7 | 16.9 | 17.3 | 17.4 | 1.7 | 6 % | VideoOut.Flip 13.4 | ``` p99 ms @##*+++++++++++++++++++++++++ 0-30.5 gpu ms :-%::--=*-----+@@@@---------- 0-5.4 ``` </details> The trace files stay local, because the runs come from a commercial title; I asked on #9373 whether summary lines plus the tools' output are enough for such a title ([comment](https://github.com/boykopovar/AnyPS5/pull/9373#issuecomment-6337623346)). A local counter over a 300 s run of the PS1 part (not committed) shows every store of these targets covering one rectangle, with no store at a draw and no fallback, so the 16-rectangle limit costs this title nothing. **Tested** on `e430b0d07a`, RX 6700 XT, AMD Windows driver 32.0.21045.16010: - The focused set of 15 tests passes 3 of 3: the 4 new executables (6 `ctest` entries), `agc_driver_linear_target_resident`, `agc_driver_address_passes` and `_targets_split`, `agc_driver_clamped_global_fill`, `agc_driver_flip_stores_small_results`, `agc_driver_storage_flush_ordering`, `agc_driver_storage_read_during_idle_store`, `agc_driver_store_idle_results` and `agc_driver_store_over_untracked`. - **Khronos validation layer**, the same 15 tests: 15 of 15 pass on `e430b0d07a`. With `main`'s production files at `d6eafa54d0` and these tests, 12 of 15 pass: `completion_stores`, `cpu_writes` and `rectangle_bound` fail, the last with all 3 outside sentinels and both sentinels between the rectangles lost. Both sides have 0 `VUID-` lines, and `VK_LOADER_DEBUG=layer` shows the layer inserted 25 times with no "was not found". - **Red, one fix at a time:** without the `AccessKeptByCpu` check, `cpu_writes` fails at the new driver read ("a driver read of row 0 before the store: pixel (0, 0) holds (0.000000, 0.000000, 0.000000, 1.000000), not the second draw's"). With `a27273ab06`'s bounding box, `rectangle_bound` fails as above. - **`ctest -R "^agc_"`** (896 tests): 891 pass. The 5 failures are the ones `main` `d6eafa54d0` has on this GPU and toolchain: `agc_driver_sample_order`, `_grid_reference`, `_recipe_depth_locations`, `agc_driver_tessellation` and `agc_driver_image_array_window_past_layer_limit`. - `tools/check_conventions.py` passes. The description is updated to match.
adriadam10 commented 2026-10-22 20:48:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-22T20:48:42Z.

Review: CHANGES_REQUESTED


The full Linux Build (llvmpipe, run 39837492452) fails on the new test at 10a8319a94:

  • agc_driver_linear_target_draw_bindings: AGC graphics: the second copying draw submitted recorded work (LinearTargetDrawBindings.cpp:299, recorder->Submissions() == submitted + 1). main does not have this test, so it is not a pre-existing failure.
  • The runner has no /dev/udmabuf (shared direct memory is copied instead of imported, dma-buf imports keep write protection: unknown), and the test passes HostImportFor(...) anyway, so the import here is not write-watched. With that, the second copying draw ends up submitting an extra batch.

Please decide whether that extra submit is correct for an unwatched import (then the test should assert what holds in both cases), or whether the store before a synchronous draw (10a8319a94) should not submit there. Either way the test has to pass on the CI runner, which cannot import dma-bufs; the earlier lavapipe runs from @jotitadev predate this test.

The rest of the diff is unchanged from the previous review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5620664290 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9685#pullrequestreview-5620664290). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-22T20:48:42Z. **Review:** CHANGES_REQUESTED --- The full Linux Build (llvmpipe, run 39837492452) fails on the new test at `10a8319a94`: - `agc_driver_linear_target_draw_bindings`: `AGC graphics: the second copying draw submitted recorded work` (`LinearTargetDrawBindings.cpp:299`, `recorder->Submissions() == submitted + 1`). `main` does not have this test, so it is not a pre-existing failure. - The runner has no `/dev/udmabuf` (`shared direct memory is copied instead of imported`, `dma-buf imports keep write protection: unknown`), and the test passes `HostImportFor(...)` anyway, so the import here is not write-watched. With that, the second copying draw ends up submitting an extra batch. Please decide whether that extra submit is correct for an unwatched import (then the test should assert what holds in both cases), or whether the store before a synchronous draw (`10a8319a94`) should not submit there. Either way the test has to pass on the CI runner, which cannot import dma-bufs; the earlier lavapipe runs from @jotitadev predate this test. The rest of the diff is unchanged from the previous review.
MarcZX10 commented 2026-10-23 03:31:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T03:31:26Z.

Review: COMMENTED


Thanks for the update. The PR now addresses the previously identified rectangle-union gap and reports the new completion-point / CPU-write coverage. However, the current exact head still has an unresolved CI-specific failure from the latest independent review: agc_driver_linear_target_draw_bindings fails 3/3 on the unwatched import path (the default and llvmpipe/CI path) because the second copying draw submits an extra batch. Please resolve that expectation/behavior and rerun the focused test on the CI-relevant path; the current hosted product jobs are skipped. I have not rerun locally because this host cannot execute the required Vulkan path.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5623567466 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9685#pullrequestreview-5623567466). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T03:31:26Z. **Review:** COMMENTED --- Thanks for the update. The PR now addresses the previously identified rectangle-union gap and reports the new completion-point / CPU-write coverage. However, the current exact head still has an unresolved CI-specific failure from the latest independent review: `agc_driver_linear_target_draw_bindings` fails 3/3 on the unwatched import path (the default and llvmpipe/CI path) because the second copying draw submits an extra batch. Please resolve that expectation/behavior and rerun the focused test on the CI-relevant path; the current hosted product jobs are skipped. I have not rerun locally because this host cannot execute the required Vulkan path.
MarcZX10 commented 2026-10-24 12:58:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:58:25Z.

Review: APPROVED


Reviewed current head d6d8966bba, including the later per-64-KiB completion-generation fix and the latest merge from main. The generation fallback keeps older completion stamps from erasing newer draw results in blocks without a CPU write, while the tests cover the direct-write ordering and drawn-rectangle preservation cases. The author reports the current focused set passing 54/54 three times on an RX 6700 XT, and 54/54 with the Khronos validation layer and zero VUID lines; the reported 1011/1014 full agc|shader result has the same three sample-order failures on main. I did not reproduce GPU tests locally on this host. Hosted eligibility, conventions, labels, and report pass; product build jobs are skipped by eligibility. The complementary #8246 byte-exact merge remains a separate follow-up proposed to land after this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638325518 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9685#pullrequestreview-5638325518). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T12:58:25Z. **Review:** APPROVED --- Reviewed current head d6d8966bbab67f53ad2d8d48eaa6b33b0a3e0871, including the later per-64-KiB completion-generation fix and the latest merge from main. The generation fallback keeps older completion stamps from erasing newer draw results in blocks without a CPU write, while the tests cover the direct-write ordering and drawn-rectangle preservation cases. The author reports the current focused set passing 54/54 three times on an RX 6700 XT, and 54/54 with the Khronos validation layer and zero VUID lines; the reported 1011/1014 full `agc|shader` result has the same three sample-order failures on main. I did not reproduce GPU tests locally on this host. Hosted eligibility, conventions, labels, and report pass; product build jobs are skipped by eligibility. The complementary #8246 byte-exact merge remains a separate follow-up proposed to land after this PR.
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!9685
No description provided.