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

Closed
opened 2026-11-26 21:20:09 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2128
Author: @aslan2142
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: rt-title-hud-vram-budget


📝 Commits (3)

  • 2443875 title HUD: VRAM from VK_EXT_memory_budget, private bytes under Wine
  • d4fb292 Merge main into rt-title-hud-vram-budget
  • 3838576 dev overlay: the title HUD's VRAM and private memory figures

📊 Changes

12 files changed (+577 additions, -31 deletions)

View changed files

📝 docs/boot.md (+9 -3)
📝 runtime/CMakeLists.txt (+7 -0)
📝 runtime/README.md (+1 -1)
📝 runtime/shims/d3d12_com.h (+8 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+23 -0)
📝 runtime/shims/title_hud.h (+38 -17)
📝 runtime/src/dev_overlay.h (+11 -7)
➕ runtime/src/memory_figures.h (+147 -0)
➕ runtime/src/vulkan_memory_budget.h (+46 -0)
➕ runtime/test/d3d12_vram_budget_test.cpp (+103 -0)
📝 runtime/test/dev_overlay_test.cpp (+70 -2)
📝 runtime/test/title_hud_test.cpp (+114 -1)

📄 Description

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2128 **Author:** [@aslan2142](https://github.com/aslan2142) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `rt-title-hud-vram-budget` --- ### 📝 Commits (3) - [`2443875`](https://github.com/ubiquitarianism/leonida/commit/244387529b6fb4992b601704d32016e7beeadd28) title HUD: VRAM from VK_EXT_memory_budget, private bytes under Wine - [`d4fb292`](https://github.com/ubiquitarianism/leonida/commit/d4fb292344088e7925ddeb3bbceb5a9ac46de8c2) Merge main into rt-title-hud-vram-budget - [`3838576`](https://github.com/ubiquitarianism/leonida/commit/38385762bd400e8260c7b3c8a80bb0c03fcc44c4) dev overlay: the title HUD's VRAM and private memory figures ### 📊 Changes **12 files changed** (+577 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `docs/boot.md` (+9 -3) 📝 `runtime/CMakeLists.txt` (+7 -0) 📝 `runtime/README.md` (+1 -1) 📝 `runtime/shims/d3d12_com.h` (+8 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+23 -0) 📝 `runtime/shims/title_hud.h` (+38 -17) 📝 `runtime/src/dev_overlay.h` (+11 -7) ➕ `runtime/src/memory_figures.h` (+147 -0) ➕ `runtime/src/vulkan_memory_budget.h` (+46 -0) ➕ `runtime/test/d3d12_vram_budget_test.cpp` (+103 -0) 📝 `runtime/test/dev_overlay_test.cpp` (+70 -2) 📝 `runtime/test/title_hud_test.cpp` (+114 -1) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:20:09 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2132
No description provided.