mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 13:00:32 +00:00
Unwrap IDXGIOutput before passing it to real DXGI routines.
* This is a grey area between valid and invalid. Technically we're still passing a valid IDXGIOutput to the functions, but in practice the function will then probably turn around and cast it to an internal concrete type which it no longer points to, and explode.
This commit is contained in:
@@ -355,6 +355,16 @@ HRESULT WrappedIDXGISwapChain4::ResizeBuffers(
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE WrappedIDXGISwapChain4::GetContainingOutput(IDXGIOutput **ppOutput)
|
||||
{
|
||||
HRESULT ret = m_pReal->GetContainingOutput(ppOutput);
|
||||
|
||||
if(SUCCEEDED(ret))
|
||||
*ppOutput = (IDXGIOutput *)(new WrappedIDXGIOutput5(this, *ppOutput));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT WrappedIDXGISwapChain4::ResizeBuffers1(_In_ UINT BufferCount, _In_ UINT Width,
|
||||
_In_ UINT Height, _In_ DXGI_FORMAT Format,
|
||||
_In_ UINT SwapChainFlags,
|
||||
@@ -383,8 +393,11 @@ HRESULT WrappedIDXGISwapChain4::SetFullscreenState(
|
||||
/* [in] */ BOOL Fullscreen,
|
||||
/* [in] */ IDXGIOutput *pTarget)
|
||||
{
|
||||
WrappedIDXGIOutput5 *wrappedOutput = (WrappedIDXGIOutput5 *)pTarget;
|
||||
IDXGIOutput *unwrappedOutput = wrappedOutput ? wrappedOutput->GetReal() : NULL;
|
||||
|
||||
if(RenderDoc::Inst().GetCaptureOptions().AllowFullscreen)
|
||||
return m_pReal->SetFullscreenState(Fullscreen, pTarget);
|
||||
return m_pReal->SetFullscreenState(Fullscreen, unwrappedOutput);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@@ -393,7 +406,12 @@ HRESULT WrappedIDXGISwapChain4::GetFullscreenState(
|
||||
/* [out] */ BOOL *pFullscreen,
|
||||
/* [out] */ IDXGIOutput **ppTarget)
|
||||
{
|
||||
return m_pReal->GetFullscreenState(pFullscreen, ppTarget);
|
||||
HRESULT ret = m_pReal->GetFullscreenState(pFullscreen, ppTarget);
|
||||
|
||||
if(SUCCEEDED(ret))
|
||||
*ppTarget = (IDXGIOutput *)(new WrappedIDXGIOutput5(this, *ppTarget));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HRESULT WrappedIDXGISwapChain4::GetBuffer(
|
||||
@@ -532,6 +550,16 @@ HRESULT WrappedIDXGISwapChain4::Present1(UINT SyncInterval, UINT Flags,
|
||||
return m_pReal1->Present1(SyncInterval, Flags, pPresentParameters);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE WrappedIDXGISwapChain4::GetRestrictToOutput(IDXGIOutput **ppRestrictToOutput)
|
||||
{
|
||||
HRESULT ret = m_pReal2->GetRestrictToOutput(ppRestrictToOutput);
|
||||
|
||||
if(SUCCEEDED(ret))
|
||||
*ppRestrictToOutput = (IDXGIOutput *)(new WrappedIDXGIOutput5(this, *ppRestrictToOutput));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
WrappedIDXGIOutput5::WrappedIDXGIOutput5(RefCountDXGIObject *owner, IDXGIOutput *real)
|
||||
: RefCountDXGIObject(real), m_Owner(owner), m_pReal(real)
|
||||
{
|
||||
@@ -959,6 +987,9 @@ HRESULT WrappedIDXGIFactory5::CreateSwapChainForHwnd(
|
||||
{
|
||||
ID3DDevice *wrapDevice = GetD3DDevice(pDevice);
|
||||
|
||||
WrappedIDXGIOutput5 *wrappedOutput = (WrappedIDXGIOutput5 *)pRestrictToOutput;
|
||||
IDXGIOutput *unwrappedOutput = wrappedOutput ? wrappedOutput->GetReal() : NULL;
|
||||
|
||||
if(wrapDevice)
|
||||
{
|
||||
if(!RenderDoc::Inst().GetCaptureOptions().AllowFullscreen && pFullscreenDesc)
|
||||
@@ -967,7 +998,7 @@ HRESULT WrappedIDXGIFactory5::CreateSwapChainForHwnd(
|
||||
}
|
||||
|
||||
HRESULT ret = m_pReal2->CreateSwapChainForHwnd(wrapDevice->GetRealIUnknown(), hWnd, pDesc,
|
||||
pFullscreenDesc, pRestrictToOutput, ppSwapChain);
|
||||
pFullscreenDesc, unwrappedOutput, ppSwapChain);
|
||||
|
||||
if(SUCCEEDED(ret))
|
||||
{
|
||||
@@ -981,7 +1012,7 @@ HRESULT WrappedIDXGIFactory5::CreateSwapChainForHwnd(
|
||||
RDCERR("Creating swap chain with non-hooked device!");
|
||||
}
|
||||
|
||||
return m_pReal2->CreateSwapChainForHwnd(pDevice, hWnd, pDesc, pFullscreenDesc, pRestrictToOutput,
|
||||
return m_pReal2->CreateSwapChainForHwnd(pDevice, hWnd, pDesc, pFullscreenDesc, unwrappedOutput,
|
||||
ppSwapChain);
|
||||
}
|
||||
|
||||
@@ -992,6 +1023,9 @@ HRESULT WrappedIDXGIFactory5::CreateSwapChainForCoreWindow(IUnknown *pDevice, IU
|
||||
{
|
||||
ID3DDevice *wrapDevice = GetD3DDevice(pDevice);
|
||||
|
||||
WrappedIDXGIOutput5 *wrappedOutput = (WrappedIDXGIOutput5 *)pRestrictToOutput;
|
||||
IDXGIOutput *unwrappedOutput = wrappedOutput ? wrappedOutput->GetReal() : NULL;
|
||||
|
||||
if(!RenderDoc::Inst().GetCaptureOptions().AllowFullscreen)
|
||||
{
|
||||
RDCWARN("Impossible to disallow fullscreen on call to CreateSwapChainForCoreWindow");
|
||||
@@ -1000,7 +1034,7 @@ HRESULT WrappedIDXGIFactory5::CreateSwapChainForCoreWindow(IUnknown *pDevice, IU
|
||||
if(wrapDevice)
|
||||
{
|
||||
HRESULT ret = m_pReal2->CreateSwapChainForCoreWindow(wrapDevice->GetRealIUnknown(), pWindow,
|
||||
pDesc, pRestrictToOutput, ppSwapChain);
|
||||
pDesc, unwrappedOutput, ppSwapChain);
|
||||
|
||||
if(SUCCEEDED(ret))
|
||||
{
|
||||
@@ -1018,7 +1052,7 @@ HRESULT WrappedIDXGIFactory5::CreateSwapChainForCoreWindow(IUnknown *pDevice, IU
|
||||
RDCERR("Creating swap chain with non-hooked device!");
|
||||
}
|
||||
|
||||
return m_pReal2->CreateSwapChainForCoreWindow(pDevice, pWindow, pDesc, pRestrictToOutput,
|
||||
return m_pReal2->CreateSwapChainForCoreWindow(pDevice, pWindow, pDesc, unwrappedOutput,
|
||||
ppSwapChain);
|
||||
}
|
||||
|
||||
@@ -1029,6 +1063,9 @@ HRESULT WrappedIDXGIFactory5::CreateSwapChainForComposition(IUnknown *pDevice,
|
||||
{
|
||||
ID3DDevice *wrapDevice = GetD3DDevice(pDevice);
|
||||
|
||||
WrappedIDXGIOutput5 *wrappedOutput = (WrappedIDXGIOutput5 *)pRestrictToOutput;
|
||||
IDXGIOutput *unwrappedOutput = wrappedOutput ? wrappedOutput->GetReal() : NULL;
|
||||
|
||||
if(!RenderDoc::Inst().GetCaptureOptions().AllowFullscreen)
|
||||
{
|
||||
RDCWARN("Impossible to disallow fullscreen on call to CreateSwapChainForComposition");
|
||||
@@ -1037,7 +1074,7 @@ HRESULT WrappedIDXGIFactory5::CreateSwapChainForComposition(IUnknown *pDevice,
|
||||
if(wrapDevice)
|
||||
{
|
||||
HRESULT ret = m_pReal2->CreateSwapChainForComposition(wrapDevice->GetRealIUnknown(), pDesc,
|
||||
pRestrictToOutput, ppSwapChain);
|
||||
unwrappedOutput, ppSwapChain);
|
||||
|
||||
if(SUCCEEDED(ret))
|
||||
{
|
||||
@@ -1055,5 +1092,5 @@ HRESULT WrappedIDXGIFactory5::CreateSwapChainForComposition(IUnknown *pDevice,
|
||||
RDCERR("Creating swap chain with non-hooked device!");
|
||||
}
|
||||
|
||||
return m_pReal2->CreateSwapChainForComposition(pDevice, pDesc, pRestrictToOutput, ppSwapChain);
|
||||
return m_pReal2->CreateSwapChainForComposition(pDevice, pDesc, unwrappedOutput, ppSwapChain);
|
||||
}
|
||||
|
||||
@@ -646,10 +646,7 @@ public:
|
||||
return m_pReal->ResizeTarget(pNewTargetParameters);
|
||||
}
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetContainingOutput(IDXGIOutput **ppOutput)
|
||||
{
|
||||
return m_pReal->GetContainingOutput(ppOutput);
|
||||
}
|
||||
virtual HRESULT STDMETHODCALLTYPE GetContainingOutput(IDXGIOutput **ppOutput);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetFrameStatistics(
|
||||
/* [out] */ DXGI_FRAME_STATISTICS *pStats)
|
||||
@@ -709,10 +706,7 @@ public:
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetRestrictToOutput(
|
||||
/* [annotation][out] */
|
||||
_Out_ IDXGIOutput **ppRestrictToOutput)
|
||||
{
|
||||
return m_pReal2->GetRestrictToOutput(ppRestrictToOutput);
|
||||
}
|
||||
_Out_ IDXGIOutput **ppRestrictToOutput);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetBackgroundColor(
|
||||
/* [annotation][in] */
|
||||
@@ -860,6 +854,7 @@ public:
|
||||
WrappedIDXGIOutput5(RefCountDXGIObject *owner, IDXGIOutput *real);
|
||||
~WrappedIDXGIOutput5();
|
||||
|
||||
IDXGIOutput *GetReal() { return m_pReal; }
|
||||
//////////////////////////////
|
||||
// implement IDXGIOutput
|
||||
|
||||
|
||||
Reference in New Issue
Block a user