Skip to content

d3d12: LEONIDA_WINDOWS_BAR_MB says once that it does nothing without resizable BAR (D3D12-BAR-WINDOWS-WARNING) - #2612

Merged
MoonEyes merged 3 commits into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-bar-windows-warning
Nov 30, 2026
Merged

MoonEyes merged 3 commits into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-bar-windows-warning

Conversation

@TheGeogeo

@TheGeogeo TheGeogeo commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-BAR-WINDOWS-WARNING (#2570 (comment))

What and why

LEONIDA_WINDOWS_BAR_MB puts title memory windows in card memory the CPU maps (D3D12_HEAP_TYPE_GPU_UPLOAD). That memory exists only with resizable BAR, and a system and driver that offer it. Without it, the cap did nothing, and nothing said so:

  • the launcher still sets 3072 on PCs with under 48 GB of RAM and prints "up to 3 GB";
  • every window first asked the card's budget (video_memory(), two QueryVideoMemoryInfo calls) and took room in the cap's counter, before mapped_card_buffer found that the heap type is not there.

This change:

  • shadow.rs: window_mapped_for checks mapped_card_memory() before anything else. Without that memory, it logs once, at info level, that the cap does nothing (LEONIDA_WINDOWS_BAR_MB is set, but the card has no GPU upload heap (it needs resizable BAR, and a Windows and driver that offer it): title memory windows stay in the PC's memory and the setting does nothing) and returns. The decision is a small pure function, mapped_windows(most, supported), that asks for support only when a cap is set; its unit test covers the three cases, not the logging or the skipped video_memory() call, which need a device.
  • play-nvidia.ps1: the default's line says the cap applies "if the card has resizable BAR". The -WindowsBarMB help gives the real default (under 48 GB of RAM and a card of 6 GB or more, since d3d12: on a card under 6 GB the launcher leaves buffer copies to the runtime and keeps windows out of VRAM #2583) instead of "under 24 GB" (an unknown card size counts as 6 GB or more).
  • d3d12/README.md: the same correction.

Behaviour with resizable BAR is unchanged. It only skips work that could not succeed.

After an independent review: the note is info rather than a warning (the launcher sets the cap by default on every PC under 48 GB), and it names GPU upload heaps rather than only resizable BAR.

Tested

On Windows 11, from d3d12\:

  • cargo test -p leonida-gpu --locked mapped_windows: the new shadow::mapped_windows_tests::a_cap_does_nothing_on_a_card_without_memory_the_cpu_maps passes. On main it does not build, because mapped_windows does not exist there.
  • cargo test --workspace --locked: every suite passes except xtask policy::tests::repository_passes_policy. That test fails the same way on main (51d343b): crates/leonida-gpu/src/host.rs (664,368 bytes) and crates/leonida-shader/src/emit/lower.rs (676,599 bytes) are over the 655,360-byte limit. This change touches neither file.
  • cargo fmt --all --check and cargo clippy --workspace --all-targets --locked -- -D warnings are already red on main, in files this change does not touch: formatting diffs across the workspace, and clippy errors in leonida-lua and leonida-shader that stop the build. In the changed lines, cargo fmt --check reports no diff, and cargo clippy -p leonida-gpu --all-targets --locked reports nothing.
  • git diff --check is clean, and so is python -I scripts/check_no_game_data.py on the three files.
  • In game, on an RTX 3080 with resizable BAR off (BAR1 256 MiB) and 32 GB of RAM, the branch's leonida.exe (diag build) ran with the launcher's default (LEONIDA_WINDOWS_BAR_MB=3072):
    • the log shows card memory the CPU maps supported=false, then the new line, once (checked with the first version of the wording; a review then changed its level to info and its text);
    • the launcher prints the new line.

GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 10.0.26300 (resizable BAR off).

AI-assisted: yes

Checklist

…resizable BAR (D3D12-BAR-WINDOWS-WARNING)

Title memory windows can only go to card memory the CPU maps when the card
has GPU upload heaps (resizable BAR, and a system and driver that offer it).
Without them the launcher still set 3072 on PCs under 48 GB of RAM and printed
"up to 3 GB", and every window asked the card's budget (two
QueryVideoMemoryInfo calls) before finding out the heap was not there.

window_mapped_for now checks for that memory first and logs once that the cap
does nothing. The launcher's line says the cap needs resizable BAR, and its
header and the README give the real default (under 48 GB of RAM, a card of
6 GB or more) instead of "under 24 GB".
…e decision covers the off case (review)

- The note is info, not a warning: the launcher sets the cap by default on
  PCs under 48 GB, so it shows on every one without resizable BAR.
- It names the real condition (GPU upload heaps: resizable BAR, and a
  Windows and driver that offer them), as the doc comments do.
- mapped_windows asks for support only when a cap is set, so its "off" case
  is the one the code takes, and the test checks that support is not asked.
- The launcher's history comment and the README say "unless the card has
  under 6 GB" (an unknown size counts as large).
@merzleckeier

Copy link
Copy Markdown
Contributor

Independent device check of 877c0d14a merged onto 4364a4fa6 on CachyOS, System Wine 11.22, VKD3D-Proton 71cae091, AMD Raphael iGPU / RADV Mesa 26.3.1. An offline fixture initialized a real D3D12 device and called the production window_mapped_for from four threads with 64 KiB per call. The only instrumentation counted calls to Host::video_memory and captured the runtime's existing tracing output.

GPU upload heap Cap Main PR
Exposed by D3D12 3072 MiB 4 budget calls, 4 mapped allocations 4 budget calls, 4 mapped allocations
Disabled through VKD3D_CONFIG=no_gpu_upload_heap 3072 MiB 4 budget calls, no mapped allocations, no message 0 budget calls, no mapped allocations, exactly 1 informational message
Either 0 MiB 0 budget calls, no mapped allocations or message 0 budget calls, no mapped allocations or message

Every case without mapped allocations also successfully made a buffer with the system-memory helper. The PR's mapped_windows unit test and No Game Data check for the three changed files passed. No game data or swap chain was used.

The RTX 4070 SUPER control did not reach the test because DXVK could not initialize a Vulkan instance in this headless setup. I did not exercise native Windows or the PowerShell launcher.

AI-assisted with OpenAI Codex (GPT-6).

@bobcatchris

Copy link
Copy Markdown
Contributor

Independent native Windows 11 + AMD Radeon RX 7900 XTX (gfx1100, driver 32.0.32029.2010, Windows 11 10.0.26200) check of 877c0d14a merged cleanly onto main 4755667f5 (no game files):

  • Baseline (main 4755667f5): cargo test -p leonida-gpu --lib -- --test-threads=4 -> 544 passed; 0 failed; 47 ignored (12.27 s).
  • PR #2612 (877c0d14a) + main 4755667f5: cargo test -p leonida-gpu --lib -- --test-threads=4 -> 545 passed; 0 failed; 47 ignored (14.20 s, +1 new test in shadow.rs, 0 regressions, 0 new compiler warnings).
  • python -I scripts/check_no_game_data.py on all 3 touched files: clean.

AI-assisted: Antigravity (Gemini 4 Neon).

@fiestorra

Copy link
Copy Markdown
Contributor

Partial verification, the part that can be checked without a Rust toolchain: the wiring and the script. I cannot build d3d12/ here (no cargo on this machine), so read this as "the names and the script agree", not "it works".

  • the knob the change documents, LEONIDA_WINDOWS_BAR_MB, is read in d3d12/crates (1 file: shadow.rs, the one this branch touches), so the README row and the code cannot be
    disagreeing about a name;
  • d3d12/scripts/play-nvidia.ps1 parses as PowerShell (Parser::ParseInput, no errors);
  • the branch is 278 commits behind main and merges cleanly against origin/main edf0ff5d0 (git merge-tree --write-tree), so it does not need a rebase to be reviewable - only to
    keep its diff to three files.

Not verified: that the flag actually says once that it does nothing without resizable BAR, which is the behaviour the title claims; that needs the Rust build and a card, and this machine has
neither in this configuration.

Written with an AI assistant.

@enlight3d

Copy link
Copy Markdown
Contributor

RUN (independent run, #2612 head 877c0d1 on main 878b024; merged locally with git merge --no-ff, no conflicts; also no conflict with #2566 head 7b5cb29 per git merge-tree --write-tree).

Commands, in d3d12/, target x86_64-pc-windows-msvc, toolchain 1.98.1:

  • cargo check --tests -p leonida-gpu: OK on the merged tree.
  • cargo test -p leonida-gpu: green, 545 passed / 0 failed / 47 ignored, including mapped_windows_tests::a_cap_does_nothing_on_a_card_without_memory_the_cpu_maps.
  • Red, behavioural: with mapped_windows ignoring the card (cap set means Try, the old behaviour), cargo test -p leonida-gpu --lib mapped_windows fails: left Try, right Unsupported.
  • Red, build: with the PR's non-test changes reverted and the test kept, it does not compile (E0432, MappedWindows and mapped_windows unresolved).
  • scripts/play-nvidia.ps1 parses with 0 errors (parser only, not run). Its default (under 48 GB of RAM, not under 6 GB of VRAM) matches the new README text.
  • Reading: with a cap set on a card without GPU upload heaps, window_mapped_for now returns None before the budget and counter steps; before, it reached the same None through mapped_card_buffer. So behaviour is unchanged apart from the one-time log line. The wiring in window_mapped_for itself (the Once message) is not exercised by a test.

No runtime/ C++ or Python in this PR, so no link or import check applies.
Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.

@MoonEyes

Copy link
Copy Markdown
Collaborator

Tested 877c0d14a merged (no commit) with main 060c47160: Windows 11, Rust toolchain from d3d12/rust-toolchain.toml, CPU only, no game run.

  • cargo test -p leonida-gpu --locked: main 549 passed, 47 ignored; with this PR 550 passed, 47 ignored, 0 failed.
  • cargo clippy -p leonida-gpu --locked -- -D warnings: 10 findings on main and the same 10 with the PR (all in leonida-lua and leonida-shader); this PR adds none.
  • Merges cleanly with main and does not force a rebase of [integration] PageMirror, GPU detile, async queue & RDNA2->SPIR-V performance stack (INTEGRATION-PERF-CPU-GPU-R6) #2566.
  • Not covered: an in-game run. It touches the render path, so before merge it should also run in game for 300 s with no device loss, as this project now asks of render-path changes.

AI-assisted (Claude Code).

@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

RUN - in-game gate (Verified by OreoFR), PROVISIONAL - RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11.

  • Base: main f9f3ec4c6; B = main + this PR at 22cd4ae24 (git merge --no-ff), diag build of leonida.exe.
  • Recipe: play-d3d12.ps1 -SeriesS -NoDlss -NoFrameGen, BAR 0, texture budget 1024, standing in the world, 360 s per run (window: world +30 to +330 s). Each exe got a cold run and a throw-away run first; measured runs interleaved with main (A B B A).

Result: PASS - 0 device loss, 0 panics, every run alive at the end.

Arm runs fps median p5 preparing (ms/frame)
main 4 24.53 (23.9-24.8) 20.35 30.3
main + #2612 2 23.85 (23.3, 24.4) 19.75 31.05
  • No fps regression beyond noise: -2.8 % against all main runs, -1.9 % against the two main runs of its own block. The run-to-run noise on this machine is ~4 %. The lower run is the first one after main, as in the other block.
  • The recipe's BAR 0 never reaches the change. mapped_windows asks for support only when a cap is set.
  • The PR's path, extra run with LEONIDA_WINDOWS_BAR_MB=3072: the log has card memory the CPU maps supported=true once. The new "does nothing" line is absent, which is correct because this card has GPU upload heaps. Windows went to mapped card memory (1616 MB at the end). The run gave 24.7 fps, was alive at the end, with no device loss.
  • Not covered: the branch this PR changes (a cap set on a card without GPU upload heaps). This laptop has resizable BAR, so it cannot take that branch.

This run was AI-assisted (Claude Code, oreofr-agent).

@MoonEyes

Copy link
Copy Markdown
Collaborator

Merging. Head 22cd4ae24 merges cleanly with main be454caa4 and does not force a rebase of #2566. Run in the game of 360 s, no device loss, posted on this head (OreoFR, RTX 4070 Laptop); cargo test on Windows with main: leonida-gpu 572 passed (main 571), leonida-shader 385 passed, 0 failed. Merged by MoonEyes.

AI-assisted (Claude Code).

@MoonEyes
MoonEyes merged commit 2a880c3 into ProjectLeonida:main Nov 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants