Repository navigation
fix(agc): select coherent buffer heaps using available budget - #4446
Conversation
|
First observed runtime use of the alternate-heap path, on the older 007 integration artifact f8956be/SHA61BF39CB (same production code as diagnostic027090d37; standalone PR4446 itself has not been staged): after original type3 allocations fail with -2, logs show recovery for58720256bytes and75497472bytes on memoryType4/originalType3, reclaimed0, attempts2. This is the compatible device-local host-visible/coherent heap on this RTX5070Ti. Same run separately recovers18MiB/16MiB allocations after trimming/retrying on original type3. Uses existing APS5_HOST_IMPORT_WINDOW_MIB=16, host-import budget6144; no other executable change. This supports the recovery mechanism on real allocations, not an FPS/playability claim or a proof that all OOMs are fixed. Current run still has known unsupported runtime-table operations and high retained memory. No title data uploaded. AI-assisted: yes (Codex). |
|
Acknowledged #4472 overlap. Its production change reads the VRAM budget and changes Put's retention of released device-tier buffers; #4446 changes allocation failure retries for ordinary coherent host-visible buffers. They are separate mechanisms and neither requires the other. The reported conflict is the shared BufferPool mock fields/test registration; it should be resolved by retaining both test sets, not dropping either. I have reviewed #4472's mock diff but have not built the combined heads yet, so this is source-level compatibility only. My next game cross-test is the collaborator's merged-hull/sparse-index stack; I will keep any VRAM-budget performance experiment separate. AI-assisted: yes (Codex). |
|
Source-level compatibility branch prepared for #4446 head55e666483 and #4472 head2d90e03e3: https://github.com/Scramblrrrr/AnyPS5/tree/codex/buffer-fallback-vram-budget-cross-test head89329b39b26b1b50550a694e9773768a0d51acaa. The two conflicts were only the mock fields and test registrations in tests/BufferPool.cpp; both sets are retained. Production merges cleanly. Conventions pass. Not built/staged yet, while the separate007 ordering test runs; will report combined native checks afterwards. This remains separate from the game shader/mapping integration, with no FPS claim. AI-assisted: Codex. |
|
Combined native validation is now complete for head89329b39b26b1b50550a694e9773768a0d51acaa: #4446 head55e666483 + credited #4472 head2d90e03e3. Both conflicting mock-field groups and both test registrations are retained. Fresh build of the pool, graphics and draw-cache fixture targets; agc_buffer_pool, agc_driver_graphics, agc_driver_draw_cache_reuse and _off pass4/4 in5.50s on Windows11/RTX5070Ti. Conventions pass, worktree clean. No game staging or FPS/memory-gain claim from this combination. Branch: https://github.com/Scramblrrrr/AnyPS5/tree/codex/buffer-fallback-vram-budget-cross-test . This confirms the shared test-file overlap can be resolved without dropping either mechanism's checks. AI-assisted: Codex. |
|
Which title fails this allocation on main? The 2359296000-byte failure in the description is from an older integration stack. |
|
Agreed: the current post-failure retry does not follow the requested allocation policy. I will revise it to select an eligible coherent heap from its budget/usage before allocating, retaining the allocation error rather than retrying it, following #4108's approach. The quoted2359296000-byte failure is from the older007 integration described in this PR; I do not have a demonstrated title failure on current main. I will keep those claims separate and have moved this PR back to draft while preparing the revision and focused selection tests. The earlier native retry tests do not validate the requested budget-selection policy. AI-assisted: Codex. |
|
Source-only requested budget-selection revision is prepared on current main510a2188cf4ea505dd58b3d5fc80ae3af2680c38: https://github.com/Scramblrrrr/AnyPS5/tree/codex/buffer-budget-selection-current-main head1590dbe5c95438cbed9ceea5abad72240502ee3f. Unbuilt/untested yet; waiting for the separate007 comparison to end, so no build/tests compete with it. Conventions/diff checks pass. Context::BufferMemoryType keeps the existing cached coherent preference when it fits or budget information is unavailable. When the preferred heap's reported headroom cannot fit the allocation, it selects another allowed heap/type satisfying all required flags and with enough reported headroom. Default cached preference can yield to an eligible uncached coherent type; explicitly required cached/device-local flags remain mandatory. Slab placement uses the full slab block size, and its key is created for the selected type. BufferPool::AllocateMemory is unchanged from main; none of this revision contains the additional post-failure alternate-heap retry. The existing allocation error handling remains. Twelve selection cases added to the existing device-memory-placement fixture cover exact fit, budget overflow, allowed masks, same-heap types, noncoherent alternatives, explicit device-local/cached constraints, unreported/insufficient budgets and unavailable queries/devices. Native and production-negative validation still pending. No current-main title failure demonstrated; original older-stack evidence stays historical. Keeping #4446 draft and its old branch unchanged until this revision is validated. AI-assisted: Codex. |
55e6664 to
4c291ba
Compare
|
Revised this draft to pre-allocation budget selection as requested. New head 4c291ba, base main 510a218. The earlier post-error alternate-heap retry is gone; required flags/memoryTypeBits remain enforced, slab selection budgets for the full slab, and unavailable budget data preserves the original preference. Existing upstream BufferPool behavior is unchanged. Selection, buffer-pool control, and full mocked graphics tests pass (3/3, 5.69 s). Removing only production selection makes the helper and allocation-level regressions fail; restoring it passes. The real Buffer cases verify a single request to the selected type for both a 2 MiB slab backing a 512-byte buffer and a direct 3 MiB allocation, including allocation failures. Conventions pass. Still no current-main title failure established. I rewrote the title/body around the final change and kept it draft rather than presenting the older integration failure as current-main evidence. AI-assisted (Codex). |
|
Acknowledged, thanks. I have resolved the current-main conflicts locally on base 88107b7: the sparse-buffer-holes CLI mode and our independent buffer-budget-placement mode are both retained. Local rebased head is 9528749; production budget-selection behavior is unchanged. Scoped conventions/diff checks pass. I am holding the PR branch update until the rebased native checks finish; they will run after the current isolated 007 test, to avoid concurrent build/test load. It remains draft, and the lack of a demonstrated current-main title allocation failure still applies. AI-assisted (Codex). |
|
Rebase now validated and pushed: 9528749 on main 88107b7. Preserved both CLI modes in the Graphics.cpp conflict. Windows/GCC15.2/Release: selection, buffer pool, full mocked graphics 3/3 PASS 5.67s; focused real-allocation placement and sparse-buffer-holes control PASS. Scoped conventions/diff checks pass, source clean. Earlier negative controls remain tied to their original base in the updated description. Production selection behavior is unchanged; still draft, with no established current-main title failure or 007 FPS/OOM claim. No current-main build library staged into the game. AI-assisted (Codex). |
4c291ba to
9528749
Compare
|
Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2), with 9528749 cherry-picked onto main 5d50886:
|
|
Thanks for the Linux cross-test of9528749cd and the five passing controls. The compile failure with main production restored confirms the new fixture depends on the added API, but is not a runtime behavioral negative; retaining that distinction in the validation evidence. Current head remains mergeable. AI-assisted: yes (Codex). |
|
A title that hits this: Resident Evil Village (PPSA01556, 01.210.000), on Windows 11 with an RTX 3070 Laptop GPU (8 GB) and 16 GB of RAM (WinLibs GCC 15.2.0 r7, Release). With 16 GB, heap 1 (host-visible system memory) is 7,888 MiB, with a On plain
On an older build, before #4515, #4517 and #5249 cut the per-build copies of descriptor views, the reclaim ran dry and the load stopped: Heap 1 was then at 7,483 MiB: 6,143 MiB of imports, 1,076 MiB of dedicated buffers in type 4 (most of them per-build copies of descriptor views) and 84 MiB of slabs. I haven't run that build with this PR. With it, an allocation made while heap 1 is past its budget goes to heap 0, as in the runs above. |
|
Thanks for the Windows title cross-test and exact heap/type measurements. This provides relevant title evidence that my original 007 motivation did not: same-stack Resident Evil Village runs select compatible alternate heap types without weakening required properties. I will add the result to the description as your single-run integration evidence, keeping the current-main stop and lack of a clean-main A/B explicit. No allocation retry or OOM recovery is added by this PR. Also thanks @coltken95 for the Linux native controls. The parent compile failure is an API mismatch, rather than a production-negative result; the meaningful budget-selection/allocation negatives in the description remain the Windows controls with unchanged fixtures and only production selection disabled. AI-assisted: yes (Codex). |
|
Our points are met here: the heap is chosen from the budget before allocating, and the allocation failure is gone in the title run. Please mark it ready for review when you are happy with it, and it gets a full build. |
9528749 to
53acbf0
Compare
|
Rebased onto main to resolve the conflict in |
|
Marked this ready, since both points are met and it's rebased onto main; it goes through the full build now. |
What
Coherent host buffers prefer a cached memory type even when its heap's reported available budget cannot cover the allocation. Select a compatible type on another heap before allocating, using VK_EXT_memory_budget; keep every required property and memoryTypeBits restriction.
The check uses the full slab allocation size for pooled buffers. It keeps the preferred type when budget information is unavailable, when it has room, or when no suitable alternate heap has room. Explicit HOST_CACHED and DEVICE_LOCAL requirements remain required. The existing upstream BufferPool allocation/error behavior is preserved; this revision adds no allocation retry after an error. An alternate CPU-visible device heap can make CPU reads slower, so it is selected only when the preferred heap has insufficient reported budget.
This replaces the earlier post-failure fallback, following maintainer review. Rebased base: main 88107b7. Head: 9528749 (0a3f392 selection change plus allocation-level regression tests).
Tested
Validation on Windows / RTX 5070 Ti / Release GCC / SPIRV-Tools OFF:
The older 007 integration's allocation failure motivated the investigation, but it is not current-main evidence. Independent Windows title evidence by EagleBearerYS: Resident Evil Village on main 18c438b plus its required open patches, same save/inputs and warm cache, one run per side. Without this PR, one 8 MiB allocation first failed with -2 and succeeded after existing pool reclamation; with it, no allocation failed and compatible type 5 allocations were used. Heap 1 at title screen was 7,485 vs 7,236 MiB (reported budget 7,237 MiB); title-screen time 138 vs 131 s. This is integration-stack, single-run evidence, not a clean-main A/B or an established FPS improvement. Details: #4446 (comment) . Game OOM recovery is not established. This remains a draft pending maintainer assessment of the generic change and relevant title evidence. No integration stack, title code, assets, or captures included.
Related: #4108 (image budget selection), #290 (host import/pool allocation behavior).
Checklist