I'm working on a custom GUI/overlay renderer using WinAPI and DirectX11.
The entire GUI is rendered in a semi-transparent floating window and the client area of it is constantly adjusted to match the current boundaries of UI elements.
When the elements are moved outside the client area I have to move/resize the window and also redraw its content.
But there is a problem: if I first present the changes (IDXGISwapChain::Present()
) and then move the window, there will be one frame between these operations with the correct content but in the wrong place.
If I do the opposite - move the window first - then there will be one frame with the incorrect content (from the previous frame) but in a correct position.
Is there a way to do both SetWindowPos()
and IDXGISwapChain::Present()
in a single transaction?
Asked
Active
Viewed 46 times
0

Simon Mourier
- 132,049
- 21
- 248
- 298

hopeless-programmer
- 787
- 5
- 17
-
1Presented like that, I'd say "no". But do you own the window in question? – Simon Mourier Jul 06 '23 at 17:28
-
@SimonMourier yes, I own the window. – hopeless-programmer Jul 07 '23 at 06:47
-
Then I'm not sure I understand the problem you have, and it also depends on how you create the swapchain, etc, you should add more details and a reproducble small projet https://stackoverflow.com/help/minimal-reproducible-example Also if you use DirectComposition or the Visual Layer https://learn.microsoft.com/en-us/windows/uwp/composition/visual-layer (which is ~DirectComposition vnext and is not limited to UWP apps contrary to what docs induces), you don't need a swap chain and you integrate much better with Windows DWM in terms of sync – Simon Mourier Jul 07 '23 at 08:12
-
As far as I'm concerned, It's not a transaction issue. [IDXGISwapChain::Present method](https://learn.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-present#remarks) Presents a rendered image to the user through **messages**. Have you tried the `SyncInterval` parameter? And could you please show a minimal, reproducible sample without private information? – YangXiaoPo-MSFT Jul 10 '23 at 02:37