fix(agc): keep the write-back ready barrier while hole copies are pending #8908
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8908"
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 meh7an on 2026-10-21T05:39:19Z.
What
StorageTexture::writeBackWindowsrecords a write-back's seed, padding and hole copies, then theimportReady/toReadbarrier before the compute retile reads the slabs those copies wrote. #7489 lets that barrier be skipped when the batch's trailing barrier already covers it (Recorder::ElideCovered). The skip is allowed only with no seeds and no padding copies, but hole copies (padding moved into a unit-shadow slab, added ina8060b40e) are not checked. A covered mask taken before those copies does not order them, so the retile can read a slab before its hole copies land.This PR also requires
holeCopies.empty()before the barrier may be skipped.Regressed by #7489 (
ea5b81134). In Sonic Origins Plus (PPSA05324), the menu's button prompts and notice line lost parts of their glyphs, and which glyphs varied from run to run.Tested
Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 2080 Ti, driver 617.14, on main
fa9eb5cfa.Sonic Origins Plus, Sonic 2 page of the main menu: full window captures taken in the session, three readings per build. The six crops are attached: rows 1-3 are main, rows 4-6 are this PR.
Bisect, first parent only, over main from
0a56aaaf4(clean) to1d4164552(broken). Clean:5e9074999,0cc1cfa1c,819ced2e1,feb74b65c,dc54701e4,05b5d192f,7f596df48. Broken:463031845,096279ed2,ea5b81134.3a14fdb32was skipped: it aborts at boot with "Thread destructor callback is already registered", which is unrelated. The first bad merge isea5b81134(#7489).Main
fa9eb5cfawithAPS5_NO_BARRIER_BATCH=1and no other change renders the prompts clean in all three captures.With a temporary print (not in this PR), the barrier was skipped while hole copies were pending 36 times in one run of the menu page.
The full
ctestsuite on main plus this PR: 1827/1828. The one miss isagc_driver_image_array_window_past_layer_limit, which is Not Run on main too, because MinGW cannot build itsalignas(65536).ctest -R "agc_storage|agc_barrier_batch|write_back|writeback" -V(13 tests) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, on main and on this PR:was not found but was requested by env var VK_INSTANCE_LAYERS. The loader debug output showsVkLayer_khronos_validation.dllloading.VUID-line.No new test. On this machine the storage write-back tests compare host imports instead of watching them ("host imports are compared, not watched"), so no window is retiled into a unit-shadow slab and no hole copy is recorded. A test of this path needs watched host imports.
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T05:40:29Z.
Review: APPROVED
Reviewed the changed path against the surrounding command sequence.
holeCopiesare issued withvkCmdCopyBufferinto the unit-shadow slabs immediately before the retile dispatch;importReadyprovides the transfer-write to compute-shader-read dependency. The priorElideCovereddecision only checked seeds and padding copies, so excluding pending hole copies is the missing guard. The PR description also reports a title repro, a bisect to #7489, and clean captures with this change. I could not reproduce the Windows/Vulkan title path in this environment, so this approval is based on the code path and your reported measurements.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-21T08:15:36Z.
@meh7an the focused regression now gives a repeatable red/green result on both GPUs.
12986aa49baddsagc_storage_hole_copy_barrierto the recorder suite (two files, 166 added lines).18d206039eadds your unchanged849c71646fon top, preserving Mehran's authorship; range-diff is=. The fixture blob is byte-identical.Frozen base: main
3bd7173b77. The control is main production plus the new test, not an unchanged-main execution containing a pre-existing fixture.The fixture uses a watched, unseeded, 1000x700 single-mip R_X surface with padding. It records a valid prior barrier and marks its coverage, then observes five import-to-slab hole copies and one retile dispatch. The control observes one dispatch before those copies are ordered; with the fix that count is zero. The aggregate barrier count is one in both cases: the test checks its position relative to the read, not just its presence. That matches Vulkan's before/after submission scopes.
You can cherry-pick the test-only commit into this PR, which already contains your production fix. No duplicate fix PR opened. The fixture uses one legal physical mip and does not depend on our #7085 extra-mip backing work.
Validation setup and limits
agc_driver_unit_shadowandagc_storage_writeback_blockseach pass 3/3 per GPU on both compositions; CPUagc_barrier_batchpasses3/3 on each. 36 positive processes plus six exact negative-control failures, no skips/timeouts/VUIDs/validation errors or warnings; maximum 0.563 s. The earlier four precondition processes retain their separate main338f pin and are not added to these counts.Windows 11 Enterprise 26200, WinLibs GCC 15.2 r7/UCRT Release, SPIRV-Tools ON. Actual physical adapters (
10de:2c02,1002:13c0) and loaded Khronos 1.4.363 verified. Required Vulkan, application cache/journal disabled, verbose serial CTest with 30 s limits; driver caches/implicit layers uncontrolled. Selected targets build; conventions and whitespace pass. Cppcheck then clang-tidy complete with no parser failures/timeouts: 52 diagnostics, all seven-line contexts unchanged from main; none in the new fixture or changed guard. Existing advisories remain disclosed, without an analyzer-clean claim.The observer follows the suite's nested-recorder lifetime pattern. Earlier fixture-development failures were retained locally and are excluded from the qualified counts. The assertions require a whole unseeded window, actual hole copies, a retile dispatch and correct ordering.
No full-default build, full-suite, title/FPS, Linux or console result. Newer checked main
27c88has byte-identicalTexture.cpp, recorder, import, unit-shadow, detiler and tiling implementation files; that is source review, not a new runtime pin. Our historical integration guard atb64afbremains separate context, not this control.AI-assisted: yes (Codex); author responsible.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T16:27:43Z.
An independent data point from a different title, GPU vendor and OS. This change fixes a GPU hang I had been chasing in Echoes of the End (PPSA25636).
Setup
33a6d6bbfbplus #8089, #8762, #8091 and #4449, which the title needs to reach the scene. My private diagnostic commits are also in it; they do nothing unless their env vars are set, and none were set below.Symptom without this change
gfx_0.0.0ring timeout at 170-410 s. Each was a soft ring reset with no VM page fault.RADV_DEBUG=hangdump places the hang inside a game computeCmdDispatchIndirect. Its loop bound comes from atxfof autexture2D, so a stale value in that texture spins the waves until the timeout.Bisect, same tree, one run each unless noted
APS5_NO_UNIT_SHADOW=1APS5_UNIT_SHADOW_MIB=4096(no evictions)APS5_FULL_BARRIERS=1APS5_NO_BARRIER_BATCH=1ElideCovereddisabledThis also explains why eviction triggers it here. A hole copy is recorded only when the padding's source is a buffer other than the destination slab. That happens routinely once evicted slabs are recreated, and rarely while slabs stay resident. With the 4 GiB budget the elision never meets a pending hole copy.
Not measured here: whether
holeCopies.empty()costs any elisions in titles without eviction. Every clean run above used the same tree and only the configuration shown.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T16:35:52Z.
Second title for this fix on AMD/Linux, next to the Echoes validation above.
Setup
mainb5d763770awith #4449 merged locally, plus a local descriptor guard for its imports. This title needs #4449 to import its direct memory at all.APS5_UNIT_SHADOW_MIBand no barrier switches. Same inputs in every run.ring gfx_0.0.0 timeoutfrom the game at ~118, ~120 and ~150 s, thenvkQueueSubmit … Vulkan result -4APS5_NO_BARRIER_BATCH=1APS5_UNIT_SHADOW_MIB=4096849c71646fmerged on top)A
RADV_DEBUG=hangdump of one of the hangs without this PR names a compute pipeline that runs out of time: a 32-thread workgroup withumaximage atomics into anr32_uint2D-array image. This is one run with the fix against three without it.AI-assisted: yes (Claude Code); results above were run on this machine.