Skip to content

Windows: take the GPU Windows chooses for the app, on DX12 - #46

Closed
zAcherttp wants to merge 3 commits into
anomalyco:devfrom
zAcherttp:windows-gpu-choice
Closed

zAcherttp wants to merge 3 commits into
anomalyco:devfrom
zAcherttp:windows-gpu-choice

Conversation

@zAcherttp

@zAcherttp zAcherttp commented Oct 30, 2026 •

Copy link
Copy Markdown

Windows: take the GPU Windows chooses for the app, on DX12

On a Windows desktop with an integrated GPU and a discrete card driving the monitor, Rune draws on the integrated GPU and copies every frame across. It also lands on Vulkan, so the DirectComposition path #31 set up for DX12 never runs for an opaque window. On an Intel UHD 730 + RTX 4070 machine (240 Hz monitor on the RTX), hello:

dev This PR
GPU, backend Intel UHD 730, Vulkan RTX 4070, DX12
Resize step (Resized to drawn, median) 34 ms, 33.6 of them in surface.configure 3.3 ms
Frames during a drag 19/s 160–178/s
Device ready after process start (median of 9) 972 ms 826 ms

The configure time on the integrated GPU isn't a vsync wait: with Immediate presents it stays at 30–35 ms, so rebuilding a swapchain there for a monitor the RTX drives costs that much. Resize times come from a size-move-loop trace on a local branch, run with that branch's own resize changes switched off (RUNE_WIN_SYNC_RESIZE=0, RUNE_WIN_RESIZE_OVERSIZE=0), so both columns redraw after Resized with vsync, as dev does.

Why

The compositor match in gpu::pick is Linux-only, so Windows falls back to request_adapter(LowPower), which takes whichever backend lists the integrated GPU first. #31 works around this for translucent surfaces (translucency::prefer); opaque windows keep the low-power pick.

Fix

  • After WGPU_ADAPTER_NAME, WGPU_POWER_PREF and the compositor match, Windows takes the card DXGI lists first: the GPU set for the app in Settings > Display > Graphics, else the system default. A laptop whose panel runs off its integrated GPU keeps it.
  • Whatever picks the card, Windows takes it on DX12 before Vulkan. translucency::prefer breaks ties the same way.
  • The card order comes from DXGI's EnumAdapters1 (about 17 ms, through windows 0.62, which wgpu-hal already builds). Reading it through wgpu's DX12 enumeration opened a device on every card and added 350–400 ms before the window opened.
  • With a hardware card, Gpu::instance loads DX12 alone, so Vulkan's driver no longer loads at launch (the 146 ms above). WGPU_BACKEND (dx12, vulkan) now limits the backends, and WGPU_BACKEND=vulkan is the way back. There's no D3D12 support probe: it costs about 230 ms, and every Windows GPU with a Vulkan driver ships a D3D12 one. This is separate from RUNE_GPU_BACKEND, which picks wgpu or Metal.
  • a_device_asked_for_immediates_draws_with_them wraps its immediate in a struct, which wgpu's HLSL backend needs (Push constant of non-struct type fails to compile on DX12 gfx-rs/wgpu#5683).

House rules: changelog fragment changelog/unreleased/2026-10-30-windows-gpu-choice.md; scripts/file-size.sh passes (0 errors); rebased on current dev. This touches the same sort key in translucency::prefer as #39; I'll rebase on whichever lands first.

Testing

On the machine above:

  • RUNE_GPU_LOG=1 cargo run -p hello picks the RTX on DX12 by default, the RTX on Vulkan with WGPU_BACKEND=vulkan, and the Intel GPU on DX12 with WGPU_POWER_PREF=low or WGPU_ADAPTER_NAME=intel. RUNE_GPU_LOG=1 now also prints how long after process start the device was ready.
  • Launch times are paired, alternating runs against WGPU_BACKEND=dx12,vulkan. Before the DX12-only instance, launch matched dev (887/927 against 886/954 ms).
  • cargo test -p rune --lib: 1267 pass and 10 fail. 7 fail the same way on dev here: edit::tests::hidden_multiline_pristine_replace_and_delete, keycaps::tests::repeated_chords_count_and_named_keys_use_glyphs, render::metallib::tests::precompiled_uber_metallib_is_fresh, both text::tests::emoji_*, and both video::tests. 3 pixel-exact layer tests fail on the RTX with either backend and pass on the integrated GPU dev picks: cache_matches_uncached_at_rest_and_skips_rerasterize_on_ancestor_live_offset, filtered_video_and_image_page_match_primitive_source and clipped_single_draw_fades_do_not_allocate_targets.

Not tested on AMD. #31's PC (RTX 5070 Ti + AMD Radeon integrated) is the case to check: RUNE_GPU_LOG=1 cargo run -p overlay should name the GPU you expect on Dx12, with clear corners rather than black ones, and an opaque window should land on the card driving the monitor.

🤖 Generated with Claude Code

zAcherttp and others added 3 commits October 31, 2026 12:42
Rune took the lowest-power adapter, so a desktop with an integrated GPU and a
discrete card driving the monitor drew on the integrated one and copied every
frame across, on Vulkan. Windows now takes the card DXGI lists first (the GPU
set for the app in Settings > Display > Graphics, else the system default),
then that card's DX12 adapter before Vulkan. WGPU_ADAPTER_NAME and
WGPU_POWER_PREF still choose the card; WGPU_BACKEND now limits the backends.
translucency::prefer breaks ties by the same backend order.

The immediates upload test wraps its immediate in a struct: wgpu's HLSL
backend rejects non-struct immediates (gfx-rs/wgpu#5683).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reading the order through wgpu's DX12 enumeration opened a device on every
card, and the pick then listed every backend again, which also opens each
card's Vulkan device: 350-400 ms more before the window could open on a
two-GPU desktop. The order now comes from DXGI's EnumAdapters1 (about 17 ms,
via windows 0.62, which wgpu-hal already builds), and the card's adapter is
looked up on DX12 alone before every backend.

hello, device ready after process start, median of 7: 886/954 ms on dev,
887/927 ms with this. RUNE_GPU_LOG=1 now prints that time on Windows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every pick on Windows already lands on DX12 (by_card takes it first), but
the instance still loaded Vulkan's driver, which costs a launch about
145 ms. With a hardware card and no WGPU_BACKEND, the instance is now DX12
only; WGPU_BACKEND=vulkan still runs on Vulkan. A D3D12 support probe
would cost about 230 ms, and every Windows GPU with a Vulkan driver ships a
D3D12 one, so there is none.

hello, device ready after process start, median of 9 alternating runs:
972 ms with DX12 and Vulkan loaded, 826 ms with DX12 alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thdxr

thdxr commented Nov 6, 2026

Copy link
Copy Markdown
Member

thanks for this. rune is agent-driven, so we don't take pull requests. if you'd like a change or a bug fixed, have your agent open an issue describing it (https://github.com/anomalyco/rune/issues) and our agents will pick it up.

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.

2 participants