Advertisement

Questions regarding swap chains in D3D12

Started by January 28, 2018 12:43 AM
2 comments, last by galop1n 7 years ago

Hi,

I'm reading https://software.intel.com/en-us/articles/sample-application-for-direct3d-12-flip-model-swap-chains to figure out the best way to setup my swapchain but I dont understand the following:

1 - In "Classic Mode" on the link above, what causes the GPU to wait for the next Vsync before starting working on the next frame?

2_classicgamemode.png

(eg: orange bar on the second column doesn't start executing right after the previous blue bar)

Its clear it has to wait because the new frame will render to the render target currently on screen, but is there an explicit wait one must do in code? Or does the driver force the wait? If so, how does the driver know? Does it check which RT is bound, so if I was rendering to GBuffer no wait would happen?

2 - When Vsync is off, what does it mean that a frame is dropped and what causes it?

Thanks!!

1. The D3D12 runtime in conjunction with DXGI enforces this wait, by inspecting which RTV descriptors are being used.

2. The DWM (desktop window manager) that composes the desktop decides to drop frames if the app has presented multiple times since the last time it composed. If your app is covering the screen and using the DXGI_PRESENT_ALLOW_TEARING flag, or has called SetFullscreenState(TRUE), instead of skipping frames, the OS will tear instead of skipping frames.

Advertisement

You can also make the wait explicit ( and put it at the front instead of at the end ) by using DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT. This flag let you wait on a swap chain buffer to be ready to be filled for next frame.

Advantages are :

* You can use the cpu for other task while waiting instead of having a dead thread stuck in Present

* It reduce the latency ( mostly because you do not aggressively queue frames, but push them instead when they are needed, closer to the actual moment they gonna be display )

* You control the number of allowed queued frame explicitly and so the exact behavior ( depends if your cpu update+render + gpu frame  fit in one vsync or two basically ).

This topic is closed to new replies.

Advertisement