fix(agc): retire a multisampled color target the title wrote over #8223

Merged
savvaniss merged 10 commits from upstream-pr/8223 into main 2026-10-30 12:16:03 +00:00
savvaniss commented 2026-10-20 04:27:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-20T04:27:41Z.


What

A multisampled color target keeps its samples on the host. Its guest memory stays guarded until an unmap or an allocation removal covers it: any access of that memory throws "overlaps multisampled color target … guest access to it is not implemented". A title with its own memory pool never unmaps. It reuses the memory of a render target it no longer needs, and the next access of the new data throws, although the target is dead. This PR takes two kinds of reuse as evidence that a target is dead:

  • The CPU wrote over it. Each target keeps a write-tracker generation, taken with CollectWrites over its color memory each time it is used. When a guarded access overlaps a target in write-watched memory, and the CPU wrote the overlapped bytes since that generation (UnchangedSinceCollected), the title has put other data there.
  • Another target was bound over it. In PPSA03208 the title reuses the memory through the GPU (trace). A 2-sample color target is drawn once. Later, a native 2-sample D32S8 depth target whose stencil plane sits at the same address is bound, and the stencil plane's import reads inside the color guard. Each bind over guarded memory now marks the targets it overlaps as claimed. That covers a depth target's depth plane, stencil plane and HTILE (at the top of DepthSurfaceView, before any import), a single-sample color target (where Draw already retires the depth surfaces it overlaps), and a draw of a multisampled color target with another address, extent, sample count or format. A draw through the target's sRGB twin format is served by the same target, so it is a draw of that target, not a claim.

A target's use clears its own mark and takes a new write generation. A use is a draw, and, as #9186 already holds a target host-only there, a dispatch's storage view of it or a color fill it absorbs. A target used again after the claim keeps its guard.

Since #9186, a guarded access also retires a target whose samples are not only on the host, that is a texture sampled before any draw, until a draw, a storage write or an absorbed fill. The three conditions sit together in RequireNoMultisampleColorTarget, in #9186's order: when every guarded range that an access overlaps can retire, they are all retired the way an unmap retires them, and the access goes on; when any of them cannot, the access refuses and nothing is retired. A later draw to the same address creates and guards a new target. A target is only retired at an access that main refuses with an exception, so nothing that runs on main behaves differently.

Each target keeps this state in one TargetUse (hostOnly, writes, claimed), and every guarded range of the target points to it, the DCC, CMASK and 8-sample FMASK ranges included. The one-fragment FMASK range of GuardOneFragmentFmask keeps its fmask flag and gets a TargetUse of its own, but claims skip it, so it refuses every guest access as on main. guard() returns void as on main; the color footprint it computes is guardedColorBytes(), which the use stamp also calls.

The debt entry for multisampled color targets records the rule and its gap: a target that is only sampled after another target was bound over it loses its samples. #6987, #6989 and #6995 work toward reading live samples from guest memory, which this does not do. Amoenus's adaptation of this branch onto main 5a2744c55e (25907aa1fb) was the reference for the one-fragment FMASK check in the test.

Tested

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, AMD Radeon RX 9070 XT, on main b7488e1ff5 (merged into this branch on 30 Oct).

  • agc_driver_sample_multisample_target runs CheckOverwrittenTarget and CheckClaimedTargets after main's sampling test. The first is the CPU-write case: a write over a drawn 4x target in watched memory retires it at the next guarded read, and a later draw guards the new target. The second has the bind cases, in plain (unwatched) memory:
    1. It draws a 2x target, checks that a read of it is refused, and binds a 2x D32S8 target whose stencil plane is the color memory. A read of 0x1000 bytes of that memory must pass.
    2. Control: the same, but the color target is drawn again after the depth bind. The read must still be refused.
    3. It draws a 2x target and then a single-sample color target over the same memory. A read of that memory must pass.
    4. It draws a 128x64 2x target over two 64 KiB blocks, then a 16x16 4x target over the first block. A read of the second block must pass, and a read of the first block is still refused by the 4x target.
    5. Control: a dispatch stores to the 2x target after the stencil bind. The read must still be refused.
    6. A stencil plane bound over a one-fragment target's FMASK guard leaves it refusing.
  • With one part of the change removed at a time, each case fails at its own check, 7 of 7 (on the 25 Oct head; the later merges change no logic of this PR):
    • without the depth claims, case 1: "a 2x target that a D32S8 target's stencil plane was bound over after its last draw is still guarded";
    • when a use keeps its own mark, case 2: "a 2x target drawn again after a D32S8 target's stencil plane was bound over it is not guarded";
    • without the single-sample claim, case 3: the single-sample draw itself is refused ("a CPU read of …+0x10000 overlaps multisampled color target …+0x10000 (2 samples)");
    • without the claim from a multisampled draw, case 4: "a 2x target that a 4x target was drawn over is still guarded";
    • when holdHostOnly stamps no use, case 5: "a 2x target that a dispatch stored to after a D32S8 target's stencil plane was bound over it is not guarded";
    • when claims also mark the one-fragment FMASK range, case 6: "a stencil plane bound over a one-fragment target's FMASK retired its guard";
    • without the CPU-write evidence, CheckOverwrittenTarget: "a read of target memory the title wrote over … overlaps multisampled color target".
  • agc_driver_sample_multisample_target on main's production code stops 3 of 3 at the CPU-write case ("a read of target memory the title wrote over … overlaps multisampled color target").
  • Validation layer on main and on this head, on the same machine, with ANYPS5_GPU=AMD, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, 31 tests: agc_driver_sample_multisample_target, agc_driver_native_msaa_vertex_input, agc_driver_native_fmask, agc_multisample_guest_access (with main's one-fragment FMASK guard tests), agc_driver_msaa_dcc_state, agc_driver_msaa_dcc_clear_2, _4 and _8, agc_driver, agc_driver_cached_image_multisample_guard, agc_driver_multisample_fill_host_only, agc_driver_multisample_retirement, agc_driver_multisampled_pass_order, agc_driver_multisample_readback and its eight cases, agc_driver_multisample_srgb_twin, agc_driver_multisample_centered_lines, agc_driver_msaa_layout, agc_driver_depth_copy_draw, and the native depth tests agc_driver_native_multisample_depth, agc_driver_native_depth_retirement, _clears, _clear_refusals and agc_driver_native_depth_bda_clear. On this head, on main b7488e1ff5, all 31 pass, and agc_driver_sample_multisample_target passes 3 of 3. On main 07da04f947 (25 Oct, not rerun for the latest merge), all 31 pass, and its agc_driver_sample_multisample_target (without this PR's cases) passes 3 of 3. Neither log has a VUID- line or was not found but was requested by env var VK_INSTANCE_LAYERS, and every Selected GPU and Vulkan device: line names the RX 9070 XT. main's new agc_driver_packed_unorm4444_multisample_partial_write does not build in this tree on either side: its object's dependency file path passes Windows' 260-character limit.
  • Merging main cecb540a63 (21 Oct): the only conflict was the depthWritten parameter that main added to DepthSurfaceView. main had moved the guard loop into RequireNoMultisampleColorTarget, and the retirement moved with it.
  • Merging main 1da03c6f34 (22 Oct, after #7948): #7948's FMASK guarded() range takes the target's use, like the DCC and CMASK ranges. In the test's Block, both sides had added the same watched parameter, and main's version is kept.
  • Merging main 07da04f947 (25 Oct, after #9186 and the one-fragment FMASK guard): conflicts in MultisampleTarget.hpp, Draw.cpp, MultisampleTarget.cpp, the test and the debt file, resolved as described above. In Draw.cpp and the header, the claim comes before GuardOneFragmentFmask.
  • Merging main b7488e1ff5 (30 Oct, after #6498 and #12566): the debt doc keeps this PR's entry and #6498's shader buffer entry, and the test file keeps both sides' test blocks. HostOnlySampleRanges from #12566 reads range.use->hostOnly (found by hugodearaujo).
  • Not run here: PPSA03208. On main, a native multisample stencil plane is not imported, so the test reads the overlapped bytes through RequireNoMultisampleTarget instead of through that import. The claim happens before the import.
  • hugodearaujo ran Assassin's Creed Mirage (PPSA13960) on Linux with an RX 9070 XT, RADV: on main bb04a4f1ea it aborts at 86 s on a CPU read over a 4x target, and with this PR that stop is gone (comment). It then aborts at 79 s on a cached image access over another 4x target. Their trace shows that access is a dispatch's store-only clear over part of the target, a GPU write that is neither a CPU write nor a bind, so it still refuses and is a follow-up.
  • JJenkx ran a private integration of the 25 Oct head on Linux (RX 6650 XT, RADV): the same 19 focused checks pass with and without the PR under the validation layer (comment). In Bendy (PPSA27624), one run got past a CPU read over an 8-sample target and an identical repeat stopped at the same read, so this PR is not a fix for that stop.
  • First revision, not rerun for this one: Boggle (CUSA03312), on #6977's branch with local support for PS4 multisampled color targets, read a texture that the title had uploaded into the memory of a 4x render target it no longer used. The target was retired there and once more at a storage image access, and the game went on to its menus and a round. The Intel UHD 770 runs and simonbbby's native Linux control (RTX 3090, RADV gfx1036, lavapipe: the PR passes 3 of 3, main's MultisampleTarget.cpp fails 3 of 3, comment) also covered the CPU-write case only.
  • tools/check_conventions.py --base origin/main passes, and tools/pr_overlap.py finds no shared exports.

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: CUSA03312 #7198; PPSA03208 at its stop at 1.349 s is expected, not run here
  • GPUs tested: AMD Radeon RX 9070 XT (driver 32.0.31041.1004), Windows 11 Pro 26300; the first revision also on Intel UHD Graphics 770 (driver 32.0.101.7088)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4931006770 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8223). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-20T04:27:41Z. --- ### What A multisampled color target keeps its samples on the host. Its guest memory stays guarded until an unmap or an allocation removal covers it: any access of that memory throws "overlaps multisampled color target … guest access to it is not implemented". A title with its own memory pool never unmaps. It reuses the memory of a render target it no longer needs, and the next access of the new data throws, although the target is dead. This PR takes two kinds of reuse as evidence that a target is dead: - **The CPU wrote over it.** Each target keeps a write-tracker generation, taken with `CollectWrites` over its color memory each time it is used. When a guarded access overlaps a target in write-watched memory, and the CPU wrote the overlapped bytes since that generation (`UnchangedSinceCollected`), the title has put other data there. - **Another target was bound over it.** In PPSA03208 the title reuses the memory through the GPU ([trace](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6318549732)). A 2-sample color target is drawn once. Later, a native 2-sample D32S8 depth target whose stencil plane sits at the same address is bound, and the stencil plane's import reads inside the color guard. Each bind over guarded memory now marks the targets it overlaps as claimed. That covers a depth target's depth plane, stencil plane and HTILE (at the top of `DepthSurfaceView`, before any import), a single-sample color target (where `Draw` already retires the depth surfaces it overlaps), and a draw of a multisampled color target with another address, extent, sample count or format. A draw through the target's sRGB twin format is served by the same target, so it is a draw of that target, not a claim. A target's use clears its own mark and takes a new write generation. A use is a draw, and, as #9186 already holds a target host-only there, a dispatch's storage view of it or a color fill it absorbs. A target used again after the claim keeps its guard. Since #9186, a guarded access also retires a target whose samples are not only on the host, that is a texture sampled before any draw, until a draw, a storage write or an absorbed fill. The three conditions sit together in `RequireNoMultisampleColorTarget`, in #9186's order: when every guarded range that an access overlaps can retire, they are all retired the way an unmap retires them, and the access goes on; when any of them cannot, the access refuses and nothing is retired. A later draw to the same address creates and guards a new target. A target is only retired at an access that `main` refuses with an exception, so nothing that runs on `main` behaves differently. Each target keeps this state in one `TargetUse` (`hostOnly`, `writes`, `claimed`), and every guarded range of the target points to it, the DCC, CMASK and 8-sample FMASK ranges included. The one-fragment FMASK range of `GuardOneFragmentFmask` keeps its `fmask` flag and gets a `TargetUse` of its own, but claims skip it, so it refuses every guest access as on `main`. `guard()` returns void as on `main`; the color footprint it computes is `guardedColorBytes()`, which the use stamp also calls. The debt entry for multisampled color targets records the rule and its gap: a target that is only sampled after another target was bound over it loses its samples. #6987, #6989 and #6995 work toward reading live samples from guest memory, which this does not do. Amoenus's adaptation of this branch onto `main` 5a2744c55e ([25907aa1fb](https://github.com/Amoenus/AnyPS5/commit/25907aa1fbc6c5364d67636b1841304a2a23e4e4)) was the reference for the one-fragment FMASK check in the test. ### Tested Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, AMD Radeon RX 9070 XT, on `main` b7488e1ff5 (merged into this branch on 30 Oct). - `agc_driver_sample_multisample_target` runs `CheckOverwrittenTarget` and `CheckClaimedTargets` after `main`'s sampling test. The first is the CPU-write case: a write over a drawn 4x target in watched memory retires it at the next guarded read, and a later draw guards the new target. The second has the bind cases, in plain (unwatched) memory: 1. It draws a 2x target, checks that a read of it is refused, and binds a 2x D32S8 target whose stencil plane is the color memory. A read of 0x1000 bytes of that memory must pass. 2. Control: the same, but the color target is drawn again after the depth bind. The read must still be refused. 3. It draws a 2x target and then a single-sample color target over the same memory. A read of that memory must pass. 4. It draws a 128x64 2x target over two 64 KiB blocks, then a 16x16 4x target over the first block. A read of the second block must pass, and a read of the first block is still refused by the 4x target. 5. Control: a dispatch stores to the 2x target after the stencil bind. The read must still be refused. 6. A stencil plane bound over a one-fragment target's FMASK guard leaves it refusing. - With one part of the change removed at a time, each case fails at its own check, 7 of 7 (on the 25 Oct head; the later merges change no logic of this PR): - without the depth claims, case 1: "a 2x target that a D32S8 target's stencil plane was bound over after its last draw is still guarded"; - when a use keeps its own mark, case 2: "a 2x target drawn again after a D32S8 target's stencil plane was bound over it is not guarded"; - without the single-sample claim, case 3: the single-sample draw itself is refused ("a CPU read of …+0x10000 overlaps multisampled color target …+0x10000 (2 samples)"); - without the claim from a multisampled draw, case 4: "a 2x target that a 4x target was drawn over is still guarded"; - when `holdHostOnly` stamps no use, case 5: "a 2x target that a dispatch stored to after a D32S8 target's stencil plane was bound over it is not guarded"; - when claims also mark the one-fragment FMASK range, case 6: "a stencil plane bound over a one-fragment target's FMASK retired its guard"; - without the CPU-write evidence, `CheckOverwrittenTarget`: "a read of target memory the title wrote over … overlaps multisampled color target". - `agc_driver_sample_multisample_target` on `main`'s production code stops 3 of 3 at the CPU-write case ("a read of target memory the title wrote over … overlaps multisampled color target"). - Validation layer on `main` and on this head, on the same machine, with `ANYPS5_GPU=AMD`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, 31 tests: `agc_driver_sample_multisample_target`, `agc_driver_native_msaa_vertex_input`, `agc_driver_native_fmask`, `agc_multisample_guest_access` (with `main`'s one-fragment FMASK guard tests), `agc_driver_msaa_dcc_state`, `agc_driver_msaa_dcc_clear_2`, `_4` and `_8`, `agc_driver`, `agc_driver_cached_image_multisample_guard`, `agc_driver_multisample_fill_host_only`, `agc_driver_multisample_retirement`, `agc_driver_multisampled_pass_order`, `agc_driver_multisample_readback` and its eight cases, `agc_driver_multisample_srgb_twin`, `agc_driver_multisample_centered_lines`, `agc_driver_msaa_layout`, `agc_driver_depth_copy_draw`, and the native depth tests `agc_driver_native_multisample_depth`, `agc_driver_native_depth_retirement`, `_clears`, `_clear_refusals` and `agc_driver_native_depth_bda_clear`. On this head, on `main` b7488e1ff5, all 31 pass, and `agc_driver_sample_multisample_target` passes 3 of 3. On `main` 07da04f947 (25 Oct, not rerun for the latest merge), all 31 pass, and its `agc_driver_sample_multisample_target` (without this PR's cases) passes 3 of 3. Neither log has a `VUID-` line or `was not found but was requested by env var VK_INSTANCE_LAYERS`, and every `Selected GPU` and `Vulkan device:` line names the RX 9070 XT. `main`'s new `agc_driver_packed_unorm4444_multisample_partial_write` does not build in this tree on either side: its object's dependency file path passes Windows' 260-character limit. - Merging `main` cecb540a63 (21 Oct): the only conflict was the `depthWritten` parameter that `main` added to `DepthSurfaceView`. `main` had moved the guard loop into `RequireNoMultisampleColorTarget`, and the retirement moved with it. - Merging `main` 1da03c6f34 (22 Oct, after #7948): #7948's FMASK `guarded()` range takes the target's `use`, like the DCC and CMASK ranges. In the test's `Block`, both sides had added the same `watched` parameter, and `main`'s version is kept. - Merging `main` 07da04f947 (25 Oct, after #9186 and the one-fragment FMASK guard): conflicts in `MultisampleTarget.hpp`, `Draw.cpp`, `MultisampleTarget.cpp`, the test and the debt file, resolved as described above. In `Draw.cpp` and the header, the claim comes before `GuardOneFragmentFmask`. - Merging `main` b7488e1ff5 (30 Oct, after #6498 and #12566): the debt doc keeps this PR's entry and #6498's shader buffer entry, and the test file keeps both sides' test blocks. `HostOnlySampleRanges` from #12566 reads `range.use->hostOnly` (found by hugodearaujo). - Not run here: PPSA03208. On `main`, a native multisample stencil plane is not imported, so the test reads the overlapped bytes through `RequireNoMultisampleTarget` instead of through that import. The claim happens before the import. - hugodearaujo ran Assassin's Creed Mirage (PPSA13960) on Linux with an RX 9070 XT, RADV: on `main` bb04a4f1ea it aborts at 86 s on a CPU read over a 4x target, and with this PR that stop is gone ([comment](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6512443055)). It then aborts at 79 s on a cached image access over another 4x target. Their [trace](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6423007150) shows that access is a dispatch's store-only clear over part of the target, a GPU write that is neither a CPU write nor a bind, so it still refuses and is a follow-up. - JJenkx ran a private integration of the 25 Oct head on Linux (RX 6650 XT, RADV): the same 19 focused checks pass with and without the PR under the validation layer ([comment](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6439324290)). In Bendy (PPSA27624), one run got past a CPU read over an 8-sample target and an identical repeat stopped at the same read, so this PR is not a fix for that stop. - First revision, not rerun for this one: Boggle (CUSA03312), on #6977's branch with local support for PS4 multisampled color targets, read a texture that the title had uploaded into the memory of a 4x render target it no longer used. The target was retired there and once more at a storage image access, and the game went on to its menus and a round. The Intel UHD 770 runs and simonbbby's native Linux control (RTX 3090, RADV gfx1036, lavapipe: the PR passes 3 of 3, `main`'s `MultisampleTarget.cpp` fails 3 of 3, [comment](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6284843434)) also covered the CPU-write case only. - `tools/check_conventions.py --base origin/main` passes, and `tools/pr_overlap.py` finds no shared exports. ### 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: CUSA03312 #7198; PPSA03208 at its stop at 1.349 s is expected, not run here - [x] GPUs tested: AMD Radeon RX 9070 XT (driver 32.0.31041.1004), Windows 11 Pro 26300; the first revision also on Intel UHD Graphics 770 (driver 32.0.101.7088) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
simonbbby commented 2026-10-20 06:26:13 +00:00 (Migrated from github.com)

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


Native Linux write-watch control for exact head eb9807f341a11320a50d8d188ab7ff902598c089, parent c9c7e6cfaf602d3d9a83b13251e14a810831fce9. I rebuilt the execution fixture and runtime dependencies, then ran the complete agc_driver_sample_multisample_target_tests in three fresh processes per restricted ICD.

Production code, with this PR's fixture throughout RTX 3090 RADV gfx1036 lavapipe
Exact PR 3/3 pass 3/3 pass 3/3 pass
Only MultisampleTarget.cpp restored to the exact parent 3/3 fail 3/3 fail 3/3 fail
Exact PR restored and rebuilt 3/3 pass 3/3 pass 3/3 pass

All nine parent controls stop at a read of target memory the title wrote over ... overlaps multisampled color target ... whose samples are only on the host. All 18 PR processes execute the new watched-memory case, including the refusal before the CPU overwrite, access after the middle 256-byte overwrite, access to the remaining prefix after retirement, and the refusal after drawing the target again. None prints overwritten target retirement not tested, skips, or times out. Thus this is a Linux before/after result for the new behavior, not a green run that bypasses write watching.

After restoration, the seven registered tests matching agc_multisample_guest_access, agc_driver_native_msaa_vertex_input, agc_driver_msaa_dcc_state, agc_driver_msaa_dcc_clear_[248], and agc_driver_sample_multisample_target pass 7/7 on NVIDIA and 7/7 on RADV. Lavapipe passes five and skips the 2x/8x DCC cases with the device lacks the requested multisample color attachments; no failures. The source tree is clean. Raw logs and JUnit results are retained.

Ubuntu 24.04, kernel 7.0.0-38, Ryzen 9950X, GCC 13.3, Release; NVIDIA 595.99.02, gfx1036 1002:13c0 / Mesa 25.2.8, lavapipe LLVM 20.1.2. Actual devices verified from loader output, required Vulkan, shader cache and pipeline journal disabled, other AnyPS5/Vulkan overrides removed. No Khronos validation layer is installed. Boggle, Windows, performance and the full suite were not tested here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6284843434 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6284843434). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-20T06:26:13Z. --- Native Linux write-watch control for exact head `eb9807f341a11320a50d8d188ab7ff902598c089`, parent `c9c7e6cfaf602d3d9a83b13251e14a810831fce9`. I rebuilt the execution fixture and runtime dependencies, then ran the complete `agc_driver_sample_multisample_target_tests` in three fresh processes per restricted ICD. | Production code, with this PR's fixture throughout | RTX 3090 | RADV gfx1036 | lavapipe | |---|---|---|---| | Exact PR | 3/3 pass | 3/3 pass | 3/3 pass | | Only `MultisampleTarget.cpp` restored to the exact parent | 3/3 fail | 3/3 fail | 3/3 fail | | Exact PR restored and rebuilt | 3/3 pass | 3/3 pass | 3/3 pass | All nine parent controls stop at `a read of target memory the title wrote over ... overlaps multisampled color target ... whose samples are only on the host`. All 18 PR processes execute the new watched-memory case, including the refusal before the CPU overwrite, access after the middle 256-byte overwrite, access to the remaining prefix after retirement, and the refusal after drawing the target again. None prints `overwritten target retirement not tested`, skips, or times out. Thus this is a Linux before/after result for the new behavior, not a green run that bypasses write watching. After restoration, the seven registered tests matching `agc_multisample_guest_access`, `agc_driver_native_msaa_vertex_input`, `agc_driver_msaa_dcc_state`, `agc_driver_msaa_dcc_clear_[248]`, and `agc_driver_sample_multisample_target` pass **7/7 on NVIDIA and 7/7 on RADV**. Lavapipe passes five and skips the 2x/8x DCC cases with `the device lacks the requested multisample color attachments`; no failures. The source tree is clean. Raw logs and JUnit results are retained. Ubuntu 24.04, kernel 7.0.0-38, Ryzen 9950X, GCC 13.3, Release; NVIDIA 595.99.02, gfx1036 `1002:13c0` / Mesa 25.2.8, lavapipe LLVM 20.1.2. Actual devices verified from loader output, required Vulkan, shader cache and pipeline journal disabled, other AnyPS5/Vulkan overrides removed. No Khronos validation layer is installed. Boggle, Windows, performance and the full suite were not tested here.
savvaniss commented 2026-10-20 12:31:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-20T12:31:06Z.


Rebased onto main 56b299c3a; the head is now 79b42bd76. The only textual conflict was the debt line next to the stencil entry. The rebase also needed one code change: #7641 added a guard() call where a target is recreated with another pipe-bank XOR. That call now also records the recreated target's color bytes and use stamp, as the two other guard() calls do.

On the RX 9070 XT, Windows, with the validation layer:

  • agc_driver_sample_multisample_target, agc_driver_native_msaa_vertex_input, agc_multisample_guest_access, agc_driver_msaa_dcc_state and agc_driver_msaa_dcc_clear_2, _4 and _8 pass 3 of 3 on main and on this head.
  • No log has a VUID- line.
  • The new case still fails with main's MultisampleTarget.cpp.

@simonbbby thank you for the Linux control with write watching on three ICDs. I added it to the description.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6290889209 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6290889209). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-20T12:31:06Z. --- Rebased onto `main` `56b299c3a`; the head is now `79b42bd76`. The only textual conflict was the debt line next to the stencil entry. The rebase also needed one code change: #7641 added a `guard()` call where a target is recreated with another pipe-bank XOR. That call now also records the recreated target's color bytes and use stamp, as the two other `guard()` calls do. On the RX 9070 XT, Windows, with the validation layer: - `agc_driver_sample_multisample_target`, `agc_driver_native_msaa_vertex_input`, `agc_multisample_guest_access`, `agc_driver_msaa_dcc_state` and `agc_driver_msaa_dcc_clear_2`, `_4` and `_8` pass 3 of 3 on `main` and on this head. - No log has a `VUID-` line. - The new case still fails with `main`'s `MultisampleTarget.cpp`. @simonbbby thank you for the Linux control with write watching on three ICDs. I added it to the description. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-21 14:28:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T14:28:13Z.


@savvaniss thanks for #8223. We hit a second form of the same reuse in PPSA03208, one that the CPU-write evidence can't see: the title reuses the memory through the GPU.

From a trace on our bring-up tree (main plus open multisample-depth PRs, with a diagnostic at colour-target registration):

  • At 0.002 s, a 2-sample colour target is registered at 0x1546eb0000 (format 13, 1920x2160, 0x870000 bytes) and drawn once.
  • Later, a native 2-sample D32S8 depth target is bound whose stencil plane is that same address (stencilAddress=0x1546eb0000, depth-only HTILE at 0x1547720000).
  • At 1.349 s, the stencil plane's initial import reads 0x1546eb0000+0x1000. That read lands inside the colour target's guard (last use 0.002 s, 1 use). Without a retire, it is refused and the title stops there.

Nothing wrote over the colour bytes from the CPU, so the write-tracker generation never changes, and as we read #8223 it would keep the guard here. To get past it, we used an unconditional retire-on-read as a probe. The title then runs about 20 s further, to its next, unrelated stop. We don't think that rule is safe for a live target, so we're not proposing it.

Could #8223 accept a second piece of evidence? When a native depth/stencil target (or a colour target with a different layout) claims a range that overlaps a guarded multisampled colour target, and the colour target's last use came before that claim, retire the colour guard through the same retirement #8223 adds for overwritten targets. That's the GPU-side counterpart of "the title wrote over it". A colour target that is still drawn after the claim would keep its guard and still refuse.

For the test, the existing fixture could:

  1. draw a 2x colour target;
  2. bind a D32S8 target whose stencil plane overlaps it;
  3. read the overlapped bytes, which should succeed with the guard retired;

plus a control where the colour target is drawn again after the depth bind and the read still refuses. We're happy to run the title on the result.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318549732 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6318549732). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T14:28:13Z. --- @savvaniss thanks for #8223. We hit a second form of the same reuse in PPSA03208, one that the CPU-write evidence can't see: the title reuses the memory through the GPU. From a trace on our bring-up tree (`main` plus open multisample-depth PRs, with a diagnostic at colour-target registration): - At 0.002 s, a 2-sample colour target is registered at `0x1546eb0000` (format 13, 1920x2160, `0x870000` bytes) and drawn once. - Later, a native 2-sample D32S8 depth target is bound whose stencil plane is that same address (`stencilAddress=0x1546eb0000`, depth-only HTILE at `0x1547720000`). - At 1.349 s, the stencil plane's initial import reads `0x1546eb0000+0x1000`. That read lands inside the colour target's guard (last use 0.002 s, 1 use). Without a retire, it is refused and the title stops there. Nothing wrote over the colour bytes from the CPU, so the write-tracker generation never changes, and as we read #8223 it would keep the guard here. To get past it, we used an unconditional retire-on-read as a probe. The title then runs about 20 s further, to its next, unrelated stop. We don't think that rule is safe for a live target, so we're not proposing it. Could #8223 accept a second piece of evidence? When a native depth/stencil target (or a colour target with a different layout) claims a range that overlaps a guarded multisampled colour target, and the colour target's last use came before that claim, retire the colour guard through the same retirement #8223 adds for overwritten targets. That's the GPU-side counterpart of "the title wrote over it". A colour target that is still drawn after the claim would keep its guard and still refuse. For the test, the existing fixture could: 1. draw a 2x colour target; 2. bind a D32S8 target whose stencil plane overlaps it; 3. read the overlapped bytes, which should succeed with the guard retired; plus a control where the colour target is drawn again after the depth bind and the read still refuses. We're happy to run the title on the result.
fma-rc commented 2026-10-21 14:43:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-21T14:43:22Z.


@savvaniss #9186 changes the same function for a different case: a multisampled texture that a shader sampled before any draw, later accessed by the GPU with no CPU write in between (Death Stranding 2 stops there even with #8223). The two conflict in guard() and RequireNoMultisampleColorTarget. I merged them locally, so each target keeps your write stamp and the new host-only flag, and the test cases from both PRs pass together on an RTX 5080.

I'm happy for #8223 to land first and then rebase #9186 onto it. If you'd rather go second, I can point you at the merged version. Which order works for you?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6318821251 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6318821251). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-21T14:43:22Z. --- @savvaniss #9186 changes the same function for a different case: a multisampled texture that a shader sampled before any draw, later accessed by the GPU with no CPU write in between (Death Stranding 2 stops there even with #8223). The two conflict in `guard()` and `RequireNoMultisampleColorTarget`. I merged them locally, so each target keeps your write stamp and the new host-only flag, and the test cases from both PRs pass together on an RTX 5080. I'm happy for #8223 to land first and then rebase #9186 onto it. If you'd rather go second, I can point you at the merged version. Which order works for you?
savvaniss commented 2026-10-21 16:42:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-21T16:42:07Z.


@oneandonlydean thanks for the trace. The rule is in 93a76298e1 (with main merged in f4352b5ed0), close to how you described it:

  • Each bind over guarded memory marks the multisampled color targets it overlaps as claimed. That covers a depth target's depth plane, stencil plane and HTILE, a single-sample color target, and a draw of a multisampled color target with another address, format, extent or sample count. The depth claims happen at the top of DepthSurfaceView, before any import reads guest memory.
  • A draw of a color target clears its own mark. A target drawn again after the claim keeps its guard and still refuses.
  • At the next guarded access, a claimed target is retired through the same path as the CPU-write case. The access then goes on, unless another live target still overlaps it.

SampleMultisampleTarget has the cases you suggested: it draws a 2x target, binds a 2x D32S8 target whose stencil plane is that memory, and reads 0x1000 bytes of it, which passes. In the control, the color target is drawn again after the bind, and the read is still refused. Two more cases cover the color-layout claims: a single-sample draw over a 2x target, and a 4x draw over part of a 2x target. With the previous head's production code, the test fails 3 of 3 at the first case. When I removed one part of the change at a time, each case failed at its own check. On the RX 9070 XT the MSAA and native-depth set (23 tests) passes under the validation layer on main and on this head, with no VUID- line. The PR description has the details.

On main, a native multisample stencil plane is not imported yet, so the test reads the overlapped bytes directly instead of going through the import from your trace. The claim comes before that import, so I expect PPSA03208 to get past its stop at 1.349 s, but I could not check that here. Thanks for offering to run it.

One trade-off is in the debt entry: a bind is taken as reuse. So if a title binds another target over a live multisampled target and afterwards only samples that target, without drawing to it, the samples are lost at the next guarded access.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6321324954 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6321324954). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-21T16:42:07Z. --- @oneandonlydean thanks for the trace. The rule is in 93a76298e1 (with `main` merged in f4352b5ed0), close to how you described it: - Each bind over guarded memory marks the multisampled color targets it overlaps as claimed. That covers a depth target's depth plane, stencil plane and HTILE, a single-sample color target, and a draw of a multisampled color target with another address, format, extent or sample count. The depth claims happen at the top of `DepthSurfaceView`, before any import reads guest memory. - A draw of a color target clears its own mark. A target drawn again after the claim keeps its guard and still refuses. - At the next guarded access, a claimed target is retired through the same path as the CPU-write case. The access then goes on, unless another live target still overlaps it. `SampleMultisampleTarget` has the cases you suggested: it draws a 2x target, binds a 2x D32S8 target whose stencil plane is that memory, and reads 0x1000 bytes of it, which passes. In the control, the color target is drawn again after the bind, and the read is still refused. Two more cases cover the color-layout claims: a single-sample draw over a 2x target, and a 4x draw over part of a 2x target. With the previous head's production code, the test fails 3 of 3 at the first case. When I removed one part of the change at a time, each case failed at its own check. On the RX 9070 XT the MSAA and native-depth set (23 tests) passes under the validation layer on `main` and on this head, with no `VUID-` line. The PR description has the details. On `main`, a native multisample stencil plane is not imported yet, so the test reads the overlapped bytes directly instead of going through the import from your trace. The claim comes before that import, so I expect PPSA03208 to get past its stop at 1.349 s, but I could not check that here. Thanks for offering to run it. One trade-off is in the debt entry: a bind is taken as reuse. So if a title binds another target over a live multisampled target and afterwards only samples that target, without drawing to it, the samples are lost at the next guarded access.
savvaniss commented 2026-10-21 16:42:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-21T16:42:09Z.


@fma-rc thanks for merging the two. Yes: #8223 first, and #9186 rebases onto it, as you offered.

Your merged version needs one more pass, though. Today's push changes the same code again for oneandonlydean's request:

  • The write stamp is no longer a separate usedAt atomic. Each target has one TargetUse (writes, claimed), and every guarded range of the target points to it, the DCC and CMASK ranges included. Your host-only flag can go in the same struct.
  • The retirement loop is now in main's RequireNoMultisampleColorTarget. It retires a target there when it is claimed (another target was bound over it after its last draw) or when the CPU wrote over it.

This does not cover your case. DS2's storage access over a texture that was sampled before any draw has no bind over it, so #9186 is still needed after #8223.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6321325702 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6321325702). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-21T16:42:09Z. --- @fma-rc thanks for merging the two. Yes: #8223 first, and #9186 rebases onto it, as you offered. Your merged version needs one more pass, though. Today's push changes the same code again for oneandonlydean's request: - The write stamp is no longer a separate `usedAt` atomic. Each target has one `TargetUse` (`writes`, `claimed`), and every guarded range of the target points to it, the DCC and CMASK ranges included. Your host-only flag can go in the same struct. - The retirement loop is now in `main`'s `RequireNoMultisampleColorTarget`. It retires a target there when it is claimed (another target was bound over it after its last draw) or when the CPU wrote over it. This does not cover your case. DS2's storage access over a texture that was sampled before any draw has no bind over it, so #9186 is still needed after #8223.
EagleBearerYS commented 2026-10-22 09:12:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T09:12:21Z.


@savvaniss a merge-order note: #9533 (a draft) overlaps this PR in DepthSurfaceView and in MultisampleTarget.cpp's guard. It imports native multisampled D32S8 targets with a separate stencil plane, and before reading that plane it asks whether a host-only multisampled colour target covers it: the PPSA03208 shape your claim-and-retire rule handles. #9533 goes after this PR and rebases onto it, keeping your claims and retires. Its import then needs a colour target you retire to stay known to it: a retired target over the plane keeps its known fill value, or else leaves the stencil plane unproven, so stale guest bytes there are never taken as the clear value. That's a change on #9533's side; nothing changes here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337125075 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6337125075). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T09:12:21Z. --- @savvaniss a merge-order note: #9533 (a draft) overlaps this PR in `DepthSurfaceView` and in `MultisampleTarget.cpp`'s `guard`. It imports native multisampled D32S8 targets with a separate stencil plane, and before reading that plane it asks whether a host-only multisampled colour target covers it: the PPSA03208 shape your claim-and-retire rule handles. #9533 goes after this PR and rebases onto it, keeping your claims and retires. Its import then needs a colour target you retire to stay known to it: a retired target over the plane keeps its known fill value, or else leaves the stencil plane unproven, so stale guest bytes there are never taken as the clear value. That's a change on #9533's side; nothing changes here.
savvaniss commented 2026-10-22 10:56:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-22T10:56:50Z.


@EagleBearerYS thanks for the merge-order note. Understood: #9533 goes after this pull request and rebases onto it, keeping its claims and retires, and the handling of a retired colour target over the stencil plane is on #9533's side. Nothing changes here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339054439 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8223#issuecomment-6339054439). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-22T10:56:50Z. --- @EagleBearerYS thanks for the merge-order note. Understood: #9533 goes after this pull request and rebases onto it, keeping its claims and retires, and the handling of a retired colour target over the stencil plane is on #9533's side. Nothing changes here.
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!8223
No description provided.