Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DirectX 11 optimization with "waitable object"

Tags:

directx-11

As explained at Optimizing DirectX apps for low latency input..., the use of DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT can make the application more responsive. I have a couple of questions on this:

  1. Why can't I achieve the same effect just by waiting for previous call to "Present1" to end, before performing the next game loop?
  2. According to MSDN article I can get the waitable object by creating the swap chain with CreateSwapChainForCoreWindow. Is there a way of getting a CoreWindow from regular Win32 application (not Windows Store app)?

Thanks

like image 360
Michael Gopshtein Avatar asked Oct 26 '25 09:10

Michael Gopshtein


1 Answers

The call to Present (or Present1) is non-blocking and returns pretty quickly. It just indicates to the API that you are done with the frame and are ready to show the frame buffer. In order to keep the CPU from getting too far ahead of the GPU, Windows by default will block on the Present once 3 frames are queued up. This normally will smooth out in apps at some steady-rate, but this additional latency can be a real problem for touch-based UI applications.

CoreWindow APIs are only usable for WinRT-based platforms like UWP for Windows 10, Windows Store, Windows phone 8, and Xbox one. They are not usable for Windows desktop apps.

What you can do in a Windows desktop app is use the DXGI_PRESENT_DO_NOT_WAIT flag and if the Present returns a failure code of DXGI_PRESENT_DO_NOT_WAIT your applications knows that it's got a number of frames queued up. You could do other work to wait a bit, throttle your content, or do other clever things with this but most games just run 'flat out' and let the game block if it's rendering too fast.

like image 68
Chuck Walbourn Avatar answered Oct 29 '25 05:10

Chuck Walbourn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!