fix(agc): ignore unchanged imported texture blocks #2984
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2984"
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-10T19:37:29Z.
What
Fixes #2767. When write tracking reports a 64 KiB texture block as possibly written, compare the block with the image snapshot before treating it as changed. If the bytes are identical, keep the pending GPU image and clear the false CPU-write stamp. This avoids redundant uploads when a host import remains write-watched but did not change guest bytes.
The issue reports the current failure on three NVIDIA setups and confirms the patch on those systems; an Intel report also reproduces the failure with import watching forced. No open PR overlaps this change.
Tested
agc_driver_dcc_keys_first_write_testsagc_driver_dcc_keys_first_write, repeated 5 times: passed 5/5tools/check_conventions.py --base upstream/mainpassedgit diff --checkpassedThe local llvmpipe run reports that write-watch is unavailable, so the import-watch portion of this execution test was skipped locally. The hardware-specific reproduction and patched results are documented by the reporters in #2767.
Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T21:40:45Z.
Tested this head (
c0610950, merged cleanly ontomain262c0316) on the hardware the linked issue is about, since the description says the watched path was skipped on llvmpipe.Arch Linux (kernel 7.2.9), GCC 16.2.1, Release,
ANYPS5_REQUIRE_VULKAN=1. RTX 5080 (NVIDIA 615.78.08), where host imports stay write-watched, and a Radeon 610M on RADV, where they are compared.main262c0316,agc_driver_dcc_keys_first_writean unchanged pending image was uploaded again)agc_driver_dcc_keys_first_writectestctest reports 4
video_out_flip_*tests as skipped in the RTX 5080 run, and those plus 3guest_video_out_*tests in the RADV run; they are counted in the 708.The diff is the patch from the issue unchanged, so this is the change the three NVIDIA reports there were made with. Not tested: Windows.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-10T23:05:31Z.
The description notes that the import-watch part of
agc_driver_dcc_keys_first_writewas skipped on llvmpipe. It only runs where the device's own host import resolves the write protection, which CI's devices don't do, so this fix has no test there. Here is one that doesn't depend on the driver, as a single commit on top of this PR's head (c0610950):milescoviello/AnyPS5:test/2984-import-window, commita086c534.RunImportWindow(inDccKeysFirstWrite.cpp, Linux only) opens an import window itself over a pending storage image withGuestMemory::ImportWatchedand stores the byte already there. That leaves the sameBlockMaybeWrittenstamp the NVIDIA import leaves, so the image must stay pending and unchanged. A store of a new byte inside a window must still be seen by the nextRefresh. Devices whose imports are compared print that the window is not tested, as the recorder's(w)test does.TechnicalDebt.mdentry: an identical-byte CPU store inside a window can't be told apart from the import, and images tracked by layer (not by 64 KiB unit) still upload again.Tested (Linux, RTX 5090 Laptop GPU 610.57.04 and Intel Arrow Lake ANV, Mesa 26.1.8):
agc_driver_dcc_keys_first_writeimport window: a pending image was uploaded again after an import that stored nothing newtools/check_conventions.pypasses. Feel free to fold it into this PR or leave it.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:43:25Z.
Checked the diff: the block is only reused when
compareUntrackedfinds it byte-identical to the snapshot, one 64 KiB unit at a time, so a real write is still seen. Local build andlibSceAgcDriverctest (344 tests) pass on this head merged ontomain. The NVIDIA failure and fix are confirmed by @fma-rc (RTX 5080) and @milescoviello (RTX 5090 Laptop), thanks. Merging; the extra driver-independent test in the thread is welcome as a separate PR.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-10T23:58:49Z.
@adriadam10 @MarcZX100 thanks for merging this. Two things, the second one more important:
1. The driver-independent test, rebased onto
main:milescoviello/AnyPS5:test/dcc-import-window(one commit,63649253; it cherry-picks cleanly onto currentmained79bde5). I can't open PRs yet under the intake rule, so it's there for whoever can carry it.2. On current
mainthis fix no longer holds on NVIDIA.agc_driver_dcc_keys_first_writefails again withan unchanged pending image was uploaded againon the merge commit3db065afand onmain(59a8cbabanded79bde5), while this PR's headc0610950passes. A first-parent bisect of the 88 merges between this PR's base4a747c48and the merge, applyingc0610950at each step, points to #2699 (926ad9e3, "read a fast-cleared surface's guest bytes only when the import is compared").#2699 makes the DCC fast-clear upload leave
originalValidfalse when the range is write-watched. This PR's comparison needs that snapshot:compareUntrackedreturns false without one, so a unit of a fast-cleared surface that an import window stampedBlockMaybeWrittencounts as changed again. Each change is right on its own; they conflict where imports stay watched. The test's surface is fast-cleared (its keys start at 0000), so it hits exactly this path.Linux, RTX 5090 Laptop GPU (610.57.04),
agc_driver_dcc_keys_first_writewith the test commit applied:mained79bde5an unchanged pending image was uploaded againmained79bde5, only the new import-window part (existing watched run skipped)import window: a pending image was uploaded again after an import that stored nothing newmain59a8cbabwith #2699's three-line clear-path change and its two test lines revertedc0610950So the new test catches the regression by itself. It doesn't rely on the import behaving like NVIDIA's, so it should fail on any device whose imports stay watched. I haven't written a fix: it means choosing between #2699's saving and the snapshot this comparison needs (for example, keeping the snapshot on the clear path when the range's import can leave import-window stamps).
AI-assisted: yes