perf(agc): upload sampled textures across existing imports #17255

Merged
PrivacyOnion merged 4 commits from upstream-pr/17255 into main 2026-11-19 09:10:52 +00:00
PrivacyOnion commented 2026-11-08 16:26:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-08T16:26:20Z.


What

P1 review correction on 2026-11-09: imported uploads can reuse the same tiled scratch range within one recorder batch. Add VK_ACCESS_TRANSFER_WRITE_BIT to the existing barrier's destination mask so successive copies have a write-after-write memory dependency. This changes the imported upload path for both single-import and multi-import surfaces. No CPU wait, submission or scratch allocation is added. The regression now uploads two distinct arrays of the same size before sampling either, proves they reused the same scratch without a submission, and verifies both arrays after the uploads.

Extend #16286's sampled-texture upload path to surfaces covered by several existing host imports. The current single-import lookup misses a GPU-written sampled surface whenever it crosses an import boundary, then waits for the writes and snapshots the entire tiled surface on the CPU.

Build an ordered, all-or-nothing copy plan under the import lock. Copy each covered span into the existing tiled upload scratch buffer behind the same GPU-write barrier, then use the existing detile and image upload. Include the import's actual buffer offset. A gap, stale registry, disabled host imports, empty range or address overflow produces no plan and retains the CPU path. No import, joined allocation or import-budget increase is created. Cache invalidation and retirement remain those of #16286.

The title that exposed this is Sniper Ghost Warrior Contracts 2, PPSA03131, 01.004.000: its 1920x1080 RGBA8 texture array has 13 layers and a 115,015,680-byte guest surface split across two existing imports. #16286 alone cannot take its GPU path. The implementation has no title ID, address, format-specific exception or relaxed validation.

This is stacked on #16286. Its prerequisite patch is a separate commit credited to JJenkx; the remaining commits add multi-import coverage and tests. #6197 creates joined storage imports; this change consumes existing imports only. #9884 removes a copy within the CPU snapshot path and retains the read/wait. Neither implements this multi-import GPU sampling path.

Tested

P1 correction validation on 2026-11-09, rebased on main 0f7eb1e23d535cc696553f5cfed14bb05c703530, fixed PR head d823c087eafb2679c8f2706179c246e844e03abf. Windows 11 build 26200, WinLibs GCC 15.2.0 Release, NVIDIA RTX 5070 driver 616.64. Both test executables and their runtime dependencies were rebuilt together for each checkout.

The new consecutive-upload fixture reproduces 8 SYNC-HAZARD-WRITE-AFTER-WRITE validation errors with the original imported barrier, even though the sampled texels are correct. With synchronization validation and the new CTest failure regex, the original barrier fails the test. The one-mask correction removes all eight errors.

Same focused selection and same physical GPU on main and the correction, using ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_GPU=RTX 5070, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT and VK_LOADER_LAYERS_DISABLE=~implicit~, with ctest --test-dir C:/Users/playl/AppData/Local/Temp/ap5p15 -R '^(agc_sampled_import_pieces|agc_recorder_upload_scratch|agc_copied_direct_ordering|agc_driver_staged_clear_sampled_read.*)$' -V --no-tests=error.

  • Main passes the five existing tests in 3.52 s. Main has no multi-import test or implementation.
  • The correction passes all six tests in 8.80 s, including the enhanced multi-import fixture.
  • Both logs contain zero VUID- errors, zero synchronization hazards, zero missing requested validation-layer messages and no skipped tests. The new test also fails automatically on SYNC-HAZARD or VUID- output.
  • Download the original-barrier reproduction, main/correction logs, source fingerprints and exact correction. No game files are included.

The historical FPS captures below predate this synchronization correction. The previous +31.7% result is not validated for this corrected head and is withdrawn as a claim about this head. No new FPS benchmark or title-unlock claim is made for the P1 correction.

Overlap refresh for the P1 correction: python tools/pr_overlap.py --branch perf/sampled-texture-imports --repo boykopovar/AnyPS5 --jobs 4 examined 1,971 open PRs. It reports 99 heads, including this PR's own previous public head. Four other heads have shared-line intersections (#4448, #10064, #15674 and the declared prerequisite #16286). Another 94 cannot merge into the scan's current main base, so the tool exits 2 and fails closed. Of the reported heads, 74 exactly match immutable heads from the prior source audit. The remaining 25 new or changed heads were compared across the shared files and the import lookup, sampled lookup and upload-constructor regions. Only #16286 and this PR's own previous head change the sampled upload regions in that refreshed group. No second multi-import uploader or competing scratch-barrier correction was found. This supersedes the historical scan below and is not a clean automatic overlap result.

The remainder records the earlier pre-correction validation and performance captures with their original commit IDs.

Windows 11 build 26200, WinLibs GCC 15.2.0, Release; Ryzen 5 5600, 16 GiB RAM, NVIDIA RTX 5070, driver 616.64. PR main base: d0d11564cac8b513bdad3c61c2cb352884fffcaa. Capture and pure-main GPU-test base: 828e44310ec98912f041d0e51b8adc809848741b; the intervening main change is LibreSSL3 BIO methods and changes none of AGC, the shader recompiler, libc or libkernel.

Focused GPU validation, same physical GPU, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_LAYERS_DISABLE=~implicit~, using ctest --test-dir C:/Users/playl/AppData/Local/Temp/ap5p15 -R <pattern> -V:

  • Pure main: the four existing copied-direct/staged-clear tests pass, 3.16 s.
  • Main plus the common benchmark prerequisites, with the new test harness but before the multi-import implementation: six existing integration tests pass and the new test fails at the expected GPU-upload assertion, 6/7 pass, 4.66 s.
  • Multi-import integration: all seven pass. The final PR head on current main, including the stronger pending-write/gap test: all five relevant tests pass, 3.66 s.
  • Final-head test selection: ^(agc_sampled_import_pieces|agc_copied_direct_ordering|agc_driver_staged_clear_sampled_read.*)$. Pure main runs the same four existing tests without the new test name.
  • All compared logs have zero VUID- errors, zero missing-validation-layer messages and no skipped tests. The new multi-import GPU test actually runs on the RTX 5070.

The new test samples real GPU-written texels from three array layers spanning four independent imports. It checks layer origins and centers, aligned and half-import source offsets, repeated GPU writes invalidating cached textures, and that a fully covered lookup does not submit/wait. A gapped import set has pending GPU writes and must fall back without producing a partial copy plan; empty and overflowing ranges produce no copies. All checked values come from GPU sampling.

Performance protocol: owned title relinked with --windows --no-patches, offline, dummy audio, default graphics settings, 3840x2160. Same machine, savedata seed, timed controller sequence and stationary initial tutorial position. The scene ran before the retained captures to warm the caches. Capture order A1, B1, A2, B2; only APS5_TRACE_SECONDS=240:40 and its output directory are set for tracing. No other profiling/trace switch, frame dumps, log redirection, compiler or focused GPU test runs during the measured windows. Startup/controller actions finish before the measured window.

Pure main stops on the tutorial's independent dual-source MIN blend, so it cannot supply gameplay FPS there. Both measured builds therefore use the identical common prerequisite set: main + #17187 (tutorial entry), #17157 (moved draw-recipe bindings) and #16286. A is 07b65274c87c6949afe3e20c1f7f997c1e1a3cb0; B is 9fd2b22bc6942fc3424e8feb551f0750c53acd45. Both are clean committed trees. Their production difference is only this PR's five multi-import implementation files; their staged library sets differ only in libSceAgcDriver.prx. The benchmark integration commits are published on the fork's perf/bench-sampled-import-pieces branch. #17187/#17157 are common benchmark prerequisites, not changes carried in this PR.

Historical pre-correction captures measured 7.49 -> 9.86 mean FPS (+31.7%) in this stationary tutorial scene. These numbers do not establish a speed gain for the corrected head.

Capture Mean FPS p50 ms p90 ms p99 ms GPU busy ms/present
A1 7.06 133.711 175.146 240.338 25.917
B1 9.24 103.697 124.105 168.438 26.601
A2 7.92 118.289 126.757 181.065 24.743
B2 10.49 95.061 100.454 108.263 24.276

tools/performance_compare.py --require-matching-context accepts both A/B pairs. Event buffers fill in these captures: frame intervals and summary phase totals are retained (totals_full=false), while slice-based inventories describe retained events only. No claim about missing event slices is made. The attached digests retain this warning.

Summary lines:

A1:

{"commit":"07b65274c87c","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":10488,"ms":40092.679},"presents":283,"frame_ms":{"p50":133.711,"p90":175.146,"p99":240.338,"max":294.023},"gpu_busy_ms_per_present":25.917,"worker_busy_pct":{"queue worker 0x0":96.777},"top_phases_ms_per_frame":{"Driver.Packet":137.071,"Driver.Packet.draw":72.452,"Driver.Draw":71.573,"Graphics.Draw":67.177,"Graphics.Draw.draw_and_resource_release":49.173,"Driver.Packet.dispatch":40.666,"Driver.Draw.shader_compile_and_link":31.215,"Driver.Draw.draw_enqueued":28.592},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":7.87,"events_lost":1183473,"totals_full":false},"draw committer":{"events_full_after_s":15.315,"events_lost":433466,"totals_full":false}},"trace":"aps5-trace-07b65274c87c-22812.json.gz"}

B1:

{"commit":"9fd2b22bc694","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":6669,"ms":40060.638},"presents":370,"frame_ms":{"p50":103.697,"p90":124.105,"p99":168.438,"max":286.409},"gpu_busy_ms_per_present":26.601,"worker_busy_pct":{"queue worker 0x0":96.415},"top_phases_ms_per_frame":{"Driver.Packet":104.36,"Driver.Packet.draw":66.04,"Driver.Draw":65.213,"Graphics.Draw":62.456,"Graphics.Draw.draw_and_resource_release":45.593,"Driver.Draw.shader_compile_and_link":31.188,"Driver.Draw.draw_enqueued":23.168,"Shader.DrawStage":17.256},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.756,"events_lost":1546971,"totals_full":false},"draw committer":{"events_full_after_s":12.391,"events_lost":609069,"totals_full":false}},"trace":"aps5-trace-9fd2b22bc694-16176.json.gz"}

A2:

{"commit":"07b65274c87c","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":7598,"ms":40035.194},"presents":317,"frame_ms":{"p50":118.289,"p90":126.757,"p99":181.065,"max":2049.128},"gpu_busy_ms_per_present":24.743,"worker_busy_pct":{"queue worker 0x0":91.737},"top_phases_ms_per_frame":{"Driver.Packet":115.827,"Driver.Packet.draw":60.356,"Driver.Draw":59.577,"Graphics.Draw":58.061,"Graphics.Draw.draw_and_resource_release":42.48,"Driver.Packet.dispatch":35.482,"Driver.Draw.shader_compile_and_link":27.252,"Driver.Dispatch":23.726},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":6.993,"events_lost":1214760,"totals_full":false},"draw committer":{"events_full_after_s":14.17,"events_lost":454245,"totals_full":false}},"trace":"aps5-trace-07b65274c87c-25744.json.gz"}

B2:

{"commit":"9fd2b22bc694","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":7348,"ms":40030.218},"presents":420,"frame_ms":{"p50":95.061,"p90":100.454,"p99":108.263,"max":126.268},"gpu_busy_ms_per_present":24.276,"worker_busy_pct":{"queue worker 0x0":96.292},"top_phases_ms_per_frame":{"Driver.Packet":91.741,"Driver.Packet.draw":58.925,"Driver.Draw":58.154,"Graphics.Draw":55.294,"Graphics.Draw.draw_and_resource_release":40.524,"Driver.Draw.shader_compile_and_link":27.283,"Driver.Draw.draw_enqueued":21.29,"Shader.DrawStage":15.077},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.442,"events_lost":1656776,"totals_full":false},"draw committer":{"events_full_after_s":11.557,"events_lost":644562,"totals_full":false}},"trace":"aps5-trace-9fd2b22bc694-1844.json.gz"}

Download all four timing traces, their complete trace_digest reports, summaries and both comparisons. The archive contains no game files, savedata or memory dumps.

tools/trace_digest.py summary for every retained trace:

A1: seconds 240:40 from present 10488: 283 presents, frame p50 133.7 / p90 175.1 / p99 240.3 / max 294.0 ms, GPU busy 25.9 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 07b65274c87c, dropped: yes

B1: seconds 240:40 from present 6669: 370 presents, frame p50 103.7 / p90 124.1 / p99 168.4 / max 286.4 ms, GPU busy 26.6 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 9fd2b22bc694, dropped: yes

A2: seconds 240:40 from present 7598: 317 presents, frame p50 118.3 / p90 126.8 / p99 181.1 / max 2049.1 ms, GPU busy 24.7 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 07b65274c87c, dropped: yes

B2: seconds 240:40 from present 7348: 420 presents, frame p50 95.1 / p90 100.5 / p99 108.3 / max 126.3 ms, GPU busy 24.3 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 9fd2b22bc694, dropped: yes

A separate diagnostic run counted hundreds of uploads from existing imports and zero CPU snapshot reads over recorded GPU writes; it rendered the tutorial correctly. That diagnostic uses profiling and is not the FPS evidence above. A preliminary attempt affected by concurrent compilation was stopped without a trace and excluded.

Historical overlap audit: python tools/pr_overlap.py --branch perf/sampled-texture-imports --repo boykopovar/AnyPS5 reports shared-line intersections with #4448, #9508, #10064, #15674, #15710 and the declared prerequisite #16286. The neighboring changes concern import-unwatching policy, image-table addresses, committed 3D slabs, import-lookup caching and shared array views. Their merge order can require a mechanical rebase; they do not implement multi-import sampled uploads. The scan fails closed for 73 older branches that conflict with main. All 79 reported heads were compared against their merge bases across the shared files and the affected import lookup, sampled lookup and snapshot-constructor regions. No second multi-import sampled upload implementation was found. This is an audited non-clean scan, not a claimed green overlap check.

python tools/check_conventions.py --base upstream/main passes. The required --base origin/main run reports existing upstream findings because the fork's origin/main is behind; the actual PR base passes. git diff --check passes. No new third-party dependency or repository report is added.
Historical GitHub Windows build/test, conventions, library-portability, eligibility, intake, labels and report checks passed for the pre-correction head 57f86b349782b0654af42e26105a36b921d2f111. Linux was skipped. A manual full-workflow dispatch was refused with HTTP 403 because this account lacks repository administration rights. The local physical-GPU results above are completed; no full Linux CI result is claimed.

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: #16286
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5070, driver 616.64, Windows 11 build 26200
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5213000390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17255). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-08T16:26:20Z. --- ### What P1 review correction on 2026-11-09: imported uploads can reuse the same tiled scratch range within one recorder batch. Add `VK_ACCESS_TRANSFER_WRITE_BIT` to the existing barrier's destination mask so successive copies have a write-after-write memory dependency. This changes the imported upload path for both single-import and multi-import surfaces. No CPU wait, submission or scratch allocation is added. The regression now uploads two distinct arrays of the same size before sampling either, proves they reused the same scratch without a submission, and verifies both arrays after the uploads. Extend #16286's sampled-texture upload path to surfaces covered by several existing host imports. The current single-import lookup misses a GPU-written sampled surface whenever it crosses an import boundary, then waits for the writes and snapshots the entire tiled surface on the CPU. Build an ordered, all-or-nothing copy plan under the import lock. Copy each covered span into the existing tiled upload scratch buffer behind the same GPU-write barrier, then use the existing detile and image upload. Include the import's actual buffer offset. A gap, stale registry, disabled host imports, empty range or address overflow produces no plan and retains the CPU path. No import, joined allocation or import-budget increase is created. Cache invalidation and retirement remain those of #16286. The title that exposed this is Sniper Ghost Warrior Contracts 2, PPSA03131, 01.004.000: its 1920x1080 RGBA8 texture array has 13 layers and a 115,015,680-byte guest surface split across two existing imports. #16286 alone cannot take its GPU path. The implementation has no title ID, address, format-specific exception or relaxed validation. This is stacked on #16286. Its prerequisite patch is a separate commit credited to JJenkx; the remaining commits add multi-import coverage and tests. #6197 creates joined storage imports; this change consumes existing imports only. #9884 removes a copy within the CPU snapshot path and retains the read/wait. Neither implements this multi-import GPU sampling path. ### Tested P1 correction validation on 2026-11-09, rebased on main `0f7eb1e23d535cc696553f5cfed14bb05c703530`, fixed PR head `d823c087eafb2679c8f2706179c246e844e03abf`. Windows 11 build 26200, WinLibs GCC 15.2.0 Release, NVIDIA RTX 5070 driver 616.64. Both test executables and their runtime dependencies were rebuilt together for each checkout. The new consecutive-upload fixture reproduces **8 `SYNC-HAZARD-WRITE-AFTER-WRITE` validation errors** with the original imported barrier, even though the sampled texels are correct. With synchronization validation and the new CTest failure regex, the original barrier fails the test. The one-mask correction removes all eight errors. Same focused selection and same physical GPU on main and the correction, using `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_GPU=RTX 5070`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT` and `VK_LOADER_LAYERS_DISABLE=~implicit~`, with `ctest --test-dir C:/Users/playl/AppData/Local/Temp/ap5p15 -R '^(agc_sampled_import_pieces|agc_recorder_upload_scratch|agc_copied_direct_ordering|agc_driver_staged_clear_sampled_read.*)$' -V --no-tests=error`. - Main passes the five existing tests in 3.52 s. Main has no multi-import test or implementation. - The correction passes all six tests in 8.80 s, including the enhanced multi-import fixture. - Both logs contain zero `VUID-` errors, zero synchronization hazards, zero missing requested validation-layer messages and no skipped tests. The new test also fails automatically on `SYNC-HAZARD` or `VUID-` output. - [Download the original-barrier reproduction, main/correction logs, source fingerprints and exact correction](https://github.com/PrivacyOnion/AnyPS5/releases/download/perf-sampled-imports-20261108/sampled-imports-p1-validation-20261109.zip). No game files are included. The historical FPS captures below predate this synchronization correction. The previous +31.7% result is **not validated for this corrected head** and is withdrawn as a claim about this head. No new FPS benchmark or title-unlock claim is made for the P1 correction. Overlap refresh for the P1 correction: `python tools/pr_overlap.py --branch perf/sampled-texture-imports --repo boykopovar/AnyPS5 --jobs 4` examined 1,971 open PRs. It reports 99 heads, including this PR's own previous public head. Four other heads have shared-line intersections (#4448, #10064, #15674 and the declared prerequisite #16286). Another 94 cannot merge into the scan's current main base, so the tool exits 2 and fails closed. Of the reported heads, 74 exactly match immutable heads from the prior source audit. The remaining 25 new or changed heads were compared across the shared files and the import lookup, sampled lookup and upload-constructor regions. Only #16286 and this PR's own previous head change the sampled upload regions in that refreshed group. No second multi-import uploader or competing scratch-barrier correction was found. This supersedes the historical scan below and is not a clean automatic overlap result. The remainder records the earlier pre-correction validation and performance captures with their original commit IDs. Windows 11 build 26200, WinLibs GCC 15.2.0, Release; Ryzen 5 5600, 16 GiB RAM, NVIDIA RTX 5070, driver 616.64. PR main base: `d0d11564cac8b513bdad3c61c2cb352884fffcaa`. Capture and pure-main GPU-test base: `828e44310ec98912f041d0e51b8adc809848741b`; the intervening main change is LibreSSL3 BIO methods and changes none of AGC, the shader recompiler, libc or libkernel. Focused GPU validation, same physical GPU, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_LAYERS_DISABLE=~implicit~`, using `ctest --test-dir C:/Users/playl/AppData/Local/Temp/ap5p15 -R <pattern> -V`: - Pure main: the four existing copied-direct/staged-clear tests pass, 3.16 s. - Main plus the common benchmark prerequisites, with the new test harness but before the multi-import implementation: six existing integration tests pass and the new test fails at the expected GPU-upload assertion, 6/7 pass, 4.66 s. - Multi-import integration: all seven pass. The final PR head on current main, including the stronger pending-write/gap test: all five relevant tests pass, 3.66 s. - Final-head test selection: `^(agc_sampled_import_pieces|agc_copied_direct_ordering|agc_driver_staged_clear_sampled_read.*)$`. Pure main runs the same four existing tests without the new test name. - All compared logs have zero `VUID-` errors, zero missing-validation-layer messages and no skipped tests. The new multi-import GPU test actually runs on the RTX 5070. The new test samples real GPU-written texels from three array layers spanning four independent imports. It checks layer origins and centers, aligned and half-import source offsets, repeated GPU writes invalidating cached textures, and that a fully covered lookup does not submit/wait. A gapped import set has pending GPU writes and must fall back without producing a partial copy plan; empty and overflowing ranges produce no copies. All checked values come from GPU sampling. Performance protocol: owned title relinked with `--windows --no-patches`, offline, dummy audio, default graphics settings, 3840x2160. Same machine, savedata seed, timed controller sequence and stationary initial tutorial position. The scene ran before the retained captures to warm the caches. Capture order A1, B1, A2, B2; only `APS5_TRACE_SECONDS=240:40` and its output directory are set for tracing. No other profiling/trace switch, frame dumps, log redirection, compiler or focused GPU test runs during the measured windows. Startup/controller actions finish before the measured window. Pure main stops on the tutorial's independent dual-source MIN blend, so it cannot supply gameplay FPS there. Both measured builds therefore use the identical common prerequisite set: main + #17187 (tutorial entry), #17157 (moved draw-recipe bindings) and #16286. A is `07b65274c87c6949afe3e20c1f7f997c1e1a3cb0`; B is `9fd2b22bc6942fc3424e8feb551f0750c53acd45`. Both are clean committed trees. Their production difference is only this PR's five multi-import implementation files; their staged library sets differ only in `libSceAgcDriver.prx`. The benchmark integration commits are published on the fork's `perf/bench-sampled-import-pieces` branch. #17187/#17157 are common benchmark prerequisites, not changes carried in this PR. Historical pre-correction captures measured 7.49 -> 9.86 mean FPS (+31.7%) in this stationary tutorial scene. These numbers do not establish a speed gain for the corrected head. | Capture | Mean FPS | p50 ms | p90 ms | p99 ms | GPU busy ms/present | |---|---:|---:|---:|---:|---:| | A1 | 7.06 | 133.711 | 175.146 | 240.338 | 25.917 | | B1 | 9.24 | 103.697 | 124.105 | 168.438 | 26.601 | | A2 | 7.92 | 118.289 | 126.757 | 181.065 | 24.743 | | B2 | 10.49 | 95.061 | 100.454 | 108.263 | 24.276 | `tools/performance_compare.py --require-matching-context` accepts both A/B pairs. Event buffers fill in these captures: frame intervals and summary phase totals are retained (`totals_full=false`), while slice-based inventories describe retained events only. No claim about missing event slices is made. The attached digests retain this warning. Summary lines: A1: ```json {"commit":"07b65274c87c","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":10488,"ms":40092.679},"presents":283,"frame_ms":{"p50":133.711,"p90":175.146,"p99":240.338,"max":294.023},"gpu_busy_ms_per_present":25.917,"worker_busy_pct":{"queue worker 0x0":96.777},"top_phases_ms_per_frame":{"Driver.Packet":137.071,"Driver.Packet.draw":72.452,"Driver.Draw":71.573,"Graphics.Draw":67.177,"Graphics.Draw.draw_and_resource_release":49.173,"Driver.Packet.dispatch":40.666,"Driver.Draw.shader_compile_and_link":31.215,"Driver.Draw.draw_enqueued":28.592},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":7.87,"events_lost":1183473,"totals_full":false},"draw committer":{"events_full_after_s":15.315,"events_lost":433466,"totals_full":false}},"trace":"aps5-trace-07b65274c87c-22812.json.gz"} ``` B1: ```json {"commit":"9fd2b22bc694","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":6669,"ms":40060.638},"presents":370,"frame_ms":{"p50":103.697,"p90":124.105,"p99":168.438,"max":286.409},"gpu_busy_ms_per_present":26.601,"worker_busy_pct":{"queue worker 0x0":96.415},"top_phases_ms_per_frame":{"Driver.Packet":104.36,"Driver.Packet.draw":66.04,"Driver.Draw":65.213,"Graphics.Draw":62.456,"Graphics.Draw.draw_and_resource_release":45.593,"Driver.Draw.shader_compile_and_link":31.188,"Driver.Draw.draw_enqueued":23.168,"Shader.DrawStage":17.256},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.756,"events_lost":1546971,"totals_full":false},"draw committer":{"events_full_after_s":12.391,"events_lost":609069,"totals_full":false}},"trace":"aps5-trace-9fd2b22bc694-16176.json.gz"} ``` A2: ```json {"commit":"07b65274c87c","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":7598,"ms":40035.194},"presents":317,"frame_ms":{"p50":118.289,"p90":126.757,"p99":181.065,"max":2049.128},"gpu_busy_ms_per_present":24.743,"worker_busy_pct":{"queue worker 0x0":91.737},"top_phases_ms_per_frame":{"Driver.Packet":115.827,"Driver.Packet.draw":60.356,"Driver.Draw":59.577,"Graphics.Draw":58.061,"Graphics.Draw.draw_and_resource_release":42.48,"Driver.Packet.dispatch":35.482,"Driver.Draw.shader_compile_and_link":27.252,"Driver.Dispatch":23.726},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":6.993,"events_lost":1214760,"totals_full":false},"draw committer":{"events_full_after_s":14.17,"events_lost":454245,"totals_full":false}},"trace":"aps5-trace-07b65274c87c-25744.json.gz"} ``` B2: ```json {"commit":"9fd2b22bc694","dirty":false,"env":{"APS5_NET_DISCONNECTED":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"240:40"},"gpu":"NVIDIA GeForce RTX 5070","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":16311,"title_id":"PPSA03131","title":"Sniper Ghost Warrior Contracts 2","content_version":"01.004.000","resolution":"3840x2160","window":{"spec":"seconds 240:40","first_present":7348,"ms":40030.218},"presents":420,"frame_ms":{"p50":95.061,"p90":100.454,"p99":108.263,"max":126.268},"gpu_busy_ms_per_present":24.276,"worker_busy_pct":{"queue worker 0x0":96.292},"top_phases_ms_per_frame":{"Driver.Packet":91.741,"Driver.Packet.draw":58.925,"Driver.Draw":58.154,"Graphics.Draw":55.294,"Graphics.Draw.draw_and_resource_release":40.524,"Driver.Draw.shader_compile_and_link":27.283,"Driver.Draw.draw_enqueued":21.29,"Shader.DrawStage":15.077},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.442,"events_lost":1656776,"totals_full":false},"draw committer":{"events_full_after_s":11.557,"events_lost":644562,"totals_full":false}},"trace":"aps5-trace-9fd2b22bc694-1844.json.gz"} ``` [Download all four timing traces, their complete trace_digest reports, summaries and both comparisons](https://github.com/PrivacyOnion/AnyPS5/releases/download/perf-sampled-imports-20261108/sampled-imports-performance-20261108.zip). The archive contains no game files, savedata or memory dumps. `tools/trace_digest.py` summary for every retained trace: A1: **seconds 240:40** from present 10488: 283 presents, frame p50 133.7 / p90 175.1 / p99 240.3 / max 294.0 ms, GPU busy 25.9 ms per present NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 07b65274c87c, dropped: yes B1: **seconds 240:40** from present 6669: 370 presents, frame p50 103.7 / p90 124.1 / p99 168.4 / max 286.4 ms, GPU busy 26.6 ms per present NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 9fd2b22bc694, dropped: yes A2: **seconds 240:40** from present 7598: 317 presents, frame p50 118.3 / p90 126.8 / p99 181.1 / max 2049.1 ms, GPU busy 24.7 ms per present NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 07b65274c87c, dropped: yes B2: **seconds 240:40** from present 7348: 420 presents, frame p50 95.1 / p90 100.5 / p99 108.3 / max 126.3 ms, GPU busy 24.3 ms per present NVIDIA GeForce RTX 5070, NVIDIA 616.64, Windows 10.0.26200, 3840x2160, commit 9fd2b22bc694, dropped: yes A separate diagnostic run counted hundreds of uploads from existing imports and zero CPU snapshot reads over recorded GPU writes; it rendered the tutorial correctly. That diagnostic uses profiling and is not the FPS evidence above. A preliminary attempt affected by concurrent compilation was stopped without a trace and excluded. Historical overlap audit: `python tools/pr_overlap.py --branch perf/sampled-texture-imports --repo boykopovar/AnyPS5` reports shared-line intersections with #4448, #9508, #10064, #15674, #15710 and the declared prerequisite #16286. The neighboring changes concern import-unwatching policy, image-table addresses, committed 3D slabs, import-lookup caching and shared array views. Their merge order can require a mechanical rebase; they do not implement multi-import sampled uploads. The scan fails closed for 73 older branches that conflict with main. All 79 reported heads were compared against their merge bases across the shared files and the affected import lookup, sampled lookup and snapshot-constructor regions. No second multi-import sampled upload implementation was found. This is an audited non-clean scan, not a claimed green overlap check. `python tools/check_conventions.py --base upstream/main` passes. The required `--base origin/main` run reports existing upstream findings because the fork's origin/main is behind; the actual PR base passes. `git diff --check` passes. No new third-party dependency or repository report is added. Historical GitHub Windows build/test, conventions, library-portability, eligibility, intake, labels and report checks passed for the pre-correction head `57f86b349782b0654af42e26105a36b921d2f111`. Linux was skipped. A manual full-workflow dispatch was refused with HTTP 403 because this account lacks repository administration rights. The local physical-GPU results above are completed; no full Linux CI result is claimed. <!-- 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. --> ### 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: #16286 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: NVIDIA GeForce RTX 5070, driver 616.64, Windows 11 build 26200 <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
THEMANnt commented 2026-11-08 20:45:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-11-08T20:45:19Z.

Review: DISMISSED


[P1] Synchronize writes when the imported upload reuses tiled scratch — Texture.cpp:704. UploadScratchBuffer(Tiled, …) returns the same buffer for a second upload in the same recorder batch when its capacity is sufficient. Both uploads write from offset zero. The imported path’s barrier makes earlier writes visible to transfer reads, but its destination access mask omits VK_ACCESS_TRANSFER_WRITE_BIT. A second imported upload can therefore issue overlapping writes to the same scratch range without the required write-after-write dependency. Please include the destination transfer write in the barrier and add a synchronization-validation case that uploads two distinct imported textures of the same size in one batch, then verifies both. I verified the reuse path and barrier on this head by source inspection. Vulkan synchronization rules.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5819596068 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17255#pullrequestreview-5819596068). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-11-08T20:45:19Z. **Review:** DISMISSED --- **[P1] Synchronize writes when the imported upload reuses tiled scratch — `Texture.cpp:704`.** `UploadScratchBuffer(Tiled, …)` returns the same buffer for a second upload in the same recorder batch when its capacity is sufficient. Both uploads write from offset zero. The imported path’s barrier makes earlier writes visible to transfer reads, but its destination access mask omits `VK_ACCESS_TRANSFER_WRITE_BIT`. A second imported upload can therefore issue overlapping writes to the same scratch range without the required write-after-write dependency. Please include the destination transfer write in the barrier and add a synchronization-validation case that uploads two distinct imported textures of the same size in one batch, then verifies both. I verified the reuse path and barrier on this head by source inspection. [Vulkan synchronization rules](https://docs.vulkan.org/spec/latest/chapters/synchronization.html).
MarcZX10 commented 2026-11-17 23:10:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T23:10:14Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the review evidence supports the multi-import upload and scratch synchronization behavior, though approval is not justified because not every reviewed file was read.

What I ran

Reviewed head afc5589f6ff47e948b2f8850382916b750392a05 using the prepared review bundle and repo_read.py. No tests or build were run.

Results

Check Result Note
Change and source review passed Targeted implementation and test paths read
Build and tests not run Author reports GPU validation; not run here

Findings

Blocking

None.

Non-blocking

None.

Not verified

No source-level defect was identified in the inspected logic. The full text of GuestBufferMemory.cpp, ShaderResources.cpp, Texture.cpp, and tests/Recorder.cpp was available through the reader; only the relevant ranges were read. The full test source and remaining portions of the diff were not reviewed. Files listed as changed in the review manifest: Graphics/include/GuestBufferMemory.hpp, Graphics/include/Texture.hpp, Graphics/src/GuestBufferMemory.cpp, Graphics/src/ShaderResources.cpp, Graphics/src/Texture.cpp, tests/Recorder.cpp, tests/cmake/agc_driver_recorder_tests.cmake, and tests/shaders/SampleImportOrigin.comp. The four files listed as too large for the review folder were read only through targeted reader ranges; no files were excluded by rule according to the manifest excerpt available.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5948178222 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17255#pullrequestreview-5948178222). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T23:10:14Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the review evidence supports the multi-import upload and scratch synchronization behavior, though approval is not justified because not every reviewed file was read. ## What I ran Reviewed head `afc5589f6ff47e948b2f8850382916b750392a05` using the prepared review bundle and `repo_read.py`. No tests or build were run. ## Results | Check | Result | Note | |---|---|---| | Change and source review | passed | Targeted implementation and test paths read | | Build and tests | not run | Author reports GPU validation; not run here | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No source-level defect was identified in the inspected logic. The full text of `GuestBufferMemory.cpp`, `ShaderResources.cpp`, `Texture.cpp`, and `tests/Recorder.cpp` was available through the reader; only the relevant ranges were read. The full test source and remaining portions of the diff were not reviewed. Files listed as changed in the review manifest: `Graphics/include/GuestBufferMemory.hpp`, `Graphics/include/Texture.hpp`, `Graphics/src/GuestBufferMemory.cpp`, `Graphics/src/ShaderResources.cpp`, `Graphics/src/Texture.cpp`, `tests/Recorder.cpp`, `tests/cmake/agc_driver_recorder_tests.cmake`, and `tests/shaders/SampleImportOrigin.comp`. The four files listed as too large for the review folder were read only through targeted reader ranges; no files were excluded by rule according to the manifest excerpt available. ## To get this to a good state Nothing is required.
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!17255
No description provided.