Skip to content

chore(agc): report heap budgets on buffer allocation failure - #7119

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
MarcZX10:codex/agc-allocation-heap-budget
Oct 19, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
MarcZX10:codex/agc-allocation-heap-budget

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What

Append VK_EXT_memory_budget usage and budget for every physical-device heap to failed AGC buffer allocations when the extension query is available. Keep allocation and retry policy unchanged; omit heap details when the extension is unavailable.

Tested

  • Linux: BufferPool.cpp and tests/BufferPool.cpp passed c++ -std=c++20 -fsyntax-only with the repository include paths.
  • The hosted agc_buffer_pool check exposed incorrect query-count assertions: allocation type selection queries the enabled budget extension, and a failed allocation then queries it again for diagnostics. The test now expects both calls and resets its counter before checking the missing-extension path.
  • Independent Linux validation from jotitadev on head d9ccae5fd: agc_buffer_pool, agc_buffer_pool_small_device_shared and agc_buffer_pool_small_device_no_staging all passed, three runs each. The full ^agc selection passed 649/649 on both an RTX 3070 and lavapipe. With BufferPool.hpp and BufferPool.cpp from main, the new diagnostic assertions failed as expected. These tests use mocked Vulkan functions; a real allocation failure and Windows were not tested.
  • python3 tools/check_conventions.py --base upstream/main: passed.
  • python3 tools/pr_overlap.py --branch codex/agc-allocation-heap-budget: no overlap with open pull requests.
  • git diff --check: passed.
  • Local Linux Release configuration succeeded after initializing pinned submodules. The agc_buffer_pool_tests build stopped before reaching the changed test at the unrelated GCC parse error in core/shader/recompiler/Optimization/src/SrtWalker/SrtDescriptorEvaluation.cpp:183; no local runtime result is claimed.

Checklist

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

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 4472 core/libs/prx/libSceAgcDriver/Graphics/include/BufferPool.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp
core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Graphics/include/BufferPool.hpp
PR 6615 core/libs/prx/libSceAgcDriver/Graphics/include/BufferPool.hpp
PR 7800 core/libs/prx/libSceAgcDriver/Graphics/include/BufferPool.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp
core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Full CI on 4b77018 (run 39032496156) fails agc_buffer_pool on both Linux and Windows. The same two checks from this PR's test fail on each:

FAIL: allocation failure did not query the memory budget exactly once
FAIL: missing-extension fallback attempted a memory budget query

agc_buffer_pool passes on main (c9e6c45). So the budget query either runs a different number of times than the test expects on the failure path, or it still runs when the extension is missing. Could you take a look? We'll rerun full CI on the new head.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for the failure report. I traced the counts: when the extension is enabled, Context::DeviceMemoryType queries the heap budget during memory-type selection, then BufferPool::AllocateMemory queries it again only when reporting the failed allocation. The regression expected one total call instead of two. The fallback assertion also carried the first case’s counter into the second case. I corrected both in commit d9ccae5fd and updated the Tested section; the new hosted run is pending. Local Release configuration succeeded, but the focused build is blocked before this test by an unrelated GCC parse error in SrtDescriptorEvaluation.cpp:183, so I do not claim a local test pass.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Follow-up: on Linux, the updated tests/BufferPool.cpp and production Graphics/src/BufferPool.cpp translation units both compile with the repository C++20 command. The full agc_buffer_pool_tests target cannot link locally because the unrelated SrtDescriptorEvaluation.cpp:183 GCC parse error stops the driver build. The automatic checks on d9ccae5fd passed conventions/eligibility/report, but skipped Linux and Windows tests. I tried the documented manual Build workflow with the focused changed-test selection; GitHub rejected dispatch with HTTP 403 (Must have admin rights to Repository). Could a maintainer dispatch it on this head to verify agc_buffer_pool?

@MarcZX10

Copy link
Copy Markdown
Contributor Author

I tried a focused local build of the PR test target at head d9ccae5fdd346bcb3031247e120c2020fee15a8a, but the build stops earlier in SrtDescriptorEvaluation.cpp:183: GCC requires the dependent call to be written read.read->template Flags<MemoryFlags>(). That is outside this PR and prevents me from reproducing agc_buffer_pool locally at this head. I have not changed the branch or inferred which budget-query assertion is wrong from the hosted failure alone; the two CI failures remain actionable and need a corrected test expectation or implementation before the PR is ready.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Local validation update at the exact head d9ccae5fdd346bcb3031247e120c2020fee15a8a: the agc_driver_tests target now builds successfully on Linux after applying the unrelated dependent-template keyword fix only in the temporary review worktree; that file was restored afterward and the worktree is clean. Running agc_driver_tests --buffer-pool-only then stops before test selection because this host CPU lacks LZCNT, BMI1, BMI2, MOVBE, AVX2 and FMA. So the target compilation is confirmed locally, but this machine cannot provide a runtime result for the buffer-pool test. The new hosted run remains needed for runtime confirmation.

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcZX100 here is the runtime result you could not get locally. The Linux and Windows CI jobs were also skipped on d9ccae5fd.

Machine: Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. Head d9ccae5fd merged onto main 47a266cf9 (clean). The full tree builds with GCC 15.2, including SrtDescriptorEvaluation.cpp.

Run Result
agc_buffer_pool, agc_buffer_pool_small_device_shared, agc_buffer_pool_small_device_no_staging all pass, 3 runs
same, with BufferPool.hpp and BufferPool.cpp from main agc_buffer_pool fails: allocation failure omitted the first heap's memory budget, ... a later heap's memory budget, ... did not query the memory budget for both type selection and its diagnostic
^agc (649 tests) on the RTX 3070 and on lavapipe 649/649 on both, same as main

So the two checks @oneandonlydean reported on 4b770187f pass on this head, and the new checks fail without the change. The missing-extension case passes in both runs, as expected, because main never queries the budget there.

These tests use the mocked Vulkan functions. ANYPS5_GPU (RTX 3070 or lavapipe) does not change the result.

Not run: Windows, a real allocation failure on a device.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for running the native test matrix. Your result confirms the two original assertions pass on d9ccae5fd, the new allocation-failure diagnostics are covered by the mocked Vulkan tests, and all 649 AGC tests pass on both the RTX 3070 and lavapipe. I’ve added your exact Linux validation to the PR description; Windows and a real device allocation failure remain untested.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 17, 2026
@MarcZX10
MarcZX10 force-pushed the codex/agc-allocation-heap-budget branch from d9ccae5 to 4d38213 Compare October 18, 2026 00:57
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@MarcZX10
MarcZX10 force-pushed the codex/agc-allocation-heap-budget branch from 4d38213 to dd81b11 Compare October 18, 2026 01:12
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Rebased the PR onto current upstream main at 5229b5b82; the updated head is dd81b1129. The rebase preserves the heap-budget diagnostic and corrected query-count assertions. check_conventions.py and git diff --check pass. A local Linux Release build of agc_driver_tests succeeds when the unrelated dependent-template parse fix in SrtDescriptorEvaluation.cpp is applied only in the temporary review worktree and then restored; the focused tests cannot run on this Xeon E5-1620 v2 host because the executable exits at its CPU feature guard (LZCNT/BMI1/BMI2/MOVBE/AVX2/FMA). Current GitHub conventions, eligibility and report checks pass; the Linux/Windows and relinker jobs are skipped for this pull request. I manually checked the overlap warnings from #4472/#5987/#6553: those change buffer pooling or host-memory fallback policy, while this PR only adds heap diagnostics after allocation failure, so the behavior does not overlap.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for running the focused tests and full AGC suite on d9ccae5fd; that independently validates the allocation diagnostic and its negative control. I also tried the three focused tests at current head dd81b1129 on Linux, but each process aborted at the host CPU feature guard before assertions (this Xeon E5-1620 v2 lacks LZCNT, BMI1/2, MOVBE, AVX2 and FMA). The current head adds the follow-up test commit, so a focused rerun there on a supported host would close that small validation gap if convenient.

@LeandroLP23

Copy link
Copy Markdown
Contributor

Windows run: agc_buffer_pool fails with this PR, on main 6efb7261b with only this PR (dd81b1129) merged, 3 runs of 3. On the same main without it, it passes. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON.

FAIL: allocation failure did not query the memory budget for both type selection and its diagnostic

With a local print, since removed, diagnosticBudgetQueries is 3 at that check, not 2. main has not changed BufferPool.cpp, BufferPool.hpp or any memoryProperties2 caller since this branch's base 5229b5b82, so this does not look like drift. One candidate for the third query is BufferPool::deviceBudget (BufferPool.cpp:229), which queries the budget whenever DeviceTierEnabled(), the default without APS5_STAGING_POOL_MIB. I could not confirm it with APS5_STAGING_POOL_MIB=0: the suite then stops earlier, at the device buffer size class check. The test mocks every Vulkan call, so the GPU should not matter. I have not run it on Linux to compare.

AI-assisted

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for tracing the extra call. The pool constructor does query the budget once to size its device tier, which made the test count include setup. In e6fb74f the test explicitly initializes and stores the mock BufferPool before taking its allocation-path count, then asserts exactly two calls for DeviceMemoryType and the allocation-failure diagnostic. The changed test translation unit compiles, and conventions pass. I could not run the focused executable here: it exits at startup because this Xeon E5-1620 v2 lacks the AVX2/LZCNT/BMI/MOVBE/FMA features required by the project. Please rerun the Windows/Linux focused check on this head.

@LeandroLP23

Copy link
Copy Markdown
Contributor

Rechecked e6fb74fd7 on the same Windows machine (Radeon 860M, Windows 11 26300, WinLibs GCC 15.2.0 r7, Release), merged alone onto main 6efb7261b. agc_buffer_pool, agc_buffer_pool_small_device_no_staging and agc_buffer_pool_small_device_shared now pass, 3 runs of 3.

AI-assisted

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for rerunning the updated head on Windows. The three buffer-pool tests passing 3/3 each complements the Linux run, where the new checks fail with the production files reverted and the 649-test AGC suite matches main. The Linux/Windows focused behavior is now covered; real allocation failure on a device remains untested.

@fdfawef324

Copy link
Copy Markdown
Contributor

I am updating #6553 after #5987 merged, retaining only the host-room placement guard and its tests while preserving main's allocation/refusal/reclaim routing. This PR's allocation-failure diagnostics are a separate topic.

Both branches already conflict with newer main in the buffer-pool test area. Proposed landing order: #6553 first, then preserve its budget and allocation-attempt assertions alongside this PR's failure diagnostics. No combined build is claimed; if this PR should land first, I can rebase the guard afterward and rerun that composition.

AI-assisted: yes

@adriadam10
adriadam10 force-pushed the codex/agc-allocation-heap-budget branch from e6fb74f to c5f8a3f Compare October 19, 2026 13:16
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for clarifying the proposed landing order. I agree that #6553 should land first, then this PR should retain its allocation-failure diagnostics together with the guard’s budget and allocation-attempt assertions. Since no combined build has been run, I’ll keep the composition unverified until that combined validation is available.

@adriadam10
adriadam10 merged commit 8c9161e into boykopovar:main Oct 19, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the heap-budget diagnostic against main: the production code merges cleanly and the only conflict was adjacent blocks in tests/BufferPool.cpp. Rebased onto current main keeping both, full build and ctest 805/805 green (agc_buffer_pool* included), consistent with the Linux (jotitadev) and Windows (LeandroLP23) runs; merged.

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.

6 participants