Skip to content

perf(agc-driver): join the imports of adjacent ranges of any size that a buffer is bound exactly over - #4517

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
AlxcBTW:perf/host-import-join-exact
Oct 14, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
AlxcBTW:perf/host-import-join-exact

Conversation

@AlxcBTW

@AlxcBTW AlxcBTW commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Sword of the Sea (PPSA25344) loading: 16 MiB and 4 MiB buffers bound over several small adjacent registered ranges are imported once instead of copied on every use. CPU copies outside imports drop from 256-348 GB per loading run to 2.3 GB.

What

The join from #4515 imports adjacent registered ranges as one when a buffer is bound across them, but only when every range is larger than the 8 MiB window. The title's loading screen binds fixed 16 MiB and 4 MiB buffers whose backing is registered in two to six adjacent pieces with the same access, and some pieces are smaller than the window. A diagnostic build listed the first nine such regions of a loading run. Each one starts exactly at a range's start and ends exactly at a later range's end, for example:

  • 0x32609f0000+0x1000000 over 0xc60000 + 0x3a0000;
  • 0x304df90000+0x1000000 over 0x810000 + 0x70000 + 0x780000;
  • 0x32c7810000+0x400000 over 0x210000 + 0xd0000 + 0x20000 + 0x100000.

No import covers such a buffer, so every use copied it on the CPU.

Now joinedRun also joins a run of any range sizes when the bound region covers it exactly, from the first range's start to the last range's end:

  • Growing heaps. A heap grown in pieces matches only for a binding over exactly its current pieces. A binding that starts or ends inside a piece stays apart, as before, so growth beside an import never re-imports it. This is the churn the 8 MiB window was introduced against.
  • Unchanged. Runs whose ranges are all larger than the window join as before.
  • joinedCovers. It is used when a joined import retires (its shadowed units go back to the ranges still registered) and now accepts any adjacent run, so a unit inside a joined run of small ranges still counts as registered.

The TechnicalDebt entry for host imports names the new case.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Release, on top of #4515.

  • importJoinTests (in agc_driver_graphics, RTX 5070 Laptop): a new check binds a buffer exactly over two 64 KiB pieces of a partly filled window and requires one import of both. The existing check (a binding across them that starts inside the first piece stays apart) still holds. Passes; with the joinedRun change reverted, it fails with a buffer bound exactly over two pieces no larger than the import window was not imported as one.

  • Non-GPU suite (ctest -E "^agc_driver|^video_out|^guest_video"): 600 of 601 pass; log_macros fails as on main on that machine.

  • Sword of the Sea, New Game into the first scene (our lab branch: main plus local patches for this title, upstream default env, join on):

    Run CPU copies outside imports Frame reached
    without this change, 300 s 348,001 MiB 182 at t295
    without this change, 1800 s 256,453 MiB 653 at t900
    with this change, 900 s 2,282 MiB 982 at t895

    With the change, 83 imports log joined at bind, and the scene's picture shows from t420. Without it, the 1800 s run first showed it between its t300 and t600 captures. No GPU event or device loss occurred.

  • Conventions: tools/check_conventions.py passes.

Checklist

🤖 Generated with Claude Code

@blawesom

Copy link
Copy Markdown
Contributor

Pre-review found a deterministic test failure on Linux/RADV — flagging early since full CI doesn't run automatically on PRs.

Independent pre-review (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV GFX1201):

  • The PR builds and tools/check_conventions.py passes.
  • agc_host_import_retire fails 3/3 runs (deterministic):
AGC graphics: missing Vulkan function: vkCmdCopyBuffer

vkCmdCopyBuffer is core Vulkan 1.0 and present on this device, so the failure is in how the new code resolves it: the retire path calls context.Resolved(&DeviceFunctions::cmdCopyBuffer, ...) on a route where the test's context has no cmdCopyBuffer table entry and no deviceProc fallback — Context.hpp's Function() then throws. Worth checking whether the test context needs the table entry, or whether the call belongs on a layer that always has the resolver.

Everything else passes (949/950 — only this test).

Also worth noting: this PR contains all of #4515's commits (the "adjacent large ranges" version) plus its generalization — listing #4515 in Depends on (or closing it as superseded) would make the relationship explicit for reviewers.

Reproduce: ctest -R agc_host_import_retire --output-on-failure

@Scramblrrrr

Copy link
Copy Markdown
Contributor

Preparing a Windows 007 cross-test of your #4515 + #4517 heads7a99692b/da93351f. Our diagnostic run on0e981f4e (all public Sleg hull-v1 commits plus #4017/#1359/#3471) reaches rendered menu ~1.4FPS under APS5_PROFILE_DRAW=1, then black frames after Resume. Completed CPU-copy reads grow from340459MiB at menu to1281216MiB after ~5minutes loading; all counted outside imports. Sparse trimming/mirroring is already enabled. This is cumulative traffic, not resident RAM.

Source-only port https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-joined-import-cross-test head481d840452a34814d909f56099f15bfedfe2a4a6 is building now. Includes Angel21PC Windows non-contiguous alias87af6e09; our integration already has map-node retirement/KeepThroughHold/holder parking. Resolved conflicts preserving our end-aware single-range window imports, adaptive import budget/eviction, per-build pointer protection and #4017 unlocked-refusal handling. Author fixtures retained alongside our whole-range and relief fixtures. No new upstream PR, no claimed 007 benefit yet. I will report native checks and whether actual joined-at-bind imports reduce those copies. AI-assisted: Codex.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

Native checks completed on final adaptation c990fc1: nine targeted tests pass (graphics author join fixtures plus existing whole-range/relief cases; guest_memory Windows alias; copied/direct ordering; retirement/at-map; storage snapshots/upload; mid-hold import lifetime). Native lifetime fixture is mocked, not a GPU race reproduction. Exact-small-span negative control retaining all fixtures but refusing joinedRun's exact-span case fails specifically 'a buffer bound exactly over two pieces no larger than the import window was not imported as one'; restored9/9 pass, conventions clean.

Two adapter issues caught and fixed by retained fixtures: fresh end=0 lookup must not mark a shorter window as used before replacement; join boundary probes must not count as uses. Ordinary replacement/eviction retains per-build pointer protection; pre-confirmation joins use the existing extracted-node/KeepThroughHold lifetime and epoch invalidation, as in your branch. Runtime now staging graphics and the required Windows-alias libc only; originals backed up. Same warm cache and PROFILE_DRAW settings as preceding 007 diagnostic. No benefit claim yet. Final branch https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-joined-import-cross-test . AI-assisted: Codex.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

First 007 runtime signal on c990fc1 (still running, not gameplay): same PROFILE_DRAW config/warm cache as0e981f4e. At exactly34,000 resource builds, guest-memory upload drops29710→4890ms and image preparation39556→21716ms; bindings767→761ms/precollect2643→2561ms. Startup/autosave and health screens render2.05–2.10FPS versus preceding autosave1.62FPS. Last copy counter7,000operations/46,307MiB, and the old prominent0x3f10000000 copy bucket is absent so far. Cumulative traffic, not RAM; startup screen advancement/control timing differ, so not a whole-run copy ratio or playable-FPS claim. New private~16.4GB. No native builds during this run. Continuing to menu/Resume; I will report the result. Host-import trace was not enabled in this run, so no joined-at-bind diagnostic line yet. AI-assisted: Codex.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

007 runtime ended unexpectedly15:23:32 UTC on c990fc1, exit0xc0000005 (access violation), below memory guard limit. Last UI sampled15:23:06 was black frame1862~6.53FPS (~80s after Resume15:21:44); no visible level. Last private24.116GB/free5.943GB. Crash reported on guest RenderThread, read of0x40 with RSI=0; reported instruction location game-dump-modules.exe+0x17bd927 (not a native libSceAgcDriver frame). This identifies the detection site only; not attributing the invalid guest state to this PR. Local dump retained privately, no game instructions/data uploaded. Earlier unsupported image-table writeback pcs0x224/0xa4 still occurred. No debugger attached.

Performance lead remains: matched34k resource checkpoint upload29.710→4.890s, images39.556→21.716s; title/menu1.8–1.9FPS under profiling vs preceding1.4; load advanced quickly before the crash. Last CPU-copy counter20k/209740MiB, no0x3f10000000 bucket yet. Needs repeat/control to separate newly reached guest failure from integration regression. Will inspect locally and cross-test. AI-assisted: Codex.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

Alias-dependency control: old graphics0e981f4e with the same new libc5A176460..., same cache/PROFILE_DRAW settings. Matched34,000-build upload30391ms/images39932ms versus joined graphics c990 upload4890ms/images21716ms. Original old-graphics/old-libc run was29710ms/39556ms. Thus the required alias library alone does not explain the measured preparation gain. Large0x3f10000000 outside-import CPU-copy bucket returns (29,431MiB already during startup); title frame959~1.16FPS/private19.91GB. One run each, FPS not fixed-frame matched. Control is still running toward Resume, to compare the guest null-pointer crash. No native builds during measurements. A new synthetic GPU writer/copy check across two registered ranges is prepared but unbuilt/unpublished so far. AI-assisted: Codex.

@AlxcBTW

AlxcBTW commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

@blawesom fixed in #4385's 63ddeb0 (the Linux write-protection probe hit the test's mock device, not the retire path); details on #4515. Merged into this branch as 2a479b4.

AI-assisted: yes (Claude Code)

@Scramblrrrr

Copy link
Copy Markdown
Contributor

Windows follow-up: alias-only control (graphics0e981f4e, same new multi-section libc5A176460) ended deliberately15:46:59 UTC at black frame2015~0.07FPS, private28.16GB/free3.09GB. Same unsupported image-table operations reached, no logged access violation before shutdown. Completed CPU copies101k/1439788MiB cumulative. Matched34k resource builds: upload30391ms/images39932ms, close to original29710/39556; joined c990 was4890/21716. One run each; late progress differs, so absence of crash is not regression proof.

Added actual Windows Vulkan crossing-writer/copy test on fork head0d8bbef5712c3ed67dfc81a2ddbb47657a8a99c4: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-joined-import-cross-test . Dispatch stores across two adjacent registered ranges, requires one import covering output, then copies and checks bytes/boundary guards. Disabled large-range joining with fixture retained: FAIL at covering-import assertion0.39s; restored final2/2PASS0.65s, no skips. This tests that path, not the game's terrain readback race. Production remains c990; newest commit tests only.

@SleglJan Thanks for the crash breakdown. I will repeat quiet at6GiB first, with host-import diagnostics, then compare a larger budget if it recurs. Same signature suggests newly reached readback failure, but I will not attribute it without the comparison. All title data/dumps retained locally only. AI-assisted: Codex.

@AlxcBTW

AlxcBTW commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

@Scramblrrrr thanks a lot for the 007 cross-test, that's exactly the independent evidence these two need. At the matched 34k-build checkpoint the joined head goes from 29.7 s to 4.9 s upload and from 39.6 s to 21.7 s image preparation, and the alias-only control stays at 30.4 s / 39.9 s. So the join, not the alias library, removes the outside-import copies (including the 0x3f10000000 bucket).

On the RenderThread crash (read of 0x40 with RSI=0 in guest code, not a driver frame): one candidate worth ruling out is #361. On Sword of the Sea, parl0v just proved that Windows writes the exception frame below rsp when a guest store faults on a shared view (WindowsMappings::HandleWrite), which zeroes red-zone locals of leaf functions; the crashing leaf then reads a pointer back as 0. Faster loading means more first-touch faults on freshly mapped ranges, so a run that gets further can hit it more often. A ring of resumed faults in the vectored handler (thread, rsp, rip) shows it directly: a shared-view write fault on the crashing thread at the crash rsp, 0 ms before.

Your crossing-writer Vulkan test (dispatch storing across two adjacent registered ranges, one covering import, byte and boundary checks) would be a good addition to #4517. If you're fine with it, I'll cherry-pick it with your authorship.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 12, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 13, 2026
@AlxcBTW

AlxcBTW commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main now that #4515 is merged. Git dropped the #4515 commit as already applied, so this branch is now only the exact-cover join commit. The fork CI is green on Windows and Linux.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@TideOPL

TideOPL commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Thanks for this. It's in our Minecraft Dungeons II (PPSA16064) test build, and we hit a case it still leaves on the CPU path. I've opened #5372 on top of this PR (it includes your commit) instead of changing the behaviour here, so you can choose what to take.

#5372's joins would hit the same #290 refusal, so your fix there covers both.

Numbers and test details are in #5372. Happy to fold it into this PR instead if you prefer.

@TideOPL

TideOPL commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@AlxcBTW Above

@AlxcBTW

AlxcBTW commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

@TideOPL thanks, that's a real gap. The first piece gets imported alone before the window fills, and then the partial cover is refused. I'd keep this PR as it is: it's rebased and green, and it has two independent measurements (Palworld, SotS). #5372 can follow it as the general join, since it changes #4515's "two pieces no larger than the window" expectation and is better reviewed on its own. I'll run #5372 on Sword of the Sea in our next main-based row (current main + the join stack) and post the outside-import copy counts there, so it gets a second title next to Minecraft Dungeons II.

SleglJan added a commit to SleglJan/AnyPS5 that referenced this pull request Oct 13, 2026
…m its import

A descriptor heap that a shader binds whole while only the pieces from its
base are mapped (a sparse heap) is copied on the CPU for every build that
binds it unless a mirror serves it. The sparse heap mirror takes a heap whose
needed extent lies in one releasable registered range. A heap mapped piece by
piece, each mapping its own allocation and the pieces back to back from the
heap's base, is several registered ranges, so every build copied its mapped
run again.

Such a region is now bound in place from an import of that run: an import
already covering it, the run's own import, or one joined over exactly the run
(boykopovar#4517). This applies to any sparse heap no mirror took, including under
APS5_NO_LEASE_MIRROR or APS5_NO_SPARSE_HEAP_MIRROR. A join is made only for a
region that starts at a registered range, once the previous bind of that
address saw the same last mapped byte: a heap that grows between every two of
its binds keeps the copy, and one bound more often than it grows is joined
again after each growth. Joins stop after 64 per joined run base, with a
message: the heap is then bound in place while an existing import covers its
run and copied otherwise. The records go with their range. The region's descriptor and BDA ranges end at the import's end, which
covers the mapped run and the last view, as the copy does. A region whose
mapped part does not start at its base, with a view past the run, written by
its shader, or whose run is not imported is copied as before.
APS5_NO_SPARSE_RUN_IMPORT=1 keeps the copy. A direct region whose import ends
before it outside this path still fails in Descriptor, as before.

A set over such a region stays reusable: DirectRegions and InPlaceReads name
the region up to its import's end, so the import's serial proves it, and a
reuse also requires the heap to be mapped exactly up to that end
(CutRegions), checked whenever the imports or the registry changed, so a
mapping past the cut makes the set miss. DirectRegions also refuses a set any
of whose regions bound in place no longer holds the import found at its base
(a later join in the same build retired it); this applies to every region
bound in place, also under the opt-out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneandonlydean

Copy link
Copy Markdown
Collaborator

#4515 is merged now. Please rebase this onto main so it carries only its own commit; the copy of #4515 in this branch (3fbd63fb0) now conflicts with the merged one.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

TideOPL's note above says this PR alone can reach a throw: after an exact-cover join, once the window around it fills, a bind across the join's end gets the joined import from importAllocation and Descriptor fails with rounded up to its view range exceeds its GPU owner. Does the growth check in #5372's importJoinTests fail on this head? If it does, the fix belongs in this PR, since it turns a copied buffer into a stop.

My rebase note was out of date; the branch is fine as it is.

@TideOPL

TideOPL commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@oneandonlydean Yes. On this head (f6c289ea4) I added only the growth step to importJoinTests: after the exact two-piece join, register a third 64 KiB piece and bind 32 bytes across the join's end, with no expectations. It fails with AGC graphics: guest buffer view …+0x20 rounded up to its view range exceeds its GPU owner …. With main's GuestBufferMemory.cpp the same bind passes; it's copied. So I agree it belongs here.

@AlxcBTW The fix in #5372 is two lines in UploadFinish, after the importAllocation call for a region a window run covers:

if (entry != nullptr && region.end > entry->base + entry->bytes) entry = importJoined(context, state, region.begin, region.end, importRanges());
if (entry != nullptr && (region.begin < entry->base || region.end > entry->base + entry->bytes)) entry = nullptr;

On this PR, importJoined refuses the partial cover, so the region falls back to a copy, as on main. Feel free to take it with the growth step; I'll drop it from #5372 once it's in here.

SleglJan added a commit to SleglJan/AnyPS5 that referenced this pull request Oct 13, 2026
…m its import

A descriptor heap that a shader binds whole while only the pieces from its
base are mapped (a sparse heap) is copied on the CPU for every build that
binds it unless a mirror serves it. The sparse heap mirror takes a heap whose
needed extent lies in one releasable registered range. A heap mapped piece by
piece, each mapping its own allocation and the pieces back to back from the
heap's base, is several registered ranges, so every build copied its mapped
run again.

Such a region is now bound in place from an import of that run: an import
already covering it, the run's own import, or one joined over exactly the run
(boykopovar#4517). This applies to any sparse heap no mirror took, including under
APS5_NO_LEASE_MIRROR or APS5_NO_SPARSE_HEAP_MIRROR. A join is made only for a
region that starts at a registered range, once the previous bind of that
address saw the same last mapped byte: a heap that grows between every two of
its binds keeps the copy, and one bound more often than it grows is joined
again after each growth. Joins stop after 64 per joined run base, with a
message: the heap is then bound in place while an existing import covers its
run and copied otherwise. The records go with their range. The region's descriptor and BDA ranges end at the import's end, which
covers the mapped run and the last view, as the copy does. A region whose
mapped part does not start at its base, with a view past the run, written by
its shader, or whose run is not imported is copied as before.
APS5_NO_SPARSE_RUN_IMPORT=1 keeps the copy. A direct region whose import ends
before it outside this path still fails in Descriptor, as before.

A set over such a region stays reusable: DirectRegions and InPlaceReads name
the region up to its import's end, so the import's serial proves it, and a
reuse also requires the heap to be mapped exactly up to that end
(CutRegions), checked whenever the imports or the registry changed, so a
mapping past the cut makes the set miss. DirectRegions also refuses a set any
of whose regions bound in place no longer holds the import found at its base
(a later join in the same build retired it); this applies to every region
bound in place, also under the opt-out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AlxcBTW

AlxcBTW commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

@TideOPL thanks. Your two lines are in ea2ea5518 (with you as co-author), and importJoinTests now does your growth step: after the exact two-piece join it registers a third 64 KiB piece and binds 32 bytes across the join's end. Fork CI for the head: run 38482881106, running. You can drop it from #5372 once that's green. @oneandonlydean

@AlxcBTW

AlxcBTW commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Fork CI for ea2ea5518 is green on Linux and Windows (run 38482881106), the growth step in importJoinTests included.

AlxcBTW and others added 2 commits October 14, 2026 13:34
…t a buffer is bound exactly over

A bound buffer is joined across adjacent registered ranges only when every
one of them is larger than the 8 MiB window. PPSA25344's loading binds 16 MiB
and 4 MiB buffers whose backing was registered in two to six adjacent
pieces with the same access, some of them smaller than the window, so each
use of such a buffer was copied on the CPU: up to 348 GB in the first 300 s
of loading.

A bound buffer that starts at the first crossed range's start and ends at the
last one's end now joins those ranges whatever their size. A heap grown in
pieces matches that only for a binding over exactly its current pieces, so
growth beside a joined import does not re-import it. joinedCovers, used when a
joined import retires, accepts any adjacent run of ranges.

importJoinTests binds exactly over two 64 KiB pieces of a partly filled
window and requires one import of both; a binding across them that starts
inside the first piece stays apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…part

After an exact two-piece join, a bind across the join's end got the
joined import from importAllocation and the view failed as "rounded up to
its view range exceeds its GPU owner". UploadFinish now asks importJoined
for a region past the import's end and drops an import that still does
not cover the region, so the region is copied, as on main. The join test
binds across the end of an exact join after a third piece is registered.

Co-authored-by: TideOPL <57710757+TideOPL@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@oneandonlydean
oneandonlydean force-pushed the perf/host-import-join-exact branch from ea2ea55 to d275a58 Compare October 14, 2026 00:46
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Rebased onto main to resolve the conflict in docs/dev/debt/libSceAgcDriver.md after #4603 (kept both entries); no other change.

@oneandonlydean
oneandonlydean merged commit 0dea07a into boykopovar:main Oct 14, 2026
8 checks passed
SleglJan added a commit to SleglJan/AnyPS5 that referenced this pull request Oct 14, 2026
…m its import

A descriptor heap that a shader binds whole while only the pieces from its
base are mapped (a sparse heap) is copied on the CPU for every build that
binds it unless a mirror serves it. The sparse heap mirror takes a heap whose
needed extent lies in one releasable registered range. A heap mapped piece by
piece, each mapping its own allocation and the pieces back to back from the
heap's base, is several registered ranges, so every build copied its mapped
run again.

Such a region is now bound in place from an import of that run: an import
already covering it, the run's own import, or one joined over exactly the run
(boykopovar#4517). This applies to any sparse heap no mirror took, including under
APS5_NO_LEASE_MIRROR or APS5_NO_SPARSE_HEAP_MIRROR. A join is made only for a
region that starts at a registered range, once the previous bind of that
address saw the same last mapped byte: a heap that grows between every two of
its binds keeps the copy, and one bound more often than it grows is joined
again after each growth. Joins stop after 64 per joined run base, with a
message: the heap is then bound in place while an existing import covers its
run and copied otherwise. The records go with their range. The region's descriptor and BDA ranges end at the import's end, which
covers the mapped run and the last view, as the copy does. A region whose
mapped part does not start at its base, with a view past the run, written by
its shader, or whose run is not imported is copied as before.
APS5_NO_SPARSE_RUN_IMPORT=1 keeps the copy. A direct region whose import ends
before it outside this path still fails in Descriptor, as before.

A set over such a region stays reusable: DirectRegions and InPlaceReads name
the region up to its import's end, so the import's serial proves it, and a
reuse also requires the heap to be mapped exactly up to that end
(CutRegions), checked whenever the imports or the registry changed, so a
mapping past the cut makes the set miss. DirectRegions also refuses a set any
of whose regions bound in place no longer holds the import found at its base
(a later join in the same build retired it); this applies to every region
bound in place, also under the opt-out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SleglJan added a commit to SleglJan/AnyPS5 that referenced this pull request Oct 14, 2026
…m its import

A descriptor heap that a shader binds whole while only the pieces from its
base are mapped (a sparse heap) is copied on the CPU for every build that
binds it unless a mirror serves it. The sparse heap mirror takes a heap whose
needed extent lies in one releasable registered range. A heap mapped piece by
piece, each mapping its own allocation and the pieces back to back from the
heap's base, is several registered ranges, so every build copied its mapped
run again.

Such a region is now bound in place from an import of that run: an import
already covering it, the run's own import, or one joined over exactly the run
(boykopovar#4517). This applies to any sparse heap no mirror took, including under
APS5_NO_LEASE_MIRROR or APS5_NO_SPARSE_HEAP_MIRROR. A join is made only for a
region that starts at a registered range, once the previous bind of that
address saw the same last mapped byte: a heap that grows between every two of
its binds keeps the copy, and one bound more often than it grows is joined
again after each growth. Joins stop after 64 per joined run base, with a
message: the heap is then bound in place while an existing import covers its
run and copied otherwise. The records go with their range. The region's descriptor and BDA ranges end at the import's end, which
covers the mapped run and the last view, as the copy does. A region whose
mapped part does not start at its base, with a view past the run, written by
its shader, or whose run is not imported is copied as before. A direct
region whose import ends before it outside this path still fails in
Descriptor, as before.

A set over such a region stays reusable: DirectRegions and InPlaceReads name
the region up to its import's end, so the import's serial proves it, and a
reuse also requires the heap to be mapped exactly up to that end
(CutRegions), checked whenever the imports or the registry changed, so a
mapping past the cut makes the set miss. DirectRegions also refuses a set any
of whose regions bound in place no longer holds the import found at its base
(a later join in the same build retired it); this applies to every region
bound in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SleglJan added a commit to SleglJan/AnyPS5 that referenced this pull request Oct 14, 2026
…m its import

A descriptor heap that a shader binds whole while only the pieces from its
base are mapped (a sparse heap) is copied on the CPU for every build that
binds it unless a mirror serves it. The sparse heap mirror takes a heap whose
needed extent lies in one releasable registered range. A heap mapped piece by
piece, each mapping its own allocation and the pieces back to back from the
heap's base, is several registered ranges, so every build copied its mapped
run again.

Such a region is now bound in place from an import of that run: an import
already covering it, the run's own import, or one joined over exactly the run
(boykopovar#4517). This applies to any sparse heap no mirror took, including under
APS5_NO_LEASE_MIRROR or APS5_NO_SPARSE_HEAP_MIRROR. A join is made only for a
region that starts at a registered range, once the previous bind of that
address saw the same last mapped byte: a heap that grows between every two of
its binds keeps the copy, and one bound more often than it grows is joined
again after each growth. Joins stop after 64 per joined run base, with a
message: the heap is then bound in place while an existing import covers its
run and copied otherwise. The records go with their range. The region's descriptor and BDA ranges end at the import's end, which
covers the mapped run and the last view, as the copy does. A region whose
mapped part does not start at its base, with a view past the run, written by
its shader, or whose run is not imported is copied as before. A direct
region whose import ends before it outside this path still fails in
Descriptor, as before.

A set over such a region stays reusable: DirectRegions and InPlaceReads name
the region up to its import's end, so the import's serial proves it, and a
reuse also requires the heap to be mapped exactly up to that end
(CutRegions), checked whenever the imports or the registry changed, so a
mapping past the cut makes the set miss. DirectRegions also refuses a set any
of whose regions bound in place no longer holds the import found at its base
(a later join in the same build retired it); this applies to every region
bound in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs libc needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants