fix(agc): check whole storage views for native surface overlap #10368

Merged
Ondra97 merged 1 commit from upstream-pr/10368 into main 2026-10-26 08:20:05 +00:00
Ondra97 commented 2026-10-23 19:36:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-23T19:36:27Z.


What

A storage-image lookup without a precomputed surface size checked only its first byte against native multisample owners. A native depth surface inside a larger cached view was missed, so the cache could return stale guest bytes and keep the overlapping native owner active.

Resolve the viewed surface's complete size before the overlap check and use that range before either the native-depth storage path or a cached storage lookup. The regression seeds a cached linear view, creates an unwritten native multisample depth surface inside it, checks a disjoint view ending at the depth boundary, then requires the complete view to retire the intersecting owner without changing guest bytes.

Tested

Current-main refresh: upstream main e05ba6feebd000cfc316c1d1f00e37e030aa3d8b, submitted head d1dc3a5920b5017e1b958151eca93479187fb75f. Windows 11 Pro 10.0.26300, AMD Ryzen 9 7900X, 31.7 GiB RAM, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON, pinned bundled dependencies. NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742; Khronos validation 1.4.363.

  • Full production relinker and libraries, patched-library fixture, graphics and focused GPU fixtures built successfully on the submitted head (cmake --build <build> --target relinker libs patched_libraries_tests agc_driver_graphics_tests agc_driver_native_multisample_depth_tests agc_driver_sample_multisample_target_tests agc_driver_depth_storage_dispatch_tests agc_driver_native_depth_bda_clear_tests --parallel 8).
  • Paired focused runs on this machine/GPU: clean main 9/9, submitted head 9/9, zero failures or skips. Both used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ctest -j 1 -V, and confirmed actual instance/device layer insertion. Neither log contains a missing requested validation layer, VUID-, or validation error/warning. Candidate selection: ^(patched_libraries|agc_driver_(graphics|native_multisample_depth|sample_multisample_target|depth_storage_dispatch|native_depth_(bda_clear|retirement|clears|clear_refusals)))$. Main selection: ^(patched_libraries|agc_driver_(graphics|native_multisample_depth|sample_multisample_target|depth_storage_dispatch|native_depth_(bda_clear|retirement|clears|clear_refusals)))$.
  • Conventions, strict current-main synchronization, whitespace, test registration and overlap checks completed. The existing prerequisite long-debt-entry warning is retained where reported; no convention errors. This is focused runtime validation, not the complete CTest suite or a new title run.

The one original feature patch remains limited to two files. The conflict placed two independent fixtures at the same insertion point; main's CheckDepthAttachmentAlias and this PR's byte-identical CheckStorageAliasRetirement are now separate functions, and both run in the default native-depth case. The production patch still only resolves viewedBytes before the existing native-MSAA guard and cached/native-depth lookup. No prerequisite was added and shader instruction semantics are unchanged.

The new regression executes on the selected GPU: an adjacent view ending exactly at the native-depth boundary retains that owner, while a larger cached storage span retires only the intersecting unwritten owner and preserves the guest bytes. Depth-storage dispatch and native-depth BDA clear checks are included in the paired selection alongside the shared native-depth/library/graphics cases. Earlier 47-check mixed-integration evidence below remains historical; it is not claimed for the rebased head.

Earlier submitted-revision evidence (historical)

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

  • Red: the added GPU case fails with a cached storage view kept a native depth owner inside its range.
  • Green: native depth and depth-storage dispatch checks pass, including the new cached-view/boundary case. Final integrated validation: 47 selected checks, zero failures/skips; full Windows Release build passes.
  • Vulkan required, shader caches disabled and actual Khronos instance/device validation layer insertion confirmed. No new VUIDs.
  • The new case uses an unwritten depth owner; it does not require the pending written-depth publication feature. The local PRAGMATA integration also contains #6743, #6782, #10304, #10351 and #9950; none is included in this two-file PR.
  • Conventions and whitespace pass. Game retest pending; no gameplay or performance claim. Full CTest suite not run.

Overlap review: 31 shared-file PR diffs checked. #10049 adds overwrite coverage while retaining the one-byte fallback; this fix uses the complete span and needs a small textual merge with that call-site change. #10064 changes committed 3D slabs. The native-depth fixture additions in #6808/#9950 cover other behavior. None implements this full-span check.
Independent validation of the published commit: Published head 87bdf5445d747ddc76f0cedcb31579e9900aa9c1: 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.

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:4988268935 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10368). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-23T19:36:27Z. --- ### What A storage-image lookup without a precomputed surface size checked only its first byte against native multisample owners. A native depth surface inside a larger cached view was missed, so the cache could return stale guest bytes and keep the overlapping native owner active. Resolve the viewed surface's complete size before the overlap check and use that range before either the native-depth storage path or a cached storage lookup. The regression seeds a cached linear view, creates an unwritten native multisample depth surface inside it, checks a disjoint view ending at the depth boundary, then requires the complete view to retire the intersecting owner without changing guest bytes. ### Tested <!-- 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. --> Current-main refresh: upstream `main` `e05ba6feebd000cfc316c1d1f00e37e030aa3d8b`, submitted head `d1dc3a5920b5017e1b958151eca93479187fb75f`. Windows 11 Pro 10.0.26300, AMD Ryzen 9 7900X, 31.7 GiB RAM, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, pinned bundled dependencies. NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742; Khronos validation 1.4.363. - Full production relinker and libraries, patched-library fixture, graphics and focused GPU fixtures built successfully on the submitted head (`cmake --build <build> --target relinker libs patched_libraries_tests agc_driver_graphics_tests agc_driver_native_multisample_depth_tests agc_driver_sample_multisample_target_tests agc_driver_depth_storage_dispatch_tests agc_driver_native_depth_bda_clear_tests --parallel 8`). - Paired focused runs on this machine/GPU: clean main **9/9**, submitted head **9/9**, zero failures or skips. Both used `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ctest -j 1 -V`, and confirmed actual instance/device layer insertion. Neither log contains a missing requested validation layer, `VUID-`, or validation error/warning. Candidate selection: `^(patched_libraries|agc_driver_(graphics|native_multisample_depth|sample_multisample_target|depth_storage_dispatch|native_depth_(bda_clear|retirement|clears|clear_refusals)))$`. Main selection: `^(patched_libraries|agc_driver_(graphics|native_multisample_depth|sample_multisample_target|depth_storage_dispatch|native_depth_(bda_clear|retirement|clears|clear_refusals)))$`. - Conventions, strict current-main synchronization, whitespace, test registration and overlap checks completed. The existing prerequisite long-debt-entry warning is retained where reported; no convention errors. This is focused runtime validation, not the complete CTest suite or a new title run. The one original feature patch remains limited to two files. The conflict placed two independent fixtures at the same insertion point; main's `CheckDepthAttachmentAlias` and this PR's byte-identical `CheckStorageAliasRetirement` are now separate functions, and both run in the default native-depth case. The production patch still only resolves `viewedBytes` before the existing native-MSAA guard and cached/native-depth lookup. No prerequisite was added and shader instruction semantics are unchanged. The new regression executes on the selected GPU: an adjacent view ending exactly at the native-depth boundary retains that owner, while a larger cached storage span retires only the intersecting unwritten owner and preserves the guest bytes. Depth-storage dispatch and native-depth BDA clear checks are included in the paired selection alongside the shared native-depth/library/graphics cases. Earlier 47-check mixed-integration evidence below remains historical; it is not claimed for the rebased head. <details> <summary>Earlier submitted-revision evidence (historical)</summary> Windows 11 Pro build 26300, WinLibs GCC 15.2.0, Release, NVIDIA GeForce RTX 4070 Ti SUPER, NVIDIA 617.42. - Red: the added GPU case fails with `a cached storage view kept a native depth owner inside its range`. - Green: native depth and depth-storage dispatch checks pass, including the new cached-view/boundary case. Final integrated validation: 47 selected checks, zero failures/skips; full Windows Release build passes. - Vulkan required, shader caches disabled and actual Khronos instance/device validation layer insertion confirmed. No new VUIDs. - The new case uses an unwritten depth owner; it does not require the pending written-depth publication feature. The local PRAGMATA integration also contains #6743, #6782, #10304, #10351 and #9950; none is included in this two-file PR. - Conventions and whitespace pass. Game retest pending; no gameplay or performance claim. Full CTest suite not run. Overlap review: 31 shared-file PR diffs checked. #10049 adds overwrite coverage while retaining the one-byte fallback; this fix uses the complete span and needs a small textual merge with that call-site change. #10064 changes committed 3D slabs. The native-depth fixture additions in #6808/#9950 cover other behavior. None implements this full-span check. **Independent validation of the published commit:** Published head `87bdf5445d747ddc76f0cedcb31579e9900aa9c1`: 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. </details> ### 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 19:38:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T19:38:32Z.

Review: APPROVED


Reviewed current head 87bdf5445d747ddc76f0cedcb31579e9900aa9c1. Resolving viewedBytes before RequireNoMultisampleTarget closes the first-byte-only gap for callers that have not precomputed a surface size, and the check now precedes both native-depth storage handling and cached lookup. The regression exercises an overlapping cached range and an adjacent disjoint range ending exactly at the native depth boundary, then checks owner retirement and byte preservation. The author reports 47 focused Windows GPU checks with Vulkan required, shader cache disabled and validation layers confirmed, no new VUIDs; I did not run the GPU test locally. Hosted eligibility, conventions, intake, labels and report pass; product jobs are skipped by path policy. git diff --check upstream/main...upstream/pr/10368 passes. I found no blocking issue.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5633554224 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10368#pullrequestreview-5633554224). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T19:38:32Z. **Review:** APPROVED --- Reviewed current head 87bdf5445d747ddc76f0cedcb31579e9900aa9c1. Resolving `viewedBytes` before `RequireNoMultisampleTarget` closes the first-byte-only gap for callers that have not precomputed a surface size, and the check now precedes both native-depth storage handling and cached lookup. The regression exercises an overlapping cached range and an adjacent disjoint range ending exactly at the native depth boundary, then checks owner retirement and byte preservation. The author reports 47 focused Windows GPU checks with Vulkan required, shader cache disabled and validation layers confirmed, no new VUIDs; I did not run the GPU test locally. Hosted eligibility, conventions, intake, labels and report pass; product jobs are skipped by path policy. `git diff --check upstream/main...upstream/pr/10368` passes. I found no blocking issue.
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!10368
No description provided.