From cc9fab36599dbb0feaa2a274d8925b57586f56a6 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 13 Jan 2022 14:14:07 +0000 Subject: [PATCH] Handle a NULL device passed into IDXGIOutput::FindClosestMatchingMode --- renderdoc/driver/dxgi/dxgi_wrapped.cpp | 36 ++++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/renderdoc/driver/dxgi/dxgi_wrapped.cpp b/renderdoc/driver/dxgi/dxgi_wrapped.cpp index 865226501..1c2366a24 100644 --- a/renderdoc/driver/dxgi/dxgi_wrapped.cpp +++ b/renderdoc/driver/dxgi/dxgi_wrapped.cpp @@ -619,16 +619,20 @@ WrappedIDXGIOutput6::~WrappedIDXGIOutput6() HRESULT STDMETHODCALLTYPE WrappedIDXGIOutput6::FindClosestMatchingMode( const DXGI_MODE_DESC *pModeToMatch, DXGI_MODE_DESC *pClosestMatch, IUnknown *pConcernedDevice) { - ID3DDevice *wrapDevice = GetD3DDevice(pConcernedDevice); - - if(wrapDevice) - return m_pReal->FindClosestMatchingMode(pModeToMatch, pClosestMatch, - wrapDevice->GetRealIUnknown()); - if(pConcernedDevice) + { + ID3DDevice *wrapDevice = GetD3DDevice(pConcernedDevice); + + if(wrapDevice) + return m_pReal->FindClosestMatchingMode(pModeToMatch, pClosestMatch, + wrapDevice->GetRealIUnknown()); + RDCERR("Unrecognised device in FindClosestMatchingMode()"); - return E_INVALIDARG; + return E_INVALIDARG; + } + + return m_pReal->FindClosestMatchingMode(pModeToMatch, pClosestMatch, NULL); } HRESULT STDMETHODCALLTYPE WrappedIDXGIOutput6::TakeOwnership(IUnknown *pDevice, BOOL Exclusive) @@ -646,16 +650,20 @@ HRESULT STDMETHODCALLTYPE WrappedIDXGIOutput6::TakeOwnership(IUnknown *pDevice, HRESULT STDMETHODCALLTYPE WrappedIDXGIOutput6::FindClosestMatchingMode1( const DXGI_MODE_DESC1 *pModeToMatch, DXGI_MODE_DESC1 *pClosestMatch, IUnknown *pConcernedDevice) { - ID3DDevice *wrapDevice = GetD3DDevice(pConcernedDevice); - - if(wrapDevice) - return m_pReal1->FindClosestMatchingMode1(pModeToMatch, pClosestMatch, - wrapDevice->GetRealIUnknown()); - if(pConcernedDevice) + { + ID3DDevice *wrapDevice = GetD3DDevice(pConcernedDevice); + + if(wrapDevice) + return m_pReal1->FindClosestMatchingMode1(pModeToMatch, pClosestMatch, + wrapDevice->GetRealIUnknown()); + RDCERR("Unrecognised device in FindClosestMatchingMode1()"); - return E_INVALIDARG; + return E_INVALIDARG; + } + + return m_pReal1->FindClosestMatchingMode1(pModeToMatch, pClosestMatch, NULL); } HRESULT STDMETHODCALLTYPE WrappedIDXGIOutput6::GetDisplaySurfaceData1(IDXGIResource *pDestination)