From bf6a62c1b3fda93d895a0098b90a81bb337a49d9 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 5 Aug 2016 09:39:26 +0200 Subject: [PATCH] Fix incorrect casting of forward declared ID3D11Device. Refs #316 * After clang-format re-arranged headers, the definition of WrappedID3D11Device was no longer visible from d3d11_context.h, but instead just the pre-declared "class WrappedID3D11Device;" * This meant the function didn't correctly upcast to the right parent type and left the return value with the wrong vtable which would crash --- renderdoc/driver/d3d11/d3d11_context.cpp | 6 ++++++ renderdoc/driver/d3d11/d3d11_context.h | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index ca68e8cba..82f4b6e20 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -210,6 +210,12 @@ WrappedID3D11DeviceContext::~WrappedID3D11DeviceContext() RenderDoc::Inst().GetCrashHandler()->UnregisterMemoryRegion(this); } +void WrappedID3D11DeviceContext::GetDevice(ID3D11Device **ppDevice) +{ + *ppDevice = (ID3D11Device *)m_pDevice; + (*ppDevice)->AddRef(); +} + const char *WrappedID3D11DeviceContext::GetChunkName(D3D11ChunkType idx) { return m_pDevice->GetChunkName(idx); diff --git a/renderdoc/driver/d3d11/d3d11_context.h b/renderdoc/driver/d3d11/d3d11_context.h index b4ae142ff..188613d3f 100644 --- a/renderdoc/driver/d3d11/d3d11_context.h +++ b/renderdoc/driver/d3d11/d3d11_context.h @@ -359,11 +359,7 @@ public: return m_pRealContext->GetPrivateData(Name, pDataSize, pData); } - virtual void STDMETHODCALLTYPE GetDevice(ID3D11Device **ppDevice) - { - *ppDevice = (ID3D11Device *)m_pDevice; - (*ppDevice)->AddRef(); - } + virtual void STDMETHODCALLTYPE GetDevice(ID3D11Device **ppDevice); ////////////////////////////// // implement ID3D11DeviceContext