perf(agc): keep a fast clear's guest bytes while they match unwatched memory #6108
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6108"
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 Gashrod1 on 2026-10-14T22:26:54Z.
What
A fast clear of a storage image over unwatched memory (
upload,IsDccClear(uploadedKeys)) callscaptureGuestBytes(nullptr)so that a laterRefreshcan compare the texels. It did so on every clear, even when the bytes it already kept still matched the memory, andcaptureGuestBytesresetscomparedGuestBytes, so the nextRefreshcompared the whole surface again instead of answering from the memo.The clear now checks the kept copy with the memoized
compareUntrackedfirst. It copies again only when a block changed, as before, and also, conservatively, when a unit kept at unwatch would read as written or a write-back's saved bytes are still pending (savedTicket). In those cases the old copy (which cancels the pending save) still runs. The state after the clear is the same as before: the same bytes inoriginal, the samelayerOriginal. The memo now survives.GuestSnapshots()countscaptureGuestBytescalls, likeUntrackedCompares(), for the regression testRunClearKeepsSnapshotinDccKeysFirstWrite.cpp(unwatched block):mainwith "copied its guest bytes 1 times");Refreshdoes not upload again (the copy holds the CPU store).Tested
After merging
main88e804b0a7: the only conflict wascaptureGuestBytes, which gained akeepWrittenparameter onmain; the counter goes into the new signature and the clear path is unchanged (keepWrittenis false there, so skipping the copy skips the same work as before). Linux, Intel Alder Lake-P iGPU (Mesa 26.2.4),ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:agc_driver_dcc_keys_first_writepasses 3 of 3; with theguestBytesStillHeld()check removed it fails with "copied its guest bytes 1 times". All 1208agc*tests pass exceptagc_driver_f32_denormal_flushandagc_idle_publish_wait, which fail the same way onmainon this machine. No validation layer is installed here; the review runs above cover it.Before the merge:
GPU tests. Linux (Intel Alder Lake-P iGPU, Mesa 26.2.4), on
ba3ffbab9: everyagc_driver*and multisample test passes exceptagc_driver_multisample_fill_host_only, which fails the same way without this change (vkWaitSemaphoresKHR-4). Underctest -j8,agc_driver_gated_dispatch_capturefailed once after the last rebase andagc_driver_oversized_descriptor_setsonce before it; both pass alone and in 3 repeats. Windows 11 (RTX 5060, 596.36):agc_driver_dcc_keys_first_writepasses, the new case included (only that test was built there).DAVE THE DIVER (PPSA19115), underwater scene, Windows 11, RTX 5060 (596.36), Ryzen 7 5800X. This title needs the MSAA stack listed in #5963 to render, so it does not run on
mainalone. The base ismain956269ad1plus that stack, measured with and without this change; that base predates69702ef10, so the measured change has nosavedTicketcheck.Captured as the Performance report form describes:
APS5_TRACE_SECONDS=180:30and no otherAPS5_*variable, log not redirected, warm caches (the scene ran, then the title was restarted), same underwater scene, same machine and session; onlylibs/changed between the two captures.tools/performance_compare.py: frame p50 -22.6 %, p99 -25.3 %,Driver.Draw.draw_and_resource_release-33.8 %; the only recorded configuration difference iswindow.first_present. The GPU time per present is unchanged; the queue worker is busy about 99 % of the window in both.Traces, attached in the comment below:
aps5-trace-9a14a74bd275-105296.json.gz(base) andaps5-trace-cc690190b21a-88920.json.gz(change). Both reporttrace_dropped: the queue worker's default event buffer filled after about 4.6 s (base) and 3.5 s (change) of the window, so the event tracks of that thread cover only those first seconds. The summary lines come from the per-thread totals and cover the whole window. I kept the default buffer because the form asks for no otherAPS5_TRACE_*switch.A local counter in that path (not part of this PR), per 10 s, in an earlier run:
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)agc_driver_dcc_keys_first_write)Imported from boykopovar/AnyPS5. Originally posted by Gashrod1 on 2026-10-15T01:04:50Z.
Traces of the two captures in the description (base, then this change).
aps5-trace-9a14a74bd275-105296.json.gz
aps5-trace-cc690190b21a-88920.json.gz
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:31:22Z.
Checked build and the AgcDriver ctest scope on the PR merged onto main:
agc_driver_dcc_keys_first_writepasses, and with theguestBytesStillHeld()condition removed the new case fails ("copied its guest bytes 1 times").agc_driver_tessellationsegfaults here with and without this change. Kept-copy conditions (savedTicket,keptAtUnwatch, memoized compare) fall back to the old capture, so the state after a clear is unchanged. Merging once the full build is green.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T13:48:32Z.
Review: APPROVED
Reviewed
a69c307fd5d4against merge baseba3ffbab9dbe. Recommend approval; no actionable finding in the focused source and execution review.Snapshot reuse remains conditional on matching guest bytes and valid ownership. Changed memory, pending saves and write-watch cases retain the conservative path. The regression assertions check unchanged clears, CPU writes and subsequent refresh behavior.
Validation: Built the candidate and base targets on Windows with GCC 15.3 and RTX 5070 Ti, driver 616.92.
agc_driver_dcc_keys_first_writepasses on both. Vulkan was required, and the candidate log confirms the changed unwatched-memory case was not skipped. The baseline lacks the new assertions, so its pass establishes environment health rather than regression sensitivity.Scope: No Linux/Mesa or full AGC run. Shader-cache settings and a validation-layer error comparison are not established by the saved evidence. Hosted product jobs were skipped; performance claims remain author-reported.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T18:13:00Z.
Review: APPROVED
@Gashrod1 approved.
What I ran: head
cf49f087femerged ontomain9ab6a281ea(clean merge,f0899ddbf4). Windows 11, WinLibs GCC 15.2.0, AMD RX 9070 XT (driver 32.0.32015.12012),ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest -V:agc_driver_dcc_keys_first_writepasses,RunClearKeepsSnapshotincluded. NoVUID-orSYNC-HAZARDids and no missing-layer lines.main9ab6a281ea, same test and settings: passes, with noVUID-orSYNC-HAZARDids and no missing-layer lines. So the change adds no validation errors.} else if (!guestBytesStillHeld()) {inStorageTexture::uploadchanged back to} else {(always copy, as onmain), the test fails withclear snapshot: a clear over unchanged unwatched memory copied its guest bytes 1 times. So the new case catches the change.pr_overlap.py --branchon the head: no conflicting lines or shared exports. 29 PRs that conflict withmainshareTexture.cpp/Texture.hppand couldn't be compared.Read in context:
guestBytesStillHeld()returns true only when all of these hold: the kept copy covers the whole surface (original.size()andoriginalHolds); no unit has a write-back pending (savedTicket); no unit is kept at unwatch for its current generation (keptAtUnwatchHolds); andcompareUntrackedreports every 64 KiB block unchanged.captureGuestBytes(nullptr)runs as before. So each case the description calls conservative still copies, and the pending save is still cancelled there.layerOriginal.assignpluscancelStoredSaves) is unchanged.I didn't re-measure the DAVE THE DIVER numbers; that needs the #5963 stack.