diff --git a/qrenderdoc/Code/CaptureContext.cpp b/qrenderdoc/Code/CaptureContext.cpp index edcadb0c6..387b75fc9 100644 --- a/qrenderdoc/Code/CaptureContext.cpp +++ b/qrenderdoc/Code/CaptureContext.cpp @@ -945,6 +945,7 @@ void CaptureContext::LoadCaptureThreaded(const QString &captureFile, const Repla const QString &origFilename, bool temporary, bool local) { m_CaptureFile = origFilename; + m_RemoteFile = captureFile; m_CaptureLocal = local; @@ -1427,6 +1428,7 @@ void CaptureContext::CloseCapture() m_CaptureTemporary = false; m_CaptureFile = QString(); + m_RemoteFile = QString(); m_APIProps = APIProperties(); m_FrameInfo = FrameDescription(); @@ -2859,3 +2861,63 @@ void CaptureContext::AddDockWindow(QWidget *newWindow, DockReference ref, QWidge manager->areaOf(refWindow), percentage); manager->addToolWindow(newWindow, areaRef); } + +void CaptureContext::EmbedDependentFiles() +{ + if(!m_Replay.GetCaptureAccess()) + return; + + // Always operate on the capture access (local or remote) + m_Replay.GetCaptureAccess()->EmbedDependenciesIntoCapture(); + + // Local replay + if(m_Replay.GetCaptureFile()) + return; + + // Remote capture : no local capture file + if(IsCaptureTemporary()) + return; + + // Local capture file being replayed remotely : copy back from the remote + if(IsCaptureLocal()) + { + Replay().CopyCaptureFromRemote(m_RemoteFile, m_CaptureFile, m_MainWindow); + + if(!QFile::exists(m_CaptureFile)) + { + RDDialog::critical(m_MainWindow, tr("Failed to save capture"), + tr("Capture couldn't be copied from remote.")); + return; + } + } +} + +void CaptureContext::RemoveDependentFiles() +{ + if(!m_Replay.GetCaptureAccess()) + return; + + // Always operate on the capture access (local or remote) + m_Replay.GetCaptureAccess()->RemoveDependenciesFromCapture(); + + // Local replay + if(m_Replay.GetCaptureFile()) + return; + + // Remote capture : no local capture file + if(IsCaptureTemporary()) + return; + + // Local capture file being replayed remotely : copy back from the remote + if(IsCaptureLocal()) + { + Replay().CopyCaptureFromRemote(m_RemoteFile, m_CaptureFile, m_MainWindow); + + if(!QFile::exists(m_CaptureFile)) + { + RDDialog::critical(m_MainWindow, tr("Failed to save capture"), + tr("Capture couldn't be copied from remote.")); + return; + } + } +} diff --git a/qrenderdoc/Code/CaptureContext.h b/qrenderdoc/Code/CaptureContext.h index 16cd673af..2d100f222 100644 --- a/qrenderdoc/Code/CaptureContext.h +++ b/qrenderdoc/Code/CaptureContext.h @@ -204,6 +204,8 @@ public: rdcarray GetBookmarks() override { return m_Bookmarks; } void SetBookmark(const EventBookmark &mark) override; void RemoveBookmark(uint32_t EID) override; + void EmbedDependentFiles() override; + void RemoveDependentFiles() override; void DelayedCallback(uint32_t milliseconds, std::function callback) override; @@ -312,6 +314,7 @@ private: bool m_CaptureLoaded = false, m_LoadInProgress = false, m_CaptureLocal = false, m_CaptureTemporary = false; QString m_CaptureFile; + QString m_RemoteFile; CaptureModifications m_CaptureMods = CaptureModifications::NoModifications; rdcarray m_DebugMessages; diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index 1504f6a28..06fc9b868 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -2420,6 +2420,36 @@ If no bookmark exists, this function will do nothing. )"); virtual void RemoveBookmark(uint32_t eventId) = 0; + DOCUMENT(R"(Stores the dependent file data into the capture i.e. shader debug files. + +This reads the contents of the dependent files and stores their file contents into the capture. +This can help the capture to be more portable by embedding all externally referenced dependent files. +Use :meth:`RemoveDependentFiles` to remove the embedded file data. + +.. warning:: + Will remove all the existing embedded file data from the capture. + Will directly modify the capture file on disk. + +.. note:: + This will increase the size of the capture file. + Externally referenced files which can't be found on disk are skipped. + For remote replay the modifications are performed on the remote machine and copied back to the local host. +)"); + virtual void EmbedDependentFiles() = 0; + + DOCUMENT(R"(Removes the dependent files storage from the capture i.e. shader debug files. + +The files will be still be considered to be referenced by the capture and could be re-embedded +by calling :meth:`EmbedDependentFiles`. + +.. warning:: + Will directly modify the capture file on disk. + +.. note:: + For remote replay the modifications are performed on the remote machine and copied back to the local host. +)"); + virtual void RemoveDependentFiles() = 0; + DOCUMENT(R"(Registers a delayed callback to be called after a certain number of milliseconds on the UI thread. diff --git a/qrenderdoc/Windows/PythonShell.cpp b/qrenderdoc/Windows/PythonShell.cpp index 23b5b6e01..1782e3882 100644 --- a/qrenderdoc/Windows/PythonShell.cpp +++ b/qrenderdoc/Windows/PythonShell.cpp @@ -647,6 +647,14 @@ struct CaptureContextInvoker : ObjectForwarder { InvokeVoidFunction(&ICaptureContext::RemoveBookmark, EID); } + virtual void EmbedDependentFiles() override + { + InvokeVoidFunction(&ICaptureContext::EmbedDependentFiles); + } + virtual void RemoveDependentFiles() override + { + InvokeVoidFunction(&ICaptureContext::RemoveDependentFiles); + } virtual void DelayedCallback(uint32_t milliseconds, std::function callback) override { InvokeVoidFunction(&ICaptureContext::DelayedCallback, milliseconds, callback);