Skip to content

fix(agc): reclaim published native depth owners safely - #10469

Open
Ondra97 wants to merge 4 commits into
boykopovar:mainfrom
Ondra97:codex/fix-published-native-depth-retirement
Open

Ondra97 wants to merge 4 commits into
boykopovar:mainfrom
Ondra97:codex/fix-published-native-depth-retirement

Conversation

@Ondra97

@Ondra97 Ondra97 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

What

After #9950 publishes a written native multisample D32 depth surface to guest memory, its guard becomes inactive, but releaseRetired still excludes multisampled surfaces. Replacing those surfaces keeps their native images and sample shadows cached after their last sampled view is released.

Record completed guest publication and reclaim an inactive published owner only when no sampled view holds it. Call the existing retire path before removing the owner so the depth/stencil owner maps cannot retain raw pointers to the freed surface. The existing recorder keep-alive mechanism preserves resources needed by recorded GPU work. Serialize publication with the GPU mutex used by surface creation and reclamation. Inactive owners without completed publication remain cached and are documented as a remaining limitation.

Depends on #9950, exact head 875fa29033c500a0f49af4c50cf3970d37fd2229, preserved as a prerequisite merge. The own change is commit f94177b01a: three files, 38 additions and three removals. It does not change sample ordering, guest layout or shader instruction semantics.

Tested

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742.

Full Release builds pass on literal main db6af9e0fd8c75366dabc2066dbf90117f7490d0 and candidate 4f64dee52dbfc4dc4c4cf374e6f24dccbf8e670e. Both use the same pinned dependencies and the real NativeMultisampleDepth execution fixture.

Same machine/GPU, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, Khronos 1.4.363. Actual instance/device layer insertion was confirmed; neither log reports a missing requested layer. Both final runs have zero validation warnings/errors, VUIDs, skips or timeouts.

Source Focused CTests Result
Literal current main 6 6 passed
Candidate after byte-exact restoration 6 6 passed
Same candidate fixture, only the own production fix removed 1 Expected failure: a published inactive native owner remained cached without held views

The selection is agc_driver_native_multisample_depth, agc_driver_native_depth_retirement, agc_driver_native_depth_clears, agc_driver_native_depth_clear_refusals, agc_driver_graphics and patched_libraries, run serially with ctest --test-dir build -R <selection> -V. Every selected test completes within 6.4 s.

The new GPU regression covers all six publication combinations: 2/4/8 samples at 5x3, and at 70x67 with pipe-bank XOR 0x8c00. It checks the published samples, HTILE and padding, keeps a native sampled view across another target allocation, verifies that its owner survives, releases the view, requires reclamation on a later allocation, then renders again at the original address. The control uses identical fixture bytes and removes only the own DepthSurface.cpp change. Production source restoration was verified by SHA-256, followed by another successful full build and the final six tests.

Conventions, strict main-sync, whitespace and registration checks pass: 1281 test executables, none built without registration. Conventions reports one existing 2196-character debt-entry warning from the #9950 prerequisite, zero errors. The full CTest suite was not run.

Overlap review checked the exact shared-file diffs, including conflicting older PRs. None implements published-owner reclamation. #9533/#9717/#9742 overlap the preserved #9950 prerequisite and already propose #9950 first; #10368/#10375 insert independent cases into the same fixture, so retain both sets of cases when merging. Recapture #7446 and buffer-alias checks #6498 are separate implementations and are excluded from this PR.

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: feat(agc): publish a written native multisample D32 depth surface to its guest planes on access #9950
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742, Windows 11 Pro 10.0.26300
  • AI-assisted: yes

ebarr24 and others added 4 commits October 22, 2026 19:24
…its guest planes on access

A guest read, DMA copy source or texture, storage, index or vertex read over a native multisample depth surface that a draw had written threw sample-preserving guest publication of native multisample depth is not implemented (Sonic Superstars PPSA06888 boykopovar#5382, Monster Hunter Wilds PPSA24191 boykopovar#7972, Onimusha PPSA27836 boykopovar#6570). The access now completes the pending fast clear and recorder work, reads the samples back in the guest layer, row, column, fragment order with the merged multisample readback, retiles them into the Z_X plane with the descriptor pipe-bank XOR through MultisampleTextureLayout, and rewrites every HTILE word to the expanded clear word (Mesa radv_get_htile_initial_value: 0xfffc000f without stencil, ZMask 0xf with the full Z range otherwise) before retiring the surface like an unwritten one. Written D16 surfaces, surfaces the device stores in another format and surfaces it cannot sample still throw with their own messages. The console HTILE after a DB decompress and its compressed plane bytes are not measured.
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 9533 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp L7
docs/dev/debt/libSceAgcDriver.md L31
PR 9717 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp L7, L1002-1009
docs/dev/debt/libSceAgcDriver.md L31
PR 9742 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp L7
docs/dev/debt/libSceAgcDriver.md L31

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 2434 docs/dev/debt/libSceAgcDriver.md
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5925 docs/dev/debt/libSceAgcDriver.md
PR 6186 docs/dev/debt/libSceAgcDriver.md
PR 6194 docs/dev/debt/libSceAgcDriver.md
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6273 docs/dev/debt/libSceAgcDriver.md
PR 6280 docs/dev/debt/libSceAgcDriver.md
PR 6300 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 docs/dev/debt/libSceAgcDriver.md
PR 6548 docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6867 docs/dev/debt/libSceAgcDriver.md
PR 6977 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7201 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7449 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7604 docs/dev/debt/libSceAgcDriver.md
PR 7618 docs/dev/debt/libSceAgcDriver.md
PR 7642 docs/dev/debt/libSceAgcDriver.md
PR 7844 docs/dev/debt/libSceAgcDriver.md
PR 7910 docs/dev/debt/libSceAgcDriver.md
PR 8014 docs/dev/debt/libSceAgcDriver.md
PR 8223 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 8319 docs/dev/debt/libSceAgcDriver.md
PR 8365 docs/dev/debt/libSceAgcDriver.md
PR 8542 docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 9348 docs/dev/debt/libSceAgcDriver.md
PR 9356 docs/dev/debt/libSceAgcDriver.md
PR 9387 docs/dev/debt/libSceAgcDriver.md
PR 9393 docs/dev/debt/libSceAgcDriver.md
PR 9431 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9432 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9508 docs/dev/debt/libSceAgcDriver.md
PR 9592 docs/dev/debt/libSceAgcDriver.md
PR 9672 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9673 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9674 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9675 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9676 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9748 docs/dev/debt/libSceAgcDriver.md
PR 9842 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9891 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9892 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9893 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9898 docs/dev/debt/libSceAgcDriver.md
PR 9904 docs/dev/debt/libSceAgcDriver.md
PR 9905 docs/dev/debt/libSceAgcDriver.md
PR 9906 docs/dev/debt/libSceAgcDriver.md
PR 10193 docs/dev/debt/libSceAgcDriver.md
PR 10194 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 10256 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 10420 docs/dev/debt/libSceAgcDriver.md

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants