Skip to content

fix(agc): mirror only unimported tails of registered heaps - #8380

Open
Zenodeon wants to merge 2 commits into
boykopovar:mainfrom
Zenodeon:agc-budgeted-host-imports
Open

Zenodeon wants to merge 2 commits into
boykopovar:mainfrom
Zenodeon:agc-budgeted-host-imports

Conversation

@Zenodeon

Copy link
Copy Markdown
Contributor

What

A registered heap that cannot be imported within the host-import budget currently falls back to a mirror of the entire registration. This duplicates bytes already serviceable by smaller imports. A remembered budget refusal for the full registration can also reject a later request for a smaller physical window.

Keep the prefix served by existing or fitting import windows, and mirror only the remaining tail. New requests use the existing import-window size, keeping their temporary import snapshots small. Refusal lookup and window construction share the same physical-bound calculation. Selected mirrors retain the original weak registration identity; GPU/CPU write-back, mapping retirement and recorder completion rules remain in force. The configured import budget and strict unsupported paths are preserved.

Stacked on #7292, authored by billythemenace2 (original topic 4a27917d095f), rebased with its attribution retained. Its allocation-limit splitting is the prerequisite; the additional budget-limited partial fallback is this PR's change. Related: #7844 changes the default import reserve; #8016 changes mirror backing/staging and overlaps the allocation site. #6918 has a shared test-registration insertion. None of those implementations is included here.

No game-specific behavior, shader semantics changes or guest API changes.

Tested

Windows 11 Pro 10.0.26200, NVIDIA RTX 4070, driver 610.88; MinGW-w64 GCC 15.2, Ninja Release, SPIR-V Tools enabled.

  • Negative control: main 02fb1ce53 plus fix(agc): import registered ranges larger than the device's largest allocation in pieces #7292 and the new regression, without this fix, fails at a heap exceeding the import budget did not import its fitting prefix.
  • The fixed synthetic case checks import-budget admission, exact mirror extent, full-mirror replacement, first/last mirrored bytes, genuine CPU writes, GPU-result write-back, a short final window, untouched unregistered neighbors, unrelated neighboring writes and registration retirement. A 384 KiB registration with 256 KiB available for imports retains a 128 KiB mirror instead of a 384 KiB mirror. This is a logical mirror-footprint check, not an RSS benchmark.
  • All 10 focused cases pass on clean main 8afd6ea47 and candidate 9a20ec2b8, including native GPU BDA span reads, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Logs were checked for missing-layer warnings and VUID- errors. There were no skips, missing-layer warnings or VUID- errors on either arm; every individual case completed below 30 seconds.
  • Complete matching runtimes and converters were frozen locally. Ccleste starts, renders and exits normally on the previous-base main (02fb1ce53) and candidate (acb7d0c91) runtimes, and on the rebased candidate (9a20ec2b8).
  • Astro's Playroom (PPSA01325) candidate smoke on the previous base (acb7d0c91) reached the opening room and rendered Astro on foot after movement input. It subsequently aborted with ShaderRecompiler::Recompile: std::bad_alloc while system commit was exhausted. Extended gameplay and bounded-memory stability are not passed. The rebased head does not yet have a new full gameplay pass.

This draft makes no FPS, sustained RSS improvement, or complete Astro memory-pressure fix claim. Runtime configurations, logs, shader dumps and evidence bundles are not included or uploaded.

Target-base conventions and diff checks pass. The required check against the fork's older origin/main hits Windows' argument-length limit; running that same checker through a pattern-file adapter identifies inherited upstream findings in unchanged files and commit subjects. The adapter and logs are local only.

Checklist

billythemenace2 and others added 2 commits October 20, 2026 15:18
…llocation in pieces

An address-based build imported each registered range whole. A range larger
than maxMemoryAllocationSize (2 GiB on AMD's Windows driver) failed at
vkAllocateMemory, and the build then asked for a heap mirror of the same size,
which failed too. Such a range is now imported in pieces no larger than the
limit, built from the range window's cells, each one BDA table entry.
Single imports above the limit are no longer attempted.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 20, 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 7647 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L2675-2676, L2684-2687, L2692-2693, L2719-2721, L2770-2777
PR 8016 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp L2692-2696, L2702-2709
PR 8963 core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp L2057

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 1191 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 2434 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4072 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 4449 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5021 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 5372 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 5431 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5441 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5499 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6146 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6202 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6290 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6548 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6628 core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6788 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6887 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6918 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6947 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6960 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6965 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6973 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6977 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6987 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6989 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6995 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7002 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7201 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 7275 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7449 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7484 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7514 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 8004 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8014 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8105 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8212 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8278 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 8612 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp

@github-actions github-actions Bot added the agc libSceAgc* label Oct 20, 2026
@Zenodeon
Zenodeon marked this pull request as ready for review October 20, 2026 13:46
@TheSovietWaffle

Copy link
Copy Markdown
Contributor

AMD data point: RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (1002:164e, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head 9a20ec2b8: agc_driver_graphics (which includes the new BdaResources.cpp cases) passes 3 of 3 on both GPUs.

AI-assisted: yes (Claude Code).

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*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants