Swap Chain Buffer Count

Started by
5 comments, last by Erik Rufelt 11 years, 5 months ago
What exactly should I set for BufferCount in the DXGI_SWAP_CHAIN_DESC structure if I want double buffering? The SDK documentation sets this value to 1. But wouldn't that only create one buffer? Shouldn't I set this field to 2 if I want a front buffer and a back buffer? The docs say "you typically include the front buffer in this value". That has me a little confused...
Advertisement
BufferCount is the number of back buffers used in the swap chain, so for double buffering you should set this value to 1
You should set

BufferCount = 2,

Sorry to contradict you here Stuntdk. If you read the MSDN documentation it says :


BufferCount
Type: UINT
A value that describes the number of buffers in the swap chain. When you call IDXGIFactory::CreateSwapChain to create a full-screen swap chain, you typically include the front buffer in this value. For more information about swap-chain buffers, see Remarks.
[/quote]

That implies that including the front buffer your BufferCount = 1, because you typically include the front buffer in this value. Also, if BufferCount was the back-buffer count, then you should be able to set it to zero, which you can't. If you try setting it to zero, your application will throw an invalid call exception.
I am by no means an expert, and still learning so I may stand corrected.
I got my information from reading Frank D. Luna "3D Game Programming With DirectX11".

He describes the BufferCount as the number of backbuffers, and throughout all his code use only the value of 1 (at least as far as I've gotten into it)
Could there perhaps be a difference whether you are using windowed or fullscreen mode?

Update:
Actually I just checked the RasterTek tutorials and Braynzar tutorials, and they both describe the BufferCount as the number of backbuffers and set it to 1 for double buffering.

I also see the somewhat conflicting explanation on MSDN, so hopefully an expert can explain some of this?
The "front buffer" in this case is the buffer that is going to be presented at the next Present, so one buffer is enough. When using the discard swap flag, you'll probably just get new actual buffer-memory at Present while the frame that just finished drawing will be queued for presenting. The driver commonly buffers 3 frames ahead anyway, so in reality you should have more than enough buffering with 1 buffer. At least that's my take on it.
If you mess with the settings to override this behavior, and want to manually make sure you triple-buffer, then maybe you should make it 2..
If I look at the object table with the BufferCount set to 1, 2 and 3, it is the same in each scenario :

obj:17 Direct3D11 Texture2D 1 1366 768
obj:7 DXGI Surface 0 1366 768

So that doesn't help me to confirm anything. If 1 is double buffering, how do you use a single buffer ?
If you actually had a single memory buffer for the display you wouldn't call Present at all, and every pixel would be visible on the screen as it was drawn (after the vertical blank passed it). Like in DOS where you had a pointer to the screen memory buffer. I don't think D3D or DXGI exposes such functionality.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb205075(v=vs.85).aspx has some more info under Presentation, which says there must always be a back-buffer and a front-buffer. Perhaps the documentation just has it wrong, depending on what the "front buffer" actually means.

This topic is closed to new replies.

Advertisement