fix(agc): preserve CPU writes after resident linear target draws #8246

Open
MarcZX10 wants to merge 30 commits from upstream-pr/8246 into main
MarcZX10 commented 2026-10-20 06:50:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T06:50:55Z.


What

Fixes #8152: a later write-back from a recorded linear-target draw could overwrite CPU stores made after Draw returned.

This PR uses the coordinated implementation authored by Rajveer Shekhawat (two commits) and the concurrent-byte correction authored by embersas. The original three commits were split into a series of smaller ones, so each commit derived from their work carries Co-authored-by trailers for both; the drawn-rectangle fix (leave the drawn-rectangle store to targets without a draw snapshot) and the final Refresh() commit are mine and carry none. It snapshots the resident image around a recorded linear draw and merges changed bytes through the linear detiler so untouched guest bytes and CPU writes survive. The regression coverage includes seeded and unseeded partial draws, masked channels, partial geometry, later blending, queued overlapping draws, cached-recipe replay and GPU detiles for supported element widths.

This is separate from #1191's resident-target performance path and #7154's depth-plane buffer coherence. It does not depend on either PR.

Tested

Current head db12f5d6fb (30 commits, rebased onto main 3fea2a937b):

  • Linux, GCC 12.2, lavapipe (LLVM 15.0.6), host CPU gate disabled in a throwaway copy of the tree because this Xeon E5-1620 v2 lacks AVX2 and FMA. All 23 agc_driver_linear_target_* tests plus agc_driver_graphics: 22 pass and 2 skip on lavapipe (direct_write_completion, import_creation). With ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation there are 0 VUID- lines (the layer is inserted at instance and device level). The same run on main is not posted yet.
  • Memory and cost in a throwaway harness (3 targets of 24 MiB, 5 to 60 draws per target): peak RSS +72 to 76 MiB over main, flat in the number of draws and targets (one live snapshot per draw). Per-draw cost was measured only with the guest memory not write-watched (kernel 6.1, no write watch), where the target is compared or uploaded whole: about 44 ms on main and 74 to 99 ms with this PR depending on whether the CPU writes before each draw. No number from a write-watched host and no tools/trace_digest.py summary are available yet. Details are in the comments below.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check pass.

Earlier reports, on older heads and not repeated on this one:

  • On pre-rebase head e5b9ac546 against base 3fd1cc393, the author reports 36/36 fresh focused runs passed on NVIDIA RTX 5070 (driver 617.42) and AMD Radeon(TM) Graphics (driver 32.0.21030.2001), Windows 11 Pro 26200, GCC 15.2 Release with SPIRV-Tools and Khronos validation/synchronization validation enabled, with no new VUIDs or validation warnings, and 118/118 common selected tests per GPU on both base and change.
  • Embersas supplied the concurrent-byte correction in comment 6289116592: on the correction tree before an older rebase (local revision fea0c0cd8a2e8f85454e0d4b5b917915e0e3035b), 15/15 focused tests and 20/20 repeated key-case executions on a Windows 11 RTX 4070 Laptop, NVIDIA 592.82, with Khronos synchronization validation. The concurrent regression recorded 5,668 lost CPU updates on the then-current head and the original unseeded control on main lost 7,680 of 8,192 CPU-written bytes; the corrected cases passed 20/20 repeats with zero lost updates.
  • No Linux/macOS write-watched runtime, console, title or performance result is claimed for the current head.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: #8152
  • Unblocks: none
  • GPUs tested: none on the current head beyond lavapipe (llvmpipe, Linux); NVIDIA RTX 5070 / driver 617.42 and AMD Radeon(TM) Graphics / driver 32.0.21030.2001 on Windows 11 Pro 26200 (reported on pre-rebase head e5b9ac546); NVIDIA RTX 4070 Laptop / driver 592.82 on Windows 11 Pro (reported by Embersas on an older correction tree)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4932110879 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T06:50:55Z. --- ### What Fixes #8152: a later write-back from a recorded linear-target draw could overwrite CPU stores made after `Draw` returned. This PR uses the coordinated implementation authored by Rajveer Shekhawat (two commits) and the concurrent-byte correction authored by embersas. The original three commits were split into a series of smaller ones, so each commit derived from their work carries `Co-authored-by` trailers for both; the drawn-rectangle fix (`leave the drawn-rectangle store to targets without a draw snapshot`) and the final `Refresh()` commit are mine and carry none. It snapshots the resident image around a recorded linear draw and merges changed bytes through the linear detiler so untouched guest bytes and CPU writes survive. The regression coverage includes seeded and unseeded partial draws, masked channels, partial geometry, later blending, queued overlapping draws, cached-recipe replay and GPU detiles for supported element widths. This is separate from #1191's resident-target performance path and #7154's depth-plane buffer coherence. It does not depend on either PR. ### Tested Current head `db12f5d6fb` (30 commits, rebased onto `main` `3fea2a937b`): - Linux, GCC 12.2, lavapipe (LLVM 15.0.6), host CPU gate disabled in a throwaway copy of the tree because this Xeon E5-1620 v2 lacks AVX2 and FMA. All 23 `agc_driver_linear_target_*` tests plus `agc_driver_graphics`: 22 pass and 2 skip on lavapipe (`direct_write_completion`, `import_creation`). With `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` there are 0 `VUID-` lines (the layer is inserted at instance and device level). The same run on `main` is not posted yet. - Memory and cost in a throwaway harness (3 targets of 24 MiB, 5 to 60 draws per target): peak RSS +72 to 76 MiB over `main`, flat in the number of draws and targets (one live snapshot per draw). Per-draw cost was measured only with the guest memory not write-watched (kernel 6.1, no write watch), where the target is compared or uploaded whole: about 44 ms on `main` and 74 to 99 ms with this PR depending on whether the CPU writes before each draw. No number from a write-watched host and no `tools/trace_digest.py` summary are available yet. Details are in the comments below. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check` pass. Earlier reports, on older heads and not repeated on this one: - On pre-rebase head `e5b9ac546` against base `3fd1cc393`, the author reports 36/36 fresh focused runs passed on NVIDIA RTX 5070 (driver 617.42) and AMD Radeon(TM) Graphics (driver 32.0.21030.2001), Windows 11 Pro 26200, GCC 15.2 Release with SPIRV-Tools and Khronos validation/synchronization validation enabled, with no new VUIDs or validation warnings, and 118/118 common selected tests per GPU on both base and change. - Embersas supplied the concurrent-byte correction in [comment 6289116592](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6289116592): on the correction tree before an older rebase (local revision `fea0c0cd8a2e8f85454e0d4b5b917915e0e3035b`), 15/15 focused tests and 20/20 repeated key-case executions on a Windows 11 RTX 4070 Laptop, NVIDIA 592.82, with Khronos synchronization validation. The concurrent regression recorded 5,668 lost CPU updates on the then-current head and the original unseeded control on `main` lost 7,680 of 8,192 CPU-written bytes; the corrected cases passed 20/20 repeats with zero lost updates. - No Linux/macOS write-watched runtime, console, title or performance result is claimed for the current head. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: #8152 - [x] Unblocks: none - [x] GPUs tested: none on the current head beyond lavapipe (llvmpipe, Linux); NVIDIA RTX 5070 / driver 617.42 and AMD Radeon(TM) Graphics / driver 32.0.21030.2001 on Windows 11 Pro 26200 (reported on pre-rebase head `e5b9ac546`); NVIDIA RTX 4070 Laptop / driver 592.82 on Windows 11 Pro (reported by Embersas on an older correction tree) - [x] AI-assisted: yes
MarcZX10 commented 2026-10-20 07:01:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T07:01:40Z.


I marked this PR draft after a second correctness review. Deferring writeback alone is insufficient: the current write-watch policy preserves whole 64 KiB blocks, which can discard the draw output in the same block as a post-draw CPU store. Also, a writeback recorded during a completion needs to execute synchronously rather than remain in a newly opened recorder batch. I am working through a region-aware writeback path and will update the PR when the regression and completion ordering are addressed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6285332964 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6285332964). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T07:01:40Z. --- I marked this PR draft after a second correctness review. Deferring writeback alone is insufficient: the current write-watch policy preserves whole 64 KiB blocks, which can discard the draw output in the same block as a post-draw CPU store. Also, a writeback recorded during a completion needs to execute synchronously rather than remain in a newly opened recorder batch. I am working through a region-aware writeback path and will update the PR when the regression and completion ordering are addressed.
MarcZX10 commented 2026-10-20 07:15:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T07:15:00Z.


Update after checking the reporter’s run on current main: my earlier proposed keep-block explanation was wrong. The seed causes a re-upload after the CPU write, and the draw completion flush happens before later CPU writes. The unseeded, different-output case demonstrates the actual whole-target writeback ordering bug. I also found a lifecycle blocker in my attempted deferral: cache eviction marks a texture released, which makes FlushPending ignore it. I discarded that incomplete local attempt; the published branch remains draft while I work out a fix that keeps the pending image discoverable and orders its later writeback at the access that needs it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6285531985 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6285531985). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T07:15:00Z. --- Update after checking the reporter’s run on current `main`: my earlier proposed keep-block explanation was wrong. The seed causes a re-upload after the CPU write, and the draw completion flush happens before later CPU writes. The unseeded, different-output case demonstrates the actual whole-target writeback ordering bug. I also found a lifecycle blocker in my attempted deferral: cache eviction marks a texture released, which makes `FlushPending` ignore it. I discarded that incomplete local attempt; the published branch remains draft while I work out a fix that keeps the pending image discoverable and orders its later writeback at the access that needs it.
MarcZX10 commented 2026-10-20 07:31:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T07:31:27Z.


I pushed two commits to #8246: fe29558e94 defers linear target eviction writeback and records the draw as a pending writer; 285884da27 updates the regression to flush and wait for readback before checking memory. The writeback keeps changed CPU bytes within the same 64 KiB block while storing the remaining GPU bytes. The focused target builds and links locally, conventions pass, and CTest is blocked before Vulkan initialization by this host CPU’s missing required extensions. I have kept the PR as a draft pending a run on a supported CPU/GPU.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6285801579 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6285801579). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T07:31:27Z. --- I pushed two commits to #8246: `fe29558e94` defers linear target eviction writeback and records the draw as a pending writer; `285884da27` updates the regression to flush and wait for readback before checking memory. The writeback keeps changed CPU bytes within the same 64 KiB block while storing the remaining GPU bytes. The focused target builds and links locally, conventions pass, and CTest is blocked before Vulkan initialization by this host CPU’s missing required extensions. I have kept the PR as a draft pending a run on a supported CPU/GPU.
fogydes commented 2026-10-20 07:35:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-20T07:35:38Z.

Review: COMMENTED


Reviewed the diff, CI, and verified the existing test on current main.

Production code (Draw.cpp): The fix defers the resident linear color target writeback from draw-recording time to batch completion via recorder.OnComplete(). Before this change, StorageTexture::FlushPending ran synchronously during recording — scheduling a whole-target copyout before any CPU stores the game makes after Draw returns. At completion, the OnComplete lambda:

  1. Acquires GuestMemory::GpuMutex() — correct, since FlushPending and WriteBack mutate shared guest-memory state.
  2. Flushes pending overlapping aliases (preserving prior alias reconciliation behavior).
  3. Calls keep->WriteBack() to write the GPU results back.

The keep shared_ptr capture extends the resident's lifetime until the completion callback runs, preventing a use-after-free if the texture is otherwise released. This is sound.

Test (LinearTargetResident.cpp): The regression sequence is well-designed:

  • Program() now takes a blueConstant parameter (default 0x80), allowing the second draw to write a distinct blue value (0xf4).
  • Draw() now takes scissorWidth (default Width), allowing a left-scissored second draw.
  • The run lambda executes two draws: full-width blue=0x80, then left-half blue=0xf4. Between draws, the seed variant writes 0x5a to the left half of the CPU buffer. After both draws, the CPU writes 0x42 to the right half. After WaitIdle(), it checks:
    • Left half: second draw's output (x, y, 2.0, 1.0 with 0xf4 blue → float 2.0 via v_mov_b32 encoding) preserved.
    • Right half: CPU-written 0x42 bytes preserved (not overwritten by GPU writeback).
  • Both run(true) (seeded) and run(false) (unseeded) are exercised.

The instruction encoding 0x7e000200u | blueConstant | (22u << 17u) is a v_mov_b32 with an inline constant — the constant index formula is correct for GCN/RDNA ISA.

CI: conventions, labels pass. Build/platform jobs skip (AGC change, no CI GPU runner).

Local verification: Built agc_driver_linear_target_resident_tests and ran ctest -R "^agc_driver_linear_target_resident$" -V with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 on current main — Passed (0.56s, NVIDIA GeForce RTX 5050 Laptop GPU). The test passes on the existing code; the enhanced test from this PR would exercise the new writeback path.

PR body: Honest about the hardware limitation (Xeon E5-1620 v2 can't run Vulkan tests). Template complete.

One observation: the PR doesn't note VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation testing, but the host CPU guard prevents the runtime from reaching Vulkan initialization anyway, so this is consistent with the limitation.

No blocking issues found.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5582044422 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5582044422). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-20T07:35:38Z. **Review:** COMMENTED --- Reviewed the diff, CI, and verified the existing test on current main. **Production code** (`Draw.cpp`): The fix defers the resident linear color target writeback from draw-recording time to batch completion via `recorder.OnComplete()`. Before this change, `StorageTexture::FlushPending` ran synchronously during recording — scheduling a whole-target copyout before any CPU stores the game makes after `Draw` returns. At completion, the `OnComplete` lambda: 1. Acquires `GuestMemory::GpuMutex()` — correct, since `FlushPending` and `WriteBack` mutate shared guest-memory state. 2. Flushes pending overlapping aliases (preserving prior alias reconciliation behavior). 3. Calls `keep->WriteBack()` to write the GPU results back. The `keep` shared_ptr capture extends the resident's lifetime until the completion callback runs, preventing a use-after-free if the texture is otherwise released. This is sound. **Test** (`LinearTargetResident.cpp`): The regression sequence is well-designed: - `Program()` now takes a `blueConstant` parameter (default `0x80`), allowing the second draw to write a distinct blue value (`0xf4`). - `Draw()` now takes `scissorWidth` (default `Width`), allowing a left-scissored second draw. - The `run` lambda executes two draws: full-width blue=`0x80`, then left-half blue=`0xf4`. Between draws, the `seed` variant writes `0x5a` to the left half of the CPU buffer. After both draws, the CPU writes `0x42` to the right half. After `WaitIdle()`, it checks: - Left half: second draw's output (`x, y, 2.0, 1.0` with `0xf4` blue → float `2.0` via `v_mov_b32` encoding) preserved. - Right half: CPU-written `0x42` bytes preserved (not overwritten by GPU writeback). - Both `run(true)` (seeded) and `run(false)` (unseeded) are exercised. The instruction encoding `0x7e000200u | blueConstant | (22u << 17u)` is a `v_mov_b32` with an inline constant — the constant index formula is correct for GCN/RDNA ISA. **CI**: `conventions`, `labels` pass. Build/platform jobs skip (AGC change, no CI GPU runner). **Local verification**: Built `agc_driver_linear_target_resident_tests` and ran `ctest -R "^agc_driver_linear_target_resident$" -V` with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` on current main — **Passed** (0.56s, NVIDIA GeForce RTX 5050 Laptop GPU). The test passes on the existing code; the enhanced test from this PR would exercise the new writeback path. **PR body**: Honest about the hardware limitation (Xeon E5-1620 v2 can't run Vulkan tests). Template complete. One observation: the PR doesn't note `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` testing, but the host CPU guard prevents the runtime from reaching Vulkan initialization anyway, so this is consistent with the limitation. No blocking issues found.
MarcZX10 commented 2026-10-20 07:40:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T07:40:44Z.


Follow-up: I found the first byte-merge revision could compare against an upload baseline that was stale across recorded draws. Commit ec9d6fecb5 snapshots guest bytes immediately before each recorded linear draw and uses CPU-specific write stamps when preserving changed bytes. The focused target rebuilt and linked successfully; runtime remains blocked before Vulkan initialization by the host CPU feature guard. I have kept the PR draft.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6285949713 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6285949713). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T07:40:44Z. --- Follow-up: I found the first byte-merge revision could compare against an upload baseline that was stale across recorded draws. Commit `ec9d6fecb5` snapshots guest bytes immediately before each recorded linear draw and uses CPU-specific write stamps when preserving changed bytes. The focused target rebuilt and linked successfully; runtime remains blocked before Vulkan initialization by the host CPU feature guard. I have kept the PR draft.
MarcZX10 commented 2026-10-20 07:43:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T07:43:08Z.


Thanks for the detailed review and for checking the previous code on your RTX 5050. Since that review, the fix changed: it now leaves target results pending after batch completion and stores them on the later read/flush path; commit ec9d6fecb5 also refreshes the byte baseline before each draw, and 50f477fccc reuses the full guest snapshot rather than limiting byte merging to 1 MiB. I rebuilt the focused target, but this Xeon host is stopped by the CPU feature guard before Vulkan. If you have time, could you run the current draft head (50f477fccc) through agc_driver_linear_target_resident on your GPU? The PR remains draft while that runtime behavior is unverified here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6285987931 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6285987931). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T07:43:08Z. --- Thanks for the detailed review and for checking the previous code on your RTX 5050. Since that review, the fix changed: it now leaves target results pending after batch completion and stores them on the later read/flush path; commit `ec9d6fecb5` also refreshes the byte baseline before each draw, and `50f477fccc` reuses the full guest snapshot rather than limiting byte merging to 1 MiB. I rebuilt the focused target, but this Xeon host is stopped by the CPU feature guard before Vulkan. If you have time, could you run the current draft head (`50f477fccc`) through `agc_driver_linear_target_resident` on your GPU? The PR remains draft while that runtime behavior is unverified here.
rajvveer commented 2026-10-20 08:31:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rajvveer on 2026-10-20T08:31:18Z.


Sharing a tested alternative implementation and regression coverage for #8152 so we can coordinate with this PR.

Branch: rajvveer/AnyPS5 — fix/agc-linear-target-cpu-writes

This approach captures the actual image on the GPU before a recorded linear draw and merges only changed bytes into guest memory. Atomic word updates preserve untouched channels sharing a word. Image and guest baselines remain separate for subsequent refresh; CPU write-back and padded array layers are covered too. It keeps the recorded path.

The tests extend Celegans12's reproducer: seeded/unseeded partial draws, masked float/RGBA8 channels, partial geometry, later blending, queued overlapping draws, actual cached-recipe replay, and GPU retile cases for 1/2/4/8/16-byte elements. Recipe replay is unseeded so a deferred re-upload cannot mask the original bug.

Validation: Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release with SPIRV-Tools; NVIDIA RTX 5070 (617.42) and AMD Radeon(TM) Graphics (32.0.21030.2001).

  • Independently built base 3fd1cc393: the compatible regression overlay reproduces the overwrite on both GPUs; synchronous controls pass.
  • 36/36 fresh focused runs passed at e5b9ac546, with the correct devices and Khronos 1.4.363 layer verified, synchronization validation enabled, and no validation errors/warnings or skips. This includes five modes plus actual recipe replay.
  • 118/118 common selected tests per GPU passed on base and change. Existing broader-suite diagnostics matched by test name, message and count: NVIDIA 5 errors/10 warnings; AMD 6 errors/10 warnings. No new VUIDs; this is not a claim that the entire suite is validation-clean.
  • Full runtime/relinker builds pass. The paired suite preceded the final recipe-only test tightening; production code was unchanged, and the final build/focused runs were repeated.

These results apply to the linked branch; I have not executed this PR's current 50f477fccc head. No real-title, Linux/macOS, console or performance result is claimed. The snapshot adds GPU work and temporary memory.

Would incorporating the implementation or regression coverage here be useful, or would you prefer a coordinated alternative PR? I have kept the separate PR on hold.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286844955 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6286844955). Originally posted by [rajvveer](https://github.com/rajvveer) on 2026-10-20T08:31:18Z. --- Sharing a tested alternative implementation and regression coverage for #8152 so we can coordinate with this PR. **Branch:** [rajvveer/AnyPS5 — fix/agc-linear-target-cpu-writes](https://github.com/rajvveer/AnyPS5/tree/fix/agc-linear-target-cpu-writes) - [Implementation: 9787db292](https://github.com/rajvveer/AnyPS5/commit/9787db2929d8a39d6edcbf354f2da8c428cb14f0) - [Queued-draw and cached-recipe coverage: e5b9ac546](https://github.com/rajvveer/AnyPS5/commit/e5b9ac5462237d88b49de3a06d22b621e0ef83a6) This approach captures the actual image on the GPU before a recorded linear draw and merges only changed bytes into guest memory. Atomic word updates preserve untouched channels sharing a word. Image and guest baselines remain separate for subsequent refresh; CPU write-back and padded array layers are covered too. It keeps the recorded path. The tests extend [Celegans12's reproducer](https://github.com/Celegans12/AnyPS5/commit/b1c835f80daf9e04a5ab54d7dfca52b62b95f4ea): seeded/unseeded partial draws, masked float/RGBA8 channels, partial geometry, later blending, queued overlapping draws, actual cached-recipe replay, and GPU retile cases for 1/2/4/8/16-byte elements. Recipe replay is unseeded so a deferred re-upload cannot mask the original bug. **Validation:** Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release with SPIRV-Tools; NVIDIA RTX 5070 (617.42) and AMD Radeon(TM) Graphics (32.0.21030.2001). - Independently built base `3fd1cc393`: the compatible regression overlay reproduces the overwrite on both GPUs; synchronous controls pass. - **36/36 fresh focused runs** passed at `e5b9ac546`, with the correct devices and Khronos 1.4.363 layer verified, synchronization validation enabled, and no validation errors/warnings or skips. This includes five modes plus actual recipe replay. - **118/118 common selected tests per GPU** passed on base and change. Existing broader-suite diagnostics matched by test name, message and count: NVIDIA 5 errors/10 warnings; AMD 6 errors/10 warnings. No new VUIDs; this is not a claim that the entire suite is validation-clean. - Full runtime/relinker builds pass. The paired suite preceded the final recipe-only test tightening; production code was unchanged, and the final build/focused runs were repeated. These results apply to the linked branch; I have not executed this PR's current `50f477fccc` head. No real-title, Linux/macOS, console or performance result is claimed. The snapshot adds GPU work and temporary memory. Would incorporating the implementation or regression coverage here be useful, or would you prefer a coordinated alternative PR? I have kept the separate PR on hold.
MarcZX10 commented 2026-10-20 08:47:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T08:47:15Z.


I chose to integrate your implementation and regression commits into #8246 rather than open a second PR for the same issue. Both commits remain authored by you (unknown <[email protected]> as recorded in Git), and the head is now e32a19b4d7957795a3b5cf21848b41889bd193a5, rebased on current main 35fa2bdd. The older-base GPU/build results and the rebase validation limits are now explicit in the PR description. Could you rerun the focused matrix on this exact head when possible? I will keep the draft open pending that current-head check.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6287131920 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6287131920). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T08:47:15Z. --- I chose to integrate your implementation and regression commits into #8246 rather than open a second PR for the same issue. Both commits remain authored by you (`unknown <[email protected]>` as recorded in Git), and the head is now `e32a19b4d7957795a3b5cf21848b41889bd193a5`, rebased on current main `35fa2bdd`. The older-base GPU/build results and the rebase validation limits are now explicit in the PR description. Could you rerun the focused matrix on this exact head when possible? I will keep the draft open pending that current-head check.
MarcZX10 commented 2026-10-20 08:48:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T08:48:12Z.


Correction to my previous note: I said I would keep the PR draft open, but GitHub shows it was already marked ready for review at 07:46 UTC. I had the state wrong; I did not change the draft/ready setting as part of integrating your commits. The PR remains ready for review, with the current-head runtime rerun still outstanding.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6287148519 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6287148519). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T08:48:12Z. --- Correction to my previous note: I said I would keep the PR draft open, but GitHub shows it was already marked ready for review at 07:46 UTC. I had the state wrong; I did not change the draft/ready setting as part of integrating your commits. The PR remains ready for review, with the current-head runtime rerun still outstanding.
rajvveer commented 2026-10-20 10:26:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rajvveer on 2026-10-20T10:26:27Z.


The requested exact-head rerun is complete: e32a19b4d7957795a3b5cf21848b41889bd193a5 was rebuilt in a separate clean worktree and passed 36/36 focused executions. agc_driver_graphics passed too. Independently rebuilt main 35fa2bdd also passed the default resident control on both GPUs.

Hardware: Windows 11 Pro 26200, NVIDIA GeForce RTX 5070 / driver 617.42, and AMD Radeon(TM) Graphics / driver 32.0.21030.2001; GCC 15.2.0 Release with SPIRV-Tools.

The matrix was five resident modes (default, unwatched, draw transitions, eager write-back, synchronous linear targets) plus cached-recipe replay, three repetitions on each GPU. Every process confirmed the intended GPU and loaded Khronos validation layer, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and synchronization validation enabled. Zero VUIDs, synchronization hazards, validation errors/warnings or skips.

A small test-only follow-up is also available: 66f62d174 — strengthen linear target replay and array coverage. It changes only LinearTargetResident.cpp and applies cleanly to e32a19b4:

  • Capture draws a quarter-width area; cached replay draws the original half-width area. The assertions now require pixels produced by replay, alongside preservation of the CPU-written right half.
  • The padded-array fixture now also covers storage snapshot, merge and refresh in imported memory at layer 1, preserving the existing CPU fallback. Distinct initial layer contents and completion of the initial upload make an incorrect baseline-layer offset observable. Full-buffer and refresh checks cover GPU results, CPU writes, padding and the untouched layer.

The follow-up was separately built and tested at 66f62d174: 36/36 focused executions passed, followed by five successful checks after the negative-control experiment was restored and rebuilt (agc_driver_graphics, plus resident and recipe on both GPUs). Temporarily removing the per-layer baseline offset made the new imported-snapshot assertion fail on both GPUs, with the CPU fallback still passing and no validation diagnostics. That mutation is absent from the commit. Convention and whitespace checks pass.

Please cherry-pick 66f62d17479bf7b393326c48926dea6bea31c6f0 if you would like to include this test tightening. The two 36-run results above belong to their respective commits; the follow-up is not yet part of this PR. No real-title, performance, Linux/macOS runtime or fresh full-suite result is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6288823051 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6288823051). Originally posted by [rajvveer](https://github.com/rajvveer) on 2026-10-20T10:26:27Z. --- The requested exact-head rerun is complete: `e32a19b4d7957795a3b5cf21848b41889bd193a5` was rebuilt in a separate clean worktree and passed **36/36 focused executions**. `agc_driver_graphics` passed too. Independently rebuilt main `35fa2bdd` also passed the default resident control on both GPUs. Hardware: Windows 11 Pro 26200, NVIDIA GeForce RTX 5070 / driver 617.42, and AMD Radeon(TM) Graphics / driver 32.0.21030.2001; GCC 15.2.0 Release with SPIRV-Tools. The matrix was five resident modes (default, unwatched, draw transitions, eager write-back, synchronous linear targets) plus cached-recipe replay, three repetitions on each GPU. Every process confirmed the intended GPU and loaded Khronos validation layer, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and synchronization validation enabled. Zero VUIDs, synchronization hazards, validation errors/warnings or skips. A small test-only follow-up is also available: [66f62d174 — strengthen linear target replay and array coverage](https://github.com/rajvveer/AnyPS5/commit/66f62d17479bf7b393326c48926dea6bea31c6f0). It changes only `LinearTargetResident.cpp` and applies cleanly to `e32a19b4`: - Capture draws a quarter-width area; cached replay draws the original half-width area. The assertions now require pixels produced by replay, alongside preservation of the CPU-written right half. - The padded-array fixture now also covers storage snapshot, merge and refresh in imported memory at layer 1, preserving the existing CPU fallback. Distinct initial layer contents and completion of the initial upload make an incorrect baseline-layer offset observable. Full-buffer and refresh checks cover GPU results, CPU writes, padding and the untouched layer. The follow-up was separately built and tested at `66f62d174`: **36/36 focused executions passed**, followed by five successful checks after the negative-control experiment was restored and rebuilt (`agc_driver_graphics`, plus resident and recipe on both GPUs). Temporarily removing the per-layer baseline offset made the new imported-snapshot assertion fail on both GPUs, with the CPU fallback still passing and no validation diagnostics. That mutation is absent from the commit. Convention and whitespace checks pass. Please cherry-pick `66f62d17479bf7b393326c48926dea6bea31c6f0` if you would like to include this test tightening. The two 36-run results above belong to their respective commits; the follow-up is not yet part of this PR. No real-title, performance, Linux/macOS runtime or fresh full-suite result is claimed.
VicRaster commented 2026-10-20 10:44:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by VicRaster on 2026-10-20T10:44:45Z.


I rebuilt exact head e32a19b4d7957795a3b5cf21848b41889bd193a5 on an RTX 4070 Laptop GPU. The existing resident and cached-recipe tests pass, but an additional concurrent-byte regression exposes lost CPU stores.

Attached is a tested correction extending Rajveer Shekhawat’s implementation and MarcZX10’s integration. The seeded/unseeded regression derives from Celegans12’s reproduction. I’m offering this for integration into the existing PR.

Confirmed failures and correction

The concurrent regression uses a 64 × 4096 RGBA8 target. The GPU writes only blue while a CPU thread updates counters in red/green and checks the preceding values. On e32a19b4, it detected 5,668 lost CPU updates, although blue was correct and later CPU sweeps repaired the final counters. Checking only the final buffer misses this failure.

GPU word-level compare-and-swap does not provide atomicity with ordinary CPU stores to adjacent bytes. The correction uses a separate publication shader with write-only uint8_t storage-buffer stores, without destination loads or atomics. The driver already enables storageBuffer8BitAccess; ordinary detile/image variants remain unchanged.

A second regression exposed a stale-baseline problem: an actual GPU write equal to stale image contents can be omitted by the before/after comparison. PrepareLinearDraw now settles prior results and overlapping aliases, then uploads guest contents before taking the GPU baseline. This regression fails with the byte-store-only intermediate and passes with the complete correction.

The comparison is not treated as a write-coverage detector. It depends on establishing a coherent baseline first. Unsynchronized CPU/GPU stores to the same byte still require ordering. Publication remains in the recorded command stream, with the existing reader/host barriers and resource retention. The new checks use the established WaitIdle boundary without an additional test-only flush.

Tested

Hardware: NVIDIA GeForce RTX 4070 Laptop GPU, NVIDIA 592.82 / Windows driver 32.0.15.9282, Windows 11 Pro 10.0.26300. WinLibs GCC 15.2.0 r7, Release, Ninja; Khronos validation layer 1.4.363.0.

  • Rebuilt main 35fa2bdd824f1a77d5d70e7feeae85fd6d9baf04: 8 failures in 12 shared focused entries. The original unseeded regression preserves all 512 GPU pixels but overwrites 7,680/8,192 CPU-written bytes. Seeded and synchronous controls pass.
  • Corrected local revision fea0c0cd8a2e8f85454e0d4b5b917915e0e3035b: 15/15 focused tests pass, including concurrent CPU updates, queued draws, channel masks, partial geometry, dependent GPU copy and CPU-visible label, cache eviction, aliases, same-value writes, expanded resident coverage and cached-recipe replay.
  • After the main comparison, restored and rebuilt the correction: 15/15 pass again.
  • Four key cases repeated five times each: 20/20 executions pass, including zero lost CPU updates in every concurrent run. Same-output seeded/unseeded, sequential CPU-writer, direct-transfer reader and synchronous controls also pass.
  • Main uses the common runtime fixtures with identical assertions. The new same-value and expanded resident/recipe cases require APIs absent from main and are reported separately. Main’s original resident control passes; descriptor-capture mocks use the matching API version.

Every GPU run used:

ANYPS5_REQUIRE_VULKAN=1
ANYPS5_NO_SHADER_CACHE=1
ANYPS5_GPU=RTX 4070 Laptop
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation
VK_LOADER_DEBUG=layer
VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT

Actual validation-layer loading was verified. Base and correction logs contain zero VUIDs, synchronization hazards, missing-layer warnings or skips. The shared deprecated-setting notice is not counted as a new validation error.

Focused candidate command:

ctest --test-dir build-review-8152 -R '^agc_driver_(linear_target_(concurrent_bytes|cpu_writes.*|publication.*|resident|recipe)|graphics|alias_copy_label|array_layer_target)$' -V --timeout 30

Convention and whitespace checks pass. spirv-val --target-env vulkan1.1 accepts the publication shader; its compiled module has 8-bit storage, byte array stride 1 and no atomic operations.

The attachment is a plain unified diff against e32a19b4d7957795a3b5cf21848b41889bd193a5, without commit metadata. Apply it with git apply <attachment>.

SHA256: d7dbee013607048a06f05efea9b4ed3a4ab31086c1b396670e5ca4cf7b403bee

The additional upload/snapshot costs work and temporary memory. No game compatibility, performance improvement, Linux/macOS runtime, fresh full-suite or other-GPU result is claimed for this correction.

AI-assisted: yes.
8152-pr8246-followup.diff.txt

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6289116592 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6289116592). Originally posted by [VicRaster](https://github.com/VicRaster) on 2026-10-20T10:44:45Z. --- I rebuilt exact head `e32a19b4d7957795a3b5cf21848b41889bd193a5` on an RTX 4070 Laptop GPU. The existing resident and cached-recipe tests pass, but an additional concurrent-byte regression exposes lost CPU stores. Attached is a tested correction extending Rajveer Shekhawat’s implementation and MarcZX10’s integration. The seeded/unseeded regression derives from Celegans12’s reproduction. I’m offering this for integration into the existing PR. ### Confirmed failures and correction The concurrent regression uses a 64 × 4096 RGBA8 target. The GPU writes only blue while a CPU thread updates counters in red/green and checks the preceding values. On `e32a19b4`, it detected **5,668 lost CPU updates**, although blue was correct and later CPU sweeps repaired the final counters. Checking only the final buffer misses this failure. GPU word-level compare-and-swap does not provide atomicity with ordinary CPU stores to adjacent bytes. The correction uses a separate publication shader with write-only `uint8_t` storage-buffer stores, without destination loads or atomics. The driver already enables `storageBuffer8BitAccess`; ordinary detile/image variants remain unchanged. A second regression exposed a stale-baseline problem: an actual GPU write equal to stale image contents can be omitted by the before/after comparison. `PrepareLinearDraw` now settles prior results and overlapping aliases, then uploads guest contents before taking the GPU baseline. This regression fails with the byte-store-only intermediate and passes with the complete correction. The comparison is not treated as a write-coverage detector. It depends on establishing a coherent baseline first. Unsynchronized CPU/GPU stores to the same byte still require ordering. Publication remains in the recorded command stream, with the existing reader/host barriers and resource retention. The new checks use the established `WaitIdle` boundary without an additional test-only flush. ### Tested **Hardware:** NVIDIA GeForce RTX 4070 Laptop GPU, NVIDIA 592.82 / Windows driver 32.0.15.9282, Windows 11 Pro 10.0.26300. WinLibs GCC 15.2.0 r7, Release, Ninja; Khronos validation layer 1.4.363.0. - Rebuilt main `35fa2bdd824f1a77d5d70e7feeae85fd6d9baf04`: **8 failures in 12 shared focused entries**. The original unseeded regression preserves all 512 GPU pixels but overwrites **7,680/8,192 CPU-written bytes**. Seeded and synchronous controls pass. - Corrected local revision `fea0c0cd8a2e8f85454e0d4b5b917915e0e3035b`: **15/15 focused tests pass**, including concurrent CPU updates, queued draws, channel masks, partial geometry, dependent GPU copy and CPU-visible label, cache eviction, aliases, same-value writes, expanded resident coverage and cached-recipe replay. - After the main comparison, restored and rebuilt the correction: **15/15 pass again**. - Four key cases repeated five times each: **20/20 executions pass**, including zero lost CPU updates in every concurrent run. Same-output seeded/unseeded, sequential CPU-writer, direct-transfer reader and synchronous controls also pass. - Main uses the common runtime fixtures with identical assertions. The new same-value and expanded resident/recipe cases require APIs absent from main and are reported separately. Main’s original resident control passes; descriptor-capture mocks use the matching API version. Every GPU run used: ```text ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU=RTX 4070 Laptop VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer VK_LAYER_ENABLES=VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT ``` Actual validation-layer loading was verified. Base and correction logs contain **zero VUIDs, synchronization hazards, missing-layer warnings or skips**. The shared deprecated-setting notice is not counted as a new validation error. Focused candidate command: ```powershell ctest --test-dir build-review-8152 -R '^agc_driver_(linear_target_(concurrent_bytes|cpu_writes.*|publication.*|resident|recipe)|graphics|alias_copy_label|array_layer_target)$' -V --timeout 30 ``` Convention and whitespace checks pass. `spirv-val --target-env vulkan1.1` accepts the publication shader; its compiled module has 8-bit storage, byte array stride 1 and no atomic operations. The attachment is a plain unified diff against `e32a19b4d7957795a3b5cf21848b41889bd193a5`, without commit metadata. Apply it with `git apply <attachment>`. SHA256: `d7dbee013607048a06f05efea9b4ed3a4ab31086c1b396670e5ca4cf7b403bee` The additional upload/snapshot costs work and temporary memory. No game compatibility, performance improvement, Linux/macOS runtime, fresh full-suite or other-GPU result is claimed for this correction. AI-assisted: yes. [8152-pr8246-followup.diff.txt](https://github.com/user-attachments/files/33712852/8152-pr8246-followup.diff.txt)
MarcZX10 commented 2026-10-20 11:00:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T11:00:55Z.


Integrated the offered correction into #8246 as commit 030409ad4a86041c29fa65bf018632452d5b5cab after rebasing all three PR commits onto current main 891d5675150936bbb330a1f27bacc86113dd2532. The new commit preserves embersas as its author; the two Rajveer commits also retain their original author metadata.

The contributor-reported RTX 4070 Laptop run and correction-tree test results are recorded in the PR description, explicitly as pre-latest-rebase results. On the rebased head, git diff --check passes. The local conventions script stops at its duplicate-export scan with E2BIG, and hosted metadata checks were pending at the last poll. I could not run a current-head Vulkan build/runtime on this host.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6289371014 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6289371014). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T11:00:55Z. --- Integrated the offered correction into #8246 as commit `030409ad4a86041c29fa65bf018632452d5b5cab` after rebasing all three PR commits onto current `main` `891d5675150936bbb330a1f27bacc86113dd2532`. The new commit preserves `embersas` as its author; the two Rajveer commits also retain their original author metadata. The contributor-reported RTX 4070 Laptop run and correction-tree test results are recorded in the PR description, explicitly as pre-latest-rebase results. On the rebased head, `git diff --check` passes. The local conventions script stops at its duplicate-export scan with `E2BIG`, and hosted metadata checks were pending at the last poll. I could not run a current-head Vulkan build/runtime on this host.
wachi35676 commented 2026-10-20 12:19:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T12:19:02Z.


This is a runtime run of the exact current head e32a19b4d, which was still outstanding. I merged it onto main 02fb1ce53 (a clean merge, after #8172).

Setup: Windows 11 (26300), WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON. The GPUs are an RTX 5070 Ti (NVIDIA 617.42) and an AMD Radeon iGPU (AMD proprietary 2.0.353). Both runs used ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; the validation layer was not used.

  • agc_driver_linear_target_resident passes 3 of 3 on each GPU. So do agc_storage_writeback_blocks, agc_write_tracking and agc_write_tracking_metadata_commit. The test logs linear target resident device: NVIDIA GeForce RTX 5070 Ti and ... AMD Radeon(TM) Graphics respectively.
  • Negative control: the PR's test uses PrepareLinearDraw, FinishLinearDraw and the new Dispatch overload, so it doesn't compile on main alone. Instead I kept the whole PR and restored only main's Draw.cpp, which removes the PrepareLinearDraw and FinishLinearDraw hook-up. The test then fails 2 of 2 on each GPU with unseeded scissor: write-back overwrote the CPU's untouched right half in row 0.
  • Related set of 75 tests (agc_driver_graphics, which includes the new TextureDetiler.cpp cases, plus storage, partially_resident, msaa, multisample, label, stencil, tessellation, write_tracking, resident and so on): 75 of 75 pass on each GPU. agc_driver_stencil_ref_export skips on NVIDIA because the GPU has no stencil export.

Not measured: the cost per draw. PrepareLinearDraw runs WriteBack() and then copies the whole image into a new 2x-size DeviceBuffer before every recorded draw into a resident linear target, and I have no title that exercises this path to time it.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6290675145 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6290675145). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-20T12:19:02Z. --- This is a runtime run of the exact current head `e32a19b4d`, which was still outstanding. I merged it onto `main` `02fb1ce53` (a clean merge, after #8172). Setup: Windows 11 (26300), WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`. The GPUs are an RTX 5070 Ti (NVIDIA 617.42) and an AMD Radeon iGPU (AMD proprietary 2.0.353). Both runs used `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`; the validation layer was not used. - `agc_driver_linear_target_resident` passes 3 of 3 on each GPU. So do `agc_storage_writeback_blocks`, `agc_write_tracking` and `agc_write_tracking_metadata_commit`. The test logs `linear target resident device: NVIDIA GeForce RTX 5070 Ti` and `... AMD Radeon(TM) Graphics` respectively. - Negative control: the PR's test uses `PrepareLinearDraw`, `FinishLinearDraw` and the new `Dispatch` overload, so it doesn't compile on `main` alone. Instead I kept the whole PR and restored only `main`'s `Draw.cpp`, which removes the `PrepareLinearDraw` and `FinishLinearDraw` hook-up. The test then fails 2 of 2 on each GPU with `unseeded scissor: write-back overwrote the CPU's untouched right half in row 0`. - Related set of 75 tests (`agc_driver_graphics`, which includes the new `TextureDetiler.cpp` cases, plus storage, partially_resident, msaa, multisample, label, stencil, tessellation, write_tracking, resident and so on): 75 of 75 pass on each GPU. `agc_driver_stencil_ref_export` skips on NVIDIA because the GPU has no stencil export. Not measured: the cost per draw. `PrepareLinearDraw` runs `WriteBack()` and then copies the whole image into a new 2x-size `DeviceBuffer` before every recorded draw into a resident linear target, and I have no title that exercises this path to time it. AI-assisted: yes (Claude Code); results above were run on this machine.
Celegans12 commented 2026-10-20 16:26:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-20T16:26:51Z.


I tested #8246 with Ghost of Yōtei (PPSA26344) on Windows 11 and an RTX 3080 Laptop, since #6892's resident linear targets are what broke our warm world runs in the first place. The unit-level fix holds up well on our tree. In the game, though, it doesn't fix the spawn: with resident linear targets on, Atsu still isn't at the river.

One caveat first: this isn't plain main. Our tree is main b50976750d merged with our local Yōtei work (local/merge19 a5d6e1707a, where resident linear targets are opt-in behind APS5_RESIDENT_LINEAR=1). I applied your head 030409ad4a on top as one diff. There were three small conflicts (Draw.cpp, Texture.cpp and the CMake test list), and I kept both sides in each. The shader cache version didn't change.

The tests all pass. Your new tests, the upstream resident-linear tests and the nearby storage and write-tracking tests went 22/22, three times each, with resident linear on. My #8152 reproducer passes 5/5 in both the seeded and the unseeded case. With only your Draw.cpp hooks taken out again, it fails 3/3 with 7,680 of the 8,192 right-half bytes rolled back, as before.

In the game, the warm run from our Ainu-village save never shows Atsu. From frame 078 on, the camera sits under the water looking up at the forest. That's the same family of symptoms as our earlier resident-linear runs (T-pose in the sky). With resident linear off, the same save spawns him at the river every time. The path does run there: in the world, about 15-43 recorded draws per 10 s go into resident linear targets, and each one gets your "linear draw baseline" upload.

I also wanted to know whether the game just reads those targets before the recorded write-back lands. So I added a local debug switch that does a full Recorder::Sync right after every recorded linear-target draw. That makes the write-back land before the next packet. It didn't help: the camera was still under the water. My guess is that the bytes reaching guest memory, or the resident image that the next draw starts from, are wrong in a case the tests don't cover, not that the order is wrong. I can't rule out an interaction with our local changes yet, though. Neither run lost the device or hit a GPU write fault.

frame 85: #8246 with resident linear on, the same with a sync after each linear draw, and resident linear off

If it helps, I can run an instrumented build next. For example, it could dump a linear target's guest bytes after one of these draws with resident linear on and off and diff them. Or I can try a newer head. Is there anything you'd want me to log in particular?

Details
  • Build: local/test-8246 = local/merge19 a5d6e1707a + #8246 030409ad4a as one commit (2339d4e0e6) + the reproducer as its own execution test (LinearTargetRepro8152.cpp, from Celegans12/AnyPS5 repro/8152-linear-writeback b1c835f80d) + the debug switch (APS5_LINEAR_DRAW_SYNC, local only). SourceVersion 3b35146912b7970c, the same as without the PR. GCC 15.2.0 Release, NVIDIA RTX 3080 Laptop.
  • Tests (APS5_RESIDENT_LINEAR=1, ctest -j4 --repeat until-fail:3): agc_driver_linear_target_{resident, recipe, cpu_writes, cpu_writes_seeded, concurrent_bytes, publication, publication_mask/geometry/reader/eviction/alias/same, repro8152}, agc_driver_partially_resident_{snapshot, pending_stores}, agc_driver_uint8x4_color_target_no_resident, agc_resident_present, agc_storage_writeback_blocks, agc_write_tracking, agc_write_tracking_metadata_commit, agc_driver_graphics, linear_display_buffer: 22/22.
  • Reproducer [8152] lines with the PR, 5/5: seeded and unseeded, each with the second draw recorded, left half 0/512 pixels lost, right half 0/8192 bytes not the CPU's 0x42. Without the PR's PrepareLinearDraw/FinishLinearDraw hooks (Draw.cpp only), 3/3 failed: seeded 0/8192, unseeded 7680/8192.
  • World runs: warm, web-teshio-b save, pad script without jumps, our usual Yōtei env plus APS5_NO_DISPATCH_OVERLAP=1, stopped 10 s after frame_090.
    • Run 1 (APS5_RESIDENT_LINEAR=1): frame_078 at 247 s, frame_090 at 401 s. Frames 078-090 show the camera below the water surface, no Atsu.
    • Run 2 (also APS5_LINEAR_DRAW_SYNC=1): frame_090 at 365 s, frames 078-090 fog/water, no Atsu. Address-based syncs 3,675 → 4,233, so the switch fired.
    • Reference (APS5_RESIDENT_LINEAR unset, earlier run on merge19 045af03378): Atsu at the river, frames 078-090.
  • Storage counters, per 10 s in the world: 15-43 "linear draw baseline" uploads (2-45 MiB), matched by as many "linear target" write-backs. During loading it reaches up to 157 (386 MiB). 0 host-heap refusals.
  • No frame-time comparison, because the broken runs render a much simpler scene than the river.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6295776844 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6295776844). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-20T16:26:51Z. --- I tested #8246 with Ghost of Yōtei (PPSA26344) on Windows 11 and an RTX 3080 Laptop, since #6892's resident linear targets are what broke our warm world runs in the first place. The unit-level fix holds up well on our tree. In the game, though, it doesn't fix the spawn: with resident linear targets on, Atsu still isn't at the river. One caveat first: this isn't plain main. Our tree is main b50976750d merged with our local Yōtei work (`local/merge19` a5d6e1707a, where resident linear targets are opt-in behind `APS5_RESIDENT_LINEAR=1`). I applied your head 030409ad4a on top as one diff. There were three small conflicts (Draw.cpp, Texture.cpp and the CMake test list), and I kept both sides in each. The shader cache version didn't change. The tests all pass. Your new tests, the upstream resident-linear tests and the nearby storage and write-tracking tests went 22/22, three times each, with resident linear on. My #8152 reproducer passes 5/5 in both the seeded and the unseeded case. With only your Draw.cpp hooks taken out again, it fails 3/3 with 7,680 of the 8,192 right-half bytes rolled back, as before. In the game, the warm run from our Ainu-village save never shows Atsu. From frame 078 on, the camera sits under the water looking up at the forest. That's the same family of symptoms as our earlier resident-linear runs (T-pose in the sky). With resident linear off, the same save spawns him at the river every time. The path does run there: in the world, about 15-43 recorded draws per 10 s go into resident linear targets, and each one gets your "linear draw baseline" upload. I also wanted to know whether the game just reads those targets before the recorded write-back lands. So I added a local debug switch that does a full `Recorder::Sync` right after every recorded linear-target draw. That makes the write-back land before the next packet. It didn't help: the camera was still under the water. My guess is that the bytes reaching guest memory, or the resident image that the next draw starts from, are wrong in a case the tests don't cover, not that the order is wrong. I can't rule out an interaction with our local changes yet, though. Neither run lost the device or hit a GPU write fault. ![frame 85: #8246 with resident linear on, the same with a sync after each linear draw, and resident linear off](https://raw.githubusercontent.com/Celegans12/AnyPS5/bringup-media/yotei/2026-10-20/8246-resident-linear-frame085.png) If it helps, I can run an instrumented build next. For example, it could dump a linear target's guest bytes after one of these draws with resident linear on and off and diff them. Or I can try a newer head. Is there anything you'd want me to log in particular? <details><summary>Details</summary> - Build: `local/test-8246` = `local/merge19` a5d6e1707a + #8246 030409ad4a as one commit (2339d4e0e6) + the reproducer as its own execution test (`LinearTargetRepro8152.cpp`, from Celegans12/AnyPS5 `repro/8152-linear-writeback` b1c835f80d) + the debug switch (`APS5_LINEAR_DRAW_SYNC`, local only). SourceVersion 3b35146912b7970c, the same as without the PR. GCC 15.2.0 Release, NVIDIA RTX 3080 Laptop. - Tests (`APS5_RESIDENT_LINEAR=1`, `ctest -j4 --repeat until-fail:3`): agc_driver_linear_target_{resident, recipe, cpu_writes, cpu_writes_seeded, concurrent_bytes, publication, publication_mask/geometry/reader/eviction/alias/same, repro8152}, agc_driver_partially_resident_{snapshot, pending_stores}, agc_driver_uint8x4_color_target_no_resident, agc_resident_present, agc_storage_writeback_blocks, agc_write_tracking, agc_write_tracking_metadata_commit, agc_driver_graphics, linear_display_buffer: 22/22. - Reproducer `[8152]` lines with the PR, 5/5: seeded and unseeded, each with the second draw recorded, left half 0/512 pixels lost, right half 0/8192 bytes not the CPU's 0x42. Without the PR's `PrepareLinearDraw`/`FinishLinearDraw` hooks (Draw.cpp only), 3/3 failed: seeded 0/8192, unseeded 7680/8192. - World runs: warm, `web-teshio-b` save, pad script without jumps, our usual Yōtei env plus `APS5_NO_DISPATCH_OVERLAP=1`, stopped 10 s after frame_090. - Run 1 (`APS5_RESIDENT_LINEAR=1`): frame_078 at 247 s, frame_090 at 401 s. Frames 078-090 show the camera below the water surface, no Atsu. - Run 2 (also `APS5_LINEAR_DRAW_SYNC=1`): frame_090 at 365 s, frames 078-090 fog/water, no Atsu. Address-based syncs 3,675 → 4,233, so the switch fired. - Reference (`APS5_RESIDENT_LINEAR` unset, earlier run on merge19 045af03378): Atsu at the river, frames 078-090. - Storage counters, per 10 s in the world: 15-43 "linear draw baseline" uploads (2-45 MiB), matched by as many "linear target" write-backs. During loading it reaches up to 157 (386 MiB). 0 host-heap refusals. - No frame-time comparison, because the broken runs render a much simpler scene than the river. </details>
MarcZX10 commented 2026-10-20 19:16:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T19:16:48Z.


@Celegans12, thanks for offering. A targeted capture on the current head 030409ad4a would help. If convenient, pick one linear target associated with the first incorrect water frame and record its guest address, dimensions/pitch/format, the guest bytes immediately before the draw baseline upload, the resident image bytes after the draw, and the guest bytes after write-back. The key is to identify the first point where those byte ranges diverge; no need for broad per-draw logging. If selecting a target is unclear, a newer-head run alone would still tell us whether the behavior changed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6299188399 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6299188399). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T19:16:48Z. --- @Celegans12, thanks for offering. A targeted capture on the current head `030409ad4a` would help. If convenient, pick one linear target associated with the first incorrect water frame and record its guest address, dimensions/pitch/format, the guest bytes immediately before the draw baseline upload, the resident image bytes after the draw, and the guest bytes after write-back. The key is to identify the first point where those byte ranges diverge; no need for broad per-draw logging. If selecting a target is unclear, a newer-head run alone would still tell us whether the behavior changed.
MarcZX10 commented 2026-10-20 20:40:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T20:40:09Z.


Thanks for the detailed title run and the sync control. That changes the next question: the isolated CPU-write regressions pass, but this title still diverges even when each writeback is forced to complete before the next packet, so completion ordering alone does not explain the spawn failure. The most useful next capture would be the first target/draw that differs between resident-linear on and off: guest address, dimensions/format/pitch, bytes before the draw, resident image bytes after it, bytes written back, and the next consumer’s read. A narrow capture around the first divergence should distinguish stale baseline/image contents from a format/layout or alias mismatch. If you can share such a trace (or an instrumented reproducer), I can investigate the next fix in this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300989649 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6300989649). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T20:40:09Z. --- Thanks for the detailed title run and the sync control. That changes the next question: the isolated CPU-write regressions pass, but this title still diverges even when each writeback is forced to complete before the next packet, so completion ordering alone does not explain the spawn failure. The most useful next capture would be the first target/draw that differs between resident-linear on and off: guest address, dimensions/format/pitch, bytes before the draw, resident image bytes after it, bytes written back, and the next consumer’s read. A narrow capture around the first divergence should distinguish stale baseline/image contents from a format/layout or alias mismatch. If you can share such a trace (or an instrumented reproducer), I can investigate the next fix in this PR.
MarcZX10 commented 2026-10-20 22:37:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:37:03Z.


Thanks, this separates the #8152 byte-preservation case from the remaining Yōtei spawn failure: the focused CPU-write/repro tests and their negative control still validate the intended fix, while the title remains below water even with the per-draw sync switch. For the first affected target, could you log a compact identity (guest address, format, extent/pitch) and a hash plus a few sampled bytes at three points: after PrepareLinearDraw establishes the baseline, after the recorded draw completes just before its completion callback, and after WriteBack? That should show where the frame used for the spawn first diverges without dumping broad title memory. Comparing resident-linear off/on on the same saved state would help anchor it. There is no need to spend time timing the broken frame; I agree those scenes are not comparable.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303331456 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6303331456). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T22:37:03Z. --- Thanks, this separates the #8152 byte-preservation case from the remaining Yōtei spawn failure: the focused CPU-write/repro tests and their negative control still validate the intended fix, while the title remains below water even with the per-draw sync switch. For the first affected target, could you log a compact identity (guest address, format, extent/pitch) and a hash plus a few sampled bytes at three points: after `PrepareLinearDraw` establishes the baseline, after the recorded draw completes just before its completion callback, and after `WriteBack`? That should show where the frame used for the spawn first diverges without dumping broad title memory. Comparing resident-linear off/on on the same saved state would help anchor it. There is no need to spend time timing the broken frame; I agree those scenes are not comparable.
MarcZX10 commented 2026-10-20 23:22:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T23:22:44Z.


Thanks for the detailed run. The result narrows this down: the reproducer confirms the CPU write-back regression is fixed, while forcing a full sync after each recorded draw does not fix the Yōtei scene, so I agree we should look at the bytes and resident image contents rather than add more ordering waits.

If you can run one instrumented comparison, please pick a target touched during frames 078–090 and log/dump:

  • the target address/range, format, dimensions, pitch/tiling, and draw sequence number;
  • its guest-memory bytes after that draw's write-back has completed;
  • the same bytes immediately before the next draw that reads or writes the target; and
  • the corresponding resident-image contents at those two points, if the existing debug path can read them back.

Please capture resident-on and resident-off runs from the same save and report the first differing byte/pixel with the owning draw. A small bounded set around one target is enough; no need for a full frame dump. That should tell us whether the mismatch is in the write-back, the resident image used by the next draw, or another local Yōtei change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6304027742 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6304027742). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T23:22:44Z. --- Thanks for the detailed run. The result narrows this down: the reproducer confirms the CPU write-back regression is fixed, while forcing a full sync after each recorded draw does not fix the Yōtei scene, so I agree we should look at the bytes and resident image contents rather than add more ordering waits. If you can run one instrumented comparison, please pick a target touched during frames 078–090 and log/dump: - the target address/range, format, dimensions, pitch/tiling, and draw sequence number; - its guest-memory bytes after that draw's write-back has completed; - the same bytes immediately before the next draw that reads or writes the target; and - the corresponding resident-image contents at those two points, if the existing debug path can read them back. Please capture resident-on and resident-off runs from the same save and report the first differing byte/pixel with the owning draw. A small bounded set around one target is enough; no need for a full frame dump. That should tell us whether the mismatch is in the write-back, the resident image used by the next draw, or another local Yōtei change.
rajvveer commented 2026-10-21 05:43:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rajvveer on 2026-10-21T05:43:11Z.


The exact PR head 030409ad4a86041c29fa65bf018632452d5b5cab now has an additional hardware check: it rebuilt and passed all 15 focused entries on each local GPU, followed by five repeats each of resident, recipe, concurrent bytes and same-value publication per GPU. That is 70 successful executions: 68 hardware runs and 2 graphics-mock runs. All 12 continuous-writer executions reported zero transient regressions, lost/stale updates or final corruption. The intended GPUs and Khronos device layer were verified; no validation errors/warnings, synchronization hazards or skips occurred in that PR-head matrix.

While investigating the remaining coherence paths, I also found and fixed a separate, reproducible swizzle mismatch in upstream main. The standalone commit is c19ba2477 — respect pipe-bank XOR when reusing storage images, based on main 3fb6a126fa80274dad6c488cbca8b40a0ba549cd:

  • pendingAlias() could borrow image coordinates from a pending image with a different pipeBankXor. Those coordinates represent different guest bytes. A cached one-slice array read returned 0x22222222 where the untouched bytes must remain 0x5a5a5a5a.
  • SameSurfaceShape() had the same omission, allowing a raw CopyBuffer to become an image-coordinate copy between incompatible mappings. The resulting destination bytes differed from the source.

Both predicates now require equal XOR. Different mappings use the existing transfer/upload paths; matching-XOR borrowing and image copies remain explicitly tested. The existing fixture checks both paths, all 64 KiB of copied data, and the source's written/untouched contents. Its 1 MiB backing allocation keeps the normal calibrated Windows import watched; the surface itself remains 64 KiB.

Validation of c19ba2477, separately from the PR-head results above:

  • Exact main production plus the final fixture fails the incorrect borrowed-pixel assertion on both GPUs. With only that guard fixed, the raw-copy assertion still fails on both. All four expected data failures are validation-clean.
  • Complete fix: 12/12 regression executions pass (five watched repeats plus one unwatched run per GPU), without validation diagnostics or skips.
  • The related set completes 12/12 numerical passes. Its Uint8x4 case has four preexisting synchronization errors per GPU on both main and the fix; normalized messages and counts match exactly. This is not an all-suite validation-clean claim.
  • An initial NVIDIA array-layer run timed out, and an initial CPU/mock graphics run exceeded its outer timeout. Subsequent paired base/fix repeats passed 24/24, followed by the completed related set. The initial timeout causes remain unconfirmed.

Both result sets used Windows 11 Pro 26200, GCC 15.2.0 Release, NVIDIA RTX 5070 / 617.42 and AMD Radeon(TM) Graphics / 32.0.21030.2001, required Vulkan, disabled shader cache and Khronos 1.4.363 synchronization validation. Convention and whitespace checks pass for the new commit.

The alias fix is available independently of this PR. I have not established that it explains Yotei's spawn failure; the first-divergence capture remains necessary to connect the title symptom to a specific path. No game, performance, Linux/macOS runtime or full-suite result is claimed for this fix.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6308991352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6308991352). Originally posted by [rajvveer](https://github.com/rajvveer) on 2026-10-21T05:43:11Z. --- The exact PR head `030409ad4a86041c29fa65bf018632452d5b5cab` now has an additional hardware check: it rebuilt and passed all 15 focused entries on each local GPU, followed by five repeats each of resident, recipe, concurrent bytes and same-value publication per GPU. That is **70 successful executions: 68 hardware runs and 2 graphics-mock runs**. All 12 continuous-writer executions reported zero transient regressions, lost/stale updates or final corruption. The intended GPUs and Khronos device layer were verified; no validation errors/warnings, synchronization hazards or skips occurred in that PR-head matrix. While investigating the remaining coherence paths, I also found and fixed a separate, reproducible swizzle mismatch in upstream main. The standalone commit is [c19ba2477 — respect pipe-bank XOR when reusing storage images](https://github.com/rajvveer/AnyPS5/commit/c19ba2477dd04aee6472cd8e4292a349e4c14cf1), based on main `3fb6a126fa80274dad6c488cbca8b40a0ba549cd`: - `pendingAlias()` could borrow image coordinates from a pending image with a different `pipeBankXor`. Those coordinates represent different guest bytes. A cached one-slice array read returned `0x22222222` where the untouched bytes must remain `0x5a5a5a5a`. - `SameSurfaceShape()` had the same omission, allowing a raw `CopyBuffer` to become an image-coordinate copy between incompatible mappings. The resulting destination bytes differed from the source. Both predicates now require equal XOR. Different mappings use the existing transfer/upload paths; matching-XOR borrowing and image copies remain explicitly tested. The existing fixture checks both paths, all 64 KiB of copied data, and the source's written/untouched contents. Its 1 MiB backing allocation keeps the normal calibrated Windows import watched; the surface itself remains 64 KiB. Validation of **c19ba2477**, separately from the PR-head results above: - Exact main production plus the final fixture fails the incorrect borrowed-pixel assertion on both GPUs. With only that guard fixed, the raw-copy assertion still fails on both. All four expected data failures are validation-clean. - Complete fix: **12/12 regression executions pass** (five watched repeats plus one unwatched run per GPU), without validation diagnostics or skips. - The related set completes **12/12 numerical passes**. Its Uint8x4 case has four preexisting synchronization errors per GPU on both main and the fix; normalized messages and counts match exactly. This is not an all-suite validation-clean claim. - An initial NVIDIA array-layer run timed out, and an initial CPU/mock graphics run exceeded its outer timeout. Subsequent paired base/fix repeats passed **24/24**, followed by the completed related set. The initial timeout causes remain unconfirmed. Both result sets used Windows 11 Pro 26200, GCC 15.2.0 Release, NVIDIA RTX 5070 / 617.42 and AMD Radeon(TM) Graphics / 32.0.21030.2001, required Vulkan, disabled shader cache and Khronos 1.4.363 synchronization validation. Convention and whitespace checks pass for the new commit. The alias fix is available independently of this PR. I have not established that it explains Yotei's spawn failure; the first-divergence capture remains necessary to connect the title symptom to a specific path. No game, performance, Linux/macOS runtime or full-suite result is claimed for this fix.
MarcZX10 commented 2026-10-21 05:44:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T05:44:57Z.


Thanks for the exact-head matrix. I understand the 70 successful executions cover the current #8246 behavior, including the focused resident/recipe/concurrent-byte cases on both reported GPUs, with the two mock runs separately identified. I will keep the standalone pipe-bank-XOR mismatch distinct until a capture ties it to the Yōtei spawn symptom; the comment correctly avoids claiming that link.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309014744 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6309014744). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T05:44:57Z. --- Thanks for the exact-head matrix. I understand the 70 successful executions cover the current #8246 behavior, including the focused resident/recipe/concurrent-byte cases on both reported GPUs, with the two mock runs separately identified. I will keep the standalone pipe-bank-XOR mismatch distinct until a capture ties it to the Yōtei spawn symptom; the comment correctly avoids claiming that link.
tibzejoker commented 2026-10-21 17:37:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-21T17:37:42Z.


GTA V (PPSA04264) runs, as promised on #8152. The base is main 663de1ab2 plus the two #9136 fixes (Dripl1x's d6e270ea9, and #9159 with 81aec5834), without which this title crashes in the open world. #8246's three commits (91533a6ef, 2b3589426, 030409ad4) were cherry-picked on that base. The only conflicts were the CMake test lists.

One 330 s open-world run per row from the same story save, APS5_PROFILE_DRAW=1. Windows 11 26200, RTX 4090 (NVIDIA 616.92), i9-13900K, WinLibs GCC 15.2.0 r7, Release:

tree committer µs/draw draws per 10 s committer busy frames in 300 s
base (resident linear targets, main's path) 38.9 213k 83 % 1,892
base + APS5_NO_RESIDENT_LINEAR=1 (synchronous) 41.7 203k 85 % 1,649
base + #8246 43.4 196k 85 % 2,035
  • Rendering. It is correct with #8246, and the spawn is normal. This title doesn't show Yōtei's symptom on any of the three rows.
  • What runs per 10 s. GTA does about 100 to 130 linear-target write-backs (25 to 38 MiB). With #8246, about 104 "linear draw baseline" uploads (about 27 MiB) are added.
  • Cost. On this title, #8246 costs about +4.5 µs per draw (+12 %) on the draw committer, which is GTA's bottleneck in the open world. The synchronous path costs +2.8 µs. Frames per 300 s follow where the save respawns (2 to 11 FPS within a run here), so I would not read the frame column. The committer cost is the comparable number.
  • Where it goes. PrepareLinearDraw runs WriteBack(), then a fresh upload(), then copies the whole image into a 2x DeviceBuffer before every recorded draw into a resident linear target. On these targets, the draw usually covers the whole surface. One way to keep the fix and drop most of that cost might be to take the baseline only when the CPU wrote the target since its last write-back: the write watch already knows. Otherwise the previous write-back's bytes are the baseline. I haven't tried it.

cc @Celegans12 (#8152). The correctness fix holds here, but for this title it costs more than going back to synchronous targets.

AI-assisted: yes (Claude Code). Measured on the machine above.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322476559 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#issuecomment-6322476559). Originally posted by [tibzejoker](https://github.com/tibzejoker) on 2026-10-21T17:37:42Z. --- GTA V (PPSA04264) runs, as promised on #8152. The base is `main` 663de1ab2 plus the two #9136 fixes (Dripl1x's d6e270ea9, and #9159 with 81aec5834), without which this title crashes in the open world. #8246's three commits (91533a6ef, 2b3589426, 030409ad4) were cherry-picked on that base. The only conflicts were the CMake test lists. One 330 s open-world run per row from the same story save, `APS5_PROFILE_DRAW=1`. Windows 11 26200, RTX 4090 (NVIDIA 616.92), i9-13900K, WinLibs GCC 15.2.0 r7, Release: | tree | committer µs/draw | draws per 10 s | committer busy | frames in 300 s | |---|---|---|---|---| | base (resident linear targets, `main`'s path) | **38.9** | 213k | 83 % | 1,892 | | base + `APS5_NO_RESIDENT_LINEAR=1` (synchronous) | 41.7 | 203k | 85 % | 1,649 | | base + #8246 | **43.4** | 196k | 85 % | 2,035 | - **Rendering.** It is correct with #8246, and the spawn is normal. This title doesn't show Yōtei's symptom on any of the three rows. - **What runs per 10 s.** GTA does about 100 to 130 linear-target write-backs (25 to 38 MiB). With #8246, about 104 "linear draw baseline" uploads (about 27 MiB) are added. - **Cost.** On this title, #8246 costs about **+4.5 µs per draw (+12 %)** on the draw committer, which is GTA's bottleneck in the open world. The synchronous path costs +2.8 µs. Frames per 300 s follow where the save respawns (2 to 11 FPS within a run here), so I would not read the frame column. The committer cost is the comparable number. - **Where it goes.** `PrepareLinearDraw` runs `WriteBack()`, then a fresh `upload()`, then copies the whole image into a 2x `DeviceBuffer` before every recorded draw into a resident linear target. On these targets, the draw usually covers the whole surface. One way to keep the fix and drop most of that cost might be to take the baseline only when the CPU wrote the target since its last write-back: the write watch already knows. Otherwise the previous write-back's bytes are the baseline. I haven't tried it. cc @Celegans12 (#8152). The correctness fix holds here, but for this title it costs more than going back to synchronous targets. AI-assisted: yes (Claude Code). Measured on the machine above.
CnRJay commented 2026-10-21 17:42:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-21T17:42:50Z.

Review: COMMENTED


The bug (#8152, a later write-back overwriting CPU stores made after Draw returned) is real, and the regression coverage is wide. The cost of the mechanism isn't stated anywhere, and it is the part that matters for the title that motivated the area.

  • "It snapshots the resident image around a recorded linear draw and merges changed bytes through the linear detiler". For a title like METAL GEAR SOLID Master Collection (PPSA14363), whose PS1 emulator draws into three 24 MiB linear targets with up to 80 draws per frame (#9217), that reads as up to 80 snapshots and merges of a 24 MiB image per target per frame. State what is snapshotted (the whole target, or the draw's scissor/footprint) and what a draw costs in bytes copied and GPU time, and say what the extra TextureDetile.comp path costs per draw. The description says "no Linux/macOS runtime, console, title or performance result is claimed", so there is no number at all.
  • #9276 addresses the same two issues (#9217 and #8152) by dropping the per-draw FlushPending and leaving results pending, and the two change the same area. They can't both be right about who owns the guarantee that CPU stores survive. Please agree one approach with its author, and measure the winner on the title that has the problem: the summary lines of main, this PR and #9276 on the same MGS scene, with the bytes written back per 10 s.
  • The concurrency correction (Embersas: 5,668 lost CPU updates on the original head) shows the merge is a read-modify-write of guest memory that races with CPU writers. The fix is validated on one Windows laptop. A byte-granular compare-exchange merge on a 24 MiB target is expensive if it's per word; say how the merge is done (the way WriteChangedOverOriginal does per 8-byte word in #6960, or otherwise) and its cost per MiB.
  • 1,686 lines, changes to the shared detile shader and descriptors, in one PR. If the detile change is only needed to merge, say whether #6905's word-store variants (which change the same shader) compose with it.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5603820025 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5603820025). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-21T17:42:50Z. **Review:** COMMENTED --- The bug (#8152, a later write-back overwriting CPU stores made after `Draw` returned) is real, and the regression coverage is wide. The cost of the mechanism isn't stated anywhere, and it is the part that matters for the title that motivated the area. - "It snapshots the resident image around a recorded linear draw and merges changed bytes through the linear detiler". For a title like METAL GEAR SOLID Master Collection (PPSA14363), whose PS1 emulator draws into three 24 MiB linear targets with up to 80 draws per frame (#9217), that reads as up to 80 snapshots and merges of a 24 MiB image per target per frame. State what is snapshotted (the whole target, or the draw's scissor/footprint) and what a draw costs in bytes copied and GPU time, and say what the extra `TextureDetile.comp` path costs per draw. The description says "no Linux/macOS runtime, console, title or performance result is claimed", so there is no number at all. - #9276 addresses the same two issues (#9217 and #8152) by dropping the per-draw `FlushPending` and leaving results pending, and the two change the same area. They can't both be right about who owns the guarantee that CPU stores survive. Please agree one approach with its author, and measure the winner on the title that has the problem: the summary lines of main, this PR and #9276 on the same MGS scene, with the bytes written back per 10 s. - The concurrency correction (Embersas: 5,668 lost CPU updates on the original head) shows the merge is a read-modify-write of guest memory that races with CPU writers. The fix is validated on one Windows laptop. A byte-granular compare-exchange merge on a 24 MiB target is expensive if it's per word; say how the merge is done (the way `WriteChangedOverOriginal` does per 8-byte word in #6960, or otherwise) and its cost per MiB. - 1,686 lines, changes to the shared detile shader and descriptors, in one PR. If the detile change is only needed to merge, say whether #6905's word-store variants (which change the same shader) compose with it.
adriadam10 commented 2026-10-21 17:51:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T17:51:49Z.

Review: CHANGES_REQUESTED


The CPU-write fix and its tests look right, and the third-party runs cover the byte-preservation cases. One blocker before merge:

  • StorageTexture::PrepareLinearDraw (core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:5147) allocates a new DeviceBuffer of 2x the target's linear size (snapshot + baseline) for every recorded draw, and linearDrawOriginal / recorder->Keep hold it until the write-back is flushed. Nothing bounds how many of these are alive at once. For a title like PPSA14363 (three 24 MiB linear targets, up to ~80 draws per frame, #9217) that is ~48 MiB per draw. Please state the bound and what frees it, and post peak RSS / device-local memory before and after on a workload like that (or reuse one snapshot per target across queued draws, or cap the number outstanding and flush when the cap is hit).
  • Please also post the per-draw cost on that kind of workload (tools/trace_digest.py summaries of main and of this PR from the same machine and scene). The GTA V numbers show +12 % committer time per draw on small targets; the 24 MiB case is the one that matters.
  • The branch conflicts with main in Graphics/include/TextureDetiler.hpp (adjacent Dispatch signature change); rebase when you push the above.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5603929992 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5603929992). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-21T17:51:49Z. **Review:** CHANGES_REQUESTED --- The CPU-write fix and its tests look right, and the third-party runs cover the byte-preservation cases. One blocker before merge: - `StorageTexture::PrepareLinearDraw` (`core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:5147`) allocates a new `DeviceBuffer` of 2x the target's linear size (snapshot + baseline) for every recorded draw, and `linearDrawOriginal` / `recorder->Keep` hold it until the write-back is flushed. Nothing bounds how many of these are alive at once. For a title like PPSA14363 (three 24 MiB linear targets, up to ~80 draws per frame, #9217) that is ~48 MiB per draw. Please state the bound and what frees it, and post peak RSS / device-local memory before and after on a workload like that (or reuse one snapshot per target across queued draws, or cap the number outstanding and flush when the cap is hit). - Please also post the per-draw cost on that kind of workload (`tools/trace_digest.py` summaries of `main` and of this PR from the same machine and scene). The GTA V numbers show +12 % committer time per draw on small targets; the 24 MiB case is the one that matters. - The branch conflicts with `main` in `Graphics/include/TextureDetiler.hpp` (adjacent `Dispatch` signature change); rebase when you push the above.
adriadam10 commented 2026-10-22 21:31:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-22T21:31:08Z.

Review: CHANGES_REQUESTED


Thanks for the work and the many runs; the byte-preservation fix and its tests look right. Still blocking:

  • core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:5147: StorageTexture::PrepareLinearDraw allocates a new DeviceBuffer of 2x the target's linear size (snapshot + baseline) for every recorded draw, and linearDrawOriginal / recorder->Keep hold it until the write-back is flushed. Nothing bounds how many are alive. With three 24 MiB linear targets and ~80 draws per frame (#9217) that is ~48 MiB per draw. Please state the bound and what frees it, and post peak RSS / device-local memory before and after on such a workload. Options: one snapshot per target shared by the queued draws, or a cap on outstanding snapshots that flushes when reached.
  • Per-draw cost: the GTA V numbers show +12 % committer time per draw on small targets. Please post tools/trace_digest.py summaries of main and of this PR (same machine, same scene) for a 24 MiB linear target.
  • PrepareLinearDraw also runs WriteBack(), FlushPending and an upload() on every draw (Draw.cpp:1969 and Draw.cpp:2562); please confirm a draw does not take this path twice.
  • The branch has a merge commit from main and still conflicts with main in Graphics/include/TextureDetiler.hpp (adjacent Dispatch signature change). Please rebase instead of merging.
  • #9685 and #9879 add the same tests/execution/LinearTargetCpuWrites.cpp; list them under Depends on or coordinate which lands.

Welcome to push again with these addressed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5621118420 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5621118420). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-22T21:31:08Z. **Review:** CHANGES_REQUESTED --- Thanks for the work and the many runs; the byte-preservation fix and its tests look right. Still blocking: - `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:5147`: `StorageTexture::PrepareLinearDraw` allocates a new `DeviceBuffer` of 2x the target's linear size (snapshot + baseline) for every recorded draw, and `linearDrawOriginal` / `recorder->Keep` hold it until the write-back is flushed. Nothing bounds how many are alive. With three 24 MiB linear targets and ~80 draws per frame (#9217) that is ~48 MiB per draw. Please state the bound and what frees it, and post peak RSS / device-local memory before and after on such a workload. Options: one snapshot per target shared by the queued draws, or a cap on outstanding snapshots that flushes when reached. - Per-draw cost: the GTA V numbers show +12 % committer time per draw on small targets. Please post `tools/trace_digest.py` summaries of `main` and of this PR (same machine, same scene) for a 24 MiB linear target. - `PrepareLinearDraw` also runs `WriteBack()`, `FlushPending` and an `upload()` on every draw (`Draw.cpp:1969` and `Draw.cpp:2562`); please confirm a draw does not take this path twice. - The branch has a merge commit from `main` and still conflicts with `main` in `Graphics/include/TextureDetiler.hpp` (adjacent `Dispatch` signature change). Please rebase instead of merging. - #9685 and #9879 add the same `tests/execution/LinearTargetCpuWrites.cpp`; list them under Depends on or coordinate which lands. Welcome to push again with these addressed.
adriadam10 commented 2026-10-27 06:35:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T06:35:41Z.

Review: CHANGES_REQUESTED


Thanks for the rebase and the split; the concurrent/preserved/publication tests look right. Still blocking:

  • Memory: StorageTexture::PrepareLinearDraw (Graphics/src/Texture.cpp:5878) still allocates a 2x-target DeviceBuffer for every recorded draw on a linear target. The bound you describe (recorder kept-bytes budget, 512 MiB submit / 1 GiB retire) is from reading the code; docs/dev memory rules ask for the bound to be shown. Please post peak RSS and device-local memory before/after on a workload with several large linear targets (e.g. 3 x 24 MiB, tens of draws per frame), or add a test that queues enough draws to hit the budget and shows the snapshots are released. Sharing one snapshot per target between queued draws would also remove the problem.
  • Per-draw cost: please post tools/trace_digest.py summaries of main and of this PR (same machine, same scene) for a 24 MiB linear target. The numbers already posted show +12 % per draw on small targets and the new path adds a copy-image-to-buffer of the whole target on every draw.
  • Please run the focused AGC tests on main and on this branch with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (see AGENTS.md) and confirm the branch adds no new VUID- errors; the detile shader gains a new uint8_t storage path and a third binding.

Welcome to push again with these addressed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5663127757 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5663127757). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-27T06:35:41Z. **Review:** CHANGES_REQUESTED --- Thanks for the rebase and the split; the concurrent/preserved/publication tests look right. Still blocking: - Memory: `StorageTexture::PrepareLinearDraw` (`Graphics/src/Texture.cpp:5878`) still allocates a 2x-target `DeviceBuffer` for every recorded draw on a linear target. The bound you describe (recorder kept-bytes budget, 512 MiB submit / 1 GiB retire) is from reading the code; docs/dev memory rules ask for the bound to be shown. Please post peak RSS and device-local memory before/after on a workload with several large linear targets (e.g. 3 x 24 MiB, tens of draws per frame), or add a test that queues enough draws to hit the budget and shows the snapshots are released. Sharing one snapshot per target between queued draws would also remove the problem. - Per-draw cost: please post `tools/trace_digest.py` summaries of `main` and of this PR (same machine, same scene) for a 24 MiB linear target. The numbers already posted show +12 % per draw on small targets and the new path adds a copy-image-to-buffer of the whole target on every draw. - Please run the focused AGC tests on `main` and on this branch with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (see AGENTS.md) and confirm the branch adds no new `VUID-` errors; the detile shader gains a new `uint8_t` storage path and a third binding. Welcome to push again with these addressed.
adriadam10 commented 2026-10-27 10:43:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T10:43:03Z.

Review: CHANGES_REQUESTED


Thanks for the rework and the measurements. Status against the previous review:

  • Memory: covered. Peak RSS +72 to 76 MiB over main, flat in draws and targets, and one live snapshot per draw (PrepareLinearDraw flushes first, FinishLinearDraw releases it). No separate test needed.
  • Validation layer: 0 VUID- lines on the 23 agc_driver_linear_target_* tests plus agc_driver_graphics. Please also state the same run on main, so the comparison in AGENTS.md is explicit.
  • Per-draw cost (still blocking): the only numbers on the current design are lavapipe on the unwatched fallback (2.2x to 3.0x per draw, mostly the whole-target compare/upload, as you found). The GTA V numbers (+12 % vs resident main) predate this rework and the new Refresh() commit. Please post tools/trace_digest.py summaries of main and of head 5c9cf43a7e from the same machine and scene on a host where the target is write-watched (Windows, macOS, or Linux >= 6.7), ideally with a 24 MiB linear target. A run by one of the contributors who already tested this PR is fine.
  • PR body: Depends on: #9685 points to a closed PR, and Tested describes older heads. Please update both to the current head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5665755663 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5665755663). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-27T10:43:03Z. **Review:** CHANGES_REQUESTED --- Thanks for the rework and the measurements. Status against the previous review: - Memory: covered. Peak RSS +72 to 76 MiB over `main`, flat in draws and targets, and one live snapshot per draw (`PrepareLinearDraw` flushes first, `FinishLinearDraw` releases it). No separate test needed. - Validation layer: 0 `VUID-` lines on the 23 `agc_driver_linear_target_*` tests plus `agc_driver_graphics`. Please also state the same run on `main`, so the comparison in AGENTS.md is explicit. - Per-draw cost (still blocking): the only numbers on the current design are lavapipe on the unwatched fallback (2.2x to 3.0x per draw, mostly the whole-target compare/upload, as you found). The GTA V numbers (+12 % vs resident `main`) predate this rework and the new `Refresh()` commit. Please post `tools/trace_digest.py` summaries of `main` and of head `5c9cf43a7e` from the same machine and scene on a host where the target is write-watched (Windows, macOS, or Linux >= 6.7), ideally with a 24 MiB linear target. A run by one of the contributors who already tested this PR is fine. - PR body: `Depends on: #9685` points to a closed PR, and `Tested` describes older heads. Please update both to the current head.
adriadam10 commented 2026-10-28 11:56:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T11:56:56Z.

Review: CHANGES_REQUESTED


Thanks for the updates. Status against the last review:

  • Memory, validation-layer comparison on main, Depends on and the tested head: covered.
  • Still blocking: per-draw cost on a write-watched host. The numbers on the current design are lavapipe on the unwatched fallback (whole-target compare/upload) and a GTA V run that predates the rework and the Refresh() commit; the Stray captures don't exercise a 24 MiB linear target. Please post tools/trace_digest.py summaries of main and of head db12f5d6fb from the same machine and scene on Windows, macOS or Linux >= 6.7, ideally with a 24 MiB linear target (a run by one of the contributors who already tested this PR is fine), or bytes copied and time per draw from a focused harness there.
  • Minor: the Tested section still says the validation run on main is not posted yet; the run is in your 2026-10-27 11:09 UTC comment (11 pass, 2 skip, 0 VUID-). Please update that line.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5682196541 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5682196541). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-28T11:56:56Z. **Review:** CHANGES_REQUESTED --- Thanks for the updates. Status against the last review: - Memory, validation-layer comparison on `main`, `Depends on` and the tested head: covered. - Still blocking: per-draw cost on a write-watched host. The numbers on the current design are lavapipe on the unwatched fallback (whole-target compare/upload) and a GTA V run that predates the rework and the `Refresh()` commit; the Stray captures don't exercise a 24 MiB linear target. Please post `tools/trace_digest.py` summaries of `main` and of head `db12f5d6fb` from the same machine and scene on Windows, macOS or Linux >= 6.7, ideally with a 24 MiB linear target (a run by one of the contributors who already tested this PR is fine), or bytes copied and time per draw from a focused harness there. - Minor: the `Tested` section still says the validation run on `main` is not posted yet; the run is in your 2026-10-27 11:09 UTC comment (11 pass, 2 skip, 0 `VUID-`). Please update that line.
adriadam10 commented 2026-11-01 01:10:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-01T01:10:31Z.

Review: CHANGES_REQUESTED


Thanks for the rebase onto the GCN split layout; the specialization IDs and push constants now line up. Status against the last review, using @savvaniss's write-watched run (RX 9070 XT, Windows, 24 MiB target, measured on db12f5d6fb):

  • Per-draw time: about 1.2x to 1.3x of base on a real GPU, which is acceptable. The 3.0x on the shortest shape looks like first-use cost; please say what it is.
  • Failing test: agc_driver_linear_target_publication_alias failed in 9 of 9 runs there (wrong CPU bytes=557056, the alias clear value 0,0,0,1.0f lands over the CPU's 0x42 bytes outside the draw). The test is added by this PR, so it has to pass on a write-watched host. Please reproduce and fix it, or explain why it only fails there.
  • Memory: device-local usage grows about 71 MiB per recorded draw on the PR against about 24 MiB on base (12,973 MiB vs 4,333 MiB at 180 draws in one frame, peak private commit 13.2 GiB vs 4.6 GiB). The earlier flat result was RSS on lavapipe. Please bound the snapshots (release or reuse them per draw, or cap how many are live) and post peak device-local memory before/after, see the memory section of CONTRIBUTING.
  • Please rerun the alias test and the memory table on the current head 9377004c3c and post the results.
  • Minor: update the Tested line that still says the validation run on main is not posted.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5725834186 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5725834186). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-01T01:10:31Z. **Review:** CHANGES_REQUESTED --- Thanks for the rebase onto the GCN split layout; the specialization IDs and push constants now line up. Status against the last review, using @savvaniss's write-watched run (RX 9070 XT, Windows, 24 MiB target, measured on `db12f5d6fb`): - Per-draw time: about 1.2x to 1.3x of base on a real GPU, which is acceptable. The 3.0x on the shortest shape looks like first-use cost; please say what it is. - Failing test: `agc_driver_linear_target_publication_alias` failed in 9 of 9 runs there (`wrong CPU bytes=557056`, the alias clear value `0,0,0,1.0f` lands over the CPU's `0x42` bytes outside the draw). The test is added by this PR, so it has to pass on a write-watched host. Please reproduce and fix it, or explain why it only fails there. - Memory: device-local usage grows about 71 MiB per recorded draw on the PR against about 24 MiB on base (12,973 MiB vs 4,333 MiB at 180 draws in one frame, peak private commit 13.2 GiB vs 4.6 GiB). The earlier flat result was RSS on lavapipe. Please bound the snapshots (release or reuse them per draw, or cap how many are live) and post peak device-local memory before/after, see the memory section of CONTRIBUTING. - Please rerun the alias test and the memory table on the current head `9377004c3c` and post the results. - Minor: update the `Tested` line that still says the validation run on `main` is not posted.
MarcZX10 commented 2026-11-02 04:57:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:57:03Z.

Review: COMMENTED


Reviewed — conflict claim is out of date, memory and alias test still open

The conflict named on 29 Oct no longer shows at head 9377004c3c, but the requested reruns and the memory bound are not done on this head.

What I ran

Head 9377004c3c38bc505be16eafb509609386318a94 (live, OPEN, unchanged from batch). Read-only: gh pr view, gh api GET on issue comments, review comments and reviews, git merge-tree --write-tree of the head against upstream/main (926f7dd492), git grep and git show at the head, git log on the PR range. Nothing was built or run.

Results

Check Result Note
Trial merge vs upstream/main Clean Exit 0 at 926f7dd492, no conflicts
Hosted checks 6 success, none failing mergeStateStatus BLOCKED, which follows the CHANGES_REQUESTED review
Alias test, memory table Not run Need a run on this head

Findings

  • adriadam10 (CHANGES_REQUESTED, 2026-11-01 01:10Z) asks for a rebase, a rerun of the alias test and a memory bound. oneandonlydean (2026-10-29) says CHANGED_ONLY is 22 and collides with GCN SPLIT0-3. At this head TextureDetile.comp:35-38 holds SPLIT0-3 at 22-25 and TextureDetile.comp:39 holds CHANGED_ONLY at 26. The collision does not exist here.
  • Snapshot release: commit c0bd1ca17a ("finish a linear draw's store and release its snapshot") is in the range. I did not measure device-local memory, so the reviewer's 71 MiB per draw figure is not verified.
  • savvaniss (2026-10-31) measured head db12f5d6fb, which is not the live head. Their alias-test failure and memory growth apply to that commit only. The TechLevelZero NVIDIA run (2026-11-01, head 9377004) also reports agc_driver_linear_target_publication_alias failing with wrong CPU bytes=557056. That is an external run, not a hosted check here, and I did not reproduce it.

Sources

Not verified

  • The alias-test failure and the memory growth numbers (no run here).
  • Whether the rebased head preserves GCN split behavior and changed-only writes; only the constant IDs were read.
  • Hosted check conclusions are from the status rollup only.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732247093 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5732247093). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T04:57:03Z. **Review:** COMMENTED --- # Reviewed — conflict claim is out of date, memory and alias test still open The conflict named on 29 Oct no longer shows at head 9377004c3c, but the requested reruns and the memory bound are not done on this head. ## What I ran Head `9377004c3c38bc505be16eafb509609386318a94` (live, OPEN, unchanged from batch). Read-only: `gh pr view`, `gh api` GET on issue comments, review comments and reviews, `git merge-tree --write-tree` of the head against `upstream/main` (926f7dd492), `git grep` and `git show` at the head, `git log` on the PR range. Nothing was built or run. ## Results | Check | Result | Note | |---|---|---| | Trial merge vs upstream/main | Clean | Exit 0 at 926f7dd492, no conflicts | | Hosted checks | 6 success, none failing | mergeStateStatus BLOCKED, which follows the CHANGES_REQUESTED review | | Alias test, memory table | Not run | Need a run on this head | ## Findings - adriadam10 (CHANGES_REQUESTED, 2026-11-01 01:10Z) asks for a rebase, a rerun of the alias test and a memory bound. oneandonlydean (2026-10-29) says `CHANGED_ONLY` is 22 and collides with GCN SPLIT0-3. At this head `TextureDetile.comp:35-38` holds SPLIT0-3 at 22-25 and `TextureDetile.comp:39` holds `CHANGED_ONLY` at 26. The collision does not exist here. - Snapshot release: commit `c0bd1ca17a` ("finish a linear draw's store and release its snapshot") is in the range. I did not measure device-local memory, so the reviewer's 71 MiB per draw figure is not verified. - savvaniss (2026-10-31) measured head `db12f5d6fb`, which is not the live head. Their alias-test failure and memory growth apply to that commit only. The TechLevelZero NVIDIA run (2026-11-01, head 9377004) also reports `agc_driver_linear_target_publication_alias` failing with `wrong CPU bytes=557056`. That is an external run, not a hosted check here, and I did not reproduce it. ## Sources - https://github.com/boykopovar/AnyPS5/blob/9377004c3c38bc505be16eafb509609386318a94/core/libs/prx/libSceAgcDriver/Graphics/shaders/TextureDetile.comp#L35-L39 ## Not verified - The alias-test failure and the memory growth numbers (no run here). - Whether the rebased head preserves GCN split behavior and changed-only writes; only the constant IDs were read. - Hosted check conclusions are from the status rollup only.
adriadam10 commented 2026-11-06 09:51:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-06T09:51:27Z.

Review: CHANGES_REQUESTED


Thanks for the rebase. Against the last review, using @savvaniss's rerun on 9377004c3c (same commit as the perf(agc) one on this head; later pushes are merges of main):

  • Memory is still unbounded per draw: device-local usage grows about 71 MiB per recorded draw against about 24 MiB on base (12,901 MiB vs 4,333 MiB at 180 draws in one frame; peak private commit 13.2 GiB vs 4.6 GiB). Please bound the snapshots (release or reuse them per draw, or cap how many are live) and post peak device-local memory before/after at 60 and 180 draws, see the memory section of CONTRIBUTING.
  • New stall: at 180 draws per frame the slowest single draw is 315 to 397 ms in every run (5,036 ms once at 150), against 7 to 10 ms on base. It looks like waiting on the frame's queued work while device-local memory is near 11 to 13 GiB. Please find what triggers it; the memory bound above may be the fix.
  • agc_driver_linear_target_publication_alias failed with wrong CPU bytes=557056 on 9377004c3c on both AMD (write-watched) and NVIDIA. The NVIDIA run on the current head passes with no new validation IDs. Please say what fixed it, and rerun it on a write-watched host (Windows) to confirm.
  • First-frame cost: savvaniss measured about +170 ms in frame 0 (mostly in WaitIdle) and later frames waiting about half as long as base. Please say what the first frame pays for.
  • Minor: the Tested line still says the validation run on main is not posted; update it with the results above.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5798452354 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8246#pullrequestreview-5798452354). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-06T09:51:27Z. **Review:** CHANGES_REQUESTED --- Thanks for the rebase. Against the last review, using @savvaniss's rerun on `9377004c3c` (same commit as the `perf(agc)` one on this head; later pushes are merges of main): - Memory is still unbounded per draw: device-local usage grows about 71 MiB per recorded draw against about 24 MiB on base (12,901 MiB vs 4,333 MiB at 180 draws in one frame; peak private commit 13.2 GiB vs 4.6 GiB). Please bound the snapshots (release or reuse them per draw, or cap how many are live) and post peak device-local memory before/after at 60 and 180 draws, see the memory section of CONTRIBUTING. - New stall: at 180 draws per frame the slowest single draw is 315 to 397 ms in every run (5,036 ms once at 150), against 7 to 10 ms on base. It looks like waiting on the frame's queued work while device-local memory is near 11 to 13 GiB. Please find what triggers it; the memory bound above may be the fix. - `agc_driver_linear_target_publication_alias` failed with `wrong CPU bytes=557056` on `9377004c3c` on both AMD (write-watched) and NVIDIA. The NVIDIA run on the current head passes with no new validation IDs. Please say what fixed it, and rerun it on a write-watched host (Windows) to confirm. - First-frame cost: savvaniss measured about +170 ms in frame 0 (mostly in `WaitIdle`) and later frames waiting about half as long as base. Please say what the first frame pays for. - Minor: the `Tested` line still says the validation run on `main` is not posted; update it with the results above.
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/8246:upstream-pr/8246'
git switch 'upstream-pr/8246'

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