fix(agc): publish native multisample depth over a colour alias its owner took in #16301

Merged
dantdmdarealguy merged 1 commit from upstream-pr/16301 into main 2026-11-10 22:34:41 +00:00
dantdmdarealguy commented 2026-11-06 06:36:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-11-06T06:36:58Z.


What

fix(agc): publish native multisample depth over a colour alias its owner took in

A native D32S8 owner can take in a multisampled colour target that lies over one of its planes. There are two such cases:

  • the R32F target over the depth plane, which the import accepts when HTILE proves its clear (#9742);
  • the R8 target over the stencil plane, whose fill the owner applies as its stencil clear (#9717).

The guest publication from #13021 refused whenever any colour target was resident over a plane. Ghost of Tsushima has both kinds of alias over its 2-sample D32S8 target.

Why the owner's bytes are newer. If the colour target has not cleared, drawn or taken a fill since the owner took its content in, every depth or stencil write of the owner came after the target's last change. The published bytes are then what the memory holds. A fill over a plane is also noted to the depth owner, and publication already refuses while such a fill has not been applied. So a stencil-plane alias's latest fill is always one the owner has absorbed.

The change:

  • The owner records the colour target it took in:
    • the depth-plane alias at import, as before;
    • the stencil-plane alias at import, and again each time it applies that target's fill as its stencil clear.
  • Publication goes ahead over a recorded target that is the only colour target over its plane and whose content counter, fill count, newest content and value are unchanged. It checks this again before the planes commit, and retires the target after they commit.
  • Any other colour target over a plane still refuses with the same message.
  • The retired target's host samples are not rewritten with the published bytes, so a later colour use of that memory starts a new target. The new debt entry says this, and that the ordering argument is inferred, not measured on the console. The publication entry now says "other resident colour aliases".

Test: agc_driver_native_depth_publication gets five cases, each for 2, 4 and 8 samples:

case expected
R32F depth-plane alias accepted at import, then a depth draw publishes the drawn samples, keeps the owner, retires the alias
R8 stencil-plane fill alias at import same as above
the same alias refilled after import, as Ghost does every frame same as above
either alias drawn after import refuses, leaves guest bytes unchanged, keeps both resident

On main the test fails with AGC graphics: native multisample depth publication over a resident colour target is not implemented. With the change it passes.

Tested

Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release.

  • Title: Ghost of Tsushima Director's Cut PPSA02225 02.024.000, relinked with relinker --windows --registry --module-dir prospero.
    • On main e322066f82 it stops as quoted above, at +270 s with a cold cache and +60 s with a warm one.
    • With this change, two 900 s runs end at the time limit with no refusal and reach the in-engine opening cinematic.
  • New test: ctest -R '^agc_driver_native_depth_publication$' fails on main with the message above and passes with the change.
  • Other tests: ctest -R "agc_driver.*(depth|multisample|msaa|stencil|alias|fmask|dcc|cmask|htile)" passes 114 of 114, and patched_libraries passes.
  • Validation layer: ctest -V -R agc_driver_native_depth (17 tests) on main and on this change, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.
    • Neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS.
    • Both logs show Insert instance layer "VK_LAYER_KHRONOS_validation" 32 times (VK_LOADER_DEBUG=layer).
    • Neither log has a VUID- line.
    • On main only agc_driver_native_depth_publication fails, with the title's message. agc_driver_native_depth_driver_queued_fill skips in both.

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: PPSA02225 #5166 (Ghost of Tsushima Director's Cut gets past compute shader 0x20001f3500: AGC graphics: native multisample depth publication over a resident colour target is not implemented)
  • GPUs tested: NVIDIA GeForce RTX 5080, driver 32.0.16.1742, Windows 11 Pro
  • AI-assisted: yes, some AI assistance was used
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5183993196 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16301). Originally posted by [dantdmdarealguy](https://github.com/dantdmdarealguy) on 2026-11-06T06:36:58Z. --- ### What `fix(agc): publish native multisample depth over a colour alias its owner took in` A native D32S8 owner can take in a multisampled colour target that lies over one of its planes. There are two such cases: - the R32F target over the depth plane, which the import accepts when HTILE proves its clear (#9742); - the R8 target over the stencil plane, whose fill the owner applies as its stencil clear (#9717). The guest publication from #13021 refused whenever any colour target was resident over a plane. Ghost of Tsushima has both kinds of alias over its 2-sample D32S8 target. **Why the owner's bytes are newer.** If the colour target has not cleared, drawn or taken a fill since the owner took its content in, every depth or stencil write of the owner came after the target's last change. The published bytes are then what the memory holds. A fill over a plane is also noted to the depth owner, and publication already refuses while such a fill has not been applied. So a stencil-plane alias's latest fill is always one the owner has absorbed. **The change:** - The owner records the colour target it took in: - the depth-plane alias at import, as before; - the stencil-plane alias at import, and again each time it applies that target's fill as its stencil clear. - Publication goes ahead over a recorded target that is the only colour target over its plane and whose content counter, fill count, newest content and value are unchanged. It checks this again before the planes commit, and retires the target after they commit. - Any other colour target over a plane still refuses with the same message. - The retired target's host samples are not rewritten with the published bytes, so a later colour use of that memory starts a new target. The new debt entry says this, and that the ordering argument is inferred, not measured on the console. The publication entry now says "other resident colour aliases". **Test:** `agc_driver_native_depth_publication` gets five cases, each for 2, 4 and 8 samples: | case | expected | |---|---| | R32F depth-plane alias accepted at import, then a depth draw | publishes the drawn samples, keeps the owner, retires the alias | | R8 stencil-plane fill alias at import | same as above | | the same alias refilled after import, as Ghost does every frame | same as above | | either alias drawn after import | refuses, leaves guest bytes unchanged, keeps both resident | On `main` the test fails with `AGC graphics: native multisample depth publication over a resident colour target is not implemented`. With the change it passes. ### Tested Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release. - **Title:** Ghost of Tsushima Director's Cut PPSA02225 02.024.000, relinked with `relinker --windows --registry --module-dir prospero`. - On `main` e322066f82 it stops as quoted above, at +270 s with a cold cache and +60 s with a warm one. - With this change, two 900 s runs end at the time limit with no refusal and reach the in-engine opening cinematic. - **New test:** `ctest -R '^agc_driver_native_depth_publication$'` fails on `main` with the message above and passes with the change. - **Other tests:** `ctest -R "agc_driver.*(depth|multisample|msaa|stencil|alias|fmask|dcc|cmask|htile)"` passes 114 of 114, and `patched_libraries` passes. - **Validation layer:** `ctest -V -R agc_driver_native_depth` (17 tests) on `main` and on this change, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. - Neither log contains `was not found but was requested by env var VK_INSTANCE_LAYERS`. - Both logs show `Insert instance layer "VK_LAYER_KHRONOS_validation"` 32 times (`VK_LOADER_DEBUG=layer`). - Neither log has a `VUID-` line. - On `main` only `agc_driver_native_depth_publication` fails, with the title's message. `agc_driver_native_depth_driver_queued_fill` skips in both. ### 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: PPSA02225 #5166 (Ghost of Tsushima Director's Cut gets past `compute shader 0x20001f3500: AGC graphics: native multisample depth publication over a resident colour target is not implemented`) - [x] GPUs tested: NVIDIA GeForce RTX 5080, driver 32.0.16.1742, Windows 11 Pro - [x] AI-assisted: yes, some AI assistance was used
gabichuuuuu commented 2026-11-07 17:55:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T17:55:54Z.

Review: COMMENTED


Windows check of head af10404d23, merged onto main 4e44ed59b2 (clean merge), with main from the same build directory as the control.

Setup: Windows 11 x64, WinLibs GCC 15.2.0 r7, Release, full build. ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R '^agc_driver_native_depth_', 3 runs per GPU on each side.

NVIDIA laptop GPU, driver 610 Intel iGPU, same machine
main 3 of 3 runs pass 3 of 3 runs fail stencil_view, uniform_planes and publication
this PR 2 of 3 runs pass all 18; run 2 timed out in native_depth_clears the same three as main, nothing new
  • The new alias cases are in --publication, so agc_driver_native_depth_publication covers them: it passes in every run on the NVIDIA GPU. On the Intel iGPU that test already fails on main (native D32S8 publication lost live samples, HTILE, padding or guest writes) in the earlier cases, so the new ones never run there; this run says nothing about them on that GPU.
  • The timeout is this machine stalling, not the change: in the same run publication, retirement, aliased_stencil and expand_gate each took about 26 s, against under 2 s normally, and native_depth_clears passes in the other runs on both GPUs.
  • Not run with VK_LAYER_KHRONOS_validation.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5814120384 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16301#pullrequestreview-5814120384). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-07T17:55:54Z. **Review:** COMMENTED --- Windows check of head `af10404d23`, merged onto `main` `4e44ed59b2` (clean merge), with `main` from the same build directory as the control. **Setup:** Windows 11 x64, WinLibs GCC 15.2.0 r7, Release, full build. `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R '^agc_driver_native_depth_'`, 3 runs per GPU on each side. | | NVIDIA laptop GPU, driver 610 | Intel iGPU, same machine | |---|---|---| | `main` | 3 of 3 runs pass | 3 of 3 runs fail `stencil_view`, `uniform_planes` and `publication` | | this PR | 2 of 3 runs pass all 18; run 2 timed out in `native_depth_clears` | the same three as `main`, nothing new | - The new alias cases are in `--publication`, so `agc_driver_native_depth_publication` covers them: it passes in every run on the NVIDIA GPU. On the Intel iGPU that test already fails on `main` (`native D32S8 publication lost live samples, HTILE, padding or guest writes`) in the earlier cases, so the new ones never run there; this run says nothing about them on that GPU. - The timeout is this machine stalling, not the change: in the same run `publication`, `retirement`, `aliased_stencil` and `expand_gate` each took about 26 s, against under 2 s normally, and `native_depth_clears` passes in the other runs on both GPUs. - Not run with `VK_LAYER_KHRONOS_validation`. AI-assisted: yes.
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!16301
No description provided.