fix(agc): write host-only multisample memory as zeros in a capture snapshot #12566
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12566"
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 chitters2004 on 2026-10-28T20:44:28Z.
What
The capture snapshot reads every committed block with
GuestMemory::ReadCommitted, which refuses memory under a multisampled color target, its FMASK or native multisample depth whose samples exist only on the host. The read throws, and the title aborts: on GTA V (PPSA04263) a capture of the North Yankton prologue ended witha CPU read of 0x2ee4a0000+0x4000000 overlaps multisampled color target 0x2f1c00000+0x80000 (2 samples), whose samples are only on the hostandSIGABRT. @Tehshortbus hit the same in a GTA V cutscene, on 8 blocks of 64 KiB (#12235 comment).Graphics::HostOnlySampleRangesreturns the guarded multisample color ranges whose samples are only on the host and, throughAppendHostWrittenDepthRanges, the native multisample depth ranges the host wrote.AgcDriver::ReadAroundRangesreads a block around sorted, possibly overlapping ranges and writes them as zeros.FrameRecorder::readGuestcalls it with those ranges for the snapshot and for the delta reads of late-added ranges and write-watched blocks, counts the bytes ashost_only_sample_bytesincapture.jsonand adds a warning when any were zeroed, so the replay starts those targets without their earlier contents.agc_frame_capture_testscoversReadAroundRangeswith a range in the middle of a block, over its start, over its end, overlapping ranges, ranges outside it and one over all of it: only those bytes are zero, every other byte matches guest memory, the count equals the zeroed length, and no guarded byte is read.SampleMultisampleTargetreads across a native target and its neighbor and checks that exactly the target's color bytes are zeroed.Overlap: #6995 changes the same
MultisampleTarget.hppinclude block. Its author agreed this lands first (comment) and records it in #6995's Depends on; the rest of the two merge automatically.readGuesttakesHostOnlySampleRangesbefore it reads, so once #6995 is in, a range that is still host-only is written as zeros without trying #6995's publication first, and bytes published earlier are read normally. So the two together don't make a capture over such a target lossless. The other PRs the overlap check lists only add next to the same lines.Tested
Windows 11 Pro 26220, WinLibs GCC, Ninja Release, NVIDIA GeForce RTX 3080 (driver 621.01).
agc_driver_sample_multisample_targetnow also checks thatHostOnlySampleRangesreports the draw-input source it has just guarded as a native target, and not the neighbouring block. These checks call the new function, so they do not build onmain. No test captures a frame over a host-only target.GTA V (PPSA04263), the same prologue scene with this series applied: the capture completes, 3 frames, with
"host_only_sample_bytes":524288(that 0x80000-byte 2-sample target) and the warning incapture.json.Paired run on
mainand this branch merged into it, same machine and GPU,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "frame_(capture|replay)|sample_multisample_target" -V: full builds on both sides with submodules at their pinned commits:mainatbb04a4f1ea: 12 tests, all passed, 0VUID-lines; this branch atfa2b143d5amerged into it (a049746c60): 12 tests, all passed, 0VUID-lines. Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T21:02:30Z.
Review: CHANGES_REQUESTED
Findings
Blocking: the new snapshot path has no test, and delta reads still reject guarded samples without documenting the limitation
The new
readGuest()logic is currently called only bysnapshot(). InwriteDelta(), both a late-added range and a write-watched block still go throughGuestMemory::ReadCommittedUnsynced(), which invokesGuardRead()and can reject an address under a guarded multisample target. Thus the change allows the initial snapshot to complete, but a later CPU write or newly tracked range overlapping still-guarded host-only samples can still stop the capture. The new debt entry only describes zeroing the snapshot, so it does not record this remaining delta failure.Please either route the applicable delta reads through the host-only-aware helper, or document in the debt entry that delta reads can still refuse these ranges. Add a focused test of the changed
readGuest()snapshot behavior: use a guarded range in the middle of a block and at each edge, then verify that only the guarded bytes become zero, surrounding bytes retain their contents, andhost_only_sample_bytesmatches the zeroed byte count. If delta reads remain unsupported, add a test that records that limitation rather than implying the whole capture path is covered.I confirmed the current call sites and read guard in this PR's exact head:
snapshot()callsreadGuest(), whilewriteDelta()callsReadCommittedUnsynced()for both late ranges and modified blocks;ReadCommittedUnsynced()invokesGuardRead().Checks
7b38bca9e56d75c2024c7017724805e6321b4473and its focused range-reporting tests.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T21:05:12Z.
Review: CHANGES_REQUESTED
Thanks, the approach is right and
readGuest's cursor arithmetic checks out on the diff. Two things block it, the same ones @oneandonlydean and @MarcZX10 raised:FrameRecorder.cppreadGuesthas no test: the added checks inSampleMultisampleTarget.cpponly callHostOnlySampleRanges. Add a test in the existing frame capture tests that snapshots a block overlapping a guarded host-only target and asserts the overlap reads as zero, the bytes on either side are unchanged, andhost_only_sample_bytesincapture.jsonequals the zeroed length. Cover the range in the middle, at the start and at the end of the block.writeDeltastill reads late-added ranges and write-watched blocks withReadCommittedUnsynced, which goes throughGuardReadand can still abort a capture over a guarded target. Either route those two reads throughreadGuest, or say in theHost-only multisample memory in frame captureentry ofdocs/dev/debt/libSceAgcDriver.mdthat delta reads of such memory still refuse (and then the PR text's "the gap is a new debt entry" is true).Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T05:58:40Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
What I checked
fa2b143d5a133903f82fb09a9d8378339096c3d9against fetchedmain2960e9a6e7.readGuestnow handles snapshots and both delta-read paths, andReadAroundRangestests cover middle/start/end, overlapping, outside, and fully covering ranges. The native-target test checks that only guarded target bytes are zeroed.git diff --checkpasses. Hosted Windows, conventions, and eligibility checks pass; product Linux and specialized jobs were skipped.Test evidence
The author reports the GTA V capture now completes and records
524288host-only bytes. They also report paired Vulkan-validation CTest runs on an RTX 3080, with 12/12 focused tests and noVUID-lines on both main and the change; the full set was run on the immediately preceding revision, and the capture test was rerun on this head. I did not run these GPU tests locally.Blocking repository coordination
The open #6995 changes the same
MultisampleTarget.hpparea; a pairwise merge preview conflicts there. This PR mentions the overlap but still saysDepends on: none, and I found no author agreement on which change lands first.CONTRIBUTING.mdrequires the authors to agree and record the order. Please coordinate with #6995’s author, update the checklist, and refresh/rerun the focused comparison on the agreed integration head. Until then I cannot approve this change.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:06:58Z.
Review: CHANGES_REQUESTED
Rechecked after the stack update
The agreement with #6995 is now explicit in both PR descriptions: #12566 first, then #6995. The earlier missing test and delta-read findings are also addressed by the current head's
ReadAroundRangescoverage and the host-only-aware reads for snapshots and deltas.Changes still requested
Please rerun the focused frame-capture and multisample-target checks on current
mainand on the PR merged into that same main. The latest reported paired run usesmain2960e9a6e7, while currentmainisf7e84c4cf1; since their merge base,core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppanddocs/dev/debt/libSceAgcDriver.mdchanged on both sides. In particular, the PR addsAppendHostWrittenDepthRangesinDepthSurface.cpp, so the older paired run does not establish the combined behavior after the intervening depth-guard changes.My current-main merge preview is clean and
git diff --checkpasses. The hosted Windows job passes; Linux and specialized product jobs are skipped. I did not run the GPU/AGC suite locally. The author's 12/12 paired Vulkan-validation result is useful but predates these shared-file changes. Please record the exact main and merged-head commits and rerun the focused gate on the agreed #12566-before-#6995 integration.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T18:46:35Z.
Review: APPROVED
Re-checked — new head, looks good
The prior current-base validation request is resolved by the reported paired run on
bb04a4f1ea, and the exact-head capture unit test and negative control pass locally.What I ran
fa2b143d5a133903f82fb09a9d8378339096c3d9against currentmainbb04a4f1ea0175e9e4f149f0359a764d62ff3296.git merge-tree --write-tree upstream/main HEADcompleted cleanly with tree7fd444989f40824be2bad5b10a2c6ef6c2f43ab8.agc_frame_capturetest on this head. A temporary mutation that removed the zero-fill made the test fail; after restoring the exact source, the test passed again.mainand the PR integrated into that same base; those runs are author-reported, not local runs.Results
main7fd444989f40824be2bad5b10a2c6ef6c2f43ab8agc_frame_capturemainand on the PR merged into that same base; zeroVUID-lines on bothUnedited local unit-test output
Unedited negative-control and restored-test output
Unedited conventions output
Negative control
memsetinReadAroundRangesFindings
Blocking
None found.
Non-blocking
The Windows GPU comparison and GTA V capture are author-reported. I did not independently run the Vulkan integration suite, verify replay on a console, or test on PS5 hardware. The capture intentionally zeroes host-only samples, so it does not preserve their prior contents.
Sources
Not verified