perf(agc): import storage surfaces that cross the import window through a joined import #6197

Open
mcsilva-dev wants to merge 1 commit from upstream-pr/6197 into main
mcsilva-dev commented 2026-10-15 02:25:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mcsilva-dev on 2026-10-15T02:25:37Z.


What

HostImportFor keeps an import run inside one 8 MiB import window (SetHostImportWindow(8 MiB)), and importAccess returns no import when the window run does not cover the range. A storage surface that crosses a window boundary therefore never has an import, and every upload of it takes the CPU path in StorageTexture::upload: GuestMemory::ReadCommitted of the whole surface, a staging copy, a detile in a CommandBatch of its own and SubmitAndWait.

EA SPORTS UFC 6 (PPSA23566) builds its transient render targets in a pool it reserves at 0x11c0000000 (+0x6f424000) and maps in 8 MiB pages (remap fixed ... +0x800000 prot=0xf3, each page on unrelated physical memory). The engine packs surfaces across page boundaries, so most of its storage surfaces cross a window. With APS5_PROFILE_DRAW=1 at the title screen, per 10 s:

[storage] uploads by path (count/MiB, 10 s): clear 0/0.0 direct 6696/5994.0 cpu 1729/6955.0 ...
cpu uploads by cause (count/ms): no import 1729/5135.5

i.e. about half of the queue worker's time went to these uploads. A temporary diagnostic that recorded the import refusal for each CPU upload named a single cause: every one was refused as not registered because the window run did not cover it, all inside the 0x11c0000000 pool. The pool is remapped only during start-up (82 remaps, none after the title screen appears), so an import over it stays valid.

HostImportSpanning keeps HostImportFor's per-window contract (importWindowTests still requires that a view crossing the window is not imported) and, when it finds no import, falls back to a joined import over the contiguous registered ranges the range covers (crossedRun → importJoined, as buffers already do). The storage texture paths that look up an import for a whole surface use it.

Tested

  • agc_driver_graphics_tests (Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT, driver 26.8.1): the new importSpanningTests fails on main with a surface crossing the import window was not imported through a joined import (checked by turning HostImportSpanning into a plain HostImportFor) and passes with this change; the whole executable passes (Graphics validation tests passed).
  • Conventions: tools/check_conventions.py --base origin/main passes.
  • UFC 6 title screen, Windows 11, i5-14600KF, 32 GB, RX 9070 XT (driver 26.8.1, LLPC), game on an NVMe SSD, warm shader cache, APS5_TRACE_SUMMARY_EVERY=10. Both builds are main 760ffa683 plus one local change that the title needs to reach the title screen on 32 GB (registered shaders prepared at first use, see #6139); they differ only by this commit:
10 s intervals, APS5_PROFILE_DRAW=1 frame p50 / p90 presents per 10 s CPU storage uploads per 10 s
main 760ffa683 (+ local change) 95 / 102 ms ~104 235 (958 MiB)
with this change 84 / 90 ms ~118 0 (direct uploads 4,152 / 6.6 GiB)

With the CPU uploads gone, the largest remaining storage cost on main is the alias round trip: storage refresh write-backs of ~8,800 surfaces (~9.6 GiB) per 10 s, the hand-overs #4286 targeted.

Together with #4286. On the UFC bring-up fork from #5996 (c222bd2c2), same machine and scene, without APS5_PROFILE_DRAW:

frame p50
fork c222bd2c2 71 ms
+ #4286 (alias hand-over, adapted to the per-layer original snapshots) 72 ms (neutral, as #4286 measured on Windows)
+ #4286 + this change 35 ms

The first two rows ran with the game on a hard disk and the third on the NVMe SSD; moving the same build between the two disks shortened start-up but did not change the title-screen frame time.

The hand-over takes an aliased surface's units on the device only when the surface is imported, and in this title the aliased surfaces were exactly the ones crossing a window. So this change is what lets #4286 act on Windows here; it may be worth another look at #4286 on top of it.

The title screen picture is the same with and without the change (compared on screenshots); I have not checked later scenes beyond the first cutscene starting.

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
  • 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
  • Unblocks: PPSA23566 #5996 (performance)
  • GPUs tested: AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 11 26200
  • AI-assisted: yes (Claude Code); the measurements are from runs on this machine
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4867293596 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197). Originally posted by [mcsilva-dev](https://github.com/mcsilva-dev) on 2026-10-15T02:25:37Z. --- ### What `HostImportFor` keeps an import run inside one 8 MiB import window (`SetHostImportWindow(8 MiB)`), and `importAccess` returns no import when the window run does not cover the range. A storage surface that crosses a window boundary therefore never has an import, and every upload of it takes the CPU path in `StorageTexture::upload`: `GuestMemory::ReadCommitted` of the whole surface, a staging copy, a detile in a `CommandBatch` of its own and `SubmitAndWait`. EA SPORTS UFC 6 (PPSA23566) builds its transient render targets in a pool it reserves at `0x11c0000000` (`+0x6f424000`) and maps in 8 MiB pages (`remap fixed ... +0x800000 prot=0xf3`, each page on unrelated physical memory). The engine packs surfaces across page boundaries, so most of its storage surfaces cross a window. With `APS5_PROFILE_DRAW=1` at the title screen, per 10 s: ``` [storage] uploads by path (count/MiB, 10 s): clear 0/0.0 direct 6696/5994.0 cpu 1729/6955.0 ... cpu uploads by cause (count/ms): no import 1729/5135.5 ``` i.e. about half of the queue worker's time went to these uploads. A temporary diagnostic that recorded the import refusal for each CPU upload named a single cause: every one was refused as not registered because the window run did not cover it, all inside the `0x11c0000000` pool. The pool is remapped only during start-up (82 remaps, none after the title screen appears), so an import over it stays valid. `HostImportSpanning` keeps `HostImportFor`'s per-window contract (`importWindowTests` still requires that a view crossing the window is not imported) and, when it finds no import, falls back to a joined import over the contiguous registered ranges the range covers (`crossedRun` → `importJoined`, as buffers already do). The storage texture paths that look up an import for a whole surface use it. ### Tested - **`agc_driver_graphics_tests`** (Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT, driver 26.8.1): the new `importSpanningTests` fails on `main` with `a surface crossing the import window was not imported through a joined import` (checked by turning `HostImportSpanning` into a plain `HostImportFor`) and passes with this change; the whole executable passes (`Graphics validation tests passed`). - **Conventions:** `tools/check_conventions.py --base origin/main` passes. - **UFC 6 title screen**, Windows 11, i5-14600KF, 32 GB, RX 9070 XT (driver 26.8.1, LLPC), game on an NVMe SSD, warm shader cache, `APS5_TRACE_SUMMARY_EVERY=10`. Both builds are `main` 760ffa683 plus one local change that the title needs to reach the title screen on 32 GB (registered shaders prepared at first use, see #6139); they differ only by this commit: | 10 s intervals, `APS5_PROFILE_DRAW=1` | frame p50 / p90 | presents per 10 s | CPU storage uploads per 10 s | |---|---|---|---| | `main` 760ffa683 (+ local change) | 95 / 102 ms | ~104 | 235 (958 MiB) | | with this change | **84 / 90 ms** | **~118** | **0** (direct uploads 4,152 / 6.6 GiB) | With the CPU uploads gone, the largest remaining storage cost on `main` is the alias round trip: `storage refresh` write-backs of ~8,800 surfaces (~9.6 GiB) per 10 s, the hand-overs #4286 targeted. **Together with #4286.** On the UFC bring-up fork from #5996 (c222bd2c2), same machine and scene, without `APS5_PROFILE_DRAW`: | | frame p50 | |---|---| | fork c222bd2c2 | 71 ms | | + #4286 (alias hand-over, adapted to the per-layer original snapshots) | 72 ms (neutral, as #4286 measured on Windows) | | + #4286 + this change | **35 ms** | The first two rows ran with the game on a hard disk and the third on the NVMe SSD; moving the same build between the two disks shortened start-up but did not change the title-screen frame time. The hand-over takes an aliased surface's units on the device only when the surface is imported, and in this title the aliased surfaces were exactly the ones crossing a window. So this change is what lets #4286 act on Windows here; it may be worth another look at #4286 on top of it. The title screen picture is the same with and without the change (compared on screenshots); I have not checked later scenes beyond the first cutscene starting. ### 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/blob/main/docs/dev/TechnicalDebt.md) - [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] Unblocks: PPSA23566 #5996 (performance) - [x] GPUs tested: AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 11 26200 - [x] AI-assisted: yes (Claude Code); the measurements are from runs on this machine
copilot-pull-request-reviewer[bot] commented 2026-10-15 02:25:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-15T02:25:44Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5527311357 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#pullrequestreview-5527311357). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-15T02:25:44Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Celegans12 commented 2026-10-15 17:11:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-15T17:11:48Z.


@mcsilva-dev I tried this on our Ghost of Yōtei branch today, and two of main's storage write-back tests fail with it. They fail on your head d7f5ffb043 by itself too, without our changes: agc_storage_split_writeback and agc_driver_storage_write_back_overhang, on Windows 11 with an RTX 3080 Laptop.

  • agc_storage_split_writeback stops at "64 KiB R_X 200x150, 3 mips, ranges split inside a 64 KiB unit: the write-back took the GPU-direct path". A split inside one 64 KiB unit now goes through the joined import instead of the CPU path.
  • agc_driver_storage_write_back_overhang stops at "byte 0x5 differs from the fully registered surface (15360 texels, 768 past pitch x height)". The write-back for the image does run, but its data only shows up in guest memory with the next submission. An extra flush and wait before the check doesn't help.

Replacing the six HostImportSpanning calls in Texture.cpp with HostImportFor makes both pass again, so it looks like it's in the joined-import path itself. Limiting the joined import to 64 KiB-aligned splits wasn't enough (an aligned split still lost data), and neither was turning unit shadows off. We've taken it back out of our game branch for now, but I'm happy to rerun a fix on Yōtei.

Details
  • Windows 11, RTX 3080 Laptop GPU (driver 610.62), MinGW-w64 GCC 15.2.0, Release.
  • Reproduced on your head d7f5ffb043 in a clean worktree, and on our branch (main a5e2a80c6b plus our stack) with the PR merged. Both tests pass on that branch with the merge reverted.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6197872487 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#issuecomment-6197872487). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-15T17:11:48Z. --- @mcsilva-dev I tried this on our Ghost of Yōtei branch today, and two of main's storage write-back tests fail with it. They fail on your head d7f5ffb043 by itself too, without our changes: `agc_storage_split_writeback` and `agc_driver_storage_write_back_overhang`, on Windows 11 with an RTX 3080 Laptop. - `agc_storage_split_writeback` stops at "64 KiB R_X 200x150, 3 mips, ranges split inside a 64 KiB unit: the write-back took the GPU-direct path". A split inside one 64 KiB unit now goes through the joined import instead of the CPU path. - `agc_driver_storage_write_back_overhang` stops at "byte 0x5 differs from the fully registered surface (15360 texels, 768 past pitch x height)". The write-back for the image does run, but its data only shows up in guest memory with the next submission. An extra flush and wait before the check doesn't help. Replacing the six `HostImportSpanning` calls in `Texture.cpp` with `HostImportFor` makes both pass again, so it looks like it's in the joined-import path itself. Limiting the joined import to 64 KiB-aligned splits wasn't enough (an aligned split still lost data), and neither was turning unit shadows off. We've taken it back out of our game branch for now, but I'm happy to rerun a fix on Yōtei. <details><summary>Details</summary> - Windows 11, RTX 3080 Laptop GPU (driver 610.62), MinGW-w64 GCC 15.2.0, Release. - Reproduced on your head d7f5ffb043 in a clean worktree, and on our branch (main a5e2a80c6b plus our stack) with the PR merged. Both tests pass on that branch with the merge reverted. </details>
AlxcBTW commented 2026-10-16 04:12:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-16T04:12:21Z.


With this PR two existing tests fail under Mesa lavapipe, on Linux and on Windows: agc_storage_split_writeback and agc_driver_storage_write_back_overhang. Both pass on the base of this PR and on current main. The stored data is right once the GPU work is complete; both failures are in the tests, which assumed the CPU write-back for a surface over several registered ranges. One line in each test makes both pass.

Runs. The fork CI builds the tests and runs the two ctest entries under lavapipe. Linux is ubuntu-latest (llvmpipe, LLVM 20.1.2). Windows is windows-latest with Mesa 26.2.4 lavapipe (llvmpipe, LLVM 23.1.2), where the test memory is private committed memory and the imports are host-pointer imports.

commit Linux Windows
main 5d9dcc42d both pass, 38839624114 both pass, 38845866370
760ffa683 (the base of this PR) both pass, 38843808385 both pass, 38845874118
d7f5ffb04 (this PR) both fail, 38841491145 both fail, 38845858868
d7f5ffb04 plus the two lines below both pass, 38846663460 both pass, 38846691864

Messages, the same on both platforms:

  • agc_storage_split_writeback: 64 KiB R_X 200x150, 3 mips, ranges split inside a 64 KiB unit: the write-back took the GPU-direct path. Nothing else is reported for that case, so its checks of the stored texels, of the words changed outside the surface and of the second store pass on the GPU-direct path.
  • agc_driver_storage_write_back_overhang: AGC graphics: storage write-back overhang: the fully registered surface received no texels.

Cause.

  1. splitWriteBackTests in tests/Recorder.cpp expects the CPU write-back when the two registered ranges split inside a 64 KiB unit and unit shadows are on (direct = !UnitShadowEnabled()). importSegments() gives up on that case (unitAligned && from % 65536 != 0): it would need two imports under one unit. writeBackLayers now asks HostImportSpanning first, which returns one joined import over both ranges, so the unit lies in a single import and the write-back goes GPU-direct. HostImportFor(...) == nullptr still holds (the test asserts it) and the GPU-direct path leaves both ranges covered by an import (the test asserts that too).
  2. Write() in tests/execution/StorageWriteBackOverhang.cpp ends with FlushAllPending("test") and AgcDriverWaitIdle_nid_postfix(), and the test then reads the guest memory through plain pointers. A GPU-direct write-back is recorded behind the work that produced the image and completes after that call. The other tests in tests/execution call AgcDriver::GuestMemory::FlushGpuWrites(address, bytes) after AgcDriverWaitIdle_nid_postfix() before they read raw memory for that reason. This test did not need it so far, because its split surface took the CPU write-back, which waits for the GPU and so also completed the GPU-direct write-back of the whole surface made before it. Builds of the same tree with and without this PR and a texel count after each Write: without it the whole surface has 0 texels after its own Write and both have 15360 after the second (38846022767); with it the split surface is GPU-direct as well, nothing waits, and both are still at 0 when the test reads (38846017110). With FlushGpuWrites added to Write() and nothing else changed, the test passes on the build with this PR, the two surfaces equal byte for byte and the padding kept (38846544700; that run is red only because agc_storage_split_writeback still fails there without its own change).

Change. One line in each test file; with both, all 34 tests of that job pass on a tree that contains this PR (38846598673):

--- a/core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
+++ b/core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
@@ -4129,7 +4129,7 @@ void splitWriteBackTests(const Device& device, Recorder& recorder) {
         {"64 KiB R_X 200x150, 3 mips, off a 64 KiB boundary, ranges split at 132 KiB", TextureTileMode::kR64KBX, 3, 4096, 135168, true, true, false, false},
         {"linear 200x150, ranges split at 64 KiB", TextureTileMode::kLinear, 1, 0, 65536, true, true, false, false},
         {"64 KiB R_X 200x150, 3 mips, second range of another access", TextureTileMode::kR64KBX, 3, 0, 131072, false, false, false, false},
-        {"64 KiB R_X 200x150, 3 mips, ranges split inside a 64 KiB unit", TextureTileMode::kR64KBX, 3, 0, 135168, true, !UnitShadowEnabled(), false, false},
+        {"64 KiB R_X 200x150, 3 mips, ranges split inside a 64 KiB unit", TextureTileMode::kR64KBX, 3, 0, 135168, true, true, false, false},
         {"64 KiB R_X 200x150, 3 mips, two adjacent allocations split at 128 KiB", TextureTileMode::kR64KBX, 3, 0, 131072, true, true, true, false},
         {"64 KiB R_X 200x150, 3 mips, ranges split at 128 KiB, a second store outside the write watch", TextureTileMode::kR64KBX, 3, 0, 131072, true, true, false, true},
         {"linear 200x150, ranges split at 64 KiB, a second store outside the write watch", TextureTileMode::kLinear, 1, 0, 65536, true, true, false, true},
--- a/core/libs/prx/libSceAgcDriver/tests/execution/StorageWriteBackOverhang.cpp
+++ b/core/libs/prx/libSceAgcDriver/tests/execution/StorageWriteBackOverhang.cpp
@@ -75,6 +75,7 @@ void Write(std::uint8_t* texels) {
     AgcDriverWaitIdle_nid_postfix();
     AgcDriver::Graphics::StorageTexture::FlushAllPending("test");
     AgcDriverWaitIdle_nid_postfix();
+    AgcDriver::GuestMemory::FlushGpuWrites(reinterpret_cast<std::uintptr_t>(texels), SurfaceBytes);
 }

The first change makes the case expect the GPU-direct path whatever UnitShadowEnabled() says. The case's data checks pass on that path (the stored texels, the words changed outside the surface, the second store); whether a split inside a unit should leave the rule of importSegments() behind is for the author and the reviewers to decide. Tested on lavapipe only (Linux and Windows); no hardware GPU.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6207905685 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#issuecomment-6207905685). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-16T04:12:21Z. --- With this PR two existing tests fail under Mesa lavapipe, on Linux and on Windows: `agc_storage_split_writeback` and `agc_driver_storage_write_back_overhang`. Both pass on the base of this PR and on current `main`. The stored data is right once the GPU work is complete; both failures are in the tests, which assumed the CPU write-back for a surface over several registered ranges. One line in each test makes both pass. **Runs.** The fork CI builds the tests and runs the two ctest entries under lavapipe. Linux is ubuntu-latest (llvmpipe, LLVM 20.1.2). Windows is windows-latest with Mesa 26.2.4 lavapipe (llvmpipe, LLVM 23.1.2), where the test memory is private committed memory and the imports are host-pointer imports. | commit | Linux | Windows | |---|---|---| | `main` 5d9dcc42d | both pass, [38839624114](https://github.com/AlxcBTW/AnyPS5/actions/runs/38839624114) | both pass, [38845866370](https://github.com/AlxcBTW/AnyPS5/actions/runs/38845866370) | | 760ffa683 (the base of this PR) | both pass, [38843808385](https://github.com/AlxcBTW/AnyPS5/actions/runs/38843808385) | both pass, [38845874118](https://github.com/AlxcBTW/AnyPS5/actions/runs/38845874118) | | d7f5ffb04 (this PR) | both fail, [38841491145](https://github.com/AlxcBTW/AnyPS5/actions/runs/38841491145) | both fail, [38845858868](https://github.com/AlxcBTW/AnyPS5/actions/runs/38845858868) | | d7f5ffb04 plus the two lines below | both pass, [38846663460](https://github.com/AlxcBTW/AnyPS5/actions/runs/38846663460) | both pass, [38846691864](https://github.com/AlxcBTW/AnyPS5/actions/runs/38846691864) | Messages, the same on both platforms: - `agc_storage_split_writeback`: `64 KiB R_X 200x150, 3 mips, ranges split inside a 64 KiB unit: the write-back took the GPU-direct path`. Nothing else is reported for that case, so its checks of the stored texels, of the words changed outside the surface and of the second store pass on the GPU-direct path. - `agc_driver_storage_write_back_overhang`: `AGC graphics: storage write-back overhang: the fully registered surface received no texels`. **Cause.** 1. `splitWriteBackTests` in `tests/Recorder.cpp` expects the CPU write-back when the two registered ranges split inside a 64 KiB unit and unit shadows are on (`direct = !UnitShadowEnabled()`). `importSegments()` gives up on that case (`unitAligned && from % 65536 != 0`): it would need two imports under one unit. `writeBackLayers` now asks `HostImportSpanning` first, which returns one joined import over both ranges, so the unit lies in a single import and the write-back goes GPU-direct. `HostImportFor(...) == nullptr` still holds (the test asserts it) and the GPU-direct path leaves both ranges covered by an import (the test asserts that too). 2. `Write()` in `tests/execution/StorageWriteBackOverhang.cpp` ends with `FlushAllPending("test")` and `AgcDriverWaitIdle_nid_postfix()`, and the test then reads the guest memory through plain pointers. A GPU-direct write-back is recorded behind the work that produced the image and completes after that call. The other tests in `tests/execution` call `AgcDriver::GuestMemory::FlushGpuWrites(address, bytes)` after `AgcDriverWaitIdle_nid_postfix()` before they read raw memory for that reason. This test did not need it so far, because its `split` surface took the CPU write-back, which waits for the GPU and so also completed the GPU-direct write-back of the `whole` surface made before it. Builds of the same tree with and without this PR and a texel count after each `Write`: without it the `whole` surface has 0 texels after its own `Write` and both have 15360 after the second ([38846022767](https://github.com/AlxcBTW/AnyPS5/actions/runs/38846022767)); with it the `split` surface is GPU-direct as well, nothing waits, and both are still at 0 when the test reads ([38846017110](https://github.com/AlxcBTW/AnyPS5/actions/runs/38846017110)). With `FlushGpuWrites` added to `Write()` and nothing else changed, the test passes on the build with this PR, the two surfaces equal byte for byte and the padding kept ([38846544700](https://github.com/AlxcBTW/AnyPS5/actions/runs/38846544700); that run is red only because `agc_storage_split_writeback` still fails there without its own change). **Change.** One line in each test file; with both, all 34 tests of that job pass on a tree that contains this PR ([38846598673](https://github.com/AlxcBTW/AnyPS5/actions/runs/38846598673)): ```diff --- a/core/libs/prx/libSceAgcDriver/tests/Recorder.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/Recorder.cpp @@ -4129,7 +4129,7 @@ void splitWriteBackTests(const Device& device, Recorder& recorder) { {"64 KiB R_X 200x150, 3 mips, off a 64 KiB boundary, ranges split at 132 KiB", TextureTileMode::kR64KBX, 3, 4096, 135168, true, true, false, false}, {"linear 200x150, ranges split at 64 KiB", TextureTileMode::kLinear, 1, 0, 65536, true, true, false, false}, {"64 KiB R_X 200x150, 3 mips, second range of another access", TextureTileMode::kR64KBX, 3, 0, 131072, false, false, false, false}, - {"64 KiB R_X 200x150, 3 mips, ranges split inside a 64 KiB unit", TextureTileMode::kR64KBX, 3, 0, 135168, true, !UnitShadowEnabled(), false, false}, + {"64 KiB R_X 200x150, 3 mips, ranges split inside a 64 KiB unit", TextureTileMode::kR64KBX, 3, 0, 135168, true, true, false, false}, {"64 KiB R_X 200x150, 3 mips, two adjacent allocations split at 128 KiB", TextureTileMode::kR64KBX, 3, 0, 131072, true, true, true, false}, {"64 KiB R_X 200x150, 3 mips, ranges split at 128 KiB, a second store outside the write watch", TextureTileMode::kR64KBX, 3, 0, 131072, true, true, false, true}, {"linear 200x150, ranges split at 64 KiB, a second store outside the write watch", TextureTileMode::kLinear, 1, 0, 65536, true, true, false, true}, --- a/core/libs/prx/libSceAgcDriver/tests/execution/StorageWriteBackOverhang.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/StorageWriteBackOverhang.cpp @@ -75,6 +75,7 @@ void Write(std::uint8_t* texels) { AgcDriverWaitIdle_nid_postfix(); AgcDriver::Graphics::StorageTexture::FlushAllPending("test"); AgcDriverWaitIdle_nid_postfix(); + AgcDriver::GuestMemory::FlushGpuWrites(reinterpret_cast<std::uintptr_t>(texels), SurfaceBytes); } ``` The first change makes the case expect the GPU-direct path whatever `UnitShadowEnabled()` says. The case's data checks pass on that path (the stored texels, the words changed outside the surface, the second store); whether a split inside a unit should leave the rule of `importSegments()` behind is for the author and the reviewers to decide. Tested on lavapipe only (Linux and Windows); no hardware GPU. AI-assisted: yes
milescoviello commented 2026-10-17 04:51:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T04:51:39Z.


A second title with storage surfaces that cross the import window: MXGP 26 (PPSA30839). Its 2560x1440 storage images are 15 MiB (0xf00000), so each one crosses an 8 MiB window. Without this PR, a local log line per CPU-path upload shows every one of them going through StorageTexture::upload's CPU path with HostImportFor returning null. That also keeps the alias exemption in StorageTexture::Refresh from applying, since it requires an import.

Linux 6.8, RTX 4070 Ti (595.99.02), Release, pad input, 130 s runs. main doesn't reach this scene, so the base is main 143f130553 + #6814, #6094, #6160, #6308, #6184, #6455 + #6917. This PR's head (d7f5ffb043) merged on top, clean merge:

without this PR with this PR
CPU-path storage uploads per run (with the upload log) 9–13 2 in every run
runs where overlapping 2560x1440 images re-upload hundreds of times (#6998), with the upload log 4 of 12 0 of 6
100–110 s window, no APS5_PROFILE_* (2 rounds) 41 / 43 presents, p50 242.7 / 233.2 ms 42 / 43 presents, p50 240.6 / 232.3 ms
without 1: **seconds 100:10** from present 436: 41 presents, frame p50 242.7 / p90 254.5 / p99 332.4 / max 332.4 ms, GPU busy 113.0 ms per present
with 1:    **seconds 100:10** from present 1264: 42 presents, frame p50 240.6 / p90 251.9 / p99 262.6 / max 262.6 ms, GPU busy 115.6 ms per present
without 2: **seconds 100:10** from present 426: 43 presents, frame p50 233.2 / p90 243.1 / p99 246.0 / max 246.0 ms, GPU busy 109.1 ms per present
with 2:    **seconds 100:10** from present 445: 43 presents, frame p50 232.3 / p90 252.2 / p99 281.3 / max 281.3 ms, GPU busy 109.1 ms per present

In normal runs the frame rate doesn't change, because those runs upload only about 10 storage images in all. The difference is in the runs where several overlapping 2560x1440 images keep flushing and re-uploading each other (#6998): with this PR that didn't happen in 6 of 6. All 18 runs reached their limits.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6229842529 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#issuecomment-6229842529). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-17T04:51:39Z. --- A second title with storage surfaces that cross the import window: MXGP 26 (PPSA30839). Its 2560x1440 storage images are 15 MiB (`0xf00000`), so each one crosses an 8 MiB window. Without this PR, a local log line per CPU-path upload shows every one of them going through `StorageTexture::upload`'s CPU path with `HostImportFor` returning null. That also keeps the alias exemption in `StorageTexture::Refresh` from applying, since it requires an import. Linux 6.8, RTX 4070 Ti (595.99.02), Release, pad input, 130 s runs. `main` doesn't reach this scene, so the base is `main` 143f130553 + #6814, #6094, #6160, #6308, #6184, #6455 + #6917. This PR's head (`d7f5ffb043`) merged on top, clean merge: | | without this PR | with this PR | |---|---|---| | CPU-path storage uploads per run (with the upload log) | 9–13 | 2 in every run | | runs where overlapping 2560x1440 images re-upload hundreds of times (#6998), with the upload log | 4 of 12 | 0 of 6 | | 100–110 s window, no `APS5_PROFILE_*` (2 rounds) | 41 / 43 presents, p50 242.7 / 233.2 ms | 42 / 43 presents, p50 240.6 / 232.3 ms | ``` without 1: **seconds 100:10** from present 436: 41 presents, frame p50 242.7 / p90 254.5 / p99 332.4 / max 332.4 ms, GPU busy 113.0 ms per present with 1: **seconds 100:10** from present 1264: 42 presents, frame p50 240.6 / p90 251.9 / p99 262.6 / max 262.6 ms, GPU busy 115.6 ms per present without 2: **seconds 100:10** from present 426: 43 presents, frame p50 233.2 / p90 243.1 / p99 246.0 / max 246.0 ms, GPU busy 109.1 ms per present with 2: **seconds 100:10** from present 445: 43 presents, frame p50 232.3 / p90 252.2 / p99 281.3 / max 281.3 ms, GPU busy 109.1 ms per present ``` In normal runs the frame rate doesn't change, because those runs upload only about 10 storage images in all. The difference is in the runs where several overlapping 2560x1440 images keep flushing and re-uploading each other (#6998): with this PR that didn't happen in 6 of 6. All 18 runs reached their limits. AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-18 17:14:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-18T17:14:43Z.

Review: CHANGES_REQUESTED


Thanks, the measurements on UFC 6 and MXGP 26 make the case for this clear. Before it can merge:

  • Conflicts with main in GuestBufferMemory.hpp and GuestBufferMemory.cpp (real content conflicts, not just adjacency). Please rebase and rerun agc_driver_graphics_tests after it.
  • Two existing tests fail with this change (reported above by @Celegans12 on Windows/RTX 3080 and by @AlxcBTW on lavapipe, Linux and Windows): agc_storage_split_writeback ("ranges split inside a 64 KiB unit: the write-back took the GPU-direct path") and agc_driver_storage_write_back_overhang. Both pass on your base. Please update them in this PR. @AlxcBTW's analysis and one-line fixes are in the thread: expect the GPU-direct path in splitWriteBackTests (Recorder.cpp, the "split inside a 64 KiB unit" row) and call AgcDriver::GuestMemory::FlushGpuWrites(...) at the end of Write() in tests/execution/StorageWriteBackOverhang.cpp.
  • @Celegans12 reports that an aligned split also lost data on their setup. Please confirm the stored texels are right once the GPU work is complete on a hardware driver (not only lavapipe), and state in the PR that the split-inside-a-unit case now deliberately leaves the importSegments() rule behind.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5564016524 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#pullrequestreview-5564016524). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-18T17:14:43Z. **Review:** CHANGES_REQUESTED --- Thanks, the measurements on UFC 6 and MXGP 26 make the case for this clear. Before it can merge: - **Conflicts with `main`** in `GuestBufferMemory.hpp` and `GuestBufferMemory.cpp` (real content conflicts, not just adjacency). Please rebase and rerun `agc_driver_graphics_tests` after it. - **Two existing tests fail with this change** (reported above by @Celegans12 on Windows/RTX 3080 and by @AlxcBTW on lavapipe, Linux and Windows): `agc_storage_split_writeback` ("ranges split inside a 64 KiB unit: the write-back took the GPU-direct path") and `agc_driver_storage_write_back_overhang`. Both pass on your base. Please update them in this PR. @AlxcBTW's analysis and one-line fixes are in the thread: expect the GPU-direct path in `splitWriteBackTests` (`Recorder.cpp`, the "split inside a 64 KiB unit" row) and call `AgcDriver::GuestMemory::FlushGpuWrites(...)` at the end of `Write()` in `tests/execution/StorageWriteBackOverhang.cpp`. - @Celegans12 reports that an aligned split also lost data on their setup. Please confirm the stored texels are right once the GPU work is complete on a hardware driver (not only lavapipe), and state in the PR that the split-inside-a-unit case now deliberately leaves the `importSegments()` rule behind.
JJenkx commented 2026-10-19 07:09:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-19T07:09:15Z.


Additional hardware regression coverage for this PR: AMD Radeon RX 6650 XT, RADV / Mesa 26.2.4-arch1.1, Arch Linux, Khronos validation enabled and shader caches disabled.

I adapted head d7f5ffb043d61c9d1ed40469f0622089ba9d04d9 onto main c1ca83479f4e3faad4064fce33afcbebb3ba60d0 (preserving main’s ExistingHostImportFor alongside HostImportSpanning) and ran a GPU readback regression against CPU-detiled reference pixels. It covers adjacent imports, initial uploads and partial refreshes, uploads outside and inside explicit temporary-recorder scopes, both single-pass settings, nine mip levels, two array layers, and a 256-byte offset that clips the import windows.

  • Full libs build: passed.
  • agc_driver_graphics: passed, 2.63 s.
  • agc_driver_storage_segmented_upload: passed, 0.11 s.
  • Zero Vulkan validation errors and zero skipped tests in those two tests.

The reproducible comparison branch and regression are at 6ce9eadd702a. Build the libs, agc_driver_graphics_tests and agc_driver_storage_segmented_upload_tests targets, with ANYPS5_AGC_EXECUTION_TESTS=StorageSegmentedUpload enabled, then run:

env VK_DRIVER_FILES=/usr/share/vulkan/icd.d/radeon_icd.json \
  VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  MESA_SHADER_CACHE_DISABLE=true ANYPS5_NO_SHADER_CACHE=1 \
  ANYPS5_REQUIRE_VULKAN=1 APS5_NO_PIPELINE_JOURNAL=1 \
  APS5_PIN_WAIT_MS=1000 \
  ctest --test-dir build-full \
  -R '^(agc_driver_graphics|agc_driver_storage_segmented_upload)$' -V

The regression restores the device's outer recorder after its temporary recorder is destroyed. Without that fixture restoration, teardown can leave the outer recorder's retained imports pinned and produce a misleading unregister timeout; the corrected regression passes here.

This is upload correctness coverage, not a title performance claim or a validation of all write-back paths. I have kept my overlapping segmented-copy implementation local rather than opening a competing upload PR. The test is available to reuse here.

AI-assisted: yes.

Hardware write-back follow-up: I also reproduced both existing test failures on this adapted branch before applying the two test corrections proposed above by @AlxcBTW. agc_storage_split_writeback reported only the unexpected GPU-direct path for the intra-unit split; agc_driver_storage_write_back_overhang reported byte 0x5 differing from the fully registered surface.

With those exact two corrections (expect the joined GPU-direct path; call GuestMemory::FlushGpuWrites before the raw CPU read), all six focused tests pass on the same RX 6650 XT with RADV, Khronos validation, and shader caches disabled:

Test Seconds
agc_storage_written_buffer_order 0.031
agc_storage_split_writeback 0.065
agc_storage_write_back 0.443
agc_driver_graphics 2.602
agc_driver_storage_segmented_upload 0.102
agc_driver_storage_write_back_overhang 0.148

Zero validation errors and zero skips. The split test retains its texel, padding, import-coverage, and second-store checks; the overhang test retains its byte-for-byte and padding checks. The write-watch probe reports dma-buf imports retaining write protection. No production driver changes were needed for these corrections.

Reproduction: hardware-test branch, with the two-line patch in its final commit, credited to @AlxcBTW. Add StorageWriteBackOverhang to ANYPS5_AGC_EXECUTION_TESTS and build agc_driver_recorder_tests and agc_driver_storage_write_back_overhang_tests; run the two write-back tests using the same environment shown above. This is hardware corroboration of the proposed test corrections, not a whole-suite or title performance claim.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6261723942 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#issuecomment-6261723942). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-19T07:09:15Z. --- Additional hardware regression coverage for this PR: **AMD Radeon RX 6650 XT, RADV / Mesa 26.2.4-arch1.1, Arch Linux**, Khronos validation enabled and shader caches disabled. I adapted head `d7f5ffb043d61c9d1ed40469f0622089ba9d04d9` onto main `c1ca83479f4e3faad4064fce33afcbebb3ba60d0` (preserving main’s `ExistingHostImportFor` alongside `HostImportSpanning`) and ran a GPU readback regression against CPU-detiled reference pixels. It covers adjacent imports, initial uploads and partial refreshes, uploads outside and inside explicit temporary-recorder scopes, both single-pass settings, nine mip levels, two array layers, and a 256-byte offset that clips the import windows. - Full `libs` build: passed. - `agc_driver_graphics`: passed, 2.63 s. - `agc_driver_storage_segmented_upload`: passed, 0.11 s. - Zero Vulkan validation errors and zero skipped tests in those two tests. The reproducible comparison branch and regression are at [6ce9eadd702a](https://github.com/JJenkx/AnyPS5/commit/6ce9eadd702a8a829f1ea548275e2c1ca1588c18). Build the `libs`, `agc_driver_graphics_tests` and `agc_driver_storage_segmented_upload_tests` targets, with `ANYPS5_AGC_EXECUTION_TESTS=StorageSegmentedUpload` enabled, then run: ```bash env VK_DRIVER_FILES=/usr/share/vulkan/icd.d/radeon_icd.json \ VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \ MESA_SHADER_CACHE_DISABLE=true ANYPS5_NO_SHADER_CACHE=1 \ ANYPS5_REQUIRE_VULKAN=1 APS5_NO_PIPELINE_JOURNAL=1 \ APS5_PIN_WAIT_MS=1000 \ ctest --test-dir build-full \ -R '^(agc_driver_graphics|agc_driver_storage_segmented_upload)$' -V ``` The regression restores the device's outer recorder after its temporary recorder is destroyed. Without that fixture restoration, teardown can leave the outer recorder's retained imports pinned and produce a misleading unregister timeout; the corrected regression passes here. This is upload correctness coverage, not a title performance claim or a validation of all write-back paths. I have kept my overlapping segmented-copy implementation local rather than opening a competing upload PR. The test is available to reuse here. AI-assisted: yes. Hardware write-back follow-up: I also reproduced both existing test failures on this adapted branch before applying the two test corrections proposed above by @AlxcBTW. `agc_storage_split_writeback` reported only the unexpected GPU-direct path for the intra-unit split; `agc_driver_storage_write_back_overhang` reported byte `0x5` differing from the fully registered surface. With those exact two corrections (expect the joined GPU-direct path; call `GuestMemory::FlushGpuWrites` before the raw CPU read), all six focused tests pass on the same RX 6650 XT with RADV, Khronos validation, and shader caches disabled: | Test | Seconds | | --- | ---: | | `agc_storage_written_buffer_order` | 0.031 | | `agc_storage_split_writeback` | 0.065 | | `agc_storage_write_back` | 0.443 | | `agc_driver_graphics` | 2.602 | | `agc_driver_storage_segmented_upload` | 0.102 | | `agc_driver_storage_write_back_overhang` | 0.148 | Zero validation errors and zero skips. The split test retains its texel, padding, import-coverage, and second-store checks; the overhang test retains its byte-for-byte and padding checks. The write-watch probe reports dma-buf imports retaining write protection. No production driver changes were needed for these corrections. Reproduction: [hardware-test branch](https://github.com/JJenkx/AnyPS5/tree/testing/storage-writeback-hardware-sync99), with the two-line patch in its final commit, credited to @AlxcBTW. Add `StorageWriteBackOverhang` to `ANYPS5_AGC_EXECUTION_TESTS` and build `agc_driver_recorder_tests` and `agc_driver_storage_write_back_overhang_tests`; run the two write-back tests using the same environment shown above. This is hardware corroboration of the proposed test corrections, not a whole-suite or title performance claim.
eliasbruno124-dev commented 2026-10-20 16:47:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eliasbruno124-dev on 2026-10-20T16:47:47Z.


Windows hardware follow-up on main 77e31219c835: RTX 3060 Laptop GPU, NVIDIA 617.42, Windows 11, WinLibs GCC 15.2.0, Release.

I adapted d7f5ffb043d6 locally, preserving current main's ExistingHostImportFor and stale-import/LRU refresh checks. Both sides include #8527 to correct the Windows deferred-settle ordering hazard; APS5_NO_DEFERRED_SETTLES is unset. These results therefore include that unmerged dependency.

The same 22 focused native tests pass before and after, with the real Khronos synchronization-validation layer, shader caches disabled, zero validation errors and zero skips. Each finishes within 14 seconds. This includes the split-writeback, overhang, storage-written-buffer ordering and eight import-settle cases.

For the review's two fixture changes, current main already flushes GPU writes before the overhang CPU read. I changed the intra-64-KiB split expectation to GPU-direct while retaining its stored-texel, padding and second-store checks. Those checks pass on this NVIDIA hardware.

I also compared automatic startup of GTA III, PPSA03527/01.003.000, with complete matching runtimes and unchanged original content. Across the emitted 10-second storage reports in each 180-second observation, CPU uploads fell from 3 (14.9 MiB) to 1 (3.0 MiB). All eight corresponding early renderer exports are byte-identical. Neither observation reached confirmed gameplay; logging and frame readbacks were enabled. This small startup difference does not establish an FPS or loading-time improvement, and does not yet reproduce the much heavier upload churn observed in the first mission.

Prepared with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6296193551 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#issuecomment-6296193551). Originally posted by [eliasbruno124-dev](https://github.com/eliasbruno124-dev) on 2026-10-20T16:47:47Z. --- Windows hardware follow-up on `main` `77e31219c835`: RTX 3060 Laptop GPU, NVIDIA 617.42, Windows 11, WinLibs GCC 15.2.0, Release. I adapted `d7f5ffb043d6` locally, preserving current main's `ExistingHostImportFor` and stale-import/LRU refresh checks. Both sides include #8527 to correct the Windows deferred-settle ordering hazard; `APS5_NO_DEFERRED_SETTLES` is unset. These results therefore include that unmerged dependency. The same 22 focused native tests pass before and after, with the real Khronos synchronization-validation layer, shader caches disabled, zero validation errors and zero skips. Each finishes within 14 seconds. This includes the split-writeback, overhang, storage-written-buffer ordering and eight import-settle cases. For the review's two fixture changes, current main already flushes GPU writes before the overhang CPU read. I changed the intra-64-KiB split expectation to GPU-direct while retaining its stored-texel, padding and second-store checks. Those checks pass on this NVIDIA hardware. I also compared automatic startup of GTA III, PPSA03527/01.003.000, with complete matching runtimes and unchanged original content. Across the emitted 10-second storage reports in each 180-second observation, CPU uploads fell from 3 (14.9 MiB) to 1 (3.0 MiB). All eight corresponding early renderer exports are byte-identical. Neither observation reached confirmed gameplay; logging and frame readbacks were enabled. This small startup difference does not establish an FPS or loading-time improvement, and does not yet reproduce the much heavier upload churn observed in the first mission. Prepared with AI assistance.
LeandroLP23 commented 2026-10-21 22:29:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-21T22:29:07Z.


A third title with storage surfaces that cross the import window, plus a test conflict with current main that came in with #6457.

Title. SuperTuxKart (PPSA69421 00.001.000), a ps5-opengl port, in a race. Its two-slice 1920x1080 color targets are 17,694,720 bytes each, at 0x2bf200000 and 0x2bfc00000. The title maps that memory in 10 MiB pieces; the import trace shows 0x2bf600000+0xa00000, 0x2c0000000+0xa00000 and 0x2c0a00000+0xa00000. So each target spans two or three registered ranges and gets no import from HostImportFor. A temporary log at the CPU path of StorageTexture::upload showed only these two images there, each with ExistingHostImportFor null. Their write-backs were already GPU-direct through importSegments(); only the uploads took the CPU path.

Setup.

  • Radeon 860M (RDNA 3.5), Ryzen AI 7 350, Windows 11 26300, AMD 32.0.13058.8001, WinLibs GCC 15.2.0, Release.
  • main 0c6a5bd593, and main with d7f5ffb043 merged locally.
  • The merge conflicts were in GuestBufferMemory.hpp and Texture.cpp. I kept main's side, added the HostImportSpanning declaration, and used HostImportSpanning in the three refresh/upload call sites and in CopyRefusal, which main split out of the copy check.

APS5_PROFILE_DRAW=1, per 10 s of the race:

main main + this PR
CPU-path uploads 98–156 (≈6.3 ms each) 0
direct uploads 196–223 344
resident target lookups of 1 ms or more 104–158, 697–736 ms 6, 6.4 ms
readTarget 1141–1200 ms 470 ms

FPS doesn't move measurably: 4.97 and 6.12 with this PR against 5.90–8.43 on main over four rounds. GPU time per present varies by 30–80 ms between runs here and hides a ~0.7 s per 10 s saving on the draw thread. The race renders as on main.

Tests on this machine (merged build, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1).

  • agc_driver_graphics: passes, importSpanningTests included.
  • agc_driver_storage_write_back_overhang: passes on this hardware driver.
  • agc_storage_split_writeback: fails as reported above, "ranges split inside a 64 KiB unit: the write-back took the GPU-direct path".
  • agc_storage_writeback_blocks: new since #6457 (a24aafb75c, "import adjacent registered ranges as aligned power-of-two blocks"). writeBackBlockTests expects the write-back of "a 4 MiB image at 64 KiB over 66 adjacent 64 KiB pieces" to make 2 imports (aligned blocks through importSegments()). With this PR the image already holds one joined import, so it makes 1. The rest of the row holds: GPU-direct write-back, 1048576 of 1048576 texels stored. Both tests pass on main.

So the rebase also has to settle which rule a surface over several adjacent ranges follows: one joined import from HostImportSpanning, or the aligned power-of-two blocks #6457 introduced. Then that row's expectation needs to match.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6327957581 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#issuecomment-6327957581). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-21T22:29:07Z. --- A third title with storage surfaces that cross the import window, plus a test conflict with current `main` that came in with #6457. **Title.** SuperTuxKart (PPSA69421 00.001.000), a ps5-opengl port, in a race. Its two-slice 1920x1080 color targets are 17,694,720 bytes each, at `0x2bf200000` and `0x2bfc00000`. The title maps that memory in 10 MiB pieces; the import trace shows `0x2bf600000+0xa00000`, `0x2c0000000+0xa00000` and `0x2c0a00000+0xa00000`. So each target spans two or three registered ranges and gets no import from `HostImportFor`. A temporary log at the CPU path of `StorageTexture::upload` showed only these two images there, each with `ExistingHostImportFor` null. Their write-backs were already GPU-direct through `importSegments()`; only the uploads took the CPU path. **Setup.** - Radeon 860M (RDNA 3.5), Ryzen AI 7 350, Windows 11 26300, AMD 32.0.13058.8001, WinLibs GCC 15.2.0, Release. - `main` `0c6a5bd593`, and `main` with `d7f5ffb043` merged locally. - The merge conflicts were in `GuestBufferMemory.hpp` and `Texture.cpp`. I kept `main`'s side, added the `HostImportSpanning` declaration, and used `HostImportSpanning` in the three refresh/upload call sites and in `CopyRefusal`, which `main` split out of the copy check. **`APS5_PROFILE_DRAW=1`, per 10 s of the race:** | | `main` | `main` + this PR | |---|---|---| | CPU-path uploads | 98–156 (≈6.3 ms each) | 0 | | direct uploads | 196–223 | 344 | | resident target lookups of 1 ms or more | 104–158, 697–736 ms | 6, 6.4 ms | | `readTarget` | 1141–1200 ms | 470 ms | FPS doesn't move measurably: 4.97 and 6.12 with this PR against 5.90–8.43 on `main` over four rounds. GPU time per present varies by 30–80 ms between runs here and hides a ~0.7 s per 10 s saving on the draw thread. The race renders as on `main`. **Tests on this machine (merged build, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`).** - `agc_driver_graphics`: passes, `importSpanningTests` included. - `agc_driver_storage_write_back_overhang`: passes on this hardware driver. - `agc_storage_split_writeback`: fails as reported above, "ranges split inside a 64 KiB unit: the write-back took the GPU-direct path". - `agc_storage_writeback_blocks`: **new since #6457** (`a24aafb75c`, "import adjacent registered ranges as aligned power-of-two blocks"). `writeBackBlockTests` expects the write-back of "a 4 MiB image at 64 KiB over 66 adjacent 64 KiB pieces" to make 2 imports (aligned blocks through `importSegments()`). With this PR the image already holds one joined import, so it makes 1. The rest of the row holds: GPU-direct write-back, 1048576 of 1048576 texels stored. Both tests pass on `main`. So the rebase also has to settle which rule a surface over several adjacent ranges follows: one joined import from `HostImportSpanning`, or the aligned power-of-two blocks #6457 introduced. Then that row's expectation needs to match. AI-assisted: yes (Claude Code)
JJenkx commented 2026-10-22 06:15:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T06:15:02Z.


@mcsilva-dev a heads-up, as #9652 touches the same area. It relaxes joinedRun so that a buffer bound from the start of a run of adjacent registered ranges joins the ranges it crosses. Before, it had to cover the run exactly. That is the buffer-descriptor side of imports that do not span a run, where this PR covers storage surfaces through HostImportSpanning. The two change different functions and should merge independently; I mention it in case you see a reason they should share one rule.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6334130427 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#issuecomment-6334130427). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-22T06:15:02Z. --- @mcsilva-dev a heads-up, as #9652 touches the same area. It relaxes `joinedRun` so that a buffer bound from the start of a run of adjacent registered ranges joins the ranges it crosses. Before, it had to cover the run exactly. That is the buffer-descriptor side of imports that do not span a run, where this PR covers storage surfaces through `HostImportSpanning`. The two change different functions and should merge independently; I mention it in case you see a reason they should share one rule.
MarcZX10 commented 2026-11-23 02:56:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:56:49Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the reviewed code adds a joined-import fallback for storage surfaces that cross an import window while preserving the existing per-window lookup contract.

What I ran

Reviewed head d7f5ffb043d61c9d1ed40469f0622089ba9d04d9 against main using the prepared diff and the pinned repository reader. No build or tests were run.

Results

Check Result Note
Diff and changed-file review passed All four changed files read
Tests and build not run Author-reported results were not independently checked

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author reports the graphics validation suite, conventions check, and UFC 6 performance measurements in description.md; these were not independently run. I did not verify later game scenes, physical-console behavior, or files excluded by the prepared review folder. All four files listed as reviewed in manifest.json were read: core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp, core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp, core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp, and core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp. No changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6016074183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6197#pullrequestreview-6016074183). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T02:56:49Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the reviewed code adds a joined-import fallback for storage surfaces that cross an import window while preserving the existing per-window lookup contract. ## What I ran Reviewed head `d7f5ffb043d61c9d1ed40469f0622089ba9d04d9` against `main` using the prepared diff and the pinned repository reader. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and changed-file review | passed | All four changed files read | | Tests and build | not run | Author-reported results were not independently checked | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The author reports the graphics validation suite, conventions check, and UFC 6 performance measurements in `description.md`; these were not independently run. I did not verify later game scenes, physical-console behavior, or files excluded by the prepared review folder. All four files listed as reviewed in `manifest.json` were read: `core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp`, `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`, `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp`, and `core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp`. No changed files were excluded. ## To get this to a good state Nothing is required.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/6197:upstream-pr/6197'
git switch 'upstream-pr/6197'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/6197'
git switch 'upstream-pr/6197'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/6197'
git switch 'upstream-pr/6197'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/6197'
git switch 'main'
git merge --squash 'upstream-pr/6197'
git switch 'main'
git merge --ff-only 'upstream-pr/6197'
git switch 'main'
git merge 'upstream-pr/6197'
git push origin 'main'
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!6197
No description provided.