[PR #1678] d3d12: geometry views fall back to system memory when the BAR window is full (RT-GEOMETRY-VIEWS-NO-REBAR) #1691

Open
opened 2026-11-26 20:22:07 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1678
Author: @adrianmjim
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/geometry-views-no-rebar


📝 Commits (2)

  • 9f989cb d3d12: geometry views fall back to system memory when the BAR window is full (RT-GEOMETRY-VIEWS-NO-REBAR)
  • 3db487a docs: geometry views prefer device-local memory, with the system-memory fallback

📊 Changes

2 files changed (+20 additions, -4 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+5 -2)
📝 runtime/shims/d3d12_title_buffer_windows.h (+15 -2)

📄 Description

Claimed in the coordination issue as: RT-GEOMETRY-VIEWS-NO-REBAR (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156374294)

What and why

d3d12_geometry_views fails on an RX 7900 XT without Resizable BAR, on every run, on main 42537e7b6:

[rt] d3d12: vkAllocateMemory failed (-2): 4194304 bytes, memory type 2 (flags 0x7, heap 2 of 256 MiB), device address 1
title memory (a constant ring): CPU-written table V# 0/64 (rewritten before the submission: yes), created CBV 0/64, root view 0/64; ...
line 492: raw_ok == kElements && cbv_ok == kElements && root_ok == kElements

The cause:

  • LEONIDA_GEOMETRY_MB views are allocated through TitleBufferWindows::allocate(..., device_local = true), which requires DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT.
  • Without Resizable BAR the only such heap is the 256 MiB BAR window. The default 256 MiB GPU address arena (required HOST_VISIBLE | HOST_COHERENT, preferred DEVICE_LOCAL) fits it exactly, since memory_type_order accepts a heap as large as the request, so the arena takes the whole BAR heap.
  • Every 4 MiB view block then fails with 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. And main passes with LEONIDA_ARENA_MB set 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_MB is now described as the cap for the views wherever they are, since the cap also counts fallback blocks.
  • The arena note in docs/d3d12_vulkan.md said 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 main 42537e7b6:

  • ctest -R "^d3d12_(geometry_views|title_va)$": both pass, 3 of 3 runs. Without the change, d3d12_geometry_views fails 3 of 3 and d3d12_title_va passes. The fallback line is printed once.
  • Full ctest on main without the change: 399 of 402. The failures are d3d12_geometry_views (this), d3d12_texture_tiles (#964) and d3d12_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

  • 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. (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/1678 **Author:** [@adrianmjim](https://github.com/adrianmjim) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/geometry-views-no-rebar` --- ### 📝 Commits (2) - [`9f989cb`](https://github.com/ubiquitarianism/leonida/commit/9f989cbe4f1206145ee2cefa2281e8804066246a) d3d12: geometry views fall back to system memory when the BAR window is full (RT-GEOMETRY-VIEWS-NO-REBAR) - [`3db487a`](https://github.com/ubiquitarianism/leonida/commit/3db487a818edffa1910962f1b24da04bf3b5289c) docs: geometry views prefer device-local memory, with the system-memory fallback ### 📊 Changes **2 files changed** (+20 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+5 -2) 📝 `runtime/shims/d3d12_title_buffer_windows.h` (+15 -2) </details> ### 📄 Description Claimed in the coordination issue as: RT-GEOMETRY-VIEWS-NO-REBAR (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7156374294) ### What and why `d3d12_geometry_views` fails on an RX 7900 XT without Resizable BAR, on every run, on `main` `42537e7b6`: ``` [rt] d3d12: vkAllocateMemory failed (-2): 4194304 bytes, memory type 2 (flags 0x7, heap 2 of 256 MiB), device address 1 title memory (a constant ring): CPU-written table V# 0/64 (rewritten before the submission: yes), created CBV 0/64, root view 0/64; ... line 492: raw_ok == kElements && cbv_ok == kElements && root_ok == kElements ``` The cause: - `LEONIDA_GEOMETRY_MB` views are allocated through `TitleBufferWindows::allocate(..., device_local = true)`, which *requires* `DEVICE_LOCAL | HOST_VISIBLE | HOST_COHERENT`. - Without Resizable BAR the only such heap is the 256 MiB BAR window. The default 256 MiB GPU address arena (required `HOST_VISIBLE | HOST_COHERENT`, preferred `DEVICE_LOCAL`) fits it exactly, since `memory_type_order` accepts a heap as large as the request, so the arena takes the whole BAR heap. - Every 4 MiB view block then fails with `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. And `main` passes with `LEONIDA_ARENA_MB` set 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_MB` is now described as the cap for the views wherever they are, since the cap also counts fallback blocks. - The arena note in `docs/d3d12_vulkan.md` said 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 `main` `42537e7b6`: - `ctest -R "^d3d12_(geometry_views|title_va)$"`: both pass, 3 of 3 runs. Without the change, `d3d12_geometry_views` fails 3 of 3 and `d3d12_title_va` passes. The fallback line is printed once. - Full `ctest` on `main` without the change: 399 of 402. The failures are `d3d12_geometry_views` (this), `d3d12_texture_tiles` (#964) and `d3d12_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 - [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. (No translator change.) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1691
No description provided.