Skip to content

win32: Present through a DXGI flip model swap chain - #381

Open
iamdarkle wants to merge 1 commit into
rust-windowing:masterfrom
iamdarkle:win32-dxgi-present
Open

iamdarkle wants to merge 1 commit into
rust-windowing:masterfrom
iamdarkle:win32-dxgi-present

Conversation

@iamdarkle

Copy link
Copy Markdown

Tested on:

  • Win32 (tier 1)

GDI blits go straight into the surface that DWM composes from, so a composition during a present can show the top of a new frame over the bottom of the old one. Slint's software renderer tears like this while scrolling (slint-ui/slint#15023). This presents through a flip model swap chain on a WARP device instead, the way Chromium's software output does on Windows 11.

  • The buffer is a mapped staging texture. Presenting copies the damage into the back buffer and passes it to Present1 as dirty rectangles.
  • GDI is still used where Direct3D 11 or flip model isn't available. That has to be decided before the first present, since GDI no longer draws into a window after a flip model present (docs).
  • windows-sys has no COM interfaces and the windows crate needs Rust 1.82, so the few Direct3D methods are declared by hand, with vtables checked against the windows crate.

The new tests draw into real windows and read back what DWM shows. They pass on GitHub's Windows Server 2022 and 2025 runners (x86_64 and i686) and on the Windows 11 arm64 runner, and they fail when the damage copy is removed.

On those runners presenting took as long as with GDI and never waited for vblank, and minimized or hidden windows kept their frames. An 800x600 surface used about 0.3 MiB more private memory and 2 MiB more working set, which is the swap chain's extra buffer. Since a restored window keeps its content, #375 now only matters for the GDI path, and the device context thread only starts for GDI (#250). Outside a buffer smaller than the window, the window shows black instead of white.

This follows the review of slint-ui/slint#15027, where Slint presented through DXGI itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant