fix(agc): retry failed host imports after range replacement #1357
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1357"
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 TibixDev on 2026-10-08T00:10:27Z.
What
Retry a rejected host import when any registered owner of its span is replaced at the same address, or when the span changes. Failed decisions retain weak owner identities and their full extent, so they cannot pin freed allocations. An unchanged failure stays cached across unrelated mapping changes.
Narrowed to the remaining correctness issue on main
d146ec1b6: this is now two files, independent of #1324. Main already contains import retirement/lifetime handling, adjacent-range imports (#3158), Windows alias fallback (#3324), and aligned import windows (#3425); those implementations are preserved. The earlier stacked span-import optimization and its performance claims are removed from this PR. No duplicateClearHostImportsor stale Windows early-return implementation remains.Tested
Fedora 44, GCC 16 Release. The new graphics fixture injects a failed Vulkan allocation, checks repeated failures and an unrelated mutation do not retry, replaces either the first or second span owner at the same address, and checks the retry succeeds without pinning the old owner. It also covers shrinking a failed span to its surviving range.
With unchanged main
GuestBufferMemory.cppand this fixture, graphics tests fail withsame-address remap retained a failed import decision. Restoring the fix passes. Six focused CTests pass: graphics, guest memory, import unmap, storage upload lifetime/failure, and descriptor pool recycling. The Vulkan integration cases ran on RX 6600/RADV with core/synchronization validation; the injected-failure fixture uses mock Vulkan. Conventions and whitespace checks pass.No title speedup or Windows result is claimed. A separate current-main Skyrim boot stops at unsupported NGS2 reverb channel conversion before a usable frame-time comparison; it does not establish title impact of this fix. Full platform CI and maintainer re-review remain.
Checklist
d146ec1b6; overlapping upstream work checked.Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T07:25:57Z.
Rebased on
eaa6ccea. Integrated #1051’s Linux writable-range check with the owner-aware failure cache. This fixes the compile error in GitHub’s merge build. Kept #1113’s byte budget and the import lifetime/remap fixes.Fedora 44 Release:
agc_driver_graphics_tests,guest_memory_tests,agc_driver_recorder_tests,agc_recorder_kept_bytes_testsbuild; the targeted tests and contribution checks pass. Windows CI is pending.RADV and lavapipe:
--shared-import-onlypass with core and synchronization validation; no validation errors.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-08T10:17:22Z.
Heads-up: this branch no longer compiles when merged onto
main(I tried30e89cc6while building #1359 on Windows to test it). #1239 merged at 09:27 UTC, after this branch's last CI run, and added its ownClearHostImports(VkDevice)toGuestBufferMemory.cpp(L1121 onmain). The merge is textually clean, so GitHub still shows it as mergeable, but the build fails:redefinition of 'void AgcDriver::Graphics::ClearHostImports(VkDevice)', because both versions are present.main's version callsstate.destroyBufferandstate.freeMemory, which this branch'sHostImportsno longer has.main's version also unmapsentry.alias.#1359 carries the same commits, so it fails the same way. Since the description says this supersedes #1239, I think the rebase only needs
main's copy removed or folded into this branch's release path. I haven't tested anything further on Windows.Imported from boykopovar/AnyPS5. Originally posted by Angel21PC on 2026-10-09T13:33:57Z.
On Windows, spans are still refused here (
importRangereturnsnullptrunder_WIN32). Part of what they need there doesn't depend on this PR, so I opened #2254: a read-write alias of shared views that are not one contiguous run of a section is mapped run by run into a placeholder reservation instead of being refused.Once both are in, the
_WIN32early return can go. A span whose alias still fails (mixed private and shared pages) would then need to be marked failed instead of throwing. I can send that follow-up, unless you'd rather fold it in here.In Poppy Playtime: Chapter 4 (UE5) on Windows, views crossing adjacent registered ranges were being copied (about 158 GB per 10 s of gameplay). Importing them over the span cut that to about 260 MB of reads and roughly doubled the frame rate (local build with other open PRs).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:39:37Z.
Review: DISMISSED
Thanks for the work here. This can't be merged as is:
mainitself (GuestBufferMemory.cpp). Nothing here can land before it.maininVulkanDevice.cpp,GuestBufferMemory.{hpp,cpp},Texture.cpp,tests/Recorder.cpp,GuestAllocations.{hpp,cpp},DirectMemory.cpp,tests/GuestMemory.cppandTechnicalDebt.md. These touch the import/lifetime logic, so they need the author to resolve them, not a mechanical rebase.importRangereturnsnullptrunder_WIN32), see @Angel21PC's comment and #2254. Please say how this PR and #2254 combine, or keep the limitation documented in TechnicalDebt.Please rebase once #1324 is merged (or fold the stack in a way that keeps one topic per PR) and we will review it again.
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T04:37:30Z.
@adriadam10 @popcoder565 Narrowed and rebased onto main
d146ec1b6: this is now only the failed-import remap fix (two files), with no #1324 prerequisite. Main already supplies retirement/lifetime handling, span imports (#3158), Windows alias fallback (#3324), and aligned windows (#3425). Those stay intact; the old stack, duplicate teardown and span-performance claims are removed.The remaining bug reproduces independently: a failed import is keyed only by base address, so replacing either range in a span can leave the new backing permanently rejected. The new fixture injects a failure, checks unchanged/unrelated mappings keep it cached, then replaces each owner and shrinks a span. Unchanged main fails
same-address remap retained a failed import decision; the fix passes and weak failure records do not pin old owners.Six focused CTests plus conventions/whitespace checks pass on Fedora 44; native integration cases ran on RADV with core/synchronization validation. No fresh Windows or title-speedup claim. Full platform CI and re-review remain. AI-assisted implementation and validation.