Repository navigation
d3d12: geometry views fall back to system memory when the BAR window is full (RT-GEOMETRY-VIEWS-NO-REBAR) - #1678
adrianmjim wants to merge 2 commits into
Conversation
…is full (RT-GEOMETRY-VIEWS-NO-REBAR) LEONIDA_GEOMETRY_MB views required DEVICE_LOCAL | HOST_VISIBLE memory. Without Resizable BAR the only such heap is the 256 MiB BAR window, and the default 256 MiB GPU address arena (host-visible, preferring device-local) takes all of it. Every 4 MiB view block then failed with VK_ERROR_OUT_OF_DEVICE_MEMORY, no view was made, and translated shaders read zeros: d3d12_geometry_views failed on an RX 7900 XT without Resizable BAR (CPU-written table V# 0/64). A device-local block that cannot be allocated now goes to host-visible system memory, logged once. Views that fit in the BAR stay there.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
What changed in this PR
Ensures d3d12_geometry_views works on systems without Resizable BAR by allowing streamed geometry view allocations to fall back to host-visible system memory when the BAR window is exhausted.
Changes:
- Add host-visible system-memory fallback for device-local view blocks when device-local host-visible heap allocation fails (logged once).
- Update documentation for
LEONIDA_GEOMETRY_MBsemantics and clarify BAR heap sizing behavior without Resizable BAR.
| File | Description |
|---|---|
| runtime/shims/d3d12_title_buffer_windows.h | Implements device-local allocation fallback to host-visible system memory with one-time logging when BAR heap is full. |
| docs/d3d12_vulkan.md | Updates LEONIDA_GEOMETRY_MB docs and clarifies default arena behavior on exact-256MiB BAR heaps. |
Review effort: Lite
| The copies go in device-local host-visible memory. Without Resizable BAR that is the 256 MiB BAR window, which | ||
| the default arena can fill; a block that finds no room there goes to host-visible system memory (logged once). |
There was a problem hiding this comment.
Right, it's a preference now. Reworded in 3db487a81 to "The copies prefer device-local host-visible memory", followed by the fallback sentence.
| constexpr VkMemoryPropertyFlags host_access = | ||
| VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; | ||
| b.memory = d.allocate(req, host_access | (device_local ? VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT : 0), | ||
| VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, nullptr, true); | ||
| if (!b.memory && device_local) { | ||
| // Without Resizable BAR the only device-local host-visible heap is the 256 MiB BAR window, and the | ||
| // default GPU address arena can fill it. A view in system memory is slower to read but still correct. | ||
| b.memory = d.allocate(req, host_access, 0, nullptr, true); | ||
| if (b.memory && !logged_host_fallback_) { | ||
| logged_host_fallback_ = true; | ||
| std::fprintf(stderr, "[rt] d3d12: no device-local host-visible memory left for a %llu KiB block of " | ||
| "buffer views, so it is in system memory\n", | ||
| static_cast<unsigned long long>(b.capacity >> 10)); | ||
| } | ||
| } |
There was a problem hiding this comment.
I left this one as it is:
- Size:
b.capacityis the 4 MiB block size, or the view's size when that is larger, so>> 10loses nothing that matters in a once-only log line. - Format:
%lluwithstatic_cast<unsigned long long>is how the rest of this header andd3d12_geometry_views.hprint sizes, and it is portable on every compiler the runtime builds with.
|
Independent verification (native Windows; RTX 4070 SUPER + AMD gfx1036 iGPU, validation on): header-only + docs, build 120/120 OK; same ctest results as #1681 — NVIDIA 15/15, AMD same 4 pre-existing 128B-pushconst failures identical on baseline. Interplay with #1681 checked: |
|
Thanks, @adrianmjim. The diagnosis is right, but #1723 (merged today) already covers the code fix:
Merged with AI-assisted (Claude Code, Claude Opus 5.5). |
|
Closing this: #1723 covers the code fix, as @aslan2142 says. On current The docs part ( |


Claimed in the coordination issue as: RT-GEOMETRY-VIEWS-NO-REBAR (#1608 (comment))
What and why
d3d12_geometry_viewsfails on an RX 7900 XT without Resizable BAR, on every run, onmain42537e7b6:The cause:
LEONIDA_GEOMETRY_MBviews are allocated throughTitleBufferWindows::allocate(..., device_local = true), which requiresDEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT.HOST_VISIBLE | HOST_COHERENT, preferredDEVICE_LOCAL) fits it exactly, sincememory_type_orderaccepts a heap as large as the request, so the arena takes the whole BAR heap.VK_ERROR_OUT_OF_DEVICE_MEMORY, no view is made, and the translated shader reads zeros.The driver is not refusing the allocation itself: a standalone probe on the same machine allocates 64 KiB to 64 MiB from that memory type, with and without
VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT, when the heap is empty. Andmainpasses withLEONIDA_ARENA_MBset to 128, 224 or 240.The fix: a device-local view block that cannot be allocated now goes to host-visible system memory, logged once. It is the same memory the non-geometry title windows already fall back to, and it keeps the 47-bit offset check, so a block the shaders could not reach is still refused. Views that fit in the BAR stay there.
Docs:
LEONIDA_GEOMETRY_MBis now described as the cap for the views wherever they are, since the cap also counts fallback blocks.docs/d3d12_vulkan.mdsaid the 256 MiB default arena lands in system memory without Resizable BAR. That holds for a smaller BAR heap (the RTX 3090's 214 MiB), but a heap of exactly 256 MiB holds it, so the note now says so.Follow-up (not here): whether the arena should take the whole BAR heap when there is no Resizable BAR is a policy question. The arena holds the default-heap buffers, descriptor heaps and shader code, so moving it to system memory is not obviously better. This change only makes the views work whichever way that goes.
Tested
AMD Radeon RX 7900 XT (RDNA3), AMD driver 32.0.32029.2010 (26.11.2), no Resizable BAR, Windows 11 build 26300, VS 2022, RelWithDebInfo, on
main42537e7b6:ctest -R "^d3d12_(geometry_views|title_va)$": both pass, 3 of 3 runs. Without the change,d3d12_geometry_viewsfails 3 of 3 andd3d12_title_vapasses. The fallback line is printed once.ctestonmainwithout the change: 399 of 402. The failures ared3d12_geometry_views(this),d3d12_texture_tiles(test: texture tiles NOTE only for the measured CopyTiles offset rounding on AMD and Intel (D3D-TILES-AMD-BYTE-OFFSET) #964) andd3d12_clear.tests/test_docs_links.py,tests/test_docs_repeated_lines.py,tests/test_docs_repo_paths.py,tests/test_text_write_line_endings.py: pass.GPUs tested: AMD Radeon RX 7900 XT (RDNA3), AMD 32.0.32029.2010, Windows 11 26300, Resizable BAR off
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (No translator change.)