perf(agc): scope pending texture snapshots to unwatched units #18940

Merged
JJenkx merged 2 commits from upstream-pr/18940 into main 2026-11-14 06:06:04 +00:00
JJenkx commented 2026-11-12 14:38:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-12T14:38:02Z.


What

Scope the saved guest baseline of a pending storage texture to the tracking units intersecting the range leaving the write watch. Previously unwatching one 64 KiB unit of a four-unit pending texture copied all 256 KiB, even though the remaining units stayed watched.

The remaining units retain write-watch stamps. Refresh and write-back query those units separately when the whole texture spans watched and unwatched memory; units that left the watch use their saved bytes. This preserves later CPU writes without eagerly copying unrelated pending units. Whole-span tracked and compared fast paths remain.

Five focused physical-GPU regressions cover tiled and linear arrays, refresh before write-back, and a partial-unit unwatch boundary. They check GPU output in untouched units and CPU writes in both an unwatched unit and a still-watched unit. The read guard counts actual snapshot bytes rather than elapsed synthetic timing: 262144 on the control, 65536 on the change. Both preserve the expected CPU/GPU contents; the control fails the new scope assertion.

Tested

Independent NVIDIA qualification: Doorriiaann reports RTX 3070 results at this exact head, with validation layer 1.4.335 and no VUID or missing-layer messages across three runs. All 19 storage cases pass on both sides, including agc_storage_pending_key_refresh and agc_storage_clear_hand_over, which were unavailable on the RX 6650 XT. All five new scope cases pass with the change and fail with the expected 262144-byte copy on the matched test-only control. These are the contributor's reported runs, not locally reproduced NVIDIA results.

Linux 7.2.14-arch1-1, Ryzen 9 7950X, AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.6-arch1.1, Release. Full baseline/candidate library builds succeeded. Conventions and whitespace checks passed.

Same 36-case focused Recorder/storage selection against both frozen providers, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, and verbose CTest. Validation layer 1.4.363 was inserted in both; no missing-layer message or VUID errors. The candidate passes all 34 supported cases. Two cases are unavailable in both because this hardware/fixture imports the backing memory (agc_storage_pending_key_refresh, agc_storage_clear_hand_over); they are excluded from coverage. The control has five expected new scope-assertion failures and two expected assertions identifying the actual unwatched unit rather than the old coarse unit-zero refusal. The remaining 27 supported cases pass on the control.

The two refusal assertions still require the refusal and its cause. The per-unit write-watch query now correctly diagnoses the last deliberately unhooked unit, so the tests no longer permit the earlier coarse unit-zero diagnosis.

Native comparison

In Sound Mind PPSA04921 v01.000.009, 1920x1080, stationary opening Trash Room loaded from the same private save. Both arms start from identical warmed shader/pipeline caches. Original game assets are read-only; module outputs, saves and runtime data are private. No own compiler work runs during the native capture.

Qualified native banks use main b842d79fdaac plus the required gather fix #18826 on both sides: control 301371760acc, change 3757f141ef6e. The control includes test fixtures but no AGC production changes. Bare main cannot reach this scene without the gather fix; these are explicitly main-plus-common-prerequisite results. The source PR itself does not depend on #18826.

The submitted branch is rebased on e89685fe6e2a. The AGC runtime files, test registration and complete new fixture namespace are byte-identical to the qualified source. The only upstream change among the four touched files is unrelated Recorder host-import test maintenance. Native banks remain frozen at the exact commits reported in their summaries.

Order: change, then control; each complete native arm enters the shared FIFO separately. Only APS5_TRACE_SECONDS=140:8 and the trace output directory are set for capture; no extra profiling flags or trace-capacity override. Each process has a PTY. Both runs exit normally with original assets, normalized inputs, warm-cache/save seeds, frozen SDKs and kernel settings unchanged/restored. No heavy compiler jobs were observed in the sampled host checks.

build presents / window frame p50 p90 p99
control 301371760acc 106 / 8077.666 ms 76.069 ms 82.136 ms 86.010 ms
change 3757f141ef6e 107 / 8028.220 ms 73.910 ms 82.240 ms 86.958 ms

Both traces are complete, with no dropped events. This is one short pair with similar throughput; it does not establish a reliable title FPS improvement. The supported performance claim is the focused fixture's 75% reduction in bytes copied at the first unwatch. The initial diagnostic 10s pair also had a small median difference, but used extra profiling flags and is not pooled with this clean pair. A 20s attempt filled the default trace buffer after 11.224s; that dropped capture is excluded.

Both arms show the same stationary room camera and geometry at 120s and 160s. Both HUDs are legible at 120s; at 160s the control window readbacks show clipped HUD/tutorial text while the candidate retains the full text. This is a comparison limitation, not a claimed graphics fix: capture lag/HUD animation has not been separated from rendering. The attached X11/composite readbacks are neither physical scanout nor native GPU-frame captures.

Complete aps5-summary.jsonl lines
{"commit":"301371760acc","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"140:8"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.14-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA04921","title":"In Sound Mind","content_version":"01.000.009","resolution":"1920x1080","window":{"spec":"seconds 140:8","first_present":2266,"ms":8077.666},"presents":106,"frame_ms":{"p50":76.069,"p90":82.136,"p99":86.01,"max":87.357},"gpu_busy_ms_per_present":42.674,"worker_busy_pct":{"queue worker 0x0":88.375,"queue worker 0x38":40.98},"top_phases_ms_per_frame":{"Driver.Packet":97.895,"Driver.Packet.draw":35.48,"Driver.Draw":35.362,"Graphics.Draw":32.547,"Driver.Packet.memory_wait":30.294,"Graphics.Draw.draw_and_resource_release":29.542,"Driver.Packet.dispatch":23.886,"Driver.Draw.draw_enqueued":19.572},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-301371760acc-3464226.json.gz"}
{"commit":"3757f141ef6e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"140:8"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.14-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA04921","title":"In Sound Mind","content_version":"01.000.009","resolution":"1920x1080","window":{"spec":"seconds 140:8","first_present":2286,"ms":8028.22},"presents":107,"frame_ms":{"p50":73.91,"p90":82.24,"p99":86.958,"max":87.332},"gpu_busy_ms_per_present":43.758,"worker_busy_pct":{"queue worker 0x0":88.045,"queue worker 0x38":39.932},"top_phases_ms_per_frame":{"Driver.Packet":95.364,"Driver.Packet.draw":33.0,"Driver.Draw":32.884,"Graphics.Draw":31.691,"Driver.Packet.memory_wait":28.975,"Graphics.Draw.draw_and_resource_release":28.885,"Driver.Packet.dispatch":24.914,"Driver.Draw.draw_enqueued":21.111},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-3757f141ef6e-3442412.json.gz"}

Traces, official trace digests, captures, verbose GPU test logs/XML, source patches/pins and cleanup qualification — 32 members, 15,902,482 bytes; SHA-256 472c6558fe36cef03ff8521e23148faa26d3217e01aa2d7a34804996da38b0c0. Game binaries, modules, saves and raw sampled stack memory are excluded.

Overlap review

The official open-PR scan found contextual conflicts with #12792 and #17788. #12792 handles failed page-walk/unknown stamps, while this patch handles mixed watched/unwatched coverage; its changed-block query still rejects a range not wholly covered by the watch. #17788 renews the small-image generation baseline after a GPU store; retain its renewal loop alongside this patch's range-scoped snapshot call. Neither implements the scoped copy change, and neither is a functional prerequisite. I will rebase this branch if either merges first, preserving their behavior.

A directed manual check of 41 shared-file heads that could not be cleanly compared found no other scoped pending-snapshot implementation. #16483 additionally installs a multisample-DCC unwatch hook; that separate hook must remain if integrated. This is a targeted source review, not proof that every unmergeable PR is behaviorally disjoint.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.6-arch1.1, Linux 7.2.14-arch1-1
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5279364138 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18940). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-12T14:38:02Z. --- ### What Scope the saved guest baseline of a pending storage texture to the tracking units intersecting the range leaving the write watch. Previously unwatching one 64 KiB unit of a four-unit pending texture copied all 256 KiB, even though the remaining units stayed watched. The remaining units retain write-watch stamps. Refresh and write-back query those units separately when the whole texture spans watched and unwatched memory; units that left the watch use their saved bytes. This preserves later CPU writes without eagerly copying unrelated pending units. Whole-span tracked and compared fast paths remain. Five focused physical-GPU regressions cover tiled and linear arrays, refresh before write-back, and a partial-unit unwatch boundary. They check GPU output in untouched units and CPU writes in both an unwatched unit and a still-watched unit. The read guard counts actual snapshot bytes rather than elapsed synthetic timing: 262144 on the control, 65536 on the change. Both preserve the expected CPU/GPU contents; the control fails the new scope assertion. ### Tested Independent NVIDIA qualification: [Doorriiaann reports RTX 3070 results](https://github.com/boykopovar/AnyPS5/pull/18940#issuecomment-6828591805) at this exact head, with validation layer 1.4.335 and no VUID or missing-layer messages across three runs. All 19 storage cases pass on both sides, including `agc_storage_pending_key_refresh` and `agc_storage_clear_hand_over`, which were unavailable on the RX 6650 XT. All five new scope cases pass with the change and fail with the expected 262144-byte copy on the matched test-only control. These are the contributor's reported runs, not locally reproduced NVIDIA results. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux 7.2.14-arch1-1, Ryzen 9 7950X, AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.6-arch1.1, Release. Full baseline/candidate library builds succeeded. Conventions and whitespace checks passed. Same 36-case focused Recorder/storage selection against both frozen providers, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer`, and verbose CTest. Validation layer 1.4.363 was inserted in both; no missing-layer message or VUID errors. The candidate passes all 34 supported cases. Two cases are unavailable in both because this hardware/fixture imports the backing memory (`agc_storage_pending_key_refresh`, `agc_storage_clear_hand_over`); they are excluded from coverage. The control has five expected new scope-assertion failures and two expected assertions identifying the actual unwatched unit rather than the old coarse unit-zero refusal. The remaining 27 supported cases pass on the control. The two refusal assertions still require the refusal and its cause. The per-unit write-watch query now correctly diagnoses the last deliberately unhooked unit, so the tests no longer permit the earlier coarse unit-zero diagnosis. #### Native comparison In Sound Mind PPSA04921 v01.000.009, 1920x1080, stationary opening Trash Room loaded from the same private save. Both arms start from identical warmed shader/pipeline caches. Original game assets are read-only; module outputs, saves and runtime data are private. No own compiler work runs during the native capture. Qualified native banks use main `b842d79fdaac` plus the required gather fix #18826 on both sides: control `301371760acc`, change `3757f141ef6e`. The control includes test fixtures but no AGC production changes. Bare main cannot reach this scene without the gather fix; these are explicitly main-plus-common-prerequisite results. The source PR itself does not depend on #18826. The submitted branch is rebased on `e89685fe6e2a`. The AGC runtime files, test registration and complete new fixture namespace are byte-identical to the qualified source. The only upstream change among the four touched files is unrelated Recorder host-import test maintenance. Native banks remain frozen at the exact commits reported in their summaries. Order: change, then control; each complete native arm enters the shared FIFO separately. Only `APS5_TRACE_SECONDS=140:8` and the trace output directory are set for capture; no extra profiling flags or trace-capacity override. Each process has a PTY. Both runs exit normally with original assets, normalized inputs, warm-cache/save seeds, frozen SDKs and kernel settings unchanged/restored. No heavy compiler jobs were observed in the sampled host checks. | build | presents / window | frame p50 | p90 | p99 | |---|---:|---:|---:|---:| | control `301371760acc` | 106 / 8077.666 ms | 76.069 ms | 82.136 ms | 86.010 ms | | change `3757f141ef6e` | 107 / 8028.220 ms | 73.910 ms | 82.240 ms | 86.958 ms | Both traces are complete, with no dropped events. This is one short pair with similar throughput; it does **not** establish a reliable title FPS improvement. The supported performance claim is the focused fixture's 75% reduction in bytes copied at the first unwatch. The initial diagnostic 10s pair also had a small median difference, but used extra profiling flags and is not pooled with this clean pair. A 20s attempt filled the default trace buffer after 11.224s; that dropped capture is excluded. Both arms show the same stationary room camera and geometry at 120s and 160s. Both HUDs are legible at 120s; at 160s the control window readbacks show clipped HUD/tutorial text while the candidate retains the full text. This is a comparison limitation, **not** a claimed graphics fix: capture lag/HUD animation has not been separated from rendering. The attached X11/composite readbacks are neither physical scanout nor native GPU-frame captures. <details> <summary>Complete aps5-summary.jsonl lines</summary> ```json {"commit":"301371760acc","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"140:8"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.14-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA04921","title":"In Sound Mind","content_version":"01.000.009","resolution":"1920x1080","window":{"spec":"seconds 140:8","first_present":2266,"ms":8077.666},"presents":106,"frame_ms":{"p50":76.069,"p90":82.136,"p99":86.01,"max":87.357},"gpu_busy_ms_per_present":42.674,"worker_busy_pct":{"queue worker 0x0":88.375,"queue worker 0x38":40.98},"top_phases_ms_per_frame":{"Driver.Packet":97.895,"Driver.Packet.draw":35.48,"Driver.Draw":35.362,"Graphics.Draw":32.547,"Driver.Packet.memory_wait":30.294,"Graphics.Draw.draw_and_resource_release":29.542,"Driver.Packet.dispatch":23.886,"Driver.Draw.draw_enqueued":19.572},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-301371760acc-3464226.json.gz"} {"commit":"3757f141ef6e","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PLAYGO_UNLISTED_CHUNKS":"installed","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"140:8"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.6-arch1.1","os":"Linux 7.2.14-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA04921","title":"In Sound Mind","content_version":"01.000.009","resolution":"1920x1080","window":{"spec":"seconds 140:8","first_present":2286,"ms":8028.22},"presents":107,"frame_ms":{"p50":73.91,"p90":82.24,"p99":86.958,"max":87.332},"gpu_busy_ms_per_present":43.758,"worker_busy_pct":{"queue worker 0x0":88.045,"queue worker 0x38":39.932},"top_phases_ms_per_frame":{"Driver.Packet":95.364,"Driver.Packet.draw":33.0,"Driver.Draw":32.884,"Graphics.Draw":31.691,"Driver.Packet.memory_wait":28.975,"Graphics.Draw.draw_and_resource_release":28.885,"Driver.Packet.dispatch":24.914,"Driver.Draw.draw_enqueued":21.111},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-3757f141ef6e-3442412.json.gz"} ``` </details> [Traces, official trace digests, captures, verbose GPU test logs/XML, source patches/pins and cleanup qualification](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/unwatch-pending-unit-scope-linux-20261112.tar.gz) — 32 members, 15,902,482 bytes; SHA-256 `472c6558fe36cef03ff8521e23148faa26d3217e01aa2d7a34804996da38b0c0`. Game binaries, modules, saves and raw sampled stack memory are excluded. #### Overlap review The official open-PR scan found contextual conflicts with #12792 and #17788. #12792 handles failed page-walk/unknown stamps, while this patch handles mixed watched/unwatched coverage; its changed-block query still rejects a range not wholly covered by the watch. #17788 renews the small-image generation baseline after a GPU store; retain its renewal loop alongside this patch's range-scoped snapshot call. Neither implements the scoped copy change, and neither is a functional prerequisite. I will rebase this branch if either merges first, preserving their behavior. A directed manual check of 41 shared-file heads that could not be cleanly compared found no other scoped pending-snapshot implementation. #16483 additionally installs a multisample-DCC unwatch hook; that separate hook must remain if integrated. This is a targeted source review, not proof that every unmergeable PR is behaviorally disjoint. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.6-arch1.1, Linux 7.2.14-arch1-1 - [x] AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!18940
No description provided.