fix(agc): keep storage image results recorded after a direct write when its completion stamps it again #8126

Merged
Longziip merged 4 commits from upstream-pr/8126 into main 2026-10-23 23:56:02 +00:00
Longziip commented 2026-10-19 22:56:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Longziip on 2026-10-19T22:56:44Z.


What

A dispatch's direct (host-imported) and copied-back buffer writes are stamped twice: by GuestBufferMemory::MarkDirectWrites when the dispatch is recorded, and again by GuestBufferMemory::WriteBack when its batch completes, if the dispatch needs a completion (a copied written buffer or BDA fault checks). The second stamp gets a newer generation than anything recorded in between. A storage image over the same memory that was uploaded and written after the dispatch in GPU order therefore saw the completion stamp as a newer write: its next Refresh dropped all of its pending results ("guest memory changed while GPU results were pending ... writers: 0 CPU, 28 driver ... 28 dropped") and re-uploaded the dispatch's older bytes.

WriteBack now stamps through StorageTexture::StampKeepingNewerResults. Before the stamp it collects the pending units of pending storage images in the range whose generation is at or after the dispatch's record-time stamp (kept in GuestBufferMemory::directWritesGeneration) and that nothing stamped since; after the stamp those units move to the new generation, so they keep their results. Each candidate unit's range is collected with GuestMemory::CollectWritesUncached before that check, so a CPU write that nothing had collected yet invalidates the unit instead of being absorbed by the stamp. Every other reader is still invalidated by the completion stamp as before. Removing the completion stamp instead is not correct: in-game it left stale textures and garbage after menu navigation.

EA SPORTS UFC 6 (PPSA23566) hits this on its main menu: a compute pass writes an 888x504 surface as a buffer and a storage image (format 22 with tile mode 3, or format 36 with tile mode 7) writes the same memory after it in the same batch. In about half of the launches the menu background and banner turned into blue and black blocks within a few minutes.

New test agc_driver_direct_write_completion (tests/execution/DirectWriteCompletion.cpp): one submission fills a write-watched surface as a buffer (plus a second, copied buffer so the dispatch takes a completion), then writes it as a storage image; after the completion has run, Refresh must keep the image current and pending. It uses as many surfaces as fit in one settled 4 MiB host import block (15 runs): a surface past it is imported alone below the settle floor and unwatched, so its record-time stamp is 0 and its results are dropped by design. On main all runs drop the results; with this change none do. A second case writes the surface from the CPU after the record and before the completion (the submission ends with a CPU-released WAIT_REG_MEM, the write is made under GpuMutex once the image is pending): its results must be dropped and the CPU bytes kept.

Related: #7233 changes the same three MarkWritten calls to MarkPossiblyWritten for a different issue (complete-coverage evidence); possible writes still invalidate readers there, so it does not fix this. Whichever lands second needs a one-line rebase.

Tested

Windows 11 Pro (build 26300), AMD Ryzen 7 5700X, NVIDIA GeForce RTX 4060 8 GB (driver 616.64), 32 GB RAM, WinLibs GCC 15.2.0, Release.

  • Focused tests on main (77e31219c) and on this change with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: ctest -R "agc_.*(storage|copied|direct_write|idle_store|untracked)". main: 35 of 35 pass (it has no agc_driver_direct_write_completion). This change: 36 of 36 pass. Neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS or any VUID- error.
  • python tools/check_conventions.py --base origin/main passes.
  • PPSA23566 (01.004.000): main still stops before the menu at the jump-table shader 0x1163c84000, so the title was run on the UFC 6 testing build from #5996 with the same change. Before: the menu corrupted in about half of the launches (hundreds of the 888x504 drop reports per run). After: three 4-minute menu runs with no corruption and no drop reports, then Fight Now through fighter select and versus into the T-Mobile Arena walkout with no visible corruption.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA23566 #5996
  • GPUs tested: NVIDIA GeForce RTX 4060 8 GB, driver 616.64, Windows 11 Pro
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4928506153 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126). Originally posted by [Longziip](https://github.com/Longziip) on 2026-10-19T22:56:44Z. --- ### What A dispatch's direct (host-imported) and copied-back buffer writes are stamped twice: by `GuestBufferMemory::MarkDirectWrites` when the dispatch is recorded, and again by `GuestBufferMemory::WriteBack` when its batch completes, if the dispatch needs a completion (a copied written buffer or BDA fault checks). The second stamp gets a newer generation than anything recorded in between. A storage image over the same memory that was uploaded and written after the dispatch in GPU order therefore saw the completion stamp as a newer write: its next `Refresh` dropped all of its pending results ("guest memory changed while GPU results were pending ... writers: 0 CPU, 28 driver ... 28 dropped") and re-uploaded the dispatch's older bytes. `WriteBack` now stamps through `StorageTexture::StampKeepingNewerResults`. Before the stamp it collects the pending units of pending storage images in the range whose generation is at or after the dispatch's record-time stamp (kept in `GuestBufferMemory::directWritesGeneration`) and that nothing stamped since; after the stamp those units move to the new generation, so they keep their results. Each candidate unit's range is collected with `GuestMemory::CollectWritesUncached` before that check, so a CPU write that nothing had collected yet invalidates the unit instead of being absorbed by the stamp. Every other reader is still invalidated by the completion stamp as before. Removing the completion stamp instead is not correct: in-game it left stale textures and garbage after menu navigation. EA SPORTS UFC 6 (PPSA23566) hits this on its main menu: a compute pass writes an 888x504 surface as a buffer and a storage image (format 22 with tile mode 3, or format 36 with tile mode 7) writes the same memory after it in the same batch. In about half of the launches the menu background and banner turned into blue and black blocks within a few minutes. New test `agc_driver_direct_write_completion` (`tests/execution/DirectWriteCompletion.cpp`): one submission fills a write-watched surface as a buffer (plus a second, copied buffer so the dispatch takes a completion), then writes it as a storage image; after the completion has run, `Refresh` must keep the image current and pending. It uses as many surfaces as fit in one settled 4 MiB host import block (15 runs): a surface past it is imported alone below the settle floor and unwatched, so its record-time stamp is 0 and its results are dropped by design. On `main` all runs drop the results; with this change none do. A second case writes the surface from the CPU after the record and before the completion (the submission ends with a CPU-released `WAIT_REG_MEM`, the write is made under `GpuMutex` once the image is pending): its results must be dropped and the CPU bytes kept. Related: #7233 changes the same three `MarkWritten` calls to `MarkPossiblyWritten` for a different issue (complete-coverage evidence); possible writes still invalidate readers there, so it does not fix this. Whichever lands second needs a one-line rebase. ### Tested Windows 11 Pro (build 26300), AMD Ryzen 7 5700X, NVIDIA GeForce RTX 4060 8 GB (driver 616.64), 32 GB RAM, WinLibs GCC 15.2.0, Release. - Focused tests on `main` (77e31219c) and on this change with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`: `ctest -R "agc_.*(storage|copied|direct_write|idle_store|untracked)"`. `main`: 35 of 35 pass (it has no `agc_driver_direct_write_completion`). This change: 36 of 36 pass. Neither log contains `was not found but was requested by env var VK_INSTANCE_LAYERS` or any `VUID-` error. - `python tools/check_conventions.py --base origin/main` passes. - PPSA23566 (01.004.000): `main` still stops before the menu at the jump-table shader `0x1163c84000`, so the title was run on the UFC 6 testing build from #5996 with the same change. Before: the menu corrupted in about half of the launches (hundreds of the 888x504 drop reports per run). After: three 4-minute menu runs with no corruption and no drop reports, then Fight Now through fighter select and versus into the T-Mobile Arena walkout with no visible corruption. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA23566 #5996 - [x] GPUs tested: NVIDIA GeForce RTX 4060 8 GB, driver 616.64, Windows 11 Pro - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-19 22:57:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T22:57:00Z.


Thank you for your contribution! Authors with no pull requests merged into main can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6279175909 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6279175909). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T22:57:00Z. --- Thank you for your contribution! Authors with no pull requests merged into `main` can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.
oneandonlydean commented 2026-10-20 08:24:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T08:24:02Z.


Reopening: this was closed by the open-PR limit while our intake was paused, not on its merits. We're taking it on and will review it under the normal process; it's assigned to us so it isn't closed again by the limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286723438 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6286723438). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T08:24:02Z. --- Reopening: this was closed by the open-PR limit while our intake was paused, not on its merits. We're taking it on and will review it under the normal process; it's assigned to us so it isn't closed again by the limit.
oneandonlydean commented 2026-10-20 08:30:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T08:30:01Z.


Thanks, the double-stamp analysis matches the code, and the new test pins the drop.

One case the keep list misses: CPU writes that have not been collected yet. GuestMemory::UnchangedSince only reads the block stamps. GuestMemory::MarkWritten first collects the range's fresh CPU writes (GuestWriteWatchCollectFresh on Linux, collectWindowsWrites with StampKind::Fresh on Windows), then stamps every block with the generation it returns. So if the guest CPU wrote over a pending unit after the unit's generation, and nothing collected that write before the completion, the unit passes the UnchangedSince filter. The write is absorbed into the completion stamp, and moving the unit to that generation hides it. The next Refresh keeps the GPU results, and storing them writes older texels over the CPU's bytes. On main the completion stamp drops the results, and the re-upload keeps the CPU write.

The other decisions about pending results in Texture.cpp collect the range first with GuestMemory::CollectWritesUncached (for example around lines 4129, 4141 and 4198 on current main). Could StampKeepingNewerResults do the same for each candidate unit before the UnchangedSince filter? A write landing between that collect and MarkWritten's own collect would still be absorbed. If the stamp can report whether its fresh collect found writes in a unit's range, skipping the unit in that case would close that window too.

A second case in DirectWriteCompletion.cpp would cover it: the CPU writes the surface between the submission and its completion, and the test expects the image's results to be dropped and the CPU bytes kept.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6286823425 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6286823425). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T08:30:01Z. --- Thanks, the double-stamp analysis matches the code, and the new test pins the drop. One case the keep list misses: CPU writes that have not been collected yet. `GuestMemory::UnchangedSince` only reads the block stamps. `GuestMemory::MarkWritten` first collects the range's fresh CPU writes (`GuestWriteWatchCollectFresh` on Linux, `collectWindowsWrites` with `StampKind::Fresh` on Windows), then stamps every block with the generation it returns. So if the guest CPU wrote over a pending unit after the unit's generation, and nothing collected that write before the completion, the unit passes the `UnchangedSince` filter. The write is absorbed into the completion stamp, and moving the unit to that generation hides it. The next `Refresh` keeps the GPU results, and storing them writes older texels over the CPU's bytes. On `main` the completion stamp drops the results, and the re-upload keeps the CPU write. The other decisions about pending results in `Texture.cpp` collect the range first with `GuestMemory::CollectWritesUncached` (for example around lines 4129, 4141 and 4198 on current `main`). Could `StampKeepingNewerResults` do the same for each candidate unit before the `UnchangedSince` filter? A write landing between that collect and `MarkWritten`'s own collect would still be absorbed. If the stamp can report whether its fresh collect found writes in a unit's range, skipping the unit in that case would close that window too. A second case in `DirectWriteCompletion.cpp` would cover it: the CPU writes the surface between the submission and its completion, and the test expects the image's results to be dropped and the CPU bytes kept.
Longziip commented 2026-10-20 16:34:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Longziip on 2026-10-20T16:34:52Z.


Thanks, agreed on the uncollected writes. Rebased onto current main and pushed:

  • StampKeepingNewerResults now runs GuestMemory::CollectWritesUncached over each candidate unit before the UnchangedSince filter, like the other pending-result decisions in Texture.cpp.
  • The test failed on current main regardless of this change: its 17th surface fell outside the 4 MiB host import block that the first run settles, so it was imported alone below settleFloorBytes with staysWatched false. MarkDirectWrites then got 0 from MarkWritten, the keep path was skipped, and the Rewatch stamp dropped the results (which is correct for unwatched memory). The test now uses as many surfaces as fit in one settled import block (15 runs).

Second case: I tried a CPU write after AgcDriverWaitIdle and one behind a CPU-released WAIT_REG_MEM placed after the store. Both pass even without the collect, because the write is ordered or collected before the completion's stamp, so neither exercises the window. A deterministic test would need a hook that runs between the record and the completion's MarkWritten. Would a test-only hook in GuestBufferMemory::WriteBack be acceptable here, or would you rather keep that out of the driver?

The window between this collect and MarkWritten's own collect is still open. Closing it needs MarkWritten to report which units its fresh collect found writes in. I can do that in a follow-up if you prefer to keep this one small.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6295941115 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6295941115). Originally posted by [Longziip](https://github.com/Longziip) on 2026-10-20T16:34:52Z. --- Thanks, agreed on the uncollected writes. Rebased onto current `main` and pushed: - `StampKeepingNewerResults` now runs `GuestMemory::CollectWritesUncached` over each candidate unit before the `UnchangedSince` filter, like the other pending-result decisions in `Texture.cpp`. - The test failed on current `main` regardless of this change: its 17th surface fell outside the 4 MiB host import block that the first run settles, so it was imported alone below `settleFloorBytes` with `staysWatched` false. `MarkDirectWrites` then got 0 from `MarkWritten`, the keep path was skipped, and the `Rewatch` stamp dropped the results (which is correct for unwatched memory). The test now uses as many surfaces as fit in one settled import block (15 runs). Second case: I tried a CPU write after `AgcDriverWaitIdle` and one behind a CPU-released `WAIT_REG_MEM` placed after the store. Both pass even without the collect, because the write is ordered or collected before the completion's stamp, so neither exercises the window. A deterministic test would need a hook that runs between the record and the completion's `MarkWritten`. Would a test-only hook in `GuestBufferMemory::WriteBack` be acceptable here, or would you rather keep that out of the driver? The window between this collect and `MarkWritten`'s own collect is still open. Closing it needs `MarkWritten` to report which units its fresh collect found writes in. I can do that in a follow-up if you prefer to keep this one small.
oneandonlydean commented 2026-10-20 16:42:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T16:42:32Z.


Thanks, the collect before UnchangedSince fixes what I raised, and the rebased first commit is unchanged. One thing is still open from my earlier comment: a test where the CPU writes the surface between submission and completion and the pending results are expected to be dropped. Without it, removing the new CollectWritesUncached line still passes the suite.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6296091826 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6296091826). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T16:42:32Z. --- Thanks, the collect before `UnchangedSince` fixes what I raised, and the rebased first commit is unchanged. One thing is still open from my earlier comment: a test where the CPU writes the surface between submission and completion and the pending results are expected to be dropped. Without it, removing the new `CollectWritesUncached` line still passes the suite.
Longziip commented 2026-10-20 16:54:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Longziip on 2026-10-20T16:54:31Z.


Added the case to DirectWriteCompletion.cpp: the submission ends with a WAIT_REG_MEM on a CPU-released label, and the test writes the surface under GpuMutex once the image is pending, then releases the label, so the CPU write lands after the record and before the completion's stamp (checked with a temporary trace of the stamp). All 15 runs drop the results and keep the CPU bytes.

It also passes without the new CollectWritesUncached line, and I traced why. MarkWritten collects with StampKind::Fresh, and on Windows WindowsMappings::collectResident reports only pages that were never collected since they were committed (report = fresh for Collection::Fresh); it does not read or reset the write watch of pages already collected. A pending unit's pages were collected when the image was recorded, so a later CPU write over them is not taken by the completion's MarkWritten: the unit is kept by the stamp (4 of 4 units in the trace), but the write-watch bit stays set and the next Refresh collects it and drops the results. The Linux and macOS paths split fresh and armed collects the same way; I could only run Windows.

So the absorbed-write case needs pages inside a pending unit that were never collected, which the record does not leave. I kept the collect (it makes the keep decision not depend on that) and the new case (it pins that a CPU write before the completion wins). If you know a path that leaves fresh pages in a pending unit, I'll turn it into the failing case.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6296330454 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6296330454). Originally posted by [Longziip](https://github.com/Longziip) on 2026-10-20T16:54:31Z. --- Added the case to `DirectWriteCompletion.cpp`: the submission ends with a `WAIT_REG_MEM` on a CPU-released label, and the test writes the surface under `GpuMutex` once the image is pending, then releases the label, so the CPU write lands after the record and before the completion's stamp (checked with a temporary trace of the stamp). All 15 runs drop the results and keep the CPU bytes. It also passes without the new `CollectWritesUncached` line, and I traced why. `MarkWritten` collects with `StampKind::Fresh`, and on Windows `WindowsMappings::collectResident` reports only pages that were never collected since they were committed (`report = fresh` for `Collection::Fresh`); it does not read or reset the write watch of pages already collected. A pending unit's pages were collected when the image was recorded, so a later CPU write over them is not taken by the completion's `MarkWritten`: the unit is kept by the stamp (4 of 4 units in the trace), but the write-watch bit stays set and the next `Refresh` collects it and drops the results. The Linux and macOS paths split fresh and armed collects the same way; I could only run Windows. So the absorbed-write case needs pages inside a pending unit that were never collected, which the record does not leave. I kept the collect (it makes the keep decision not depend on that) and the new case (it pins that a CPU write before the completion wins). If you know a path that leaves fresh pages in a pending unit, I'll turn it into the failing case.
oneandonlydean commented 2026-10-20 17:45:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T17:45:22Z.


Thanks for the test. A correction to my earlier comment about uncollected CPU writes: I instrumented it, and on this path the case doesn't produce wrong output, even without the CollectWritesUncached line.

With that line reverted, your new CPU-write case still passes 15/15. The completion's filter does keep the units (the write isn't collected yet), but the next Refresh sees the CPU write through the tracker's CPU-kind block stamps, logs "guest memory changed while GPU results were pending; keeping the CPU's blocks", and drops the image. The write survives either way. So the extra collect is harmless defence rather than a required fix; keeping it or dropping it are both fine with me. No further changes needed from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6297323472 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6297323472). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T17:45:22Z. --- Thanks for the test. A correction to my earlier comment about uncollected CPU writes: I instrumented it, and on this path the case doesn't produce wrong output, even without the `CollectWritesUncached` line. With that line reverted, your new CPU-write case still passes 15/15. The completion's filter does keep the units (the write isn't collected yet), but the next `Refresh` sees the CPU write through the tracker's CPU-kind block stamps, logs "guest memory changed while GPU results were pending; keeping the CPU's blocks", and drops the image. The write survives either way. So the extra collect is harmless defence rather than a required fix; keeping it or dropping it are both fine with me. No further changes needed from my side.
simonbbby commented 2026-10-20 18:26:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-20T18:26:05Z.


Linux control at 021d6d98d658e13cd0ecdbadc791a2495a865ea4, using the unchanged agc_driver_direct_write_completion_tests fixture. Ubuntu 24.04, GCC 13.3 Release, shader cache disabled and ANYPS5_REQUIRE_VULKAN=1:

ICD / GPU PR head Only GuestBufferMemory.cpp restored from base 77e31219c PR restored
NVIDIA RTX 3090, 595.99.02 1/1 pass 3/3 fail: all 15 newer image results dropped 3/3 pass
RADV gfx1036, Mesa 25.2.8 1/1 pass 3/3 pass 3/3 pass
lavapipe LLVM 20.1.2, Mesa 25.2.8 1/1 pass 3/3 pass 3/3 pass

Each process was fresh; parent and restored columns each contain three runs per ICD.

On every restored run, the first case keeps all 15 newer image results. The second case keeps zero images over the CPU write and loses zero CPU writes, across all three ICDs. NVIDIA's parent control stops at the completion of a buffer write dropped image results recorded after it; restoring the PR removes that failure. RADV/lavapipe passing the parent control means they do not discriminate the original double-stamp bug here.

This adds Linux/NVIDIA reproduction and RADV/lavapipe compatibility coverage. I did not remove the extra CollectWritesUncached call: the latest maintainer comment already resolves that point. No retail title was run, and no Khronos validation layer is installed here. Source restored to the exact PR head, clean working tree.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298113828 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6298113828). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-20T18:26:05Z. --- Linux control at `021d6d98d658e13cd0ecdbadc791a2495a865ea4`, using the unchanged `agc_driver_direct_write_completion_tests` fixture. Ubuntu 24.04, GCC 13.3 Release, shader cache disabled and `ANYPS5_REQUIRE_VULKAN=1`: | ICD / GPU | PR head | Only `GuestBufferMemory.cpp` restored from base `77e31219c` | PR restored | |---|---|---|---| | NVIDIA RTX 3090, 595.99.02 | 1/1 pass | **3/3 fail**: all 15 newer image results dropped | 3/3 pass | | RADV gfx1036, Mesa 25.2.8 | 1/1 pass | 3/3 pass | 3/3 pass | | lavapipe LLVM 20.1.2, Mesa 25.2.8 | 1/1 pass | 3/3 pass | 3/3 pass | Each process was fresh; parent and restored columns each contain three runs per ICD. On every restored run, the first case keeps all 15 newer image results. The second case keeps zero images over the CPU write and loses zero CPU writes, across all three ICDs. NVIDIA's parent control stops at `the completion of a buffer write dropped image results recorded after it`; restoring the PR removes that failure. RADV/lavapipe passing the parent control means they do **not** discriminate the original double-stamp bug here. This adds Linux/NVIDIA reproduction and RADV/lavapipe compatibility coverage. I did not remove the extra `CollectWritesUncached` call: the latest maintainer comment already resolves that point. No retail title was run, and no Khronos validation layer is installed here. Source restored to the exact PR head, clean working tree.
MarcZX10 commented 2026-10-20 22:14:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:14:24Z.


The overlap bot flags #7233 here, and I checked the current hunks: #7233 changes the three MarkWritten calls in MarkDirectWrites/WriteBack to MarkPossiblyWritten; this PR captures the generation from MarkWritten in MarkDirectWrites and wraps the two WriteBack stamps. These changes appear composable, but whichever branch lands second should preserve both the possible-write classification and the generation needed by StampKeepingNewerResults. #7233 is currently mergeable and has already been rebased onto current main. Could you coordinate the order with Marc before merging/rebasing so the combined hunk keeps both behaviors? I have not run this PR locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6302970891 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6302970891). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T22:14:24Z. --- The overlap bot flags #7233 here, and I checked the current hunks: #7233 changes the three `MarkWritten` calls in `MarkDirectWrites`/`WriteBack` to `MarkPossiblyWritten`; this PR captures the generation from `MarkWritten` in `MarkDirectWrites` and wraps the two `WriteBack` stamps. These changes appear composable, but whichever branch lands second should preserve both the possible-write classification and the generation needed by `StampKeepingNewerResults`. #7233 is currently mergeable and has already been rebased onto current main. Could you coordinate the order with Marc before merging/rebasing so the combined hunk keeps both behaviors? I have not run this PR locally.
Longziip commented 2026-10-20 22:47:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Longziip on 2026-10-20T22:47:59Z.


Thanks both, and thanks @simonbbby for the Linux/NVIDIA reproduction.

Order with #7233: whichever lands second rebases, and the combined hunk is mechanical. I merged pr7233 into this branch locally: the only conflict is the three MarkWritten calls in GuestBufferMemory.cpp. MarkPossiblyWritten returns the generation of the same markWritten helper, so the resolution keeps both behaviors:

  • MarkDirectWrites: const auto generation = GuestMemory::MarkPossiblyWritten(...); if (generation != 0) directWritesGeneration = std::max(directWritesGeneration, generation);
  • both WriteBack stamps: StampKeepingNewerResults(begin, size, directWritesGeneration, [&] { return GuestMemory::MarkPossiblyWritten(begin, size); })

agc_driver_direct_write_completion passes on that combined tree here (15 of 15 kept, 0 of 15 kept over the CPU write). If #7233 merges first I will rebase this onto it with that resolution; if this one merges first, #7233 only needs the same one-line change per call. I have not pushed the combined tree.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6303501962 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8126#issuecomment-6303501962). Originally posted by [Longziip](https://github.com/Longziip) on 2026-10-20T22:47:59Z. --- Thanks both, and thanks @simonbbby for the Linux/NVIDIA reproduction. Order with #7233: whichever lands second rebases, and the combined hunk is mechanical. I merged `pr7233` into this branch locally: the only conflict is the three `MarkWritten` calls in `GuestBufferMemory.cpp`. `MarkPossiblyWritten` returns the generation of the same `markWritten` helper, so the resolution keeps both behaviors: - `MarkDirectWrites`: `const auto generation = GuestMemory::MarkPossiblyWritten(...); if (generation != 0) directWritesGeneration = std::max(directWritesGeneration, generation);` - both `WriteBack` stamps: `StampKeepingNewerResults(begin, size, directWritesGeneration, [&] { return GuestMemory::MarkPossiblyWritten(begin, size); })` `agc_driver_direct_write_completion` passes on that combined tree here (15 of 15 kept, 0 of 15 kept over the CPU write). If #7233 merges first I will rebase this onto it with that resolution; if this one merges first, #7233 only needs the same one-line change per call. I have not pushed the combined tree.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8126
No description provided.