fix(agc): check registered image views in one registry lookup #15971
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15971"
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 ItsJustChrisE on 2026-11-05T04:20:34Z.
What
registeredImageViewsCurrent(ShaderResources.cpp) andCaptureRegisteredViewsCurrent(DispatchCache.hpp, also used byShaderMemory::snapshotCurrent) looked each registered image view up one at a time. They accepted the result only if the globalGuestAllocationsGenerationcounter didn't move during the pass, with two attempts. Every mutation of any guest allocation, on any thread, bumps that counter. So a title that maps and unmaps memory continuously fails the check even when none of the views changed.buildCompletethen throwsregistered image range changed after resource preparation, which aborts the title.Street Fighter 6 (PPSA02632) hits this about a minute after start-up, while its eight
ResourceManager::parallelProcthreads stream data. A temporary probe showed that the single view matched its captured range on every pass while the counter moved 35–58 times per pass, until both attempts were used up.The fix adds
GuestAllocationsLookupEach_nid_postfixto libc. It looks up a list of addresses while holding the registry lock once, using the same rule asGuestAllocationsLookupwithoutnext. Both helpers now compare all views against that one snapshot, so they no longer depend on the counter. A real change is still detected: a view's range removed, remapped with a new backing serial, or changed in extent or protection. The two helpers stay separate copies, as before.New test
agc_shader_registered_view_churn(agc_shader_memory_tests --registered-view-churn): one thread maps and unmaps an unrelated range nonstop while the main thread checks three views of one registered range 20,000 times. Every check must accept. The test then removes the range, maps it again, and checks views with the old and the new backing serial.Tested
Windows 11 Pro 10.0.26300, Ryzen 7 7700X, NVIDIA GeForce RTX 3080 (driver 610.88), WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON,ANYPS5_AGC_EXECUTION_TESTS=ImageArrayRowsPastLayerLimit;ImageTableCache;ImageTable;GuardedNullPointer.Focused tests on
main8bfe082f60with only the new test added, and on this change on the same base, each run withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_GPU="RTX 3080"(Vulkan SDK 1.4.363.1):agc_shader_registered_view_churnagc_shader_memoryagc_shader_nested_snapshot_retryagc_shader_table_snapshot_reuseagc_shader_table_snapshot_reuse_unmaskedagc_driver_image_array_rows_past_layer_limitagc_driver_image_tableagc_driver_image_table_cacheagc_driver_guarded_null_pointerWith
VK_LOADER_DEBUG=allthe loader reportedInsert instance layer "VK_LAYER_KHRONOS_validation". Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS(the runs usedVK_LOADER_DEBUG=error, so the loader would have printed it), and neither log contains aVUID-line or aValidation Error/Warningline. After rebasing onto4639eff7f4,agc_shader_registered_view_churn,agc_shader_memoryandagc_driver_image_array_rows_past_layer_limitwere rebuilt and passed again with validation, with noVUID-lines.Street Fighter 6 (PPSA02632, 01.000.000) on Windows, with #15945 for its
Party.prx. Cross was sent throughAPS5_PAD_INPUT_FILEevery 15 s after the first minute, same machine and GPU, warm shader cache:mainacac7c8541+ #15945, with a logging-only probe inregisteredImageViewsCurrent: aborted after 66 s withregistered image range changed after resource preparation(0xc0000409). An earlier manual run of the same build without the probe aborted the same way after the Capcom logo.8bfe082f60, withParty.prxfrom #15945: ran for the full 480 s cap with no abort and nonot implementedline, ending at about 93 presents per 10 s.tools/check_conventions.py --base origin/mainpassed.tools/pr_overlap.pylists 12 open PRs that share these files. I checked their diffs: none changes either helper or adds a batch lookup. #13809, #13928 and #13929 readGuestAllocationsGenerationonly for their own cache stamps.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
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T15:13:41Z.
Review: APPROVED
@ItsJustChrisE looks right. Looking every view up under one hold of the registry lock gives the same consistent snapshot the generation check was after, without depending on unrelated mappings. The field comparison that catches a real change is unchanged, and so are the reads of the returned ranges after the lock is released. I see no new lock ordering:
GuestAllocationsLookupEach_nid_postfixtakes the same registry mutexGuestAllocationsLookup_nid_postfixtook.What I ran
Head
5f67111fe4merged ontomain78e4248fea(clean merge), Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT (AMD Software 26.10.2, driver 32.0.32015.12012). Your nine tests,ctest -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, test executables rebuilt:main'sDispatchCache.hppandShaderResources.cpp, with your testagc_shader_registered_view_churnagc_driver_image_array_rows_past_layer_limitVUID-check_conventions.pypasses.pr_overlap.py --branchfinds no PR it could compare; the 60 that share these files conflict withmain.Non-blocking: both helpers now allocate two vectors per check. If that ever shows up in a dispatch-heavy trace, a small fixed buffer for the common one-to-three-view case would avoid it; I haven't measured it.
Approving.
AI-assisted: yes (Claude Code)