From ba38a3e2e68977d4a109fdf049b774b75146320a Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 4 Aug 2020 22:56:59 -0700 Subject: Fixed IDXGISwapChain2 issue on Windows 7 (closed https://github.com/DiligentGraphics/DiligentEngine/issues/95). --- .../GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Graphics/GraphicsEngineD3DBase') diff --git a/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp b/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp index 0389f583..701361d1 100644 --- a/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp +++ b/Graphics/GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp @@ -205,7 +205,7 @@ protected: // false if an application is not manifested for Windows 8.1 or Windows 10, even if the current // operating system version is Windows 8.1 or Windows 10. CComPtr pDXGIFactory3; - if (SUCCEEDED(pDXGIFactory->QueryInterface(__uuidof(pDXGIFactory3), reinterpret_cast(static_cast(&pDXGIFactory3))))) + if (SUCCEEDED(pDXGIFactory.QueryInterface(&pDXGIFactory3))) { swapChainDesc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; } @@ -254,16 +254,20 @@ protected: #endif - hr = pSwapChain1->QueryInterface(__uuidof(m_pSwapChain), reinterpret_cast(static_cast(&m_pSwapChain))); + hr = pSwapChain1.QueryInterface(&m_pSwapChain); CHECK_D3D_RESULT_THROW(hr, "Failed to query the required swap chain interface"); if ((swapChainDesc.Flags & DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT) != 0) { - // IMPORTANT: SetMaximumFrameLatency must be called BEFORE GetFrameLatencyWaitableObject! - m_pSwapChain->SetMaximumFrameLatency(m_MaxFrameLatency); + CComPtr pSwapChain2; + if (SUCCEEDED(pSwapChain1.QueryInterface(&pSwapChain2))) + { + // IMPORTANT: SetMaximumFrameLatency must be called BEFORE GetFrameLatencyWaitableObject! + pSwapChain2->SetMaximumFrameLatency(m_MaxFrameLatency); - m_FrameLatencyWaitableObject = m_pSwapChain->GetFrameLatencyWaitableObject(); - VERIFY(m_FrameLatencyWaitableObject != NULL, "Waitable object must not be null"); + m_FrameLatencyWaitableObject = pSwapChain2->GetFrameLatencyWaitableObject(); + VERIFY(m_FrameLatencyWaitableObject != NULL, "Waitable object must not be null"); + } } else { -- cgit v1.2.3