Skip to content

D3D12.X: DPI-aware XCL window, borderless fullscreen and a monitor choice - #734

Open
MrCheese5 wants to merge 4 commits into
xcl-dev:mainfrom
MrCheese5:uw-b2-window
Open

MrCheese5 wants to merge 4 commits into
xcl-dev:mainfrom
MrCheese5:uw-b2-window

Conversation

@MrCheese5

@MrCheese5 MrCheese5 commented Nov 24, 2026 •

Copy link
Copy Markdown

Stacked on #555, #732 and #733; only the top commit belongs here.

At 125 % display scaling, Windows enlarged the DPI-unaware XCL window, so the game's image was drawn smaller and then blurred back up.

  • The process is per-monitor DPI aware (V2), set in host_main before the window exists. window_width and window_height are at 100 % and get scaled by the monitor's DPI, and WM_DPICHANGED takes the size Windows suggests.
  • fullscreen (XCL_FULLSCREEN, default false): a borderless window over the monitor at its native resolution. Alt+Enter or F11 switches while the game runs.
  • monitor (XCL_MONITOR, default "primary"): "primary", a number from the monitor N: list logged at start, or a device name. With window_pos = "auto", the window is centred on a named monitor.

This changes behaviour for everyone on a scaled display: a 1280x720 window is 1600x900 pixels at 125 %, the same size on screen as before, but sharp.

What is in it

  • crates/xcl/src/hle/d3d12x/present.rs: DPI awareness, the monitor list and choice, fullscreen and its toggle, the window sized at the monitor's DPI; a test of pick_monitor()
  • crates/xcl/src/host.rs: dpi_aware() at start
  • crates/xcl/Cargo.toml: the Win32_UI_HiDpi feature of the windows crate (no new crate)
  • crates/xcl/src/config.rs, README.md: fullscreen, monitor

Tested

  • RTX 4090 (driver 621.14), i9-14900K, Windows 11 26200, Rust stable-x86_64-pc-windows-msvc, debug tests, release smoke runs
  • cargo test -p xcl --lib pick_monitor: covered by the suite run below
  • cargo test --workspace -- --test-threads=1: 698 passed, 0 failed, 41 ignored; SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64)
  • Single-threaded on purpose: with --test-threads=4, GPU tests on this machine hang or lose the device tonight on main too (bdab194 and 91f9a5e; bdab194 had passed with 4 threads earlier the same night, and the driver logs GPU errors). Single-threaded, main 91f9a5e passes (cargo test -p xcl --lib -- --test-threads=1: 647 passed, 0 failed).

Regression run
Both runs use a fresh data root of their own and the default settings (a 1280x720 window, nothing new turned on), so this shows that nothing else changes.

xcl-smoke v1
commit: 91f9a5e9f03156ea82dc55a18f7704862da7a5db
gpu: NVIDIA GeForce RTX 4090
title: Xbox
seconds: 60
exit: 0x0
frames shown: 811 (PresentX 811)
presents per 2 s (last 3): 37 34 36
device removals: 0
crashes: 0
peak commit: 15536 MB
xcl-smoke v1
commit: d8dfa6f2d54bf5fe89bf10869598aab7a3c7357d
gpu: NVIDIA GeForce RTX 4090
title: Xbox
seconds: 60
exit: 0x0
frames shown: 835 (PresentX 835)
presents per 2 s (last 3): 36 37 36
device removals: 0
crashes: 0
peak commit: 15550 MB

Not tested

  • Alt+Enter and F11 by hand, and WM_DPICHANGED when moving between monitors of different scales.
  • Fullscreen on a secondary monitor.
  • AMD and wave64 GPUs.

AI use

  • Claude Code with Claude Opus 5.5: wrote the code, the tests and this description; the hardware checks above are runs on the machine named under Tested.

🤖 Generated with Claude Code

simnJS and others added 4 commits November 24, 2026 03:26
Text and thin lines of a retail title looked jagged in the XCL window.
Root cause: the title presents 3840x2160, present.rs copied it into a
swap chain of the same size (DXGI_SCALING_STRETCH) and DWM shrank it to
the window (1280x720 by default) with a single bilinear tap per pixel:
at 3x or 1.5x it skips texels, so strokes get uneven and edges
stair-step. A full-size frame dump of the same frame is clean.

When the window's client area is smaller than the image on either side,
the swap chain now takes the client size (ResizeBuffers on resize) and a
full-screen triangle draws the image into it: its pixel shader averages
the whole footprint of each window pixel (area filter, exact partial
texel weights), in linear light - 8/10-bit UNORM decoded and encoded
with the sRGB curve (the swap chain's default colour space), an _SRGB
source through its view, FP16 (scRGB) as is. A window as large as the
image keeps the copy; a minimized one (0x0) shows nothing and keeps its
swap chain. Without DXC (or a pipeline the device refuses) the copy
stays, with one log line. Frame dumps still read the title's own image.
One "present:" line names the route and the sizes.

Resizes: the presenter draws on the title's adopted device, whose
CreateRenderTargetView hook (note_rtv) keeps a reference to every view's
resource; the filter's view of a back buffer would hold one swap chain
buffer and make every ResizeBuffers fail (DXGI_ERROR_INVALID_CALL), so
Scaler::record forgets its own view at once. A refused ResizeBuffers is
logged once per size and asked for again twice a second; the frame is
still shown, drawn at the swap chain's current size. present_now's
per-frame work is present_frame, so a test can drive it.

Tests: the route decision; a GPU test drawing 1-pixel lines and a
checker from 3840x2160 and 1920x1080 into 1280x720 against a CPU area
filter (within 1.5 of 255); a GPU test on an adopted device with a
hidden window: frames at 1280x720, 1920x1080, 800x450 (each new back
buffer matches the CPU filter), minimized, 1280x720 again, and a refused
resize that still shows the frame.

Assisted-by: Claude Code (Claude Opus 5.5)
Dropping a Presenter released the swap chain, the scaler's descriptor
heaps and the title's image while its last present's command list could
still be running on the GPU. swap_chain_follows_the_window drops its
presenter right after the last present_frame; when the list was still
running, the device was suspended (0x887A0005) and the GPU tests that
ran after it failed. That happens intermittently and depends on timing.
The drop now waits for the presenter's fence (2 s at most; not after a
failed Signal, when the presenter is disabled).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A 16:9 image in a window of another shape (a 21:9 or 16:10 screen) was
stretched to it. The swap chain is now the client area's size and the
image is placed in it by `scaling` (xcl.toml, XCL_SCALING):
- "fit" (default): the aspect ratio is kept, with black bars
- "integer": whole multiples only (falls back to fit in a smaller window)
- "stretch": the old behaviour

An image that lands 1:1 (3840x2160 in a 5120x2160 client area) is copied
texel for texel at its place (Route::Place, after clearing the bars).
Other sizes go through the area filter, which now draws into a rectangle
(viewport + an origin root constant) with the bars cleared to black.
Without DXC the old stretched copy stays.

Tests: place() for each scaling, the routes, and on the GPU a 1280x720
image placed 1:1 in 1680x720 (exact texels, black bars) and filtered
into 1032x432 (against a CPU area filter).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oice

At 125 % display scaling Windows enlarged the DPI-unaware XCL window, so
the game's image was drawn smaller and blurred back up.

- The process is per-monitor DPI aware (V2), set in host_main before the
  window exists. window_width / window_height are at 100 % and scaled by
  the monitor's DPI, and WM_DPICHANGED takes the size Windows suggests.
- `fullscreen` (XCL_FULLSCREEN): a borderless window over the monitor at
  its native resolution. Alt+Enter or F11 switches while running.
- `monitor` (XCL_MONITOR): "primary", a number from the list logged at
  start, or a device name. "auto" placement centres on a named monitor.

Test: pick_monitor() for each kind of setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LocranKing

Copy link
Copy Markdown

Tested on Windows 11 + NVIDIA GeForce RTX 3060 Ti (8 GB, wave32).

Tested

  • Commit: d8dfa6f2d54bf5fe89bf10869598aab7a3c7357d (pr-734, clean tree)
  • Hardware / software: Windows 11 Home Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2101), rustc 1.100.0 (x86_64-pc-windows-msvc, MSVC 14.44.35207), DXC 1.9.2602.17 (SDK 10.0.26100.0), --release
  • cargo test --workspace --release --no-fail-fast -- --test-threads=4:
    • xcl lib: 657 passed, 1 failed, 21 ignored (hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state panicked at crates\xcl\src\hle\d3d12x\real.rs:5355:17 on assert_ne!(VirtualFree(...), 0)).
    • Remaining 15 workspace targets: 40 passed, 0 failed, 20 ignored; 2 (no wave64) skipped (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware).
    • Re-run standalone (cargo test --release -p xcl --lib coherent_buffer_sanitizes_console_flags_and_state): 1 passed, 0 failed (appears to be a --test-threads=4 concurrency flake, not a regression from D3D12.X: DPI-aware XCL window, borderless fullscreen and a monitor choice #734).

Regression run (scripts/smoke.ps1, 60 s, XCL_NETWORK=0, title folder name redacted)

main (64b3f35):

xcl-smoke v1
commit: 64b3f35599bb7102f55d640e1a791e7d6dd3b175
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 544 (PresentX 545)
presents per 2 s (last 3): 22 22 21
device removals: 0
crashes: 0
peak commit: 15491 MB

PR #734 (d8dfa6f):

xcl-smoke v1
commit: d8dfa6f2d54bf5fe89bf10869598aab7a3c7357d
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1553 (PresentX 1553)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14711 MB

Not tested: Multi-monitor / borderless fullscreen / DPI-scaled interactive checks, debug build, XCL_SAMPLE_* tests on this branch, AMD / wave64 hardware.

AI use: Antigravity (Gemini 4 Hydrogen) ran the build, tests, and smoke runs and drafted this report from the command outputs.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of d8dfa6f2d54bf5fe89bf10869598aab7a3c7357d on AMD RDNA4. I merged it onto current main 64b3f35 locally (clean merge), so the tree tested includes the stack under it (#555, #732, #733).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 707 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 666 passed, 0 failed, 21 ignored
  • 0 SKIPPED; pick_monitor_by_setting and the other present tests pass.

Review: Per-monitor DPI awareness (V2) is set in host_main before any window exists, which is the order Windows requires. The window and fullscreen behaviour itself needs a desktop session and was not exercised by the tests; I reviewed the top commit only.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

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.

4 participants