Skip to main content
GameDev.net gamedev.net
🔒 Locked 🤖 Godot

Trying to figure out smooth window resize with Direct2D

Started by Raph Apr 9, 2018 at 4:44 AM 4 replies 4.1k views
Original Post
Raph
Raph

I really, really would like to have smooth, artifact-free resize of an app that renders its content using Direct2D. (In point of fact, the app is an editor, but I'm using "game-like" techniques to render the UI, and a solution to this problem would be useful for games).

I've been playing with this for a while, and am frustrated that I have a couple of "almost" solutions, but nothing that works robustly. I wrote up my explorations (with links to code) on my blog. The code happens to be in Rust, but I'm calling WinAPI pretty directly, so a working recipe would be easy enough to adapt to or from C++.

I'm feeling stuck enough on this that I'm offering a $2500 bounty for a proper solution. I'd love to be able to make forward progress, and don't want to spend a lot more time on it myself.

I'm not 100% it's even possible on Windows, though I see glimmers of hope.

Raph
Raph

Replying to my own question. I think I've figured out a reasonable hybrid solution: use a swapchain with flip swap effect in the steady state, but fall back to a hwnd render target when the window is resizing. I've implemented this and collected reports from users with a wide range of configurations: https://github.com/google/xi-win/issues/19

I suspect this might be the best that can be done, but of course am open to improvements.

Thanks to Jesse (SoldierOfLight) for discussion which helped me understand what's going on.

SoldierOfLight
SoldierOfLight

For what it's worth, prior to Win10 14393 (1607), I think that attempting to switch from a FLIP swapchain to blt or GDI will not work. On those OSes, once a flip swapchain is bound, GDI content in the client region is ignored. Not 100% sure whether it was 1607, might've been the release before or after.

Raph
Raph

SoldierOfLight: does it matter that I'm creating the swapchain for composition rather than binding it directly to the window? In any case, if it does turn out to be a problem, it'll be easy enough to version-check and fall back to a different strategy.

SoldierOfLight
SoldierOfLight

That's an excellent question. In that case, I think you're okay. I believe that using DComp to layer on top of a window is different than binding the swapchain directly to the window. I'm not positive though, my experience with DComp is pretty minimal.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.