diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index 2daa41ef2..9626cb819 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -412,8 +412,32 @@ public: // interface for DXGI virtual IUnknown *GetRealIUnknown() { return GetReal(); } virtual IID GetBackbufferUUID() { return __uuidof(ID3D11Texture2D); } - virtual IID GetDeviceUUID() { return __uuidof(ID3D11Device); } - virtual IUnknown *GetDeviceInterface() { return (ID3D11Device *)this; } + virtual bool IsDeviceUUID(REFIID iid) + { + if(iid == __uuidof(ID3D11Device) || iid == __uuidof(ID3D11Device1) || + iid == __uuidof(ID3D11Device2) || iid == __uuidof(ID3D11Device3) || + iid == __uuidof(ID3D11Device4)) + return true; + + return false; + } + virtual IUnknown *GetDeviceInterface(REFIID iid) + { + if(iid == __uuidof(ID3D11Device)) + return (ID3D11Device *)this; + else if(iid == __uuidof(ID3D11Device1)) + return (ID3D11Device1 *)this; + else if(iid == __uuidof(ID3D11Device2)) + return (ID3D11Device2 *)this; + else if(iid == __uuidof(ID3D11Device3)) + return (ID3D11Device3 *)this; + else if(iid == __uuidof(ID3D11Device4)) + return (ID3D11Device4 *)this; + + RDCERR("Requested unknown device interface %s", ToStr::Get(iid).c_str()); + + return NULL; + } //////////////////////////////////////////////////////////////// // log replaying diff --git a/renderdoc/driver/d3d12/d3d12_command_queue.h b/renderdoc/driver/d3d12/d3d12_command_queue.h index 7a4a9fbc0..a763b821e 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue.h +++ b/renderdoc/driver/d3d12/d3d12_command_queue.h @@ -126,8 +126,19 @@ public: // interface for DXGI virtual IUnknown *GetRealIUnknown() { return GetReal(); } virtual IID GetBackbufferUUID() { return __uuidof(ID3D12Resource); } - virtual IID GetDeviceUUID() { return __uuidof(ID3D12CommandQueue); } - virtual IUnknown *GetDeviceInterface() { return (ID3D12CommandQueue *)this; } + virtual bool IsDeviceUUID(REFIID iid) + { + return iid == __uuidof(ID3D12CommandQueue) ? true : false; + } + virtual IUnknown *GetDeviceInterface(REFIID iid) + { + if(iid == __uuidof(ID3D12CommandQueue)) + return (ID3D12CommandQueue *)this; + + RDCERR("Requested unknown device interface %s", ToStr::Get(iid).c_str()); + + return NULL; + } // the rest forward to the device virtual void FirstFrame(WrappedIDXGISwapChain3 *swapChain) { m_pDevice->FirstFrame(swapChain); } virtual void NewSwapchainBuffer(IUnknown *backbuffer) diff --git a/renderdoc/driver/d3d12/d3d12_device.h b/renderdoc/driver/d3d12/d3d12_device.h index 3079d6989..483210c15 100644 --- a/renderdoc/driver/d3d12/d3d12_device.h +++ b/renderdoc/driver/d3d12/d3d12_device.h @@ -424,8 +424,16 @@ public: // interface for DXGI virtual IUnknown *GetRealIUnknown() { return GetReal(); } virtual IID GetBackbufferUUID() { return __uuidof(ID3D12Resource); } - virtual IID GetDeviceUUID() { return __uuidof(ID3D12Device); } - virtual IUnknown *GetDeviceInterface() { return (ID3D12Device *)this; } + virtual bool IsDeviceUUID(REFIID iid) { return iid == __uuidof(ID3D12Device) ? true : false; } + virtual IUnknown *GetDeviceInterface(REFIID iid) + { + if(iid == __uuidof(ID3D12Device)) + return (ID3D12Device *)this; + + RDCERR("Requested unknown device interface %s", ToStr::Get(iid).c_str()); + + return NULL; + } // Swap Chain IMPLEMENT_FUNCTION_THREAD_SERIALISED(IUnknown *, WrapSwapchainBuffer, WrappedIDXGISwapChain3 *swap, DXGI_SWAP_CHAIN_DESC *desc, diff --git a/renderdoc/driver/dxgi/dxgi_wrapped.cpp b/renderdoc/driver/dxgi/dxgi_wrapped.cpp index bd0fd7529..bef557cb8 100644 --- a/renderdoc/driver/dxgi/dxgi_wrapped.cpp +++ b/renderdoc/driver/dxgi/dxgi_wrapped.cpp @@ -382,10 +382,10 @@ HRESULT WrappedIDXGISwapChain3::GetDevice( if(SUCCEEDED(ret)) { // try one of the trivial wraps, we don't mind making a new one of those - if(riid == m_pDevice->GetDeviceUUID()) + if(m_pDevice->IsDeviceUUID(riid)) { // probably they're asking for the device device. - *ppDevice = m_pDevice->GetDeviceInterface(); + *ppDevice = m_pDevice->GetDeviceInterface(riid); m_pDevice->AddRef(); } else if(riid == __uuidof(IDXGISwapChain)) @@ -601,10 +601,10 @@ HRESULT STDMETHODCALLTYPE WrappedIDXGISwapChain3::QueryInterface(REFIID riid, vo HRESULT STDMETHODCALLTYPE WrappedIDXGIDevice::QueryInterface(REFIID riid, void **ppvObject) { - if(riid == m_pD3DDevice->GetDeviceUUID()) + if(m_pD3DDevice->IsDeviceUUID(riid)) { m_pD3DDevice->AddRef(); - *ppvObject = m_pD3DDevice->GetDeviceInterface(); + *ppvObject = m_pD3DDevice->GetDeviceInterface(riid); return S_OK; } else @@ -620,10 +620,10 @@ HRESULT STDMETHODCALLTYPE WrappedIDXGIDevice1::QueryInterface(REFIID riid, void { HRESULT hr = S_OK; - if(riid == m_pD3DDevice->GetDeviceUUID()) + if(m_pD3DDevice->IsDeviceUUID(riid)) { m_pD3DDevice->AddRef(); - *ppvObject = m_pD3DDevice->GetDeviceInterface(); + *ppvObject = m_pD3DDevice->GetDeviceInterface(riid); return S_OK; } else if(riid == __uuidof(IDXGIDevice1)) @@ -673,10 +673,10 @@ HRESULT STDMETHODCALLTYPE WrappedIDXGIDevice1::QueryInterface(REFIID riid, void HRESULT STDMETHODCALLTYPE WrappedIDXGIDevice2::QueryInterface(REFIID riid, void **ppvObject) { - if(riid == m_pD3DDevice->GetDeviceUUID()) + if(m_pD3DDevice->IsDeviceUUID(riid)) { m_pD3DDevice->AddRef(); - *ppvObject = m_pD3DDevice->GetDeviceInterface(); + *ppvObject = m_pD3DDevice->GetDeviceInterface(riid); return S_OK; } else if(riid == __uuidof(IDXGIDevice1)) @@ -717,10 +717,10 @@ HRESULT STDMETHODCALLTYPE WrappedIDXGIDevice2::QueryInterface(REFIID riid, void HRESULT STDMETHODCALLTYPE WrappedIDXGIDevice3::QueryInterface(REFIID riid, void **ppvObject) { - if(riid == m_pD3DDevice->GetDeviceUUID()) + if(m_pD3DDevice->IsDeviceUUID(riid)) { m_pD3DDevice->AddRef(); - *ppvObject = m_pD3DDevice->GetDeviceInterface(); + *ppvObject = m_pD3DDevice->GetDeviceInterface(riid); return S_OK; } else if(riid == __uuidof(IDXGIDevice1)) diff --git a/renderdoc/driver/dxgi/dxgi_wrapped.h b/renderdoc/driver/dxgi/dxgi_wrapped.h index 8578878d4..f811d1685 100644 --- a/renderdoc/driver/dxgi/dxgi_wrapped.h +++ b/renderdoc/driver/dxgi/dxgi_wrapped.h @@ -164,8 +164,8 @@ struct ID3DDevice virtual IID GetBackbufferUUID() = 0; - virtual IID GetDeviceUUID() = 0; - virtual IUnknown *GetDeviceInterface() = 0; + virtual bool IsDeviceUUID(REFIID guid) = 0; + virtual IUnknown *GetDeviceInterface(REFIID guid) = 0; virtual void FirstFrame(WrappedIDXGISwapChain3 *swapChain) = 0;