My application needs to render images to multiple windows. To do this I create a SwapChain for each window. However, I noticed a large perfomance loss when I render two images to two windows in comparison to rendering the images of the same size into one window. 75 fps vs 45 fps. After profiling I noticed that 25% of the whole CPU time is used in IDXGISwapChain::Present(). When I only use a single SwapChain, no time is spent in IDXGISwapChain::Present(). To me, there seems to be some kind of synchronization, although I don't use VSync.
I create the SwapChains using the following:
DXGI_SWAP_CHAIN_DESC1 swapChainDesc;
swapChainDesc.Width = width;
swapChainDesc.Height = height;
swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
swapChainDesc.BufferCount = 2;
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDesc.SampleDesc.Count = 1;
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
swapChainDesc.Stereo = FALSE;
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
factory->CreateSwapChainForHwnd( device, window, &swapChainDesc, nullptr, nullptr, &swap_chain );
And presenting is simply done with:
swap_chain->Present(0, 0 );
Both SwapChains are created using the same ID3D11Device and ID3D11DeviceContext.
Initially I used the BitBlt model, but the switch the flip model didn't change anything. Is there anything else I can try to improve the performance?
Edit: I played around a bit and it seems that the performance is drastically improved if I use the BitBlt model for one swap chain and the Flip model for the other. I would have assumed that this would result in the worst performance