fix(agc): refuse the fast revalidation of a sampled texture whose memory became a depth target #11444
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11444"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Sam-mon7 on 2026-10-26T13:45:36Z.
What
Registering a depth surface over guest memory leaves the guest bytes and their write stamps unchanged. The fast revalidation of an ordinary sampled texture whose base address a depth surface now starts at therefore still proved it unchanged and reused the old texture, while a fresh lookup returns the depth owner.
Both sampled-texture fast paths, the epoch path (
fastRevalidate) and the per-surface path (fastRevalidateEach), now check depth ownership after the memory and pending-overlap proofs:DepthSurfaceCanSample: the surface starts at the texture's base and its size, format and layout are onesDepthSurfaceTextureaccepts) fails the proof asFastFail::SampledDepth, andRevalidatereturns false without a full walk, so the set is rebuilt and the lookup takes the depth owner;FastFail::Depth(the full lookup's resident-depth guard checks overlapping ranges);main's fast, own-source and T1 paths, with no full walk.agc_driver_sampled_depth_transitionsamples a surface, registers a depth target over it without writing it, and checks that the resources no longer revalidate and that a rebuilt set takes the depth owner.agc_driver_sampled_depth_overlapbuilds an ordinary snapshot inside a live single-sample depth surface's memory at a different base and checks that it stays on the fast proof.agc_driver_sampled_depth_size,_format,_retryand_own-sourcecheck that a same-base surface that cannot serve the descriptor keeps the fast, T1 or own-source path with zero full walks. The_eachvariants run withAPS5_NO_EPOCH_REVALIDATE=1.agc_driver_revalidation_profilechecks the[revalidate-work]and[revalidate-slow]lines thatAPS5_PROFILE_DRAW=1prints per fast-fail reason (walks, walk time, descriptors, bytes, uploads, refreshes and waits). The tests are registered intests/cmake/agc_driver_partially_resident_snapshot_tests.cmake.Found while running Demon's Souls (PPSA01341) on a local branch, where a sampled texture's memory later became a depth target; the fix is generic.
Overlap: #10064 touches the same test fragment,
PartiallyResidentSnapshot.cppandTexture.cpp. A merge preview of the two heads conflicts only in include lists and in theTexturesnapshot constructor's first lines (#10064 adds a parameter, this PR a timing scope). Both sides can be kept in either merge order, so neither PR depends on the other.Tested
Windows 11 Pro 10.0.26200, WinLibs GCC 15.2.0, Release, NVIDIA GeForce RTX 4070 (driver 610.88). Branch merged with
main0d5e03be8cas21f79f1d3a; the revalidation fix itself is unchanged fromfc5679f3ea.ctest -R 'agc_driver_(sampled|partially_resident|large_tracked|untracked_snapshot|compared_shared|depth|dcc|clear_snapshot|image_table|template|revalidat|cached_image|resource_cache|fast_revalid|epoch)|agc_driver_native_(multisample_depth|depth_retirement|depth_clears|depth_clear_refusals)|agc_multisample_guest_access' -j2 -V, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.main0d5e03be8c: 61/61 pass.21f79f1d3a: 72/72 pass (the same 61 plus the 11 tests this PR adds).VUID-or a missing-validation-layer message;VK_LOADER_DEBUG=layershows the loader insertingVK_LAYER_KHRONOS_validation(SDK 1.4.363.0).DepthSurfaceCanSamplerefusals removed,agc_driver_sampled_depth_transitionand_transition_eachfail (sampled resources reused a stale texture after depth registration without a guest write); the other 14 partially-resident and sampled-depth tests pass. (The new tests do not build againstmainalone: they readProofReport::fullWalksand the new profiling counters.)python tools/check_conventions.py --base 0d5e03be8cpasses;git diff --checkis clean; the build has no warnings in the files this PR changes.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Performance and Diagnostics
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T13:48:03Z.
Review: CHANGES_REQUESTED
I reviewed the implementation and regression coverage. The new overlap check makes both epoch and per-surface sampled-texture fast paths fall back when an active depth surface now covers the sampled memory, and the test verifies the next lookup takes the depth owner without relying on guest writes.
tools/check_conventions.py --base upstream/main --head upstream/pr-11444andgit diff --check upstream/main...upstream/pr-11444pass.The branch is still based on
7b415520b607, while currentmainis9656d366be90(two commits ahead). The intervening changes do not modify the implementation or test source, but they do update the AGC CMake file where these tests are registered. Please sync this branch to currentmain, then rerun the focused Vulkan-validation comparison and conventions on the resulting tree. Hosted product jobs are skipped by path policy, so they do not independently validate these AGC changes. The current report is useful but is still for the older base; I am requesting changes for the current-main/test validation requirement.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T07:53:36Z.
Review: COMMENTED
Linux NVIDIA and lavapipe run on a current
main. The runs so far are Windows only (RTX 4070, RTX 4070 SUPER, GTX 1650 SUPER, Radeon iGPU).Setup: Ubuntu 26.04, GCC 15.2, Release. RTX 3070 (NVIDIA 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), each selected with
VK_DRIVER_FILES. Head0588244e7merged with--no-commitontomainb7105f728(clean, including the AGCCMakeLists.txt; it also merges cleanly onto8df2c3ed0). Focused runs useANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos layer 1.4.341).VK_LOADER_DEBUG=layershows the layer inserted, and no log has the missing-layer message.main+ only this PR'sCMakeLists.txtandPartiallyResidentSnapshot.cpphunks):agc_driver_sampled_depth_transitionandagc_driver_sampled_depth_transition_eachfail on both devices withsampled resources reused a stale texture after depth registration without a guest write.^agc_driver_(sampled|partially_resident|large_tracked|untracked_snapshot|compared_shared|depth|image_table|resource_cache)(46 tests) is 46/46, 3/3, on each device, includingagc_driver_depth_plane_partial_store. 0VUID-.^agcsuite (without display/flip/lds_atomics64,-j1 --timeout 30): 3070 1044/1044; lavapipe 1043/1044. The only failure isagc_driver_multisample_retirement, which fails the same way onmainon this host.sizeofasserts inShaderDiskCache.cppandPipelineJournal.cpphold.public_headerspasses withmain8df2c3ed0.GPUs tested: NVIDIA RTX 3070 (Linux), lavapipe
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:10:40Z.
Review: CHANGES_REQUESTED
Rechecked exact head
1d53c28ddbafter the requested main sync and paired Vulkan run. The implementation still usesDepthSurfaceAt(base)in both fast revalidation paths and retains overlap refusal for multisampled surfaces; the author-reported test coverage and hardware runs are useful. Currentmainmerges cleanly, andgit diff --checkpasses. However, current main has since changed the sharedDepthSurface.hpp,DepthSurface.cpp,ShaderResources.cpp, and AGC CMake registration paths since the reported basee2a5118839. The PR's central decision now depends onDepthSurfaceAtand the depth guard, so the old paired run does not validate this combined state. Please update to current main and rerun the focused Vulkan-validation comparison on both trees, recording the exact commits. I did not run the GPU tests locally; the specialized hosted jobs are skipped. Changes remain requested until that integration evidence is available.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T00:51:44Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The updated fix has focused coverage, but it still conflicts with current
mainin three implementation files, so the reported test run does not verify an integrated current-main head.What I ran
Reviewed PR head
fc5679f3ea7eca5216289cc4d6199570c1a89f0eagainst currentmain76fd1c09e9be0465d50a7431a79d371a5a10abb2. The merge preview found conflicts and did not produce a clean integration. Environment: Linux; no compiler or local tests were run.Results
Graphics/include/ShaderResources.hpp,Graphics/src/DepthSurface.cpp, andGraphics/src/ShaderResources.cpp.git diff --check466bf10f7f; I did not rerun them. That base is older than current main and cannot resolve the conflicts found above.Unedited merge-preview and conventions output
Unedited hosted check output for this head
Findings
Blocking
The merge preview against current
mainconflicts in the three files that contain the revalidation logic, so the changed implementation has not been validated as an integrated current-main head. Please integrate the current base, resolve those conflicts while preserving the updated depth and overlap behavior, and rerun the focused tests on the resulting head.Not verified
I did not run a build, tests, GPU checks, or a current-main merged test preview because the source merge conflicts. The focused results above are author-reported for the PR head against the older base named in the report.
To get this to a good state
Please update the branch to current
mainand post the exact new head plus focused test results. I will recheck the merge, conventions, and the same relevant tests on that head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T07:26:04Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes address the sampled texture transition; I found no verified blocking defect, but the review is incomplete because I could not run checks and one changed file was excluded from the prepared bundle.
What I ran
Reviewed head
8ecc5b00f5d16041d9a98d79fbd7368a9299295f. No commands or tests were run; the reader script was unavailable as a shell command in this session. I inspected the prepared description, commits, manifest and diff, plus targeted ranges inDepthSurface.cpp,ShaderResources.cppand the excludedTexture.cpp.Results
Texture.cppwas excluded from the bundleFindings
Blocking
None verified in the inspected code.
Non-blocking
None.
Not verified
The author reports 72/72 focused tests passing, a successful red/green check, and clean convention and diff checks; these results were not independently verified. The four
Texture.cppadditions were visible in the diff and their corresponding ranges were inspected through the reader, but the file was excluded from the prepared bundle. The remaining contents of changed files and console behavior were not verified.Files read:
description.md,commits.md,manifest.json,diff.patch; targeted ranges inDepthSurface.cpp,ShaderResources.cpp, andTexture.cpp. The other changed files were present in the bundle, but their full text was not read. Excluded by bundle rule:Texture.cpp.To get this to a good state
Nothing is required. Optional: run the focused tests on this exact head and inspect the complete
Texture.cppdiff in repository context.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-01T14:15:23Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: the fast proof must recognize depth-bit descriptors that the full depth lookup accepts.
What I ran
Reviewed the prepared diff and targeted source ranges at head
e462885cc24c68a1d9e9ddd80b264e9a8892965a. No tests, builds, or merged-preview checks were run. The PR description reports a merge withmainand its test results; these were not independently verified.Results
Negative control
Not run by the reviewer. The description reports red/green results for the float-format transition tests; no depth-bit transition control is reported.
Findings
Blocking
DepthSurfaceCanSamplecallsSampledAccepts({}, resource), so itsdepthBitscheck is always false, then callsPlaneTextureAccepts(resource, false). For a single-sample D32 surface with a depth-bit descriptor usingFormat32UIntorFormat32SInt, the fast proof can therefore miss the depth owner and reuse the stale sampled texture. The full lookup passes descriptor words toDepthSurfaceTexture, where the same depth-bit layout is accepted. Pass the descriptor words or equivalent depth-bit metadata into the fast ownership check, and add a transition test for this case. Changed lines:core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:3068andcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:3070.Non-blocking
None.
Sources
DepthSurface.cppat the reviewed head —SampledAcceptsenables depth-bit acceptance only when descriptor words are supplied.DepthSurface.cppat the reviewed head —DepthSurfaceTexturedetermines depth-bit acceptance from the descriptor words.ShaderResources.cppat the reviewed head — the full sampled lookup tries the depth surface before its ordinary texture path.Not verified
No tests, build, Vulkan validation, or console behavior were run. All 12 changed paths were reviewed: 11 head texts were available in
files/;Texture.cppwas inspected through targeted ranges withrepo_read.py.files.jsonlists no excluded paths.To get this to a good state
Pass the descriptor’s depth-bit information into
DepthSurfaceCanSampleand add a regression test that registers a D32 surface over an unchanged depth-bit sampled texture. Then rerun the focused transition and revalidation tests on the updated head.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T14:17:53Z.
Review: COMMENTED
Actionable comments posted (2)
d6a513da-1077-4e7a-9edb-fcac7db961bbReviewing files that changed from the base of the PR and between
184c5100c1ande462885cc2.core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DeferredDestruction.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Resources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_partially_resident_snapshot_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/PartiallyResidentSnapshot.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.