fix(agc): preserve CPU writes after resident linear target draws #8246
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8246"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
Drawreturned.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-bytrailers for both; the drawn-rectangle fix (leave the drawn-rectangle store to targets without a draw snapshot) and the finalRefresh()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 ontomain3fea2a937b):agc_driver_linear_target_*tests plusagc_driver_graphics: 22 pass and 2 skip on lavapipe (direct_write_completion,import_creation). WithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationthere are 0VUID-lines (the layer is inserted at instance and device level). The same run onmainis not posted yet.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 onmainand 74 to 99 ms with this PR depending on whether the CPU writes before each draw. No number from a write-watched host and notools/trace_digest.pysummary are available yet. Details are in the comments below.python3 tools/check_conventions.py --base upstream/mainandgit diff --checkpass.Earlier reports, on older heads and not repeated on this one:
e5b9ac546against base3fd1cc393, 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.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 onmainlost 7,680 of 8,192 CPU-written bytes; the corrected cases passed 20/20 repeats with zero lost updates.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)e5b9ac546); NVIDIA RTX 4070 Laptop / driver 592.82 on Windows 11 Pro (reported by Embersas on an older correction tree)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.
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 makesFlushPendingignore 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.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T07:31:27Z.
I pushed two commits to #8246:
fe29558e94defers linear target eviction writeback and records the draw as a pending writer;285884da27updates 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.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 viarecorder.OnComplete(). Before this change,StorageTexture::FlushPendingran synchronously during recording — scheduling a whole-target copyout before any CPU stores the game makes afterDrawreturns. At completion, theOnCompletelambda:GuestMemory::GpuMutex()— correct, sinceFlushPendingandWriteBackmutate shared guest-memory state.keep->WriteBack()to write the GPU results back.The
keepshared_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 ablueConstantparameter (default0x80), allowing the second draw to write a distinct blue value (0xf4).Draw()now takesscissorWidth(defaultWidth), allowing a left-scissored second draw.runlambda executes two draws: full-width blue=0x80, then left-half blue=0xf4. Between draws, theseedvariant writes0x5ato the left half of the CPU buffer. After both draws, the CPU writes0x42to the right half. AfterWaitIdle(), it checks:x, y, 2.0, 1.0with0xf4blue → float2.0viav_mov_b32encoding) preserved.0x42bytes preserved (not overwritten by GPU writeback).run(true)(seeded) andrun(false)(unseeded) are exercised.The instruction encoding
0x7e000200u | blueConstant | (22u << 17u)is av_mov_b32with an inline constant — the constant index formula is correct for GCN/RDNA ISA.CI:
conventions,labelspass. Build/platform jobs skip (AGC change, no CI GPU runner).Local verification: Built
agc_driver_linear_target_resident_testsand ranctest -R "^agc_driver_linear_target_resident$" -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1on 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_validationtesting, but the host CPU guard prevents the runtime from reaching Vulkan initialization anyway, so this is consistent with the limitation.No blocking issues found.
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
ec9d6fecb5snapshots 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.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
ec9d6fecb5also refreshes the byte baseline before each draw, and50f477fcccreuses 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) throughagc_driver_linear_target_residenton your GPU? The PR remains draft while that runtime behavior is unverified here.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).
3fd1cc393: the compatible regression overlay reproduces the overwrite on both GPUs; synchronous controls pass.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.These results apply to the linked branch; I have not executed this PR's current
50f477fccchead. 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.
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 nowe32a19b4d7957795a3b5cf21848b41889bd193a5, rebased on current main35fa2bdd. 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.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.
Imported from boykopovar/AnyPS5. Originally posted by rajvveer on 2026-10-20T10:26:27Z.
The requested exact-head rerun is complete:
e32a19b4d7957795a3b5cf21848b41889bd193a5was rebuilt in a separate clean worktree and passed 36/36 focused executions.agc_driver_graphicspassed too. Independently rebuilt main35fa2bddalso 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=1and 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.cppand applies cleanly toe32a19b4: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
66f62d17479bf7b393326c48926dea6bea31c6f0if 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.Imported from boykopovar/AnyPS5. Originally posted by VicRaster on 2026-10-20T10:44:45Z.
I rebuilt exact head
e32a19b4d7957795a3b5cf21848b41889bd193a5on 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_tstorage-buffer stores, without destination loads or atomics. The driver already enablesstorageBuffer8BitAccess; 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.
PrepareLinearDrawnow 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
WaitIdleboundary 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.
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.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.Every GPU run used:
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:
Convention and whitespace checks pass.
spirv-val --target-env vulkan1.1accepts 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 withgit apply <attachment>.SHA256:
d7dbee013607048a06f05efea9b4ed3a4ab31086c1b396670e5ca4cf7b403beeThe 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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T11:00:55Z.
Integrated the offered correction into #8246 as commit
030409ad4a86041c29fa65bf018632452d5b5cabafter rebasing all three PR commits onto currentmain891d5675150936bbb330a1f27bacc86113dd2532. The new commit preservesembersasas 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 --checkpasses. The local conventions script stops at its duplicate-export scan withE2BIG, and hosted metadata checks were pending at the last poll. I could not run a current-head Vulkan build/runtime on this host.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 ontomain02fb1ce53(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 usedANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; the validation layer was not used.agc_driver_linear_target_residentpasses 3 of 3 on each GPU. So doagc_storage_writeback_blocks,agc_write_trackingandagc_write_tracking_metadata_commit. The test logslinear target resident device: NVIDIA GeForce RTX 5070 Tiand... AMD Radeon(TM) Graphicsrespectively.PrepareLinearDraw,FinishLinearDrawand the newDispatchoverload, so it doesn't compile onmainalone. Instead I kept the whole PR and restored onlymain'sDraw.cpp, which removes thePrepareLinearDrawandFinishLinearDrawhook-up. The test then fails 2 of 2 on each GPU withunseeded scissor: write-back overwrote the CPU's untouched right half in row 0.agc_driver_graphics, which includes the newTextureDetiler.cppcases, 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_exportskips on NVIDIA because the GPU has no stencil export.Not measured: the cost per draw.
PrepareLinearDrawrunsWriteBack()and then copies the whole image into a new 2x-sizeDeviceBufferbefore 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.
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
b50976750dmerged with our local Yōtei work (local/merge19a5d6e1707a, where resident linear targets are opt-in behindAPS5_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::Syncright 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.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
local/test-8246=local/merge19a5d6e1707a + #8246 030409ad4a as one commit (2339d4e0e6) + the reproducer as its own execution test (LinearTargetRepro8152.cpp, from Celegans12/AnyPS5repro/8152-linear-writebackb1c835f80d) + 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.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.[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'sPrepareLinearDraw/FinishLinearDrawhooks (Draw.cpp only), 3/3 failed: seeded 0/8192, unseeded 7680/8192.web-teshio-bsave, pad script without jumps, our usual Yōtei env plusAPS5_NO_DISPATCH_OVERLAP=1, stopped 10 s after frame_090.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.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.APS5_RESIDENT_LINEARunset, earlier run on merge19 045af03378): Atsu at the river, frames 078-090.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
030409ad4awould 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.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.
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
PrepareLinearDrawestablishes the baseline, after the recorded draw completes just before its completion callback, and afterWriteBack? 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.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:
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.
Imported from boykopovar/AnyPS5. Originally posted by rajvveer on 2026-10-21T05:43:11Z.
The exact PR head
030409ad4a86041c29fa65bf018632452d5b5cabnow 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 differentpipeBankXor. Those coordinates represent different guest bytes. A cached one-slice array read returned0x22222222where the untouched bytes must remain0x5a5a5a5a.SameSurfaceShape()had the same omission, allowing a rawCopyBufferto 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:
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.
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.
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
main663de1ab2plus the two #9136 fixes (Dripl1x'sd6e270ea9, and #9159 with81aec5834), 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:main's path)APS5_NO_RESIDENT_LINEAR=1(synchronous)PrepareLinearDrawrunsWriteBack(), then a freshupload(), then copies the whole image into a 2xDeviceBufferbefore 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.
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
Drawreturned) 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.TextureDetile.comppath costs per draw. The description says "no Linux/macOS runtime, console, title or performance result is claimed", so there is no number at all.FlushPendingand 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.WriteChangedOverOriginaldoes per 8-byte word in #6960, or otherwise) and its cost per MiB.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 newDeviceBufferof 2x the target's linear size (snapshot + baseline) for every recorded draw, andlinearDrawOriginal/recorder->Keephold 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).tools/trace_digest.pysummaries ofmainand 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.maininGraphics/include/TextureDetiler.hpp(adjacentDispatchsignature change); rebase when you push the above.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::PrepareLinearDrawallocates a newDeviceBufferof 2x the target's linear size (snapshot + baseline) for every recorded draw, andlinearDrawOriginal/recorder->Keephold 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.tools/trace_digest.pysummaries ofmainand of this PR (same machine, same scene) for a 24 MiB linear target.PrepareLinearDrawalso runsWriteBack(),FlushPendingand anupload()on every draw (Draw.cpp:1969andDraw.cpp:2562); please confirm a draw does not take this path twice.mainand still conflicts withmaininGraphics/include/TextureDetiler.hpp(adjacentDispatchsignature change). Please rebase instead of merging.tests/execution/LinearTargetCpuWrites.cpp; list them under Depends on or coordinate which lands.Welcome to push again with these addressed.
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:
StorageTexture::PrepareLinearDraw(Graphics/src/Texture.cpp:5878) still allocates a 2x-targetDeviceBufferfor 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.tools/trace_digest.pysummaries ofmainand 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.mainand on this branch withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(see AGENTS.md) and confirm the branch adds no newVUID-errors; the detile shader gains a newuint8_tstorage path and a third binding.Welcome to push again with these addressed.
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:
main, flat in draws and targets, and one live snapshot per draw (PrepareLinearDrawflushes first,FinishLinearDrawreleases it). No separate test needed.VUID-lines on the 23agc_driver_linear_target_*tests plusagc_driver_graphics. Please also state the same run onmain, so the comparison in AGENTS.md is explicit.main) predate this rework and the newRefresh()commit. Please posttools/trace_digest.pysummaries ofmainand of head5c9cf43a7efrom 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.Depends on: #9685points to a closed PR, andTesteddescribes older heads. Please update both to the current head.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:
main,Depends onand the tested head: covered.Refresh()commit; the Stray captures don't exercise a 24 MiB linear target. Please posttools/trace_digest.pysummaries ofmainand of headdb12f5d6fbfrom 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.Testedsection still says the validation run onmainis not posted yet; the run is in your 2026-10-27 11:09 UTC comment (11 pass, 2 skip, 0VUID-). Please update that line.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):agc_driver_linear_target_publication_aliasfailed in 9 of 9 runs there (wrong CPU bytes=557056, the alias clear value0,0,0,1.0flands over the CPU's0x42bytes 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.9377004c3cand post the results.Testedline that still says the validation run onmainis not posted.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 apiGET on issue comments, review comments and reviews,git merge-tree --write-treeof the head againstupstream/main(926f7dd492),git grepandgit showat the head,git logon the PR range. Nothing was built or run.Results
926f7dd492, no conflictsFindings
CHANGED_ONLYis 22 and collides with GCN SPLIT0-3. At this headTextureDetile.comp:35-38holds SPLIT0-3 at 22-25 andTextureDetile.comp:39holdsCHANGED_ONLYat 26. The collision does not exist here.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.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 reportsagc_driver_linear_target_publication_aliasfailing withwrong CPU bytes=557056. That is an external run, not a hosted check here, and I did not reproduce it.Sources
github.com/boykopovar/AnyPS5@9377004c3c/core/libs/prx/libSceAgcDriver/Graphics/shaders/TextureDetile.comp (L35-L39)Not verified
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 theperf(agc)one on this head; later pushes are merges of main):agc_driver_linear_target_publication_aliasfailed withwrong CPU bytes=557056on9377004c3con 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.WaitIdle) and later frames waiting about half as long as base. Please say what the first frame pays for.Testedline still says the validation run onmainis not posted; update it with the results above.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.