Multiple SwapChain

SwapChain is a special render buffer, which is used as a final rendering target to output to display. Each time a frame has been completed in Buffer1, it becomes Buffer2 to be displayed on the output. The previous Buffer2 becomes Buffer1 to create the next frame. This constant change between back and front buffer is called swapping or flipping.

SwapChain generation
You can find the SwapChain Class in DXGI. The buffer generation is simple:

Private _SwapChain As DXGI.SwapChain
 _SwapChain = New DXGI.SwapChain(Factory, Device, _SwapChainDescription)

Default Swapchain Description
This function creates a default description for the SwapChain buffer. This should be easy to create a SwapChain on each device.

'Default SwapChain Description
Public Shared Function GetDefaultSwapChainDescrition(C As System.Windows.Forms.Control) As DXGI.SwapChainDescription

 Dim SwapChainDesc As New DXGI.SwapChainDescription
 Dim ModeDesc As New DXGI.ModeDescription
 Dim SampleDesc As New DXGI.SampleDescription

 With ModeDesc
  .Format = DXGI.Format.R8G8B8A8_UNorm
  .RefreshRate = New Rational(60, 1)
  .Scaling = DXGI.DisplayModeScaling.Unspecified
  .ScanlineOrdering = DXGI.DisplayModeScanlineOrdering.Unspecified
  .Width = C.Height
  .Height = C.Width
 End With

 With SampleDesc
  .Count = 1
  .Quality = 0
 End With

 With SwapChainDesc
  .ModeDescription = ModeDesc
  .SampleDescription = SampleDesc
  .BufferCount = 1
  .Flags = DXGI.SwapChainFlags.None
  .IsWindowed = True
  .OutputHandle = C.Handle
  .SwapEffect = DXGI.SwapEffect.Discard
  .Usage = DXGI.Usage.RenderTargetOutput
 End With

 Return SwapChainDesc
End Function

Multiple SwapChain
If you want to render on more then one Control, you need to create several SwapChain buffers. It should be noted that all SwapChains are using the same Factory and Device.

Multiple Swapchain Rendering


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s