Repository navigation
fix(agc): publish only the bytes a write-back retiled into a shadow unit - #22705
oneandonlydean merged 2 commits into
Conversation
A unit shadow publish copied every byte of a 64 KiB unit from the slab to the import. In a unit that a write-back covers only in part, the rest of the slab holds bytes seeded from the import or left by an earlier retile. Those bytes are not GPU results. If a CPU store landed after the seed read the import, the publish put the old bytes back over it. MarkShadowed now records the span of each unit that retiles wrote since its last publish, and a publish copies only that span. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A unit's produced range was the hull of its retiled spans, so slab bytes in a gap between two spans were still published. Keep the spans as a sorted list and copy each one. The test now also covers two disjoint spans and a second span retiled into a unit that was already published. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@PrivacyOnion @MarcZX10 could one of you review this on The new |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the optional point below concerns test coverage.
What I ran
Reviewed head d7258c0045cf479d1d652691f1d68374a2d8a7f8. I read UnitShadow.cpp, StorageFlushOrdering.cpp, and claude-shadow-publish-produced-bytes.md, along with the prepared description, commits, manifest, and diff. No commands or tests were run in this review; the test results in the description are author-reported.
Results
| Check | Result | Note |
|---|---|---|
| Changed code review | passed | Read all three changed files |
| Tests | not run | Results supplied by author |
Findings
Blocking
None.
Non-blocking
- The added test checks partial, disjoint, and subsequent spans, but not a range clipped at the start or end of a partially covered import unit. Adding such a case would exercise the
UnitRangeclipping used when forming copy regions.
Not verified
No tests were run. Runtime behavior, including the reported Bloodborne issue, was not independently verified. All files listed as reviewed in the manifest were read; none were excluded.
To get this to a good state
Nothing is required. Optionally add coverage for spans clipped at an import boundary.
|
@oneandonlydean MarcZX10 approved the current head It fixes a heap overwrite that crashed Bloodborne CUSA00900 at the handover into gameplay. The in-game retest is still pending. @MarcZX10 thanks for the review. I will add the optional case for a span clipped at an import-unit boundary as a follow-up rather than move this head. |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Ran the storage flush ordering tests on NVIDIA's proprietary Linux driver with the Khronos validation layer, since the description's runs are on Windows. Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
Main runs its own version of Negative control: this PR's build with No new AI-assisted: yes (Claude Code) |
|
Thanks @domx4q, this is a great run. Linux and Ada were the gaps, and the negative control with main's |
|
In-game retest on Bloodborne CUSA00900 01.09 (Windows, local tree = main plus earlier Bloodborne fixes plus this PR's
That is a new, separate stop (a pixel shader prepared at first use right after the skip) and is not related to the shadow publish. Controllable gameplay is not reached yet, so there is no gameplay FPS. Presents per 10 s: title and menus 17-26 FPS, the loading screen 0.9-13 FPS while the map streams, and the cutscene 15-24 FPS (about 21 on average). |
|
Ghost of Tsushima (PPSA02225) runs with this PR. I was watching for corruption or crashes from GPU bytes that are no longer published, since GoT leans heavily on shadow units. Setup:
AI-assisted: yes (Claude Code). The runs are from this machine. |
|
Thanks @milescoviello, added to Tested. Agreed on both: the run 4 stall also shows up without this change, and the run 7 segfault is in the shader recompiler, which this PR does not touch. |
|
Windows + AMD run; I found no AMD run in the description or in the comments. Head Setup: Windows 11 25H2 (build 26200), AMD Radeon 760M integrated graphics (
AI-assisted: yes (build and runs scripted with an AI assistant, on the hardware above). |
|
@rafaconvaitis thanks for testing |
|
Head No new failures and no new validation messages on either GPU.
Layer runs used AI-assisted: yes |
|
@Colewiz7 thanks for running |
What
A unit shadow publish copied all 64 KiB of every selected unit from the slab to the import, even when write-backs had retiled only part of the unit. The rest of the slab unit holds bytes that were seeded from the import or left over from an earlier retile, so they are not GPU results. If the guest changed those bytes after the seed read them, the publish wrote the older bytes back over the guest's.
MarkShadowednow records the byte spans that retiles wrote into each unit since it went live, as a sorted list of disjoint spans.publishUnitscopies only those spans. Freshness is still decided per unit, as before.Found in Bloodborne (CUSA00900 1.09). The title's GPU-visible heap keeps chunk headers and free-list links right after its render targets, at offsets such as
+0x78040inside the unit that holds the end of a0x78000-byte surface. Instrumented runs did the following:fdlink (0x25ab28050) changed while no thread held the heap lock, to an older but plausible heap pointer;0x25aab0000+0x80000over a surface ending at0x25ab28000).The stale link later made the title's allocator hand out a chunk inside a live render target. The game crashed in its own
free()(rip 0x248599f) at 110-150 s, during the hand-over from the loading screen to gameplay.Known gap (fragment
claude-shadow-publish-produced-bytes.md): freshness is still judged per unit. A CPU store anywhere in a unit drops the unit's retiled bytes too.Tested
tests/execution/StorageFlushOrdering.cpp(RunPartlyShadowedUnitPublish): it fills a whole slab unit, marks only part of it shadowed, publishes, and checks the guest bytes outside the marked spans. It covers half a unit, two disjoint spans, and a second span marked into an already published unit.FAILED, 8192 dwords past the retiled range hold the slab's bytes, not the guest's. With this change,agc_driver_storage_flush_orderingandagc_driver_storage_flush_ordering_no_importpass.ctest --test-dir build -R agc_driver_storage_flush_ordering -VwithANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer(LunarG layer 1.4.363).Insert instance layer "VK_LAYER_KHRONOS_validation".was not found but was requested by env var VK_INSTANCE_LAYERS.VUID-line.d7258c0045merged onto main1ccc399b17: Arch Linux, GCC 16.2.1, RTX 4090 (Ada), NVIDIA 620.70.06, Khronos layer 1.4.363.1. Both focused tests pass on main and on the PR, the layer loads in both, and neither log has aVUID-line. With main'sUnitShadow.cppthe new partly-retiled case fails 2 of 2 runs.d7258c0045merged onto main6119c53c4b: Linux 7.0, RTX 4070 Ti, NVIDIA 615.71.09, Ghost of Tsushima (PPSA02225), 450 s scripted runs from a pinned save with a cold shader cache. No visible corruption; menus and cutscene frames match main. One black-screen stall was also seen on a build without this change, and one segfault was in the shader recompiler (FencedEntries), which this PR does not touch.d7258c0045merged onto main3c07e1d05e: Windows 11 25H2, WinLibs GCC 15.2.0, AMD Radeon 760M iGPU, AMD Software 26.11.2, Khronos layer 1.4.363. Both focused tests pass 3 of 3 runs on main and on the PR, the layer loads in every run, and no log has aVUID-line. With this PR's tests on main's sources,agc_driver_storage_flush_orderingfails (quarter 2 has 4096 dwords that are not 0x3f800000).d7258c0045merged onto main7c836568c8: Linux 7.3.4, GCC 16.2.1, Mesa 26.2.6 RADV, RX 7900 XT (gfx1100) and 7800X3D iGPU (gfx1036). The full test set (6206 tests on the 7900 XT, the 2007 GPU tests on the iGPU) and-R '^agc'with the Khronos layer 1.4.363.1 show no new failures against main, and neither GPU has aVUID-orSYNC-HAZARDline.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)