title HUD and dev overlay: VRAM from VK_EXT_memory_budget, private memory under Wine (RT-TITLE-HUD-VRAM-BUDGET) #2128

Merged
aslan2142 merged 3 commits from upstream-pr/2128 into main 2026-11-25 23:21:08 +00:00
aslan2142 commented 2026-11-25 22:00:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T22:00:37Z.


Claimed in the coordination issue as: RT-TITLE-HUD-VRAM-BUDGET (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7172679484)

What and why

The title HUD from #1922 (kawaii-shakal, thanks) reads 0 for VRAM and private memory under Wine. This PR makes both figures real. It also shows them in the dev overlay from #2137 (Snooozs), which had neither figure: it showed the working set and free RAM only.

  • VRAM:
    • Source: the HUD read VRAM from the host dxgi.dll's QueryVideoMemoryInfo, which Wine answers with 0. It now reads the runtime's own Vulkan device.
    • Device creation: create_vulkan_device_standalone enables VK_EXT_memory_budget when the GPU has it, like the other optional extensions, and records that as VulkanDeviceInfo::memory_budget.
    • Query: runtime/src/vulkan_memory_budget.h chains VkPhysicalDeviceMemoryBudgetPropertiesEXT into vkGetPhysicalDeviceMemoryProperties2. It sums heapUsage and heapBudget over the DEVICE_LOCAL heaps and reports the other heaps' usage as shared. rt::d3d12::vulkan_vram_budget(ID3D12Device*) reads one device.
    • Publishing: the dev overlay runs outside the device, so the device publishes its figure in runtime/src/memory_figures.h:
      • a device with the extension publishes a reader when it is created and withdraws it first thing in its destructor;
      • the lock is held during a read, so a reader never runs after its device is gone;
      • latest_vram() calls the reader at most once per 500 ms, for the HUD and the overlay together.
    • Fallback: without the extension, the HUD uses DXGI's figure when it has one, as on Windows. Otherwise both views show VRAM n/a instead of a false 0.0/0.0.
  • Private memory:
    • Cause: Wine's GetProcessMemoryInfo fills only the PROCESS_MEMORY_COUNTERS part and leaves PrivateUsage at 0. Measured in title_hud_test under Wine 11.22: PrivateUsage 0, PagefileUsage 6422528.
    • Fix: PagefileUsage is the same commit-charge figure on Windows 8 and later, so both views show the larger of the two. If both are 0, they show RAM n/a.
  • One helper for both views: memory_figures.h holds the private-bytes choice, the RAM ... and VRAM ... text and the publisher. title_hud.h and dev_overlay.h both call it. It needs no Vulkan headers, and Win32 only under _WIN32, so dev_overlay_test still builds on every host.
  • What each view shows:
    • HUD: ... | RAM 2.5 GB (ws 1.0) | VRAM 3.5/16.0 GB +0.5 shared | ...
    • Overlay: cores and free RAM keep their line, and a new last line reads RAM 2.5 GB (ws 1.0) VRAM 3.5/16.0 GB +0.5 shared.
    • Without the extension (and, in the HUD, without a DXGI figure), the VRAM part of both reads VRAM n/a.
  • Docs: docs/boot.md and the LEONIDA_DEV_OVERLAY row of runtime/README.md.

Related: #2083 gates title_hud_test on the Vulkan headers. It touches the same CMake target's registration, but not the lines this PR changes.

Tested

  • dev_overlay_test (extended; it also builds and passes natively on Linux with g++):
    • the overlay's text with no figures (RAM n/a VRAM n/a) and with both;
    • the private-bytes fallback (PagefileUsage only, both, neither);
    • the publisher: no figure before a device publishes, one read per 500 ms, another device's withdrawal leaves the figure in place, and the device's own withdrawal removes it.
  • title_hud_test:
    • the heap sums, including heaps past memoryHeapCount;
    • the DXGI fallback and Wine's all-zero answer;
    • this process's own private bytes;
    • a fake source in the window title, read at most once per refresh;
    • a HUD without its own source shows the figure a device published.
  • d3d12_vram_budget_test (new; registered with SKIP_RETURN_CODE 77):
    • the standalone device enables the extension exactly when the GPU lists it;
    • the device publishes its figure while it lives and withdraws it on release;
    • with a 64 MiB buffer alive, the budget is non-zero: on the iGPU, 271 MiB in use of 21 471 MiB device-local;
    • without the extension, it checks that the figure is n/a and skips.
  • Failing without the change: the new checks call memory_figures.h and read the overlay's seventh line, so they fail or do not build without it.
  • Full Windows suite under Wine (clang-cl + xwin build), compared with the main baseline:
    • lavapipe: 410 pass, 12 fail, 40 skip (baseline 393 pass, 12 fail);
    • RADV iGPU: 403 pass, 20 fail, 39 skip (baseline 386 pass, 20 fail);
    • verdict: no test went from pass to fail; 17 tests went absent -> pass on each device: d3d12_vram_budget, title_hud, dev_overlay and 14 from merges since the baseline.
    • The remaining failures fail the same way in the baseline. They are environment-only (bcrypt, file system, gameinput host, root signature, clears, present/swapchain, pipeline cache seed).
  • Other checks: tests/test_docs_*.py, test_text_write_line_endings.py, test_ci_registration.py, test_ctest_registration.py and scripts/check_no_game_data.py on the changed files all pass.
  • Not tested: Windows itself, and the game. The overlay window was not watched on screen; its text is the tested pure function.

GPUs tested: lavapipe (Mesa 26.3.1) and AMD Radeon iGPU gfx1036 (RADV, Mesa 26.3.1), Wine 11.22 (Staging) on Arch Linux. Both expose VK_EXT_memory_budget.

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5499906942 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2128). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T22:00:37Z. --- Claimed in the coordination issue as: RT-TITLE-HUD-VRAM-BUDGET (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7172679484) ### What and why The title HUD from #1922 (kawaii-shakal, thanks) reads 0 for VRAM and private memory under Wine. This PR makes both figures real. It also shows them in the dev overlay from #2137 (Snooozs), which had neither figure: it showed the working set and free RAM only. - **VRAM**: - **Source:** the HUD read VRAM from the host `dxgi.dll`'s `QueryVideoMemoryInfo`, which Wine answers with 0. It now reads the runtime's own Vulkan device. - **Device creation:** `create_vulkan_device_standalone` enables `VK_EXT_memory_budget` when the GPU has it, like the other optional extensions, and records that as `VulkanDeviceInfo::memory_budget`. - **Query:** `runtime/src/vulkan_memory_budget.h` chains `VkPhysicalDeviceMemoryBudgetPropertiesEXT` into `vkGetPhysicalDeviceMemoryProperties2`. It sums `heapUsage` and `heapBudget` over the `DEVICE_LOCAL` heaps and reports the other heaps' usage as shared. `rt::d3d12::vulkan_vram_budget(ID3D12Device*)` reads one device. - **Publishing:** the dev overlay runs outside the device, so the device publishes its figure in `runtime/src/memory_figures.h`: - a device with the extension publishes a reader when it is created and withdraws it first thing in its destructor; - the lock is held during a read, so a reader never runs after its device is gone; - `latest_vram()` calls the reader at most once per 500 ms, for the HUD and the overlay together. - **Fallback:** without the extension, the HUD uses DXGI's figure when it has one, as on Windows. Otherwise both views show `VRAM n/a` instead of a false `0.0/0.0`. - **Private memory**: - **Cause:** Wine's `GetProcessMemoryInfo` fills only the `PROCESS_MEMORY_COUNTERS` part and leaves `PrivateUsage` at 0. Measured in `title_hud_test` under Wine 11.22: `PrivateUsage 0, PagefileUsage 6422528`. - **Fix:** `PagefileUsage` is the same commit-charge figure on Windows 8 and later, so both views show the larger of the two. If both are 0, they show `RAM n/a`. - **One helper for both views:** `memory_figures.h` holds the private-bytes choice, the `RAM ...` and `VRAM ...` text and the publisher. `title_hud.h` and `dev_overlay.h` both call it. It needs no Vulkan headers, and Win32 only under `_WIN32`, so `dev_overlay_test` still builds on every host. - **What each view shows:** - HUD: `... | RAM 2.5 GB (ws 1.0) | VRAM 3.5/16.0 GB +0.5 shared | ...` - Overlay: cores and free RAM keep their line, and a new last line reads `RAM 2.5 GB (ws 1.0) VRAM 3.5/16.0 GB +0.5 shared`. - Without the extension (and, in the HUD, without a DXGI figure), the VRAM part of both reads `VRAM n/a`. - **Docs:** `docs/boot.md` and the `LEONIDA_DEV_OVERLAY` row of `runtime/README.md`. Related: #2083 gates `title_hud_test` on the Vulkan headers. It touches the same CMake target's registration, but not the lines this PR changes. ### Tested - **`dev_overlay_test`** (extended; it also builds and passes natively on Linux with g++): - the overlay's text with no figures (`RAM n/a VRAM n/a`) and with both; - the private-bytes fallback (`PagefileUsage` only, both, neither); - the publisher: no figure before a device publishes, one read per 500 ms, another device's withdrawal leaves the figure in place, and the device's own withdrawal removes it. - **`title_hud_test`:** - the heap sums, including heaps past `memoryHeapCount`; - the DXGI fallback and Wine's all-zero answer; - this process's own private bytes; - a fake source in the window title, read at most once per refresh; - a HUD without its own source shows the figure a device published. - **`d3d12_vram_budget_test`** (new; registered with `SKIP_RETURN_CODE 77`): - the standalone device enables the extension exactly when the GPU lists it; - the device publishes its figure while it lives and withdraws it on release; - with a 64 MiB buffer alive, the budget is non-zero: on the iGPU, 271 MiB in use of 21 471 MiB device-local; - without the extension, it checks that the figure is `n/a` and skips. - **Failing without the change:** the new checks call `memory_figures.h` and read the overlay's seventh line, so they fail or do not build without it. - **Full Windows suite under Wine** (clang-cl + xwin build), compared with the `main` baseline: - lavapipe: 410 pass, 12 fail, 40 skip (baseline 393 pass, 12 fail); - RADV iGPU: 403 pass, 20 fail, 39 skip (baseline 386 pass, 20 fail); - verdict: no test went from pass to fail; 17 tests went `absent -> pass` on each device: `d3d12_vram_budget`, `title_hud`, `dev_overlay` and 14 from merges since the baseline. - The remaining failures fail the same way in the baseline. They are environment-only (bcrypt, file system, gameinput host, root signature, clears, present/swapchain, pipeline cache seed). - **Other checks:** `tests/test_docs_*.py`, `test_text_write_line_endings.py`, `test_ci_registration.py`, `test_ctest_registration.py` and `scripts/check_no_game_data.py` on the changed files all pass. - **Not tested:** Windows itself, and the game. The overlay window was not watched on screen; its text is the tested pure function. GPUs tested: lavapipe (Mesa 26.3.1) and AMD Radeon iGPU gfx1036 (RADV, Mesa 26.3.1), Wine 11.22 (Staging) on Arch Linux. Both expose `VK_EXT_memory_budget`. AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change)
aslan2142 commented 2026-11-25 23:21:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T23:21:10Z.


Merged. The title HUD (#1922) and the dev overlay (#2137) now show real memory figures under Wine.

  • VRAM: from VK_EXT_memory_budget on the runtime's own device: used and budget over the device-local heaps, plus what the other heaps use as shared. It is read at most once per 500 ms for both views, and shows n/a without the extension instead of a false 0.
  • Private memory: the larger of PrivateUsage and PagefileUsage, since Wine leaves the first at 0; n/a when neither can be read.
  • One helper: runtime/src/memory_figures.h feeds both the HUD and the overlay. The device publishes its figure when it is created and withdraws it first thing on release.
  • Tested: the full Windows suite under Wine on llvmpipe and the RADV gfx1036 iGPU, merged onto main ffcfe68f1 (with #2137): no test went from pass to fail, and dev_overlay, title_hud and d3d12_vram_budget pass on both. Not yet run on Windows itself or with the game.
  • Checked on main ffcfe68f1 + 38385762b: it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 12 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7177444065 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2128#issuecomment-7177444065). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T23:21:10Z. --- Merged. The title HUD (#1922) and the dev overlay (#2137) now show real memory figures under Wine. - **VRAM:** from `VK_EXT_memory_budget` on the runtime's own device: used and budget over the device-local heaps, plus what the other heaps use as shared. It is read at most once per 500 ms for both views, and shows `n/a` without the extension instead of a false 0. - **Private memory:** the larger of `PrivateUsage` and `PagefileUsage`, since Wine leaves the first at 0; `n/a` when neither can be read. - **One helper:** `runtime/src/memory_figures.h` feeds both the HUD and the overlay. The device publishes its figure when it is created and withdraws it first thing on release. - **Tested:** the full Windows suite under Wine on llvmpipe and the RADV gfx1036 iGPU, merged onto `main` `ffcfe68f1` (with #2137): no test went from pass to fail, and `dev_overlay`, `title_hud` and `d3d12_vram_budget` pass on both. Not yet run on Windows itself or with the game. - **Checked on `main` `ffcfe68f1` + `38385762b`:** it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 12 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2128
No description provided.