From 152ebc2e2e3c33b9ec545e7cbc54792fe65213ec Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 5 Jul 2018 11:39:37 +0100 Subject: [PATCH] Add handling for D3D12.1 - D3D12.3 interface UUIDs in queries --- renderdoc/driver/d3d12/d3d12_command_list.h | 12 +----- renderdoc/driver/d3d12/d3d12_command_queue.h | 12 +----- renderdoc/driver/d3d12/d3d12_commands.cpp | 12 ++++++ renderdoc/driver/d3d12/d3d12_device.cpp | 6 ++- renderdoc/driver/d3d12/d3d12_device.h | 45 +++++++++++++++++++- renderdoc/driver/d3d12/d3d12_resources.h | 12 +----- 6 files changed, 63 insertions(+), 36 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_command_list.h b/renderdoc/driver/d3d12/d3d12_command_list.h index a7544970b..c4754bf13 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list.h +++ b/renderdoc/driver/d3d12/d3d12_command_list.h @@ -195,17 +195,7 @@ public: virtual HRESULT STDMETHODCALLTYPE GetDevice(REFIID riid, _COM_Outptr_opt_ void **ppvDevice) { - if(riid == __uuidof(ID3D12Device) && ppvDevice) - { - *ppvDevice = (ID3D12Device *)m_pDevice; - m_pDevice->AddRef(); - } - else if(riid != __uuidof(ID3D12Device)) - { - return E_NOINTERFACE; - } - - return E_INVALIDARG; + return m_pDevice->GetDevice(riid, ppvDevice); } ////////////////////////////// diff --git a/renderdoc/driver/d3d12/d3d12_command_queue.h b/renderdoc/driver/d3d12/d3d12_command_queue.h index f26db3dd1..818ac6599 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue.h +++ b/renderdoc/driver/d3d12/d3d12_command_queue.h @@ -217,17 +217,7 @@ public: virtual HRESULT STDMETHODCALLTYPE GetDevice(REFIID riid, _COM_Outptr_opt_ void **ppvDevice) { - if(riid == __uuidof(ID3D12Device) && ppvDevice) - { - *ppvDevice = (ID3D12Device *)m_pDevice; - m_pDevice->AddRef(); - } - else if(riid != __uuidof(ID3D12Device)) - { - return E_NOINTERFACE; - } - - return E_INVALIDARG; + return m_pDevice->GetDevice(riid, ppvDevice); } ////////////////////////////// diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index c7f875dbf..28fe64063 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -896,6 +896,18 @@ HRESULT STDMETHODCALLTYPE WrappedID3D12GraphicsCommandList2::QueryInterface(REFI AddRef(); return S_OK; } + else if(riid == __uuidof(ID3D12GraphicsCommandList1)) + { + *ppvObject = (ID3D12GraphicsCommandList1 *)this; + AddRef(); + return S_OK; + } + else if(riid == __uuidof(ID3D12GraphicsCommandList2)) + { + *ppvObject = (ID3D12GraphicsCommandList2 *)this; + AddRef(); + return S_OK; + } else if(riid == __uuidof(ID3D12CommandList)) { *ppvObject = (ID3D12CommandList *)this; diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 37fea8946..2715434fd 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -86,7 +86,8 @@ ULONG STDMETHODCALLTYPE DummyID3D12DebugDevice::Release() HRESULT STDMETHODCALLTYPE DummyID3D12DebugDevice::QueryInterface(REFIID riid, void **ppvObject) { if(riid == __uuidof(ID3D12InfoQueue) || riid == __uuidof(ID3D12DebugDevice) || - riid == __uuidof(ID3D12Device)) + riid == __uuidof(ID3D12Device) || riid == __uuidof(ID3D12Device1) || + riid == __uuidof(ID3D12Device2) || riid == __uuidof(ID3D12Device3)) return m_pDevice->QueryInterface(riid, ppvObject); if(riid == __uuidof(IUnknown)) @@ -116,7 +117,8 @@ ULONG STDMETHODCALLTYPE WrappedID3D12DebugDevice::Release() HRESULT STDMETHODCALLTYPE WrappedID3D12DebugDevice::QueryInterface(REFIID riid, void **ppvObject) { if(riid == __uuidof(ID3D12InfoQueue) || riid == __uuidof(ID3D12DebugDevice) || - riid == __uuidof(ID3D12Device)) + riid == __uuidof(ID3D12Device) || riid == __uuidof(ID3D12Device1) || + riid == __uuidof(ID3D12Device2) || riid == __uuidof(ID3D12Device3)) return m_pDevice->QueryInterface(riid, ppvObject); if(riid == __uuidof(IUnknown)) diff --git a/renderdoc/driver/d3d12/d3d12_device.h b/renderdoc/driver/d3d12/d3d12_device.h index 91d680082..95c0cd408 100644 --- a/renderdoc/driver/d3d12/d3d12_device.h +++ b/renderdoc/driver/d3d12/d3d12_device.h @@ -517,11 +517,24 @@ public: // interface for DXGI virtual IUnknown *GetRealIUnknown() { return GetReal(); } virtual IID GetBackbufferUUID() { return __uuidof(ID3D12Resource); } - virtual bool IsDeviceUUID(REFIID iid) { return iid == __uuidof(ID3D12Device) ? true : false; } + virtual bool IsDeviceUUID(REFIID iid) + { + if(iid == __uuidof(ID3D12Device) || iid == __uuidof(ID3D12Device1) || + iid == __uuidof(ID3D12Device2) || iid == __uuidof(ID3D12Device3)) + return true; + + return false; + } virtual IUnknown *GetDeviceInterface(REFIID iid) { if(iid == __uuidof(ID3D12Device)) return (ID3D12Device *)this; + else if(iid == __uuidof(ID3D12Device1)) + return (ID3D12Device1 *)this; + else if(iid == __uuidof(ID3D12Device2)) + return (ID3D12Device2 *)this; + else if(iid == __uuidof(ID3D12Device3)) + return (ID3D12Device3 *)this; RDCERR("Requested unknown device interface %s", ToStr(iid).c_str()); @@ -541,6 +554,36 @@ public: void Unmap(ID3D12Resource *Resource, UINT Subresource, byte *mapPtr, const D3D12_RANGE *pWrittenRange); + // helper for ID3D12DeviceChild implementations to use + HRESULT GetDevice(REFIID riid, _COM_Outptr_opt_ void **ppvDevice) + { + if(!ppvDevice) + return E_INVALIDARG; + + if(riid == __uuidof(ID3D12Device)) + { + *ppvDevice = (ID3D12Device *)this; + this->AddRef(); + } + else if(riid == __uuidof(ID3D12Device1)) + { + *ppvDevice = (ID3D12Device1 *)this; + this->AddRef(); + } + else if(riid == __uuidof(ID3D12Device2)) + { + *ppvDevice = (ID3D12Device2 *)this; + this->AddRef(); + } + else if(riid == __uuidof(ID3D12Device3)) + { + *ppvDevice = (ID3D12Device3 *)this; + this->AddRef(); + } + + return E_NOINTERFACE; + } + IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, MapDataWrite, ID3D12Resource *Resource, UINT Subresource, byte *mapPtr, D3D12_RANGE range); IMPLEMENT_FUNCTION_THREAD_SERIALISED(void, WriteToSubresource, ID3D12Resource *Resource, diff --git a/renderdoc/driver/d3d12/d3d12_resources.h b/renderdoc/driver/d3d12/d3d12_resources.h index 65a5c8fd2..ded6cd47f 100644 --- a/renderdoc/driver/d3d12/d3d12_resources.h +++ b/renderdoc/driver/d3d12/d3d12_resources.h @@ -302,17 +302,7 @@ public: virtual HRESULT STDMETHODCALLTYPE GetDevice(REFIID riid, _COM_Outptr_opt_ void **ppvDevice) { - if(riid == __uuidof(ID3D12Device) && ppvDevice) - { - *ppvDevice = (ID3D12Device *)m_pDevice; - m_pDevice->AddRef(); - } - else if(riid != __uuidof(ID3D12Device)) - { - return E_NOINTERFACE; - } - - return E_INVALIDARG; + return m_pDevice->GetDevice(riid, ppvDevice); } };