mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:00:52 +01:00
[PR #1732] [MERGED] d3d12: keep a Resizable BAR arena in VRAM when the driver excludes it from a very large buffer (RT-ARENA-REBAR-FIT) #1746
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1746
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1732
Author: @kawaii-shakal
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:arena-rebar-cap📝 Commits (2)
96bbe55d3d12: keep a Resizable BAR arena in VRAM when the driver excludes it from a very large buffer (RT-ARENA-REBAR-FIT)a607b77d3d12: check heap eligibility when sizing the ReBAR arena📊 Changes
4 files changed (+101 additions, -6 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+9 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+26 -3)📝
runtime/src/arena_size.h(+30 -1)📝
runtime/test/arena_size_test.cpp(+36 -2)📄 Description
Claim: RT-ARENA-REBAR-FIT, https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7159118394 (step 2 of #1702)
What and why
On the retail boot with
LEONIDA_ARENA_MB=4096, which is #1537's workaround for the world-start device loss, the memory probe showed the 4,095 MiB arena in system memory (type 2,HOST_VISIBLE | HOST_COHERENT). That was on an RTX 5070 Ti that does have Resizable BAR:[rt] d3d12: upload heaps in VRAM (DEVICE_LOCAL | HOST_VISIBLE, Resizable BAR). The cost: 4 GiB more host commit (that run ended with commit and RAM exhausted, #1702), and every default-heap buffer, descriptor heap and shader program read over PCIe.The cause is the buffer's
memoryTypeBits, not the allocation. A standalone Vulkan probe on the same machine (RTX 5070 Ti, NVIDIA 617.42, Windows 11 Pro 26300) shows this:DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENTone included;memoryTypeBits0x1fup to 4,090 MiB and0xffrom 4,092 MiB, so the ReBAR type is excluded;memory_type_orderthen never offers that type, and the arena goes to the first host-visible coherent one.0x1f(type 4, ReBAR, allowed)0xf(type 4 excluded)runtime/src/arena_size.h:device_local_arena_bytes(bytes, fits). It returnsbyteswhen it fits. Otherwise it returns the largest size below, in 16 MiB steps and losing at most an eighth, that does. If nothing in reach fits it returnsbytesunchanged. It also adds a new cap bit,arena_cap_bar, with its name.runtime/shims/d3d12_vulkan_device.cpp,create_arena: with Resizable BAR (leonida::resizable_bar),fitscreates a probe buffer of that size and checks whether itsmemoryTypeBitshas aDEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENTtype. Each size tried costs one probe buffer. The cap is logged like the existing ones. Without Resizable BAR nothing changes.docs/d3d12_vulkan.md: the memory type policy (section 3.3) says this.Test
arena_size_test: newresizable_bar_fitcase with a syntheticfits. It covers:d3d12_title_va_testwithLEONIDA_ARENA_MB=4096logsGPU address arena: 4080 MiB of the 4095 MiB asked for, capped by the device's Resizable BAR memory types for a buffer that largeand passes. WithLEONIDA_ARENA_MB=1024it logs no cap and passes. At 4,080 MiB the probe above gives0x1f, somemory_type_orderpicks the ReBAR type first.scripts/check_no_game_data.pyis clean.Not done here: a retail boot with this branch, so the memory-probe line
arena 4080 MiB (type 4)and the effect on host commit are not yet measured. Other vendors' limits are not measured either: a driver that keeps the type for every size takes the first branch and nothing changes.AI-assisted: yes (Claude Code, Claude Opus 5.5).
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.