From 954a11de89afa63bd2cb27adbb6bc78e319a0416 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 10 Nov 2017 12:22:13 +0000 Subject: [PATCH] Implement shutting down individual replay outputs * This means e.g. that if the mesh output view gets closed, we don't keep it around internally and keep calling InitPostVSBuffers for it. --- qrenderdoc/Windows/BufferViewer.cpp | 3 +++ qrenderdoc/Windows/TextureViewer.cpp | 3 +++ renderdoc/api/replay/renderdoc_replay.h | 13 +++++++------ renderdoc/replay/replay_controller.cpp | 12 +++++++++++- renderdoc/replay/replay_controller.h | 1 + renderdoc/replay/replay_output.cpp | 5 +++++ 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index 1c544615e..287afe34b 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -1274,6 +1274,9 @@ void BufferViewer::stageRowMenu(MeshDataStage stage, QMenu *menu, const QPoint & BufferViewer::~BufferViewer() { + if(m_Output) + m_Output->Shutdown(); + if(m_ModelVSIn->indices) m_ModelVSIn->indices->deref(); diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index c50765929..47459f9cc 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -652,6 +652,9 @@ TextureViewer::TextureViewer(ICaptureContext &ctx, QWidget *parent) TextureViewer::~TextureViewer() { + if(m_Output) + m_Output->Shutdown(); + m_Ctx.BuiltinWindowClosed(this); m_Ctx.RemoveLogViewer(this); delete ui; diff --git a/renderdoc/api/replay/renderdoc_replay.h b/renderdoc/api/replay/renderdoc_replay.h index 2beeb3afb..7a707d1b1 100644 --- a/renderdoc/api/replay/renderdoc_replay.h +++ b/renderdoc/api/replay/renderdoc_replay.h @@ -404,6 +404,13 @@ The different types are enumerated in :class:`ReplayOutputType`. )"); struct IReplayOutput { + DOCUMENT(R"(Shutdown this output. + +It's optional to call this, as calling :meth:`ReplayController.Shutdown` will shut down all of its +outputs. +)"); + virtual void Shutdown() = 0; + DOCUMENT("Sets the :class:`TextureDisplay` configuration for a texture output."); virtual void SetTextureDisplay(const TextureDisplay &o) = 0; @@ -587,12 +594,6 @@ struct IReplayController DOCUMENT("Shutdown and destroy the current interface and all outputs that have been created."); virtual void Shutdown() = 0; - DOCUMENT(R"(Shutdown a particular output. - -:param ReplayOutput output: The output to shut down. -)"); - virtual void ShutdownOutput(IReplayOutput *output) = 0; - DOCUMENT(R"(Goes into a blocking loop, repeatedly replaying the open capture as fast as possible, displaying the selected texture in a default unscaled manner to the given output window. diff --git a/renderdoc/replay/replay_controller.cpp b/renderdoc/replay/replay_controller.cpp index 3b80c0744..ac5ca0710 100644 --- a/renderdoc/replay/replay_controller.cpp +++ b/renderdoc/replay/replay_controller.cpp @@ -1427,7 +1427,17 @@ ReplayOutput *ReplayController::CreateOutput(WindowingSystem system, void *data, void ReplayController::ShutdownOutput(IReplayOutput *output) { - RDCUNIMPLEMENTED("Shutting down individual outputs"); + for(auto it = m_Outputs.begin(); it != m_Outputs.end(); ++it) + { + if((IReplayOutput *)*it == output) + { + delete *it; + m_Outputs.erase(it); + return; + } + } + + RDCERR("Unrecognised output"); } void ReplayController::Shutdown() diff --git a/renderdoc/replay/replay_controller.h b/renderdoc/replay/replay_controller.h index 4c2b99362..58607a5e7 100644 --- a/renderdoc/replay/replay_controller.h +++ b/renderdoc/replay/replay_controller.h @@ -37,6 +37,7 @@ struct ReplayController; struct ReplayOutput : public IReplayOutput { public: + void Shutdown(); void SetTextureDisplay(const TextureDisplay &o); void SetMeshDisplay(const MeshDisplay &o); diff --git a/renderdoc/replay/replay_output.cpp b/renderdoc/replay/replay_output.cpp index 352f19374..c4693986e 100644 --- a/renderdoc/replay/replay_output.cpp +++ b/renderdoc/replay/replay_output.cpp @@ -117,6 +117,11 @@ ReplayOutput::~ReplayOutput() ClearThumbnails(); } +void ReplayOutput::Shutdown() +{ + m_pRenderer->ShutdownOutput(this); +} + void ReplayOutput::SetTextureDisplay(const TextureDisplay &o) { if(o.overlay != m_RenderData.texDisplay.overlay ||