Skip to content

perf(agc): read dropped sampled snapshots straight into their upload staging buffer - #9884

Merged
oneandonlydean merged 13 commits into
boykopovar:mainfrom
thuanquang:perf/snapshot-staging-upload
Nov 10, 2026
Merged

oneandonlydean merged 13 commits into
boykopovar:mainfrom
thuanquang:perf/snapshot-staging-upload

Conversation

@thuanquang

@thuanquang thuanquang commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

This reopens the change I closed on 2026-10-23 in favour of #8026. It is now rebased past #8026 and keeps #8026's spare pool for the snapshots that still use a vector.

Since #6982, a sampled snapshot of a tracked or hinted surface over 256 KiB keeps no bytes after its upload, and since #8026 its vector then goes to a spare pool. To build one, cachedTexture does three things on main 91ecd2d974:

  • it takes a vector of the surface size from that pool, or allocates and zero-fills a new one (ShaderResources.cpp:1081-1082);
  • it reads the guest surface into the vector (:1117);
  • the Texture copies the vector into a pooled staging Buffer (Texture.cpp:489-490).

The vector is parked afterwards (ShaderResources.cpp:1128).

With Uncompressed keys, such a snapshot is now read straight into the staging Buffer:

  • ShaderResources.cpp, cachedTexture:
    • The drop test runs before the read, on the same inputs as main's drop after the upload: over 256 KiB, and either entry.generation != 0 (the snapshot generation) or the untracked-memory hint when no write is pending.
    • A dropped Uncompressed snapshot gets a pooled host-visible Buffer (TRANSFER_SRC). ReadTextureSurface fills it, and the texture is built from it.
    • It takes nothing from the spare pool and parks nothing of its own. If the entry it replaces kept a vector, that vector goes to the pool.
    • It still runs the pool's expiry, so a spare unused for more than 16 presents is released at the next snapshot, as on main. The expiry loop moves into expireSpareSnapshots, which parkSnapshot and spareSnapshot now call too.
    • The staging path passes feat(agc): sample 1D arrays past maxImageArrayLayers as rows of a 2D image #12246's layerRows as the vector path does, so a dropped snapshot of a 1D array past maxImageArrayLayers is still laid out as rows of a 2D image.
    • Kept snapshots and snapshots with other keys (DCC clear keys, ClearSingle) keep the vector and the pool. A surface that main clears on the GPU (perf(agc): clear a fast-cleared sampled texture on the GPU #13648) keeps no snapshot, as before, and still parks the vector of the entry it replaces. The uncached path (APS5_NO_TEXTURE_CACHE) is unchanged.
  • Texture.cpp (declared in Texture.hpp): the span constructor and a new constructor that takes the staging Buffer as a std::shared_ptr (with depthCompare and layerRows) both delegate to one private constructor. It allocates a staging Buffer and copies the span into it only when none was handed in. The rest of the upload is main's: since fix(agc): reuse one tiled and one linear texture upload scratch per recorded batch #10773, with a recorder, it copies the staging Buffer into the batch's tiled upload scratch and keeps the Buffer with the batch (Texture.cpp:513-526 on this head).

For a dropped Uncompressed snapshot, this removes the vector allocation, its zero-fill and the surface-sized memcpy. The staging Buffer goes back to the BufferPool when the recorder releases it, as on main.

A reused pooled Buffer still holds earlier bytes, so this relies on ReadTextureSurface writing every byte for Uncompressed keys. GuestMemory::ReadCommitted does: it copies the whole range when it is accessible, and otherwise zero-fills the range and copies the committed parts (copyCommitted, GuestMemory.cpp:2927-2934 on 91ecd2d974, which ReadCommitted calls at :2944). On Windows, since #10575, each of those copies is a ReadProcessMemory read. If it fails because a page is not readable, the copy goes page by page and zero-fills every page it cannot read; since #10498, a short read or any other read error throws, and nothing is uploaded from that Buffer (readPages, visitReadablePages and copyCommittedBytes, :2867-2905). #8026 relies on the same contract for reused vectors, and on 91ecd2d974, DepthSurface.cpp:1603 already reads with ReadCommitted straight into a pooled Buffer.

Changes since the close (old head 388daf981f):

Overlap:

Why

PPSA14363 (METAL GEAR SOLID - Master Collection Version): in my runs of a timing build on main 379b1dca32 (below), each page turn in the launcher's Screenplay Book sampled a new snapshot of a 15360x8640 R8 linear surface (126.6 MiB), which was dropped after its upload. I have not checked the snapshot itself again on a current build; the page-turn pair on this head is under Tested.

#8026 releases a spare once it has gone unused for more than 16 presents, and page turns come seconds apart (7 s in my scripted route, about 400 presents). So in my runs, main allocated and zero-filled a new 126.6 MiB vector on every turn, read the surface into it and copied it into the staging buffer.

The same holds for any dropped Uncompressed snapshot: it always pays the memcpy, and it pays the allocation and zero-fill whenever no spare of its size was parked in the last 16 presents.

I measured this with a local timing build on main 379b1dca32, which has #8026 (timing probes, not in this PR; run with APS5_PROFILE_DRAW=1 and APS5_TRACE_SUMMARY_EVERY=10; it also carried a local change of mine, not part of any PR, that uploads a linear snapshot without the identity detile and changes only the steps after the memcpy). Two runs, each opening the book and turning 8 pages: none of the 18 snapshot builds took a vector from the pool. Per page turn (16 turns, Ryzen 5 5600X):

Step Range Median
vector allocation and zero-fill 17.4-31.1 ms 23.5 ms
guest read (ReadTextureSurface) 7.1-14.6 ms 9.2 ms
memcpy into the staging Buffer 6.6-15.1 ms 8.7 ms

This PR removes the first and the last step, which took 24.1-46.2 ms per turn together (median 31.6 ms); the read stays. Keeping spares longer would avoid only the allocation and zero-fill, by holding 126.6 MiB of host memory between turns, and would keep the memcpy. The page-turn frame times of main and of this head are under Tested.

Tested

Head ac57b02043 on main 4f41f4c375 (2026-11-03). RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.16010, Windows 11 26200, WinLibs GCC 15.2.0 r7 Release, ANYPS5_REQUIRE_VULKAN=1.

Integration since 0386e61741, the head of the earlier results:

New test: agc_snapshot_read_into_staging (agc_driver_recorder_tests --snapshot-read-into-staging-only) samples through CachedSampledTexture on write-watched guest allocations. On the head, in the validation-layer run (ctest -V), every row below printed passed and none printed not tested. The test took 0.21-1.59 s in the three plain runs; its CTest TIMEOUT is 30 s.

  • GPU-clear guard (181f0ab5e7, needs no BC):
    • An uncompressed 256 KiB 8_8_8_8 snapshot keeps its vector. Once its keys read 1111, the GPU clear that replaces it must park that vector in the spare pool.
    • A new 1111 surface of the same size, cleared on the GPU 16 presents later, must leave that spare alone, and the next snapshot, one present later, releases it.
    • The row also passes on main's production files.
  • Dropped snapshots of four surfaces: a linear 512x512 one, a 64KB_R_X one, a padded linear 600x300 one (rows of 640 texels), and a three-level linear one whose level-1 centre pages are not committed, with committed levels stored before and after them.
    • Before each, a pooled staging Buffer of the surface's size is filled with 0xee and returned to the pool.
    • Each snapshot must leave the spare pool empty.
    • It must upload from that reused Buffer: a probe Buffer of that size must not get it back.
    • It must sample the guest bytes in every level, with zeros in the uncommitted pages.
    • It must be remade after a driver store of the bytes already there, since it kept none to compare.
  • 1D array laid out as rows (e9b72ae83a, needs nullDescriptor): a watched linear 1D array of 8-texel 8_8_8_8 slices, bound as a 2D image through ShaderResources.
    • The row's own context caps maxImageArrayLayers at 2048. The RX 6700 XT reports 8192, which allows every array a T# can describe.
    • The array has 2049 slices (524,544 bytes), so cachedTexture drops its snapshot, and the texture lays it out as rows of a 2D image.
    • It must be a snapshot, not a storage view, park no vector, and sample the centre slice at the centre of the image.
  • The pool (BC5 producers, need BC):
    • A fast-cleared BC5 snapshot still parks its vector.
    • A dropped Uncompressed snapshot of the same size 16 presents later leaves that spare alone, and the next snapshot, one present later, releases it.
    • A dropped snapshot 16 presents after a spare was parked keeps the spare. One 17 presents after it releases the spare.
  • The ctest entry unsets APS5_SYNC_TEXTURE_UPLOAD, APS5_DUMP_TEXTURE, APS5_NO_TEXTURE_CACHE and the buffer pool switches (APS5_BUFFER_POOL_SLOTS, APS5_BUFFER_POOL_SHARED, APS5_NO_BUFFER_CLASSES, APS5_STAGING_POOL_MIB). Each of them changes how a snapshot uploads or which Buffer the pool hands out.
  • Negative control (a), main's production files: this head with Texture.hpp, ShaderResources.cpp and Texture.cpp from 4f41f4c375 fails in 4 of 4 runs (3 plain, 1 with the validation layer): AGC graphics: the dropped snapshot of the linear surface parked a vector in the spare pool. The head passes in 4 of 4 runs. With main's files the test stops at that row, so the 1D-array row does not run there.
  • Negative control (b), layerRows dropped from the staging path: with false instead of layerRows in the staging createTexture call of cachedTexture, the test fails at the 1D-array row, after the four other dropped rows pass: AGC graphics: a texture array with more layers than maxImageArrayLayers is not implemented (1 run). With the file restored, the head passes again.

Related tests: 45 tests, selected by name with ctest -N -R 'detile_small_elements|recorder|snapshot|sampled_cache|partially_resident|recover_.*allocation|read_written_staging|staged_clear_sampled_read|sampled_storage_base_level_usage|buffer_pool|storage_cache_budget|clear_keys|sampled_clear'.

Validation layer: the same 45 tests with ctest -V, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan-ValidationLayers vulkan-sdk-1.4.363.0), VK_LOADER_DEBUG=layer, VK_LOADER_LAYERS_DISABLE=~implicit~, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1, on main's production files with these tests and on the head. Each log shows the loader inserting VK_LAYER_KHRONOS_validation 35 times, once in each of the 35 tests that create a Vulkan instance (agc_snapshot_read_into_staging among them; the other 10 print no loader output). Neither log has was not found but was requested, a VUID- line or a Validation Error. Results as above: 44 of 45 and 45 of 45.

Title, on the previous head 1b0577cc92 (the same changed lines as this head, on main 91ecd2d974): PPSA14363, launcher → Screenplay Book, 8 page turns (R1) 7 s apart, scripted pad input. 150 s legs of main 91ecd2d9743b831b575d293e6c8fafbe737e1e88 (M) and of 1b0577cc927bdde256dc6a54697f9c57f2d340af (P), two clean builds, in the order M1, P1, M2, P2 (2026-11-03).

  • Each arm runs in its own folder. One 150 s run of the same route warmed each folder's shader cache before M1, and no leg's log shows a shader disk cache miss. Each leg started the title anew, and each folder's libSceAgcDriver.prx was checked by hash against its build.
  • Each leg set only APS5_TRACE_SECONDS=60:70 and the pad input variables. No leg's trace dropped events.
  • The GPU and build locks were held for every leg. Before each leg, a check found no build, test, other emulator run or other game running, then 30 s of quiet CPU. League of Legends may have been running; the check does not count it.
  • Per page turn, the analysis takes the longest present interval from 1 s before to 1.5 s after the press, the longest draw-committer span overlapping it, and the longest GPU batch overlapping it or starting within 50 ms after it.

Per leg, 8 page turns each (ms; medians over the turns of the leg):

Leg Page-turn frame median Range Longest committer span Longest GPU batch Window p99 Window max
M1 (main 91ecd2d974) 103.35 96.3-126.9 42.1 27.65 17.428 126.883
P1 (1b0577cc92) 77.95 74.4-92.5 15.7 27.95 17.433 92.502
M2 (main 91ecd2d974) 100.5 97.8-126.9 43.2 27.6 17.505 126.907
P2 (1b0577cc92) 74.1 68.3-92.3 15.6 28.25 17.572 92.258

All turns of each arm: main 91ecd2d974 102.7 ms median (96.3-126.9, 16 turns), committer span 42.7 ms, GPU batch 27.6 ms; 1b0577cc92 77.3 ms median (68.3-92.5, 16 turns), committer span 15.6 ms, GPU batch 28.2 ms. Every page turn still drops frames with the change.

Over the whole 70 s window, in each of the 3 adjacent pairs (M1-P1, M2-P1, M2-P2), the frame p50 is the same (16.683 ms). With the change the mean frame is 0.07-0.08 ms shorter, there are 2.4-2.8 more presents per 10 s, and the GPU is busy 0.002-0.006 ms less per present.

Traces of all four legs, each with its tools/trace_digest.py output, as CONTRIBUTING asks: M1: trace, digest; P1: trace, digest; M2: trace, digest; P2: trace, digest. They hold only AnyPS5's scope and thread names, timings, batch ids and present numbers; I checked each for anything from the title.

Summary lines of the four legs (M1, P1, M2, P2):

{"commit":"91ecd2d9743b","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"60:70"},"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 60:70","first_present":3572,"ms":70003.123},"presents":4139,"frame_ms":{"p50":16.683,"p90":16.910,"p99":17.428,"max":126.883},"gpu_busy_ms_per_present":6.837,"worker_busy_pct":{"queue worker 0x0":10.513},"top_phases_ms_per_frame":{"VideoOut.Flip":13.645,"VideoOut.Flip.vblank_wait":12.619,"Driver.Packet":1.775,"Graphics.Draw":1.429,"Graphics.Draw.draw_and_resource_release":1.269,"Driver.Packet.draw":1.203,"Driver.Draw":1.183,"VideoOut.Flip.present":0.935},"trace_dropped":false,"trace":"aps5-trace-91ecd2d9743b-14216.json.gz"}
{"commit":"1b0577cc927b","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"60:70"},"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 60:70","first_present":3575,"ms":70003.079},"presents":4159,"frame_ms":{"p50":16.683,"p90":16.910,"p99":17.433,"max":92.502},"gpu_busy_ms_per_present":6.831,"worker_busy_pct":{"queue worker 0x0":10.011},"top_phases_ms_per_frame":{"VideoOut.Flip":13.686,"VideoOut.Flip.vblank_wait":12.650,"Driver.Packet":1.682,"Graphics.Draw":1.342,"Graphics.Draw.draw_and_resource_release":1.191,"Driver.Packet.draw":1.167,"Driver.Draw":1.148,"VideoOut.Flip.present":0.929},"trace_dropped":false,"trace":"aps5-trace-1b0577cc927b-8828.json.gz"}
{"commit":"91ecd2d9743b","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"60:70"},"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 60:70","first_present":3572,"ms":70003.310},"presents":4140,"frame_ms":{"p50":16.683,"p90":16.909,"p99":17.505,"max":126.907},"gpu_busy_ms_per_present":6.833,"worker_busy_pct":{"queue worker 0x0":10.440},"top_phases_ms_per_frame":{"VideoOut.Flip":13.644,"VideoOut.Flip.vblank_wait":12.612,"Driver.Packet":1.762,"Graphics.Draw":1.413,"Graphics.Draw.draw_and_resource_release":1.260,"Driver.Packet.draw":1.195,"Driver.Draw":1.175,"VideoOut.Flip.present":0.939},"trace_dropped":false,"trace":"aps5-trace-91ecd2d9743b-8032.json.gz"}
{"commit":"1b0577cc927b","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"60:70"},"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 60:70","first_present":3574,"ms":70003.066},"presents":4157,"frame_ms":{"p50":16.683,"p90":16.921,"p99":17.572,"max":92.258},"gpu_busy_ms_per_present":6.829,"worker_busy_pct":{"queue worker 0x0":10.067},"top_phases_ms_per_frame":{"VideoOut.Flip":13.663,"VideoOut.Flip.vblank_wait":12.616,"Driver.Packet":1.692,"Graphics.Draw":1.347,"Graphics.Draw.draw_and_resource_release":1.196,"Driver.Packet.draw":1.184,"Driver.Draw":1.164,"VideoOut.Flip.present":0.965},"trace_dropped":false,"trace":"aps5-trace-1b0577cc927b-2116.json.gz"}
tools/performance_compare.py --require-matching-context M1 against P1

Performance comparison

Capture Commit Trace Presents Window (ms)
baseline 91ecd2d aps5-trace-91ecd2d9743b-14216.json.gz 4139 70003.123
candidate 1b0577c aps5-trace-1b0577cc927b-8828.json.gz 4159 70003.079
  • Compare captures from the same machine, title, content version and scene; matching recorded metadata cannot verify the physical machine or scene.
  • Changes are candidate minus baseline. A negative frame-time change means a shorter frame interval.
  • A missing top phase is unreported, not zero; its change is unavailable.
  • Worker busy changes are percentage points; change (%) is relative to the baseline. Workers are matched by their recorded names; a missing worker is unreported, not idle.

Frame and GPU times (ms)

Metric Baseline Candidate Change Change (%)
frame_ms.p50 16.683 16.683 +0.000 +0.000
frame_ms.p90 16.910 16.910 +0.000 +0.000
frame_ms.p99 17.428 17.433 +0.005 +0.029
frame_ms.max 126.883 92.502 -34.381 -27.097
mean_frame_ms 16.913 16.832 -0.081 -0.481
gpu_busy_ms_per_present 6.837 6.831 -0.006 -0.088

Top phases (ms per frame)

Metric Baseline Candidate Change Change (%)
Driver.Draw 1.183 1.148 -0.035 -2.959
Driver.Packet 1.775 1.682 -0.093 -5.239
Driver.Packet.draw 1.203 1.167 -0.036 -2.993
Graphics.Draw 1.429 1.342 -0.087 -6.088
Graphics.Draw.draw_and_resource_release 1.269 1.191 -0.078 -6.147
VideoOut.Flip 13.645 13.686 +0.041 +0.300
VideoOut.Flip.present 0.935 0.929 -0.006 -0.642
VideoOut.Flip.vblank_wait 12.619 12.650 +0.031 +0.246

Worker busy time (%)

Metric Baseline Candidate Change (pp) Change (%)
queue worker 0x0 10.513 10.011 -0.502 -4.775
tools/trace_digest.py of the M1 trace

seconds 60:70 from present 3572: 4139 presents, frame p50 16.7 / p90 16.9 / p99 17.4 / max 126.9 ms, GPU busy 6.8 ms per present
AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1 (AMD proprietary shader compiler), Windows 10.0.26200, 1920x1080, commit 91ecd2d, dropped: no

{"commit":"91ecd2d9743b","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"60:70"},"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 60:70","first_present":3572,"ms":70003.123},"presents":4139,"frame_ms":{"p50":16.683,"p90":16.91,"p99":17.428,"max":126.883},"gpu_busy_ms_per_present":6.837,"worker_busy_pct":{"queue worker 0x0":10.513},"top_phases_ms_per_frame":{"VideoOut.Flip":13.645,"VideoOut.Flip.vblank_wait":12.619,"Driver.Packet":1.775,"Graphics.Draw":1.429,"Graphics.Draw.draw_and_resource_release":1.269,"Driver.Packet.draw":1.203,"Driver.Draw":1.183,"VideoOut.Flip.present":0.935},"trace_dropped":false,"trace":"aps5-trace-91ecd2d9743b-14216.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 4142: 126.9 ms at 9509 ms: Driver.Packet (queue worker 0x0) 90.0, Graphics.Draw (draw committer) 89.5, Graphics.Draw.draw_and_resource_release (draw committer) 89.4, Driver.Packet.pipeline_drain (queue worker 0x0) 89.0
  • present 5362: 111.4 ms at 30213 ms: Driver.WorkerWait (queue worker 0x0) 67.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 67.3, Driver.Packet (queue worker 0x0) 43.1, Graphics.Draw (draw committer) 42.8
  • present 4544: 105.3 ms at 16367 ms: Driver.WorkerWait (queue worker 0x0) 57.6, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 57.6, Driver.Packet (queue worker 0x0) 46.6, Graphics.Draw (draw committer) 46.2
  • present 6190: 103.4 ms at 44261 ms: Driver.WorkerWait (queue worker 0x0) 59.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 59.5, Driver.Packet (queue worker 0x0) 42.9, Graphics.Draw (draw committer) 42.7
  • present 7017: 103.3 ms at 58291 ms: Driver.WorkerWait (queue worker 0x0) 57.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 57.0, Driver.Packet (queue worker 0x0) 45.3, Graphics.Draw (draw committer) 44.6

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.0 (0 %) 0.0 (0 %) 16.9 0.6 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
queue worker 0x0 1.0 (6 %) 15.1 (89 %) 0.9 2.9 Driver.Packet 1.0, Driver.Completion 0.0
draw committer 0.8 (5 %) 0.0 (0 %) 16.1 1.5 Graphics.Draw 0.7, Vulkan.DrawFromRecipe 0.1
presenter 0.8 (5 %) 12.9 (76 %) 3.3 0.0 VideoOut.Flip 13.6, Driver.Present 0.0
gpu 6.8 (40 %) 0.0 (0 %) 10.1 0.0 batch 6.8

Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 15.1, Driver.WorkerWait.idle_and_completion_poll 15.1, VideoOut.Flip 13.6, VideoOut.Flip.vblank_wait 12.6, batch 6.8, Driver.Packet 1.0, VideoOut.Flip.present 0.9, Driver.Present 0.9, Graphics.Draw 0.7, Graphics.Draw.draw_and_resource_release 0.6

Longest waits

  • Driver.WorkerWait (queue worker 0x0) 78.7 ms at 30202 ms, present 5361
  • Driver.WorkerWait (queue worker 0x0) 72.2 ms at 44248 ms, present 6189
  • Driver.WorkerWait (queue worker 0x0) 70.4 ms at 37274 ms, present 5779
  • Driver.WorkerWait (queue worker 0x0) 70.2 ms at 16354 ms, present 4543
  • Driver.WorkerWait (queue worker 0x0) 70.0 ms at 58278 ms, present 7016
  • Driver.WorkerWait (queue worker 0x0) 68.0 ms at 51322 ms, present 6605
  • Driver.WorkerWait (queue worker 0x0) 64.4 ms at 23294 ms, present 4952
  • Driver.WorkerWait (queue worker 0x0) 59.3 ms at 58427 ms, present 7018
  • Driver.WorkerWait (queue worker 0x0) 51.5 ms at 37422 ms, present 5781
  • Driver.WorkerWait (queue worker 0x0) 49.0 ms at 9496 ms, present 4141

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

  • batch 1142: 33.4 ms at 9636 ms, present 4143: GPU no ranges; recorded by Graphics.Draw (draw committer) 89.1, Graphics.Draw.draw_and_resource_release (draw committer) 89.1, Resources.Complete (draw committer) 23.6, Resources.Prepare (draw committer) 1.2
  • batch 6892: 28.2 ms at 58395 ms, present 7018: GPU no ranges; recorded by Graphics.Draw (draw committer) 44.3, Graphics.Draw.draw_and_resource_release (draw committer) 44.2, Resources.Prepare (draw committer) 0.0
  • batch 4418: 27.9 ms at 37389 ms, present 5781: GPU no ranges; recorded by Graphics.Draw (draw committer) 42.7, Graphics.Draw.draw_and_resource_release (draw committer) 42.6, Resources.Prepare (draw committer) 0.0
  • batch 3582: 27.7 ms at 30325 ms, present 5363: GPU no ranges; recorded by Graphics.Draw (draw committer) 42.2, Graphics.Draw.draw_and_resource_release (draw committer) 42.1, Graphics.Draw.vertex_upload (draw committer) 0.0
  • batch 6070: 27.6 ms at 51435 ms, present 6607: GPU no ranges; recorded by Graphics.Draw (draw committer) 42.6, Graphics.Draw.draw_and_resource_release (draw committer) 42.5, Graphics.Draw.vertex_upload (draw committer) 0.0
tools/trace_digest.py of the P1 trace

seconds 60:70 from present 3575: 4159 presents, frame p50 16.7 / p90 16.9 / p99 17.4 / max 92.5 ms, GPU busy 6.8 ms per present
AMD Radeon RX 6700 XT, AMD proprietary driver 26.10.1 (AMD proprietary shader compiler), Windows 10.0.26200, 1920x1080, commit 1b0577c, dropped: no

{"commit":"1b0577cc927b","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"60:70"},"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 60:70","first_present":3575,"ms":70003.079},"presents":4159,"frame_ms":{"p50":16.683,"p90":16.91,"p99":17.433,"max":92.502},"gpu_busy_ms_per_present":6.831,"worker_busy_pct":{"queue worker 0x0":10.011},"top_phases_ms_per_frame":{"VideoOut.Flip":13.686,"VideoOut.Flip.vblank_wait":12.65,"Driver.Packet":1.682,"Graphics.Draw":1.342,"Graphics.Draw.draw_and_resource_release":1.191,"Driver.Packet.draw":1.167,"Driver.Draw":1.148,"VideoOut.Flip.present":0.929},"trace_dropped":false,"trace":"aps5-trace-1b0577cc927b-8828.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 4144: 92.5 ms at 9493 ms: Driver.Packet (queue worker 0x0) 55.2, Graphics.Draw (draw committer) 55.1, Graphics.Draw.draw_and_resource_release (draw committer) 55.0, Driver.Packet.pipeline_drain (queue worker 0x0) 54.5
  • present 5373: 81.8 ms at 30263 ms: Driver.WorkerWait (queue worker 0x0) 64.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 64.2, Driver.Packet (queue worker 0x0) 16.7, Graphics.Draw (draw committer) 16.3
  • present 6203: 78.7 ms at 44261 ms: Driver.WorkerWait (queue worker 0x0) 60.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 60.4, Driver.Packet (queue worker 0x0) 17.4, Graphics.Draw (draw committer) 16.9
  • present 5786: 78.3 ms at 37237 ms: Driver.WorkerWait (queue worker 0x0) 60.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 60.2, Driver.Packet (queue worker 0x0) 17.0, Graphics.Draw (draw committer) 16.8
  • present 7036: 77.6 ms at 58291 ms: Driver.WorkerWait (queue worker 0x0) 60.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 60.0, Driver.Packet (queue worker 0x0) 16.7, Graphics.Draw (draw committer) 16.4

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.0 (0 %) 0.0 (0 %) 16.8 0.6 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
queue worker 0x0 0.9 (5 %) 15.1 (90 %) 0.9 2.8 Driver.Packet 0.9, Driver.Completion 0.0
draw committer 0.8 (5 %) 0.0 (0 %) 16.0 1.5 Graphics.Draw 0.7, Vulkan.DrawFromRecipe 0.1
presenter 0.8 (5 %) 12.9 (77 %) 3.1 0.0 VideoOut.Flip 13.7, Driver.Present 0.0
gpu 6.8 (41 %) 0.0 (0 %) 10.0 0.0 batch 6.8

Largest slices (ms per frame, inclusive, all threads): Driver.WorkerWait 15.1, Driver.WorkerWait.idle_and_completion_poll 15.1, VideoOut.Flip 13.7, VideoOut.Flip.vblank_wait 12.7, batch 6.8, VideoOut.Flip.present 0.9, Driver.Present 0.9, Driver.Packet 0.9, Graphics.Draw 0.7, Driver.Packet.draw 0.6

Longest waits

  • Driver.WorkerWait (queue worker 0x0) 77.0 ms at 30251 ms, present 5372
  • Driver.WorkerWait (queue worker 0x0) 73.5 ms at 37224 ms, present 5785
  • Driver.WorkerWait (queue worker 0x0) 73.0 ms at 58278 ms, present 7035
  • Driver.WorkerWait (queue worker 0x0) 72.8 ms at 44248 ms, present 6202
  • Driver.WorkerWait (queue worker 0x0) 71.2 ms at 16371 ms, present 4550
  • Driver.WorkerWait (queue worker 0x0) 69.8 ms at 23310 ms, present 4961
  • Driver.WorkerWait (queue worker 0x0) 68.1 ms at 51339 ms, present 6623
  • Driver.WorkerWait (queue worker 0x0) 49.6 ms at 9479 ms, present 4143
  • Driver.WorkerWait (queue worker 0x0) 36.5 ms at 23399 ms, present 4963
  • Vulkan.Acquire.acquire_fence_wait (presenter) 34.0 ms at 23399 ms, present 4963

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

  • batch 2776: 34.7 ms at 23399 ms, present 4963: GPU no ranges; recorded by Graphics.Draw (draw committer) 16.7, Graphics.Draw.draw_and_resource_release (draw committer) 16.7
  • batch 1140: 31.8 ms at 9585 ms, present 4145: GPU no ranges; recorded by Graphics.Draw (draw committer) 54.6, Graphics.Draw.draw_and_resource_release (draw committer) 54.6, Resources.Complete (draw committer) 10.1, Resources.Prepare (draw committer) 1.3
  • batch 6100: 28.2 ms at 51426 ms, present 6625: GPU no ranges; recorded by Graphics.Draw (draw committer) 16.4, Graphics.Draw.draw_and_resource_release (draw committer) 16.3
  • batch 4424: 28.0 ms at 37315 ms, present 5787: GPU no ranges; recorded by Graphics.Draw (draw committer) 16.2, Graphics.Draw.draw_and_resource_release (draw committer) 16.1
  • batch 5258: 27.9 ms at 44340 ms, present 6204: GPU no ranges; recorded by Graphics.Draw (draw committer) 16.5, Graphics.Draw.draw_and_resource_release (draw committer) 16.4

Title, on the previous head: the same route, form and analysis, main 6a3afa4deb against 0386e61741 (this PR on 6a3afa4deb), legs M1, P1, M2, P2 on 2026-10-31 (UTC), two clean builds, no dropped trace events.

  • Over all turns of each arm (16 each), the committer span fell from 42.5 to 15.9 ms and the GPU batch was 29.1 and 29.4 ms. The page-turn frame median was 102.5 ms in both arms (main 92.8-262.5 ms, 0386e61741 68.1-228.8 ms).
  • Per leg, the page-turn frame medians were 99.4 and 117.0 ms for main, and 102.55 and 102.45 ms for 0386e61741.
  • Over the whole window, the frame p50 was the same in each of the 3 pairs, and the mean frame was 0.05-0.09 ms shorter with the change.
  • The slowest page turn of each leg of that pair took 218.7-262.5 ms, in both arms; I have not looked into why.
  • Traces of its four legs, each with its tools/trace_digest.py output: M1: trace, digest; P1: trace, digest; M2: trace, digest; P2: trace, digest. They hold the same kinds of data as the traces above, and I checked them the same way.
Title, on an earlier revision: main 5fa2520ad9 against 85f41ae08d (not current-main numbers)

Title, on an earlier revision: the same route and analysis. These legs compare main 5fa2520ad9 with 85f41ae08d, which is this change on 5fa2520ad9. They are not current-main numbers.

  • 150 s legs of main 5fa2520ad9 (M) and of 85f41ae08d (S), in the order M1, S1, two legs of a local build that also has the detile change from Why, S2, M2, and later M3, S3. 85f41ae08d is pushed as thuanquang:perf/snapshot-staging-upload-measured. Outside tests/Recorder.cpp, its changed lines against 5fa2520ad9 are the same as 0386e61741's against 6a3afa4deb.
  • M2 is void and left out: a demanding game was not running when it started and was running when it ended.
  • The GPU and build locks were held for every leg, so none of my other builds or GPU jobs ran during one. Before and after each leg a check found no demanding game running, except after M2. League of Legends may have been running; the check does not count it.
  • Each leg set only APS5_TRACE_SECONDS=60:70 and the pad input variables. Only libSceAgcDriver.prx differed between legs, checked by hash. Each leg started the title anew in the same run folder, whose shader cache was copied from an earlier run before M1 and kept between legs.

Per leg, 8 page turns each (ms; medians over the turns of the leg):

Leg Page-turn frame median Range Longest committer span Longest GPU batch Window p99 Window max
M1 (main 5fa2520ad9) 111.8 107.2-143.3 43.4 35.8 18.763 143.273
M3 (main 5fa2520ad9) 123.5 107.3-157.8 48.8 37.3 17.352 157.814
S1 (85f41ae08d) 74.7 66.4-97.2 10.4 28.5 17.373 97.168
S2 (85f41ae08d) 73.3 66.8-102.3 10.0 31.8 17.308 102.327
S3 (85f41ae08d) 76.0 63.5-103.3 9.3 31.2 17.241 103.336

All turns of each arm: main 5fa2520ad9 122.6 ms median (107.2-157.8, 16 turns), committer span 46.5 ms, GPU batch 36.1 ms; 85f41ae08d 75.3 ms median (63.5-103.3, 24 turns), committer span 9.9 ms, GPU batch 30.9 ms. Every page turn still drops frames with the change.

Traces of M1, M3, S1 and S3, as CONTRIBUTING asks (S2's trace is not attached): M1: trace, digest; M3: trace, digest; S1: trace, digest; S3: trace, digest. They hold only AnyPS5's scope and thread names, timings, batch ids and present numbers; I checked each for anything from the title. Each digest is the tools/trace_digest.py output of its trace.

Summary lines of M1 (main 5fa2520ad9) and S1 (85f41ae08d)
{"commit":"5fa2520ad95e","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"60:70"},"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 60:70","first_present":3552,"ms":70003.173},"presents":4126,"frame_ms":{"p50":16.683,"p90":16.914,"p99":18.763,"max":143.273},"gpu_busy_ms_per_present":8.634,"worker_busy_pct":{"queue worker 0x0":14.159},"top_phases_ms_per_frame":{"VideoOut.Flip":12.819,"VideoOut.Flip.vblank_wait":11.509,"Driver.Packet":2.397,"Graphics.Draw":1.905,"Driver.Packet.draw":1.696,"Driver.Draw":1.663,"Graphics.Draw.draw_and_resource_release":1.549,"Driver.Draw.draw_enqueued":1.001},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":42.045,"events_lost":162856,"totals_full":false}},"trace":"aps5-trace-5fa2520ad95e-7364.json.gz"}
{"commit":"85f41ae08dbc","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"60:70"},"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 60:70","first_present":3573,"ms":70003.273},"presents":4157,"frame_ms":{"p50":16.684,"p90":16.910,"p99":17.373,"max":97.168},"gpu_busy_ms_per_present":8.044,"worker_busy_pct":{"queue worker 0x0":11.491},"top_phases_ms_per_frame":{"VideoOut.Flip":13.362,"VideoOut.Flip.vblank_wait":12.380,"Driver.Packet":1.931,"Graphics.Draw":1.539,"Driver.Packet.draw":1.390,"Driver.Draw":1.363,"Graphics.Draw.draw_and_resource_release":1.239,"Driver.Draw.draw_enqueued":0.808},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":57.427,"events_lost":57660,"totals_full":false}},"trace":"aps5-trace-85f41ae08dbc-27224.json.gz"}

In that pair, every leg's trace dropped events of the queue worker thread (trace_dropped), as its M1 and S1 lines show (M3, S2 and S3 likewise); the page-turn analysis reads presents, draw-committer spans and GPU batches. M3 also dropped draw-committer events from 61.4 s into its window, after its last page turn (58.0 s into the window).

tools/performance_compare.py M1 against S1

Performance comparison

Capture Commit Trace Presents Window (ms)
baseline 5fa2520 aps5-trace-5fa2520ad95e-7364.json.gz 4126 70003.173
candidate 85f41ae aps5-trace-85f41ae08dbc-27224.json.gz 4157 70003.273
  • Compare captures from the same machine, title, content version and scene; matching recorded metadata cannot verify the physical machine or scene.
  • Changes are candidate minus baseline. A negative frame-time change means a shorter frame interval.
  • A missing top phase is unreported, not zero; its change is unavailable.
  • Recorded configuration differs; these measurements do not isolate the code change.
  • baseline: trace events were dropped; the event trace omits some of the work included in phase totals.
  • candidate: trace events were dropped; the event trace omits some of the work included in phase totals.

Configuration differences

Setting Baseline Candidate
window.first_present 3552 3573

Frame and GPU times (ms)

Metric Baseline Candidate Change Change (%)
frame_ms.p50 16.683 16.684 +0.001 +0.006
frame_ms.p90 16.914 16.910 -0.004 -0.024
frame_ms.p99 18.763 17.373 -1.390 -7.408
frame_ms.max 143.273 97.168 -46.105 -32.180
mean_frame_ms 16.966 16.840 -0.126 -0.746
gpu_busy_ms_per_present 8.634 8.044 -0.590 -6.833

Top phases (ms per frame)

Metric Baseline Candidate Change Change (%)
Driver.Draw 1.663 1.363 -0.300 -18.040
Driver.Draw.draw_enqueued 1.001 0.808 -0.193 -19.281
Driver.Packet 2.397 1.931 -0.466 -19.441
Driver.Packet.draw 1.696 1.390 -0.306 -18.042
Graphics.Draw 1.905 1.539 -0.366 -19.213
Graphics.Draw.draw_and_resource_release 1.549 1.239 -0.310 -20.013
VideoOut.Flip 12.819 13.362 +0.543 +4.236
VideoOut.Flip.vblank_wait 11.509 12.380 +0.871 +7.568

The only recorded configuration difference is window.first_present (3552 against 3573), the present at which each window opened.

tools/check_conventions.py and git diff --check pass against 4f41f4c375.

Not tested:

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 (fix(agc): reuse one tiled and one linear texture upload scratch per recorded batch #10773, the agreed prerequisite, merged first on 2026-11-02 as 88a4bed5d3; this head contains it)
  • Fixes: none
  • Unblocks: PPSA14363 METAL GEAR SOLID - Master Collection Version (PPSA14363) #9615 (Screenplay Book page-turn frames, not a stop)
  • GPUs tested: AMD Radeon RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.16010, Windows 11 26200, on head ac57b02043 (tests) and 1b0577cc92 (page-turn pair). From this thread, on e9b72ae83a: by TechLevelZero's NVIDIA run, merged onto main f6232fc (0 new failures, no new validation IDs against main; the new test was validated but not compared), NVIDIA RTX 2000 Ada Generation (driver 595.99.02), Ubuntu 26.04.1 (comment); by XairRrR, merged onto main 4f41f4c375 (20 related tests, negative control red), lavapipe (Mesa 26.1.6, LLVM 19), Debian 13 (review). On 52a861028e: by ycbuzi, merged onto main 2e1c72239b (the 17 snapshot tests, 2 runs each, negative control red), NVIDIA GeForce RTX 4070 SUPER and GTX 1650 SUPER (NVIDIA 616.92) and AMD Radeon RDNA2 iGPU 1002:164e (AMD 32.0.21030.2001), Windows 11 26200 (comment); by NFSS10 (14 related tests with the validation layer), AMD Radeon RX 7900 GRE, AMD 25.6.1, Windows 10.0.22631 (comment); by Bram910, cherry-picked onto a local integration (7 tests with the validation layer, negative control red), NVIDIA GeForce RTX 3080, Windows driver 32.0.16.1047, Windows 11 26200 (comment)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

@MarcZX10

Copy link
Copy Markdown
Contributor

The staging-buffer handoff and the test’s 0xee poison checks directly verify that the pooled buffer is both fully initialized (including uncommitted ranges) and used for upload; the reported negative controls are useful. The title timing is carefully labeled as measured on an earlier production-equivalent revision, and the PR lists the exact A/B stack. Current head 71ab9347 is 42 commits behind main, with base d6e7ab42; hosted conventions/eligibility/intake/labels/report pass, while platform/product jobs are skipped. Please rebase onto current main, recheck the #8026 vector-pool overlap and rerun the focused staging/cache tests on the final head; current full-suite failures are reported as the same baseline failures. I did not run these tests locally.

@thuanquang
thuanquang force-pushed the perf/snapshot-staging-upload branch from 71ab934 to e5ef93b Compare October 22, 2026 20:45
@thuanquang

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Thanks. Done:

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 16286 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp L73
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp L1138-1141
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L507, L544, L663-664
PR 16752 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp L15560
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake L470
PR 17255 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp L73
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp L1138-1141
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L507, L544, L663-664
PR 18029 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp L15560
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake L464

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 5021 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6186 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6209 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6280 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6340 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6412 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 7449 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 7457 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7514 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 7689 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 8484 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 9289 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 9592 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10049 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10492 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10497 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 12070 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 12575 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 12855 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 12944 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 13251 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 13809 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 14344 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 14944 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15059 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15302 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15529 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 15570 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 15621 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 15659 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15674 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 15941 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 17338 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
PR 17738 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 17796 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 17915 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 17956 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp

@MarcZX10

Copy link
Copy Markdown
Contributor

Thanks for the rebase and focused test reruns on 7c900bbc21. Upstream main has since advanced to 8aa44cf3c7d8a2fa163f82e5b86aecbb3a6c20da; GitHub compare now shows this PR head is 89 commits behind that tip, with merge base still 7c900bbc21. The current checks are from the earlier head/base. Please rebase or otherwise update against current main, recheck the disclosed #8026 overlap, and rerun the focused staging/cache tests on the resulting head. I’m asking for current-base evidence because the source and tests need to be evaluated with intervening changes included.

@thuanquang
thuanquang force-pushed the perf/snapshot-staging-upload branch from e5ef93b to 388daf9 Compare October 23, 2026 05:32
@thuanquang

Copy link
Copy Markdown
Contributor Author

@MarcZX10 Done:

  • Rebased onto main 9d6adeb550 with no conflicts; the patch is unchanged (git range-diff shows the commit as identical), and the head is now 388daf981f.
  • On that head (RX 6700 XT, AMD driver 32.0.21045.16010, Windows 11 26200, MinGW GCC 15.2 Release, ANYPS5_REQUIRE_VULKAN=1): the 12 focused staging/cache tests pass three times in a row (and three more times in a second batch). A Khronos validation layer run of the same 12 passes them all and prints only the two VUID-VkImageViewCreateInfo-usage-02275 errors from agc_sampled_storage_base_level_usage that the earlier runs on main and on this branch printed too, and nothing else.
  • perf(agc): reuse sampled snapshot byte buffers across cache entry replacement #8026 rechecked: it is still at bb925032c0. On its own it conflicts with current main in tests/TextureFormat.cpp, and against this head it conflicts at the same two places in ShaderResources.cpp as before: the CachedTexture entry construction in cachedTexture and the drop after the upload. Folding or ordering is still open there.
  • The overlap bot also lists two adjacent-line conflicts with PRs that merge cleanly with main on their own: feat(agc): back extra guest mip levels with storage images #7085 adds a mip-count report right after the snapshot size Require in Texture.cpp that this PR extends to the handed buffer, and fix(agc): reclaim idle images safely during cache creation #7800 wraps the snapshot texture construction in ShaderResources.cpp in a forwarding createTexture lambda, which the dropped branch's constructor call can go through unchanged. Whichever of them merges first, I'll rebase this PR onto it.

The body's Tested section now leads with this head.

@EagleBearerYS

Copy link
Copy Markdown
Contributor

A note on merge order. Our upcoming fix for Ghost of Tsushima Director's Cut (PPSA02225), fix/agc-3d-view-committed-slices-v2, changes the same sampled upload as this PR (cachedTexture and Texture's constructor). It uploads only the committed slabs of a sampled 3D view whose range is only partly committed, instead of materializing the whole volume.

The two compose: once both are in, the packed slabs would be read straight into your upload staging buffer. Ours will go second and adapt to this one when it merges, with this PR in its Depends on.

@thuanquang

Copy link
Copy Markdown
Contributor Author

Closing this in favour of #8026, which has merged. Thanks @NFSS10 for the spare pool, and @MarcZX10 for the reviews.

What this PR would still add on top of #8026, per dropped Uncompressed snapshot (over 256 KiB, tracked or hinted): the guest bytes go straight into the staging buffer, so it saves one surface-sized memcpy and the one spare that #8026 keeps parked per size. On a Ryzen 5 5600X, a local timing diagnostic on main + #9115 measured that memcpy at 1.32-1.41 ms per 24 MiB snapshot. #8026 already removes the larger part on the same runs, the vector allocation and zero-fill: 2.92-2.97 ms per 24 MiB.

For PPSA14363 that leaves an estimated 2% of a frame in the PS1 codec on today's main, and nothing on our stack of game PRs: with #9685 and #9879 the PS1 targets stay resident, and a whole 600 s or 960 s run builds only 6 snapshots. Rebasing would also mean changing #8026's just-merged recycleTests and spareAgeTests, whose spare comes from a dropped Uncompressed snapshot. So another round isn't worth it now.

The vector-free path stays on the fork branch (thuanquang:perf/snapshot-staging-upload, 388daf981f), in case a title shows large dropped Uncompressed snapshots every frame, or rare huge ones. @EagleBearerYS your Ghost of Tsushima 3D committed-slice fix doesn't need to wait for this PR or depend on it.

@thuanquang thuanquang closed this Oct 23, 2026
…taging buffer

A sampled snapshot of a tracked or hinted surface over 256 KiB keeps no
bytes after its upload: boykopovar#8026 parks its vector in the spare pool. To
build one, cachedTexture still took a vector of the surface size from
that pool or value-initialised a new one, read the guest surface into
it, and the Texture then copied the vector into a pooled staging Buffer.

With uncompressed keys the surface is now read straight into the
staging Buffer, which a new Texture constructor uploads as it is: no
vector, no zero-fill, no surface-sized memcpy, and the spare pool is
neither taken from nor parked into. Such a snapshot still runs boykopovar#8026's
expiry walk, so a spare idle for more than 16 presents is freed as
before. ReadTextureSurface zero-fills uncommitted pages itself, so a
reused pooled Buffer reads them as zero. The pending-write check still
comes before the read, and snapshots that are kept, have other keys
(DCC clear fills, ClearSingle expansion) or are views of storage images
take the paths they took.

agc_snapshot_read_into_staging samples dropped snapshots of watched
linear, 64KB_R_X and padded (600x300, rows of 640 texels) surfaces, and
of a three-level linear surface whose level-1 centre pages are not
committed, each read into a pooled staging buffer poisoned beforehand.
Each must leave the spare pool empty, upload from that buffer, sample
the guest bytes (zero in the uncommitted pages, the written bytes in the
committed levels stored before and after them) and be remade after a
driver store of the bytes already there, since it kept none to compare.
A fast-cleared tracked snapshot still parks its vector, and a dropped
uncompressed snapshot of the same size made 16 presents later must leave
that spare alone, so it expires on time. A dropped snapshot made 16
presents after a spare was parked must keep it, and one made 17 presents
after must free it. boykopovar#8026's recycle and spare-age tests now park through
fast-cleared snapshots, the producer that still uses the pool.

Co-Authored-By: Claude <noreply@anthropic.com>
@thuanquang thuanquang reopened this Oct 25, 2026
@thuanquang
thuanquang force-pushed the perf/snapshot-staging-upload branch from 388daf9 to 52a8610 Compare October 25, 2026 04:06
@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 25, 2026
@thuanquang

Copy link
Copy Markdown
Contributor Author

Reopened with a new head, 52a861028e on main 30be9b428b, and a rewritten body.

I closed this on 2026-10-23 because #8026 already removed the larger part of the cost on the snapshots measured then, and kept the branch in case a title showed large dropped snapshots every frame, or rare huge ones. PPSA14363 has a rare huge one: each page turn in the launcher's Screenplay Book samples a new snapshot of a 15360x8640 R8 surface (126.6 MiB) and drops it after the upload. Turns come 7 s apart in my route (about 400 presents), and #8026 releases a spare once it has gone unused for more than 16 presents, so every turn allocates and zero-fills a new vector. In a local timing build, none of the 18 builds of that snapshot (two runs, each opening the book and turning 8 pages) got a spare, and the vector allocation, zero-fill and memcpy into the staging buffer, which this PR removes, took 24.1-46.2 ms per page turn (16 turns, Ryzen 5 5600X).

Changes since 388daf981f: rebased past #8026; a dropped Uncompressed snapshot takes nothing from #8026's pool but still runs its expiry; #8026's recycleTests and spareAgeTests now get their spare from a fast-cleared snapshot. @NFSS10, could you look at that test change?

The body has the page-turn A/B of main 5fa2520ad9 against this PR on the same base: the worst frame per page turn has a median of 122.6 ms on main (16 turns) and 75.3 ms with this PR (24 turns).

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@thuanquang

Copy link
Copy Markdown
Contributor Author

I attached the traces behind the page-turn numbers, as CONTRIBUTING asks for a speed claim: M1 and M3 (main 5fa2520ad9) and S1 and S3 (this change, 85f41ae08d), each with its tools/trace_digest.py output, on a branch of my fork: https://github.com/thuanquang/AnyPS5/tree/evidence/9884-page-turn-traces (also linked in the body above the summary lines). They contain only AnyPS5's scope and thread names, timings, batch ids and present numbers; I checked each for anything from the title.

@ycbuzi

ycbuzi commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

A run of this head on NVIDIA, plus a second AMD device.

Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release. 52a861028e merged onto main 2e1c72239b with no conflicts. One GPU at a time with ANYPS5_GPU, plus ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1, run with ctest -V --repeat until-fail:2.

There are 17 tests:

  • agc_snapshot_read_into_staging;
  • agc_snapshot_copy_failure, agc_storage_cpu_snapshot, agc_draw_snapshot_cap, agc_draw_snapshot_epoch, agc_pending_write_snapshot, and agc_shader_table_snapshot_reuse (and _unmasked);
  • agc_driver_partially_resident_snapshot and _pending_stores, agc_driver_sampled_cache_budget (plus _memory and _without_storage_image_multisample), agc_driver_large_tracked_snapshot, agc_driver_untracked_snapshot_hint, agc_driver_compared_shared_snapshot and agc_driver_recover_storage_allocation.
device (as the fixtures log it) result
Vulkan device: NVIDIA GeForce RTX 4070 SUPER (0x2783, Ada), NVIDIA 616.92 17 of 17 pass, both runs
Vulkan device: NVIDIA GeForce GTX 1650 SUPER (0x2187, Turing), NVIDIA 616.92 17 of 17 pass, both runs
Vulkan device: AMD Radeon(TM) Graphics (1002:164e, RDNA2 iGPU), AMD 32.0.21030.2001 17 of 17 pass, both runs

Negative control on the RTX 4070 SUPER and on the Radeon: Texture.hpp, ShaderResources.cpp and Texture.cpp taken from main, with the test unchanged. agc_snapshot_read_into_staging then fails on both with AGC graphics: the dropped snapshot of the linear surface parked a vector in the spare pool, as on the RX 6700 XT.

The build has no errors. Its warnings are main's existing Signals.cpp:24 one, plus two -Wstringop-overread from stl_algobase.h:1889 that also appear in the control build with main's versions of those three files.

Not run: the validation layer, the PPSA14363 measurement.

AI-assisted: yes (Claude Code)

@oneandonlydean oneandonlydean self-assigned this Oct 26, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@thuanquang We're keeping this PR for the "read the dropped snapshot straight into the staging buffer" change, and I'm closing #10845 by @milescoviello as a duplicate, since it implements the same thing with the same rule in cachedTexture. Credit to @milescoviello for that work. Some of its evidence is useful here too; it was measured on #10845's code, not this head, so treat it as supporting:

Full details are in the #10845 description: #10845

If the read-back test adds coverage your agc_snapshot_read_into_staging doesn't have, it would be worth bringing over. Two small description fixes while you're there: the "The traces are not attached" line is out of date now that they're linked, and the "no other open PR implements the same functions" box can stay checked once #10845 is closed.

@milescoviello

Copy link
Copy Markdown
Contributor

@thuanquang now that #10845 is closed as a duplicate of this, one piece of it may be worth having on top: a GPU read-back of the staged texels.

In #10845, agc_driver_partially_resident_snapshot gained LargeTrackedTexels. It samples a watched texture larger than SnapshotCompareBytes through a compute texel fetch, after it goes through the staging-buffer upload. It requires the sorted texels to equal the sorted source words, with zeros for uncommitted pages, for a fully committed layout and for one with 64 KiB committed. It checks the upload's contents rather than which path it took, so it would cover this PR's staging read. It's on my fork as perf/texture-upload-without-snapshot.

If you'd like it, I can open it as a test-only follow-up once this lands, or you can take it into this PR, whichever suits you.

AI-assisted: yes (Claude Code)

@thuanquang

Copy link
Copy Markdown
Contributor Author

@milescoviello thanks, yes please. A test-only follow-up once this lands is the cleaner way: LargeTrackedTexels checks the staged texels rather than which path produced them, which is exactly what this change needs covered, and it keeps this PR to one topic. I'll review it when it's up.

@oneandonlydean thanks for keeping this one and for crediting #10845's evidence.

@thuanquang

Copy link
Copy Markdown
Contributor Author

@oneandonlydean thanks; the description is fixed (the stale "traces are not attached" line is gone, the box stays checked).

On merge order, I'd keep the one agreed for #10845, since this PR makes the same change in the same blocks (I test-merged this head with each; every conflict is in Texture.cpp, plus Texture.hpp and ShaderResources.cpp for #10064):

  1. fix(agc): reuse one tiled and one linear texture upload scratch per recorded batch #10773 first. It and this PR both rewrite the staging/scratch block of the upload in Texture's constructor; I'll rebase this PR onto it when it lands. @fma-rc, is that still fine with this PR in perf(agc): read a large watched texture straight into its upload staging buffer #10845's place?
  2. This PR next.
  3. fix(agc): build a partially committed sampled 3D view from its committed slices #10064, with the resolution you described for perf(agc): read a large watched texture straight into its upload staging buffer #10845 (a !slabs.has_value() term on the staged condition, packedSlabs moving into the staging constructor). @EagleBearerYS, does that order still work?
  4. feat(agc): back extra guest mip levels with storage images #7085, keeping this PR's staging-buffer size check and your mip-level report after it. @Amoenus, same question.

AI-assisted: yes (Claude Code)

@EagleBearerYS

Copy link
Copy Markdown
Contributor

@thuanquang Yes, that order works for #10064: #10773, then this PR, then #10064, then #7085, merge order only. It's the order agreed for #10845 with this PR in its place, and #7085's author agreed earlier that #10064 goes before #7085. #10064 is still a draft, so I'll take the merges on its side: a !slabs.has_value() term on the condition that picks the staging buffer, since a packed-slab snapshot isn't the surface's layout and stays on the vector path, and packedSlabs forwarded into the staging constructor. Thanks for test-merging it.

Main's boykopovar#12246 lays a sampled 1D array past maxImageArrayLayers out as
rows of a 2D image (`layerRows`), and the merge of a4eca2a passes
that flag through the staging constructor that a dropped snapshot
takes. No test reached that combination: CachedSampledTexture never
passes layerRows, and main's ImageArrayRowsPastLayerLimit samples
static memory outside the write watch, whose snapshot has no
generation and no untracked key and so keeps its vector.

agc_snapshot_read_into_staging now binds a watched linear 1D array as
a 2D image through ShaderResources. The row's own context caps
maxImageArrayLayers at 2048; cachedTexture and the Texture read the
limit from the context they are given. A device that reports 8192 (the
RX 6700 XT on AMD's Windows driver) allows every array a T# can
describe, so without the cap the row would never reach layer rows
there. The array has the capped limit + 1 slices, one more when that
count is even: with an odd count the rows on both sides of the image
centre belong to the centre slice. Its snapshot (2049 slices of 256
bytes at the cap) is over 256 KiB, so cachedTexture drops it, reads it
into a staging buffer and makes a layer-rows Texture from that buffer.
The lookup must park no vector (main's production files park the
snapshot vector after the upload), and the image centre must sample
the centre slice. Without layerRows on the staging path the Texture
refuses the array ("a texture array with more layers than
maxImageArrayLayers is not implemented"). The row prints a "not
tested" line without nullDescriptor or when the rows would exceed
maxImageDimension2D.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 3, 2026

@XairRrR XairRrR left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — approved

Dropped Uncompressed snapshots are now read straight into a pooled staging Buffer. The merged tree builds and passes the related snapshot and sampled-cache tests on lavapipe. The new test fails on main's production files and passes with the PR, and the validation layer reports no new VUIDs that come from this change.

What I ran

Head e9b72ae83aa067744d220d8a33ae15a906e2ab20 merged into main 4f41f4c375f5abb487dbd184fbc150f31994d762 (merged tree 307f0479be47bc7bd49c21ae3aa506d8ee504a3b), in a clean worktree. Debian 13 VM (Xeon Gold 6136), GCC 14.2.0, Release, Vulkan through lavapipe (Mesa 26.1.6, LLVM 19).

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...e9b72ae83aa067744d220d8a33ae15a906e2ab20
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "snapshot|sampled_cache|staging|large_tracked|partially_resident"
ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -V -R "^(agc_snapshot_read_into_staging|agc_driver_sampled_cache_budget)$"
# negative control: Texture.hpp, ShaderResources.cpp, Texture.cpp from main
git show 4f41f4c375f5abb487dbd184fbc150f31994d762:<path> > <path>
ninja -C build -j32 -l32 agc_driver_recorder_tests agc_driver_sampled_cache_budget_tests
ctest --test-dir build --output-on-failure -R "^(agc_snapshot_read_into_staging|agc_driver_sampled_cache_budget|agc_driver_sampled_cache_budget_without_storage_image_multisample)$"
ninja -C build -j32 -l32 agc_driver_native_multisample_depth_tests
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer ctest --test-dir build -V -R "^agc_driver_native_depth_uniform_planes$"
# restore
git show 307f0479be47bc7bd49c21ae3aa506d8ee504a3b:<path> > <path>
ninja -C build -j32 -l32 agc_driver_native_multisample_depth_tests agc_driver_recorder_tests agc_driver_sampled_cache_budget_tests libs
env VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer ctest --test-dir build -V -R "^(agc_driver_native_depth_uniform_planes|agc_snapshot_read_into_staging|agc_driver_sampled_cache_budget)$"
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Configure, build, libs (script) ok
Script test run (2230 tests) no new failures and no timeouts. The 7 known failures (denormal/division tests, unwrap_self_…, vector_constant_factor_tininess) also fail on main
20 related tests (snapshot, sampled_cache, staging, large_tracked, partially_resident) 20/20 pass
agc_snapshot_read_into_staging passes in 0.36 s. lavapipe exposes BC, so every row runs, including the BC5 spare-pool rows and the 1D-array-as-rows row; none prints "not tested"
Validation layer, script comparison the layer loaded in 769 of 770 tests; the one new-VUID test is agc_driver_native_depth_uniform_planes (see below)
Validation layer, agc_snapshot_read_into_staging and agc_driver_sampled_cache_budget the layer was inserted, no Validation Error, no was not found
Worktree after restore git status --porcelain is empty
agc_snapshot_read_into_staging output (merged tree)
fast-cleared surface cleared on the GPU parks the snapshot vector it replaces and leaves the spare snapshot pool alone: passed
dropped snapshot read into its staging buffer, linear: passed
dropped snapshot read into its staging buffer, tiled: passed
dropped snapshot read into its staging buffer, padded linear: passed
dropped snapshot read into its staging buffer, partially committed: passed
dropped snapshot read into its staging buffer, 1D array laid out as rows of a 2D image: passed
dropped snapshot leaves the spare snapshot pool alone: passed
dropped snapshot expires idle spare snapshots: passed
Snapshot read into staging tests passed

The VUID-vkCmdDispatch-groupCountX-00386 in agc_driver_native_depth_uniform_planes does not come from this PR. The test came to main with c998727, after the validation baseline d1ae628bc2, which is why the script reported it as "test not run on main". I rebuilt the test with main's versions of the three production files this PR changes and ran it under the validation layer. It printed the same VUID-vkCmdDispatch-groupCountX-00386 four times, which matches the merged tree. The PR does not touch dispatch code.

Negative control

I restored Texture.hpp, ShaderResources.cpp and Texture.cpp from main, kept the tests and rebuilt:

  • agc_snapshot_read_into_staging fails with AGC graphics: the dropped snapshot of the linear surface parked a vector in the spare pool.
  • agc_driver_sampled_cache_budget and _without_storage_image_multisample pass. That is expected: the rewritten recycleTests/spareAgeTests now park their spare through a fast-cleared BC5 snapshot, which uses the vector path both before and after this change.

After restoring the merged files and rebuilding, all three pass and the worktree is clean.

Findings

Blocking

None.

Non-blocking

  1. The description's Tested section and its "Not tested" list are older than the head.
    • The hardware results ("Head 0386e61741 on main 6a3afa4deb") predate three commits:
      • 181f0ab (BC5 producers and the GPU-clear guard row);
      • 38f795a (the merge of main with #10773 and #12246, which passes layerRows through the staging constructor);
      • e9b72ae (the 1D-array-as-rows row).
    • The "GPUs tested" line still says "on this head".
    • "Not tested" still lists "this PR on top of #10773 (I rebase it … when #10773 lands)". #10773 is already in main (88a4bed), and the merge commit says it was resolved.
    • Suggestion: rerun the focused tests (including validation) on the RX 6700 XT at e9b72ae83a and update those lines, or state which head the hardware result is for. The tests on lavapipe here cover the current head.
  2. On devices without BC support, the spare-pool rows don't run. Those are the BC5-producer rows in agc_snapshot_read_into_staging, recycleTests and spareAgeTests (core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp:757, :774).
    • Each prints a "not tested" line and returns success.
    • lavapipe and desktop GPUs have BC, so CI still covers them. If the staging path is ever widened to clear keys, these tests also need a new producer, as NFSS10 already noted in the discussion.
    • No change needed now.

I checked the code and found nothing wrong:

  • Drop decision. It moves before the read (ShaderResources.cpp:1121) and is equivalent to main's post-upload drop at :1143 for Uncompressed keys. entry.generation is snapshotGeneration, and entry.untracked is set only when no write is pending.
  • Other key types. Non-Uncompressed keys and kept snapshots keep the vector and the spare pool.
  • Staging buffer contents. The pooled Buffer is fully written by ReadTextureSurface for Uncompressed keys, which the poisoned-buffer rows exercise, including the uncommitted-pages case.
  • Size check. Buffer::Bytes() returns exactly the requested size, so the size Require at Texture.cpp:400 holds. Constructing with a staging buffer and a clear together is refused.
  • Debt docs. The PR adds no code comments, so no debt-doc change is needed.
  • Perf evidence. The description carries summary lines from two commits (5fa2520ad95e, 85f41ae08dbc) and links to the traces.
  • Merge order. Depends on: #10773 is satisfied by main.

Not verified

  • Hardware GPUs: I had only lavapipe, so I relied on the author's and commenters' RX 6700 XT, NVIDIA and RDNA2 runs, which were on earlier heads.
  • Windows/MinGW: the ReadProcessMemory path of GuestMemory::ReadCommitted into a pooled Buffer.
  • The PPSA14363 page-turn numbers: I did not run the title, and the numbers come from an earlier revision (85f41ae08d), as the description says.
  • I did not open or check the trace files linked from the author's fork.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head e9b72ae merged onto main f6232fc · tested 2026-11-03 09:04 UTC · 34 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,737 passed · 5 failed (0 new, 3 also fail on main, 2 unstable on main) · 49 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,791 of 3,743 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (935 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.5 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 4 of the last 10 main runs
agc_submit_progress: failed in 6 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (1, not in the main baseline's validation pass)
agc_snapshot_read_into_staging
Validation IDs already present on main (4 IDs in 525 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (525 tests): agc_driver, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 517 more
VUID-vkCmdCopyImage-srcImage-01548 (8 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback
VUID-vkCmdCopyImage-srcImage-01551 (8 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
Skipped (49)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_stencil_ref_export: skipped, the device lacks VK_EXT_shader_stencil_export
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver
Reproduce
git fetch origin e9b72ae83aa067744d220d8a33ae15a906e2ab20 f6232fcfda70644495273f6b8dd88cf0603463d6
git checkout f6232fcfda70644495273f6b8dd88cf0603463d6 && git merge --no-ff e9b72ae83aa067744d220d8a33ae15a906e2ab20
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

thuanquang added a commit to thuanquang/AnyPS5 that referenced this pull request Nov 3, 2026
6a3afa4 vs 0386e61

Screenplay Book (PPSA14363), APS5_TRACE_SECONDS=60:70. AnyPS5 scope/thread names, timings and counts only.
@thuanquang

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks. Items 1-3 are answered on head ac57b02043521237a0d1036ac888a48ce2971571: e9b72ae83a with main 91ecd2d974 and then main 4f41f4c375 merged in, both without conflicts. The description is updated to this head.

  1. Current-main integration. 38f795a674 merged main a4eca2a056. Its conflicts came from feat(agc): sample 1D arrays past maxImageArrayLayers as rows of a 2D image #12246 and fix(agc): reuse one tiled and one linear texture upload scratch per recorded batch #10773. The staging path now passes feat(agc): sample 1D arrays past maxImageArrayLayers as rows of a 2D image #12246's layerRows as well, and fix(agc): reuse one tiled and one linear texture upload scratch per recorded batch #10773's upload scratch is kept as it is. A new row of agc_snapshot_read_into_staging drops the snapshot of a 1D array laid out as rows. The two later merges had no conflicts, and the head's changed lines against 4f41f4c375 are the same as e9b72ae83a's against a4eca2a056. On ac57b02043 (RX 6700 XT, AMD 32.0.21045.16010, Windows 11 26200, ANYPS5_REQUIRE_VULKAN=1):

    • Focused set: 45 tests, which include the 25 (now also perf(agc): store whole words of 1- and 2-byte texels in the detile shader #6905's agc_detile_small_elements). The head passes 45 of 45 in each of 3 runs.
    • Negative control: with Texture.hpp, ShaderResources.cpp and Texture.cpp from 4f41f4c375, 44 of 45 pass in each of 3 runs. agc_snapshot_read_into_staging fails with the dropped snapshot of the linear surface parked a vector in the spare pool.
    • A second control passes false for layerRows in the staging createTexture call. The new row then fails with a texture array with more layers than maxImageArrayLayers is not implemented (1 run).
    • Validation layer (ctest -V, VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1) on the negative-control tree and on the head: the layer is inserted 35 times in each log, once per test that creates an instance. Neither log has a VUID- line, a Validation Error or a "was not found" line.

    This head's tree (e7a000f88c) is the tree git merge-tree gives for e9b72ae83a merged into 4f41f4c375, the merge XairRrR's lavapipe run used.

  2. Matched pair. It ran on the previous head 1b0577cc92 against its main 91ecd2d974, with the same changed lines as this head, from two clean builds, on the Screenplay Book route, legs M, P, M, P. Each leg set only APS5_TRACE_SECONDS=60:70 and the pad input, and no trace dropped events. Over 16 page turns per arm (medians):

    • page-turn frame: 102.7 → 77.3 ms;
    • draw-committer span: 42.7 → 15.6 ms;
    • GPU batch: 27.6 → 28.2 ms.

    Over the whole window, p50 is the same (16.683 ms) and the mean frame is 0.07-0.08 ms shorter in each of the 3 pairs. The summary lines, the trace_digest.py output and the four traces are in the description. The earlier pair on 0386e61741 against 6a3afa4deb cut the committer span the same way (42.5 → 15.9 ms), but its page-turn frame median was 102.5 ms in both arms. Its traces are in the description too.

    Between 91ecd2d974 and 4f41f4c375, perf(agc): store whole words of 1- and 2-byte texels in the detile shader #6905 changed the detile shader that this upload dispatches: for 1- and 2-byte texels, such as the page surface's R8, it now stores whole words, in both arms. That is outside the allocation, zero-fill and memcpy this PR removes. I have not run the pair on 4f41f4c375, so page-turn and GPU-batch times there may differ in both arms.

  3. Depends on. fix(agc): reuse one tiled and one linear texture upload scratch per recorded batch #10773 merged first, on 2026-11-02 (88a4bed5d3), in the agreed order, and this head contains it. Since 2026-10-31 the checklist said Depends on: #10773. With fix(agc): reuse one tiled and one linear texture upload scratch per recorded batch #10773 merged, it now says none, with that note.

@XairRrR thanks for the lavapipe run. The description now has the RX 6700 XT results on this head (your non-blocking item 1).

AI-assisted: yes (Claude Code)

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head ac57b02 merged onto main 4f41f4c · tested 2026-11-03 12:00 UTC · 32 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,746 passed · 10 failed (0 new, 8 also fail on main, 2 unstable on main) · 58 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,814 of 3,811 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (931 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.5 s, ⚠️ public_headers 57.5 s, ⚠️ agc_driver_image_sample_unnormalized 42.1 s, ⚠️ agc_driver_lazy_resolved_abi 37.2 s, ⚠️ agc_shader_sampler_limits 36.6 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 7 of the last 9 main runs
agc_driver_store_over_untracked: failed in 1 of the last 9 main runs
Failing on main too (8, not counted against this PR)
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
agc_driver_submit_progress
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (1, not in the main baseline's validation pass)
agc_snapshot_read_into_staging
Validation IDs already present on main (4 IDs in 517 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (517 tests): agc_driver, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 509 more
VUID-vkCmdCopyImage-srcImage-01548 (8 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback, agc_driver_stencil_plane_memory
VUID-vkCmdCopyImage-srcImage-01551 (8 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback, agc_driver_stencil_plane_memory
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
Skipped (58)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_image_table_vouched_lookups: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a watched imported table cannot be vouched for
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_driver_unit_shadow_budget: skipped, the device does not import watched host memory for unit shadows
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_idle_publish_wait: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a forced watch of the import reads its submissions as CPU stores
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_shadowed_key_stores: skipped, the device imports no watched host memory under a unit shadow
agc_small_tiled_shadow_label: skipped, host imports are unavailable: the test block is not imported and watched
agc_storage_clear_hand_over: skipped, the device imports no watched host memory for the clear-key hand-over
agc_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayW
Reproduce
git fetch origin ac57b02043521237a0d1036ac888a48ce2971571 4f41f4c375f5abb487dbd184fbc150f31994d762
git checkout 4f41f4c375f5abb487dbd184fbc150f31994d762 && git merge --no-ff ac57b02043521237a0d1036ac888a48ce2971571
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head ac57b02 merged onto main 4f41f4c · tested 2026-11-03 12:15 UTC · 36 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,759 passed · 7 failed (0 new, 3 also fail on main, 4 unstable on main) · 48 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,814 of 3,811 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (931 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.1 s
Unstable on main (4, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 4 of the last 10 main runs
agc_driver_submit_progress: failed in 5 of the last 10 main runs
agc_submit_progress: failed in 6 of the last 10 main runs
agc_submit_progress_no_timeline: failed in 5 of the last 10 main runs
Failing on main too (3, not counted against this PR)
agc_driver_image_table
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (1, not in the main baseline's validation pass)
agc_snapshot_read_into_staging
Validation IDs already present on main (4 IDs in 517 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (517 tests): agc_driver, agc_driver_address_passes, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, agc_driver_bc_block_copy, agc_driver_bda_anchor_reads, agc_driver_bda_span_reads, and 509 more
VUID-vkCmdCopyImage-srcImage-01548 (9 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback, and 1 more
VUID-vkCmdCopyImage-srcImage-01551 (9 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_sampling, agc_driver_depth_storage_dispatch, agc_driver_depth_surface_from_storage, agc_driver_dispatch_move_depth, agc_driver_stencil_null_feedback, and 1 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (1 test): agc_driver_srgb8_color_target
Skipped (48)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_stencil_ref_export: skipped, the device lacks VK_EXT_shader_stencil_export
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_dcc: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_deferred: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_main: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not co
Reproduce
git fetch origin ac57b02043521237a0d1036ac888a48ce2971571 4f41f4c375f5abb487dbd184fbc150f31994d762
git checkout 4f41f4c375f5abb487dbd184fbc150f31994d762 && git merge --no-ff ac57b02043521237a0d1036ac888a48ce2971571
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 10, 2026
@Lucke0051

Copy link
Copy Markdown
Contributor

Ran this PR merged onto main 75020cd (PR head 52de5f0) on two Linux GPUs and compared with main on the same machine (CachyOS, Linux 7.3.1, gcc 16.2.1 Release). These are the first runs on an Intel GPU. The host has write watch (host imports resolve write protection: yes), so agc_snapshot_read_into_staging ran every row instead of skipping as it does under WSL.

GPU AGC, shader and VideoOut tests
NVIDIA GeForce RTX 3070 Ti, NVIDIA 615.78.08 no difference from main; agc_snapshot_read_into_staging passes 3 of 3 alone, all 8 of its rows
Intel UHD Graphics 630 (CML GT2), Mesa 26.2.6 no difference from main; agc_snapshot_read_into_staging passes 3 of 3 alone, all 8 of its rows
Failures main has too on this machine

Command: ANYPS5_GPU=<NVIDIA|UHD> ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j8 --timeout 120 -R '^(agc|video_out|shader)'; the new test alone with -R '^agc_snapshot_read_into_staging$' -V. Correctness only, no timings. No validation layer installed here, so no VUID- comparison.

AI-assisted: yes (Claude ran the tests and drafted this comment)

@oneandonlydean
oneandonlydean merged commit 154939b into boykopovar:main Nov 10, 2026
13 checks passed
adriadam10 added a commit that referenced this pull request Nov 11, 2026
The test compared one bump count taken with the waits against one taken without,
three times, and failed when every pair differed by 8 or more. The bump count of
a spin submission is timing dependent (33 with a jump to 48 on lavapipe, no wait
involved), so on a loaded runner each pair can carry a spike on the with side.
Main's push build 42922616353 failed it with pairs 12, 8, 8 (#16484/#9884 touch
neither WaitMemory nor this test; the label wait code was unchanged since
e17983e). It now stops at the first pair under Waits / 2 and gives up after 12;
a real regression bumps at every wait (16 or more) in every pair and still fails.

Co-Authored-By: Claude <noreply@anthropic.com>
chitters2004 added a commit to chitters2004/AnyPS5 that referenced this pull request Nov 11, 2026
Conflicts:
- tests/cmake/agc_driver_recorder_tests.cmake: main (boykopovar#9884) registered
  agc_snapshot_read_into_staging where we registered agc_encoded_segments;
  kept both.
- tests/Recorder.cpp main: main added the --snapshot-read-into-staging-only
  branch where we added --encoded-segments-only; kept both.

boykopovar#17943 merges with main cleanly, so main is merged here directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adriadam10 pushed a commit that referenced this pull request Nov 11, 2026
#9884 reads a dropped sampled snapshot straight into its upload staging buffer, through a Texture constructor that takes the buffer, and conflicted in Texture.hpp, Texture.cpp and ShaderResources.cpp. The merge gives that constructor and its private delegate this PR's packed slabs, so a partially committed snapshot that is dropped is read slab by slab into the staging buffer. The snapshot size check and the upload's tiled buffer, Keep and copy use the staging buffer's size when there is one, since the snapshot span is then empty. cachedTexture keeps #9884's drop and staging flow, sized by this PR's packed snapshot size, and reads through readSnapshot and passes packedSlabs as this PR does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build perf Performance change unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.