Advertisement

What happens when the GPU is still rendring to a presented buffer/frame?

Started by January 20, 2019 02:03 AM
2 comments, last by HD86 6 years ago

This question shows that "IDXGISwapChain::Present()" will present a back buffer even if the GPU has not finished rendering to it. So the GPU can be rendering to a front buffer. In this case, will the contents of the front buffer be actually shown on the display while the GPU is still rendering to it? How does this work exactly?

I'm not sure I understand the question. There's synchronization in two directions:

1. After issuing rendering work, you call the Present API, and after your rendering work is done, the DWM / screen will start consuming that buffer.

2. After presenting a buffer, and then cycling through the rest of the buffers in the swapchain, it's time to render to the first one again. The swapchain issues GPU synchronization on your behalf to make sure that you can't render to this buffer until the DWM / screen are done with it, in the case where you cycled through your resources very quickly.

If you're thinking that you call Present, and then try to render to the resource again... well, you can't. The swapchain prevents that from happening. You can only render to one buffer in the swapchain at a time - the one which is considered the "current back buffer." You can get this buffer's index from IDXGISwapChain3::GetCurrentBackBufferIndex.

Advertisement

Thanks for the detailed answer.

This topic is closed to new replies.

Advertisement