fix(agc): publish unit-shadow results before an address-based build maps its heaps #6682
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6682"
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 EagleBearerYS on 2026-10-16T04:24:31Z.
What
An address-based build binds the registered heaps in place and does not store the storage results pending in them: the heaps hold every pending image, and storing them all would serialize the build. With unit shadows on, a storage write-back that retiles into a shadow ("storage refresh", "storage image creation") reaches the import only through a publish: a host-facing reader, an eviction, an idle flush. Nothing published before an address-based build, so its pointer reads saw the bytes as of the last publish. In Resident Evil Village (PPSA01556) that is the title menu's last frame, published once by the idle flush at the load and shown dimmed over gameplay.
Two paths had the gap:
FlushPendingfor the exempt in-place heaps;APS5_BDA_FLUSH=1did not reach them either.UploadFinishnow publishes the fresh units over the heaps the build maps: the space's base, and the exempt regions of the per-build path. OneAnyShadowedOverlapscheck over their span gates it.address, in the[storage]line.A CPU store inside a completion action (6ee5a91b2a). Found by an after-the-fact completeness review, on
mainwith or without the rest of this PR. A store a completion action makes was published withPublishScope::None, which skips the units it covers partly. Its stamp then marked those units stale, and the next publish dropped them whole: up to 65,532 bytes of results around each such store. Completion stores now publish their partly covered units first, and a store that waited for its batch publishes like any other; the completion's existingSync()orders the copy.Tested
Linux, Mesa lavapipe, CI's Linux job mirror:
^agcat the head: 607 of 608 pass (43 of them skip as expected); the one failure,agc_driver_preparation_scope_settle, is a timing flake that also fails on main under the same parallel load and passes alone;--repeat until-fail:10).agc_unit_shadow_completion_storefails in all 3 runs on Linux with the same message, and with them it and 41 neighbouring tests pass 10 runs in a row; the GPU tests skip on the Windows runner.New
agc_driver_bda_reads_shadowed_resultsandagc_driver_bda_reads_shadowed_results_per_build(APS5_NO_ADDRESS_SPACE_CACHE=1). A storage image's write-back retiles into the unit shadow of a registered heap, then an address-based build maps the heap:Windows 11, RTX 3070 Laptop GPU (driver 617.42), MinGW build:
GuestBufferMemory.cppchange reverted, both fail with the same message as on Linux;agc_unit_shadow_completion_storeand both tests above pass 5 runs in a row; with its five source files at the parent, onlyagc_unit_shadow_completion_storefails ("a CPU store inside a completion over a pending image lost 65532 bytes of the image's results around it").Resident Evil Village (PPSA01556), Windows 11, RTX 3070 Laptop GPU (driver 617.42), unit shadows on (the default):
Linux, NVIDIA GeForce RTX 3070 (driver 595.99.02), Ubuntu 26.04, run by jotitadev on this head merged onto
main0615cd2b8(review):main's sources and this PR's tests,agc_driver_bda_reads_shadowed_resultsand_per_buildfail with "an address-based build over a heap left the unit shadow's stored results unpublished: the import held the earlier bytes at its submission", andagc_unit_shadow_completion_storewith "a CPU store inside a completion over a pending image lost 65532 bytes of the image's results around it".Merged with
main0d078f75d3(c320f283d7, the head, no conflicts), on GitHub's runners (run): the^agctests pass on Linux (712, 0 failed), and the suites' only failure is libc'sprecise_waittiming test. On Windows the only failures areagc_driver_pm4_replay_toolandagc_shader_replay_tool, which fail the same way on that runner for an unrelated branch (run).Cost in the title: follows as an edit.
Checklist
main7663bc63bb; mergesmain0d078f75d3; no other open PR implements the same functions. Overlaps (git merge-treewithmain5d9dcc42d2):if (addressable) StoreDepthExpandWrites(context);at the same line at the end ofUploadFinish. Keep both, the expand store first, so expanded planes stored into a shadow are published too.UploadFinish, where this PR publishes: it takes its space back throughResumeSpaceand proves itself inRevalidate. Whichever merges second publishes the space's unit shadows afterproveBuildinRevalidate(aPublishSpaceShadows()call), with a test that reuses a draw over a shadowed heap.MarkShadowed, so this publishes them for pointer reads the same way.NotImplemented_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 jotitadev on 2026-10-16T15:30:12Z.
Review: COMMENTED
Linux run on a desktop NVIDIA GPU with the proprietary driver; the description covers lavapipe on Linux and an RTX 3070 Laptop on Windows.
Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, plus lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same machine. Ubuntu 26.04 (kernel 7.0.0-38), i7-8700, GCC 15.2, Release,
BUILD_TESTING=ON. Head6ee5a91b2merged ontomain0615cd2b8, clean merge (maindid not build at the time, #6784).GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04
RTX 3070:
Texture,UnitShadow,Recorder.cppandGuestBufferMemory.cppfrommain):agc_driver_bda_reads_shadowed_resultsand_per_buildfail withan address-based build over a heap left the unit shadow's stored results unpublished: the import held the earlier bytes at its submission, andagc_unit_shadow_completion_storefails witha CPU store inside a completion over a pending image lost 65532 bytes of the image's results around it.agc_unit_shadowpasses.host imports resolve write protection: no ... imported ranges stay watched, while lavapipe reportsimported ranges are compared, so the new tests ran under both import modes on Linux.ctest -R "^agc|shader|recompiler" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64|display|flip" -j1 --timeout 60: 616 tests, onlyagc_driver_store_over_untrackedfails, which also fails on unchangedmainhere (#6347).lavapipe: the four tests pass.
Not checked: Resident Evil Village or any title, Windows, the address-space cache toggle beyond what the
_per_buildtest sets.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T15:34:41Z.
@jotitadev thank you for the run on a desktop RTX 3070 with NVIDIA's Linux driver. It covers a case the description didn't: that driver keeps imported ranges in the write watch, while lavapipe compares them, so the new tests now have a red and a green under both import modes. I've added your run to the description's Tested section.