• Create Account

## Swap Chain Buffer Count

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1sunnysideup  Members

Posted 02 November 2012 - 05:21 PM

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...

Edited by sunnysideup, 02 November 2012 - 05:23 PM.

### #2Stuntdk  Members

Posted 03 November 2012 - 02:28 AM

BufferCount is the number of back buffers used in the swap chain, so for double buffering you should set this value to 1

### #3Gavin Williams  Members

Posted 03 November 2012 - 11:19 AM

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.

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.

Edited by Gavin Williams, 03 November 2012 - 11:38 AM.

### #4Stuntdk  Members

Posted 03 November 2012 - 01:02 PM

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?

Edited by Stuntdk, 03 November 2012 - 01:08 PM.

### #5Erik Rufelt  Members

Posted 03 November 2012 - 03:32 PM

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..

### #6Gavin Williams  Members

Posted 03 November 2012 - 04:35 PM

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 ?

### #7Erik Rufelt  Members

Posted 03 November 2012 - 05:27 PM

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.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.