From 4ff1355a107800a7c9505fc5e7a4b5a5a08192b9 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 11 Jul 2014 22:15:24 +0100 Subject: [PATCH] Add D3D11 driver side call to fetch drawcall by event ID --- renderdoc/driver/d3d11/d3d11_device.cpp | 46 +++++++++++++++++++++++++ renderdoc/driver/d3d11/d3d11_device.h | 3 ++ 2 files changed, 49 insertions(+) diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index e3ae80837..a3a4f42df 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -3160,3 +3160,49 @@ WrappedID3D11DeviceContext *WrappedID3D11Device::GetDeferredContext( size_t idx return *it; } + +const FetchDrawcall *WrappedID3D11Device::GetDrawcall(const FetchDrawcall *draw, uint32_t eventID) +{ + if(draw == NULL) return NULL; + if(draw->eventID == eventID) return draw; + + int32_t count = draw->children.count; + for(int32_t i=0; i < count; i++) + { + const FetchDrawcall *cur = &draw->children.elems[i]; + const FetchDrawcall *next = i+1 < count ? &draw->children.elems[i+1] : NULL; + + if(next && next->eventID <= eventID) + continue; + + cur = GetDrawcall(cur, eventID); + + if(cur) + return cur; + } + + return NULL; +} + +const FetchDrawcall *WrappedID3D11Device::GetDrawcall(uint32_t frameID, uint32_t eventID) +{ + if(frameID >= m_FrameRecord.size()) + return NULL; + + int32_t count = m_FrameRecord[frameID].drawcallList.count; + for(int32_t i=0; i < count; i++) + { + const FetchDrawcall *cur = &m_FrameRecord[frameID].drawcallList.elems[i]; + const FetchDrawcall *next = i+1 < count ? &m_FrameRecord[frameID].drawcallList.elems[i+1] : NULL; + + if(next && next->eventID <= eventID) + continue; + + cur = GetDrawcall(cur, eventID); + + if(cur) + return cur; + } + + return NULL; +} \ No newline at end of file diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index 7e8349238..03cf255d6 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -198,6 +198,7 @@ private: double m_TotalTime, m_AvgFrametime, m_MinFrametime, m_MaxFrametime; vector m_FrameRecord; + const FetchDrawcall *GetDrawcall(const FetchDrawcall *draw, uint32_t eventID); public: static const int AllocPoolCount = 4; ALLOCATE_WITH_WRAPPED_POOL(WrappedID3D11Device, AllocPoolCount); @@ -228,6 +229,8 @@ public: vector &GetFrameRecord() { return m_FrameRecord; } + const FetchDrawcall *GetDrawcall(uint32_t frameID, uint32_t eventID); + vector GetDebugMessages(); const vector &GetLayoutDesc(ID3D11InputLayout *layout) { return m_LayoutDescs[layout]; } ShaderReflection *GetLayoutDXBC(ID3D11InputLayout *layout) { return m_LayoutDXBC[layout]; }