graphics: give images dedicated allocations where the driver allows many #1394

Open
github-bot wants to merge 1 commit from github-bot/gh-1394 into main AGit
Owner

@⁠msfvn on GitHub · 2026-10-11 02:01 UTC · original
msfvn:vma-dedicated-images → main · +7 −0 · 1 files · 1 commits · open

Problem

Images share VMA's default 256 MiB blocks. As the texture cache creates and frees images of different sizes, those blocks fill with holes, and VMA only releases a block once it is completely empty. On Astro Bot with a 4 GB GPU, vmaCalculateStatistics showed 634 MiB of device memory in 187 unused ranges (largest 77 MiB) at the point where new images started failing to allocate. Smaller blocks (64 MiB) did not help, ~500 MiB stayed unused.

Change

Create images with VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT when maxMemoryAllocationCount >= 65536, so freeing an image returns its memory to the driver. Linux drivers report UINT32_MAX; Windows drivers commonly report 4096, so they keep the pooled path.

Testing

Linux, RTX 3050 Laptop 4 GB, Astro Bot intro, same scene: unused memory inside VMA blocks went from ~700 MiB to ~48 MiB, and the frame rate in the VRAM-bound part of the intro went from 2-4 to 3-9 fps. Measured on a local build that also had other memory changes of mine; together with #1270 and #1271 on current main it runs the intro without failures.

AI involvement: written with Claude Code (AI assistant) at my request and reviewed by a C++ developer I know; tested on my machine (RTX 3050 Laptop 4 GB, CachyOS) as described above, including playing Astro Bot on this build. Happy to adjust anything you point out.

**@⁠msfvn** on GitHub · 2026-10-11 02:01 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1394) `msfvn:vma-dedicated-images` → `main` · +7 −0 · 1 files · 1 commits · open ### Problem Images share VMA's default 256 MiB blocks. As the texture cache creates and frees images of different sizes, those blocks fill with holes, and VMA only releases a block once it is completely empty. On Astro Bot with a 4 GB GPU, `vmaCalculateStatistics` showed 634 MiB of device memory in 187 unused ranges (largest 77 MiB) at the point where new images started failing to allocate. Smaller blocks (64 MiB) did not help, ~500 MiB stayed unused. ### Change Create images with `VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT` when `maxMemoryAllocationCount >= 65536`, so freeing an image returns its memory to the driver. Linux drivers report `UINT32_MAX`; Windows drivers commonly report 4096, so they keep the pooled path. ### Testing Linux, RTX 3050 Laptop 4 GB, Astro Bot intro, same scene: unused memory inside VMA blocks went from ~700 MiB to ~48 MiB, and the frame rate in the VRAM-bound part of the intro went from 2-4 to 3-9 fps. Measured on a local build that also had other memory changes of mine; together with #1270 and #1271 on current `main` it runs the intro without failures. **AI involvement:** written with Claude Code (AI assistant) at my request and reviewed by a C++ developer I know; tested on my machine (RTX 3050 Laptop 4 GB, CachyOS) as described above, including playing Astro Bot on this build. Happy to adjust anything you point out.
Images share VMA's 256 MiB blocks. As the texture cache creates and frees
images of mixed sizes, the blocks fill with holes: on Astro Bot with a
4 GB GPU, 600-860 MiB of device memory sat in 187 unused ranges while new
images failed to allocate. VMA only returns a block once it is empty.

Allocate images on their own, so freeing one hands the memory back to the
driver. With this the gap between allocated and reserved memory went from
~700 MiB to ~48 MiB in the same scene. Only where the driver reports a
large allocation limit; Windows drivers commonly cap allocations at 4096.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:55:34 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-11 02:06 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d520f3ad-d96c-4a92-acff-8eaa292bbb44

📥 Commits

Reviewing files that changed from the base of the PR and between 730e1a3cf3 and 9b8fd69120.


📒 Files selected for processing (1)
  • src/graphics/host_gpu/vma.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.



📝 Walkthrough

Walkthrough

CreateImage now enables VMA dedicated-memory allocation when the physical device’s maxMemoryAllocationCount is at least 65,536. Below that threshold, it leaves the allocation flags unchanged.

Suggested reviewers: nmzik


Priority: ⬆️ High

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9b8fd

Images now request dedicated memory on devices reporting a high allocation limit. Allocation-limit exhaustion could cause image creation to fail, but no available workload evidence establishes that this occurs, so no concrete merge blocker is demonstrated.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: using dedicated image allocations when the driver supports a high allocation count.
Description check Passed The description directly explains the memory-fragmentation problem, the VMA allocation change, the platform condition, and the reported testing results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-11 02:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1394#issuecomment-6104463472) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1394?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `d520f3ad-d96c-4a92-acff-8eaa292bbb44` <hr> </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 730e1a3cf39d50c787d477e813e0bef92006a063 and 9b8fd691204853e7567352ddf8aa82932c50d83d. <hr> </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (1)</strong></summary> <dl> <dd> * `src/graphics/host_gpu/vma.cpp` <hr> </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review. <hr> </dd> </dl> </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> ## Walkthrough `CreateImage` now enables VMA dedicated-memory allocation when the physical device’s `maxMemoryAllocationCount` is at least 65,536. Below that threshold, it leaves the allocation flags unchanged. **Suggested reviewers:** `nmzik` <hr> </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬆️ High <!-- change_assessment_commit:"9b8fd691204853e7567352ddf8aa82932c50d83d" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `9b8fd` <!-- final_review_risk_coverage:{"sourceCommitId":"9b8fd691204853e7567352ddf8aa82932c50d83d","coveredCommitId":"9b8fd691204853e7567352ddf8aa82932c50d83d","kind":"reviewed"} --> Images now request dedicated memory on devices reporting a high allocation limit. Allocation-limit exhaustion could cause image creation to fail, but no available workload evidence establishes that this occurs, so no concrete merge blocker is demonstrated. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v1.svg" width="14" height="17" align="middle" alt="Passed" title="Passed"></picture></sup> 4 | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v1.svg" width="14" height="17" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: using dedicated image allocations when the driver supports a high allocation count. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the memory-fragmentation problem, the VMA allocation change, the platform condition, and the reported testing results. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <hr> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1394)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) <hr> </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/vma.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1394/head:github-bot/gh-1394'
git switch 'github-bot/gh-1394'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1394'
git switch 'github-bot/gh-1394'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1394'
git switch 'github-bot/gh-1394'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1394'
git switch 'main'
git merge --squash 'github-bot/gh-1394'
git switch 'main'
git merge --ff-only 'github-bot/gh-1394'
git switch 'main'
git merge 'github-bot/gh-1394'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.