diff --git a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp index 86018cb0a..306606cca 100644 --- a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp @@ -4677,6 +4677,13 @@ bool WrappedID3D11DeviceContext::Serialise_FinishCommandList(BOOL RestoreDeferre HRESULT WrappedID3D11DeviceContext::FinishCommandList(BOOL RestoreDeferredContextState, ID3D11CommandList **ppCommandList) { + if(GetType() == D3D11_DEVICE_CONTEXT_IMMEDIATE) + { + m_pDevice->AddDebugMessage(eDbgCategory_Execution, eDbgSeverity_High, eDbgSource_IncorrectAPIUse, + "It is invalid to call FinishCommandList on an immediate context. The call has been dropped from the capture."); + return DXGI_ERROR_INVALID_CALL; + } + DrainAnnotationQueue(); ID3D11CommandList *real = NULL; diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index bbf050211..0828dd290 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -706,10 +706,13 @@ void WrappedID3D11Device::LazyInit() void WrappedID3D11Device::AddDebugMessage(DebugMessageCategory c, DebugMessageSeverity sv, DebugMessageSource src, std::string d) { - if(m_State == READING || src == eDbgSource_RuntimeWarning) + // Only add runtime warnings while executing. + // While reading, add the messages from the log, and while writing add messages + // we add (on top of the API debug messages) + if(m_State != EXECUTING || src == eDbgSource_RuntimeWarning) { DebugMessage msg; - msg.eventID = m_pImmediateContext->GetEventID(); + msg.eventID = m_State >= WRITING ? 0 : m_pImmediateContext->GetEventID(); msg.messageID = 0; msg.source = src; msg.category = c; @@ -719,15 +722,23 @@ void WrappedID3D11Device::AddDebugMessage(DebugMessageCategory c, DebugMessageSe } } +void WrappedID3D11Device::AddDebugMessage(DebugMessage msg) +{ + if(m_State != EXECUTING || msg.source == eDbgSource_RuntimeWarning) + m_DebugMessages.push_back(msg); +} + vector WrappedID3D11Device::GetDebugMessages() { vector ret; + // if reading, m_DebugMessages will contain all the messages (we + // don't try and fetch anything from the API). If writing, + // m_DebugMessages will contain any manually-added messages. + ret.swap(m_DebugMessages); + if(m_State < WRITING) - { - ret.swap(m_DebugMessages); return ret; - } if(!m_pInfoQueue) return ret; @@ -2482,6 +2493,8 @@ void WrappedID3D11Device::StartFrameCapture(void *dev, void *wnd) record.frameInfo.captureTime = Timing::GetUnixTimestamp(); m_FrameRecord.push_back(record); + m_DebugMessages.clear(); + GetResourceManager()->ClearReferencedResources(); GetResourceManager()->MarkResourceFrameReferenced(m_ResourceID, eFrameRef_Write); diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index 0c76c7d0e..85c2d6135 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -306,7 +306,7 @@ public: void FirstFrame(IDXGISwapChain *swap); vector GetDebugMessages(); - void AddDebugMessage(DebugMessage msg) { if(m_State < WRITING) m_DebugMessages.push_back(msg); } + void AddDebugMessage(DebugMessage msg); void AddDebugMessage(DebugMessageCategory c, DebugMessageSeverity sv, DebugMessageSource src, std::string d); const vector &GetLayoutDesc(ID3D11InputLayout *layout) { return m_LayoutDescs[layout]; }