[RenderSystemDX] use two buffers in FSEX.
authorAnton Fedchin <anightik@gmail.com>
Tue, 15 Mar 2016 15:26:44 +0000 (18:26 +0300)
committerAnton Fedchin <afedchin@ruswizards.com>
Mon, 21 Mar 2016 10:25:52 +0000 (13:25 +0300)
xbmc/rendering/dx/RenderSystemDX.cpp
xbmc/rendering/dx/RenderSystemDX.h

index 7dbc8e3..c324e90 100644 (file)
@@ -390,10 +390,11 @@ void CRenderSystemDX::SetFullScreenInternal()
       if (FAILED(hr))
         CLog::Log(LOGERROR, "%s - Failed to switch output mode: %s", __FUNCTION__, GetErrorDescription(hr).c_str());
     }
-
-    // wait until switching screen state is done
     DXWait(m_pD3DDev, m_pImdContext);
   }
+  // in windowed mode DWM uses triple buffering in any case. 
+  // for FSEM we use double buffering
+  SetMaximumFrameLatency(2 - m_useWindowedDX);
 }
 
 bool CRenderSystemDX::IsFormatSupport(DXGI_FORMAT format, unsigned int usage)
@@ -619,16 +620,9 @@ bool CRenderSystemDX::CreateDevice()
     pMultiThreading->Release();
   }
 
-  IDXGIDevice1* pDXGIDevice = NULL;
-  if (SUCCEEDED(m_pD3DDev->QueryInterface(__uuidof(IDXGIDevice1), reinterpret_cast<void**>(&pDXGIDevice))))
-  {
-    // Not sure the following actually does something but this exists in dx9 implementation
-    pDXGIDevice->SetGPUThreadPriority(7);
-    // Ensure that DXGI does not queue more than one frame at a time. This both reduces
-    // latency and ensures that the application will only render after each VSync
-    pDXGIDevice->SetMaximumFrameLatency(1);
-    SAFE_RELEASE(pDXGIDevice);
-  }
+  // in windowed mode DWM uses triple buffering in any case. 
+  // for FSEM we use double buffering
+  SetMaximumFrameLatency(2 - m_useWindowedDX);
 
 #ifdef _DEBUG
   if (SUCCEEDED(m_pD3DDev->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&m_d3dDebug))))
@@ -1729,4 +1723,17 @@ void CRenderSystemDX::FinishCommandList(bool bExecute /*= true*/)
   SAFE_RELEASE(pCommandList);
 }
 
+void CRenderSystemDX::SetMaximumFrameLatency(uint32_t latency)
+{
+  if (!m_pD3DDev)
+    return;
+
+  IDXGIDevice1* pDXGIDevice = nullptr;
+  if (SUCCEEDED(m_pD3DDev->QueryInterface(__uuidof(IDXGIDevice1), reinterpret_cast<void**>(&pDXGIDevice))))
+  {
+    pDXGIDevice->SetMaximumFrameLatency(latency);
+    SAFE_RELEASE(pDXGIDevice);
+  }
+}
+
 #endif
index 5a8a63e..5b0e1ad 100644 (file)
@@ -138,6 +138,7 @@ protected:
   void SetFullScreenInternal();
   void GetClosestDisplayModeToCurrent(IDXGIOutput* output, DXGI_MODE_DESC* outCurrentDisplayMode, bool useCached = false);
   void CheckInterlasedStereoView(void);
+  void SetMaximumFrameLatency(uint32_t latency);
 
   virtual void UpdateMonitor() {};