fix(agc): retire native depth before binding an overlapping layout #10375

Merged
Ondra97 merged 1 commit from upstream-pr/10375 into main 2026-10-25 10:58:30 +00:00
Ondra97 commented 2026-10-23 20:01:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-23T20:01:34Z.


What

Binding a new depth attachment whose plane or HTILE overlapped an active native multisample depth owner was rejected as a layout/metadata change. Even an unwritten owner could not be replaced by another valid layout over the same guest memory.

Use the existing native-depth guest-access transition before constructing the new attachment: publish supported written contents, retire intersecting owners, then validate/create the new layout. Keep the existing attachment unchanged when its identity matches. Release the surface-cache lock before publication; the GPU lock continues to serialize the transition. Unsupported publication paths still throw.

Tested

Windows 11 Pro build 26300, WinLibs GCC 15.2.0, Release, RTX 4070 Ti SUPER, NVIDIA 617.42.

  • Red: a native multisample depth attachment changed from 5x3 to 6x3 with another HTILE while an old sampled view remains held. Main rejects it as native multisample depth attachment layout or metadata changed.
  • Green: the replacement gets a different view, rebinding it reuses that view, and retiring an unwritten owner leaves every guest byte unchanged. A single-sample bind over an unwritten native HTILE owner also succeeds without modifying HTILE.
  • Final integration: 47 selected checks plus four native-depth clear/BDA-clear/retirement/refusal checks pass: 51 total, zero skips. Invalid CPU/depth writes, partial or unproven clears and overlapping-clear refusals remain covered. Full Windows Release build passes.
  • Vulkan required, shader caches disabled; actual Khronos instance/device validation layers confirmed. No VUIDs in the final validation.
  • The regression uses an unwritten owner and needs no pending publication feature. Written aliases use the existing guest-publication guard and retain its unsupported-path errors. Local game integration includes #6743, #6782, #10304, #10351, #10368 and #9950; those patches are excluded here.
  • Conventions and whitespace pass. Fresh PRAGMATA run displays the autosave warning and loading, then its first reported failure is external GPU writes over native multisample depth are not implemented. Menu/gameplay remain unconfirmed; no speedup claim. Full CTest suite not run.

Overlap review: 28 shared-file PR diffs inspected. #6808 adds overlap diagnostics, #7256 changes creation-lock placement, #9533/#9717/#9742 add separate stencil handling, and #9950 adds written D32 publication. Their nearby edits need normal merge coordination; they do not provide this attachment-alias transition.
Independent validation of the published commit: Published head e393705239a3104846c1a91548e7c1fc9a2f9a38: full Windows Release build and native multisample depth, depth-storage dispatch, native-depth BDA clear/retirement/clear/refusal checks and patched-library validation pass on a clean tracked tree without overlays (7/7, zero skips). Vulkan is required, shader caches are disabled, and loader logs confirm actual Khronos instance/device validation layers; no VUIDs. Hardware and toolchain are the Windows/NVIDIA configuration listed above. This independently validates the published commit in addition to the earlier integration runs. The complete CTest suite was not run.
Review baseline comparison (2026-10-24): I ran the same seven focused CTest names on current main 7966e590ef7cb1054500eef513f99c59e05547b0 and compared its log with the clean, previously run published head e393705239a3104846c1a91548e7c1fc9a2f9a38. Both runs used this Windows 11 / RTX 4070 Ti SUPER host, Release / WinLibs GCC 15.2.0, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_GPU=RTX 4070 Ti SUPER, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the same Khronos layer path and VK_LOADER_DEBUG=error,warn,layer. The main-side build was limited to the four targets required by the selected tests; the PR head also passed the full Release build reported above.

ctest --test-dir <build> -R '^(agc_driver_native_multisample_depth|agc_driver_depth_storage_dispatch|agc_driver_native_depth_(bda_clear|retirement|clears|clear_refusals)|patched_libraries)$' -j1 -V

Log check Current main Published PR head
Same seven CTest names 7 passed, 0 failed, 0 skipped 7 passed, 0 failed, 0 skipped
Vulkan loader Inserted VK_LAYER_KHRONOS_validation at instance and device level Inserted VK_LAYER_KHRONOS_validation at instance and device level
VUID- identifiers / validation warnings or errors / missing requested layer 0 / 0 / 0 0 / 0 / 0
New attachment-alias fixture line in agc_driver_native_multisample_depth absent, since the case is introduced by this PR present: native depth attachment alias changes layout while retaining held GPU views

Both logs report Selected GPU name=NVIDIA GeForce RTX 4070 Ti SUPER. The matched JUnit test names and results, loader insertion lines and VUID scans were compared directly. The earlier red control on main with the new fixture overlaid is reported above; this baseline comparison uses each revision's own clean source.

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: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti SUPER, NVIDIA 617.42, Windows 11 Pro build 26300
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4988546248 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10375). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-23T20:01:34Z. --- ### What Binding a new depth attachment whose plane or HTILE overlapped an active native multisample depth owner was rejected as a layout/metadata change. Even an unwritten owner could not be replaced by another valid layout over the same guest memory. Use the existing native-depth guest-access transition before constructing the new attachment: publish supported written contents, retire intersecting owners, then validate/create the new layout. Keep the existing attachment unchanged when its identity matches. Release the surface-cache lock before publication; the GPU lock continues to serialize the transition. Unsupported publication paths still throw. ### Tested Windows 11 Pro build 26300, WinLibs GCC 15.2.0, Release, RTX 4070 Ti SUPER, NVIDIA 617.42. - Red: a native multisample depth attachment changed from 5x3 to 6x3 with another HTILE while an old sampled view remains held. Main rejects it as `native multisample depth attachment layout or metadata changed`. - Green: the replacement gets a different view, rebinding it reuses that view, and retiring an unwritten owner leaves every guest byte unchanged. A single-sample bind over an unwritten native HTILE owner also succeeds without modifying HTILE. - Final integration: 47 selected checks plus four native-depth clear/BDA-clear/retirement/refusal checks pass: 51 total, zero skips. Invalid CPU/depth writes, partial or unproven clears and overlapping-clear refusals remain covered. Full Windows Release build passes. - Vulkan required, shader caches disabled; actual Khronos instance/device validation layers confirmed. No VUIDs in the final validation. - The regression uses an unwritten owner and needs no pending publication feature. Written aliases use the existing guest-publication guard and retain its unsupported-path errors. Local game integration includes #6743, #6782, #10304, #10351, #10368 and #9950; those patches are excluded here. - Conventions and whitespace pass. Fresh PRAGMATA run displays the autosave warning and loading, then its first reported failure is `external GPU writes over native multisample depth are not implemented`. Menu/gameplay remain unconfirmed; no speedup claim. Full CTest suite not run. Overlap review: 28 shared-file PR diffs inspected. #6808 adds overlap diagnostics, #7256 changes creation-lock placement, #9533/#9717/#9742 add separate stencil handling, and #9950 adds written D32 publication. Their nearby edits need normal merge coordination; they do not provide this attachment-alias transition. **Independent validation of the published commit:** Published head `e393705239a3104846c1a91548e7c1fc9a2f9a38`: full Windows Release build and native multisample depth, depth-storage dispatch, native-depth BDA clear/retirement/clear/refusal checks and patched-library validation pass on a clean tracked tree without overlays (7/7, zero skips). Vulkan is required, shader caches are disabled, and loader logs confirm actual Khronos instance/device validation layers; no VUIDs. Hardware and toolchain are the Windows/NVIDIA configuration listed above. This independently validates the published commit in addition to the earlier integration runs. The complete CTest suite was not run. **Review baseline comparison (2026-10-24):** I ran the same seven focused CTest names on current `main` `7966e590ef7cb1054500eef513f99c59e05547b0` and compared its log with the clean, previously run published head `e393705239a3104846c1a91548e7c1fc9a2f9a38`. Both runs used this Windows 11 / RTX 4070 Ti SUPER host, Release / WinLibs GCC 15.2.0, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_GPU=RTX 4070 Ti SUPER`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, the same Khronos layer path and `VK_LOADER_DEBUG=error,warn,layer`. The main-side build was limited to the four targets required by the selected tests; the PR head also passed the full Release build reported above. `ctest --test-dir <build> -R '^(agc_driver_native_multisample_depth|agc_driver_depth_storage_dispatch|agc_driver_native_depth_(bda_clear|retirement|clears|clear_refusals)|patched_libraries)$' -j1 -V` | Log check | Current `main` | Published PR head | | --- | --- | --- | | Same seven CTest names | 7 passed, 0 failed, 0 skipped | 7 passed, 0 failed, 0 skipped | | Vulkan loader | Inserted `VK_LAYER_KHRONOS_validation` at instance and device level | Inserted `VK_LAYER_KHRONOS_validation` at instance and device level | | `VUID-` identifiers / validation warnings or errors / missing requested layer | 0 / 0 / 0 | 0 / 0 / 0 | | New attachment-alias fixture line in `agc_driver_native_multisample_depth` | absent, since the case is introduced by this PR | present: `native depth attachment alias changes layout while retaining held GPU views` | Both logs report `Selected GPU name=NVIDIA GeForce RTX 4070 Ti SUPER`. The matched JUnit test names and results, loader insertion lines and VUID scans were compared directly. The earlier red control on `main` with the new fixture overlaid is reported above; this baseline comparison uses each revision's own clean source. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> NVIDIA GeForce RTX 4070 Ti SUPER, NVIDIA 617.42, Windows 11 Pro build 26300 - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-23 20:03:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T20:03:37Z.

Review: DISMISSED


The RTX 4070 Ti SUPER run is detailed and the new alias regression is meaningful. Before approval, the AGC validation rule still needs the same focused tests on both current main and this head, using ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, with logs compared for newly introduced VUID- errors. The description reports the red main behavior and the PR-side 51 checks, confirms the layer loaded and no final VUIDs, but does not show the equivalent main-side focused run/log or establish that the comparison used the same test set and environment. Please add those baseline results (including confirmation the layer was found and the VUID comparison), or explain the exact equivalent baseline procedure. I could not run this locally because the required GPU is unavailable here.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5633807763 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10375#pullrequestreview-5633807763). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T20:03:37Z. **Review:** DISMISSED --- The RTX 4070 Ti SUPER run is detailed and the new alias regression is meaningful. Before approval, the AGC validation rule still needs the same focused tests on both current `main` and this head, using `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, with logs compared for newly introduced `VUID-` errors. The description reports the red main behavior and the PR-side 51 checks, confirms the layer loaded and no final VUIDs, but does not show the equivalent main-side focused run/log or establish that the comparison used the same test set and environment. Please add those baseline results (including confirmation the layer was found and the VUID comparison), or explain the exact equivalent baseline procedure. I could not run this locally because the required GPU is unavailable 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!10375
No description provided.