Repository navigation
fix(agc): advance stored layers when a write-back keeps CPU-written blocks - #4663
Conversation
b624363 to
c6b403d
Compare
|
Changes in this revision (rebased onto current
|
|
An Intel run, and the full suite, which the description lists as not run. Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head c6b403d merged into
Written with AI assistance. |
|
Linux test (Arch, GCC 16.2.1, Release, Intel Arc B390 on Mesa 26.2.2 ANV), head The watched-memory case passes. On this machine the write-watch probe reports |
adriadam10
left a comment
There was a problem hiding this comment.
Checked on Linux (RADV, Radeon 660M): the PR merged onto main builds, agc_storage_kept_unit_settle passes, and it fails with only the Texture.cpp change reverted, so the test does exercise the change there. libSceAgcDriver ctest otherwise matches main (agc_driver_tessellation segfaults on main too).
- However, @nicolasfalesy reports that on Linux with Intel Arc (ANV, Mesa 26.2.2) the direct-memory case fails with this PR:
the second write-back stored over unit 0, which the CPU wrote after that unit's generation. That is the failure that the watched-memory case guards against (a layer that kept a block must keep its old generation). There the probe reportsdma-buf imports keep write protection: yes, so direct memory takes the dma-buf import path, not the host-import path the description targets. We can't reproduce it on RADV, so please find out why that path advances (or stamps) unit 0's generation, and either fix it or restrict what the test claims. A test that fails on a Linux driver can't be merged. - Windows runs by @kr4y4 (RTX 4070 and Intel iGPU, full suite) pass, so this looks specific to the Linux dma-buf path.
Happy to re-review once the Linux/ANV case passes.
c6b403d to
dd97094
Compare
|
Thanks for the Linux run. I traced it, and the failure doesn't come from a dma-buf write-back path. Your direct memory never reached the dma-buf import.
What changed: the branch is rebased onto f2c314e with one extra commit. The direct case now checks the write watch again after the import. If the import took the memory out of the watch, it prints Could you rerun Written with AI assistance. |
adriadam10
left a comment
There was a problem hiding this comment.
Checked on Linux (RADV): the PR merged onto main builds, agc_storage_kept_unit_settle passes, and it fails with only the Texture.cpp change reverted. The remaining libSceAgcDriver ctest difference vs main is agc_driver_tessellation (segfaults on main too). The ANV case from @nicolasfalesy is now skipped (77) when the host import takes the memory out of the write watch, which matches the trace in your reply; the compared-path store throwing on main is a separate follow-up. Windows full-suite runs by @kr4y4 pass. Merging once the full Build is green.
3b69ed3 to
cedf5f6
Compare
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
9255016 to
841ca00
Compare
…locks On a host-imported surface a storage write-back keeps the 64 KiB blocks the CPU wrote since their tracked layer's generation, stores the rest and stamps the stored ranges with MarkWritten. Settling advanced the stored layers' generations past those stamps only when no layer kept a block (or when an adjacent pending surface needed the collect). When one tracked layer kept a block, every other stored layer kept its old generation, so the write-back's own stamps read as CPU writes: the next write-back kept those layers as well and did not store the GPU's newer results over them. A tracked layer is one 64 KiB unit when the surface has block units: tiled (not linear), 64 KiB-aligned base, not thick, with layer and block tracking on. Otherwise it is an array layer (64 KiB-aligned layer slices, layer tracking on) or the whole surface. Settling now collects and advances each stored layer that kept no block; a layer that kept a block keeps its old generation and re-uploads at its next use, as before. When no stored layer advances (nothing stored, or every selected layer kept a block, such as a single tracked layer that kept one), no adjacent pending surface needs the collect and no unit was retiled into the unit shadow, settling still skips the collect, as main did. Units retiled into the unit shadow are now marked at the settle collect's generation also when a block was kept; main marked them at TrackerGeneration() there without collecting. The two differ only for a CPU write to a stored unit made after the keep decision: main left it to a later walk, which made the retiled unit stale so the CPU's bytes won; now the walk stamps it at the marked generation and the stored results win, as they already did when no block was kept. agc_storage_kept_unit_settle uses a 1024x512 RGBA8 surface in 64 KiB tiling (32 block units): it writes one byte of unit 0 from the CPU, stores a red clear, stores a blue clear, and requires units 1-31 to hold blue and unit 0 to keep the CPU's byte after both stores. On main the GPU-mapped direct memory case fails with unit 1 still red. The watched-memory case (host imports off: the write-back that stores through the CPU) passes on main; it guards the kept layer's old generation and fails when settling also advances a layer that kept a block. The test returns 77, naming the reason, when the direct-memory case cannot run: no write watching, no host imports, direct memory not write-watched, or its host import refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ompared agc_storage_kept_unit_settle checked that the GPU-mapped direct memory was write-watched before it made the host import. On Linux, when host imports resolve write protection and dma-buf imports keep it, the host-pointer import is tried first in a window that does not stay watched, and dma-buf only when it fails (importAllocation in GuestBufferMemory.cpp). Where the host-pointer import of shared memory succeeds, as on Intel's ANV, the import takes the direct memory out of the write watch, so the case ran on the compared path: the upload saves the guest bytes, the first write-back keeps unit 0 by comparison and drops the saved bytes of every unit it selected, and the second write-back has nothing to compare. Before e544993 it stored every unit whole, over the CPU's byte in unit 0, which is the failure reported on Linux; on main it throws (technical debt: results over memory outside the write watch without saved bytes). Neither depends on the settle change. On Windows, importing watched private memory (compared there) reproduces both: on 7e181fc, with or without this branch's Texture.cpp change, the second check fails with that message; on main the second write-back throws. The case now checks the write watch again after the import and returns 77, naming the reason, when the import took the memory out of it. Where the import keeps the memory watched (the Windows alias import, a Linux dma-buf import) it runs as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
841ca00 to
7bfeeb9
Compare
|
The full Build is red on this head, on Linux only: Could the direct-memory case skip on its own and let the rest of the test run (and pass) there? If the remaining skip really is a device limitation, word it the way |
…ilable Co-Authored-By: Codex <noreply@openai.com>
|
Fixed in ca73d0f. The watched-memory case now runs and passes independently; an unavailable direct-memory subcase only prints its own reason. Missing host write watching and all readback failures remain failures, so this does not turn required coverage into a skip. Verification: full matching-header Recorder.cpp and unchanged Texture.cpp pass GCC -O3 syntax checks. The literal completion-policy CPU replay reproduces old exit77/check_skips failure and corrected exit0/check_skips success; injected watched/direct failures still fail. The GPU readback body and production code are unchanged. This follow-up has not been rerun on Linux or on a native GPU; CI must confirm lavapipe coverage. On ca73d0f, conventions run 38533264055, eligibility and report pass. GitHub retains cancelled duplicate conventions run 38533264336; rerunning it requires repository admin rights. The test-only Build gate skipped Linux/Windows, so a maintainer Build dispatch with GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100 (prior production-fix/readback evidence in the PR; this follow-up uses source and CPU checks only). AI-assisted: yes Co-Authored-By: Codex noreply@openai.com |
|
Re-checked the new commit |
What
On a host-imported surface a storage write-back keeps the 64 KiB blocks that the CPU wrote since their tracked layer's generation, stores the rest, and stamps the stored ranges with
MarkWritten. Settling advanced the stored layers' generations past those stamps only when no layer kept a block (or when an adjacent pending surface needed the collect).So when one tracked layer kept a block, every other stored layer kept its old generation, and the write-back's own stamps then read as CPU writes: the next write-back kept those layers as well and did not store the GPU's newer results over them.
A tracked layer is one 64 KiB unit when the surface has block units: tiled (not linear), 64 KiB-aligned base, not thick, with layer and block tracking on. Otherwise it is an array layer (64 KiB-aligned layer slices, layer tracking on) or the whole surface. With a single tracked layer, a layer that kept a block is the only stored layer, so nothing advances and settling behaves as on
main.Settling now collects and advances each stored layer that kept no block. A layer that kept a block keeps its old generation and re-uploads at its next use, as before. When no stored layer advances (nothing stored, or every selected layer kept a block), no adjacent pending surface needs the collect and no unit was retiled into the unit shadow, settling still skips the collect, as on
main.MarkShadowednow takes the settle collect's generation also when a block was kept;mainpassedTrackerGeneration()there without collecting. The two differ only for a CPU write to a stored unit made after the keep decision: onmaina later walk stamped it newer, so the retiled unit went stale and the CPU's bytes won; now this walk stamps it at the marked generation and the stored results win, as they already did when no block was kept.agc_storage_kept_unit_settleuses a 1024x512 RGBA8 surface in 64 KiB tiling (32 block units). It writes one byte of unit 0 from the CPU, stores a red clear (unit 0 is kept, as intended), then stores a blue clear, and requires units 1-31 to be blue and unit 0 to keep the CPU's byte after both stores. It runs on GPU-mapped direct memory (the host-import path, where that import keeps the memory write-watched) and on watched memory with host imports off (the write-back that stores through the CPU). Onmainthe direct-memory case fails:The watched-memory case passes on
main. It guards the kept layer's old generation on the path that stores through the CPU, which this change also makes collect and advance when a unit is kept: if settling advanced the layer that kept a block too, the watched case fails (the second write-back stored over unit 0, which the CPU wrote after that unit's generation).The watched-memory case is required and passes independently when the optional direct-memory subcase is unavailable. Unsupported direct imports still print the specific subcase reason and continue. A missing host write watch or any readback failure fails the test. The suite no longer reports all of its coverage skipped merely because the direct-memory subcase could not run.
Found while tracing the storage corruption in Demon's Souls (PPSA01342 v1.005). On its own this change shows no visible difference there: the green band in that title's movies comes from shared write tracking, fixed in #4661. This PR fixes the write-back bookkeeping that the test above exercises.
Tested
Windows Server 2025, RTX 3060, GCC 15.2 (Release). The branch is rebased onto
mainat 14db084; the tests below ran on the same commit rebased onto 84659e1 (git range-diffshows it unchanged). Main between the two adds the3rdparty/libusb-cmakesubmodule, which this worktree's build directory could not configure without initialising, and changes nolibSceAgcDriverfile.agc_storage_kept_unit_settle: passes with this change. With only theTexture.cppchange reverted, the direct-memory case fails with the message above. With settling also advancing layers that kept a block, the watched-memory case fails (checked on the earlier base 0142215).ctest -R agc -j 4(446 tests): 436 pass andagc_driver_stencil_ref_exportskips. 9 fail, and each also failed with only theTexture.cppchange reverted (checked on the earlier base 621ce1d):agc_driver_flat_loads,agc_driver_flat_loads_x2_x3,agc_driver_flat_loads_x4,agc_driver_global_loads,agc_driver_global_loads_x2_x3,agc_driver_global_loads_x4,agc_driver_flat_apertures_2,agc_driver_flat_apertures_5(abort with "guest allocation ... is still pinned by GPU work or an import") andagc_driver_pixel_interlock(vkDeviceWaitIdlereturns -4).tools/check_test_registration.py: passes.agc, and any title or homebrew.Follow-up for Linux CI coverage:
ca73d0fchanges only the fixture's completion policy; the production code and GPU readback body are unchanged. The entire matching-headerRecorder.cppand unchangedTexture.cpppass GCC-O3syntax checks. A CPU replay of the literal completion selector/catch/Require, with explicit observation callbacks replacing GPU work, reports old exit 77 versus corrected exit 0 after watched success/direct unavailability; the unchanged Linuxcheck_skips.pyreports lost coverage before and passes afterward. Injected watched/direct failures still fail. This is a completion-policy check, not a fresh Linux or native GPU rerun; the published CI run must verify lavapipe rendering coverage.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)🤖 Generated with Claude Code
Co-Authored-By: Codex noreply@openai.com