Jump to content

  • Log In with Google      Sign In   
  • Create Account


Multiple swap chains performance problem


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.

  • You cannot reply to this topic
4 replies to this topic

#1 lipsryme   Members   -  Reputation: 985

Like
0Likes
Like

Posted 30 April 2014 - 02:28 PM

I'm using multiple swap chains (4-5 max active at the same time, depending on how many render windows are currently open) on a single d3d11 device.

 

Here's the issue:

Vsync off: Losing about 0.5ms per active swap chain (is that an expected performance loss?)

Vsync on: framerate seems stable at 60fps but everything is choppy (and gets "choppier" with every additional active swapchain) like its running at 25fps or so. (my main problem)

 

This is how I create the swap chains:

HRESULT hr; 
		SwapChainAndBackBuffer *chain = nullptr;
		
		// null here means that we don't want to increment the ref count
		if (this->swapChainsAndBackBuffers.empty())
				chain = new SwapChainAndBackBuffer(name, desc, nullptr, nullptr);
		else
				chain = new SwapChainAndBackBuffer(name, desc, this->device, this->context);
		
		IDXGIDevice *dxgi_device = nullptr;
		IDXGIAdapter *dxgi_adapter = nullptr;
		IDXGIFactory *dxgi_factory = nullptr;

		hr = this->device->QueryInterface(&dxgi_device);
		if (FAILED(hr)) 
				return false;

		hr = dxgi_device->GetAdapter(&dxgi_adapter);
		if (FAILED(hr))
				return false;

		hr = dxgi_adapter->GetParent(IID_PPV_ARGS(&dxgi_factory));
		if (FAILED(hr))
				return false;
		
		// Describe our Buffer
		DXGI_MODE_DESC bufferDesc;
		ZeroMemory(&bufferDesc, sizeof(DXGI_MODE_DESC));

		bufferDesc.Width = desc.screenWidth;
		bufferDesc.Height = desc.screenHeight;
		bufferDesc.RefreshRate.Numerator = (desc.vsync) ? this->supportedDisplayNumerator : 0;
		bufferDesc.RefreshRate.Denominator = (desc.vsync) ? this->supportedDisplayDenominator : 1;
		bufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
		bufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE;
		bufferDesc.Scaling = DXGI_MODE_SCALING_STRETCHED;

		// Set Feature level
		D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0;

		// Describe our SwapChain
		DXGI_SWAP_CHAIN_DESC swapChainDesc;
		ZeroMemory(&swapChainDesc, sizeof(DXGI_SWAP_CHAIN_DESC));

		swapChainDesc.BufferDesc = bufferDesc;
		swapChainDesc.SampleDesc.Count = desc.MSAA_count;
		swapChainDesc.SampleDesc.Quality = this->supportedMSAAQuality;
		swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
		swapChainDesc.BufferCount = 1;
		swapChainDesc.OutputWindow = desc.hwnd;
		swapChainDesc.Windowed = !desc.isFullscreen;
		swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
		swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

		hr = dxgi_factory->CreateSwapChain(this->device, &swapChainDesc, &chain->swapChain);
		if (FAILED(hr))
		{
				this->log->OutputToConsole("LipsRendererD3D11: Failed to create swap chain!", LogType::Error);
				return false;
		}

System is running Window 8.1 but I'm using regular DX11.0 device for compatibility.

Any ideas why the slowdown is happening ?


Edited by lipsryme, 30 April 2014 - 02:34 PM.


Sponsor:

#2 Erik Rufelt   Crossbones+   -  Reputation: 3031

Like
0Likes
Like

Posted 30 April 2014 - 02:44 PM

I've seen this happen when different monitors don't share the exact same clock. The synchronization in the driver and/or OS doesn't handle it properly and can't maintain separate swap-intervals or non-synced blank intervals. Not sure if it's fixable..

It seems to work somewhat OK in fullscreen with a single device, or if the different swap-chains use different devices on different physical graphics cards in window mode.



#3 lipsryme   Members   -  Reputation: 985

Like
0Likes
Like

Posted 30 April 2014 - 02:50 PM

Well its running on the same monitor/GPU. And I need them to run smoothly for editor usage with several windows. wacko.png

Works totally fine if I disable vsync on all of them (tried setting true on just one but the same happens)


Edited by lipsryme, 30 April 2014 - 02:54 PM.


#4 Erik Rufelt   Crossbones+   -  Reputation: 3031

Like
0Likes
Like

Posted 30 April 2014 - 03:12 PM

You can try not using vsync and using another API to manually vsync before Present, like http://msdn.microsoft.com/en-us/library/windows/desktop/bb174349%28v=vs.85%29.aspx or DirectDraw.



#5 BornToCode   Members   -  Reputation: 900

Like
0Likes
Like

Posted 02 May 2014 - 05:21 PM

I am experiencing a very similar issue but on windows 7. There is actually no way to fix it. The way we handle it at work is just like you said, is to have everything run with vsync turn off.






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.



PARTNERS