host: prefer high-performance discrete GPU adapter via IDXGIFactory6 #663
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!663
Loading…
Reference in a new issue
No description provided.
Delete branch "nyutt/merge-high-perf-adapter"
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?
Contributor role (optional)
What it changes
Merge: read fromcrates/darner-gpu/src/host.rs.create()callsD3D12CreateDevice(None, ...)(default adapter enumeration order), which on systems with an integrated GPU enabled (such as Ryzen 7 7800X3D iGPU + discrete RTX GPU, or laptops) can pick the wrong adapter if Windows enumerates the iGPU as index 0.Add
pick_high_performance_adapter()usingIDXGIFactory6::EnumAdapterByGpuPreference(..., DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE), skipping software (DXGI_ADAPTER_FLAG_SOFTWARE) adapters and logging the chosen adapter name and vendor ID, falling back toNoneif enumeration fails.How it was tested
6e6a0c4(based onorigin/Merge28a9b42)Merge.Merge.cargo clippy -p darner-gpu --lib --locked-> 0 new warnings inhost.rsMergeto observe the"host device: selected high-performance adapter"log line.Checklist
Merge).Merge.Checked for overlap
[pr-fix][rendering] host: prefer high-performance discrete GPU adapter via IDXGIFactory6to host: prefer high-performance discrete GPU adapter via IDXGIFactory6Tested on a laptop with two GPUs: an RTX 4050 Laptop GPU (6 GB, driver 621.24) and the Ryzen 7 8845HS's Radeon 780M, Windows 11. Windows lists the 780M first.
Without this PR (
v2026.12.05.01-test,28a9b42): the host device is made on the 780M. The picture is washed out at about 16 fps, and the NVIDIA card sits at 0 %. A per-app "High performance" GPU preference in Windows settings doesn't change this, becauseD3D12CreateDevice(None)ignores it. With the 780M disabled in Device Manager, adapter 0 becomes the Microsoft Basic Render Driver (WARP).With this PR plus the four changes below (built with
cargo build --release --locked -p darneron6e6a0c4): the device is made on the RTX 4050. The run's console shows DLSS made (960x544 to 1920x1080) and DLSS frame generation 2x on. The first start then compiles the full pipeline set for the new card, about 38,500 pipelines.I did not run this PR on its own. From reading the code, four more places still ask DXGI for adapter 0, so on a laptop like this they look at the iGPU while the device is on the dGPU:
apps/darner/src/play.rscard(): decides whether the card is NVIDIA's. That picks between offering DLSS and FSR files at the start, and is passed tooption_switches.apps/darner/src/preload.rsdriver(): the adapter and driver recorded in the preload's mark. With the iGPU's driver recorded there, a new NVIDIA driver doesn't start a new preload.crates/darner-gpu/src/mfg.rsfirst_adapter_name(): the card name forDARNER_FORCE_MFG_RTX40/ MFG Unlocker. With the iGPU first, it reads the iGPU's name, so the RTX 40 force never applies.crates/darner-shader/src/emit/host.rs: its non-WARP device is made withD3D12CreateDevice(None).Each change is the same as this PR's:
EnumAdapterByGpuPreference(0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE)on anIDXGIFactory6. Diff on top of6e6a0c4(35 lines added, 14 removed):diff
These belong in this PR rather than a new one, so I'm posting them here. I have not run
cargo testorcargo clippyon this revision.This comment was written with AI assistance (Claude Code).
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.