host: use the high-performance card when the default is integrated #3049
Open
github-bot
wants to merge 1 commit from
github-bot/gh-3049 into main
AGit
pull from: github-bot/gh-3049
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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
github/ubiquitarianism--leonida!3049
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3049"
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?
@tharun-37 on GitHub · 2026-12-02 05:32 UTC · original
tharun-37:d3d12-host-integrated-default→main· +165 −15 · 4 files · 1 commits · openFixes #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 4060ran. 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_ADAPTERnames no card,create()triesdefault_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 validLEONIDA_ADAPTERstill 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 toD3D12CreateDevice(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()returningNone, 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 ignoredcargo test -p leonida-gpu --lib --locked: 670 passed, 0 failed, 59 ignoredcargo clippy -p leonida-gpu --lib --tests --locked: no new warnings (the oneunused_mutonhost.rsis already on main)python -I scripts/check_no_game_data.py: passpython -I tools/d3d12_switches.py --check d3d12/docs/switches.md: passAI-assisted (OpenCode). An independent read-only reviewer agent audited the full diff before this was opened.
@dannyhashim08 on GitHub · 2026-12-02 08:40 UTC · original
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):
D3D12CreateDevice(None, ...)): silently pickedIntel(R) Graphics(wave lanesmin=8 max=32, UMA VRAM budget17581 MB/ shared0 MB, Streamline/DLSS-G failing withunsupported hw detected), resulting in multi-second GPU frame times andDXGI_ERROR_DEVICE_HUNG (0x887A0006)within a few minutes.IDXGIFactory6::EnumAdapterByGpuPreference(0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE)on229d352ee):NVIDIA GeForce RTX 5080 Laptop GPU(0x10de,16003 MBdedicated VRAM), wave lanesmin=32 max=32, Streamline/DLSS-G starts cleanly (sl::Result::eOk).DEVICE_HUNG/ errors; GPU wait dropped to0.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 on GitHub · 2026-12-02 11:14 UTC · original
Verified locally on Windows 10 22H2 + NVIDIA GeForce RTX 5070 12 GB (single discrete GPU, driver
621.40), PR head4d96edeaemerged cleanly ontomaina252854a2: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).host::tests::the_discrete_card_is_taken_only_in_place_of_an_integrated_default(PASS) andhost::tests::a_card_with_little_memory_of_its_own_is_integrated(PASS).python -I tools/d3d12_switches.py --check d3d12/docs/switches.md-- exit0.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-- exit0.default_adapter()cleanly preserves existing behavior on single-dGPU desktops and explicitLEONIDA_ADAPTERoverrides, safely falls back toD3D12CreateDevice(None, ...)if the high-performance adapter fails device creation, and avoids switching to/from WARP/Microsoft Basic Render Driver (VendorId == 0x1414 && DeviceId == 0x8c).< 1 GiBdedicated-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-Adapteris set or DXCoreIsIntegratedis 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 on GitHub · 2026-12-02 15:16 UTC · original
Ran natively on Windows 11, head
4d96edeaemerged into currentmain(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).cargo test -p leonida-gpu --lib --lockedcargo clippy -p leonida-gpu --lib --tests --lockedunused_mutinhost.rs, already on main; nothing newWhat DXGI reports here (from a throwaway
#[ignore]probe inhost::tests, not pushed):integrated()ARCHITECTURE1.UMAEnumAdapterByGpuPreference(HIGH_PERFORMANCE)returns the discrete card,MINIMUM_POWERthe integrated one.Adapter the host device is made on, calling
create()from the probe:main(by reading:D3D12CreateDevice(None)= adapter 0)default_adapter()=NoneLEONIDA_D3D12_WARP=1(diagnostics build)LEONIDA_ADAPTER=#1LEONIDA_ADAPTER=#0LEONIDA_ADAPTER=nomatchSo 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, andtakes_fast_card(<integrated adapter>, Some(<discrete card>))with the real descriptors from this machine returnsfalse. 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 reportsUMA = trueinD3D12_FEATURE_DATA_ARCHITECTURE1, and the discrete card reportsfalse, so that flag, or DXCore'sIsIntegratedthat the comment mentions, separates the two here where dedicated memory does not.UMAneeds 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 indefault_adapter()'s comment.Other checks, by reading:
IDXGIFactory6:high_performance_adapter()returnsNonethrough.ok()?,default_adapter()returnsNone, and the run falls back toD3D12CreateDevice(None)as on main. Not run: the interface exists on every Windows 10 1803+ install, so it could not be removed here.IDXGIAdapter3(memory budget) is found withEnumAdapterByLuid(device.GetAdapterLuid()), as areplaces.rs,indirect.rs,replay/gpu.rs,fg.rs(Streamline). None of the runtime paths assumes adapter 0. The remainingD3D12CreateDevice(None)andEnumAdapters(0)calls are in tests (trainer.rs,dlss.rs,indirect.rsbenchmarks), 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 on GitHub · 2026-12-02 18:12 UTC · original
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.
4d96edeaedmain45dc41f95c(clean merge treeb93e734122; merge base8422def759, 206 commits behind)43fc605ed)Ran (Linux, Python 3.13.18, on an export of the merge tree)
Review
takes_fast_cardswitches only when adapter 0 is non-software with under 1 GiB of its own memory, and DXGI'sHIGH_PERFORMANCEadapter is a different, non-software card with at least 1 GiB. If that card cannot make a device, it warns and falls back toD3D12CreateDevice(None). A validLEONIDA_ADAPTERstill 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 inchosen_adapter, soLEONIDA_ADAPTER=#0on a hosted runner no longer picks it. That is a small behaviour change outside the default path; worth one line in the description.integrated()); DXCoreIsIntegratedwould be exact. Fine as a first step.Overlaps
git merge-tree pr/3049 pr/3141givesCONFLICT (content)ind3d12/crates/leonida-gpu/src/host.rs. Both rewrite the no-adapter branch ofcreate(), and #3141's warning ("name the card with LEONIDA_ADAPTER") is moot once this switch is automatic.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
@MoonEyes on GitHub · 2026-12-02 22:01 UTC · original
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:mainSHA it was merged onto;mainalone 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 on GitHub · 2026-12-02 22:25 UTC · original
VERIFY-3049 — Windows nativo: los dos tests pasan, y el control muerde la heurística
(this PR)8422def75(behindmainb41763227)main—merge-treeclean,git merge --no-ffclean (auto-mergedREADME.md,host.rs,host/menu.rs,play-nvidia.ps1)Ran
Negative control (synthetic): I inverted the heuristic (
DedicatedVideoMemory > 1 << 30), rebuilt and ran: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'sIsIntegratedsays 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_adapterpicking 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 ispub(crate)inplaces/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
Written with an AI assistant.
@fiestorra on GitHub · 2026-12-03 07:08 UTC · original
#3286y#3049son el mismo arreglo por dos vías, y los dos estánBLOCKEDesperando una aprobaciónLo encontré siguiendo una nota de mi propio
#2999, que dice literalmente en un comentario del código: «If#3049lands, 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:Los dos cambian la misma decisión en
host.rs: cuando el adaptador por defecto es la integrada, usar el de alto rendimiento.#3049es más grande y más explícito (165 líneas contra 72, y documenta el interruptor enswitches.md);#3286trae ademáswide_eachsin bloqueo y el-Builddel 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:
#3286primero, porque es el que he medido (716/0 en el crate entero) y el que menos toca;#3049después, reducido a lo que#3286no hace — su documentación deswitches.mdy el caso del laptop;#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:
MERGEABLEconBLOCKEDy 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 on GitHub · 2026-12-03 07:26 UTC · original
Reviewed
4d96edeaond9b618f1. 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 explicitRadeonand#1both 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.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.