From 589229f4ca62e6fb82e4937d81bf0eac9d1d5108 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 24 Oct 2018 15:52:09 +0200 Subject: [PATCH] [dxgi] Query device interface from the presenter Removes the coupling between IDXGISwapChain and IDXGIDevice. This is necessary because D3D12 devices don't support IDXGIDevice. --- src/d3d11/d3d11_swapchain.cpp | 7 +++++++ src/d3d11/d3d11_swapchain.h | 4 ++++ src/dxgi/dxgi_interfaces.h | 4 ++++ src/dxgi/dxgi_swapchain.cpp | 3 +-- src/dxgi/dxgi_swapchain.h | 1 - 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index 042c222d..3d4c6bd6 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -73,6 +73,13 @@ namespace dxvk { } + HRESULT STDMETHODCALLTYPE D3D11SwapChain::GetDevice( + REFIID riid, + void** ppDevice) { + return m_parent->QueryInterface(riid, ppDevice); + } + + HRESULT STDMETHODCALLTYPE D3D11SwapChain::GetImage( UINT BufferId, REFIID riid, diff --git a/src/d3d11/d3d11_swapchain.h b/src/d3d11/d3d11_swapchain.h index 6297eb08..da9a98ae 100644 --- a/src/d3d11/d3d11_swapchain.h +++ b/src/d3d11/d3d11_swapchain.h @@ -40,6 +40,10 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE GetDesc( DXGI_SWAP_CHAIN_DESC1* pDesc); + HRESULT STDMETHODCALLTYPE GetDevice( + REFIID riid, + void** ppDevice); + HRESULT STDMETHODCALLTYPE GetImage( UINT BufferId, REFIID riid, diff --git a/src/dxgi/dxgi_interfaces.h b/src/dxgi/dxgi_interfaces.h index 7ae27581..7d58957b 100644 --- a/src/dxgi/dxgi_interfaces.h +++ b/src/dxgi/dxgi_interfaces.h @@ -29,6 +29,10 @@ IDXGIVkSwapChain : public IUnknown { virtual HRESULT STDMETHODCALLTYPE GetDesc( DXGI_SWAP_CHAIN_DESC1* pDesc) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDevice( + REFIID riid, + void** ppDevice) = 0; virtual HRESULT STDMETHODCALLTYPE GetImage( UINT BufferId, diff --git a/src/dxgi/dxgi_swapchain.cpp b/src/dxgi/dxgi_swapchain.cpp index 847a2256..b4ce223f 100644 --- a/src/dxgi/dxgi_swapchain.cpp +++ b/src/dxgi/dxgi_swapchain.cpp @@ -35,7 +35,6 @@ namespace dxvk { if (FAILED(device->GetAdapter(&adapter))) throw DxvkError("DXGI: DxgiSwapChain: Failed to retrieve adapter"); - m_device = static_cast(device.ptr()); m_adapter = static_cast(adapter.ptr()); // Initialize frame statistics @@ -93,7 +92,7 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE DxgiSwapChain::GetDevice(REFIID riid, void** ppDevice) { - return m_device->QueryInterface(riid, ppDevice); + return m_presenter->GetDevice(riid, ppDevice); } diff --git a/src/dxgi/dxgi_swapchain.h b/src/dxgi/dxgi_swapchain.h index 232d0602..e0cd2b58 100644 --- a/src/dxgi/dxgi_swapchain.h +++ b/src/dxgi/dxgi_swapchain.h @@ -136,7 +136,6 @@ namespace dxvk { Com m_factory; Com m_adapter; - Com m_device; HWND m_window; DXGI_SWAP_CHAIN_DESC1 m_desc;