fix(agc): import registered ranges larger than the device's largest allocation in pieces #7292
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7292"
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 billythemenace2 on 2026-10-17T21:41:30Z.
Requested by billy
What
An address-based build (
AcquireRegistered) imports each registered range as one host import. On a device whosemaxMemoryAllocationSizeis smaller than the range, that import fails atvkAllocateMemory. AMD's Windows driver reports 2 GiB, and the import fails withVK_ERROR_INVALID_EXTERNAL_HANDLE. The build then asks for a heap mirror of the same size, which fails as well and stops the title. Astro's Playroom (PPSA01325) on an RX 5700 XT stops this way a few seconds in, on a 6.4 GiB range:VkPhysicalDeviceMaintenance3Properties::maxMemoryAllocationSizenext to the host import properties and passes it toSetHostImportMaxBytes.importPieces). Each piece is a run of the range window's cells no larger than the limit, imported throughimportAllocationwith an end, as access windows already are. Each piece is a region of its own with its own BDA table entry, served in place. If any piece can't be imported, the build falls back to the existing path, as before.importRunAtno longer attempts a single import larger than the limit, which the driver would refuse anyway.Tested
agc_driver_graphics,agc_driver_bda_deviceandagc_driver_bda_span_readspass. The newimportPiecesOverAllocationLimitTestsregisters a 5-window range with the limit at 3 windows. It checks that the BDA table covers the range with entries no larger than the limit, each served in place by an import within the limit. It fails without the change ("a BDA table entry of a range over the allocation limit is larger than the limit").APS5_HOST_IMPORT_MIB=12288andAPS5_TRACE_HOST_IMPORT=1: its 2.2 GiB range0x1000000000+0x8a800000is now imported as0x7c000000+0xe800000, where before it was refused or mirrored. The first 1.9 GiB piece of the 6.4 GiB range is then refused by the driver at 5.8 GiB of live imports, because the host heap on this machine is 7.6 GiB (15 GiB RAM). So the title still stops at the same heap mirror here. A machine with more RAM should get past it, but I can't test that.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 fma-rc on 2026-10-17T23:38:07Z.
I ran the new test on a Radeon 680M (RADV, Linux) against current main
98c251fc62, 3 runs each. With only the test and theSetHostImportMaxBytessetter applied (the setter stores the limit, nothing reads it),agc_driver_graphicsfails every run witha BDA table entry of a range over the allocation limit is larger than the limit. With the whole PR it passes 3/3, and main without the test passes 3/3.So the test does catch the missing split. RADV here reports
maxMemoryAllocationSize= 0xfffffffc (the RTX 5080 reports no limit), so Linux AMD is under the 6.4 GiB range too. A 180 s Playroom boot on main on the 680M logged no failed host import, though. I'll run Playroom on main and on this PR on the 680M for longer and add what it shows.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-18T10:24:20Z.
Rebase handoff — rebased onto current
main(authorship unchanged). One conflict inGuestBufferMemory.hpp:main's newerSetHostImportDeferredSettlesdeclaration kept alongside yourSetHostImportMaxBytes.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; full suite green apart from the knownmainregression (agc_driver_tessellationsegfault — Mesa, #5444), not this PR.To pick it up:
Head is
c1d5a013b.Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-18T15:24:23Z.
@fma-rc thank you, that's the check this needed: the test fails with only the setter applied and passes with the whole PR. Good to know RADV on the 680M reports
0xfffffffc, so ranges over 4 GiB hit this on Linux AMD too. A longer Playroom run on main and on this PR would be very welcome.@blawesom thank you for the rebase. I redid it here on
maine5f18ea99with the same resolution, keepingSetHostImportDeferredSettlesbesideSetHostImportMaxBytes. The patch is identical to yourc1d5a013b.agc_driver_graphicsand the conventions check pass on the RX 5700 XT. The branch is now at0a98bd0a5.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-19T16:29:19Z.
Rebased onto
main32004dfa5. The only conflict was inGuestBufferMemory.hpp:main's newHostImportBudgetdeclaration now sits besideSetHostImportMaxBytes.agc_driver_graphicsand the conventions check pass on the RX 5700 XT. The branch is at4a27917d0.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-20T15:52:03Z.
Rebased onto
maind073fe6a1, now atfa61ee5dc.mainadded the covering-import shortcut and theImportRequesterargument in the meantime. A range still served by the covering import of an earlier range keeps that import. A range over the allocation limit goes toimportPieces, whoseimportAllocationcalls passImportRequester::Build. The size guard inimportRunAtsits before the newstepDownfailure check.agc_driver_graphics,agc_driver_bda_device,agc_driver_bda_span_readsand the conventions check pass on the RX 5700 XT.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-21T08:14:48Z.
Verified on a second AMD Windows driver branch: Radeon 860M (RDNA 3.5,
1002:1114, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0, Release.vulkaninforeportsmaxMemoryAllocationSize= 0x80000000, the same 2 GiB as the RX 5700 XT.I merged
fa61ee5dcontomainec7eacc62(clean merge, one auto-merge inBdaResources.cpp). WithANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1,agc_driver_graphicspasses, includingimportPiecesOverAllocationLimitTests, and so doagc_driver_bda_deviceandagc_driver_bda_span_reads. No title I have here registers a range over 2 GiB, so I have no title run to add.Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-21T19:18:08Z.
@LeandroLP23 thank you. A second AMD Windows driver branch (RDNA 3.5) reporting the same 2 GiB
maxMemoryAllocationSize, withimportPiecesOverAllocationLimitTestspassing, is exactly the coverage this needed.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T00:45:06Z.
@billythemenace2 a merge-order note: #9514 changes the plain import in
AcquireRegistered, next to the branch this PR adds for a range larger than the device's largest allocation. When the host import budget refuses a range, #9514 retries the import with eviction, and only when copying the range would take the build pastAPS5_ADDRESS_COPY_MAX_MIB. Your piece import stays as it is, so the two should compose. As this one is a draft, #9514 proposes going first, and this PR would rebase over it. If you'd rather this one went first, say so and #9514 will list it under Depends on.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:05:43Z.
I am reviewing #9514, which changes
AcquireRegisteredadjacent to #7292’s piece-import path. Its author proposes #9514 first and then rebasing #7292, arguing that a piece-served range avoids the budget-refusal retry. Please confirm whether that order is safe for #7292, or specify the sequence you need, so the two PRs can record the agreed order before merge.Imported from boykopovar/AnyPS5. Originally posted by billythemenace2 on 2026-10-22T14:08:44Z.
@EagleBearerYS @MarcZX10 yes, #9514 first is safe, and I'll rebase this over it. The two paths don't overlap. This PR only changes the branch for a range larger than
maxMemoryAllocationSize, which never reaches the plainimportAllocationthat #9514 retries with eviction. Its pieces go throughimportPieces, withevictfalse as before. If a piece is refused by the budget, the whole range falls back to the existing mirror and copy path, so the cap #9514 checks still applies there.One possible follow-up once both are in: let
importPiecesuse #9514's eviction retry for a refused piece. I'd keep that out of both PRs.I'm marking this ready for review. It's been checked on two AMD Windows driver branches (RDNA1 and RDNA 3.5) and on RADV.
AI-assisted (Claude Code).