host: use the high-performance card when the default is integrated #3049

Open
tharun-37 wants to merge 1 commit from upstream-pr/3049 into main
tharun-37 commented 2026-12-02 05:32:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tharun-37 on 2026-12-02T05:32:40Z.


Fixes #3034.

On a hybrid laptop Windows' default adapter is often the integrated GPU, and D3D12CreateDevice(None) made the host device there: #3034's runs on a 512 MB Radeon 610M (15,683 MB shared budget) ended in a device removal, where -Adapter 4060 ran. The shader host already asks DXGI for the highest-performance adapter in its tests (leonida-shader/src/emit/host.rs); the runtime now agrees with it.

When LEONIDA_ADAPTER names no card, create() tries default_adapter(): if adapter 0 is an integrated GPU (under 1 GiB of its own memory) and DXGI's highest-performance adapter is a different, non-software card with memory of its own, the host device is made on that card, and the start logs both names and the card's memory. Everything else is unchanged: a valid LEONIDA_ADAPTER still wins, a default card with memory of its own stays, an iGPU-only system stays, and if the preferred card cannot make a device the run falls back to D3D12CreateDevice(None) with a warning naming the card.

The rule is a pure predicate (takes_fast_card) with unit tests covering the 1 GiB boundary, the same LUID, a software fast card, a software/Basic Render Driver default, and no fast card. A red control that forces the predicate off makes the new test fail on its first assertion. -Adapter's help and the menu's unset value ("AUTOMATIC") now describe the automatic choice.

This addresses items 1 and 2 of #3034 (the start names the card when it switches; the general adapter log is #2948). Item 3, refusing or flagging a budget larger than the card's dedicated memory, is a separate memory-plan decision and is not changed here.

Not repeated on a laptop whose default card is the integrated GPU: on this machine adapter 0 is already the discrete card (RTX 4060 Laptop + Intel UHD) and a DXGI probe shows default_adapter() returning None, so the default is untouched. The integrated-default case is covered by the unit rule.

Tests (Windows 11, RTX 4060 Laptop, driver 32.0.16.2140; no game files):

  • cargo test -p leonida-gpu --lib host::tests --locked: 69 passed, 1 ignored
  • cargo test -p leonida-gpu --lib --locked: 670 passed, 0 failed, 59 ignored
  • cargo clippy -p leonida-gpu --lib --tests --locked: no new warnings (the one unused_mut on host.rs is already on main)
  • python -I scripts/check_no_game_data.py: pass
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: pass

AI-assisted (OpenCode). An independent read-only reviewer agent audited the full diff before this was opened.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5600519548 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3049). Originally posted by [tharun-37](https://github.com/tharun-37) on 2026-12-02T05:32:40Z. --- Fixes #3034. On a hybrid laptop Windows' default adapter is often the integrated GPU, and `D3D12CreateDevice(None)` made the host device there: #3034's runs on a 512 MB Radeon 610M (15,683 MB shared budget) ended in a device removal, where `-Adapter 4060` ran. The shader host already asks DXGI for the highest-performance adapter in its tests (`leonida-shader/src/emit/host.rs`); the runtime now agrees with it. When `LEONIDA_ADAPTER` names no card, `create()` tries `default_adapter()`: if adapter 0 is an integrated GPU (under 1 GiB of its own memory) and DXGI's highest-performance adapter is a different, non-software card with memory of its own, the host device is made on that card, and the start logs both names and the card's memory. Everything else is unchanged: a valid `LEONIDA_ADAPTER` still wins, a default card with memory of its own stays, an iGPU-only system stays, and if the preferred card cannot make a device the run falls back to `D3D12CreateDevice(None)` with a warning naming the card. The rule is a pure predicate (`takes_fast_card`) with unit tests covering the 1 GiB boundary, the same LUID, a software fast card, a software/Basic Render Driver default, and no fast card. A red control that forces the predicate off makes the new test fail on its first assertion. `-Adapter`'s help and the menu's unset value ("AUTOMATIC") now describe the automatic choice. This addresses items 1 and 2 of #3034 (the start names the card when it switches; the general adapter log is #2948). Item 3, refusing or flagging a budget larger than the card's dedicated memory, is a separate memory-plan decision and is not changed here. Not repeated on a laptop whose default card is the integrated GPU: on this machine adapter 0 is already the discrete card (RTX 4060 Laptop + Intel UHD) and a DXGI probe shows `default_adapter()` returning `None`, so the default is untouched. The integrated-default case is covered by the unit rule. Tests (Windows 11, RTX 4060 Laptop, driver 32.0.16.2140; no game files): - `cargo test -p leonida-gpu --lib host::tests --locked`: 69 passed, 1 ignored - `cargo test -p leonida-gpu --lib --locked`: 670 passed, 0 failed, 59 ignored - `cargo clippy -p leonida-gpu --lib --tests --locked`: no new warnings (the one `unused_mut` on `host.rs` is already on main) - `python -I scripts/check_no_game_data.py`: pass - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md`: pass AI-assisted (OpenCode). An independent read-only reviewer agent audited the full diff before this was opened.
dannyhashim08 commented 2026-12-02 08:40:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by dannyhashim08 on 2026-12-02T08:40:28Z.


Verified this approach on a hybrid-graphics laptop where DXGI adapter 0 is the integrated GPU (Intel(R) Graphics + NVIDIA GeForce RTX 5080 Laptop GPU, driver 621.47, Windows 11):

  • Before (D3D12CreateDevice(None, ...)): silently picked Intel(R) Graphics (wave lanes min=8 max=32, UMA VRAM budget 17581 MB / shared 0 MB, Streamline/DLSS-G failing with unsupported hw detected), resulting in multi-second GPU frame times and DXGI_ERROR_DEVICE_HUNG (0x887A0006) within a few minutes.
  • After (IDXGIFactory6::EnumAdapterByGpuPreference(0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE) on 229d352ee):
    • Selects NVIDIA GeForce RTX 5080 Laptop GPU (0x10de, 16003 MB dedicated VRAM), wave lanes min=32 max=32, Streamline/DLSS-G starts cleanly (sl::Result::eOk).
    • 9+ minutes (>5,000 frames) with zero DEVICE_HUNG / errors; GPU wait dropped to 0.2–8.6 ms/frame (10–31% busy).
    • cargo test -p leonida-gpu --lib host::tests: 67 passed, 0 failed.

(Note: AI-assisted testing/comment.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7339770718 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3049#issuecomment-7339770718). Originally posted by [dannyhashim08](https://github.com/dannyhashim08) on 2026-12-02T08:40:28Z. --- Verified this approach on a hybrid-graphics laptop where DXGI adapter 0 is the integrated GPU (Intel(R) Graphics + NVIDIA GeForce RTX 5080 Laptop GPU, driver 621.47, Windows 11): - **Before (`D3D12CreateDevice(None, ...)`):** silently picked `Intel(R) Graphics` (wave lanes `min=8 max=32`, UMA VRAM budget `17581 MB` / shared `0 MB`, Streamline/DLSS-G failing with `unsupported hw detected`), resulting in multi-second GPU frame times and `DXGI_ERROR_DEVICE_HUNG (0x887A0006)` within a few minutes. - **After (`IDXGIFactory6::EnumAdapterByGpuPreference(0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE)` on `229d352ee`):** - Selects `NVIDIA GeForce RTX 5080 Laptop GPU` (`0x10de`, `16003 MB` dedicated VRAM), wave lanes `min=32 max=32`, Streamline/DLSS-G starts cleanly (`sl::Result::eOk`). - 9+ minutes (>5,000 frames) with zero `DEVICE_HUNG` / errors; GPU wait dropped to `0.2–8.6 ms/frame` (10–31% busy). - `cargo test -p leonida-gpu --lib host::tests`: 67 passed, 0 failed. (Note: AI-assisted testing/comment.)
lixonik commented 2026-12-02 11:14:35 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T11:14:35Z.


Verified locally on Windows 10 22H2 + NVIDIA GeForce RTX 5070 12 GB (single discrete GPU, driver 621.40), PR head 4d96edeae merged cleanly onto main a252854a2:

  • Unit tests:
    • cargo test -p leonida-gpu --locked --lib host::tests:: -- --skip depth_bounds_pipeline_loads_and_filters_draws -- 68 passed, 0 failed, 1 ignored (skipping only the pre-existing Win10 inbox-d3d12 depth-bounds test).
    • Explicitly confirmed new tests: host::tests::the_discrete_card_is_taken_only_in_place_of_an_integrated_default (PASS) and host::tests::a_card_with_little_memory_of_its_own_is_integrated (PASS).
  • Hygiene checks:
    • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md -- exit 0.
    • python -I scripts/check_no_game_data.py d3d12/README.md d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-gpu/src/host/menu.rs d3d12/scripts/play-nvidia.ps1 -- exit 0.
  • Code review notes:
    • default_adapter() cleanly preserves existing behavior on single-dGPU desktops and explicit LEONIDA_ADAPTER overrides, safely falls back to D3D12CreateDevice(None, ...) if the high-performance adapter fails device creation, and avoids switching to/from WARP/Microsoft Basic Render Driver (VendorId == 0x1414 && DeviceId == 0x8c).
    • The < 1 GiB dedicated-VRAM heuristic is clearly documented in code and README (covers standard 128-512 MiB iGPUs such as #3034's 512 MB Radeon 610M; a BIOS UMA reservation >= 1 GiB stays on the previous behavior unless -Adapter is set or DXCore IsIntegrated is used later).

Result: PASS (non-regression + unit tests + clean-room verified on desktop RTX 5070; complements @dannyhashim08's hybrid-laptop verification).

AI-assisted: yes (Antigravity).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7343633373 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3049#issuecomment-7343633373). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T11:14:35Z. --- Verified locally on Windows 10 22H2 + NVIDIA GeForce RTX 5070 12 GB (single discrete GPU, driver `621.40`), PR head `4d96edeae` merged cleanly onto `main` `a252854a2`: - **Unit tests:** - `cargo test -p leonida-gpu --locked --lib host::tests:: -- --skip depth_bounds_pipeline_loads_and_filters_draws` -- **68 passed, 0 failed, 1 ignored** (skipping only the pre-existing Win10 inbox-d3d12 depth-bounds test). - Explicitly confirmed new tests: `host::tests::the_discrete_card_is_taken_only_in_place_of_an_integrated_default` (**PASS**) and `host::tests::a_card_with_little_memory_of_its_own_is_integrated` (**PASS**). - **Hygiene checks:** - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` -- exit `0`. - `python -I scripts/check_no_game_data.py d3d12/README.md d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-gpu/src/host/menu.rs d3d12/scripts/play-nvidia.ps1` -- exit `0`. - **Code review notes:** - `default_adapter()` cleanly preserves existing behavior on single-dGPU desktops and explicit `LEONIDA_ADAPTER` overrides, safely falls back to `D3D12CreateDevice(None, ...)` if the high-performance adapter fails device creation, and avoids switching to/from WARP/Microsoft Basic Render Driver (`VendorId == 0x1414 && DeviceId == 0x8c`). - The `< 1 GiB` dedicated-VRAM heuristic is clearly documented in code and README (covers standard 128-512 MiB iGPUs such as #3034's 512 MB Radeon 610M; a BIOS UMA reservation >= 1 GiB stays on the previous behavior unless `-Adapter` is set or DXCore `IsIntegrated` is used later). Result: **PASS** (non-regression + unit tests + clean-room verified on desktop RTX 5070; complements `@dannyhashim08`'s hybrid-laptop verification). AI-assisted: yes (Antigravity).
Kal0s-design commented 2026-12-02 15:16:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T15:16:46Z.


Ran natively on Windows 11, head 4d96edeae merged into current main (43fc605ed, merges cleanly), toolchain 1.98.1, --locked, on a desktop with a discrete card and an integrated adapter both enabled (plus the Basic Render Driver).

Check Result
cargo test -p leonida-gpu --lib --locked 698 passed, 0 failed, 59 ignored (both new tests included)
cargo clippy -p leonida-gpu --lib --tests --locked one unused_mut in host.rs, already on main; nothing new

What DXGI reports here (from a throwaway #[ignore] probe in host::tests, not pushed):

DXGI index Dedicated memory integrated() D3D12 ARCHITECTURE1.UMA
Discrete card #0 several GB false false
Integrated adapter #1 1876 MB false true
Basic Render Driver #3 0 true (software) true

EnumAdapterByGpuPreference(HIGH_PERFORMANCE) returns the discrete card, MINIMUM_POWER the integrated one.

Adapter the host device is made on, calling create() from the probe:

Setting PR main (by reading: D3D12CreateDevice(None) = adapter 0)
nothing set discrete (#0), default_adapter() = None discrete (#0)
LEONIDA_D3D12_WARP=1 (diagnostics build) software adapter software adapter
LEONIDA_ADAPTER=#1 integrated adapter (override respected) same
LEONIDA_ADAPTER=#0 discrete same
LEONIDA_ADAPTER=nomatch warning, then the automatic choice: discrete warning, then adapter 0

So on this machine the PR changes nothing, as on the author's laptop: adapter 0 is already the discrete card. I did not change Windows' graphics preference to make the integrated adapter the default.

The finding: this integrated adapter would not be caught by the 1 GiB rule. It reports 1876 MB of dedicated memory (presumably the firmware UMA carve-out), so integrated() is false for it, and takes_fast_card(<integrated adapter>, Some(<discrete card>)) with the real descriptors from this machine returns false. If it were the default adapter, the run would stay on it, which is the #3034 situation. The code comment already names this case ("an integrated GPU that reserves 1 GiB or more passes for a card"); this is a real adapter that does it, on current hardware. The same adapter reports UMA = true in D3D12_FEATURE_DATA_ARCHITECTURE1, and the discrete card reports false, so that flag, or DXCore's IsIntegrated that the comment mentions, separates the two here where dedicated memory does not. UMA needs a device on the default adapter first; DXCore does not.

A side effect of the same case: the shader host (leonida-shader/src/emit/host.rs) always takes the high-performance adapter, so with such an integrated adapter as default the runtime and the shader host would sit on different adapters, against the "the run and its shaders agree" note in default_adapter()'s comment.

Other checks, by reading:

  • No IDXGIFactory6: high_performance_adapter() returns None through .ok()?, default_adapter() returns None, and the run falls back to D3D12CreateDevice(None) as on main. Not run: the interface exists on every Windows 10 1803+ install, so it could not be removed here.
  • LUID consistency: after the device is made, the host's IDXGIAdapter3 (memory budget) is found with EnumAdapterByLuid(device.GetAdapterLuid()), as are places.rs, indirect.rs, replay/gpu.rs, fg.rs (Streamline). None of the runtime paths assumes adapter 0. The remaining D3D12CreateDevice(None) and EnumAdapters(0) calls are in tests (trainer.rs, dlss.rs, indirect.rs benchmarks), which stay on the default adapter.
  • d3d12/README.md: "On a laptop with an integrated and a discrete GPU, the default is usually the discrete one, and the switch is logged" reads against the sentence before it and the PR description (the default is often the integrated one). Probably "the card taken is usually the discrete one" was meant.

Not checked: a machine where the integrated adapter is DXGI's adapter 0, a device-creation failure on the high-performance card, a title run, Linux/Proton.

GPUs tested: one NVIDIA desktop card, one integrated adapter + WARP.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7350053618 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3049#issuecomment-7350053618). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T15:16:46Z. --- Ran natively on Windows 11, head `4d96edeae` merged into current `main` (`43fc605ed`, merges cleanly), toolchain 1.98.1, `--locked`, on a desktop with a discrete card and an integrated adapter both enabled (plus the Basic Render Driver). | Check | Result | |---|---| | `cargo test -p leonida-gpu --lib --locked` | 698 passed, 0 failed, 59 ignored (both new tests included) | | `cargo clippy -p leonida-gpu --lib --tests --locked` | one `unused_mut` in `host.rs`, already on main; nothing new | What DXGI reports here (from a throwaway `#[ignore]` probe in `host::tests`, not pushed): | | DXGI index | Dedicated memory | `integrated()` | D3D12 `ARCHITECTURE1.UMA` | |---|---|---|---|---| | Discrete card | #0 | several GB | false | false | | Integrated adapter | #1 | **1876 MB** | **false** | **true** | | Basic Render Driver | #3 | 0 | true (software) | true | `EnumAdapterByGpuPreference(HIGH_PERFORMANCE)` returns the discrete card, `MINIMUM_POWER` the integrated one. Adapter the host device is made on, calling `create()` from the probe: | Setting | PR | `main` (by reading: `D3D12CreateDevice(None)` = adapter 0) | |---|---|---| | nothing set | discrete (#0), `default_adapter()` = `None` | discrete (#0) | | `LEONIDA_D3D12_WARP=1` (diagnostics build) | software adapter | software adapter | | `LEONIDA_ADAPTER=#1` | integrated adapter (override respected) | same | | `LEONIDA_ADAPTER=#0` | discrete | same | | `LEONIDA_ADAPTER=nomatch` | warning, then the automatic choice: discrete | warning, then adapter 0 | So on this machine the PR changes nothing, as on the author's laptop: adapter 0 is already the discrete card. I did not change Windows' graphics preference to make the integrated adapter the default. The finding: **this integrated adapter would not be caught by the 1 GiB rule.** It reports 1876 MB of dedicated memory (presumably the firmware UMA carve-out), so `integrated()` is false for it, and `takes_fast_card(<integrated adapter>, Some(<discrete card>))` with the real descriptors from this machine returns `false`. If it were the default adapter, the run would stay on it, which is the #3034 situation. The code comment already names this case ("an integrated GPU that reserves 1 GiB or more passes for a card"); this is a real adapter that does it, on current hardware. The same adapter reports `UMA = true` in `D3D12_FEATURE_DATA_ARCHITECTURE1`, and the discrete card reports `false`, so that flag, or DXCore's `IsIntegrated` that the comment mentions, separates the two here where dedicated memory does not. `UMA` needs a device on the default adapter first; DXCore does not. A side effect of the same case: the shader host (`leonida-shader/src/emit/host.rs`) always takes the high-performance adapter, so with such an integrated adapter as default the runtime and the shader host would sit on different adapters, against the "the run and its shaders agree" note in `default_adapter()`'s comment. Other checks, by reading: - **No `IDXGIFactory6`:** `high_performance_adapter()` returns `None` through `.ok()?`, `default_adapter()` returns `None`, and the run falls back to `D3D12CreateDevice(None)` as on main. Not run: the interface exists on every Windows 10 1803+ install, so it could not be removed here. - **LUID consistency:** after the device is made, the host's `IDXGIAdapter3` (memory budget) is found with `EnumAdapterByLuid(device.GetAdapterLuid())`, as are `places.rs`, `indirect.rs`, `replay/gpu.rs`, `fg.rs` (Streamline). None of the runtime paths assumes adapter 0. The remaining `D3D12CreateDevice(None)` and `EnumAdapters(0)` calls are in tests (`trainer.rs`, `dlss.rs`, `indirect.rs` benchmarks), which stay on the default adapter. - `d3d12/README.md`: "On a laptop with an integrated and a discrete GPU, the default is usually the discrete one, and the switch is logged" reads against the sentence before it and the PR description (the default is often the integrated one). Probably "the card taken is usually the discrete one" was meant. Not checked: a machine where the integrated adapter is DXGI's adapter 0, a device-creation failure on the high-performance card, a title run, Linux/Proton. GPUs tested: one NVIDIA desktop card, one integrated adapter + WARP. AI-assisted: yes (Claude Code).
MoonEyes commented 2026-12-02 18:12:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:12:06Z.


Reviewed #3049 (Rust not built here: Windows-only DXGI code). The rule is a sound, well-tested predicate, and the launcher tests pass on Linux. It conflicts with #3141 and leaves #2999's new launcher note wrong, and the model disclosure is incomplete.

Head 4d96edeaed
Merged onto main 45dc41f95c (clean merge tree b93e734122; merge base 8422def759, 206 commits behind)
Windows evidence dannyhashim08 (hybrid laptop, iGPU as adapter 0: switch made), lixonik (single discrete GPU: unchanged), Kal0s-design (this head, merged onto 43fc605ed)

Ran (Linux, Python 3.13.18, on an export of the merge tree)

python -I tests/test_win_launchers.py                        OK (skipped=5; same on main)
python -I tools/d3d12_switches.py --check d3d12/docs/switches.md   exit 0
python -I scripts/check_no_game_data.py <the 4 changed files>       exit 0

Review

  • takes_fast_card switches only when adapter 0 is non-software with under 1 GiB of its own memory, and DXGI's HIGH_PERFORMANCE adapter is a different, non-software card with at least 1 GiB. If that card cannot make a device, it warns and falls back to D3D12CreateDevice(None). A valid LEONIDA_ADAPTER still wins. The unit tests cover the 1 GiB edge, same LUID, a software fast card, the Basic Render Driver stub (0x1414:0x8c) and no fast card. This is the root cause of #3034's device removal, handled where the device is made.
  • software() now also treats the Basic Render Driver as software in chosen_adapter, so LEONIDA_ADAPTER=#0 on a hosted runner no longer picks it. That is a small behaviour change outside the default path; worth one line in the description.
  • The 1 GiB heuristic is documented as such (integrated()); DXCore IsIntegrated would be exact. Fine as a first step.

Overlaps

  1. #3141 (open): git merge-tree pr/3049 pr/3141 gives CONFLICT (content) in d3d12/crates/leonida-gpu/src/host.rs. Both rewrite the no-adapter branch of create(), and #3141's warning ("name the card with LEONIDA_ADAPTER") is moot once this switch is automatic.
  2. #2999 (open) adds a note to d3d12/scripts/play-nvidia.ps1: "No -Adapter: Windows' default card is used, which may not be the NVIDIA one". It merges cleanly with this PR, but after this PR the statement is wrong for the integrated-default case. Whichever lands second should reword it.

Process. No claim ID (only Fixes #3034). The AI line says "OpenCode" without the model, and CONTRIBUTING.md asks for the specific models, including the reviewer's.

Verdict: defects (process and coordination, not code). Add the claim ID and model names, and agree the order with #3141 and #2999. The code itself I would merge.

AI-assisted: Claude Opus 5.5 (Claude Code), review only.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354110481 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3049#issuecomment-7354110481). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:12:06Z. --- **Reviewed #3049 (Rust not built here: Windows-only DXGI code). The rule is a sound, well-tested predicate, and the launcher tests pass on Linux. It conflicts with #3141 and leaves #2999's new launcher note wrong, and the model disclosure is incomplete.** | | | |---|---| | Head | `4d96edeaed` | | Merged onto | `main` `45dc41f95c` (clean merge tree `b93e734122`; merge base `8422def759`, 206 commits behind) | | Windows evidence | dannyhashim08 (hybrid laptop, iGPU as adapter 0: switch made), lixonik (single discrete GPU: unchanged), Kal0s-design (this head, merged onto `43fc605ed`) | **Ran (Linux, Python 3.13.18, on an export of the merge tree)** ``` python -I tests/test_win_launchers.py OK (skipped=5; same on main) python -I tools/d3d12_switches.py --check d3d12/docs/switches.md exit 0 python -I scripts/check_no_game_data.py <the 4 changed files> exit 0 ``` **Review** - `takes_fast_card` switches only when adapter 0 is non-software with under 1 GiB of its own memory, and DXGI's `HIGH_PERFORMANCE` adapter is a different, non-software card with at least 1 GiB. If that card cannot make a device, it warns and falls back to `D3D12CreateDevice(None)`. A valid `LEONIDA_ADAPTER` still wins. The unit tests cover the 1 GiB edge, same LUID, a software fast card, the Basic Render Driver stub (`0x1414:0x8c`) and no fast card. This is the root cause of #3034's device removal, handled where the device is made. - `software()` now also treats the Basic Render Driver as software in `chosen_adapter`, so `LEONIDA_ADAPTER=#0` on a hosted runner no longer picks it. That is a small behaviour change outside the default path; worth one line in the description. - The 1 GiB heuristic is documented as such (`integrated()`); DXCore `IsIntegrated` would be exact. Fine as a first step. **Overlaps** 1. **#3141** (open): `git merge-tree pr/3049 pr/3141` gives `CONFLICT (content)` in `d3d12/crates/leonida-gpu/src/host.rs`. Both rewrite the no-adapter branch of `create()`, and #3141's warning ("name the card with LEONIDA_ADAPTER") is moot once this switch is automatic. 2. **#2999** (open) adds a note to `d3d12/scripts/play-nvidia.ps1`: "No -Adapter: Windows' default card is used, which may not be the NVIDIA one". It merges cleanly with this PR, but after this PR the statement is wrong for the integrated-default case. Whichever lands second should reword it. **Process.** No claim ID (only `Fixes #3034`). The AI line says "OpenCode" without the model, and CONTRIBUTING.md asks for the specific models, including the reviewer's. **Verdict: defects (process and coordination, not code).** Add the claim ID and model names, and agree the order with #3141 and #2999. The code itself I would merge. AI-assisted: Claude Opus 5.5 (Claude Code), review only. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
MoonEyes commented 2026-12-02 22:01:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:01:15Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360110552 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3049#issuecomment-7360110552). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T22:01:15Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
fiestorra commented 2026-12-02 22:25:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T22:25:31Z.


VERIFY-3049 — Windows nativo: los dos tests pasan, y el control muerde la heurística

Head (this PR)
Merge base 8422def75 (behind main b41763227)
Merged onto main — merge-tree clean, git merge --no-ff clean (auto-merged README.md, host.rs, host/menu.rs, play-nvidia.ps1)

Ran

cargo test -p leonida-gpu --lib integrated           2 passed
  host::tests::a_card_with_little_memory_of_its_own_is_integrated ... ok
  host::tests::the_discrete_card_is_taken_only_in_place_of_an_integrated_default ... ok

Negative control (synthetic): I inverted the heuristic (DedicatedVideoMemory > 1 << 30), rebuilt and ran:

FAILED: a_card_with_little_memory_of_its_own_is_integrated
FAILED: the_discrete_card_is_taken_only_in_place_of_an_integrated_default
assertion failed: super::integrated(&a_card(1, 0, false))

Both bite.

What the change is: on a machine whose default D3D12 adapter is an integrated GPU, the runtime now asks DXGI for the highest-performance card and makes the device there, falling back to Windows' default if that creation fails — and it logs which card answered. The "integrated" test is a heuristic with its caveat written next to it (DedicatedVideoMemory < 1 GiB, and the doc says DXCore's IsIntegrated says it for certain, which this does not use) — I would rather see the caveat than a claim of certainty, and it is there.

A fact worth recording for whoever merges: this is the runtime half of the problem my #2995 addresses in the test half (test_adapter picking the high-performance card so the crate's tests stop making their device on the integrated one). They do not conflict — different functions, and #2995 is pub(crate) in places/tests.rs — and merged together they would make this machine agree with itself: the runtime on the 4090, the tests on the 4090.

What I could not test

  • The pick itself: this machine has an integrated Radeon and a 4090, which is exactly the configuration the change is for, but seeing which card the runtime takes is a run — no title was started.
  • The fallback (high-performance creation fails → default): needs a driver that refuses the device on that card.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360673877 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3049#issuecomment-7360673877). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T22:25:31Z. --- ## VERIFY-3049 — Windows nativo: los dos tests pasan, y el control muerde la heurística | | | |---|---| | Head | `(this PR)` | | Merge base | `8422def75` (behind `main` `b41763227`) | | Merged onto | `main` — `merge-tree` clean, `git merge --no-ff` clean (auto-merged `README.md`, `host.rs`, `host/menu.rs`, `play-nvidia.ps1`) | **Ran** ``` cargo test -p leonida-gpu --lib integrated 2 passed host::tests::a_card_with_little_memory_of_its_own_is_integrated ... ok host::tests::the_discrete_card_is_taken_only_in_place_of_an_integrated_default ... ok ``` **Negative control (synthetic)**: I inverted the heuristic (`DedicatedVideoMemory > 1 << 30`), rebuilt and ran: ``` FAILED: a_card_with_little_memory_of_its_own_is_integrated FAILED: the_discrete_card_is_taken_only_in_place_of_an_integrated_default assertion failed: super::integrated(&a_card(1, 0, false)) ``` **Both bite.** **What the change is**: on a machine whose default D3D12 adapter is an **integrated** GPU, the runtime now asks DXGI for the **highest-performance** card and makes the device there, **falling back to Windows' default if that creation fails** — and it logs which card answered. The "integrated" test is a **heuristic with its caveat written next to it** (`DedicatedVideoMemory < 1 GiB`, and the doc says DXCore's `IsIntegrated` says it for certain, which this does not use) — I would rather see the caveat than a claim of certainty, and it is there. **A fact worth recording for whoever merges**: this is the **runtime** half of the problem my #2995 addresses in the **test** half (`test_adapter` picking the high-performance card so the crate's tests stop making their device on the integrated one). **They do not conflict** — different functions, and #2995 is `pub(crate)` in `places/tests.rs` — **and merged together they would make this machine agree with itself**: the runtime on the 4090, the tests on the 4090. ## What I could not test - **The pick itself**: this machine *has* an integrated Radeon and a 4090, which is exactly the configuration the change is for, but seeing which card the runtime takes is a **run** — no title was started. - **The fallback** (high-performance creation fails → default): needs a driver that refuses the device on that card. Written with an AI assistant.
fiestorra commented 2026-12-03 07:08:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T07:08:31Z.


#3286 y #3049 son el mismo arreglo por dos vías, y los dos están BLOCKED esperando una aprobación

Lo encontré siguiendo una nota de mi propio #2999, que dice literalmente en un comentario del código: «If #3049 lands, the no-adapter case picks the high-performance card and the sentence below becomes wrong for exactly the case it warns about; reword it there.»

Así que miré #3049, y es esto:

#3049   "host: use the high-performance card when the default is integrated"
        4 files, +165/−15    BLOCKED · MERGEABLE
        doc: "Unset: Windows' default card, or the card DXGI ranks high-performance
              when the default is an integrated GPU"
        doc: "unless that card is an integrated GPU: then it runs on the card Windows
              names high-performance, and takes the default card only if the device
              cannot be made there"

#3286   "d3d12: high-performance GPU selection, lock-free wide_each, and -Build…"
        4 files, +72/−19     BLOCKED · MERGEABLE
        host.rs: high_performance_adapter() primero, D3D12CreateDevice(None) como reserva
        medido por mí: cherry-pick sobre d9b618f10 deja leonida-gpu en 716/0

Los dos cambian la misma decisión en host.rs: cuando el adaptador por defecto es la integrada, usar el de alto rendimiento. #3049 es más grande y más explícito (165 líneas contra 72, y documenta el interruptor en switches.md); #3286 trae además wide_each sin bloqueo y el -Build del script.

Y lo que eso significa para el merge, que es lo único que importa aquí: si entran los dos, el segundo va a chocar en host.rs — y si sólo entra uno, el otro queda obsoleto.

La recomendación, con los números delante:

  1. #3286 primero, porque es el que he medido (716/0 en el crate entero) y el que menos toca;
  2. #3049 después, reducido a lo que #3286 no hace — su documentación de switches.md y el caso del laptop;
  3. y #2999, mío, reescribir su aviso cuando el que entre lo haga: hoy su frase es verdad (Windows usa la tarjeta por defecto, que puede no ser la NVIDIA), y después del merge sería mentira para el caso exacto que avisa. El comentario ya lo dice y por eso lo dejo aquí, no en un cambio de código.

Y una nota sobre el "BLOCKED" de los dos: MERGEABLE con BLOCKED y sin checks rojos es una aprobación que falta, no un problema técnico. Dos PRs del mismo autor bloqueados por lo mismo es exactamente lo que se resuelve en una conversación de treinta segundos y no con más revisiones.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7370642271 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3049#issuecomment-7370642271). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T07:08:31Z. --- ## `#3286` y `#3049` son **el mismo arreglo por dos vías**, y los dos están `BLOCKED` esperando una aprobación **Lo encontré siguiendo una nota de mi propio `#2999`**, **que dice literalmente en un comentario del código**: *«If `#3049` lands, the no-adapter case picks the high-performance card and the sentence below becomes wrong for exactly the case it warns about; reword it there.»* **Así que miré `#3049`, y es esto**: ``` #3049 "host: use the high-performance card when the default is integrated" 4 files, +165/−15 BLOCKED · MERGEABLE doc: "Unset: Windows' default card, or the card DXGI ranks high-performance when the default is an integrated GPU" doc: "unless that card is an integrated GPU: then it runs on the card Windows names high-performance, and takes the default card only if the device cannot be made there" #3286 "d3d12: high-performance GPU selection, lock-free wide_each, and -Build…" 4 files, +72/−19 BLOCKED · MERGEABLE host.rs: high_performance_adapter() primero, D3D12CreateDevice(None) como reserva medido por mí: cherry-pick sobre d9b618f10 deja leonida-gpu en 716/0 ``` **Los dos cambian la misma decisión en `host.rs`**: **cuando el adaptador por defecto es la integrada, usar el de alto rendimiento.** **`#3049` es más grande y más explícito** (**165 líneas contra 72, y documenta el interruptor en `switches.md`**); **`#3286` trae además `wide_each` sin bloqueo y el `-Build` del script.** **Y lo que eso significa para el merge, que es lo único que importa aquí**: **si entran los dos, el segundo va a chocar en `host.rs`** — **y si sólo entra uno, el otro queda obsoleto.** **La recomendación, con los números delante**: 1. **`#3286` primero**, **porque es el que he medido** (**716/0 en el crate entero**) **y el que menos toca**; 2. **`#3049` después, reducido a lo que `#3286` no hace** — **su documentación de `switches.md` y el caso del laptop**; 3. **y `#2999`, mío, reescribir su aviso cuando el que entre lo haga**: **hoy su frase es verdad** (**Windows usa la tarjeta por defecto, que puede no ser la NVIDIA**), **y después del merge sería mentira para el caso exacto que avisa.** **El comentario ya lo dice y por eso lo dejo aquí, no en un cambio de código.** **Y una nota sobre el "BLOCKED" de los dos**: **`MERGEABLE` con `BLOCKED` y sin checks rojos es una aprobación que falta, no un problema técnico.** **Dos PRs del mismo autor bloqueados por lo mismo es exactamente lo que se resuelve en una conversación de treinta segundos y no con más revisiones.**
merzleckeier commented 2026-12-03 07:26:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T07:26:26Z.


Reviewed 4d96edea on d9b618f1. The adapter tests and background-processing regression pass in a Windows MSVC build with #3301 (670df262) and #3303 (5942d059) merged. I also checked the actual device selected under Wine 11.22 / VKD3D-Proton 3.1 by reading its DXGI adapter. Automatic selection and an unrecognized name used the RTX 4070 SUPER. The explicit Radeon and #1 both used AMD Raphael. Both DXGI orders put the NVIDIA card first on this machine, so the iGPU-first decision is covered here by the synthetic predicate test.

The heads of #3049 and #3286 conflict in host.rs. Their policies overlap on the hybrid case and differ with two discrete GPUs. #3049 preserves a discrete default under its memory heuristic. #3286 tries the high-performance candidate even when the default is discrete. #3286 also includes separate worker and launcher changes, with the launcher profile issues still open. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7370999161 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3049#issuecomment-7370999161). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T07:26:26Z. --- Reviewed `4d96edea` on `d9b618f1`. The adapter tests and background-processing regression pass in a Windows MSVC build with #3301 (`670df262`) and #3303 (`5942d059`) merged. I also checked the actual device selected under Wine 11.22 / VKD3D-Proton 3.1 by reading its DXGI adapter. Automatic selection and an unrecognized name used the RTX 4070 SUPER. The explicit `Radeon` and `#1` both used AMD Raphael. Both DXGI orders put the NVIDIA card first on this machine, so the iGPU-first decision is covered here by the synthetic predicate test. The heads of #3049 and #3286 conflict in `host.rs`. Their policies overlap on the hybrid case and differ with two discrete GPUs. #3049 preserves a discrete default under its memory heuristic. #3286 tries the high-performance candidate even when the default is discrete. #3286 also includes separate worker and launcher changes, with the [launcher profile issues still open](https://github.com/ProjectLeonida/mandy/pull/3286#pullrequestreview-6163242024). AI-assisted with OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3049:upstream-pr/3049'
git switch 'upstream-pr/3049'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3049'
git switch 'upstream-pr/3049'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3049'
git switch 'upstream-pr/3049'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3049'
git switch 'main'
git merge --squash 'upstream-pr/3049'
git switch 'main'
git merge --ff-only 'upstream-pr/3049'
git switch 'main'
git merge 'upstream-pr/3049'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!3049
No description provided.