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). --- .../GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp | 4 ++-- .../GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp | 2 +- Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp | 2 +- .../GraphicsEngineD3DBase/include/SwapChainD3DBase.hpp | 16 ++++++++++------ 4 files changed, 14 insertions(+), 10 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp index 0c36c5d3..209d5d4c 100644 --- a/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/SwapChainD3D11Impl.hpp @@ -37,10 +37,10 @@ namespace Diligent { /// Swap chain implementation in Direct3D11 backend. -class SwapChainD3D11Impl final : public SwapChainD3DBase +class SwapChainD3D11Impl final : public SwapChainD3DBase { public: - using TSwapChainBase = SwapChainD3DBase; + using TSwapChainBase = SwapChainD3DBase; SwapChainD3D11Impl(IReferenceCounters* pRefCounters, const SwapChainDesc& SCDesc, diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp index e73bec3a..4647ba13 100644 --- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp @@ -57,7 +57,7 @@ static CComPtr DXGIAdapterFromD3D11Device(ID3D11Device* pd3d11Dev if (SUCCEEDED(hr)) { CComPtr pDXGIAdapter1; - pDXGIAdapter->QueryInterface(__uuidof(pDXGIAdapter1), reinterpret_cast(static_cast(&pDXGIAdapter1))); + pDXGIAdapter.QueryInterface(&pDXGIAdapter1); return pDXGIAdapter1; } else diff --git a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp index 1b61a393..74a69136 100644 --- a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp @@ -295,7 +295,7 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12(const EngineD3D12Creat if (EngineCI.EnableDebugLayer) { CComPtr pInfoQueue; - hr = d3d12Device->QueryInterface(__uuidof(pInfoQueue), reinterpret_cast(static_cast(&pInfoQueue))); + hr = d3d12Device.QueryInterface(&pInfoQueue); if (SUCCEEDED(hr)) { // Suppress whole categories of messages 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