From 094c4164dc2eda85317c323938ba38bd4f8c494b Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 6 Apr 2017 14:11:42 +0100 Subject: [PATCH] Refactor qrenderdoc to provide stable, clean and deliberate API * Note, this API is still in-flux and beta, so there may still be some more changes before it's 'stable', and even then it will still be subject to some amount of change. * This API is then exposed to python via SWIG bindings and hides internals that don't need to be visible, and means the actual API is easier to work with. * We also use this API to reduce inter-dependencies between different windows that need to interact with each other at a high level. * The naming is python/standard RenderDoc TitleCase method names, not Qt style camelCase methods. # Conflicts: # qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp # qrenderdoc/Windows/TextureViewer.cpp --- qrenderdoc/Code/CaptureContext.cpp | 242 ++++++--- qrenderdoc/Code/CaptureContext.h | 198 ++++---- .../{ => Interface}/CommonPipelineState.cpp | 81 +++- .../{ => Interface}/CommonPipelineState.h | 98 +--- .../Code/{ => Interface}/PersistantConfig.cpp | 30 +- .../Code/{ => Interface}/PersistantConfig.h | 81 ++-- qrenderdoc/Code/Interface/QRDInterface.cpp | 154 ++++++ qrenderdoc/Code/Interface/QRDInterface.h | 458 ++++++++++++++++++ .../Code/{ => Interface}/RemoteHost.cpp | 2 +- qrenderdoc/Code/{ => Interface}/RemoteHost.h | 14 +- qrenderdoc/Code/RenderManager.h | 82 +--- qrenderdoc/Code/qrenderdoc.cpp | 2 +- qrenderdoc/Widgets/CustomPaintWidget.cpp | 2 +- qrenderdoc/Widgets/CustomPaintWidget.h | 6 +- qrenderdoc/Widgets/ResourcePreview.cpp | 2 +- qrenderdoc/Widgets/ResourcePreview.h | 4 +- qrenderdoc/Windows/APIInspector.cpp | 4 +- qrenderdoc/Windows/APIInspector.h | 18 +- qrenderdoc/Windows/BufferViewer.cpp | 55 +-- qrenderdoc/Windows/BufferViewer.h | 28 +- .../Windows/ConstantBufferPreviewer.cpp | 14 +- qrenderdoc/Windows/ConstantBufferPreviewer.h | 17 +- qrenderdoc/Windows/DebugMessageView.cpp | 36 +- qrenderdoc/Windows/DebugMessageView.h | 19 +- qrenderdoc/Windows/Dialogs/CaptureDialog.cpp | 189 +++----- qrenderdoc/Windows/Dialogs/CaptureDialog.h | 51 +- qrenderdoc/Windows/Dialogs/LiveCapture.cpp | 25 +- qrenderdoc/Windows/Dialogs/LiveCapture.h | 4 +- qrenderdoc/Windows/Dialogs/RemoteManager.cpp | 24 +- qrenderdoc/Windows/Dialogs/RemoteManager.h | 6 +- qrenderdoc/Windows/Dialogs/SettingsDialog.cpp | 182 +++---- qrenderdoc/Windows/Dialogs/SettingsDialog.h | 6 +- qrenderdoc/Windows/Dialogs/TipsDialog.cpp | 6 +- qrenderdoc/Windows/Dialogs/TipsDialog.h | 4 +- .../Windows/Dialogs/VirtualFileDialog.cpp | 6 +- .../Windows/Dialogs/VirtualFileDialog.h | 4 +- qrenderdoc/Windows/EventBrowser.cpp | 4 +- qrenderdoc/Windows/EventBrowser.h | 17 +- qrenderdoc/Windows/MainWindow.cpp | 238 ++++----- qrenderdoc/Windows/MainWindow.h | 18 +- .../D3D11PipelineStateViewer.cpp | 129 ++--- .../PipelineState/D3D11PipelineStateViewer.h | 13 +- .../D3D12PipelineStateViewer.cpp | 148 ++---- .../PipelineState/D3D12PipelineStateViewer.h | 13 +- .../PipelineState/GLPipelineStateViewer.cpp | 109 ++--- .../PipelineState/GLPipelineStateViewer.h | 13 +- .../PipelineState/PipelineStateViewer.cpp | 45 +- .../PipelineState/PipelineStateViewer.h | 20 +- .../VulkanPipelineStateViewer.cpp | 114 ++--- .../PipelineState/VulkanPipelineStateViewer.h | 4 +- qrenderdoc/Windows/PixelHistoryView.cpp | 29 +- qrenderdoc/Windows/PixelHistoryView.h | 20 +- qrenderdoc/Windows/ShaderViewer.cpp | 40 +- qrenderdoc/Windows/ShaderViewer.h | 48 +- qrenderdoc/Windows/StatisticsViewer.cpp | 24 +- qrenderdoc/Windows/StatisticsViewer.h | 17 +- qrenderdoc/Windows/TextureViewer.cpp | 189 +++----- qrenderdoc/Windows/TextureViewer.h | 56 +-- qrenderdoc/qrenderdoc.pro | 14 +- qrenderdoc/qrenderdoc_local.vcxproj | 14 +- qrenderdoc/qrenderdoc_local.vcxproj.filters | 45 +- 61 files changed, 1973 insertions(+), 1562 deletions(-) rename qrenderdoc/Code/{ => Interface}/CommonPipelineState.cpp (94%) rename qrenderdoc/Code/{ => Interface}/CommonPipelineState.h (70%) rename qrenderdoc/Code/{ => Interface}/PersistantConfig.cpp (92%) rename qrenderdoc/Code/{ => Interface}/PersistantConfig.h (89%) create mode 100644 qrenderdoc/Code/Interface/QRDInterface.cpp create mode 100644 qrenderdoc/Code/Interface/QRDInterface.h rename qrenderdoc/Code/{ => Interface}/RemoteHost.cpp (99%) rename qrenderdoc/Code/{ => Interface}/RemoteHost.h (86%) diff --git a/qrenderdoc/Code/CaptureContext.cpp b/qrenderdoc/Code/CaptureContext.cpp index 231aea354..6773ec28d 100644 --- a/qrenderdoc/Code/CaptureContext.cpp +++ b/qrenderdoc/Code/CaptureContext.cpp @@ -31,23 +31,25 @@ #include #include #include -#include #include #include "Windows/APIInspector.h" #include "Windows/BufferViewer.h" +#include "Windows/ConstantBufferPreviewer.h" #include "Windows/DebugMessageView.h" #include "Windows/Dialogs/CaptureDialog.h" #include "Windows/Dialogs/LiveCapture.h" #include "Windows/EventBrowser.h" #include "Windows/MainWindow.h" #include "Windows/PipelineState/PipelineStateViewer.h" +#include "Windows/PixelHistoryView.h" +#include "Windows/ShaderViewer.h" #include "Windows/StatisticsViewer.h" #include "Windows/TextureViewer.h" #include "QRDUtils.h" CaptureContext::CaptureContext(QString paramFilename, QString remoteHost, uint32_t remoteIdent, bool temp, PersistantConfig &cfg) - : Config(cfg) + : m_Config(cfg) { m_LogLoaded = false; m_LoadInProgress = false; @@ -90,20 +92,9 @@ bool CaptureContext::isRunning() return m_MainWindow && m_MainWindow->isVisible(); } -QString CaptureContext::ConfigFile(const QString &filename) -{ - QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - - QDir dir(path); - if(!dir.exists()) - dir.mkdir("."); - - return QDir::cleanPath(dir.absoluteFilePath(filename)); -} - QString CaptureContext::TempLogFilename(QString appname) { - QString folder = Config.TemporaryCaptureDirectory; + QString folder = Config().TemporaryCaptureDirectory; QDir dir(folder); @@ -175,7 +166,7 @@ void CaptureContext::LoadLogfileThreaded(const QString &logFile, const QString & m_LogLocal = local; - Config.Save(); + Config().Save(); m_LoadProgress = 0.0f; m_PostloadProgress = 0.0f; @@ -201,9 +192,9 @@ void CaptureContext::LoadLogfileThreaded(const QString &logFile, const QString & if(!temporary) { - PersistantConfig::AddRecentFile(Config.RecentLogFiles, origFilename, 10); + AddRecentFile(Config().RecentLogFiles, origFilename, 10); - Config.Save(); + Config().Save(); } m_EventID = 0; @@ -257,14 +248,14 @@ void CaptureContext::LoadLogfileThreaded(const QString &logFile, const QString & m_PostloadProgress = 0.9f; - r->GetD3D11PipelineState(&CurD3D11PipelineState); - r->GetD3D12PipelineState(&CurD3D12PipelineState); - r->GetGLPipelineState(&CurGLPipelineState); - r->GetVulkanPipelineState(&CurVulkanPipelineState); - CurPipelineState.SetStates(m_APIProps, &CurD3D11PipelineState, &CurD3D12PipelineState, - &CurGLPipelineState, &CurVulkanPipelineState); + r->GetD3D11PipelineState(&m_CurD3D11PipelineState); + r->GetD3D12PipelineState(&m_CurD3D12PipelineState); + r->GetGLPipelineState(&m_CurGLPipelineState); + r->GetVulkanPipelineState(&m_CurVulkanPipelineState); + m_CurPipelineState.SetStates(m_APIProps, &m_CurD3D11PipelineState, &m_CurD3D12PipelineState, + &m_CurGLPipelineState, &m_CurVulkanPipelineState); - UnreadMessageCount = 0; + m_UnreadMessageCount = 0; AddMessages(m_FrameInfo.debugMessages); m_PostloadProgress = 1.0f; @@ -275,9 +266,9 @@ void CaptureContext::LoadLogfileThreaded(const QString &logFile, const QString & QDateTime today = QDateTime::currentDateTimeUtc(); QDateTime compare = today.addDays(-21); - if(compare > Config.DegradedLog_LastUpdate && m_APIProps.degraded) + if(compare > Config().DegradedLog_LastUpdate && m_APIProps.degraded) { - Config.DegradedLog_LastUpdate = today; + Config().DegradedLog_LastUpdate = today; RDDialog::critical( NULL, "Degraded support of log", @@ -534,14 +525,14 @@ void CaptureContext::CloseLogfile() m_Textures.clear(); m_TextureList.clear(); - CurD3D11PipelineState = D3D11Pipe::State(); - CurD3D12PipelineState = D3D12Pipe::State(); - CurGLPipelineState = GLPipe::State(); - CurVulkanPipelineState = VKPipe::State(); - CurPipelineState.SetStates(m_APIProps, NULL, NULL, NULL, NULL); + m_CurD3D11PipelineState = D3D11Pipe::State(); + m_CurD3D12PipelineState = D3D12Pipe::State(); + m_CurGLPipelineState = GLPipe::State(); + m_CurVulkanPipelineState = VKPipe::State(); + m_CurPipelineState.SetStates(m_APIProps, NULL, NULL, NULL, NULL); - DebugMessages.clear(); - UnreadMessageCount = 0; + m_DebugMessages.clear(); + m_UnreadMessageCount = 0; m_LogLoaded = false; @@ -564,12 +555,12 @@ void CaptureContext::SetEventID(const QVector &exclude, uint32 m_Renderer.BlockInvoke([this, eventID, force](IReplayRenderer *r) { r->SetFrameEvent(eventID, force); - r->GetD3D11PipelineState(&CurD3D11PipelineState); - r->GetD3D12PipelineState(&CurD3D12PipelineState); - r->GetGLPipelineState(&CurGLPipelineState); - r->GetVulkanPipelineState(&CurVulkanPipelineState); - CurPipelineState.SetStates(m_APIProps, &CurD3D11PipelineState, &CurD3D12PipelineState, - &CurGLPipelineState, &CurVulkanPipelineState); + r->GetD3D11PipelineState(&m_CurD3D11PipelineState); + r->GetD3D12PipelineState(&m_CurD3D12PipelineState); + r->GetGLPipelineState(&m_CurGLPipelineState); + r->GetVulkanPipelineState(&m_CurVulkanPipelineState); + m_CurPipelineState.SetStates(m_APIProps, &m_CurD3D11PipelineState, &m_CurD3D12PipelineState, + &m_CurGLPipelineState, &m_CurVulkanPipelineState); }); for(ILogViewerForm *logviewer : m_LogViewers) @@ -584,7 +575,17 @@ void CaptureContext::SetEventID(const QVector &exclude, uint32 } } -void *CaptureContext::FillWindowingData(WId widget) +void CaptureContext::AddMessages(const rdctype::array &msgs) +{ + m_UnreadMessageCount += msgs.count; + for(const DebugMessage &msg : msgs) + m_DebugMessages.push_back(msg); + + if(m_DebugMessageView) + m_DebugMessageView->RefreshMessageList(); +} + +void *CaptureContext::FillWindowingData(uintptr_t widget) { #if defined(WIN32) @@ -619,7 +620,12 @@ void *CaptureContext::FillWindowingData(WId widget) #endif } -EventBrowser *CaptureContext::eventBrowser() +IMainWindow *CaptureContext::GetMainWindow() +{ + return m_MainWindow; +} + +IEventBrowser *CaptureContext::GetEventBrowser() { if(m_EventBrowser) return m_EventBrowser; @@ -631,7 +637,7 @@ EventBrowser *CaptureContext::eventBrowser() return m_EventBrowser; } -APIInspector *CaptureContext::apiInspector() +IAPIInspector *CaptureContext::GetAPIInspector() { if(m_APIInspector) return m_APIInspector; @@ -643,7 +649,7 @@ APIInspector *CaptureContext::apiInspector() return m_APIInspector; } -TextureViewer *CaptureContext::textureViewer() +ITextureViewer *CaptureContext::GetTextureViewer() { if(m_TextureViewer) return m_TextureViewer; @@ -655,7 +661,7 @@ TextureViewer *CaptureContext::textureViewer() return m_TextureViewer; } -BufferViewer *CaptureContext::meshPreview() +IBufferViewer *CaptureContext::GetMeshPreview() { if(m_MeshPreview) return m_MeshPreview; @@ -667,7 +673,7 @@ BufferViewer *CaptureContext::meshPreview() return m_MeshPreview; } -PipelineStateViewer *CaptureContext::pipelineViewer() +IPipelineStateViewer *CaptureContext::GetPipelineViewer() { if(m_PipelineViewer) return m_PipelineViewer; @@ -679,7 +685,7 @@ PipelineStateViewer *CaptureContext::pipelineViewer() return m_PipelineViewer; } -CaptureDialog *CaptureContext::captureDialog() +ICaptureDialog *CaptureContext::GetCaptureDialog() { if(m_CaptureDialog) return m_CaptureDialog; @@ -702,7 +708,7 @@ CaptureDialog *CaptureContext::captureDialog() return m_CaptureDialog; } -DebugMessageView *CaptureContext::debugMessageView() +IDebugMessageView *CaptureContext::GetDebugMessageView() { if(m_DebugMessageView) return m_DebugMessageView; @@ -714,7 +720,7 @@ DebugMessageView *CaptureContext::debugMessageView() return m_DebugMessageView; } -StatisticsViewer *CaptureContext::statisticsViewer() +IStatisticsViewer *CaptureContext::GetStatisticsViewer() { if(m_StatisticsViewer) return m_StatisticsViewer; @@ -726,101 +732,161 @@ StatisticsViewer *CaptureContext::statisticsViewer() return m_StatisticsViewer; } -void CaptureContext::showEventBrowser() +void CaptureContext::ShowEventBrowser() { m_MainWindow->showEventBrowser(); } -void CaptureContext::showAPIInspector() +void CaptureContext::ShowAPIInspector() { m_MainWindow->showAPIInspector(); } -void CaptureContext::showTextureViewer() +void CaptureContext::ShowTextureViewer() { m_MainWindow->showTextureViewer(); } -void CaptureContext::showMeshPreview() +void CaptureContext::ShowMeshPreview() { m_MainWindow->showMeshPreview(); } -void CaptureContext::showPipelineViewer() +void CaptureContext::ShowPipelineViewer() { m_MainWindow->showPipelineViewer(); } -void CaptureContext::showCaptureDialog() +void CaptureContext::ShowCaptureDialog() { m_MainWindow->showCaptureDialog(); } -void CaptureContext::showDebugMessageView() +void CaptureContext::ShowDebugMessageView() { m_MainWindow->showDebugMessageView(); } -void CaptureContext::showStatisticsViewer() +void CaptureContext::ShowStatisticsViewer() { m_MainWindow->showStatisticsViewer(); } -QWidget *CaptureContext::createToolWindow(const QString &objectName) +IShaderViewer *CaptureContext::EditShader(bool customShader, const QString &entryPoint, + const QStringMap &files, + IShaderViewer::SaveMethod saveCallback, + IShaderViewer::CloseMethod closeCallback, QWidget *parent) +{ + return ShaderViewer::EditShader(*this, customShader, entryPoint, files, saveCallback, + closeCallback, parent); +} + +IShaderViewer *CaptureContext::DebugShader(const ShaderBindpointMapping *bind, + const ShaderReflection *shader, ShaderStage stage, + ShaderDebugTrace *trace, const QString &debugContext, + QWidget *parent) +{ + return ShaderViewer::DebugShader(*this, bind, shader, stage, trace, debugContext, parent); +} + +IShaderViewer *CaptureContext::ViewShader(const ShaderBindpointMapping *bind, + const ShaderReflection *shader, ShaderStage stage, + QWidget *parent) +{ + return ShaderViewer::ViewShader(*this, bind, shader, stage, parent); +} + +IBufferViewer *CaptureContext::ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId id, + const QString &format) +{ + BufferViewer *viewer = new BufferViewer(*this, false, m_MainWindow); + + viewer->ViewBuffer(byteOffset, byteSize, id, format); + + return viewer; +} + +IBufferViewer *CaptureContext::ViewTextureAsBuffer(uint32_t arrayIdx, uint32_t mip, ResourceId id, + const QString &format) +{ + BufferViewer *viewer = new BufferViewer(*this, false, m_MainWindow); + + viewer->ViewTexture(arrayIdx, mip, id, format); + + return viewer; +} + +IConstantBufferPreviewer *CaptureContext::ViewConstantBuffer(ShaderStage stage, uint32_t slot, + uint32_t idx) +{ + ConstantBufferPreviewer *existing = ConstantBufferPreviewer::has(stage, slot, idx); + if(existing != NULL) + return existing; + + return new ConstantBufferPreviewer(*this, stage, slot, idx, m_MainWindow); +} + +IPixelHistoryView *CaptureContext::ViewPixelHistory(ResourceId texID, int x, int y, + const TextureDisplay &display) +{ + return new PixelHistoryView(*this, texID, QPoint(x, y), display, m_MainWindow); +} + +QWidget *CaptureContext::CreateBuiltinWindow(const QString &objectName) { if(objectName == "textureViewer") { - return textureViewer(); + return GetTextureViewer()->Widget(); } else if(objectName == "eventBrowser") { - return eventBrowser(); + return GetEventBrowser()->Widget(); } else if(objectName == "pipelineViewer") { - return pipelineViewer(); + return GetPipelineViewer()->Widget(); } else if(objectName == "meshPreview") { - return meshPreview(); + return GetMeshPreview()->Widget(); } else if(objectName == "apiInspector") { - return apiInspector(); + return GetAPIInspector()->Widget(); } else if(objectName == "capDialog") { - return captureDialog(); + return GetCaptureDialog()->Widget(); } else if(objectName == "debugMessageView") { - return debugMessageView(); + return GetDebugMessageView()->Widget(); } else if(objectName == "statisticsViewer") { - return statisticsViewer(); + return GetStatisticsViewer()->Widget(); } return NULL; } -void CaptureContext::windowClosed(QWidget *window) +void CaptureContext::BuiltinWindowClosed(QWidget *window) { - if((QWidget *)m_EventBrowser == window) + if(m_EventBrowser && m_EventBrowser->Widget() == window) m_EventBrowser = NULL; - else if((QWidget *)m_TextureViewer == window) + else if(m_TextureViewer && m_TextureViewer->Widget() == window) m_TextureViewer = NULL; - else if((QWidget *)m_CaptureDialog == window) + else if(m_CaptureDialog && m_CaptureDialog->Widget() == window) m_CaptureDialog = NULL; - else if((QWidget *)m_APIInspector == window) + else if(m_APIInspector && m_APIInspector->Widget() == window) m_APIInspector = NULL; - else if((QWidget *)m_PipelineViewer == window) + else if(m_PipelineViewer && m_PipelineViewer->Widget() == window) m_PipelineViewer = NULL; - else if((QWidget *)m_MeshPreview == window) + else if(m_MeshPreview && m_MeshPreview->Widget() == window) m_MeshPreview = NULL; - else if((QWidget *)m_DebugMessageView == window) + else if(m_DebugMessageView && m_DebugMessageView->Widget() == window) m_DebugMessageView = NULL; - else if((QWidget *)m_StatisticsViewer == window) + else if(m_StatisticsViewer && m_StatisticsViewer->Widget() == window) m_StatisticsViewer = NULL; else qCritical() << "Unrecognised window being closed: " << window; @@ -830,3 +896,31 @@ void CaptureContext::setupDockWindow(QWidget *shad) { shad->setWindowIcon(*m_Icon); } + +void CaptureContext::RaiseDockWindow(QWidget *dockWindow) +{ + ToolWindowManager::raiseToolWindow(dockWindow); +} + +void CaptureContext::AddDockWindow(QWidget *newWindow, DockReference ref, QWidget *refWindow, + float percentage) +{ + setupDockWindow(newWindow); + + if(ref == DockReference::MainToolArea) + { + m_MainWindow->mainToolManager()->addToolWindow(newWindow, m_MainWindow->mainToolArea()); + return; + } + if(ref == DockReference::LeftToolArea) + { + m_MainWindow->mainToolManager()->addToolWindow(newWindow, m_MainWindow->leftToolArea()); + return; + } + + ToolWindowManager *manager = ToolWindowManager::managerOf(refWindow); + + ToolWindowManager::AreaReference areaRef((ToolWindowManager::AreaReferenceType)ref, + manager->areaOf(refWindow), percentage); + manager->addToolWindow(newWindow, areaRef); +} diff --git a/qrenderdoc/Code/CaptureContext.h b/qrenderdoc/Code/CaptureContext.h index b96e157e4..4f95c58c5 100644 --- a/qrenderdoc/Code/CaptureContext.h +++ b/qrenderdoc/Code/CaptureContext.h @@ -30,31 +30,13 @@ #include #include #include -#include "CommonPipelineState.h" -#include "PersistantConfig.h" +#include "Interface/QRDInterface.h" #include "RenderManager.h" #if defined(RENDERDOC_PLATFORM_LINUX) #include #endif -struct ILogViewerForm -{ - virtual void OnLogfileLoaded() = 0; - virtual void OnLogfileClosed() = 0; - - // These 2 functions distinguish between the event which is actually - // selected and the event which the displayed state should be taken from. In - // the case of an event with children, OnSelectedEventChanged receives the - // ID of the event itself, whereas OnEventChanged receives that of the last - // child. This means that selecting an event with children displays the - // state after all of its children have completed, the exception being that - // the API inspector uses the selected event ID to display the API calls of - // that event rather than of the last child. - virtual void OnSelectedEventChanged(uint32_t eventID) = 0; - virtual void OnEventChanged(uint32_t eventID) = 0; -}; - class MainWindow; class EventBrowser; class APIInspector; @@ -65,7 +47,9 @@ class CaptureDialog; class DebugMessageView; class StatisticsViewer; -class CaptureContext +QString ConfigFilePath(const QString &filename); + +class CaptureContext : public ICaptureContext { public: CaptureContext(QString paramFilename, QString remoteHost, uint32_t remoteIdent, bool temp, @@ -74,21 +58,21 @@ public: bool isRunning(); - static QString ConfigFile(const QString &filename); - - QString TempLogFilename(QString appname); + QString ConfigFilePath(const QString &filename) override { return ::ConfigFilePath(filename); } + QString TempLogFilename(QString appname) override; ////////////////////////////////////////////////////////////////////////////// // Control functions - void LoadLogfile(const QString &logFile, const QString &origFilename, bool temporary, bool local); + void LoadLogfile(const QString &logFile, const QString &origFilename, bool temporary, + bool local) override; - void CloseLogfile(); + void CloseLogfile() override; void SetEventID(const QVector &exclude, uint32_t selectedEventID, - uint32_t eventID, bool force = false); - void RefreshStatus() { SetEventID({}, m_SelectedEventID, m_EventID, true); } - void AddLogViewer(ILogViewerForm *f) + uint32_t eventID, bool force = false) override; + void RefreshStatus() override { SetEventID({}, m_SelectedEventID, m_EventID, true); } + void AddLogViewer(ILogViewerForm *f) override { m_LogViewers.push_back(f); @@ -99,90 +83,122 @@ public: } } - void RemoveLogViewer(ILogViewerForm *f) { m_LogViewers.removeAll(f); } + void RemoveLogViewer(ILogViewerForm *f) override { m_LogViewers.removeAll(f); } ////////////////////////////////////////////////////////////////////////////// // Accessors - RenderManager &Renderer() { return m_Renderer; } - bool LogLoaded() { return m_LogLoaded; } - bool IsLogLocal() { return m_LogLocal; } - bool LogLoading() { return m_LoadInProgress; } - QString LogFilename() { return m_LogFile; } - const FrameDescription &FrameInfo() { return m_FrameInfo; } - const APIProperties &APIProps() { return m_APIProps; } - uint32_t CurSelectedEvent() { return m_SelectedEventID; } - uint32_t CurEvent() { return m_EventID; } - const DrawcallDescription *CurSelectedDrawcall() + RenderManager &Renderer() override { return m_Renderer; } + bool LogLoaded() override { return m_LogLoaded; } + bool IsLogLocal() override { return m_LogLocal; } + bool LogLoading() override { return m_LoadInProgress; } + QString LogFilename() override { return m_LogFile; } + const FrameDescription &FrameInfo() override { return m_FrameInfo; } + const APIProperties &APIProps() override { return m_APIProps; } + uint32_t CurSelectedEvent() override { return m_SelectedEventID; } + uint32_t CurEvent() override { return m_EventID; } + const DrawcallDescription *CurSelectedDrawcall() override { return GetDrawcall(CurSelectedEvent()); } - const DrawcallDescription *CurDrawcall() { return GetDrawcall(CurEvent()); } - const rdctype::array &CurDrawcalls() { return m_Drawcalls; } - TextureDescription *GetTexture(ResourceId id) { return m_Textures[id]; } - const rdctype::array &GetTextures() { return m_TextureList; } - BufferDescription *GetBuffer(ResourceId id) { return m_Buffers[id]; } - const rdctype::array &GetBuffers() { return m_BufferList; } - const DrawcallDescription *GetDrawcall(uint32_t eventID) - int UnreadMessageCount; - void AddMessages(const rdctype::array &msgs) + const DrawcallDescription *CurDrawcall() override { return GetDrawcall(CurEvent()); } + const rdctype::array &CurDrawcalls() override { return m_Drawcalls; } + TextureDescription *GetTexture(ResourceId id) override { return m_Textures[id]; } + const rdctype::array &GetTextures() override { return m_TextureList; } + BufferDescription *GetBuffer(ResourceId id) override { return m_Buffers[id]; } + const rdctype::array &GetBuffers() override { return m_BufferList; } + const DrawcallDescription *GetDrawcall(uint32_t eventID) override { - UnreadMessageCount += msgs.count; - for(const DebugMessage &msg : msgs) - DebugMessages.push_back(msg); + return GetDrawcall(m_Drawcalls, eventID); } - const FetchDrawcall *GetDrawcall(uint32_t eventID) { return GetDrawcall(m_Drawcalls, eventID); } - WindowingSystem m_CurWinSystem; - void *FillWindowingData(WId widget); + WindowingSystem CurWindowingSystem() override { return m_CurWinSystem; } + void *FillWindowingData(uintptr_t winId) override; - const QIcon &winIcon() { return *m_Icon; } - MainWindow *mainWindow() { return m_MainWindow; } - EventBrowser *eventBrowser(); - APIInspector *apiInspector(); - TextureViewer *textureViewer(); - BufferViewer *meshPreview(); - PipelineStateViewer *pipelineViewer(); - CaptureDialog *captureDialog(); - DebugMessageView *debugMessageView(); - StatisticsViewer *statisticsViewer(); - void setupDockWindow(QWidget *shad); + const QVector &DebugMessages() override { return m_DebugMessages; } + int UnreadMessageCount() override { return m_UnreadMessageCount; } + void MarkMessagesRead() override { m_UnreadMessageCount = 0; } + void AddMessages(const rdctype::array &msgs) override; - bool hasEventBrowser() { return m_EventBrowser != NULL; } - bool hasAPIInspector() { return m_APIInspector != NULL; } - bool hasTextureViewer() { return m_TextureViewer != NULL; } - bool hasPipelineViewer() { return m_PipelineViewer != NULL; } - bool hasMeshPreview() { return m_MeshPreview != NULL; } - bool hasCaptureDialog() { return m_CaptureDialog != NULL; } - bool hasDebugMessageView() { return m_DebugMessageView != NULL; } - bool hasStatisticsViewer() { return m_StatisticsViewer != NULL; } - void showEventBrowser(); - void showAPIInspector(); - void showTextureViewer(); - void showMeshPreview(); - void showPipelineViewer(); - void showCaptureDialog(); - void showDebugMessageView(); - void showStatisticsViewer(); + IMainWindow *GetMainWindow() override; + IEventBrowser *GetEventBrowser() override; + IAPIInspector *GetAPIInspector() override; + ITextureViewer *GetTextureViewer() override; + IBufferViewer *GetMeshPreview() override; + IPipelineStateViewer *GetPipelineViewer() override; + ICaptureDialog *GetCaptureDialog() override; + IDebugMessageView *GetDebugMessageView() override; + IStatisticsViewer *GetStatisticsViewer() override; - QWidget *createToolWindow(const QString &objectName); - void windowClosed(QWidget *window); + bool HasEventBrowser() override { return m_EventBrowser != NULL; } + bool HasAPIInspector() override { return m_APIInspector != NULL; } + bool HasTextureViewer() override { return m_TextureViewer != NULL; } + bool HasPipelineViewer() override { return m_PipelineViewer != NULL; } + bool HasMeshPreview() override { return m_MeshPreview != NULL; } + bool HasCaptureDialog() override { return m_CaptureDialog != NULL; } + bool HasDebugMessageView() override { return m_DebugMessageView != NULL; } + bool HasStatisticsViewer() override { return m_StatisticsViewer != NULL; } + void ShowEventBrowser() override; + void ShowAPIInspector() override; + void ShowTextureViewer() override; + void ShowMeshPreview() override; + void ShowPipelineViewer() override; + void ShowCaptureDialog() override; + void ShowDebugMessageView() override; + void ShowStatisticsViewer() override; - D3D11Pipe::State CurD3D11PipelineState; - D3D12Pipe::State CurD3D12PipelineState; - GLPipe::State CurGLPipelineState; - VKPipe::State CurVulkanPipelineState; - CommonPipelineState CurPipelineState; + IShaderViewer *EditShader(bool customShader, const QString &entryPoint, const QStringMap &files, + IShaderViewer::SaveMethod saveCallback, + IShaderViewer::CloseMethod closeCallback, QWidget *parent) override; - PersistantConfig &Config; + IShaderViewer *DebugShader(const ShaderBindpointMapping *bind, const ShaderReflection *shader, + ShaderStage stage, ShaderDebugTrace *trace, + const QString &debugContext, QWidget *parent) override; + IShaderViewer *ViewShader(const ShaderBindpointMapping *bind, const ShaderReflection *shader, + ShaderStage stage, QWidget *parent) override; + + IBufferViewer *ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId id, + const QString &format = "") override; + IBufferViewer *ViewTextureAsBuffer(uint32_t arrayIdx, uint32_t mip, ResourceId id, + const QString &format = "") override; + + IConstantBufferPreviewer *ViewConstantBuffer(ShaderStage stage, uint32_t slot, + uint32_t idx) override; + IPixelHistoryView *ViewPixelHistory(ResourceId texID, int x, int y, + const TextureDisplay &display) override; + + QWidget *CreateBuiltinWindow(const QString &objectName) override; + void BuiltinWindowClosed(QWidget *window) override; + + void RaiseDockWindow(QWidget *dockWindow) override; + void AddDockWindow(QWidget *newWindow, DockReference ref, QWidget *refWindow, + float percentage = 0.5f) override; + + D3D11Pipe::State &CurD3D11PipelineState() override { return m_CurD3D11PipelineState; } + D3D12Pipe::State &CurD3D12PipelineState() override { return m_CurD3D12PipelineState; } + GLPipe::State &CurGLPipelineState() override { return m_CurGLPipelineState; } + VKPipe::State &CurVulkanPipelineState() override { return m_CurVulkanPipelineState; } + CommonPipelineState &CurPipelineState() override { return m_CurPipelineState; } + PersistantConfig &Config() override { return m_Config; } private: RenderManager m_Renderer; + D3D11Pipe::State m_CurD3D11PipelineState; + D3D12Pipe::State m_CurD3D12PipelineState; + GLPipe::State m_CurGLPipelineState; + VKPipe::State m_CurVulkanPipelineState; + CommonPipelineState m_CurPipelineState; + + PersistantConfig &m_Config; + QVector m_LogViewers; bool m_LogLoaded, m_LoadInProgress, m_LogLocal; QString m_LogFile; + QVector m_DebugMessages; + int m_UnreadMessageCount; + bool PassEquivalent(const DrawcallDescription &a, const DrawcallDescription &b); bool ContainsMarker(const rdctype::array &m_Drawcalls); void AddFakeProfileMarkers(); @@ -216,6 +232,8 @@ private: return NULL; } + void setupDockWindow(QWidget *shad); + rdctype::array m_Drawcalls; APIProperties m_APIProps; @@ -228,6 +246,8 @@ private: rdctype::array m_WinSystems; + WindowingSystem m_CurWinSystem; + #if defined(RENDERDOC_PLATFORM_LINUX) xcb_connection_t *m_XCBConnection; Display *m_X11Display; diff --git a/qrenderdoc/Code/CommonPipelineState.cpp b/qrenderdoc/Code/Interface/CommonPipelineState.cpp similarity index 94% rename from qrenderdoc/Code/CommonPipelineState.cpp rename to qrenderdoc/Code/Interface/CommonPipelineState.cpp index 431c3784e..a5ad8f8d4 100644 --- a/qrenderdoc/Code/CommonPipelineState.cpp +++ b/qrenderdoc/Code/Interface/CommonPipelineState.cpp @@ -22,8 +22,9 @@ * THE SOFTWARE. ******************************************************************************/ -#include "CommonPipelineState.h" -#include "QRDUtils.h" +#include +#include "Code/QRDUtils.h" +#include "QRDInterface.h" QString CommonPipelineState::GetImageLayout(ResourceId id) { @@ -96,6 +97,82 @@ QString CommonPipelineState::OutputAbbrev() return "RT"; } +const D3D11Pipe::Shader &CommonPipelineState::GetD3D11Stage(ShaderStage stage) +{ + if(stage == ShaderStage::Vertex) + return m_D3D11->m_VS; + if(stage == ShaderStage::Domain) + return m_D3D11->m_DS; + if(stage == ShaderStage::Hull) + return m_D3D11->m_HS; + if(stage == ShaderStage::Geometry) + return m_D3D11->m_GS; + if(stage == ShaderStage::Pixel) + return m_D3D11->m_PS; + if(stage == ShaderStage::Compute) + return m_D3D11->m_CS; + + qCritical() << "Error - invalid stage " << (int)stage; + return m_D3D11->m_CS; +} + +const D3D12Pipe::Shader &CommonPipelineState::GetD3D12Stage(ShaderStage stage) +{ + if(stage == ShaderStage::Vertex) + return m_D3D12->m_VS; + if(stage == ShaderStage::Domain) + return m_D3D12->m_DS; + if(stage == ShaderStage::Hull) + return m_D3D12->m_HS; + if(stage == ShaderStage::Geometry) + return m_D3D12->m_GS; + if(stage == ShaderStage::Pixel) + return m_D3D12->m_PS; + if(stage == ShaderStage::Compute) + return m_D3D12->m_CS; + + qCritical() << "Error - invalid stage " << (int)stage; + return m_D3D12->m_CS; +} + +const GLPipe::Shader &CommonPipelineState::GetGLStage(ShaderStage stage) +{ + if(stage == ShaderStage::Vertex) + return m_GL->m_VS; + if(stage == ShaderStage::Tess_Control) + return m_GL->m_TCS; + if(stage == ShaderStage::Tess_Eval) + return m_GL->m_TES; + if(stage == ShaderStage::Geometry) + return m_GL->m_GS; + if(stage == ShaderStage::Fragment) + return m_GL->m_FS; + if(stage == ShaderStage::Compute) + return m_GL->m_CS; + + qCritical() << "Error - invalid stage " << (int)stage; + return m_GL->m_CS; +} + +const VKPipe::Shader &CommonPipelineState::GetVulkanStage(ShaderStage stage) +{ + if(stage == ShaderStage::Vertex) + return m_Vulkan->m_VS; + if(stage == ShaderStage::Tess_Control) + return m_Vulkan->m_TCS; + if(stage == ShaderStage::Tess_Eval) + return m_Vulkan->m_TES; + if(stage == ShaderStage::Geometry) + return m_Vulkan->m_GS; + if(stage == ShaderStage::Fragment) + return m_Vulkan->m_FS; + if(stage == ShaderStage::Compute) + return m_Vulkan->m_CS; + + qCritical() << "Error - invalid stage " << (int)stage; + return m_Vulkan->m_CS; +} + QString CommonPipelineState::GetShaderExtension() { if(IsLogGL() || (!LogLoaded() && DefaultType == GraphicsAPI::OpenGL) || IsLogVK() || diff --git a/qrenderdoc/Code/CommonPipelineState.h b/qrenderdoc/Code/Interface/CommonPipelineState.h similarity index 70% rename from qrenderdoc/Code/CommonPipelineState.h rename to qrenderdoc/Code/Interface/CommonPipelineState.h index 86e5c8575..af57f9f10 100644 --- a/qrenderdoc/Code/CommonPipelineState.h +++ b/qrenderdoc/Code/Interface/CommonPipelineState.h @@ -24,11 +24,8 @@ #pragma once -#include -#include -#include -#include -#include "renderdoc_replay.h" +// do not include any headers here, they must all be in QRDInterface.h +#include "QRDInterface.h" struct BoundResource { @@ -53,6 +50,8 @@ struct BoundResource CompType typeHint; }; +DECLARE_REFLECTION_STRUCT(BoundResource); + struct BoundVBuffer { ResourceId Buffer; @@ -60,6 +59,8 @@ struct BoundVBuffer uint32_t ByteStride; }; +DECLARE_REFLECTION_STRUCT(BoundVBuffer); + struct VertexInputAttribute { QString Name; @@ -72,11 +73,15 @@ struct VertexInputAttribute bool Used; }; +DECLARE_REFLECTION_STRUCT(VertexInputAttribute); + struct Viewport { float x, y, width, height; }; +DECLARE_REFLECTION_STRUCT(Viewport); + class CommonPipelineState { public: @@ -158,6 +163,7 @@ public: QString GetShaderEntryPoint(ShaderStage stage); ResourceId GetShader(ShaderStage stage); QString GetShaderName(ShaderStage stage); + QString GetShaderExtension(); void GetIBuffer(ResourceId &buf, uint64_t &ByteOffset); bool IsStripRestartEnabled(); uint32_t GetStripRestartIndex(uint32_t indexByteWidth); @@ -177,82 +183,8 @@ private: VKPipe::State *m_Vulkan = NULL; APIProperties m_APIProps; - const D3D11Pipe::Shader &GetD3D11Stage(ShaderStage stage) - { - if(stage == ShaderStage::Vertex) - return m_D3D11->m_VS; - if(stage == ShaderStage::Domain) - return m_D3D11->m_DS; - if(stage == ShaderStage::Hull) - return m_D3D11->m_HS; - if(stage == ShaderStage::Geometry) - return m_D3D11->m_GS; - if(stage == ShaderStage::Pixel) - return m_D3D11->m_PS; - if(stage == ShaderStage::Compute) - return m_D3D11->m_CS; - - qCritical() << "Error - invalid stage " << (int)stage; - return m_D3D11->m_CS; - } - - const D3D12Pipe::Shader &GetD3D12Stage(ShaderStage stage) - { - if(stage == ShaderStage::Vertex) - return m_D3D12->m_VS; - if(stage == ShaderStage::Domain) - return m_D3D12->m_DS; - if(stage == ShaderStage::Hull) - return m_D3D12->m_HS; - if(stage == ShaderStage::Geometry) - return m_D3D12->m_GS; - if(stage == ShaderStage::Pixel) - return m_D3D12->m_PS; - if(stage == ShaderStage::Compute) - return m_D3D12->m_CS; - - qCritical() << "Error - invalid stage " << (int)stage; - return m_D3D12->m_CS; - } - - const GLPipe::Shader &GetGLStage(ShaderStage stage) - { - if(stage == ShaderStage::Vertex) - return m_GL->m_VS; - if(stage == ShaderStage::Tess_Control) - return m_GL->m_TCS; - if(stage == ShaderStage::Tess_Eval) - return m_GL->m_TES; - if(stage == ShaderStage::Geometry) - return m_GL->m_GS; - if(stage == ShaderStage::Fragment) - return m_GL->m_FS; - if(stage == ShaderStage::Compute) - return m_GL->m_CS; - - qCritical() << "Error - invalid stage " << (int)stage; - return m_GL->m_CS; - } - - const VKPipe::Shader &GetVulkanStage(ShaderStage stage) - { - if(stage == ShaderStage::Vertex) - return m_Vulkan->m_VS; - if(stage == ShaderStage::Tess_Control) - return m_Vulkan->m_TCS; - if(stage == ShaderStage::Tess_Eval) - return m_Vulkan->m_TES; - if(stage == ShaderStage::Geometry) - return m_Vulkan->m_GS; - if(stage == ShaderStage::Fragment) - return m_Vulkan->m_FS; - if(stage == ShaderStage::Compute) - return m_Vulkan->m_CS; - - qCritical() << "Error - invalid stage " << (int)stage; - return m_Vulkan->m_CS; - } - -public: - QString GetShaderExtension(); + const D3D11Pipe::Shader &GetD3D11Stage(ShaderStage stage); + const D3D12Pipe::Shader &GetD3D12Stage(ShaderStage stage); + const GLPipe::Shader &GetGLStage(ShaderStage stage); + const VKPipe::Shader &GetVulkanStage(ShaderStage stage); }; \ No newline at end of file diff --git a/qrenderdoc/Code/PersistantConfig.cpp b/qrenderdoc/Code/Interface/PersistantConfig.cpp similarity index 92% rename from qrenderdoc/Code/PersistantConfig.cpp rename to qrenderdoc/Code/Interface/PersistantConfig.cpp index 515e78bab..464a363d7 100644 --- a/qrenderdoc/Code/PersistantConfig.cpp +++ b/qrenderdoc/Code/Interface/PersistantConfig.cpp @@ -22,12 +22,10 @@ * THE SOFTWARE. ******************************************************************************/ -#include "PersistantConfig.h" #include #include -#include "QRDUtils.h" -#include "RemoteHost.h" -#include "renderdoc_replay.h" +#include "Code/QRDUtils.h" +#include "QRDInterface.h" #define JSON_ID "rdocConfigData" #define JSON_VER 1 @@ -258,7 +256,7 @@ void PersistantConfig::SetupFormatting() */ } -void PersistantConfig::AddRecentFile(QList &recentList, const QString &file, int maxItems) +void AddRecentFile(QList &recentList, const QString &file, int maxItems) { QDir dir(file); QString path = dir.canonicalPath(); @@ -292,3 +290,25 @@ QString PersistantConfig::GetConfigSetting(const QString &name) return ""; } + +SPIRVDisassembler::SPIRVDisassembler(const QVariant &var) +{ + QVariantMap map = var.toMap(); + if(map.contains("name")) + name = map["name"].toString(); + if(map.contains("executable")) + executable = map["executable"].toString(); + if(map.contains("args")) + args = map["args"].toString(); +} + +SPIRVDisassembler::operator QVariant() const +{ + QVariantMap map; + + map["name"] = name; + map["executable"] = executable; + map["args"] = args; + + return map; +} diff --git a/qrenderdoc/Code/PersistantConfig.h b/qrenderdoc/Code/Interface/PersistantConfig.h similarity index 89% rename from qrenderdoc/Code/PersistantConfig.h rename to qrenderdoc/Code/Interface/PersistantConfig.h index eb2debdb0..8df4f3859 100644 --- a/qrenderdoc/Code/PersistantConfig.h +++ b/qrenderdoc/Code/Interface/PersistantConfig.h @@ -24,11 +24,8 @@ #pragma once -#include -#include -#include -#include -#include +// do not include any headers here, they must all be in QRDInterface.h +#include "QRDInterface.h" #include "RemoteHost.h" typedef QMap QStringMap; @@ -36,33 +33,15 @@ typedef QMap QStringMap; struct SPIRVDisassembler { SPIRVDisassembler() {} - SPIRVDisassembler(const QVariant &var) - { - QVariantMap map = var.toMap(); - if(map.contains("name")) - name = map["name"].toString(); - if(map.contains("executable")) - executable = map["executable"].toString(); - if(map.contains("args")) - args = map["args"].toString(); - } - - operator QVariant() const - { - QVariantMap map; - - map["name"] = name; - map["executable"] = executable; - map["args"] = args; - - return map; - } + VARIANT_CAST(SPIRVDisassembler); QString name; QString executable; QString args; }; +DECLARE_REFLECTION_STRUCT(SPIRVDisassembler); + #define CONFIG_SETTING_VAL(access, variantType, type, name, defaultValue) \ access: \ type name = defaultValue; @@ -144,18 +123,34 @@ struct SPIRVDisassembler \ CONFIG_SETTING(private, QVariantList, QList, RemoteHostList) +enum class TimeUnit : int +{ + Seconds = 0, + Milliseconds, + Microseconds, + Nanoseconds, + Count, +}; + +inline QString UnitPrefix(TimeUnit t) +{ + if(t == TimeUnit::Seconds) + return "s"; + else if(t == TimeUnit::Milliseconds) + return "ms"; + else if(t == TimeUnit::Microseconds) + return "µs"; + else if(t == TimeUnit::Nanoseconds) + return "ns"; + + return "s"; +} + +void AddRecentFile(QList &recentList, const QString &file, int maxItems); + class PersistantConfig { public: - enum class TimeUnit : int - { - Seconds = 0, - Milliseconds, - Microseconds, - Nanoseconds, - Count, - }; - // Runtime list of dynamically allocated hosts. // Saved to/from private RemoteHostList in CONFIG_SETTINGS() QList RemoteHosts; @@ -171,22 +166,6 @@ public: void SetupFormatting(); - static QString UnitPrefix(TimeUnit t) - { - if(t == TimeUnit::Seconds) - return "s"; - else if(t == TimeUnit::Milliseconds) - return "ms"; - else if(t == TimeUnit::Microseconds) - return "µs"; - else if(t == TimeUnit::Nanoseconds) - return "ns"; - - return "s"; - } - - static void AddRecentFile(QList &recentList, const QString &file, int maxItems); - void SetConfigSetting(const QString &name, const QString &value); QString GetConfigSetting(const QString &name); diff --git a/qrenderdoc/Code/Interface/QRDInterface.cpp b/qrenderdoc/Code/Interface/QRDInterface.cpp new file mode 100644 index 000000000..b0418970b --- /dev/null +++ b/qrenderdoc/Code/Interface/QRDInterface.cpp @@ -0,0 +1,154 @@ + +#include "QRDInterface.h" +#include +#include +#include "Code/QRDUtils.h" + +QString EnvironmentModification::GetTypeString() const +{ + QString ret; + + if(type == EnvMod::Append) + ret = QString("Append, %1").arg(ToQStr(separator)); + else if(type == EnvMod::Prepend) + ret = QString("Prepend, %1").arg(ToQStr(separator)); + else + ret = "Set"; + + return ret; +} + +QString EnvironmentModification::GetDescription() const +{ + QString ret; + + if(type == EnvMod::Append) + ret = QString("Append %1 with %2 using %3").arg(variable).arg(value).arg(ToQStr(separator)); + else if(type == EnvMod::Prepend) + ret = QString("Prepend %1 with %2 using %3").arg(variable).arg(value).arg(ToQStr(separator)); + else + ret = QString("Set %1 to %2").arg(variable).arg(value); + + return ret; +} + +EnvironmentModification::operator QVariant() const +{ + QVariantMap ret; + ret["variable"] = variable; + ret["value"] = value; + ret["type"] = ToQStr(type); + ret["separator"] = ToQStr(separator); + return ret; +} + +EnvironmentModification::EnvironmentModification(const QVariant &v) +{ + QVariantMap data = v.toMap(); + variable = data["variable"].toString(); + value = data["value"].toString(); + + QString t = data["type"].toString(); + + if(t == ToQStr(EnvMod::Append)) + type = EnvMod::Append; + else if(t == ToQStr(EnvMod::Prepend)) + type = EnvMod::Prepend; + else + type = EnvMod::Set; + + QString s = data["separator"].toString(); + + if(s == ToQStr(EnvSep::SemiColon)) + separator = EnvSep::SemiColon; + else if(s == ToQStr(EnvSep::Colon)) + separator = EnvSep::Colon; + else if(s == ToQStr(EnvSep::Platform)) + separator = EnvSep::Platform; + else + separator = EnvSep::NoSep; +} + +CaptureSettings::CaptureSettings() +{ + Inject = false; + AutoStart = false; + RENDERDOC_GetDefaultCaptureOptions(&Options); +} + +CaptureSettings::operator QVariant() const +{ + QVariantMap ret; + + ret["AutoStart"] = AutoStart; + + ret["Executable"] = Executable; + ret["WorkingDir"] = WorkingDir; + ret["CmdLine"] = CmdLine; + + QVariantList env; + for(int i = 0; i < Environment.size(); i++) + env.push_back((QVariant)Environment[i]); + ret["Environment"] = env; + + QVariantMap opts; + opts["AllowVSync"] = Options.AllowVSync; + opts["AllowFullscreen"] = Options.AllowFullscreen; + opts["APIValidation"] = Options.APIValidation; + opts["CaptureCallstacks"] = Options.CaptureCallstacks; + opts["CaptureCallstacksOnlyDraws"] = Options.CaptureCallstacksOnlyDraws; + opts["DelayForDebugger"] = Options.DelayForDebugger; + opts["VerifyMapWrites"] = Options.VerifyMapWrites; + opts["HookIntoChildren"] = Options.HookIntoChildren; + opts["RefAllResources"] = Options.RefAllResources; + opts["SaveAllInitials"] = Options.SaveAllInitials; + opts["CaptureAllCmdLists"] = Options.CaptureAllCmdLists; + opts["DebugOutputMute"] = Options.DebugOutputMute; + ret["Options"] = opts; + + return ret; +} + +CaptureSettings::CaptureSettings(const QVariant &v) +{ + QVariantMap data = v.toMap(); + + AutoStart = data["AutoStart"].toBool(); + + Executable = data["Executable"].toString(); + WorkingDir = data["WorkingDir"].toString(); + CmdLine = data["CmdLine"].toString(); + + QVariantList env = data["Environment"].toList(); + for(int i = 0; i < env.size(); i++) + { + EnvironmentModification e(env[i]); + Environment.push_back(e); + } + + QVariantMap opts = data["Options"].toMap(); + + Options.AllowVSync = opts["AllowVSync"].toBool(); + Options.AllowFullscreen = opts["AllowFullscreen"].toBool(); + Options.APIValidation = opts["APIValidation"].toBool(); + Options.CaptureCallstacks = opts["CaptureCallstacks"].toBool(); + Options.CaptureCallstacksOnlyDraws = opts["CaptureCallstacksOnlyDraws"].toBool(); + Options.DelayForDebugger = opts["DelayForDebugger"].toUInt(); + Options.VerifyMapWrites = opts["VerifyMapWrites"].toBool(); + Options.HookIntoChildren = opts["HookIntoChildren"].toBool(); + Options.RefAllResources = opts["RefAllResources"].toBool(); + Options.SaveAllInitials = opts["SaveAllInitials"].toBool(); + Options.CaptureAllCmdLists = opts["CaptureAllCmdLists"].toBool(); + Options.DebugOutputMute = opts["DebugOutputMute"].toBool(); +} + +QString ConfigFilePath(const QString &filename) +{ + QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); + + QDir dir(path); + if(!dir.exists()) + dir.mkdir("."); + + return QDir::cleanPath(dir.absoluteFilePath(filename)); +} diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h new file mode 100644 index 000000000..540e7b62b --- /dev/null +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -0,0 +1,458 @@ +#pragma once + +// take care before adding any more headers here, as they must be converted to python types. Any +// types in the RenderDoc core interface are already wrapped, and Qt types must either be manually +// converted directly to python, or interfaced with PySide, otherwise we get into the situation +// where pyside and SWIG have independent incompatible wrappers of Qt types +#include +#include +#include +#include +#include +#include + +#include + +// we depend on the internal RenderDoc API, but the bindings for that are imported entirely +#include "renderdoc_replay.h" + +// this is pre-declared as an opaque type as we only support converting to QWidget* via PySide +class QWidget; + +// we only support QVariant as an 'internal' interface, it's not exposed to python. However we need +// to use it in constructors/operators so conditionally compile it rather than split small structs +// into interface/implementations +#if defined(SWIG) + +#define VARIANT_CAST(classname) + +#else + +#include + +// conversion to/from QVariant +#define VARIANT_CAST(classname) \ + classname(const QVariant &var); \ + operator QVariant() const; + +#endif + +#include "CommonPipelineState.h" +#include "PersistantConfig.h" +#include "RemoteHost.h" + +struct ICaptureContext; + +struct EnvironmentModification +{ + EnvironmentModification() + { + type = EnvMod::Set; + separator = EnvSep::NoSep; + } + + QString variable; + QString value; + + EnvMod type; + EnvSep separator; + + QString GetTypeString() const; + QString GetDescription() const; + + VARIANT_CAST(EnvironmentModification); +}; + +DECLARE_REFLECTION_STRUCT(EnvironmentModification); + +struct CaptureSettings +{ + CaptureSettings(); + + VARIANT_CAST(CaptureSettings); + + CaptureOptions Options; + bool Inject; + bool AutoStart; + QString Executable; + QString WorkingDir; + QString CmdLine; + QList Environment; +}; + +DECLARE_REFLECTION_STRUCT(CaptureSettings); + +struct IMainWindow +{ + virtual QWidget *Widget() = 0; + +protected: + IMainWindow() = default; + ~IMainWindow() = default; +}; + +DECLARE_REFLECTION_STRUCT(IMainWindow); + +struct IEventBrowser +{ + virtual QWidget *Widget() = 0; + +protected: + IEventBrowser() = default; + ~IEventBrowser() = default; +}; + +DECLARE_REFLECTION_STRUCT(IEventBrowser); + +struct IAPIInspector +{ + virtual QWidget *Widget() = 0; + + virtual void Refresh() = 0; + +protected: + IAPIInspector() = default; + ~IAPIInspector() = default; +}; + +DECLARE_REFLECTION_STRUCT(IAPIInspector); + +struct IPipelineStateViewer +{ + virtual QWidget *Widget() = 0; + + virtual bool SaveShaderFile(const ShaderReflection *shader) = 0; + +protected: + IPipelineStateViewer() = default; + ~IPipelineStateViewer() = default; +}; + +DECLARE_REFLECTION_STRUCT(IPipelineStateViewer); + +struct ITextureViewer +{ + virtual QWidget *Widget() = 0; + + virtual void ViewTexture(ResourceId ID, bool focus) = 0; + virtual void GotoLocation(int x, int y) = 0; + +protected: + ITextureViewer() = default; + ~ITextureViewer() = default; +}; + +DECLARE_REFLECTION_STRUCT(ITextureViewer); + +struct IBufferViewer +{ + virtual QWidget *Widget() = 0; + + virtual void ScrollToRow(int row, MeshDataStage stage = MeshDataStage::VSIn) = 0; + virtual void ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId id, + const QString &format = "") = 0; + virtual void ViewTexture(uint32_t arrayIdx, uint32_t mip, ResourceId id, + const QString &format = "") = 0; + +protected: + IBufferViewer() = default; + ~IBufferViewer() = default; +}; + +DECLARE_REFLECTION_STRUCT(IBufferViewer); + +struct ICaptureDialog +{ + virtual QWidget *Widget() = 0; + + virtual bool IsInjectMode() = 0; + virtual void SetInjectMode(bool inject) = 0; + + virtual void SetExecutableFilename(const QString &filename) = 0; + virtual void SetWorkingDirectory(const QString &dir) = 0; + virtual void SetCommandLine(const QString &cmd) = 0; + virtual void SetEnvironmentModifications(const QList &modifications) = 0; + + virtual void SetSettings(CaptureSettings settings) = 0; + virtual CaptureSettings Settings() = 0; + + virtual void TriggerCapture() = 0; + + virtual void LoadSettings(QString filename) = 0; + virtual void SaveSettings(QString filename) = 0; + virtual void UpdateGlobalHook() = 0; + +protected: + ICaptureDialog() = default; + ~ICaptureDialog() = default; +}; + +DECLARE_REFLECTION_STRUCT(ICaptureDialog); + +struct IDebugMessageView +{ + virtual QWidget *Widget() = 0; + +protected: + IDebugMessageView() = default; + ~IDebugMessageView() = default; +}; + +DECLARE_REFLECTION_STRUCT(IDebugMessageView); + +struct IStatisticsViewer +{ + virtual QWidget *Widget() = 0; + +protected: + IStatisticsViewer() = default; + ~IStatisticsViewer() = default; +}; + +DECLARE_REFLECTION_STRUCT(IStatisticsViewer); + +struct IShaderViewer +{ + typedef std::function SaveMethod; + typedef std::function CloseMethod; + + virtual QWidget *Widget() = 0; + + virtual int CurrentStep() = 0; + virtual void SetCurrentStep(int step) = 0; + + virtual void ToggleBreakpoint(int instruction = -1) = 0; + + virtual void ShowErrors(const QString &errors) = 0; + +protected: + IShaderViewer() = default; + ~IShaderViewer() = default; +}; + +DECLARE_REFLECTION_STRUCT(IShaderViewer); + +struct IConstantBufferPreviewer +{ + virtual QWidget *Widget() = 0; + +protected: + IConstantBufferPreviewer() = default; + ~IConstantBufferPreviewer() = default; +}; + +DECLARE_REFLECTION_STRUCT(IConstantBufferPreviewer); + +struct IPixelHistoryView +{ + virtual QWidget *Widget() = 0; + virtual void SetHistory(const rdctype::array &history) = 0; + +protected: + IPixelHistoryView() = default; + ~IPixelHistoryView() = default; +}; + +DECLARE_REFLECTION_STRUCT(IPixelHistoryView); + +struct ILogViewerForm +{ + virtual void OnLogfileLoaded() = 0; + virtual void OnLogfileClosed() = 0; + + // These 2 functions distinguish between the event which is actually + // selected and the event which the displayed state should be taken from. In + // the case of an event with children, OnSelectedEventChanged receives the + // ID of the event itself, whereas OnEventChanged receives that of the last + // child. This means that selecting an event with children displays the + // state after all of its children have completed, the exception being that + // the API inspector uses the selected event ID to display the API calls of + // that event rather than of the last child. + virtual void OnSelectedEventChanged(uint32_t eventID) = 0; + virtual void OnEventChanged(uint32_t eventID) = 0; + +protected: + ILogViewerForm() = default; + ~ILogViewerForm() = default; +}; + +DECLARE_REFLECTION_STRUCT(ILogViewerForm); + +struct IRenderManager +{ + typedef std::function InvokeMethod; + typedef std::function &)> DirectoryBrowseMethod; + + virtual void DeleteCapture(const QString &logfile, bool local) = 0; + + // this tagged version is for cases when we might send a request - e.g. to pick a vertex or pixel + // - and want to pre-empt it with a new request before the first has returned. Either because some + // other work is taking a while or because we're sending requests faster than they can be + // processed. + // the manager processes only the request on the top of the queue, so when a new tagged invoke + // comes in, we remove any other requests in the queue before it that have the same tag + virtual void AsyncInvoke(const QString &tag, InvokeMethod m) = 0; + virtual void AsyncInvoke(InvokeMethod m) = 0; + virtual void BlockInvoke(InvokeMethod m) = 0; + + virtual ReplayStatus ConnectToRemoteServer(RemoteHost *host) = 0; + virtual void DisconnectFromRemoteServer() = 0; + virtual void ShutdownServer() = 0; + virtual void PingRemote() = 0; + + virtual const RemoteHost *CurrentRemote() = 0; + virtual uint32_t ExecuteAndInject(const QString &exe, const QString &workingDir, + const QString &cmdLine, const QList &env, + const QString &logfile, CaptureOptions opts) = 0; + + virtual QStringList GetRemoteSupport() = 0; + virtual void GetHomeFolder(bool synchronous, DirectoryBrowseMethod cb) = 0; + virtual bool ListFolder(QString path, bool synchronous, DirectoryBrowseMethod cb) = 0; + virtual QString CopyCaptureToRemote(const QString &localpath, QWidget *window) = 0; + virtual void CopyCaptureFromRemote(const QString &remotepath, const QString &localpath, + QWidget *window) = 0; + +protected: + IRenderManager() = default; + ~IRenderManager() = default; +}; + +DECLARE_REFLECTION_STRUCT(IRenderManager); + +// should match ToolWindowManager::AreaReferenceType +enum class DockReference : int +{ + LastUsedArea, + NewFloatingArea, + EmptySpace, + NoArea, + AddTo, + LeftOf, + RightOf, + TopOf, + BottomOf, + + // extra values here + MainToolArea, + LeftToolArea, +}; + +struct ICaptureContext +{ + virtual QString ConfigFilePath(const QString &filename) = 0; + + virtual QString TempLogFilename(QString appname) = 0; + + virtual void LoadLogfile(const QString &logFile, const QString &origFilename, bool temporary, + bool local) = 0; + virtual void CloseLogfile() = 0; + + virtual void SetEventID(const QVector &exclude, uint32_t selectedEventID, + uint32_t eventID, bool force = false) = 0; + virtual void RefreshStatus() = 0; + + virtual void AddLogViewer(ILogViewerForm *f) = 0; + virtual void RemoveLogViewer(ILogViewerForm *f) = 0; + + ////////////////////////////////////////////////////////////////////////////// + // Accessors + + virtual IRenderManager &Renderer() = 0; + virtual bool LogLoaded() = 0; + virtual bool IsLogLocal() = 0; + virtual bool LogLoading() = 0; + virtual QString LogFilename() = 0; + virtual const FrameDescription &FrameInfo() = 0; + virtual const APIProperties &APIProps() = 0; + virtual uint32_t CurSelectedEvent() = 0; + virtual uint32_t CurEvent() = 0; + virtual const DrawcallDescription *CurSelectedDrawcall() = 0; + virtual const DrawcallDescription *CurDrawcall() = 0; + virtual const rdctype::array &CurDrawcalls() = 0; + virtual TextureDescription *GetTexture(ResourceId id) = 0; + virtual const rdctype::array &GetTextures() = 0; + virtual BufferDescription *GetBuffer(ResourceId id) = 0; + virtual const rdctype::array &GetBuffers() = 0; + + virtual const DrawcallDescription *GetDrawcall(uint32_t eventID) = 0; + + virtual WindowingSystem CurWindowingSystem() = 0; + virtual void *FillWindowingData(uintptr_t winId) = 0; + + virtual const QVector &DebugMessages() = 0; + virtual int UnreadMessageCount() = 0; + virtual void MarkMessagesRead() = 0; + virtual void AddMessages(const rdctype::array &msgs) = 0; + + virtual IMainWindow *GetMainWindow() = 0; + virtual IEventBrowser *GetEventBrowser() = 0; + virtual IAPIInspector *GetAPIInspector() = 0; + virtual ITextureViewer *GetTextureViewer() = 0; + virtual IBufferViewer *GetMeshPreview() = 0; + virtual IPipelineStateViewer *GetPipelineViewer() = 0; + virtual ICaptureDialog *GetCaptureDialog() = 0; + virtual IDebugMessageView *GetDebugMessageView() = 0; + virtual IStatisticsViewer *GetStatisticsViewer() = 0; + + virtual bool HasEventBrowser() = 0; + virtual bool HasAPIInspector() = 0; + virtual bool HasTextureViewer() = 0; + virtual bool HasPipelineViewer() = 0; + virtual bool HasMeshPreview() = 0; + virtual bool HasCaptureDialog() = 0; + virtual bool HasDebugMessageView() = 0; + virtual bool HasStatisticsViewer() = 0; + + virtual void ShowEventBrowser() = 0; + virtual void ShowAPIInspector() = 0; + virtual void ShowTextureViewer() = 0; + virtual void ShowMeshPreview() = 0; + virtual void ShowPipelineViewer() = 0; + virtual void ShowCaptureDialog() = 0; + virtual void ShowDebugMessageView() = 0; + virtual void ShowStatisticsViewer() = 0; + + virtual IShaderViewer *EditShader(bool customShader, const QString &entryPoint, + const QStringMap &files, IShaderViewer::SaveMethod saveCallback, + IShaderViewer::CloseMethod closeCallback, QWidget *parent) = 0; + + virtual IShaderViewer *DebugShader(const ShaderBindpointMapping *bind, + const ShaderReflection *shader, ShaderStage stage, + ShaderDebugTrace *trace, const QString &debugContext, + QWidget *parent) = 0; + + virtual IShaderViewer *ViewShader(const ShaderBindpointMapping *bind, + const ShaderReflection *shader, ShaderStage stage, + QWidget *parent) = 0; + + virtual IBufferViewer *ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId id, + const QString &format = "") = 0; + virtual IBufferViewer *ViewTextureAsBuffer(uint32_t arrayIdx, uint32_t mip, ResourceId id, + const QString &format = "") = 0; + + virtual IConstantBufferPreviewer *ViewConstantBuffer(ShaderStage stage, uint32_t slot, + uint32_t idx) = 0; + virtual IPixelHistoryView *ViewPixelHistory(ResourceId texID, int x, int y, + const TextureDisplay &display) = 0; + + virtual QWidget *CreateBuiltinWindow(const QString &objectName) = 0; + virtual void BuiltinWindowClosed(QWidget *window) = 0; + + virtual void RaiseDockWindow(QWidget *dockWindow) = 0; + virtual void AddDockWindow(QWidget *newWindow, DockReference ref, QWidget *refWindow, + float percentage = 0.5f) = 0; + + virtual D3D11Pipe::State &CurD3D11PipelineState() = 0; + virtual D3D12Pipe::State &CurD3D12PipelineState() = 0; + virtual GLPipe::State &CurGLPipelineState() = 0; + virtual VKPipe::State &CurVulkanPipelineState() = 0; + virtual CommonPipelineState &CurPipelineState() = 0; + + virtual PersistantConfig &Config() = 0; + +protected: + ICaptureContext() = default; + ~ICaptureContext() = default; +}; + +DECLARE_REFLECTION_STRUCT(ICaptureContext); diff --git a/qrenderdoc/Code/RemoteHost.cpp b/qrenderdoc/Code/Interface/RemoteHost.cpp similarity index 99% rename from qrenderdoc/Code/RemoteHost.cpp rename to qrenderdoc/Code/Interface/RemoteHost.cpp index 9d275ca6a..4869514d7 100644 --- a/qrenderdoc/Code/RemoteHost.cpp +++ b/qrenderdoc/Code/Interface/RemoteHost.cpp @@ -22,10 +22,10 @@ * THE SOFTWARE. ******************************************************************************/ -#include "RemoteHost.h" #include #include #include "Code/QRDUtils.h" +#include "QRDInterface.h" #include "renderdoc_replay.h" RemoteHost::RemoteHost() diff --git a/qrenderdoc/Code/RemoteHost.h b/qrenderdoc/Code/Interface/RemoteHost.h similarity index 86% rename from qrenderdoc/Code/RemoteHost.h rename to qrenderdoc/Code/Interface/RemoteHost.h index db9cc585c..5a5b9f006 100644 --- a/qrenderdoc/Code/RemoteHost.h +++ b/qrenderdoc/Code/Interface/RemoteHost.h @@ -24,17 +24,19 @@ #pragma once -#include +class RemoteHost; + +// do not include any headers here, they must all be in QRDInterface.h +#include "QRDInterface.h" class RemoteHost { public: RemoteHost(); - RemoteHost(const QVariant &var); - operator QVariant() const; + VARIANT_CAST(RemoteHost); - bool isValid() { return !Hostname.isEmpty(); } + bool IsValid() { return !Hostname.isEmpty(); } void CheckStatus(); void Launch(); @@ -45,4 +47,6 @@ public: QString Hostname; QString RunCommand; -}; \ No newline at end of file +}; + +DECLARE_REFLECTION_STRUCT(RemoteHost); \ No newline at end of file diff --git a/qrenderdoc/Code/RenderManager.h b/qrenderdoc/Code/RenderManager.h index a390cf6ab..f379b1e35 100644 --- a/qrenderdoc/Code/RenderManager.h +++ b/qrenderdoc/Code/RenderManager.h @@ -32,8 +32,8 @@ #include #include #include +#include "Interface/QRDInterface.h" #include "QRDUtils.h" -#include "RemoteHost.h" #include "renderdoc_replay.h" struct IReplayRenderer; @@ -44,85 +44,9 @@ class RemoteHost; #define INVOKE_MEMFN(function) \ m_Ctx.Renderer().AsyncInvoke([this](IReplayRenderer *r) { function(r); }); -struct EnvironmentModification -{ - QString variable; - QString value; - - EnvMod type; - EnvSep separator; - - QString GetTypeString() const - { - QString ret; - - if(type == EnvMod::Append) - ret = QString("Append, %1").arg(ToQStr(separator)); - else if(type == EnvMod::Prepend) - ret = QString("Prepend, %1").arg(ToQStr(separator)); - else - ret = "Set"; - - return ret; - } - - QString GetDescription() const - { - QString ret; - - if(type == EnvMod::Append) - ret = QString("Append %1 with %2 using %3").arg(variable).arg(value).arg(ToQStr(separator)); - else if(type == EnvMod::Prepend) - ret = QString("Prepend %1 with %2 using %3").arg(variable).arg(value).arg(ToQStr(separator)); - else - ret = QString("Set %1 to %2").arg(variable).arg(value); - - return ret; - } - - QVariantMap toJSON() const - { - QVariantMap ret; - ret["variable"] = variable; - ret["value"] = value; - ret["type"] = ToQStr(type); - ret["separator"] = ToQStr(separator); - return ret; - } - - void fromJSON(const QVariantMap &data) - { - variable = data["variable"].toString(); - value = data["value"].toString(); - - QString t = data["type"].toString(); - - if(t == ToQStr(EnvMod::Append)) - type = EnvMod::Append; - else if(t == ToQStr(EnvMod::Prepend)) - type = EnvMod::Prepend; - else - type = EnvMod::Set; - - QString s = data["separator"].toString(); - - if(s == ToQStr(EnvSep::SemiColon)) - separator = EnvSep::SemiColon; - else if(s == ToQStr(EnvSep::Colon)) - separator = EnvSep::Colon; - else if(s == ToQStr(EnvSep::Platform)) - separator = EnvSep::Platform; - else - separator = EnvSep::NoSep; - } -}; - -class RenderManager +class RenderManager : public IRenderManager { public: - typedef std::function InvokeMethod; - typedef std::function &)> DirectoryBrowseMethod; - RenderManager(); ~RenderManager(); @@ -148,7 +72,7 @@ public: void ShutdownServer(); void PingRemote(); - const RemoteHost *remote() { return m_RemoteHost; } + const RemoteHost *CurrentRemote() { return m_RemoteHost; } uint32_t ExecuteAndInject(const QString &exe, const QString &workingDir, const QString &cmdLine, const QList &env, const QString &logfile, CaptureOptions opts); diff --git a/qrenderdoc/Code/qrenderdoc.cpp b/qrenderdoc/Code/qrenderdoc.cpp index d9d76d96b..e9eb158af 100644 --- a/qrenderdoc/Code/qrenderdoc.cpp +++ b/qrenderdoc/Code/qrenderdoc.cpp @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) dir.mkpath(configPath); } - QString configFilename = CaptureContext::ConfigFile("UI.config"); + QString configFilename = ConfigFilePath("UI.config"); if(!config.Load(configFilename)) { diff --git a/qrenderdoc/Widgets/CustomPaintWidget.cpp b/qrenderdoc/Widgets/CustomPaintWidget.cpp index 47a1395ed..d3c15976f 100644 --- a/qrenderdoc/Widgets/CustomPaintWidget.cpp +++ b/qrenderdoc/Widgets/CustomPaintWidget.cpp @@ -36,7 +36,7 @@ CustomPaintWidget::CustomPaintWidget(QWidget *parent) : QWidget(parent) setMouseTracking(true); } -CustomPaintWidget::CustomPaintWidget(CaptureContext *c, QWidget *parent) : QWidget(parent) +CustomPaintWidget::CustomPaintWidget(ICaptureContext *c, QWidget *parent) : QWidget(parent) { m_Ctx = c; m_Output = NULL; diff --git a/qrenderdoc/Widgets/CustomPaintWidget.h b/qrenderdoc/Widgets/CustomPaintWidget.h index 0721bff0c..5296c5c6c 100644 --- a/qrenderdoc/Widgets/CustomPaintWidget.h +++ b/qrenderdoc/Widgets/CustomPaintWidget.h @@ -27,7 +27,7 @@ #include struct IReplayOutput; -class CaptureContext; +struct ICaptureContext; class CustomPaintWidget : public QWidget { @@ -35,7 +35,7 @@ private: Q_OBJECT public: explicit CustomPaintWidget(QWidget *parent = 0); - explicit CustomPaintWidget(CaptureContext *c, QWidget *parent = 0); + explicit CustomPaintWidget(ICaptureContext *c, QWidget *parent = 0); ~CustomPaintWidget(); // this is needed to solve a chicken-and-egg problem. We need to recreate the widget @@ -74,7 +74,7 @@ public slots: protected: void paintEvent(QPaintEvent *e) override; QPaintEngine *paintEngine() const override { return m_Ctx ? NULL : QWidget::paintEngine(); } - CaptureContext *m_Ctx; + ICaptureContext *m_Ctx; IReplayOutput *m_Output; QColor m_Dark; QColor m_Light; diff --git a/qrenderdoc/Widgets/ResourcePreview.cpp b/qrenderdoc/Widgets/ResourcePreview.cpp index 1f1e2dc31..18967ea23 100644 --- a/qrenderdoc/Widgets/ResourcePreview.cpp +++ b/qrenderdoc/Widgets/ResourcePreview.cpp @@ -26,7 +26,7 @@ #include #include "ui_ResourcePreview.h" -ResourcePreview::ResourcePreview(CaptureContext &c, IReplayOutput *output, QWidget *parent) +ResourcePreview::ResourcePreview(ICaptureContext &c, IReplayOutput *output, QWidget *parent) : QFrame(parent), ui(new Ui::ResourcePreview) { ui->setupUi(this); diff --git a/qrenderdoc/Widgets/ResourcePreview.h b/qrenderdoc/Widgets/ResourcePreview.h index 2c61c63f6..b705e72c1 100644 --- a/qrenderdoc/Widgets/ResourcePreview.h +++ b/qrenderdoc/Widgets/ResourcePreview.h @@ -32,14 +32,14 @@ class ResourcePreview; } struct IReplayOutput; -class CaptureContext; +struct ICaptureContext; class ResourcePreview : public QFrame { Q_OBJECT public: - explicit ResourcePreview(CaptureContext &c, IReplayOutput *output, QWidget *parent = 0); + explicit ResourcePreview(ICaptureContext &c, IReplayOutput *output, QWidget *parent = 0); ~ResourcePreview(); signals: diff --git a/qrenderdoc/Windows/APIInspector.cpp b/qrenderdoc/Windows/APIInspector.cpp index dced7e189..58d580a82 100644 --- a/qrenderdoc/Windows/APIInspector.cpp +++ b/qrenderdoc/Windows/APIInspector.cpp @@ -28,7 +28,7 @@ Q_DECLARE_METATYPE(APIEvent); -APIInspector::APIInspector(CaptureContext &ctx, QWidget *parent) +APIInspector::APIInspector(ICaptureContext &ctx, QWidget *parent) : QFrame(parent), ui(new Ui::APIInspector), m_Ctx(ctx) { ui->setupUi(this); @@ -49,7 +49,7 @@ APIInspector::APIInspector(CaptureContext &ctx, QWidget *parent) APIInspector::~APIInspector() { - m_Ctx.windowClosed(this); + m_Ctx.BuiltinWindowClosed(this); m_Ctx.RemoveLogViewer(this); delete ui; } diff --git a/qrenderdoc/Windows/APIInspector.h b/qrenderdoc/Windows/APIInspector.h index beff3ab05..f9b973ac6 100644 --- a/qrenderdoc/Windows/APIInspector.h +++ b/qrenderdoc/Windows/APIInspector.h @@ -32,24 +32,28 @@ namespace Ui class APIInspector; } -class APIInspector : public QFrame, public ILogViewerForm +class APIInspector : public QFrame, public IAPIInspector, public ILogViewerForm { Q_OBJECT public: - explicit APIInspector(CaptureContext &ctx, QWidget *parent = 0); + explicit APIInspector(ICaptureContext &ctx, QWidget *parent = 0); ~APIInspector(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID); - void OnEventChanged(uint32_t eventID) {} + // IAPIInspector + QWidget *Widget() override { return this; } + void Refresh() override { on_apiEvents_itemSelectionChanged(); } + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override; + void OnEventChanged(uint32_t eventID) override {} public slots: void on_apiEvents_itemSelectionChanged(); private: Ui::APIInspector *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; void addCallstack(rdctype::array calls); void fillAPIView(); diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index 4a163bd8b..b89309e55 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -32,7 +32,6 @@ #include #include #include "Code/Resources.h" -#include "Windows/ShaderViewer.h" #include "ui_BufferViewer.h" class CameraWrapper @@ -807,7 +806,7 @@ void CacheDataForIteration(QVector &cache, const QListsetupUi(this); @@ -1135,7 +1134,7 @@ BufferViewer::~BufferViewer() delete m_Flycam; if(m_MeshView) - m_Ctx.windowClosed(this); + m_Ctx.BuiltinWindowClosed(this); m_Ctx.RemoveLogViewer(this); delete ui; @@ -1151,7 +1150,7 @@ void BufferViewer::OnLogfileLoaded() WId renderID = ui->render->winId(); m_Ctx.Renderer().BlockInvoke([renderID, this](IReplayRenderer *r) { - m_Output = r->CreateOutput(m_Ctx.m_CurWinSystem, m_Ctx.FillWindowingData(renderID), + m_Output = r->CreateOutput(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(renderID), ReplayOutputType::Mesh); ui->render->setOutput(m_Output); @@ -1298,9 +1297,9 @@ void BufferViewer::RT_FetchMeshData(IReplayRenderer *r) ResourceId ib; uint64_t ioffset = 0; - m_Ctx.CurPipelineState.GetIBuffer(ib, ioffset); + m_Ctx.CurPipelineState().GetIBuffer(ib, ioffset); - QVector vbs = m_Ctx.CurPipelineState.GetVBuffers(); + QVector vbs = m_Ctx.CurPipelineState().GetVBuffers(); rdctype::array idata; if(ib != ResourceId() && draw && (draw->flags & DrawFlags::UseIBuffer)) @@ -1810,7 +1809,7 @@ void BufferViewer::guessSecondaryColumn(BufferItemModel *model) void BufferViewer::updatePreviewColumns() { - QVector vbs = m_Ctx.CurPipelineState.GetVBuffers(); + QVector vbs = m_Ctx.CurPipelineState().GetVBuffers(); const DrawcallDescription *draw = m_Ctx.CurDrawcall(); if(draw) @@ -1828,7 +1827,7 @@ void BufferViewer::updatePreviewColumns() m_VSInPosition.topo = draw->topology; m_VSInPosition.idxByteWidth = draw->indexByteWidth; m_VSInPosition.baseVertex = draw->baseVertex; - m_Ctx.CurPipelineState.GetIBuffer(m_VSInPosition.idxbuf, m_VSInPosition.idxoffs); + m_Ctx.CurPipelineState().GetIBuffer(m_VSInPosition.idxbuf, m_VSInPosition.idxoffs); { const FormatElement &el = m_ModelVSIn->columns[elIdx]; @@ -1917,7 +1916,7 @@ void BufferViewer::updatePreviewColumns() m_PostVSPosition.idxByteWidth = m_VSInPosition.idxByteWidth = 0; m_PostGSPosition.unproject = true; - m_PostVSPosition.unproject = !m_Ctx.CurPipelineState.IsTessellationEnabled(); + m_PostVSPosition.unproject = !m_Ctx.CurPipelineState().IsTessellationEnabled(); } else { @@ -1938,7 +1937,7 @@ void BufferViewer::configureMeshColumns() { const DrawcallDescription *draw = m_Ctx.CurDrawcall(); - QVector vinputs = m_Ctx.CurPipelineState.GetVertexInputs(); + QVector vinputs = m_Ctx.CurPipelineState().GetVertexInputs(); m_ModelVSIn->columns.reserve(vinputs.count()); @@ -1960,9 +1959,9 @@ void BufferViewer::configureMeshColumns() else m_ModelVSIn->numRows = draw->numIndices; - QVector vbs = m_Ctx.CurPipelineState.GetVBuffers(); + QVector vbs = m_Ctx.CurPipelineState().GetVBuffers(); - Viewport vp = m_Ctx.CurPipelineState.GetViewport(0); + Viewport vp = m_Ctx.CurPipelineState().GetViewport(0); m_Config.fov = ui->fovGuess->value(); m_Config.aspect = vp.width / vp.height; @@ -1977,7 +1976,7 @@ void BufferViewer::configureMeshColumns() if(ui->farGuess->value() > 0.0) m_PostVS.farPlane = m_PostGS.farPlane = ui->farGuess->value(); - const ShaderReflection *vs = m_Ctx.CurPipelineState.GetShaderReflection(ShaderStage::Vertex); + const ShaderReflection *vs = m_Ctx.CurPipelineState().GetShaderReflection(ShaderStage::Vertex); m_ModelVSOut->columns.clear(); @@ -2025,7 +2024,7 @@ void BufferViewer::configureMeshColumns() uint numComps = sig.format.compCount; uint elemSize = sig.format.compType == CompType::Double ? 8U : 4U; - if(m_Ctx.CurPipelineState.HasAlignedPostVSData()) + if(m_Ctx.CurPipelineState().HasAlignedPostVSData()) { if(numComps == 2) offset = AlignUp(offset, 2U * elemSize); @@ -2043,9 +2042,10 @@ void BufferViewer::configureMeshColumns() if(draw) { - const ShaderReflection *last = m_Ctx.CurPipelineState.GetShaderReflection(ShaderStage::Geometry); + const ShaderReflection *last = + m_Ctx.CurPipelineState().GetShaderReflection(ShaderStage::Geometry); if(last == NULL) - last = m_Ctx.CurPipelineState.GetShaderReflection(ShaderStage::Domain); + last = m_Ctx.CurPipelineState().GetShaderReflection(ShaderStage::Domain); if(last) { @@ -2091,7 +2091,7 @@ void BufferViewer::configureMeshColumns() uint numComps = sig.format.compCount; uint elemSize = sig.format.compType == CompType::Double ? 8U : 4U; - if(m_Ctx.CurPipelineState.HasAlignedPostVSData()) + if(m_Ctx.CurPipelineState().HasAlignedPostVSData()) { if(numComps == 2) offset = AlignUp(offset, 2U * elemSize); @@ -2332,7 +2332,7 @@ bool BufferViewer::isCurrentRasterOut() } else if(m_CurStage == MeshDataStage::VSOut) { - if(m_Ctx.LogLoaded() && m_Ctx.CurPipelineState.IsTessellationEnabled()) + if(m_Ctx.LogLoaded() && m_Ctx.CurPipelineState().IsTessellationEnabled()) return false; return true; @@ -2365,7 +2365,7 @@ void BufferViewer::Reset() m_BBoxes.clear(); - CaptureContext *ctx = &m_Ctx; + ICaptureContext *ctx = &m_Ctx; // while a log is loaded, pass NULL into the widget if(!m_Ctx.LogLoaded()) @@ -2534,7 +2534,7 @@ void BufferViewer::camGuess_changed(double value) m_Config.aspect = 1.0f; // take a guess for the aspect ratio, for if the user hasn't overridden it - Viewport vp = m_Ctx.CurPipelineState.GetViewport(0); + Viewport vp = m_Ctx.CurPipelineState().GetViewport(0); m_Config.aspect = vp.width / vp.height; if(ui->aspectGuess->value() > 0.0) @@ -2761,20 +2761,15 @@ void BufferViewer::debugVertex() debugContext += tr(", Instance %1").arg(m_Config.curInstance); const ShaderReflection *shaderDetails = - m_Ctx.CurPipelineState.GetShaderReflection(ShaderStage::Pixel); + m_Ctx.CurPipelineState().GetShaderReflection(ShaderStage::Pixel); const ShaderBindpointMapping &bindMapping = - m_Ctx.CurPipelineState.GetBindpointMapping(ShaderStage::Pixel); + m_Ctx.CurPipelineState().GetBindpointMapping(ShaderStage::Pixel); // viewer takes ownership of the trace - ShaderViewer *s = ShaderViewer::debugShader(m_Ctx, &bindMapping, shaderDetails, - ShaderStage::Pixel, trace, debugContext, this); + IShaderViewer *s = m_Ctx.DebugShader(&bindMapping, shaderDetails, ShaderStage::Pixel, trace, + debugContext, this); - m_Ctx.setupDockWindow(s); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(s, ref); + m_Ctx.AddDockWindow(s->Widget(), DockReference::AddTo, this); }); }); } diff --git a/qrenderdoc/Windows/BufferViewer.h b/qrenderdoc/Windows/BufferViewer.h index 03fcab962..43f7531fd 100644 --- a/qrenderdoc/Windows/BufferViewer.h +++ b/qrenderdoc/Windows/BufferViewer.h @@ -52,23 +52,17 @@ struct BufferExport BufferExport(ExportFormat f) : format(f) {} }; -class BufferViewer : public QFrame, public ILogViewerForm +class BufferViewer : public QFrame, public IBufferViewer, public ILogViewerForm { Q_OBJECT public: - explicit BufferViewer(CaptureContext &ctx, bool meshview, QWidget *parent = 0); + explicit BufferViewer(ICaptureContext &ctx, bool meshview, QWidget *parent = 0); ~BufferViewer(); - void ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId id, const QString &format = ""); - void ViewTexture(uint32_t arrayIdx, uint32_t mip, ResourceId id, const QString &format = ""); - - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID); - - void ScrollToRow(int row, MeshDataStage stage = MeshDataStage::VSIn) + // IBufferViewer + QWidget *Widget() override { return this; } + void ScrollToRow(int row, MeshDataStage stage = MeshDataStage::VSIn) override { if(stage == MeshDataStage::VSOut) ScrollToRow(m_ModelVSOut, row); @@ -77,6 +71,16 @@ public: else ScrollToRow(m_ModelVSIn, row); } + void ViewBuffer(uint64_t byteOffset, uint64_t byteSize, ResourceId id, + const QString &format = "") override; + void ViewTexture(uint32_t arrayIdx, uint32_t mip, ResourceId id, + const QString &format = "") override; + + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override; private slots: // automatic slots @@ -114,7 +118,7 @@ private slots: private: Ui::BufferViewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; IReplayOutput *m_Output; diff --git a/qrenderdoc/Windows/ConstantBufferPreviewer.cpp b/qrenderdoc/Windows/ConstantBufferPreviewer.cpp index e62e01f40..edf65c385 100644 --- a/qrenderdoc/Windows/ConstantBufferPreviewer.cpp +++ b/qrenderdoc/Windows/ConstantBufferPreviewer.cpp @@ -28,7 +28,7 @@ QList ConstantBufferPreviewer::m_Previews; -ConstantBufferPreviewer::ConstantBufferPreviewer(CaptureContext &ctx, const ShaderStage stage, +ConstantBufferPreviewer::ConstantBufferPreviewer(ICaptureContext &ctx, const ShaderStage stage, uint32_t slot, uint32_t idx, QWidget *parent) : QFrame(parent), ui(new Ui::ConstantBufferPreviewer), m_Ctx(ctx) { @@ -94,11 +94,11 @@ void ConstantBufferPreviewer::OnEventChanged(uint32_t eventID) { uint64_t offs = 0; uint64_t size = 0; - m_Ctx.CurPipelineState.GetConstantBuffer(m_stage, m_slot, m_arrayIdx, m_cbuffer, offs, size); + m_Ctx.CurPipelineState().GetConstantBuffer(m_stage, m_slot, m_arrayIdx, m_cbuffer, offs, size); - m_shader = m_Ctx.CurPipelineState.GetShader(m_stage); - QString entryPoint = m_Ctx.CurPipelineState.GetShaderEntryPoint(m_stage); - const ShaderReflection *reflection = m_Ctx.CurPipelineState.GetShaderReflection(m_stage); + m_shader = m_Ctx.CurPipelineState().GetShader(m_stage); + QString entryPoint = m_Ctx.CurPipelineState().GetShaderEntryPoint(m_stage); + const ShaderReflection *reflection = m_Ctx.CurPipelineState().GetShaderReflection(m_stage); updateLabels(); @@ -218,7 +218,7 @@ void ConstantBufferPreviewer::updateLabels() needName = false; } - const ShaderReflection *reflection = m_Ctx.CurPipelineState.GetShaderReflection(m_stage); + const ShaderReflection *reflection = m_Ctx.CurPipelineState().GetShaderReflection(m_stage); if(reflection != NULL) { @@ -234,7 +234,7 @@ void ConstantBufferPreviewer::updateLabels() QString title = QString("%1 %2 %3").arg(ToQStr(m_stage, pipeType)).arg(IsD3D(pipeType) ? "CB" : "UBO").arg(m_slot); - if(m_Ctx.CurPipelineState.SupportsResourceArrays()) + if(m_Ctx.CurPipelineState().SupportsResourceArrays()) title += QString(" [%1]").arg(m_arrayIdx); ui->slotLabel->setText(title); diff --git a/qrenderdoc/Windows/ConstantBufferPreviewer.h b/qrenderdoc/Windows/ConstantBufferPreviewer.h index bc34fe0f6..c023f11ba 100644 --- a/qrenderdoc/Windows/ConstantBufferPreviewer.h +++ b/qrenderdoc/Windows/ConstantBufferPreviewer.h @@ -34,21 +34,24 @@ class ConstantBufferPreviewer; struct FormatElement; -class ConstantBufferPreviewer : public QFrame, public ILogViewerForm +class ConstantBufferPreviewer : public QFrame, public IConstantBufferPreviewer, public ILogViewerForm { Q_OBJECT public: - explicit ConstantBufferPreviewer(CaptureContext &ctx, const ShaderStage stage, uint32_t slot, + explicit ConstantBufferPreviewer(ICaptureContext &ctx, const ShaderStage stage, uint32_t slot, uint32_t idx, QWidget *parent = 0); ~ConstantBufferPreviewer(); static ConstantBufferPreviewer *has(ShaderStage stage, uint32_t slot, uint32_t idx); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID); + // IConstantBufferPreviewer + QWidget *Widget() override { return this; } + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override; private slots: // automatic slots @@ -60,7 +63,7 @@ private slots: private: Ui::ConstantBufferPreviewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; ResourceId m_cbuffer; ResourceId m_shader; diff --git a/qrenderdoc/Windows/DebugMessageView.cpp b/qrenderdoc/Windows/DebugMessageView.cpp index ecd580c5e..f0545b00a 100644 --- a/qrenderdoc/Windows/DebugMessageView.cpp +++ b/qrenderdoc/Windows/DebugMessageView.cpp @@ -32,7 +32,7 @@ static const int EIDRole = Qt::UserRole + 1; class DebugMessageItemModel : public QAbstractItemModel { public: - DebugMessageItemModel(CaptureContext &ctx, QObject *parent) + DebugMessageItemModel(ICaptureContext &ctx, QObject *parent) : QAbstractItemModel(parent), m_Ctx(ctx) { } @@ -54,7 +54,7 @@ public: QModelIndex parent(const QModelIndex &index) const override { return QModelIndex(); } int rowCount(const QModelIndex &parent = QModelIndex()) const override { - return m_Ctx.DebugMessages.count(); + return m_Ctx.DebugMessages().count(); } int columnCount(const QModelIndex &parent = QModelIndex()) const override { return 6; } Qt::ItemFlags flags(const QModelIndex &index) const override @@ -93,7 +93,7 @@ public: if(col >= 0 && col < columnCount() && row < rowCount()) { - const DebugMessage &msg = m_Ctx.DebugMessages[row]; + const DebugMessage &msg = m_Ctx.DebugMessages()[row]; switch(col) { @@ -109,20 +109,20 @@ public: } if(index.isValid() && role == EIDRole && index.row() >= 0 && - index.row() < m_Ctx.DebugMessages.count()) - return m_Ctx.DebugMessages[index.row()].eventID; + index.row() < m_Ctx.DebugMessages().count()) + return m_Ctx.DebugMessages()[index.row()].eventID; return QVariant(); } private: - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; }; class DebugMessageFilterModel : public QSortFilterProxyModel { public: - DebugMessageFilterModel(CaptureContext &ctx, QObject *parent) + DebugMessageFilterModel(ICaptureContext &ctx, QObject *parent) : QSortFilterProxyModel(parent), m_Ctx(ctx) { } @@ -164,7 +164,7 @@ protected: bool isVisibleRow(int sourceRow) const { - const DebugMessage &msg = m_Ctx.DebugMessages[sourceRow]; + const DebugMessage &msg = m_Ctx.DebugMessages()[sourceRow]; if(m_HiddenSources.contains(msg.source)) return false; @@ -183,8 +183,8 @@ protected: bool lessThan(const QModelIndex &left, const QModelIndex &right) const override { - const DebugMessage &leftMsg = m_Ctx.DebugMessages[left.row()]; - const DebugMessage &rightMsg = m_Ctx.DebugMessages[right.row()]; + const DebugMessage &leftMsg = m_Ctx.DebugMessages()[left.row()]; + const DebugMessage &rightMsg = m_Ctx.DebugMessages()[right.row()]; if(leftMsg.eventID < rightMsg.eventID) return true; @@ -205,10 +205,10 @@ protected: } private: - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; }; -DebugMessageView::DebugMessageView(CaptureContext &ctx, QWidget *parent) +DebugMessageView::DebugMessageView(ICaptureContext &ctx, QWidget *parent) : QFrame(parent), ui(new Ui::DebugMessageView), m_Ctx(ctx) { ui->setupUi(this); @@ -254,7 +254,7 @@ DebugMessageView::DebugMessageView(CaptureContext &ctx, QWidget *parent) DebugMessageView::~DebugMessageView() { - m_Ctx.windowClosed(this); + m_Ctx.BuiltinWindowClosed(this); m_Ctx.RemoveLogViewer(this); delete ui; @@ -278,8 +278,8 @@ void DebugMessageView::RefreshMessageList() ui->messages->resizeColumnsToContents(); - if(m_Ctx.UnreadMessageCount > 0) - setWindowTitle(tr("(%1) Errors and Warnings").arg(m_Ctx.UnreadMessageCount)); + if(m_Ctx.UnreadMessageCount() > 0) + setWindowTitle(tr("(%1) Errors and Warnings").arg(m_Ctx.UnreadMessageCount())); else setWindowTitle(tr("Errors and Warnings")); } @@ -348,7 +348,7 @@ void DebugMessageView::messages_contextMenu(const QPoint &pos) { index = m_FilterModel->mapToSource(index); - const DebugMessage &msg = m_Ctx.DebugMessages[index.row()]; + const DebugMessage &msg = m_Ctx.DebugMessages()[index.row()]; QString hide = tr("Hide"); QString show = tr("Show"); @@ -375,9 +375,9 @@ void DebugMessageView::messages_contextMenu(const QPoint &pos) void DebugMessageView::paintEvent(QPaintEvent *e) { - if(m_Ctx.UnreadMessageCount > 0) + if(m_Ctx.UnreadMessageCount() > 0) { - m_Ctx.UnreadMessageCount = 0; + m_Ctx.MarkMessagesRead(); RefreshMessageList(); } diff --git a/qrenderdoc/Windows/DebugMessageView.h b/qrenderdoc/Windows/DebugMessageView.h index 306b1069e..95a4c05d3 100644 --- a/qrenderdoc/Windows/DebugMessageView.h +++ b/qrenderdoc/Windows/DebugMessageView.h @@ -37,18 +37,21 @@ class QMenu; class DebugMessageItemModel; class DebugMessageFilterModel; -class DebugMessageView : public QFrame, public ILogViewerForm +class DebugMessageView : public QFrame, public IDebugMessageView, public ILogViewerForm { Q_OBJECT public: - explicit DebugMessageView(CaptureContext &ctx, QWidget *parent = 0); + explicit DebugMessageView(ICaptureContext &ctx, QWidget *parent = 0); ~DebugMessageView(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID) {} + // IDebugMessageView + QWidget *Widget() override { return this; } + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override {} void RefreshMessageList(); private slots: @@ -60,9 +63,9 @@ private slots: void messages_toggled(); private: - void paintEvent(QPaintEvent *e); + void paintEvent(QPaintEvent *e) override; Ui::DebugMessageView *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; QVector m_Messages; DebugMessageItemModel *m_ItemModel; diff --git a/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp b/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp index 8ef802279..8fff3514c 100644 --- a/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/CaptureDialog.cpp @@ -39,79 +39,7 @@ Q_DECLARE_METATYPE(CaptureSettings); -CaptureSettings::CaptureSettings() -{ - Inject = false; - AutoStart = false; - RENDERDOC_GetDefaultCaptureOptions(&Options); -} - -QVariantMap CaptureSettings::toJSON() const -{ - QVariantMap ret; - - ret["AutoStart"] = AutoStart; - - ret["Executable"] = Executable; - ret["WorkingDir"] = WorkingDir; - ret["CmdLine"] = CmdLine; - - QVariantList env; - for(int i = 0; i < Environment.size(); i++) - env.push_back(Environment[i].toJSON()); - ret["Environment"] = env; - - QVariantMap opts; - opts["AllowVSync"] = Options.AllowVSync; - opts["AllowFullscreen"] = Options.AllowFullscreen; - opts["APIValidation"] = Options.APIValidation; - opts["CaptureCallstacks"] = Options.CaptureCallstacks; - opts["CaptureCallstacksOnlyDraws"] = Options.CaptureCallstacksOnlyDraws; - opts["DelayForDebugger"] = Options.DelayForDebugger; - opts["VerifyMapWrites"] = Options.VerifyMapWrites; - opts["HookIntoChildren"] = Options.HookIntoChildren; - opts["RefAllResources"] = Options.RefAllResources; - opts["SaveAllInitials"] = Options.SaveAllInitials; - opts["CaptureAllCmdLists"] = Options.CaptureAllCmdLists; - opts["DebugOutputMute"] = Options.DebugOutputMute; - ret["Options"] = opts; - - return ret; -} - -void CaptureSettings::fromJSON(const QVariantMap &data) -{ - AutoStart = data["AutoStart"].toBool(); - - Executable = data["Executable"].toString(); - WorkingDir = data["WorkingDir"].toString(); - CmdLine = data["CmdLine"].toString(); - - QVariantList env = data["Environment"].toList(); - for(int i = 0; i < env.size(); i++) - { - EnvironmentModification e; - e.fromJSON(env[i].value()); - Environment.push_back(e); - } - - QVariantMap opts = data["Options"].toMap(); - - Options.AllowVSync = opts["AllowVSync"].toBool(); - Options.AllowFullscreen = opts["AllowFullscreen"].toBool(); - Options.APIValidation = opts["APIValidation"].toBool(); - Options.CaptureCallstacks = opts["CaptureCallstacks"].toBool(); - Options.CaptureCallstacksOnlyDraws = opts["CaptureCallstacksOnlyDraws"].toBool(); - Options.DelayForDebugger = opts["DelayForDebugger"].toUInt(); - Options.VerifyMapWrites = opts["VerifyMapWrites"].toBool(); - Options.HookIntoChildren = opts["HookIntoChildren"].toBool(); - Options.RefAllResources = opts["RefAllResources"].toBool(); - Options.SaveAllInitials = opts["SaveAllInitials"].toBool(); - Options.CaptureAllCmdLists = opts["CaptureAllCmdLists"].toBool(); - Options.DebugOutputMute = opts["DebugOutputMute"].toBool(); -} - -CaptureDialog::CaptureDialog(CaptureContext &ctx, OnCaptureMethod captureCallback, +CaptureDialog::CaptureDialog(ICaptureContext &ctx, OnCaptureMethod captureCallback, OnInjectMethod injectCallback, QWidget *parent) : QFrame(parent), ui(new Ui::CaptureDialog), m_Ctx(ctx) { @@ -163,26 +91,26 @@ CaptureDialog::CaptureDialog(CaptureContext &ctx, OnCaptureMethod captureCallbac m_CaptureCallback = captureCallback; m_InjectCallback = injectCallback; - setSettings(CaptureSettings()); + SetSettings(CaptureSettings()); - updateGlobalHook(); + UpdateGlobalHook(); } CaptureDialog::~CaptureDialog() { - m_Ctx.windowClosed(this); + m_Ctx.BuiltinWindowClosed(this); if(ui->toggleGlobal->isChecked()) { ui->toggleGlobal->setChecked(false); - updateGlobalHook(); + UpdateGlobalHook(); } delete ui; } -void CaptureDialog::setInjectMode(bool inject) +void CaptureDialog::SetInjectMode(bool inject) { m_Inject = inject; @@ -208,7 +136,7 @@ void CaptureDialog::setInjectMode(bool inject) QSizePolicy::Expanding); ui->verticalLayout->invalidate(); - ui->globalGroup->setVisible(m_Ctx.Config.AllowGlobalHook); + ui->globalGroup->setVisible(m_Ctx.Config().AllowGlobalHook); ui->launch->setText("Launch"); this->setWindowTitle("Capture Executable"); @@ -259,7 +187,7 @@ void CaptureDialog::on_exePath_textChanged(const QString &text) { QString path = dir.absolutePath(); - if(!m_Ctx.Renderer().remote()) + if(!m_Ctx.Renderer().CurrentRemote()) path = QDir::toNativeSeparators(path); // match the path separators from the path @@ -275,7 +203,7 @@ void CaptureDialog::on_exePath_textChanged(const QString &text) ui->workDirPath->setPlaceholderText(""); } - updateGlobalHook(); + UpdateGlobalHook(); } void CaptureDialog::on_vulkanLayerWarn_clicked() @@ -438,16 +366,16 @@ void CaptureDialog::on_exePathBrowse_clicked() { initDir = dir.absolutePath(); } - else if(m_Ctx.Config.LastCapturePath != "") + else if(m_Ctx.Config().LastCapturePath != "") { - initDir = m_Ctx.Config.LastCapturePath; - if(m_Ctx.Config.LastCaptureExe != "") - file = m_Ctx.Config.LastCaptureExe; + initDir = m_Ctx.Config().LastCapturePath; + if(m_Ctx.Config().LastCaptureExe != "") + file = m_Ctx.Config().LastCaptureExe; } QString filename; - if(m_Ctx.Renderer().remote()) + if(m_Ctx.Renderer().CurrentRemote()) { VirtualFileDialog vfd(m_Ctx, this); RDDialog::show(&vfd); @@ -459,7 +387,7 @@ void CaptureDialog::on_exePathBrowse_clicked() } if(filename != "") - setExecutableFilename(filename); + SetExecutableFilename(filename); } void CaptureDialog::on_workDirBrowse_clicked() @@ -475,13 +403,13 @@ void CaptureDialog::on_workDirBrowse_clicked() QDir dir = QFileInfo(ui->exePath->text()).dir(); if(dir.exists()) initDir = dir.absolutePath(); - else if(m_Ctx.Config.LastCapturePath != "") - initDir = m_Ctx.Config.LastCapturePath; + else if(m_Ctx.Config().LastCapturePath != "") + initDir = m_Ctx.Config().LastCapturePath; } QString dir; - if(m_Ctx.Renderer().remote()) + if(m_Ctx.Renderer().CurrentRemote()) { VirtualFileDialog vfd(m_Ctx, this); vfd.setDirBrowse(); @@ -507,7 +435,7 @@ void CaptureDialog::on_envVarEdit_clicked() int res = RDDialog::show(&envEditor); if(res) - setEnvironmentModifications(envEditor.modifications()); + SetEnvironmentModifications(envEditor.modifications()); } void CaptureDialog::on_toggleGlobal_clicked() @@ -516,7 +444,7 @@ void CaptureDialog::on_toggleGlobal_clicked() { ui->toggleGlobal->setChecked(!ui->toggleGlobal->isChecked()); - updateGlobalHook(); + UpdateGlobalHook(); } } @@ -530,8 +458,8 @@ void CaptureDialog::on_saveSettings_clicked() QDir dirinfo = QFileInfo(filename).dir(); if(dirinfo.exists()) { - saveSettings(filename); - PersistantConfig::AddRecentFile(m_Ctx.Config.RecentCaptureSettings, filename, 10); + SaveSettings(filename); + AddRecentFile(m_Ctx.Config().RecentCaptureSettings, filename, 10); } } } @@ -543,14 +471,14 @@ void CaptureDialog::on_loadSettings_clicked() if(filename != "" && QFileInfo::exists(filename)) { - loadSettings(filename); - PersistantConfig::AddRecentFile(m_Ctx.Config.RecentCaptureSettings, filename, 10); + LoadSettings(filename); + AddRecentFile(m_Ctx.Config().RecentCaptureSettings, filename, 10); } } void CaptureDialog::on_launch_clicked() { - triggerCapture(); + TriggerCapture(); } void CaptureDialog::on_close_clicked() @@ -558,15 +486,15 @@ void CaptureDialog::on_close_clicked() ToolWindowManager::closeToolWindow(this); } -void CaptureDialog::setSettings(CaptureSettings settings) +void CaptureDialog::SetSettings(CaptureSettings settings) { - setInjectMode(settings.Inject); + SetInjectMode(settings.Inject); ui->exePath->setText(settings.Executable); ui->workDirPath->setText(settings.WorkingDir); ui->cmdline->setText(settings.CmdLine); - setEnvironmentModifications(settings.Environment); + SetEnvironmentModifications(settings.Environment); ui->AllowFullscreen->setChecked(settings.Options.AllowFullscreen); ui->AllowVSync->setChecked(settings.Options.AllowVSync); @@ -582,15 +510,15 @@ void CaptureDialog::setSettings(CaptureSettings settings) if(settings.AutoStart) { - triggerCapture(); + TriggerCapture(); } } -CaptureSettings CaptureDialog::settings() +CaptureSettings CaptureDialog::Settings() { CaptureSettings ret; - ret.Inject = injectMode(); + ret.Inject = IsInjectMode(); ret.AutoStart = ui->AutoStart->isChecked(); @@ -615,13 +543,13 @@ CaptureSettings CaptureDialog::settings() return ret; } -void CaptureDialog::saveSettings(QString filename) +void CaptureDialog::SaveSettings(QString filename) { QFile f(filename); if(f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { QVariantMap values; - values["settings"] = settings().toJSON(); + values["settings"] = (QVariant)Settings(); SaveToJSON(values, f, JSON_ID, JSON_VER); } else @@ -650,21 +578,33 @@ void CaptureDialog::fillProcessList() } } -void CaptureDialog::setExecutableFilename(QString filename) +void CaptureDialog::SetExecutableFilename(const QString &filename) { - if(!m_Ctx.Renderer().remote()) - filename = QDir::toNativeSeparators(QFileInfo(filename).absoluteFilePath()); + QString fn = filename; - ui->exePath->setText(filename); + if(!m_Ctx.Renderer().CurrentRemote()) + fn = QDir::toNativeSeparators(QFileInfo(fn).absoluteFilePath()); - if(!m_Ctx.Renderer().remote()) + ui->exePath->setText(fn); + + if(!m_Ctx.Renderer().CurrentRemote()) { - m_Ctx.Config.LastCapturePath = QFileInfo(filename).absolutePath(); - m_Ctx.Config.LastCaptureExe = QFileInfo(filename).completeBaseName(); + m_Ctx.Config().LastCapturePath = QFileInfo(fn).absolutePath(); + m_Ctx.Config().LastCaptureExe = QFileInfo(fn).completeBaseName(); } } -void CaptureDialog::loadSettings(QString filename) +void CaptureDialog::SetWorkingDirectory(const QString &dir) +{ + ui->workDirPath->setText(dir); +} + +void CaptureDialog::SetCommandLine(const QString &cmd) +{ + ui->cmdline->setText(cmd); +} + +void CaptureDialog::LoadSettings(QString filename) { QFile f(filename); if(f.open(QIODevice::ReadOnly | QIODevice::Text)) @@ -675,9 +615,8 @@ void CaptureDialog::loadSettings(QString filename) if(success) { - CaptureSettings settings; - settings.fromJSON(values["settings"].value()); - setSettings(settings); + CaptureSettings settings(values["settings"]); + SetSettings(settings); } else { @@ -691,9 +630,9 @@ void CaptureDialog::loadSettings(QString filename) } } -void CaptureDialog::updateGlobalHook() +void CaptureDialog::UpdateGlobalHook() { - ui->globalGroup->setVisible(!injectMode() && m_Ctx.Config.AllowGlobalHook); + ui->globalGroup->setVisible(!IsInjectMode() && m_Ctx.Config().AllowGlobalHook); if(ui->exePath->text().length() >= 4) { @@ -712,7 +651,7 @@ void CaptureDialog::updateGlobalHook() } } -void CaptureDialog::setEnvironmentModifications(const QList &modifications) +void CaptureDialog::SetEnvironmentModifications(const QList &modifications) { m_EnvModifications = modifications; @@ -729,9 +668,9 @@ void CaptureDialog::setEnvironmentModifications(const QListenvVar->setText(envModText); } -void CaptureDialog::triggerCapture() +void CaptureDialog::TriggerCapture() { - if(injectMode()) + if(IsInjectMode()) { QModelIndexList sel = ui->processList->selectionModel()->selectedRows(); if(sel.size() == 1) @@ -745,7 +684,7 @@ void CaptureDialog::triggerCapture() QString name = m_ProcessModel->data(m_ProcessModel->index(item.row(), 0)).toString(); uint32_t PID = m_ProcessModel->data(m_ProcessModel->index(item.row(), 1)).toUInt(); - m_InjectCallback(PID, settings().Environment, name, settings().Options, + m_InjectCallback(PID, Settings().Environment, name, Settings().Options, [this](LiveCapture *live) { if(ui->queueFrameCap->isChecked()) live->QueueCapture((int)ui->queuedFrame->value()); @@ -757,7 +696,7 @@ void CaptureDialog::triggerCapture() QString exe = ui->exePath->text(); // for non-remote captures, check the executable locally - if(!m_Ctx.Renderer().remote()) + if(!m_Ctx.Renderer().CurrentRemote()) { if(!QFileInfo::exists(exe)) { @@ -770,7 +709,7 @@ void CaptureDialog::triggerCapture() QString workingDir = ""; // for non-remote captures, check the directory locally - if(m_Ctx.Renderer().remote()) + if(m_Ctx.Renderer().CurrentRemote()) { workingDir = ui->workDirPath->text(); } @@ -782,7 +721,7 @@ void CaptureDialog::triggerCapture() QString cmdLine = ui->cmdline->text(); - m_CaptureCallback(exe, workingDir, cmdLine, settings().Environment, settings().Options, + m_CaptureCallback(exe, workingDir, cmdLine, Settings().Environment, Settings().Options, [this](LiveCapture *live) { if(ui->queueFrameCap->isChecked()) live->QueueCapture((int)ui->queuedFrame->value()); diff --git a/qrenderdoc/Windows/Dialogs/CaptureDialog.h b/qrenderdoc/Windows/Dialogs/CaptureDialog.h index 0470b83dc..ceab6df1a 100644 --- a/qrenderdoc/Windows/Dialogs/CaptureDialog.h +++ b/qrenderdoc/Windows/Dialogs/CaptureDialog.h @@ -36,23 +36,7 @@ class CaptureDialog; class QStandardItemModel; class LiveCapture; -struct CaptureSettings -{ - CaptureSettings(); - - CaptureOptions Options; - bool Inject; - bool AutoStart; - QString Executable; - QString WorkingDir; - QString CmdLine; - QList Environment; - - QVariantMap toJSON() const; - void fromJSON(const QVariantMap &data); -}; - -class CaptureDialog : public QFrame +class CaptureDialog : public QFrame, public ICaptureDialog { Q_OBJECT @@ -65,17 +49,28 @@ public: CaptureOptions opts, std::function callback)> OnInjectMethod; - explicit CaptureDialog(CaptureContext &ctx, OnCaptureMethod captureCallback, + explicit CaptureDialog(ICaptureContext &ctx, OnCaptureMethod captureCallback, OnInjectMethod injectCallback, QWidget *parent = 0); ~CaptureDialog(); - bool injectMode() { return m_Inject; } - void setInjectMode(bool inject); + // ICaptureDialog + QWidget *Widget() override { return this; } + bool IsInjectMode() override { return m_Inject; } + void SetInjectMode(bool inject) override; - void setExecutableFilename(QString filename); - void loadSettings(QString filename); + void SetExecutableFilename(const QString &filename) override; + void SetWorkingDirectory(const QString &dir) override; + void SetCommandLine(const QString &cmd) override; + void SetEnvironmentModifications(const QList &modifications) override; - void updateGlobalHook(); + void SetSettings(CaptureSettings settings) override; + CaptureSettings Settings() override; + + void TriggerCapture() override; + + void LoadSettings(QString filename) override; + void SaveSettings(QString filename) override; + void UpdateGlobalHook() override; private slots: // automatic slots @@ -101,21 +96,13 @@ private slots: private: Ui::CaptureDialog *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; QStandardItemModel *m_ProcessModel; OnCaptureMethod m_CaptureCallback; OnInjectMethod m_InjectCallback; - void setEnvironmentModifications(const QList &modifications); - void triggerCapture(); - - void setSettings(CaptureSettings settings); - CaptureSettings settings(); - - void saveSettings(QString filename); - QList m_EnvModifications; bool m_Inject; void fillProcessList(); diff --git a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp index c2bc029e1..0b4afd909 100644 --- a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp +++ b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp @@ -41,7 +41,7 @@ static const int PIDRole = Qt::UserRole + 1; static const int IdentRole = Qt::UserRole + 2; static const int LogPtrRole = Qt::UserRole + 3; -LiveCapture::LiveCapture(CaptureContext &ctx, const QString &hostname, uint32_t ident, +LiveCapture::LiveCapture(ICaptureContext &ctx, const QString &hostname, uint32_t ident, MainWindow *main, QWidget *parent) : QFrame(parent), ui(new Ui::LiveCapture), @@ -564,9 +564,9 @@ bool LiveCapture::checkAllowClose() // we either have to save or delete the log. Make sure that if it's remote that we are able // to by having an active connection or replay context on that host. if(suppressRemoteWarning == false && (!m_Connection || !m_Connection->Connected()) && - !log->local && - (!m_Ctx.Renderer().remote() || m_Ctx.Renderer().remote()->Hostname != m_Hostname || - !m_Ctx.Renderer().remote()->Connected)) + !log->local && (!m_Ctx.Renderer().CurrentRemote() || + m_Ctx.Renderer().CurrentRemote()->Hostname != m_Hostname || + !m_Ctx.Renderer().CurrentRemote()->Connected)) { QMessageBox::StandardButton res2 = RDDialog::question( this, tr("No active replay context"), @@ -611,8 +611,9 @@ void LiveCapture::openCapture(CaptureLog *log) { log->opened = true; - if(!log->local && (!m_Ctx.Renderer().remote() || m_Ctx.Renderer().remote()->Hostname != m_Hostname || - !m_Ctx.Renderer().remote()->Connected)) + if(!log->local && (!m_Ctx.Renderer().CurrentRemote() || + m_Ctx.Renderer().CurrentRemote()->Hostname != m_Hostname || + !m_Ctx.Renderer().CurrentRemote()->Connected)) { RDDialog::critical( this, tr("No active replay context"), @@ -665,8 +666,9 @@ bool LiveCapture::saveCapture(CaptureLog *log) } else { - if(!m_Ctx.Renderer().remote() || m_Ctx.Renderer().remote()->Hostname != m_Hostname || - !m_Ctx.Renderer().remote()->Connected) + if(!m_Ctx.Renderer().CurrentRemote() || + m_Ctx.Renderer().CurrentRemote()->Hostname != m_Hostname || + !m_Ctx.Renderer().CurrentRemote()->Connected) { RDDialog::critical(this, tr("No active replay context"), tr("This capture is on remote host %1 and there is no active replay " @@ -691,7 +693,7 @@ bool LiveCapture::saveCapture(CaptureLog *log) log->saved = true; log->path = path; - PersistantConfig::AddRecentFile(m_Ctx.Config.RecentLogFiles, path, 10); + AddRecentFile(m_Ctx.Config().RecentLogFiles, path, 10); m_Main->PopulateRecentFiles(); return true; } @@ -875,8 +877,9 @@ void LiveCapture::connectionClosed() // to this machine as a remote context if(!log->local) { - if(!m_Ctx.Renderer().remote() || m_Ctx.Renderer().remote()->Hostname != m_Hostname || - !m_Ctx.Renderer().remote()->Connected) + if(!m_Ctx.Renderer().CurrentRemote() || + m_Ctx.Renderer().CurrentRemote()->Hostname != m_Hostname || + !m_Ctx.Renderer().CurrentRemote()->Connected) return; } diff --git a/qrenderdoc/Windows/Dialogs/LiveCapture.h b/qrenderdoc/Windows/Dialogs/LiveCapture.h index 3efb745b4..cdd3970ed 100644 --- a/qrenderdoc/Windows/Dialogs/LiveCapture.h +++ b/qrenderdoc/Windows/Dialogs/LiveCapture.h @@ -47,7 +47,7 @@ class LiveCapture : public QFrame Q_OBJECT public: - explicit LiveCapture(CaptureContext &ctx, const QString &runCommand, uint32_t ident, + explicit LiveCapture(ICaptureContext &ctx, const QString &runCommand, uint32_t ident, MainWindow *main, QWidget *parent = 0); ~LiveCapture(); @@ -129,7 +129,7 @@ private: void deleteCaptureUnprompted(QListWidgetItem *item); Ui::LiveCapture *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; QString m_Hostname; uint32_t m_RemoteIdent; MainWindow *m_Main; diff --git a/qrenderdoc/Windows/Dialogs/RemoteManager.cpp b/qrenderdoc/Windows/Dialogs/RemoteManager.cpp index 0f3e9a243..12140cde7 100644 --- a/qrenderdoc/Windows/Dialogs/RemoteManager.cpp +++ b/qrenderdoc/Windows/Dialogs/RemoteManager.cpp @@ -25,7 +25,7 @@ #include "RemoteManager.h" #include #include "3rdparty/flowlayout/FlowLayout.h" -#include "Code/RemoteHost.h" +#include "Code/Interface/QRDInterface.h" #include "Code/Resources.h" #include "Windows/Dialogs/LiveCapture.h" #include "Windows/MainWindow.h" @@ -81,7 +81,7 @@ static void setItalic(QTreeWidgetItem *node, bool italic) node->setFont(1, f); } -RemoteManager::RemoteManager(CaptureContext &ctx, MainWindow *main) +RemoteManager::RemoteManager(ICaptureContext &ctx, MainWindow *main) : QDialog(NULL), ui(new Ui::RemoteManager), m_Ctx(ctx), m_Main(main) { ui->setupUi(this); @@ -109,9 +109,9 @@ RemoteManager::RemoteManager(CaptureContext &ctx, MainWindow *main) vertical->addWidget(lookupsProgressFlow); vertical->addWidget(ui->bottomLayout->parentWidget()); - m_Ctx.Config.AddAndroidHosts(); + m_Ctx.Config().AddAndroidHosts(); - for(RemoteHost *h : m_Ctx.Config.RemoteHosts) + for(RemoteHost *h : m_Ctx.Config().RemoteHosts) addHost(h); on_hosts_itemClicked(ui->hosts->topLevelItem(0), 0); @@ -356,9 +356,9 @@ void RemoteManager::addNewHost() { bool found = false; - for(int i = 0; i < m_Ctx.Config.RemoteHosts.count(); i++) + for(int i = 0; i < m_Ctx.Config().RemoteHosts.count(); i++) { - if(m_Ctx.Config.RemoteHosts[i]->Hostname.compare(host, Qt::CaseInsensitive) == 0) + if(m_Ctx.Config().RemoteHosts[i]->Hostname.compare(host, Qt::CaseInsensitive) == 0) { found = true; break; @@ -371,8 +371,8 @@ void RemoteManager::addNewHost() h->Hostname = host; h->RunCommand = ui->runCommand->text().trimmed(); - m_Ctx.Config.RemoteHosts.push_back(h); - m_Ctx.Config.Save(); + m_Ctx.Config().RemoteHosts.push_back(h); + m_Ctx.Config().Save(); addHost(h); } @@ -391,7 +391,7 @@ void RemoteManager::setRunCommand() if(h) { h->RunCommand = ui->runCommand->text().trimmed(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } } @@ -661,9 +661,9 @@ void RemoteManager::on_deleteHost_clicked() if(res == QMessageBox::Yes) { - int idx = m_Ctx.Config.RemoteHosts.indexOf(host); - delete m_Ctx.Config.RemoteHosts.takeAt(idx); - m_Ctx.Config.Save(); + int idx = m_Ctx.Config().RemoteHosts.indexOf(host); + delete m_Ctx.Config().RemoteHosts.takeAt(idx); + m_Ctx.Config().Save(); deleteChildren(item); diff --git a/qrenderdoc/Windows/Dialogs/RemoteManager.h b/qrenderdoc/Windows/Dialogs/RemoteManager.h index 16d6b7f17..e4b9a74d1 100644 --- a/qrenderdoc/Windows/Dialogs/RemoteManager.h +++ b/qrenderdoc/Windows/Dialogs/RemoteManager.h @@ -33,7 +33,7 @@ class RemoteManager; } class QTreeWidgetItem; -class CaptureContext; +struct ICaptureContext; class MainWindow; class RemoteHost; @@ -42,7 +42,7 @@ class RemoteManager : public QDialog Q_OBJECT public: - explicit RemoteManager(CaptureContext &ctx, MainWindow *main); + explicit RemoteManager(ICaptureContext &ctx, MainWindow *main); ~RemoteManager(); private slots: @@ -61,7 +61,7 @@ private slots: private: Ui::RemoteManager *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; MainWindow *m_Main; QWidget *lookupsProgressFlow; diff --git a/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp b/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp index b2023c71d..80259811c 100644 --- a/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp @@ -24,13 +24,13 @@ #include "SettingsDialog.h" #include "Code/CaptureContext.h" -#include "Code/PersistantConfig.h" +#include "Code/Interface/QRDInterface.h" #include "Code/QRDUtils.h" #include "Windows/Dialogs/OrderedListEditor.h" #include "CaptureDialog.h" #include "ui_SettingsDialog.h" -SettingsDialog::SettingsDialog(CaptureContext &ctx, QWidget *parent) +SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent) : QDialog(parent), ui(new Ui::SettingsDialog), m_Ctx(ctx) { ui->setupUi(this); @@ -44,49 +44,49 @@ SettingsDialog::SettingsDialog(CaptureContext &ctx, QWidget *parent) m_Init = true; - for(int i = 0; i < (int)PersistantConfig::TimeUnit::Count; i++) + for(int i = 0; i < (int)TimeUnit::Count; i++) { - ui->EventBrowser_TimeUnit->addItem(PersistantConfig::UnitPrefix((PersistantConfig::TimeUnit)i)); + ui->EventBrowser_TimeUnit->addItem(UnitPrefix((TimeUnit)i)); } ui->pages->clearSelection(); ui->pages->setItemSelected(ui->pages->item(0), true); ui->tabWidget->setCurrentIndex(0); - ui->saveDirectory->setText(m_Ctx.Config.DefaultCaptureSaveDirectory); - ui->tempDirectory->setText(m_Ctx.Config.TemporaryCaptureDirectory); + ui->saveDirectory->setText(m_Ctx.Config().DefaultCaptureSaveDirectory); + ui->tempDirectory->setText(m_Ctx.Config().TemporaryCaptureDirectory); - if(!m_Ctx.Config.SPIRVDisassemblers.isEmpty()) + if(!m_Ctx.Config().SPIRVDisassemblers.isEmpty()) { - ui->externalDisassemblerArgs->setText(m_Ctx.Config.SPIRVDisassemblers[0].args); - ui->externalDisassemblePath->setText(m_Ctx.Config.SPIRVDisassemblers[0].executable); + ui->externalDisassemblerArgs->setText(m_Ctx.Config().SPIRVDisassemblers[0].args); + ui->externalDisassemblePath->setText(m_Ctx.Config().SPIRVDisassemblers[0].executable); } - ui->Android_AdbExecutablePath->setText(m_Ctx.Config.Android_AdbExecutablePath); - ui->Android_MaxConnectTimeout->setValue(m_Ctx.Config.Android_MaxConnectTimeout); + ui->Android_AdbExecutablePath->setText(m_Ctx.Config().Android_AdbExecutablePath); + ui->Android_MaxConnectTimeout->setValue(m_Ctx.Config().Android_MaxConnectTimeout); - ui->TextureViewer_ResetRange->setChecked(m_Ctx.Config.TextureViewer_ResetRange); - ui->TextureViewer_PerTexSettings->setChecked(m_Ctx.Config.TextureViewer_PerTexSettings); - ui->ShaderViewer_FriendlyNaming->setChecked(m_Ctx.Config.ShaderViewer_FriendlyNaming); - ui->CheckUpdate_AllowChecks->setChecked(m_Ctx.Config.CheckUpdate_AllowChecks); - ui->Font_PreferMonospaced->setChecked(m_Ctx.Config.Font_PreferMonospaced); + ui->TextureViewer_ResetRange->setChecked(m_Ctx.Config().TextureViewer_ResetRange); + ui->TextureViewer_PerTexSettings->setChecked(m_Ctx.Config().TextureViewer_PerTexSettings); + ui->ShaderViewer_FriendlyNaming->setChecked(m_Ctx.Config().ShaderViewer_FriendlyNaming); + ui->CheckUpdate_AllowChecks->setChecked(m_Ctx.Config().CheckUpdate_AllowChecks); + ui->Font_PreferMonospaced->setChecked(m_Ctx.Config().Font_PreferMonospaced); - ui->AlwaysReplayLocally->setChecked(m_Ctx.Config.AlwaysReplayLocally); + ui->AlwaysReplayLocally->setChecked(m_Ctx.Config().AlwaysReplayLocally); - ui->AllowGlobalHook->setChecked(m_Ctx.Config.AllowGlobalHook); + ui->AllowGlobalHook->setChecked(m_Ctx.Config().AllowGlobalHook); - ui->EventBrowser_TimeUnit->setCurrentIndex((int)m_Ctx.Config.EventBrowser_TimeUnit); - ui->EventBrowser_HideEmpty->setChecked(m_Ctx.Config.EventBrowser_HideEmpty); - ui->EventBrowser_HideAPICalls->setChecked(m_Ctx.Config.EventBrowser_HideAPICalls); - ui->EventBrowser_ApplyColors->setChecked(m_Ctx.Config.EventBrowser_ApplyColors); - ui->EventBrowser_ColorEventRow->setChecked(m_Ctx.Config.EventBrowser_ColorEventRow); + ui->EventBrowser_TimeUnit->setCurrentIndex((int)m_Ctx.Config().EventBrowser_TimeUnit); + ui->EventBrowser_HideEmpty->setChecked(m_Ctx.Config().EventBrowser_HideEmpty); + ui->EventBrowser_HideAPICalls->setChecked(m_Ctx.Config().EventBrowser_HideAPICalls); + ui->EventBrowser_ApplyColors->setChecked(m_Ctx.Config().EventBrowser_ApplyColors); + ui->EventBrowser_ColorEventRow->setChecked(m_Ctx.Config().EventBrowser_ColorEventRow); // disable sub-checkbox ui->EventBrowser_ColorEventRow->setEnabled(ui->EventBrowser_ApplyColors->isChecked()); - ui->Formatter_MinFigures->setValue(m_Ctx.Config.Formatter_MinFigures); - ui->Formatter_MaxFigures->setValue(m_Ctx.Config.Formatter_MaxFigures); - ui->Formatter_NegExp->setValue(m_Ctx.Config.Formatter_NegExp); - ui->Formatter_PosExp->setValue(m_Ctx.Config.Formatter_PosExp); + ui->Formatter_MinFigures->setValue(m_Ctx.Config().Formatter_MinFigures); + ui->Formatter_MaxFigures->setValue(m_Ctx.Config().Formatter_MaxFigures); + ui->Formatter_NegExp->setValue(m_Ctx.Config().Formatter_NegExp); + ui->Formatter_PosExp->setValue(m_Ctx.Config().Formatter_PosExp); m_Init = false; @@ -128,76 +128,76 @@ void SettingsDialog::on_okButton_accepted() // general void SettingsDialog::formatter_valueChanged(int val) { - m_Ctx.Config.Formatter_MinFigures = ui->Formatter_MinFigures->value(); - m_Ctx.Config.Formatter_MaxFigures = ui->Formatter_MaxFigures->value(); - m_Ctx.Config.Formatter_NegExp = ui->Formatter_NegExp->value(); - m_Ctx.Config.Formatter_PosExp = ui->Formatter_PosExp->value(); + m_Ctx.Config().Formatter_MinFigures = ui->Formatter_MinFigures->value(); + m_Ctx.Config().Formatter_MaxFigures = ui->Formatter_MaxFigures->value(); + m_Ctx.Config().Formatter_NegExp = ui->Formatter_NegExp->value(); + m_Ctx.Config().Formatter_PosExp = ui->Formatter_PosExp->value(); - m_Ctx.Config.SetupFormatting(); + m_Ctx.Config().SetupFormatting(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_tempDirectory_textEdited(const QString &dir) { if(QDir(dir).exists()) - m_Ctx.Config.TemporaryCaptureDirectory = dir; + m_Ctx.Config().TemporaryCaptureDirectory = dir; else - m_Ctx.Config.TemporaryCaptureDirectory = ""; + m_Ctx.Config().TemporaryCaptureDirectory = ""; - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_saveDirectory_textEdited(const QString &dir) { if(QDir(dir).exists() || dir == "") - m_Ctx.Config.DefaultCaptureSaveDirectory = dir; + m_Ctx.Config().DefaultCaptureSaveDirectory = dir; - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_browseSaveCaptureDirectory_clicked() { QString dir = RDDialog::getExistingDirectory(this, "Choose default directory for saving captures", - m_Ctx.Config.DefaultCaptureSaveDirectory); + m_Ctx.Config().DefaultCaptureSaveDirectory); if(dir != "") - m_Ctx.Config.DefaultCaptureSaveDirectory = dir; + m_Ctx.Config().DefaultCaptureSaveDirectory = dir; - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_AllowGlobalHook_toggled(bool checked) { - m_Ctx.Config.AllowGlobalHook = ui->AllowGlobalHook->isChecked(); + m_Ctx.Config().AllowGlobalHook = ui->AllowGlobalHook->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); - if(m_Ctx.hasCaptureDialog()) - m_Ctx.captureDialog()->updateGlobalHook(); + if(m_Ctx.HasCaptureDialog()) + m_Ctx.GetCaptureDialog()->UpdateGlobalHook(); } void SettingsDialog::on_CheckUpdate_AllowChecks_toggled(bool checked) { - m_Ctx.Config.CheckUpdate_AllowChecks = ui->CheckUpdate_AllowChecks->isChecked(); + m_Ctx.Config().CheckUpdate_AllowChecks = ui->CheckUpdate_AllowChecks->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_Font_PreferMonospaced_toggled(bool checked) { - m_Ctx.Config.Font_PreferMonospaced = ui->Font_PreferMonospaced->isChecked(); + m_Ctx.Config().Font_PreferMonospaced = ui->Font_PreferMonospaced->isChecked(); - m_Ctx.Config.SetupFormatting(); + m_Ctx.Config().SetupFormatting(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_AlwaysReplayLocally_toggled(bool checked) { - m_Ctx.Config.AlwaysReplayLocally = ui->AlwaysReplayLocally->isChecked(); + m_Ctx.Config().AlwaysReplayLocally = ui->AlwaysReplayLocally->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } // core @@ -206,36 +206,37 @@ void SettingsDialog::on_chooseSearchPaths_clicked() OrderedListEditor listEd(tr("Shader debug info search paths"), tr("Search Path"), BrowseMode::Folder, this); - listEd.setItems(m_Ctx.Config.GetConfigSetting("shader.debug.searchPaths") + listEd.setItems(m_Ctx.Config() + .GetConfigSetting("shader.debug.searchPaths") .split(QChar(';'), QString::SkipEmptyParts)); int res = RDDialog::show(&listEd); if(res) - m_Ctx.Config.SetConfigSetting("shader.debug.searchPaths", listEd.getItems().join(QChar(';'))); + m_Ctx.Config().SetConfigSetting("shader.debug.searchPaths", listEd.getItems().join(QChar(';'))); } // texture viewer void SettingsDialog::on_TextureViewer_PerTexSettings_toggled(bool checked) { - m_Ctx.Config.TextureViewer_PerTexSettings = ui->TextureViewer_PerTexSettings->isChecked(); + m_Ctx.Config().TextureViewer_PerTexSettings = ui->TextureViewer_PerTexSettings->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_TextureViewer_ResetRange_toggled(bool checked) { - m_Ctx.Config.TextureViewer_ResetRange = ui->TextureViewer_ResetRange->isChecked(); + m_Ctx.Config().TextureViewer_ResetRange = ui->TextureViewer_ResetRange->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } // shader viewer void SettingsDialog::on_ShaderViewer_FriendlyNaming_toggled(bool checked) { - m_Ctx.Config.ShaderViewer_FriendlyNaming = ui->ShaderViewer_FriendlyNaming->isChecked(); + m_Ctx.Config().ShaderViewer_FriendlyNaming = ui->ShaderViewer_FriendlyNaming->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_browseExtDisasemble_clicked() @@ -251,28 +252,28 @@ void SettingsDialog::on_browseExtDisasemble_clicked() void SettingsDialog::on_externalDisassemblePath_textEdited(const QString &path) { - if(m_Ctx.Config.SPIRVDisassemblers.isEmpty()) + if(m_Ctx.Config().SPIRVDisassemblers.isEmpty()) { - m_Ctx.Config.SPIRVDisassemblers.push_back(SPIRVDisassembler()); - m_Ctx.Config.SPIRVDisassemblers.back().name = "Unknown"; + m_Ctx.Config().SPIRVDisassemblers.push_back(SPIRVDisassembler()); + m_Ctx.Config().SPIRVDisassemblers.back().name = "Unknown"; } - m_Ctx.Config.SPIRVDisassemblers.back().executable = path; + m_Ctx.Config().SPIRVDisassemblers.back().executable = path; - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_externalDisassemblerArgs_textEdited(const QString &args) { - if(m_Ctx.Config.SPIRVDisassemblers.isEmpty()) + if(m_Ctx.Config().SPIRVDisassemblers.isEmpty()) { - m_Ctx.Config.SPIRVDisassemblers.push_back(SPIRVDisassembler()); - m_Ctx.Config.SPIRVDisassemblers.back().name = "Unknown"; + m_Ctx.Config().SPIRVDisassemblers.push_back(SPIRVDisassembler()); + m_Ctx.Config().SPIRVDisassemblers.back().name = "Unknown"; } - m_Ctx.Config.SPIRVDisassemblers.back().args = args; + m_Ctx.Config().SPIRVDisassemblers.back().args = args; - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } // event browser @@ -281,75 +282,74 @@ void SettingsDialog::on_EventBrowser_TimeUnit_currentIndexChanged(int index) if(m_Init) return; - m_Ctx.Config.EventBrowser_TimeUnit = - (PersistantConfig::TimeUnit)ui->EventBrowser_TimeUnit->currentIndex(); + m_Ctx.Config().EventBrowser_TimeUnit = (TimeUnit)ui->EventBrowser_TimeUnit->currentIndex(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_EventBrowser_HideEmpty_toggled(bool checked) { - m_Ctx.Config.EventBrowser_HideEmpty = ui->EventBrowser_HideEmpty->isChecked(); + m_Ctx.Config().EventBrowser_HideEmpty = ui->EventBrowser_HideEmpty->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_EventBrowser_HideAPICalls_toggled(bool checked) { - m_Ctx.Config.EventBrowser_HideAPICalls = ui->EventBrowser_HideAPICalls->isChecked(); + m_Ctx.Config().EventBrowser_HideAPICalls = ui->EventBrowser_HideAPICalls->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_EventBrowser_ApplyColors_toggled(bool checked) { - m_Ctx.Config.EventBrowser_ApplyColors = ui->EventBrowser_ApplyColors->isChecked(); + m_Ctx.Config().EventBrowser_ApplyColors = ui->EventBrowser_ApplyColors->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_EventBrowser_ColorEventRow_toggled(bool checked) { - m_Ctx.Config.EventBrowser_ColorEventRow = ui->EventBrowser_ColorEventRow->isChecked(); + m_Ctx.Config().EventBrowser_ColorEventRow = ui->EventBrowser_ColorEventRow->isChecked(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } // android void SettingsDialog::on_browseTempCaptureDirectory_clicked() { QString dir = RDDialog::getExistingDirectory(this, "Choose directory for temporary captures", - m_Ctx.Config.TemporaryCaptureDirectory); + m_Ctx.Config().TemporaryCaptureDirectory); if(dir != "") - m_Ctx.Config.TemporaryCaptureDirectory = dir; + m_Ctx.Config().TemporaryCaptureDirectory = dir; - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_browseAdbPath_clicked() { QString adb = RDDialog::getExecutableFileName( this, "Locate adb executable", - QFileInfo(m_Ctx.Config.Android_AdbExecutablePath).absoluteDir().path()); + QFileInfo(m_Ctx.Config().Android_AdbExecutablePath).absoluteDir().path()); if(adb != "") - m_Ctx.Config.Android_AdbExecutablePath = adb; + m_Ctx.Config().Android_AdbExecutablePath = adb; - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_Android_MaxConnectTimeout_valueChanged(double timeout) { - m_Ctx.Config.Android_MaxConnectTimeout = ui->Android_MaxConnectTimeout->value(); + m_Ctx.Config().Android_MaxConnectTimeout = ui->Android_MaxConnectTimeout->value(); - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } void SettingsDialog::on_Android_AdbExecutablePath_textEdited(const QString &adb) { if(QFileInfo::exists(adb)) - m_Ctx.Config.Android_AdbExecutablePath = adb; + m_Ctx.Config().Android_AdbExecutablePath = adb; - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } diff --git a/qrenderdoc/Windows/Dialogs/SettingsDialog.h b/qrenderdoc/Windows/Dialogs/SettingsDialog.h index 4d6fed7f5..8c81a4346 100644 --- a/qrenderdoc/Windows/Dialogs/SettingsDialog.h +++ b/qrenderdoc/Windows/Dialogs/SettingsDialog.h @@ -33,14 +33,14 @@ class SettingsDialog; class QListWidgetItem; -class CaptureContext; +struct ICaptureContext; class SettingsDialog : public QDialog { Q_OBJECT public: - explicit SettingsDialog(CaptureContext &ctx, QWidget *parent = 0); + explicit SettingsDialog(ICaptureContext &ctx, QWidget *parent = 0); ~SettingsDialog(); private slots: @@ -92,6 +92,6 @@ private slots: private: Ui::SettingsDialog *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; bool m_Init = false; }; diff --git a/qrenderdoc/Windows/Dialogs/TipsDialog.cpp b/qrenderdoc/Windows/Dialogs/TipsDialog.cpp index 402dbef14..8049159f1 100644 --- a/qrenderdoc/Windows/Dialogs/TipsDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/TipsDialog.cpp @@ -28,14 +28,14 @@ #include #include -TipsDialog::TipsDialog(CaptureContext &Ctx, QWidget *parent) +TipsDialog::TipsDialog(ICaptureContext &Ctx, QWidget *parent) : m_Ctx(Ctx), QDialog(parent), ui(new Ui::TipsDialog), m_currentTip(0) { ui->setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); initialize(); - if(m_Ctx.Config.Tips_HasSeenFirst) + if(m_Ctx.Config().Tips_HasSeenFirst) { showRandomTip(); } @@ -44,7 +44,7 @@ TipsDialog::TipsDialog(CaptureContext &Ctx, QWidget *parent) showTip(m_currentTip); } - m_Ctx.Config.Tips_HasSeenFirst = true; + m_Ctx.Config().Tips_HasSeenFirst = true; } TipsDialog::~TipsDialog() diff --git a/qrenderdoc/Windows/Dialogs/TipsDialog.h b/qrenderdoc/Windows/Dialogs/TipsDialog.h index 1f8cf1fd5..8dfeff093 100644 --- a/qrenderdoc/Windows/Dialogs/TipsDialog.h +++ b/qrenderdoc/Windows/Dialogs/TipsDialog.h @@ -40,7 +40,7 @@ class TipsDialog : public QDialog Q_OBJECT public: - explicit TipsDialog(CaptureContext &Ctx, QWidget *parent = 0); + explicit TipsDialog(ICaptureContext &Ctx, QWidget *parent = 0); ~TipsDialog(); protected: @@ -58,7 +58,7 @@ protected: QVector m_tips; int m_currentTip; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; private slots: void on_nextButton_clicked(); diff --git a/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp b/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp index 83b2e34ec..2d203341c 100644 --- a/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/VirtualFileDialog.cpp @@ -48,7 +48,7 @@ public: FileNameRole, }; - RemoteFileModel(RenderManager &r, QObject *parent = NULL) + RemoteFileModel(IRenderManager &r, QObject *parent = NULL) : Renderer(r), QAbstractItemModel(parent) { makeIconStates(fileIcon, Pixmaps::page_white_database()); @@ -361,7 +361,7 @@ public: } private: - RenderManager &Renderer; + IRenderManager &Renderer; QIcon dirIcon[2]; QIcon exeIcon[2]; @@ -549,7 +549,7 @@ protected: } }; -VirtualFileDialog::VirtualFileDialog(CaptureContext &ctx, QWidget *parent) +VirtualFileDialog::VirtualFileDialog(ICaptureContext &ctx, QWidget *parent) : QDialog(parent), ui(new Ui::VirtualFileDialog) { ui->setupUi(this); diff --git a/qrenderdoc/Windows/Dialogs/VirtualFileDialog.h b/qrenderdoc/Windows/Dialogs/VirtualFileDialog.h index 1db1b427b..428458724 100644 --- a/qrenderdoc/Windows/Dialogs/VirtualFileDialog.h +++ b/qrenderdoc/Windows/Dialogs/VirtualFileDialog.h @@ -31,7 +31,7 @@ namespace Ui class VirtualFileDialog; } -class CaptureContext; +struct ICaptureContext; class RemoteFileModel; class RemoteFileProxy; @@ -40,7 +40,7 @@ class VirtualFileDialog : public QDialog Q_OBJECT public: - explicit VirtualFileDialog(CaptureContext &ctx, QWidget *parent = 0); + explicit VirtualFileDialog(ICaptureContext &ctx, QWidget *parent = 0); ~VirtualFileDialog(); QString chosenPath() { return m_ChosenPath; } diff --git a/qrenderdoc/Windows/EventBrowser.cpp b/qrenderdoc/Windows/EventBrowser.cpp index 63f44cf6f..c40673e07 100644 --- a/qrenderdoc/Windows/EventBrowser.cpp +++ b/qrenderdoc/Windows/EventBrowser.cpp @@ -43,7 +43,7 @@ enum COL_LAST_EID, }; -EventBrowser::EventBrowser(CaptureContext &ctx, QWidget *parent) +EventBrowser::EventBrowser(ICaptureContext &ctx, QWidget *parent) : QFrame(parent), ui(new Ui::EventBrowser), m_Ctx(ctx) { ui->setupUi(this); @@ -117,7 +117,7 @@ EventBrowser::EventBrowser(CaptureContext &ctx, QWidget *parent) EventBrowser::~EventBrowser() { - m_Ctx.windowClosed(this); + m_Ctx.BuiltinWindowClosed(this); m_Ctx.RemoveLogViewer(this); delete ui; delete m_SizeDelegate; diff --git a/qrenderdoc/Windows/EventBrowser.h b/qrenderdoc/Windows/EventBrowser.h index 0e2b1d472..1b63a3486 100644 --- a/qrenderdoc/Windows/EventBrowser.h +++ b/qrenderdoc/Windows/EventBrowser.h @@ -40,19 +40,22 @@ class QTimer; class FlowLayout; class SizeDelegate; -class EventBrowser : public QFrame, public ILogViewerForm +class EventBrowser : public QFrame, public IEventBrowser, public ILogViewerForm { private: Q_OBJECT public: - explicit EventBrowser(CaptureContext &ctx, QWidget *parent = 0); + explicit EventBrowser(ICaptureContext &ctx, QWidget *parent = 0); ~EventBrowser(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID); + // IEventBrowser + QWidget *Widget() override { return this; } + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override; private slots: // automatic slots @@ -119,5 +122,5 @@ private: void RefreshIcon(QTreeWidgetItem *item); Ui::EventBrowser *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; }; diff --git a/qrenderdoc/Windows/MainWindow.cpp b/qrenderdoc/Windows/MainWindow.cpp index 917cb317c..9a9b1a008 100644 --- a/qrenderdoc/Windows/MainWindow.cpp +++ b/qrenderdoc/Windows/MainWindow.cpp @@ -27,13 +27,13 @@ #include #include #include +#include #include #include #include #include "Code/CaptureContext.h" #include "Code/QRDUtils.h" #include "Code/Resources.h" -#include "PipelineState/PipelineStateViewer.h" #include "Resources/resource.h" #include "Widgets/Extended/RDLabel.h" #include "Windows/Dialogs/AboutDialog.h" @@ -43,13 +43,6 @@ #include "Windows/Dialogs/SettingsDialog.h" #include "Windows/Dialogs/SuggestRemoteDialog.h" #include "Windows/Dialogs/TipsDialog.h" -#include "APIInspector.h" -#include "BufferViewer.h" -#include "ConstantBufferPreviewer.h" -#include "DebugMessageView.h" -#include "EventBrowser.h" -#include "StatisticsViewer.h" -#include "TextureViewer.h" #include "ui_MainWindow.h" #include "version.h" @@ -79,7 +72,7 @@ struct Version extern "C" void *__stdcall GetModuleHandleA(const char *); #endif -MainWindow::MainWindow(CaptureContext &ctx) : QMainWindow(NULL), ui(new Ui::MainWindow), m_Ctx(ctx) +MainWindow::MainWindow(ICaptureContext &ctx) : QMainWindow(NULL), ui(new Ui::MainWindow), m_Ctx(ctx) { ui->setupUi(this); @@ -183,8 +176,9 @@ MainWindow::MainWindow(CaptureContext &ctx) : QMainWindow(NULL), ui(new Ui::Main PopulateRecentCaptures(); ui->toolWindowManager->setRubberBandLineWidth(50); - ui->toolWindowManager->setToolWindowCreateCallback( - [this](const QString &objectName) -> QWidget * { return m_Ctx.createToolWindow(objectName); }); + ui->toolWindowManager->setToolWindowCreateCallback([this](const QString &objectName) -> QWidget * { + return m_Ctx.CreateBuiltinWindow(objectName); + }); ui->action_Resolve_Symbols->setEnabled(false); ui->action_Resolve_Symbols->setText(tr("Resolve Symbols")); @@ -192,8 +186,8 @@ MainWindow::MainWindow(CaptureContext &ctx) : QMainWindow(NULL), ui(new Ui::Main bool loaded = LoadLayout(0); LambdaThread *th = new LambdaThread([this]() { - m_Ctx.Config.AddAndroidHosts(); - for(RemoteHost *host : m_Ctx.Config.RemoteHosts) + m_Ctx.Config().AddAndroidHosts(); + for(RemoteHost *host : m_Ctx.Config().RemoteHosts) host->CheckStatus(); }); th->selfDelete(true); @@ -202,36 +196,36 @@ MainWindow::MainWindow(CaptureContext &ctx) : QMainWindow(NULL), ui(new Ui::Main // create default layout if layout failed to load if(!loaded) { - EventBrowser *eventBrowser = m_Ctx.eventBrowser(); + QWidget *eventBrowser = m_Ctx.GetEventBrowser()->Widget(); ui->toolWindowManager->addToolWindow(eventBrowser, ToolWindowManager::EmptySpace); - TextureViewer *textureViewer = m_Ctx.textureViewer(); + QWidget *textureViewer = m_Ctx.GetTextureViewer()->Widget(); ui->toolWindowManager->addToolWindow( textureViewer, ToolWindowManager::AreaReference(ToolWindowManager::RightOf, ui->toolWindowManager->areaOf(eventBrowser), 0.75f)); - PipelineStateViewer *pipe = m_Ctx.pipelineViewer(); + QWidget *pipe = m_Ctx.GetPipelineViewer()->Widget(); ui->toolWindowManager->addToolWindow( pipe, ToolWindowManager::AreaReference(ToolWindowManager::AddTo, ui->toolWindowManager->areaOf(textureViewer))); - BufferViewer *mesh = m_Ctx.meshPreview(); + QWidget *mesh = m_Ctx.GetMeshPreview()->Widget(); ui->toolWindowManager->addToolWindow( mesh, ToolWindowManager::AreaReference(ToolWindowManager::AddTo, ui->toolWindowManager->areaOf(textureViewer))); - CaptureDialog *capDialog = m_Ctx.captureDialog(); + QWidget *capDialog = m_Ctx.GetCaptureDialog()->Widget(); ui->toolWindowManager->addToolWindow( capDialog, ToolWindowManager::AreaReference(ToolWindowManager::AddTo, ui->toolWindowManager->areaOf(textureViewer))); - APIInspector *apiInspector = m_Ctx.apiInspector(); + QWidget *apiInspector = m_Ctx.GetAPIInspector()->Widget(); ui->toolWindowManager->addToolWindow( apiInspector, @@ -284,7 +278,7 @@ QString MainWindow::GetLayoutPath(int layout) if(layout > 0) filename = QString("Layout%1.config").arg(layout); - return m_Ctx.ConfigFile(filename); + return ConfigFilePath(filename); } void MainWindow::on_action_Exit_triggered() @@ -298,7 +292,7 @@ void MainWindow::on_action_Open_Log_triggered() return; QString filename = - RDDialog::getOpenFileName(this, "Select Logfile to open", m_Ctx.Config.LastLogPath, + RDDialog::getOpenFileName(this, "Select Logfile to open", m_Ctx.Config().LastLogPath, "Log Files (*.rdc);;Image Files (*.dds *.hdr *.exr *.bmp *.jpg " "*.jpeg *.png *.tga *.gif *.psd;;All Files (*.*)"); @@ -353,8 +347,8 @@ void MainWindow::OnCaptureTrigger(const QString &exe, const QString &workingDir, } LiveCapture *live = new LiveCapture( - m_Ctx, m_Ctx.Renderer().remote() ? m_Ctx.Renderer().remote()->Hostname : "", ret, this, - this); + m_Ctx, m_Ctx.Renderer().CurrentRemote() ? m_Ctx.Renderer().CurrentRemote()->Hostname : "", + ret, this, this); ShowLiveCapture(live); callback(live); }); @@ -428,7 +422,8 @@ void MainWindow::LoadLogfile(const QString &filename, bool temporary, bool local rdctype::str machineIdent; ReplaySupport support = ReplaySupport::Unsupported; - bool remoteReplay = !local || (m_Ctx.Renderer().remote() && m_Ctx.Renderer().remote()->Connected); + bool remoteReplay = + !local || (m_Ctx.Renderer().CurrentRemote() && m_Ctx.Renderer().CurrentRemote()->Connected); if(local) { @@ -437,7 +432,8 @@ void MainWindow::LoadLogfile(const QString &filename, bool temporary, bool local // if the return value suggests remote replay, and it's not already selected, AND the user // hasn't previously chosen to always replay locally without being prompted, ask if they'd // prefer to switch to a remote context for replaying. - if(support == ReplaySupport::SuggestRemote && !remoteReplay && !m_Ctx.Config.AlwaysReplayLocally) + if(support == ReplaySupport::SuggestRemote && !remoteReplay && + !m_Ctx.Config().AlwaysReplayLocally) { SuggestRemoteDialog dialog(ToQStr(driver), ToQStr(machineIdent), this); @@ -465,7 +461,8 @@ void MainWindow::LoadLogfile(const QString &filename, bool temporary, bool local [this]() { return contextChooser->isEnabled(); }); } - remoteReplay = (m_Ctx.Renderer().remote() && m_Ctx.Renderer().remote()->Connected); + remoteReplay = + (m_Ctx.Renderer().CurrentRemote() && m_Ctx.Renderer().CurrentRemote()->Connected); if(!remoteReplay) { @@ -484,9 +481,9 @@ void MainWindow::LoadLogfile(const QString &filename, bool temporary, bool local // set that bit as sticky in the config if(dialog.alwaysReplayLocally()) { - m_Ctx.Config.AlwaysReplayLocally = true; + m_Ctx.Config().AlwaysReplayLocally = true; - m_Ctx.Config.Save(); + m_Ctx.Config().Save(); } } } @@ -516,7 +513,7 @@ void MainWindow::LoadLogfile(const QString &filename, bool temporary, bool local QString remoteMessage = tr("This log was captured with %1 and cannot be replayed on %2.\n\n") .arg(driver.c_str()) - .arg(m_Ctx.Renderer().remote()->Hostname); + .arg(m_Ctx.Renderer().CurrentRemote()->Hostname); remoteMessage += "Try selecting a different remote context in the status bar."; @@ -558,7 +555,7 @@ void MainWindow::LoadLogfile(const QString &filename, bool temporary, bool local if(!remoteReplay) { - m_Ctx.Config.LastLogPath = QFileInfo(filename).absolutePath(); + m_Ctx.Config().LastLogPath = QFileInfo(filename).absolutePath(); } statusText->setText(tr("Loading ") + origFilename + "..."); @@ -567,25 +564,25 @@ void MainWindow::LoadLogfile(const QString &filename, bool temporary, bool local void MainWindow::OpenCaptureConfigFile(const QString &filename, bool exe) { - CaptureDialog *capDialog = m_Ctx.captureDialog(); + ICaptureDialog *capDialog = m_Ctx.GetCaptureDialog(); if(exe) - capDialog->setExecutableFilename(filename); + capDialog->SetExecutableFilename(filename); else - capDialog->loadSettings(filename); + capDialog->LoadSettings(filename); - if(!ui->toolWindowManager->toolWindows().contains(capDialog)) - ui->toolWindowManager->addToolWindow(capDialog, mainToolArea()); + if(!ui->toolWindowManager->toolWindows().contains(capDialog->Widget())) + ui->toolWindowManager->addToolWindow(capDialog->Widget(), mainToolArea()); } QString MainWindow::GetSavePath() { QString dir; - if(m_Ctx.Config.DefaultCaptureSaveDirectory != "") + if(m_Ctx.Config().DefaultCaptureSaveDirectory != "") { if(m_LastSaveCapturePath == "") - dir = m_Ctx.Config.DefaultCaptureSaveDirectory; + dir = m_Ctx.Config().DefaultCaptureSaveDirectory; else dir = m_LastSaveCapturePath; } @@ -648,7 +645,7 @@ bool MainWindow::PromptSaveLog() return false; } - PersistantConfig::AddRecentFile(m_Ctx.Config.RecentLogFiles, saveFilename, 10); + AddRecentFile(m_Ctx.Config().RecentLogFiles, saveFilename, 10); PopulateRecentFiles(); SetTitle(saveFilename); @@ -730,8 +727,8 @@ void MainWindow::SetTitle(const QString &filename) prefix += " - "; } - if(m_Ctx.Renderer().remote()) - prefix += tr("Remote: %1 - ").arg(m_Ctx.Renderer().remote()->Hostname); + if(m_Ctx.Renderer().CurrentRemote()) + prefix += tr("Remote: %1 - ").arg(m_Ctx.Renderer().CurrentRemote()->Hostname); QString text = prefix + "RenderDoc "; @@ -760,9 +757,9 @@ void MainWindow::PopulateRecentFiles() ui->menu_Recent_Logs->setEnabled(false); int idx = 1; - for(int i = m_Ctx.Config.RecentLogFiles.size() - 1; i >= 0; i--) + for(int i = m_Ctx.Config().RecentLogFiles.size() - 1; i >= 0; i--) { - const QString &filename = m_Ctx.Config.RecentLogFiles[i]; + const QString &filename = m_Ctx.Config().RecentLogFiles[i]; ui->menu_Recent_Logs->addAction("&" + QString::number(idx) + " " + filename, [this, filename] { recentLog(filename); }); idx++; @@ -781,9 +778,9 @@ void MainWindow::PopulateRecentCaptures() ui->menu_Recent_Capture_Settings->setEnabled(false); int idx = 1; - for(int i = m_Ctx.Config.RecentCaptureSettings.size() - 1; i >= 0; i--) + for(int i = m_Ctx.Config().RecentCaptureSettings.size() - 1; i >= 0; i--) { - const QString &filename = m_Ctx.Config.RecentCaptureSettings[i]; + const QString &filename = m_Ctx.Config().RecentCaptureSettings[i]; ui->menu_Recent_Capture_Settings->addAction("&" + QString::number(idx) + " " + filename, [this, filename] { recentCapture(filename); }); idx++; @@ -797,9 +794,9 @@ void MainWindow::PopulateRecentCaptures() void MainWindow::ShowLiveCapture(LiveCapture *live) { - live->setWindowIcon(m_Ctx.winIcon()); m_LiveCaptures.push_back(live); - ui->toolWindowManager->addToolWindow(live, mainToolArea()); + + m_Ctx.AddDockWindow(live, DockReference::MainToolArea, this); } void MainWindow::LiveCaptureClosed(LiveCapture *live) @@ -807,25 +804,32 @@ void MainWindow::LiveCaptureClosed(LiveCapture *live) m_LiveCaptures.removeOne(live); } +ToolWindowManager *MainWindow::mainToolManager() +{ + return ui->toolWindowManager; +} + ToolWindowManager::AreaReference MainWindow::mainToolArea() { // bit of a hack. Maybe the ToolWindowManager should track this? // Try and identify where to add new windows, by searching a // priority list of other windows to use their area - if(m_Ctx.hasTextureViewer() && ui->toolWindowManager->toolWindows().contains(m_Ctx.textureViewer())) - return ToolWindowManager::AreaReference(ToolWindowManager::AddTo, - ui->toolWindowManager->areaOf(m_Ctx.textureViewer())); - else if(m_Ctx.hasPipelineViewer() && - ui->toolWindowManager->toolWindows().contains(m_Ctx.pipelineViewer())) - return ToolWindowManager::AreaReference(ToolWindowManager::AddTo, - ui->toolWindowManager->areaOf(m_Ctx.pipelineViewer())); - else if(m_Ctx.hasMeshPreview() && ui->toolWindowManager->toolWindows().contains(m_Ctx.meshPreview())) - return ToolWindowManager::AreaReference(ToolWindowManager::AddTo, - ui->toolWindowManager->areaOf(m_Ctx.meshPreview())); - else if(m_Ctx.hasCaptureDialog() && - ui->toolWindowManager->toolWindows().contains(m_Ctx.captureDialog())) - return ToolWindowManager::AreaReference(ToolWindowManager::AddTo, - ui->toolWindowManager->areaOf(m_Ctx.captureDialog())); + if(m_Ctx.HasTextureViewer() && + ui->toolWindowManager->toolWindows().contains(m_Ctx.GetTextureViewer()->Widget())) + return ToolWindowManager::AreaReference( + ToolWindowManager::AddTo, ui->toolWindowManager->areaOf(m_Ctx.GetTextureViewer()->Widget())); + else if(m_Ctx.HasPipelineViewer() && + ui->toolWindowManager->toolWindows().contains(m_Ctx.GetPipelineViewer()->Widget())) + return ToolWindowManager::AreaReference( + ToolWindowManager::AddTo, ui->toolWindowManager->areaOf(m_Ctx.GetPipelineViewer()->Widget())); + else if(m_Ctx.HasMeshPreview() && + ui->toolWindowManager->toolWindows().contains(m_Ctx.GetMeshPreview()->Widget())) + return ToolWindowManager::AreaReference( + ToolWindowManager::AddTo, ui->toolWindowManager->areaOf(m_Ctx.GetMeshPreview()->Widget())); + else if(m_Ctx.HasCaptureDialog() && + ui->toolWindowManager->toolWindows().contains(m_Ctx.GetCaptureDialog()->Widget())) + return ToolWindowManager::AreaReference( + ToolWindowManager::AddTo, ui->toolWindowManager->areaOf(m_Ctx.GetCaptureDialog()->Widget())); // if all else fails just add to the last place we placed something. return ToolWindowManager::AreaReference(ToolWindowManager::LastUsedArea); @@ -834,17 +838,19 @@ ToolWindowManager::AreaReference MainWindow::mainToolArea() ToolWindowManager::AreaReference MainWindow::leftToolArea() { // see mainToolArea() - if(m_Ctx.hasTextureViewer() && ui->toolWindowManager->toolWindows().contains(m_Ctx.textureViewer())) - return ToolWindowManager::AreaReference(ToolWindowManager::LeftOf, - ui->toolWindowManager->areaOf(m_Ctx.textureViewer())); - else if(m_Ctx.hasPipelineViewer() && - ui->toolWindowManager->toolWindows().contains(m_Ctx.pipelineViewer())) - return ToolWindowManager::AreaReference(ToolWindowManager::LeftOf, - ui->toolWindowManager->areaOf(m_Ctx.pipelineViewer())); - else if(m_Ctx.hasCaptureDialog() && - ui->toolWindowManager->toolWindows().contains(m_Ctx.captureDialog())) - return ToolWindowManager::AreaReference(ToolWindowManager::LeftOf, - ui->toolWindowManager->areaOf(m_Ctx.captureDialog())); + if(m_Ctx.HasTextureViewer() && + ui->toolWindowManager->toolWindows().contains(m_Ctx.GetTextureViewer()->Widget())) + return ToolWindowManager::AreaReference( + ToolWindowManager::LeftOf, ui->toolWindowManager->areaOf(m_Ctx.GetTextureViewer()->Widget())); + else if(m_Ctx.HasPipelineViewer() && + ui->toolWindowManager->toolWindows().contains(m_Ctx.GetPipelineViewer()->Widget())) + return ToolWindowManager::AreaReference( + ToolWindowManager::LeftOf, + ui->toolWindowManager->areaOf(m_Ctx.GetPipelineViewer()->Widget())); + else if(m_Ctx.HasCaptureDialog() && + ui->toolWindowManager->toolWindows().contains(m_Ctx.GetCaptureDialog()->Widget())) + return ToolWindowManager::AreaReference( + ToolWindowManager::LeftOf, ui->toolWindowManager->areaOf(m_Ctx.GetCaptureDialog()->Widget())); return ToolWindowManager::AreaReference(ToolWindowManager::LastUsedArea); } @@ -863,7 +869,7 @@ void MainWindow::recentLog(const QString &filename) if(res == QMessageBox::Yes) { - m_Ctx.Config.RecentLogFiles.removeOne(filename); + m_Ctx.Config().RecentLogFiles.removeOne(filename); PopulateRecentFiles(); } @@ -884,7 +890,7 @@ void MainWindow::recentCapture(const QString &filename) if(res == QMessageBox::Yes) { - m_Ctx.Config.RecentLogFiles.removeOne(filename); + m_Ctx.Config().RecentLogFiles.removeOne(filename); PopulateRecentFiles(); } @@ -917,9 +923,9 @@ void MainWindow::setLogHasErrors(bool errors) text = tr("%1 loaded. Log has %2 errors, warnings or performance notes. " "See the 'Log Errors and Warnings' window.") .arg(filename) - .arg(m_Ctx.DebugMessages.size()); - if(m_Ctx.UnreadMessageCount > 0) - text += tr(" %1 Unread.").arg(m_Ctx.UnreadMessageCount); + .arg(m_Ctx.DebugMessages().size()); + if(m_Ctx.UnreadMessageCount() > 0) + text += tr(" %1 Unread.").arg(m_Ctx.UnreadMessageCount()); statusText->setText(text); } else @@ -933,7 +939,7 @@ void MainWindow::remoteProbe() { if(!m_Ctx.LogLoaded() && !m_Ctx.LogLoading()) { - for(RemoteHost *host : m_Ctx.Config.RemoteHosts) + for(RemoteHost *host : m_Ctx.Config().RemoteHosts) { // don't mess with a host we're connected to - this is handled anyway if(host->Connected) @@ -958,13 +964,13 @@ void MainWindow::messageCheck() bool disconnected = false; - if(m_Ctx.Renderer().remote()) + if(m_Ctx.Renderer().CurrentRemote()) { - bool prev = m_Ctx.Renderer().remote()->ServerRunning; + bool prev = m_Ctx.Renderer().CurrentRemote()->ServerRunning; m_Ctx.Renderer().PingRemote(); - if(prev != m_Ctx.Renderer().remote()->ServerRunning) + if(prev != m_Ctx.Renderer().CurrentRemote()->ServerRunning) disconnected = true; } @@ -979,31 +985,30 @@ void MainWindow::messageCheck() "RenderDoc to reconnect and load the capture again")); } - if(m_Ctx.Renderer().remote() && !m_Ctx.Renderer().remote()->ServerRunning) + if(m_Ctx.Renderer().CurrentRemote() && !m_Ctx.Renderer().CurrentRemote()->ServerRunning) contextChooser->setIcon(Icons::cross()); if(!msgs.empty()) { m_Ctx.AddMessages(msgs); - m_Ctx.debugMessageView()->RefreshMessageList(); } - if(m_Ctx.UnreadMessageCount > 0) + if(m_Ctx.UnreadMessageCount() > 0) m_messageAlternate = !m_messageAlternate; else m_messageAlternate = false; - setLogHasErrors(!m_Ctx.DebugMessages.empty()); + setLogHasErrors(!m_Ctx.DebugMessages().empty()); }); }); } else if(!m_Ctx.LogLoaded() && !m_Ctx.LogLoading()) { - if(m_Ctx.Renderer().remote()) + if(m_Ctx.Renderer().CurrentRemote()) m_Ctx.Renderer().PingRemote(); GUIInvoke::call([this]() { - if(m_Ctx.Renderer().remote() && !m_Ctx.Renderer().remote()->ServerRunning) + if(m_Ctx.Renderer().CurrentRemote() && !m_Ctx.Renderer().CurrentRemote()->ServerRunning) { contextChooser->setIcon(Icons::cross()); contextChooser->setText(tr("Replay Context: %1").arg("Local")); @@ -1020,9 +1025,9 @@ void MainWindow::FillRemotesMenu(QMenu *menu, bool includeLocalhost) { menu->clear(); - for(int i = 0; i < m_Ctx.Config.RemoteHosts.count(); i++) + for(int i = 0; i < m_Ctx.Config().RemoteHosts.count(); i++) { - RemoteHost *host = m_Ctx.Config.RemoteHosts[i]; + RemoteHost *host = m_Ctx.Config().RemoteHosts[i]; // add localhost at the end if(host->Hostname == "localhost") @@ -1080,9 +1085,9 @@ void MainWindow::switchContext() RemoteHost *host = NULL; - if(hostIdx >= 0 && hostIdx < m_Ctx.Config.RemoteHosts.count()) + if(hostIdx >= 0 && hostIdx < m_Ctx.Config().RemoteHosts.count()) { - host = m_Ctx.Config.RemoteHosts[hostIdx]; + host = m_Ctx.Config().RemoteHosts[hostIdx]; } for(LiveCapture *live : m_LiveCaptures) @@ -1203,7 +1208,7 @@ void MainWindow::contextChooser_menuShowing() FillRemotesMenu(contextChooserMenu, true); } -void MainWindow::statusDoubleClicked() +void MainWindow::statusDoubleClicked(QMouseEvent *event) { showDebugMessageView(); } @@ -1215,7 +1220,7 @@ void MainWindow::OnLogfileLoaded() statusProgress->setVisible(false); - setLogHasErrors(!m_Ctx.DebugMessages.empty()); + setLogHasErrors(!m_Ctx.DebugMessages().empty()); m_Ctx.Renderer().AsyncInvoke([this](IReplayRenderer *r) { bool hasResolver = r->HasCallstacks(); @@ -1233,7 +1238,7 @@ void MainWindow::OnLogfileLoaded() PopulateRecentFiles(); - ToolWindowManager::raiseToolWindow(m_Ctx.eventBrowser()); + ToolWindowManager::raiseToolWindow(m_Ctx.GetEventBrowser()->Widget()); } void MainWindow::OnLogfileClosed() @@ -1250,7 +1255,7 @@ void MainWindow::OnLogfileClosed() SetTitle(); // if the remote sever disconnected during log replay, resort back to a 'disconnected' state - if(m_Ctx.Renderer().remote() && !m_Ctx.Renderer().remote()->ServerRunning) + if(m_Ctx.Renderer().CurrentRemote() && !m_Ctx.Renderer().CurrentRemote()->ServerRunning) { statusText->setText( tr("Remote server disconnected. To attempt to reconnect please select it again.")); @@ -1281,7 +1286,7 @@ void MainWindow::on_action_About_triggered() void MainWindow::on_action_Mesh_Output_triggered() { - BufferViewer *meshPreview = m_Ctx.meshPreview(); + QWidget *meshPreview = m_Ctx.GetMeshPreview()->Widget(); if(ui->toolWindowManager->toolWindows().contains(meshPreview)) ToolWindowManager::raiseToolWindow(meshPreview); @@ -1291,7 +1296,7 @@ void MainWindow::on_action_Mesh_Output_triggered() void MainWindow::on_action_API_Inspector_triggered() { - APIInspector *apiInspector = m_Ctx.apiInspector(); + QWidget *apiInspector = m_Ctx.GetAPIInspector()->Widget(); if(ui->toolWindowManager->toolWindows().contains(apiInspector)) { @@ -1299,10 +1304,11 @@ void MainWindow::on_action_API_Inspector_triggered() } else { - if(m_Ctx.hasEventBrowser()) + if(m_Ctx.HasEventBrowser()) { - ToolWindowManager::AreaReference ref(ToolWindowManager::BottomOf, - ui->toolWindowManager->areaOf(m_Ctx.eventBrowser())); + ToolWindowManager::AreaReference ref( + ToolWindowManager::BottomOf, + ui->toolWindowManager->areaOf(m_Ctx.GetEventBrowser()->Widget())); ui->toolWindowManager->addToolWindow(apiInspector, ref); } else @@ -1314,7 +1320,7 @@ void MainWindow::on_action_API_Inspector_triggered() void MainWindow::on_action_Event_Browser_triggered() { - EventBrowser *eventBrowser = m_Ctx.eventBrowser(); + QWidget *eventBrowser = m_Ctx.GetEventBrowser()->Widget(); if(ui->toolWindowManager->toolWindows().contains(eventBrowser)) ToolWindowManager::raiseToolWindow(eventBrowser); @@ -1324,7 +1330,7 @@ void MainWindow::on_action_Event_Browser_triggered() void MainWindow::on_action_Texture_Viewer_triggered() { - TextureViewer *textureViewer = m_Ctx.textureViewer(); + QWidget *textureViewer = m_Ctx.GetTextureViewer()->Widget(); if(ui->toolWindowManager->toolWindows().contains(textureViewer)) ToolWindowManager::raiseToolWindow(textureViewer); @@ -1334,7 +1340,7 @@ void MainWindow::on_action_Texture_Viewer_triggered() void MainWindow::on_action_Pipeline_State_triggered() { - PipelineStateViewer *pipelineViewer = m_Ctx.pipelineViewer(); + QWidget *pipelineViewer = m_Ctx.GetPipelineViewer()->Widget(); if(ui->toolWindowManager->toolWindows().contains(pipelineViewer)) ToolWindowManager::raiseToolWindow(pipelineViewer); @@ -1344,31 +1350,31 @@ void MainWindow::on_action_Pipeline_State_triggered() void MainWindow::on_action_Capture_Log_triggered() { - CaptureDialog *capDialog = m_Ctx.captureDialog(); + ICaptureDialog *capDialog = m_Ctx.GetCaptureDialog(); - capDialog->setInjectMode(false); + capDialog->SetInjectMode(false); - if(ui->toolWindowManager->toolWindows().contains(capDialog)) - ToolWindowManager::raiseToolWindow(capDialog); + if(ui->toolWindowManager->toolWindows().contains(capDialog->Widget())) + ToolWindowManager::raiseToolWindow(capDialog->Widget()); else - ui->toolWindowManager->addToolWindow(capDialog, mainToolArea()); + ui->toolWindowManager->addToolWindow(capDialog->Widget(), mainToolArea()); } void MainWindow::on_action_Inject_into_Process_triggered() { - CaptureDialog *capDialog = m_Ctx.captureDialog(); + ICaptureDialog *capDialog = m_Ctx.GetCaptureDialog(); - capDialog->setInjectMode(true); + capDialog->SetInjectMode(true); - if(ui->toolWindowManager->toolWindows().contains(capDialog)) - ToolWindowManager::raiseToolWindow(capDialog); + if(ui->toolWindowManager->toolWindows().contains(capDialog->Widget())) + ToolWindowManager::raiseToolWindow(capDialog->Widget()); else - ui->toolWindowManager->addToolWindow(capDialog, mainToolArea()); + ui->toolWindowManager->addToolWindow(capDialog->Widget(), mainToolArea()); } void MainWindow::on_action_Errors_and_Warnings_triggered() { - DebugMessageView *debugMessages = m_Ctx.debugMessageView(); + QWidget *debugMessages = m_Ctx.GetDebugMessageView()->Widget(); if(ui->toolWindowManager->toolWindows().contains(debugMessages)) ToolWindowManager::raiseToolWindow(debugMessages); @@ -1378,7 +1384,7 @@ void MainWindow::on_action_Errors_and_Warnings_triggered() void MainWindow::on_action_Statistics_Viewer_triggered() { - StatisticsViewer *stats = m_Ctx.statisticsViewer(); + QWidget *stats = m_Ctx.GetStatisticsViewer()->Widget(); if(ui->toolWindowManager->toolWindows().contains(stats)) ToolWindowManager::raiseToolWindow(stats); @@ -1397,8 +1403,8 @@ void MainWindow::on_action_Resolve_Symbols_triggered() return !running; }); - if(m_Ctx.hasAPIInspector()) - m_Ctx.apiInspector()->on_apiEvents_itemSelectionChanged(); + if(m_Ctx.HasAPIInspector()) + m_Ctx.GetAPIInspector()->Refresh(); } void MainWindow::on_action_Attach_to_Running_Instance_triggered() diff --git a/qrenderdoc/Windows/MainWindow.h b/qrenderdoc/Windows/MainWindow.h index d928d55c1..7e203a01f 100644 --- a/qrenderdoc/Windows/MainWindow.h +++ b/qrenderdoc/Windows/MainWindow.h @@ -42,20 +42,27 @@ class QToolButton; class CaptureDialog; class LiveCapture; -class MainWindow : public QMainWindow, public ILogViewerForm +class MainWindow : public QMainWindow, public IMainWindow, public ILogViewerForm { private: Q_OBJECT public: - explicit MainWindow(CaptureContext &ctx); + explicit MainWindow(ICaptureContext &ctx); ~MainWindow(); + // IMainWindow + QWidget *Widget() override { return this; } + // ILogViewerForm void OnLogfileLoaded() override; void OnLogfileClosed() override; void OnSelectedEventChanged(uint32_t eventID) override {} void OnEventChanged(uint32_t eventID) override; + ToolWindowManager *mainToolManager(); + ToolWindowManager::AreaReference mainToolArea(); + ToolWindowManager::AreaReference leftToolArea(); + void setProgress(float val); void takeLogOwnership() { m_OwnTempLog = true; } void LoadFromFilename(const QString &filename); @@ -114,7 +121,7 @@ private slots: void loadLayout_triggered(); void messageCheck(); void remoteProbe(); - void statusDoubleClicked(); + void statusDoubleClicked(QMouseEvent *event); void switchContext(); void contextChooser_menuShowing(); @@ -126,11 +133,8 @@ private: QString dragFilename(const QMimeData *mimeData); - ToolWindowManager::AreaReference mainToolArea(); - ToolWindowManager::AreaReference leftToolArea(); - Ui::MainWindow *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; QList m_LiveCaptures; diff --git a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp index 1f640e596..191d73b80 100644 --- a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp @@ -24,14 +24,10 @@ #include "D3D11PipelineStateViewer.h" #include +#include #include #include "3rdparty/toolwindowmanager/ToolWindowManager.h" #include "Code/Resources.h" -#include "Windows/BufferViewer.h" -#include "Windows/ConstantBufferPreviewer.h" -#include "Windows/MainWindow.h" -#include "Windows/ShaderViewer.h" -#include "Windows/TextureViewer.h" #include "PipelineStateViewer.h" #include "ui_D3D11PipelineStateViewer.h" @@ -71,8 +67,8 @@ struct ViewTag Q_DECLARE_METATYPE(ViewTag); -D3D11PipelineStateViewer::D3D11PipelineStateViewer(CaptureContext &ctx, PipelineStateViewer &common, - QWidget *parent) +D3D11PipelineStateViewer::D3D11PipelineStateViewer(ICaptureContext &ctx, + PipelineStateViewer &common, QWidget *parent) : QFrame(parent), ui(new Ui::D3D11PipelineStateViewer), m_Ctx(ctx), m_Common(common) { ui->setupUi(this); @@ -121,7 +117,7 @@ D3D11PipelineStateViewer::D3D11PipelineStateViewer(CaptureContext &ctx, Pipeline QObject::connect(b, &QToolButton::clicked, this, &D3D11PipelineStateViewer::shaderView_clicked); for(RDLabel *b : shaderLabels) - QObject::connect(b, &RDLabel::clicked, this, &D3D11PipelineStateViewer::shaderView_clicked); + QObject::connect(b, &RDLabel::clicked, [this](QMouseEvent *) { shaderView_clicked(); }); for(QToolButton *b : editButtons) QObject::connect(b, &QToolButton::clicked, this, &D3D11PipelineStateViewer::shaderEdit_clicked); @@ -434,9 +430,9 @@ void D3D11PipelineStateViewer::setViewDetails(QTreeWidgetItem *node, const ViewT if(view.type == ViewTag::OMDepth) { - if(m_Ctx.CurD3D11PipelineState.m_OM.DepthReadOnly) + if(m_Ctx.CurD3D11PipelineState().m_OM.DepthReadOnly) text += tr("Depth component is read-only\n"); - if(m_Ctx.CurD3D11PipelineState.m_OM.StencilReadOnly) + if(m_Ctx.CurD3D11PipelineState().m_OM.StencilReadOnly) text += tr("Stencil component is read-only\n"); } @@ -527,8 +523,8 @@ void D3D11PipelineStateViewer::addResourceRow(const ViewTag &view, const ShaderR bool viewDetails = false; if(view.type == ViewTag::OMDepth) - viewDetails = m_Ctx.CurD3D11PipelineState.m_OM.DepthReadOnly || - m_Ctx.CurD3D11PipelineState.m_OM.StencilReadOnly; + viewDetails = m_Ctx.CurD3D11PipelineState().m_OM.DepthReadOnly || + m_Ctx.CurD3D11PipelineState().m_OM.StencilReadOnly; bool filledSlot = (r.Resource != ResourceId()); bool usedSlot = (shaderInput); @@ -683,23 +679,23 @@ const D3D11Pipe::Shader *D3D11PipelineStateViewer::stageForSender(QWidget *widge while(widget) { if(widget == ui->stagesTabs->widget(0)) - return &m_Ctx.CurD3D11PipelineState.m_VS; + return &m_Ctx.CurD3D11PipelineState().m_VS; if(widget == ui->stagesTabs->widget(1)) - return &m_Ctx.CurD3D11PipelineState.m_VS; + return &m_Ctx.CurD3D11PipelineState().m_VS; if(widget == ui->stagesTabs->widget(2)) - return &m_Ctx.CurD3D11PipelineState.m_HS; + return &m_Ctx.CurD3D11PipelineState().m_HS; if(widget == ui->stagesTabs->widget(3)) - return &m_Ctx.CurD3D11PipelineState.m_DS; + return &m_Ctx.CurD3D11PipelineState().m_DS; if(widget == ui->stagesTabs->widget(4)) - return &m_Ctx.CurD3D11PipelineState.m_GS; + return &m_Ctx.CurD3D11PipelineState().m_GS; if(widget == ui->stagesTabs->widget(5)) - return &m_Ctx.CurD3D11PipelineState.m_PS; + return &m_Ctx.CurD3D11PipelineState().m_PS; if(widget == ui->stagesTabs->widget(6)) - return &m_Ctx.CurD3D11PipelineState.m_PS; + return &m_Ctx.CurD3D11PipelineState().m_PS; if(widget == ui->stagesTabs->widget(7)) - return &m_Ctx.CurD3D11PipelineState.m_PS; + return &m_Ctx.CurD3D11PipelineState().m_PS; if(widget == ui->stagesTabs->widget(8)) - return &m_Ctx.CurD3D11PipelineState.m_CS; + return &m_Ctx.CurD3D11PipelineState().m_CS; widget = widget->parentWidget(); } @@ -1037,7 +1033,7 @@ void D3D11PipelineStateViewer::setState() return; } - const D3D11Pipe::State &state = m_Ctx.CurD3D11PipelineState; + const D3D11Pipe::State &state = m_Ctx.CurD3D11PipelineState(); const DrawcallDescription *draw = m_Ctx.CurDrawcall(); const QPixmap &tick = Pixmaps::tick(); @@ -1729,22 +1725,15 @@ void D3D11PipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int { if(tex->resType == TextureDim::Buffer) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewTextureAsBuffer(0, 0, tex->ID); - viewer->ViewTexture(0, 0, tex->ID); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } else { - if(!m_Ctx.hasTextureViewer()) - m_Ctx.showTextureViewer(); - TextureViewer *viewer = m_Ctx.textureViewer(); + if(!m_Ctx.HasTextureViewer()) + m_Ctx.ShowTextureViewer(); + ITextureViewer *viewer = m_Ctx.GetTextureViewer(); viewer->ViewTexture(tex->ID, true); } @@ -1770,12 +1759,12 @@ void D3D11PipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int if(stage->stage == ShaderStage::Geometry) { - for(int i = 0; i < m_Ctx.CurD3D11PipelineState.m_SO.Outputs.count; i++) + for(int i = 0; i < m_Ctx.CurD3D11PipelineState().m_SO.Outputs.count; i++) { - if(buf->ID == m_Ctx.CurD3D11PipelineState.m_SO.Outputs[i].Buffer) + if(buf->ID == m_Ctx.CurD3D11PipelineState().m_SO.Outputs[i].Buffer) { - size -= m_Ctx.CurD3D11PipelineState.m_SO.Outputs[i].Offset; - offs += m_Ctx.CurD3D11PipelineState.m_SO.Outputs[i].Offset; + size -= m_Ctx.CurD3D11PipelineState().m_SO.Outputs[i].Offset; + offs += m_Ctx.CurD3D11PipelineState().m_SO.Outputs[i].Offset; break; } } @@ -1939,18 +1928,9 @@ void D3D11PipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int } } - { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewBuffer(offs, size, view.res.Resource, format); - viewer->ViewBuffer(offs, size, view.res.Resource, format); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); - } + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } @@ -1968,22 +1948,9 @@ void D3D11PipelineStateViewer::cbuffer_itemActivated(QTreeWidgetItem *item, int int cb = tag.value(); - ConstantBufferPreviewer *existing = ConstantBufferPreviewer::has(stage->stage, cb, 0); - if(existing) - { - ToolWindowManager::raiseToolWindow(existing); - return; - } + IConstantBufferPreviewer *prev = m_Ctx.ViewConstantBuffer(stage->stage, cb, 0); - ConstantBufferPreviewer *prev = - new ConstantBufferPreviewer(m_Ctx, stage->stage, cb, 0, m_Ctx.mainWindow()); - - m_Ctx.setupDockWindow(prev); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::RightOf, manager->areaOf(this), 0.3f); - manager->addToolWindow(prev, ref); + m_Ctx.AddDockWindow(prev->Widget(), DockReference::RightOf, this, 0.3f); } void D3D11PipelineStateViewer::on_iaLayouts_itemActivated(QTreeWidgetItem *item, int column) @@ -2001,16 +1968,9 @@ void D3D11PipelineStateViewer::on_iaBuffers_itemActivated(QTreeWidgetItem *item, if(buf.id != ResourceId()) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewBuffer(buf.offset, UINT64_MAX, buf.id); - viewer->ViewBuffer(buf.offset, UINT64_MAX, buf.id); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } } @@ -2019,7 +1979,7 @@ void D3D11PipelineStateViewer::highlightIABind(int slot) { int idx = ((slot + 1) * 21) % 32; // space neighbouring colours reasonably distinctly - const D3D11Pipe::IA &IA = m_Ctx.CurD3D11PipelineState.m_IA; + const D3D11Pipe::IA &IA = m_Ctx.CurD3D11PipelineState().m_IA; QColor col = QColor::fromHslF(float(idx) / 32.0f, 1.0f, 0.95f); @@ -2076,7 +2036,7 @@ void D3D11PipelineStateViewer::on_iaLayouts_mouseMove(QMouseEvent *e) vertex_leave(NULL); - const D3D11Pipe::IA &IA = m_Ctx.CurD3D11PipelineState.m_IA; + const D3D11Pipe::IA &IA = m_Ctx.CurD3D11PipelineState().m_IA; if(idx.isValid()) { @@ -2185,7 +2145,7 @@ void D3D11PipelineStateViewer::shaderView_clicked() QWidget *sender = qobject_cast(QObject::sender()); if(sender == ui->iaBytecode || sender == ui->iaBytecodeViewButton) { - shaderDetails = m_Ctx.CurD3D11PipelineState.m_IA.Bytecode; + shaderDetails = m_Ctx.CurD3D11PipelineState().m_IA.Bytecode; bindMap = NULL; } else @@ -2200,15 +2160,10 @@ void D3D11PipelineStateViewer::shaderView_clicked() shaderStage = stage->stage; } - ShaderViewer *shad = - ShaderViewer::viewShader(m_Ctx, bindMap, shaderDetails, shaderStage, m_Ctx.mainWindow()); + IShaderViewer *shad = + m_Ctx.ViewShader(bindMap, shaderDetails, shaderStage, m_Ctx.GetMainWindow()->Widget()); - m_Ctx.setupDockWindow(shad); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(shad, ref); + m_Ctx.AddDockWindow(shad->Widget(), DockReference::AddTo, this); } void D3D11PipelineStateViewer::shaderEdit_clicked() @@ -2268,7 +2223,7 @@ void D3D11PipelineStateViewer::on_exportHTML_clicked() void D3D11PipelineStateViewer::on_meshView_clicked() { - if(!m_Ctx.hasMeshPreview()) - m_Ctx.showMeshPreview(); - ToolWindowManager::raiseToolWindow(m_Ctx.meshPreview()); + if(!m_Ctx.HasMeshPreview()) + m_Ctx.ShowMeshPreview(); + ToolWindowManager::raiseToolWindow(m_Ctx.GetMeshPreview()->Widget()); } diff --git a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.h b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.h index f20f6d164..89ca376c6 100644 --- a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.h +++ b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.h @@ -42,14 +42,15 @@ class D3D11PipelineStateViewer : public QFrame, public ILogViewerForm Q_OBJECT public: - explicit D3D11PipelineStateViewer(CaptureContext &ctx, PipelineStateViewer &common, + explicit D3D11PipelineStateViewer(ICaptureContext &ctx, PipelineStateViewer &common, QWidget *parent = 0); ~D3D11PipelineStateViewer(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID); + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override; private slots: // automatic slots @@ -74,7 +75,7 @@ private slots: private: Ui::D3D11PipelineStateViewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; PipelineStateViewer &m_Common; void setShaderState(const D3D11Pipe::Shader &stage, QLabel *shader, RDTreeWidget *tex, diff --git a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp index 4de3a7ddd..140550cd8 100644 --- a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp @@ -24,14 +24,10 @@ #include "D3D12PipelineStateViewer.h" #include +#include #include #include "3rdparty/toolwindowmanager/ToolWindowManager.h" #include "Code/Resources.h" -#include "Windows/BufferViewer.h" -#include "Windows/ConstantBufferPreviewer.h" -#include "Windows/MainWindow.h" -#include "Windows/ShaderViewer.h" -#include "Windows/TextureViewer.h" #include "PipelineStateViewer.h" #include "ui_D3D12PipelineStateViewer.h" @@ -98,8 +94,8 @@ struct ViewTag Q_DECLARE_METATYPE(ViewTag); -D3D12PipelineStateViewer::D3D12PipelineStateViewer(CaptureContext &ctx, PipelineStateViewer &common, - QWidget *parent) +D3D12PipelineStateViewer::D3D12PipelineStateViewer(ICaptureContext &ctx, + PipelineStateViewer &common, QWidget *parent) : QFrame(parent), ui(new Ui::D3D12PipelineStateViewer), m_Ctx(ctx), m_Common(common) { ui->setupUi(this); @@ -147,7 +143,7 @@ D3D12PipelineStateViewer::D3D12PipelineStateViewer(CaptureContext &ctx, Pipeline QObject::connect(b, &QToolButton::clicked, this, &D3D12PipelineStateViewer::shaderView_clicked); for(RDLabel *b : shaderLabels) - QObject::connect(b, &RDLabel::clicked, this, &D3D12PipelineStateViewer::shaderView_clicked); + QObject::connect(b, &RDLabel::clicked, [this](QMouseEvent *) { shaderView_clicked(); }); for(QToolButton *b : editButtons) QObject::connect(b, &QToolButton::clicked, this, &D3D12PipelineStateViewer::shaderEdit_clicked); @@ -462,7 +458,7 @@ void D3D12PipelineStateViewer::setViewDetails(QTreeWidgetItem *node, const ViewT bool viewdetails = false; - for(const D3D12Pipe::ResourceData &im : m_Ctx.CurD3D12PipelineState.Resources) + for(const D3D12Pipe::ResourceData &im : m_Ctx.CurD3D12PipelineState().Resources) { if(im.id == tex->ID) { @@ -482,9 +478,9 @@ void D3D12PipelineStateViewer::setViewDetails(QTreeWidgetItem *node, const ViewT if(view.space == ViewTag::OMDepth) { - if(m_Ctx.CurD3D12PipelineState.m_OM.DepthReadOnly) + if(m_Ctx.CurD3D12PipelineState().m_OM.DepthReadOnly) text += tr("Depth component is read-only\n"); - if(m_Ctx.CurD3D12PipelineState.m_OM.StencilReadOnly) + if(m_Ctx.CurD3D12PipelineState().m_OM.StencilReadOnly) text += tr("Stencil component is read-only\n"); } @@ -541,7 +537,7 @@ void D3D12PipelineStateViewer::setViewDetails(QTreeWidgetItem *node, const ViewT const D3D12Pipe::View &res = view.res; - for(const D3D12Pipe::ResourceData &im : m_Ctx.CurD3D12PipelineState.Resources) + for(const D3D12Pipe::ResourceData &im : m_Ctx.CurD3D12PipelineState().Resources) { if(im.id == buf->ID) { @@ -624,8 +620,8 @@ void D3D12PipelineStateViewer::addResourceRow(const ViewTag &view, const D3D12Pi bool viewDetails = false; if(view.space == ViewTag::OMDepth) - viewDetails = m_Ctx.CurD3D12PipelineState.m_OM.DepthReadOnly || - m_Ctx.CurD3D12PipelineState.m_OM.StencilReadOnly; + viewDetails = m_Ctx.CurD3D12PipelineState().m_OM.DepthReadOnly || + m_Ctx.CurD3D12PipelineState().m_OM.StencilReadOnly; QString rootel = r.Immediate ? QString("#%1 Direct").arg(r.RootElement) : QString("#%1 Table[%2]").arg(r.RootElement).arg(r.TableIndex); @@ -781,23 +777,23 @@ const D3D12Pipe::Shader *D3D12PipelineStateViewer::stageForSender(QWidget *widge while(widget) { if(widget == ui->stagesTabs->widget(0)) - return &m_Ctx.CurD3D12PipelineState.m_VS; + return &m_Ctx.CurD3D12PipelineState().m_VS; if(widget == ui->stagesTabs->widget(1)) - return &m_Ctx.CurD3D12PipelineState.m_VS; + return &m_Ctx.CurD3D12PipelineState().m_VS; if(widget == ui->stagesTabs->widget(2)) - return &m_Ctx.CurD3D12PipelineState.m_HS; + return &m_Ctx.CurD3D12PipelineState().m_HS; if(widget == ui->stagesTabs->widget(3)) - return &m_Ctx.CurD3D12PipelineState.m_DS; + return &m_Ctx.CurD3D12PipelineState().m_DS; if(widget == ui->stagesTabs->widget(4)) - return &m_Ctx.CurD3D12PipelineState.m_GS; + return &m_Ctx.CurD3D12PipelineState().m_GS; if(widget == ui->stagesTabs->widget(5)) - return &m_Ctx.CurD3D12PipelineState.m_PS; + return &m_Ctx.CurD3D12PipelineState().m_PS; if(widget == ui->stagesTabs->widget(6)) - return &m_Ctx.CurD3D12PipelineState.m_PS; + return &m_Ctx.CurD3D12PipelineState().m_PS; if(widget == ui->stagesTabs->widget(7)) - return &m_Ctx.CurD3D12PipelineState.m_PS; + return &m_Ctx.CurD3D12PipelineState().m_PS; if(widget == ui->stagesTabs->widget(8)) - return &m_Ctx.CurD3D12PipelineState.m_CS; + return &m_Ctx.CurD3D12PipelineState().m_CS; widget = widget->parentWidget(); } @@ -879,12 +875,12 @@ void D3D12PipelineStateViewer::setShaderState(const D3D12Pipe::Shader &stage, QL RDTreeWidget *cbuffers, RDTreeWidget *uavs) { ShaderReflection *shaderDetails = stage.ShaderDetails; - const D3D12Pipe::State &state = m_Ctx.CurD3D12PipelineState; + const D3D12Pipe::State &state = m_Ctx.CurD3D12PipelineState(); if(stage.Object == ResourceId()) shader->setText(tr("Unbound Shader")); else if(state.customName) - shader->setText(ToQStr(state.name) + " - " + m_Ctx.CurPipelineState.Abbrev(stage.stage)); + shader->setText(ToQStr(state.name) + " - " + m_Ctx.CurPipelineState().Abbrev(stage.stage)); else shader->setText(ToQStr(state.name) + " - " + ToQStr(stage.stage, GraphicsAPI::D3D12) + " Shader"); @@ -1175,7 +1171,7 @@ void D3D12PipelineStateViewer::setState() return; } - const D3D12Pipe::State &state = m_Ctx.CurD3D12PipelineState; + const D3D12Pipe::State &state = m_Ctx.CurD3D12PipelineState(); const DrawcallDescription *draw = m_Ctx.CurDrawcall(); const QPixmap &tick = Pixmaps::tick(); @@ -1705,22 +1701,15 @@ void D3D12PipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int { if(tex->resType == TextureDim::Buffer) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewTextureAsBuffer(0, 0, tex->ID); - viewer->ViewTexture(0, 0, tex->ID); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } else { - if(!m_Ctx.hasTextureViewer()) - m_Ctx.showTextureViewer(); - TextureViewer *viewer = m_Ctx.textureViewer(); + if(!m_Ctx.HasTextureViewer()) + m_Ctx.ShowTextureViewer(); + ITextureViewer *viewer = m_Ctx.GetTextureViewer(); viewer->ViewTexture(tex->ID, true); } @@ -1744,14 +1733,14 @@ void D3D12PipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int { // last thing, see if it's a streamout buffer - if(stage == &m_Ctx.CurD3D12PipelineState.m_GS) + if(stage == &m_Ctx.CurD3D12PipelineState().m_GS) { - for(int i = 0; i < m_Ctx.CurD3D12PipelineState.m_SO.Outputs.count; i++) + for(int i = 0; i < m_Ctx.CurD3D12PipelineState().m_SO.Outputs.count; i++) { - if(buf->ID == m_Ctx.CurD3D12PipelineState.m_SO.Outputs[i].Buffer) + if(buf->ID == m_Ctx.CurD3D12PipelineState().m_SO.Outputs[i].Buffer) { - size -= m_Ctx.CurD3D12PipelineState.m_SO.Outputs[i].Offset; - offs += m_Ctx.CurD3D12PipelineState.m_SO.Outputs[i].Offset; + size -= m_Ctx.CurD3D12PipelineState().m_SO.Outputs[i].Offset; + offs += m_Ctx.CurD3D12PipelineState().m_SO.Outputs[i].Offset; break; } } @@ -1887,18 +1876,9 @@ void D3D12PipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int } } - { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewBuffer(offs, size, view.res.Resource, format); - viewer->ViewBuffer(offs, size, view.res.Resource, format); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); - } + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } @@ -1919,38 +1899,18 @@ void D3D12PipelineStateViewer::cbuffer_itemActivated(QTreeWidgetItem *item, int if(cb.idx == ~0U) { // unused cbuffer, open regular buffer viewer - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); - const D3D12Pipe::CBuffer &buf = stage->Spaces[cb.space].ConstantBuffers[cb.reg]; - viewer->ViewBuffer(buf.Offset, buf.ByteSize, buf.Buffer); + IBufferViewer *viewer = m_Ctx.ViewBuffer(buf.Offset, buf.ByteSize, buf.Buffer); - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); return; } - ConstantBufferPreviewer *existing = ConstantBufferPreviewer::has(stage->stage, cb.idx, 0); - if(existing) - { - ToolWindowManager::raiseToolWindow(existing); - return; - } + IConstantBufferPreviewer *prev = m_Ctx.ViewConstantBuffer(stage->stage, cb.idx, 0); - ConstantBufferPreviewer *prev = - new ConstantBufferPreviewer(m_Ctx, stage->stage, cb.idx, 0, m_Ctx.mainWindow()); - - m_Ctx.setupDockWindow(prev); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::RightOf, manager->areaOf(this), 0.3f); - manager->addToolWindow(prev, ref); + m_Ctx.AddDockWindow(prev->Widget(), DockReference::RightOf, this, 0.3f); } void D3D12PipelineStateViewer::on_iaLayouts_itemActivated(QTreeWidgetItem *item, int column) @@ -1968,16 +1928,9 @@ void D3D12PipelineStateViewer::on_iaBuffers_itemActivated(QTreeWidgetItem *item, if(buf.id != ResourceId()) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewBuffer(buf.offset, UINT64_MAX, buf.id); - viewer->ViewBuffer(buf.offset, UINT64_MAX, buf.id); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } } @@ -1986,7 +1939,7 @@ void D3D12PipelineStateViewer::highlightIABind(int slot) { int idx = ((slot + 1) * 21) % 32; // space neighbouring colours reasonably distinctly - const D3D12Pipe::IA &IA = m_Ctx.CurD3D12PipelineState.m_IA; + const D3D12Pipe::IA &IA = m_Ctx.CurD3D12PipelineState().m_IA; QColor col = QColor::fromHslF(float(idx) / 32.0f, 1.0f, 0.95f); @@ -2043,7 +1996,7 @@ void D3D12PipelineStateViewer::on_iaLayouts_mouseMove(QMouseEvent *e) vertex_leave(NULL); - const D3D12Pipe::IA &IA = m_Ctx.CurD3D12PipelineState.m_IA; + const D3D12Pipe::IA &IA = m_Ctx.CurD3D12PipelineState().m_IA; if(idx.isValid()) { @@ -2151,15 +2104,10 @@ void D3D12PipelineStateViewer::shaderView_clicked() if(stage == NULL || stage->Object == ResourceId()) return; - ShaderViewer *shad = ShaderViewer::viewShader( - m_Ctx, &stage->BindpointMapping, stage->ShaderDetails, stage->stage, m_Ctx.mainWindow()); + IShaderViewer *shad = m_Ctx.ViewShader(&stage->BindpointMapping, stage->ShaderDetails, + stage->stage, m_Ctx.GetMainWindow()->Widget()); - m_Ctx.setupDockWindow(shad); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(shad, ref); + m_Ctx.AddDockWindow(shad->Widget(), DockReference::AddTo, this); } void D3D12PipelineStateViewer::shaderEdit_clicked() @@ -2219,7 +2167,7 @@ void D3D12PipelineStateViewer::on_exportHTML_clicked() void D3D12PipelineStateViewer::on_meshView_clicked() { - if(!m_Ctx.hasMeshPreview()) - m_Ctx.showMeshPreview(); - ToolWindowManager::raiseToolWindow(m_Ctx.meshPreview()); + if(!m_Ctx.HasMeshPreview()) + m_Ctx.ShowMeshPreview(); + ToolWindowManager::raiseToolWindow(m_Ctx.GetMeshPreview()->Widget()); } diff --git a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.h b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.h index e093b1cc0..fcfc15e82 100644 --- a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.h +++ b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.h @@ -42,14 +42,15 @@ class D3D12PipelineStateViewer : public QFrame, public ILogViewerForm Q_OBJECT public: - explicit D3D12PipelineStateViewer(CaptureContext &ctx, PipelineStateViewer &common, + explicit D3D12PipelineStateViewer(ICaptureContext &ctx, PipelineStateViewer &common, QWidget *parent = 0); ~D3D12PipelineStateViewer(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID); + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override; private slots: // automatic slots @@ -73,7 +74,7 @@ private slots: private: Ui::D3D12PipelineStateViewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; PipelineStateViewer &m_Common; void setShaderState(const D3D12Pipe::Shader &stage, QLabel *shader, RDTreeWidget *tex, diff --git a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp index c3c5cf33d..592922a9e 100644 --- a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp @@ -24,14 +24,10 @@ #include "GLPipelineStateViewer.h" #include +#include #include #include "3rdparty/toolwindowmanager/ToolWindowManager.h" #include "Code/Resources.h" -#include "Windows/BufferViewer.h" -#include "Windows/ConstantBufferPreviewer.h" -#include "Windows/MainWindow.h" -#include "Windows/ShaderViewer.h" -#include "Windows/TextureViewer.h" #include "PipelineStateViewer.h" #include "ui_GLPipelineStateViewer.h" @@ -74,7 +70,7 @@ struct ReadWriteTag Q_DECLARE_METATYPE(ReadWriteTag); -GLPipelineStateViewer::GLPipelineStateViewer(CaptureContext &ctx, PipelineStateViewer &common, +GLPipelineStateViewer::GLPipelineStateViewer(ICaptureContext &ctx, PipelineStateViewer &common, QWidget *parent) : QFrame(parent), ui(new Ui::GLPipelineStateViewer), m_Ctx(ctx), m_Common(common) { @@ -127,7 +123,7 @@ GLPipelineStateViewer::GLPipelineStateViewer(CaptureContext &ctx, PipelineStateV QObject::connect(b, &QToolButton::clicked, this, &GLPipelineStateViewer::shaderView_clicked); for(RDLabel *b : shaderLabels) - QObject::connect(b, &RDLabel::clicked, this, &GLPipelineStateViewer::shaderView_clicked); + QObject::connect(b, &RDLabel::clicked, [this](QMouseEvent *) { shaderView_clicked(); }); for(QToolButton *b : editButtons) QObject::connect(b, &QToolButton::clicked, this, &GLPipelineStateViewer::shaderEdit_clicked); @@ -419,23 +415,23 @@ const GLPipe::Shader *GLPipelineStateViewer::stageForSender(QWidget *widget) while(widget) { if(widget == ui->stagesTabs->widget(0)) - return &m_Ctx.CurGLPipelineState.m_VS; + return &m_Ctx.CurGLPipelineState().m_VS; if(widget == ui->stagesTabs->widget(1)) - return &m_Ctx.CurGLPipelineState.m_VS; + return &m_Ctx.CurGLPipelineState().m_VS; if(widget == ui->stagesTabs->widget(2)) - return &m_Ctx.CurGLPipelineState.m_TCS; + return &m_Ctx.CurGLPipelineState().m_TCS; if(widget == ui->stagesTabs->widget(3)) - return &m_Ctx.CurGLPipelineState.m_TES; + return &m_Ctx.CurGLPipelineState().m_TES; if(widget == ui->stagesTabs->widget(4)) - return &m_Ctx.CurGLPipelineState.m_GS; + return &m_Ctx.CurGLPipelineState().m_GS; if(widget == ui->stagesTabs->widget(5)) - return &m_Ctx.CurGLPipelineState.m_FS; + return &m_Ctx.CurGLPipelineState().m_FS; if(widget == ui->stagesTabs->widget(6)) - return &m_Ctx.CurGLPipelineState.m_FS; + return &m_Ctx.CurGLPipelineState().m_FS; if(widget == ui->stagesTabs->widget(7)) - return &m_Ctx.CurGLPipelineState.m_FS; + return &m_Ctx.CurGLPipelineState().m_FS; if(widget == ui->stagesTabs->widget(8)) - return &m_Ctx.CurGLPipelineState.m_CS; + return &m_Ctx.CurGLPipelineState().m_CS; widget = widget->parentWidget(); } @@ -538,7 +534,7 @@ void GLPipelineStateViewer::setShaderState(const GLPipe::Shader &stage, QLabel * { ShaderReflection *shaderDetails = stage.ShaderDetails; const ShaderBindpointMapping &mapping = stage.BindpointMapping; - const GLPipe::State &state = m_Ctx.CurGLPipelineState; + const GLPipe::State &state = m_Ctx.CurGLPipelineState(); const QIcon &action = Icons::action(); const QIcon &action_hover = Icons::action_hover(); @@ -1049,7 +1045,7 @@ void GLPipelineStateViewer::setState() return; } - const GLPipe::State &state = m_Ctx.CurGLPipelineState; + const GLPipe::State &state = m_Ctx.CurGLPipelineState(); const DrawcallDescription *draw = m_Ctx.CurDrawcall(); bool showDisabled = ui->showDisabled->isChecked(); @@ -1955,22 +1951,15 @@ void GLPipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int co { if(tex->resType == TextureDim::Buffer) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewTextureAsBuffer(0, 0, tex->ID); - viewer->ViewTexture(0, 0, tex->ID); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } else { - if(!m_Ctx.hasTextureViewer()) - m_Ctx.showTextureViewer(); - TextureViewer *viewer = m_Ctx.textureViewer(); + if(!m_Ctx.HasTextureViewer()) + m_Ctx.ShowTextureViewer(); + ITextureViewer *viewer = m_Ctx.GetTextureViewer(); viewer->ViewTexture(tex->ID, true); } @@ -2022,16 +2011,9 @@ void GLPipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int co if(buf.ID != ResourceId()) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewBuffer(buf.offset, buf.size, buf.ID, format); - viewer->ViewBuffer(buf.offset, buf.size, buf.ID, format); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } } @@ -2050,22 +2032,9 @@ void GLPipelineStateViewer::ubo_itemActivated(QTreeWidgetItem *item, int column) int cb = tag.value(); - ConstantBufferPreviewer *existing = ConstantBufferPreviewer::has(stage->stage, cb, 0); - if(existing) - { - ToolWindowManager::raiseToolWindow(existing); - return; - } + IConstantBufferPreviewer *prev = m_Ctx.ViewConstantBuffer(stage->stage, cb, 0); - ConstantBufferPreviewer *prev = - new ConstantBufferPreviewer(m_Ctx, stage->stage, cb, 0, m_Ctx.mainWindow()); - - m_Ctx.setupDockWindow(prev); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::RightOf, manager->areaOf(this), 0.3f); - manager->addToolWindow(prev, ref); + m_Ctx.AddDockWindow(prev->Widget(), DockReference::RightOf, this, 0.3f); } void GLPipelineStateViewer::on_viAttrs_itemActivated(QTreeWidgetItem *item, int column) @@ -2083,16 +2052,9 @@ void GLPipelineStateViewer::on_viBuffers_itemActivated(QTreeWidgetItem *item, in if(buf.id != ResourceId()) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewBuffer(buf.offset, UINT64_MAX, buf.id); - viewer->ViewBuffer(buf.offset, UINT64_MAX, buf.id); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } } @@ -2101,7 +2063,7 @@ void GLPipelineStateViewer::highlightIABind(int slot) { int idx = ((slot + 1) * 21) % 32; // space neighbouring colours reasonably distinctly - const GLPipe::VertexInput &VI = m_Ctx.CurGLPipelineState.m_VtxIn; + const GLPipe::VertexInput &VI = m_Ctx.CurGLPipelineState().m_VtxIn; QColor col = QColor::fromHslF(float(idx) / 32.0f, 1.0f, 0.95f); @@ -2152,7 +2114,7 @@ void GLPipelineStateViewer::on_viAttrs_mouseMove(QMouseEvent *e) vertex_leave(NULL); - const GLPipe::VertexInput &VI = m_Ctx.CurGLPipelineState.m_VtxIn; + const GLPipe::VertexInput &VI = m_Ctx.CurGLPipelineState().m_VtxIn; if(idx.isValid()) { @@ -2252,15 +2214,10 @@ void GLPipelineStateViewer::shaderView_clicked() ShaderReflection *shaderDetails = stage->ShaderDetails; - ShaderViewer *shad = ShaderViewer::viewShader(m_Ctx, &stage->BindpointMapping, shaderDetails, - stage->stage, m_Ctx.mainWindow()); + IShaderViewer *shad = m_Ctx.ViewShader(&stage->BindpointMapping, shaderDetails, stage->stage, + m_Ctx.GetMainWindow()->Widget()); - m_Ctx.setupDockWindow(shad); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(shad, ref); + m_Ctx.AddDockWindow(shad->Widget(), DockReference::AddTo, this); } void GLPipelineStateViewer::shaderEdit_clicked() @@ -2320,7 +2277,7 @@ void GLPipelineStateViewer::on_exportHTML_clicked() void GLPipelineStateViewer::on_meshView_clicked() { - if(!m_Ctx.hasMeshPreview()) - m_Ctx.showMeshPreview(); - ToolWindowManager::raiseToolWindow(m_Ctx.meshPreview()); + if(!m_Ctx.HasMeshPreview()) + m_Ctx.ShowMeshPreview(); + ToolWindowManager::raiseToolWindow(m_Ctx.GetMeshPreview()->Widget()); } diff --git a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.h b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.h index e39bf40fd..315358473 100644 --- a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.h +++ b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.h @@ -41,14 +41,15 @@ class GLPipelineStateViewer : public QFrame, public ILogViewerForm Q_OBJECT public: - explicit GLPipelineStateViewer(CaptureContext &ctx, PipelineStateViewer &common, + explicit GLPipelineStateViewer(ICaptureContext &ctx, PipelineStateViewer &common, QWidget *parent = 0); ~GLPipelineStateViewer(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID); + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override; private slots: // automatic slots @@ -72,7 +73,7 @@ private slots: private: Ui::GLPipelineStateViewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; PipelineStateViewer &m_Common; enum class GLReadWriteType diff --git a/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp index 5dda58f49..06c3d83fd 100644 --- a/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp @@ -24,15 +24,13 @@ #include "PipelineStateViewer.h" #include "3rdparty/toolwindowmanager/ToolWindowManager.h" -#include "Windows/MainWindow.h" -#include "Windows/ShaderViewer.h" #include "D3D11PipelineStateViewer.h" #include "D3D12PipelineStateViewer.h" #include "GLPipelineStateViewer.h" #include "VulkanPipelineStateViewer.h" #include "ui_PipelineStateViewer.h" -PipelineStateViewer::PipelineStateViewer(CaptureContext &ctx, QWidget *parent) +PipelineStateViewer::PipelineStateViewer(ICaptureContext &ctx, QWidget *parent) : QFrame(parent), ui(new Ui::PipelineStateViewer), m_Ctx(ctx) { ui->setupUi(this); @@ -53,7 +51,7 @@ PipelineStateViewer::~PipelineStateViewer() { reset(); - m_Ctx.windowClosed(this); + m_Ctx.BuiltinWindowClosed(this); m_Ctx.RemoveLogViewer(this); delete ui; @@ -82,7 +80,7 @@ void PipelineStateViewer::OnLogfileClosed() void PipelineStateViewer::OnEventChanged(uint32_t eventID) { - if(m_Ctx.CurPipelineState.DefaultType != m_Ctx.APIProps().pipelineType) + if(m_Ctx.CurPipelineState().DefaultType != m_Ctx.APIProps().pipelineType) OnLogfileLoaded(); if(m_Current) @@ -146,7 +144,7 @@ void PipelineStateViewer::setToD3D11() m_D3D11 = new D3D11PipelineStateViewer(m_Ctx, *this, this); ui->layout->addWidget(m_D3D11); m_Current = m_D3D11; - m_Ctx.CurPipelineState.DefaultType = GraphicsAPI::D3D11; + m_Ctx.CurPipelineState().DefaultType = GraphicsAPI::D3D11; } void PipelineStateViewer::setToD3D12() @@ -159,7 +157,7 @@ void PipelineStateViewer::setToD3D12() m_D3D12 = new D3D12PipelineStateViewer(m_Ctx, *this, this); ui->layout->addWidget(m_D3D12); m_Current = m_D3D12; - m_Ctx.CurPipelineState.DefaultType = GraphicsAPI::D3D12; + m_Ctx.CurPipelineState().DefaultType = GraphicsAPI::D3D12; } void PipelineStateViewer::setToGL() @@ -172,7 +170,7 @@ void PipelineStateViewer::setToGL() m_GL = new GLPipelineStateViewer(m_Ctx, *this, this); ui->layout->addWidget(m_GL); m_Current = m_GL; - m_Ctx.CurPipelineState.DefaultType = GraphicsAPI::OpenGL; + m_Ctx.CurPipelineState().DefaultType = GraphicsAPI::OpenGL; } void PipelineStateViewer::setToVulkan() @@ -185,7 +183,7 @@ void PipelineStateViewer::setToVulkan() m_Vulkan = new VulkanPipelineStateViewer(m_Ctx, *this, this); ui->layout->addWidget(m_Vulkan); m_Current = m_Vulkan; - m_Ctx.CurPipelineState.DefaultType = GraphicsAPI::Vulkan; + m_Ctx.CurPipelineState().DefaultType = GraphicsAPI::Vulkan; } bool PipelineStateViewer::PrepareShaderEditing(const ShaderReflection *shaderDetails, @@ -227,11 +225,11 @@ void PipelineStateViewer::EditShader(ShaderStage shaderType, ResourceId id, const ShaderReflection *shaderDetails, const QString &entryFunc, const QStringMap &files, const QString &mainfile) { - ShaderViewer *sv = ShaderViewer::editShader( - m_Ctx, false, entryFunc, files, + IShaderViewer *sv = m_Ctx.EditShader( + false, entryFunc, files, // save callback [entryFunc, mainfile, shaderType, id, shaderDetails]( - CaptureContext *ctx, ShaderViewer *viewer, const QStringMap &updatedfiles) { + ICaptureContext *ctx, IShaderViewer *viewer, const QStringMap &updatedfiles) { QString compileSource = updatedfiles[mainfile]; // try and match up #includes against the files that we have. This isn't always @@ -274,7 +272,7 @@ void PipelineStateViewer::EditShader(ShaderStage shaderType, ResourceId id, if(compileSource[ws] != '<' && compileSource[ws] != '"') { - viewer->showErrors("Invalid #include directive found:\r\n" + line); + viewer->ShowErrors("Invalid #include directive found:\r\n" + line); return; } @@ -283,7 +281,7 @@ void PipelineStateViewer::EditShader(ShaderStage shaderType, ResourceId id, if(end == -1) { - viewer->showErrors("Invalid #include directive found:\r\n" + line); + viewer->ShowErrors("Invalid #include directive found:\r\n" + line); return; } @@ -336,7 +334,7 @@ void PipelineStateViewer::EditShader(ShaderStage shaderType, ResourceId id, ResourceId to = r->BuildTargetShader( entryFunc.toUtf8().data(), compileSource.toUtf8().data(), flags, shaderType, &errs); - GUIInvoke::call([viewer, errs]() { viewer->showErrors(ToQStr(errs)); }); + GUIInvoke::call([viewer, errs]() { viewer->ShowErrors(ToQStr(errs)); }); if(to == ResourceId()) { r->RemoveReplacement(from); @@ -351,7 +349,7 @@ void PipelineStateViewer::EditShader(ShaderStage shaderType, ResourceId id, }, // Close Callback - [id](CaptureContext *ctx) { + [id](ICaptureContext *ctx) { // remove the replacement on close (we could make this more sophisticated if there // was a place to control replaced resources/shaders). ctx->Renderer().AsyncInvoke([ctx, id](IReplayRenderer *r) { @@ -359,14 +357,9 @@ void PipelineStateViewer::EditShader(ShaderStage shaderType, ResourceId id, GUIInvoke::call([ctx] { ctx->RefreshStatus(); }); }); }, - m_Ctx.mainWindow()); + m_Ctx.GetMainWindow()->Widget()); - m_Ctx.setupDockWindow(sv); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(sv, ref); + m_Ctx.AddDockWindow(sv->Widget(), DockReference::AddTo, this); } bool PipelineStateViewer::SaveShaderFile(const ShaderReflection *shader) @@ -376,15 +369,15 @@ bool PipelineStateViewer::SaveShaderFile(const ShaderReflection *shader) QString filter; - if(m_Ctx.CurPipelineState.IsLogD3D11() || m_Ctx.CurPipelineState.IsLogD3D12()) + if(m_Ctx.CurPipelineState().IsLogD3D11() || m_Ctx.CurPipelineState().IsLogD3D12()) { filter = tr("DXBC Shader files (*.dxbc)"); } - else if(m_Ctx.CurPipelineState.IsLogGL()) + else if(m_Ctx.CurPipelineState().IsLogGL()) { filter = tr("GLSL files (*.glsl)"); } - else if(m_Ctx.CurPipelineState.IsLogVK()) + else if(m_Ctx.CurPipelineState().IsLogVK()) { filter = tr("SPIR-V files (*.spv)"); } diff --git a/qrenderdoc/Windows/PipelineState/PipelineStateViewer.h b/qrenderdoc/Windows/PipelineState/PipelineStateViewer.h index 1aea264e4..90473f919 100644 --- a/qrenderdoc/Windows/PipelineState/PipelineStateViewer.h +++ b/qrenderdoc/Windows/PipelineState/PipelineStateViewer.h @@ -37,25 +37,29 @@ class D3D12PipelineStateViewer; class GLPipelineStateViewer; class VulkanPipelineStateViewer; -class PipelineStateViewer : public QFrame, public ILogViewerForm +class PipelineStateViewer : public QFrame, public IPipelineStateViewer, public ILogViewerForm { Q_OBJECT Q_PROPERTY(QVariant persistData READ persistData WRITE setPersistData DESIGNABLE false SCRIPTABLE false) public: - explicit PipelineStateViewer(CaptureContext &ctx, QWidget *parent = 0); + explicit PipelineStateViewer(ICaptureContext &ctx, QWidget *parent = 0); ~PipelineStateViewer(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID); + // IPipelineStateViewer + QWidget *Widget() override { return this; } + bool SaveShaderFile(const ShaderReflection *shader) override; + + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override; QVariant persistData(); void setPersistData(const QVariant &persistData); - bool SaveShaderFile(const ShaderReflection *shader); bool PrepareShaderEditing(const ShaderReflection *shaderDetails, QString &entryFunc, QStringMap &files, QString &mainfile); void EditShader(ShaderStage shaderType, ResourceId id, const ShaderReflection *shaderDetails, @@ -63,7 +67,7 @@ public: private: Ui::PipelineStateViewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; void setToD3D11(); void setToD3D12(); diff --git a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp index 9de97a2e7..c7e74b7a5 100644 --- a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp @@ -24,14 +24,10 @@ #include "VulkanPipelineStateViewer.h" #include +#include #include #include "3rdparty/toolwindowmanager/ToolWindowManager.h" #include "Code/Resources.h" -#include "Windows/BufferViewer.h" -#include "Windows/ConstantBufferPreviewer.h" -#include "Windows/MainWindow.h" -#include "Windows/ShaderViewer.h" -#include "Windows/TextureViewer.h" #include "PipelineStateViewer.h" #include "ui_VulkanPipelineStateViewer.h" @@ -92,7 +88,7 @@ struct BufferTag Q_DECLARE_METATYPE(BufferTag); -VulkanPipelineStateViewer::VulkanPipelineStateViewer(CaptureContext &ctx, +VulkanPipelineStateViewer::VulkanPipelineStateViewer(ICaptureContext &ctx, PipelineStateViewer &common, QWidget *parent) : QFrame(parent), ui(new Ui::VulkanPipelineStateViewer), m_Ctx(ctx), m_Common(common) { @@ -130,7 +126,7 @@ VulkanPipelineStateViewer::VulkanPipelineStateViewer(CaptureContext &ctx, QObject::connect(b, &QToolButton::clicked, this, &VulkanPipelineStateViewer::shaderView_clicked); for(RDLabel *b : shaderLabels) - QObject::connect(b, &RDLabel::clicked, this, &VulkanPipelineStateViewer::shaderView_clicked); + QObject::connect(b, &RDLabel::clicked, [this](QMouseEvent *) { shaderView_clicked(); }); for(QToolButton *b : editButtons) QObject::connect(b, &QToolButton::clicked, this, &VulkanPipelineStateViewer::shaderEdit_clicked); @@ -368,7 +364,7 @@ void VulkanPipelineStateViewer::setViewDetails(QTreeWidgetItem *node, const bind bool viewdetails = false; { - for(const VKPipe::ImageData &im : m_Ctx.CurVulkanPipelineState.images) + for(const VKPipe::ImageData &im : m_Ctx.CurVulkanPipelineState().images) { if(im.image == tex->ID) { @@ -487,23 +483,23 @@ const VKPipe::Shader *VulkanPipelineStateViewer::stageForSender(QWidget *widget) while(widget) { if(widget == ui->stagesTabs->widget(0)) - return &m_Ctx.CurVulkanPipelineState.m_VS; + return &m_Ctx.CurVulkanPipelineState().m_VS; if(widget == ui->stagesTabs->widget(1)) - return &m_Ctx.CurVulkanPipelineState.m_VS; + return &m_Ctx.CurVulkanPipelineState().m_VS; if(widget == ui->stagesTabs->widget(2)) - return &m_Ctx.CurVulkanPipelineState.m_TCS; + return &m_Ctx.CurVulkanPipelineState().m_TCS; if(widget == ui->stagesTabs->widget(3)) - return &m_Ctx.CurVulkanPipelineState.m_TES; + return &m_Ctx.CurVulkanPipelineState().m_TES; if(widget == ui->stagesTabs->widget(4)) - return &m_Ctx.CurVulkanPipelineState.m_GS; + return &m_Ctx.CurVulkanPipelineState().m_GS; if(widget == ui->stagesTabs->widget(5)) - return &m_Ctx.CurVulkanPipelineState.m_FS; + return &m_Ctx.CurVulkanPipelineState().m_FS; if(widget == ui->stagesTabs->widget(6)) - return &m_Ctx.CurVulkanPipelineState.m_FS; + return &m_Ctx.CurVulkanPipelineState().m_FS; if(widget == ui->stagesTabs->widget(7)) - return &m_Ctx.CurVulkanPipelineState.m_FS; + return &m_Ctx.CurVulkanPipelineState().m_FS; if(widget == ui->stagesTabs->widget(8)) - return &m_Ctx.CurVulkanPipelineState.m_CS; + return &m_Ctx.CurVulkanPipelineState().m_CS; widget = widget->parentWidget(); } @@ -1408,7 +1404,7 @@ void VulkanPipelineStateViewer::setState() m_CombinedImageSamplers.clear(); - const VKPipe::State &state = m_Ctx.CurVulkanPipelineState; + const VKPipe::State &state = m_Ctx.CurVulkanPipelineState(); const DrawcallDescription *draw = m_Ctx.CurDrawcall(); bool showDisabled = ui->showDisabled->isChecked(); @@ -2014,22 +2010,15 @@ void VulkanPipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, in { if(tex->resType == TextureDim::Buffer) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewTextureAsBuffer(0, 0, tex->ID); - viewer->ViewTexture(0, 0, tex->ID); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } else { - if(!m_Ctx.hasTextureViewer()) - m_Ctx.showTextureViewer(); - TextureViewer *viewer = m_Ctx.textureViewer(); + if(!m_Ctx.HasTextureViewer()) + m_Ctx.ShowTextureViewer(); + ITextureViewer *viewer = m_Ctx.GetTextureViewer(); viewer->ViewTexture(tex->ID, true); } @@ -2083,16 +2072,9 @@ void VulkanPipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, in if(buf.ID != ResourceId()) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewBuffer(buf.offset, buf.size, buf.ID, format); - viewer->ViewBuffer(buf.offset, buf.size, buf.ID, format); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } } @@ -2111,23 +2093,9 @@ void VulkanPipelineStateViewer::ubo_itemActivated(QTreeWidgetItem *item, int col CBufferTag cb = tag.value(); - ConstantBufferPreviewer *existing = - ConstantBufferPreviewer::has(stage->stage, cb.slotIdx, cb.arrayIdx); - if(existing != NULL) - { - ToolWindowManager::raiseToolWindow(existing); - return; - } + IConstantBufferPreviewer *prev = m_Ctx.ViewConstantBuffer(stage->stage, cb.slotIdx, cb.arrayIdx); - ConstantBufferPreviewer *prev = - new ConstantBufferPreviewer(m_Ctx, stage->stage, cb.slotIdx, cb.arrayIdx, m_Ctx.mainWindow()); - - m_Ctx.setupDockWindow(prev); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::RightOf, manager->areaOf(this), 0.3f); - manager->addToolWindow(prev, ref); + m_Ctx.AddDockWindow(prev->Widget(), DockReference::RightOf, this, 0.3f); } void VulkanPipelineStateViewer::on_viAttrs_itemActivated(QTreeWidgetItem *item, int column) @@ -2145,16 +2113,9 @@ void VulkanPipelineStateViewer::on_viBuffers_itemActivated(QTreeWidgetItem *item if(buf.id != ResourceId()) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewBuffer(buf.offset, UINT64_MAX, buf.id); - viewer->ViewBuffer(buf.offset, UINT64_MAX, buf.id); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } } @@ -2163,7 +2124,7 @@ void VulkanPipelineStateViewer::highlightIABind(int slot) { int idx = ((slot + 1) * 21) % 32; // space neighbouring colours reasonably distinctly - const VKPipe::VertexInput &VI = m_Ctx.CurVulkanPipelineState.VI; + const VKPipe::VertexInput &VI = m_Ctx.CurVulkanPipelineState().VI; QColor col = QColor::fromHslF(float(idx) / 32.0f, 1.0f, 0.95f); @@ -2222,7 +2183,7 @@ void VulkanPipelineStateViewer::on_viAttrs_mouseMove(QMouseEvent *e) vertex_leave(NULL); - const VKPipe::VertexInput &VI = m_Ctx.CurVulkanPipelineState.VI; + const VKPipe::VertexInput &VI = m_Ctx.CurVulkanPipelineState().VI; if(idx.isValid()) { @@ -2322,15 +2283,10 @@ void VulkanPipelineStateViewer::shaderView_clicked() ShaderReflection *shaderDetails = stage->ShaderDetails; - ShaderViewer *shad = ShaderViewer::viewShader(m_Ctx, &stage->BindpointMapping, shaderDetails, - stage->stage, m_Ctx.mainWindow()); + IShaderViewer *shad = m_Ctx.ViewShader(&stage->BindpointMapping, shaderDetails, stage->stage, + m_Ctx.GetMainWindow()->Widget()); - m_Ctx.setupDockWindow(shad); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(shad, ref); + m_Ctx.AddDockWindow(shad->Widget(), DockReference::AddTo, this); } void VulkanPipelineStateViewer::shaderEdit_clicked() @@ -2358,7 +2314,7 @@ void VulkanPipelineStateViewer::shaderEdit_clicked() { QString glsl; - if(!m_Ctx.Config.SPIRVDisassemblers.isEmpty()) + if(!m_Ctx.Config().SPIRVDisassemblers.isEmpty()) glsl = disassembleSPIRV(shaderDetails); if(glsl.isEmpty()) @@ -2379,7 +2335,7 @@ QString VulkanPipelineStateViewer::disassembleSPIRV(const ShaderReflection *shad { QString glsl; - const SPIRVDisassembler &disasm = m_Ctx.Config.SPIRVDisassemblers[0]; + const SPIRVDisassembler &disasm = m_Ctx.Config().SPIRVDisassemblers[0]; if(disasm.executable.isEmpty()) return ""; @@ -2480,7 +2436,7 @@ void VulkanPipelineStateViewer::on_exportHTML_clicked() void VulkanPipelineStateViewer::on_meshView_clicked() { - if(!m_Ctx.hasMeshPreview()) - m_Ctx.showMeshPreview(); - ToolWindowManager::raiseToolWindow(m_Ctx.meshPreview()); + if(!m_Ctx.HasMeshPreview()) + m_Ctx.ShowMeshPreview(); + ToolWindowManager::raiseToolWindow(m_Ctx.GetMeshPreview()->Widget()); } diff --git a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.h b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.h index a23036b11..779adf3a0 100644 --- a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.h +++ b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.h @@ -48,7 +48,7 @@ class VulkanPipelineStateViewer : public QFrame, public ILogViewerForm Q_OBJECT public: - explicit VulkanPipelineStateViewer(CaptureContext &ctx, PipelineStateViewer &common, + explicit VulkanPipelineStateViewer(ICaptureContext &ctx, PipelineStateViewer &common, QWidget *parent = 0); ~VulkanPipelineStateViewer(); @@ -80,7 +80,7 @@ private slots: private: Ui::VulkanPipelineStateViewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; PipelineStateViewer &m_Common; QVariantList makeSampler(const QString &bindset, const QString &slotname, diff --git a/qrenderdoc/Windows/PixelHistoryView.cpp b/qrenderdoc/Windows/PixelHistoryView.cpp index 17d5acef4..c371a04e5 100644 --- a/qrenderdoc/Windows/PixelHistoryView.cpp +++ b/qrenderdoc/Windows/PixelHistoryView.cpp @@ -28,8 +28,6 @@ #include #include #include "3rdparty/toolwindowmanager/ToolWindowManager.h" -#include "Windows/BufferViewer.h" -#include "Windows/ShaderViewer.h" #include "ui_PixelHistoryView.h" struct EventTag @@ -43,7 +41,7 @@ Q_DECLARE_METATYPE(EventTag); class PixelHistoryItemModel : public QAbstractItemModel { public: - PixelHistoryItemModel(CaptureContext &ctx, ResourceId tex, const TextureDisplay &display, + PixelHistoryItemModel(ICaptureContext &ctx, ResourceId tex, const TextureDisplay &display, QObject *parent) : QAbstractItemModel(parent), m_Ctx(ctx) { @@ -390,7 +388,7 @@ public: } private: - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; const TextureDescription *m_Tex; TextureDisplay m_Display; @@ -555,7 +553,7 @@ private: } }; -PixelHistoryView::PixelHistoryView(CaptureContext &ctx, ResourceId id, QPoint point, +PixelHistoryView::PixelHistoryView(ICaptureContext &ctx, ResourceId id, QPoint point, const TextureDisplay &display, QWidget *parent) : QFrame(parent), ui(new Ui::PixelHistoryView), m_Ctx(ctx) { @@ -628,7 +626,7 @@ void PixelHistoryView::OnLogfileClosed() ToolWindowManager::closeToolWindow(this); } -void PixelHistoryView::setHistory(const rdctype::array &history) +void PixelHistoryView::SetHistory(const rdctype::array &history) { m_Model->setHistory(history); } @@ -657,29 +655,24 @@ void PixelHistoryView::startDebug(EventTag tag) QString debugContext = QString("Pixel %1,%2").arg(m_Pixel.x()).arg(m_Pixel.y()); const ShaderReflection *shaderDetails = - m_Ctx.CurPipelineState.GetShaderReflection(ShaderStage::Pixel); + m_Ctx.CurPipelineState().GetShaderReflection(ShaderStage::Pixel); const ShaderBindpointMapping &bindMapping = - m_Ctx.CurPipelineState.GetBindpointMapping(ShaderStage::Pixel); + m_Ctx.CurPipelineState().GetBindpointMapping(ShaderStage::Pixel); // viewer takes ownership of the trace - ShaderViewer *s = ShaderViewer::debugShader(m_Ctx, &bindMapping, shaderDetails, - ShaderStage::Pixel, trace, debugContext, this); + IShaderViewer *s = m_Ctx.DebugShader(&bindMapping, shaderDetails, ShaderStage::Pixel, trace, + debugContext, m_Ctx.GetMainWindow()->Widget()); - m_Ctx.setupDockWindow(s); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(s, ref); + m_Ctx.AddDockWindow(s->Widget(), DockReference::AddTo, m_Ctx.GetMainWindow()->Widget()); }); } void PixelHistoryView::jumpToPrimitive(EventTag tag) { m_Ctx.SetEventID({this}, tag.eventID, tag.eventID); - m_Ctx.showMeshPreview(); + m_Ctx.ShowMeshPreview(); - BufferViewer *viewer = m_Ctx.meshPreview(); + IBufferViewer *viewer = m_Ctx.GetMeshPreview(); const DrawcallDescription *draw = m_Ctx.CurDrawcall(); diff --git a/qrenderdoc/Windows/PixelHistoryView.h b/qrenderdoc/Windows/PixelHistoryView.h index 8e4060f46..12f3e9765 100644 --- a/qrenderdoc/Windows/PixelHistoryView.h +++ b/qrenderdoc/Windows/PixelHistoryView.h @@ -32,25 +32,27 @@ namespace Ui class PixelHistoryView; } -class CaptureContext; class PixelHistoryItemModel; struct EventTag; -class PixelHistoryView : public QFrame, public ILogViewerForm +class PixelHistoryView : public QFrame, public IPixelHistoryView, public ILogViewerForm { Q_OBJECT public: - explicit PixelHistoryView(CaptureContext &ctx, ResourceId id, QPoint point, + explicit PixelHistoryView(ICaptureContext &ctx, ResourceId id, QPoint point, const TextureDisplay &display, QWidget *parent = 0); ~PixelHistoryView(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID) {} - void setHistory(const rdctype::array &history); + // IPixelHistoryView + QWidget *Widget() override { return this; } + void SetHistory(const rdctype::array &history) override; + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override {} private slots: // automatic slots void on_events_customContextMenuRequested(const QPoint &pos); @@ -58,7 +60,7 @@ private slots: private: Ui::PixelHistoryView *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; TextureDisplay m_Display; QPoint m_Pixel; diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index 79e900538..35269c97d 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -33,7 +33,6 @@ #include "3rdparty/toolwindowmanager/ToolWindowManagerArea.h" #include "Code/ScintillaSyntax.h" #include "Widgets/FindReplace.h" -#include "Windows/PipelineState/PipelineStateViewer.h" #include "ui_ShaderViewer.h" struct CBufferTag @@ -55,7 +54,7 @@ Q_DECLARE_METATYPE(CBufferTag); Q_DECLARE_METATYPE(ResourceTag); Q_DECLARE_METATYPE(ShaderVariable); -ShaderViewer::ShaderViewer(CaptureContext &ctx, QWidget *parent) +ShaderViewer::ShaderViewer(ICaptureContext &ctx, QWidget *parent) : QFrame(parent), ui(new Ui::ShaderViewer), m_Ctx(ctx) { ui->setupUi(this); @@ -265,10 +264,11 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR m_Trace = NULL; if(trace) - setWindowTitle( - QString("Debugging %1 - %2").arg(m_Ctx.CurPipelineState.GetShaderName(stage)).arg(debugContext)); + setWindowTitle(QString("Debugging %1 - %2") + .arg(m_Ctx.CurPipelineState().GetShaderName(stage)) + .arg(debugContext)); else - setWindowTitle(m_Ctx.CurPipelineState.GetShaderName(stage)); + setWindowTitle(m_Ctx.CurPipelineState().GetShaderName(stage)); if(shader) { @@ -386,9 +386,9 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR QObject::connect(new QShortcut(QKeySequence(Qt::Key_F5 | Qt::ShiftModifier), m_DisassemblyView), &QShortcut::activated, this, &ShaderViewer::runBack); QObject::connect(new QShortcut(QKeySequence(Qt::Key_F9), m_DisassemblyView), - &QShortcut::activated, [this]() { toggleBreakpoint(); }); + &QShortcut::activated, [this]() { ToggleBreakpoint(); }); - setCurrentStep(0); + SetCurrentStep(0); } else { @@ -603,10 +603,10 @@ bool ShaderViewer::stepBack() if(!m_Trace) return false; - if(currentStep() == 0) + if(CurrentStep() == 0) return false; - setCurrentStep(currentStep() - 1); + SetCurrentStep(CurrentStep() - 1); return true; } @@ -616,10 +616,10 @@ bool ShaderViewer::stepNext() if(!m_Trace) return false; - if(currentStep() + 1 >= m_Trace->states.count) + if(CurrentStep() + 1 >= m_Trace->states.count) return false; - setCurrentStep(currentStep() + 1); + SetCurrentStep(CurrentStep() + 1); return true; } @@ -687,7 +687,7 @@ void ShaderViewer::runTo(int runToInstruction, bool forward, ShaderEvents condit if(!m_Trace) return; - int step = currentStep(); + int step = CurrentStep(); int inc = forward ? 1 : -1; @@ -712,7 +712,7 @@ void ShaderViewer::runTo(int runToInstruction, bool forward, ShaderEvents condit step += inc; } - setCurrentStep(step); + SetCurrentStep(step); } QString ShaderViewer::stringRep(const ShaderVariable &var, bool useType) @@ -871,9 +871,9 @@ void ShaderViewer::updateDebugging() } QMap> rw = - m_Ctx.CurPipelineState.GetReadWriteResources(m_Stage); + m_Ctx.CurPipelineState().GetReadWriteResources(m_Stage); QMap> ro = - m_Ctx.CurPipelineState.GetReadOnlyResources(m_Stage); + m_Ctx.CurPipelineState().GetReadOnlyResources(m_Stage); bool tree = false; @@ -1009,12 +1009,12 @@ void ShaderViewer::ensureLineScrolled(ScintillaEdit *s, int line) s->scrollCaret(); } -int ShaderViewer::currentStep() +int ShaderViewer::CurrentStep() { return m_CurrentStep; } -void ShaderViewer::setCurrentStep(int step) +void ShaderViewer::SetCurrentStep(int step) { if(m_Trace && !m_Trace->states.empty()) m_CurrentStep = qBound(0, step, m_Trace->states.count - 1); @@ -1024,7 +1024,7 @@ void ShaderViewer::setCurrentStep(int step) updateDebugging(); } -void ShaderViewer::toggleBreakpoint(int instruction) +void ShaderViewer::ToggleBreakpoint(int instruction) { sptr_t instLine = -1; @@ -1080,7 +1080,7 @@ void ShaderViewer::toggleBreakpoint(int instruction) } } -void ShaderViewer::showErrors(const QString &errors) +void ShaderViewer::ShowErrors(const QString &errors) { if(m_Errors) { @@ -1400,7 +1400,7 @@ void ShaderViewer::on_save_clicked() { if(m_Trace) { - m_Ctx.pipelineViewer()->SaveShaderFile(m_ShaderDetails); + m_Ctx.GetPipelineViewer()->SaveShaderFile(m_ShaderDetails); return; } diff --git a/qrenderdoc/Windows/ShaderViewer.h b/qrenderdoc/Windows/ShaderViewer.h index 6e492388e..530266c01 100644 --- a/qrenderdoc/Windows/ShaderViewer.h +++ b/qrenderdoc/Windows/ShaderViewer.h @@ -41,17 +41,14 @@ class FindReplace; // from Scintilla typedef intptr_t sptr_t; -class ShaderViewer : public QFrame, public ILogViewerForm +class ShaderViewer : public QFrame, public IShaderViewer, public ILogViewerForm { Q_OBJECT public: - typedef std::function SaveMethod; - typedef std::function CloseMethod; - - static ShaderViewer *editShader(CaptureContext &ctx, bool customShader, const QString &entryPoint, - const QStringMap &files, SaveMethod saveCallback, - CloseMethod closeCallback, QWidget *parent) + static IShaderViewer *EditShader(ICaptureContext &ctx, bool customShader, const QString &entryPoint, + const QStringMap &files, IShaderViewer::SaveMethod saveCallback, + IShaderViewer::CloseMethod closeCallback, QWidget *parent) { ShaderViewer *ret = new ShaderViewer(ctx, parent); ret->m_SaveCallback = saveCallback; @@ -60,35 +57,38 @@ public: return ret; } - static ShaderViewer *debugShader(CaptureContext &ctx, const ShaderBindpointMapping *bind, - const ShaderReflection *shader, ShaderStage stage, - ShaderDebugTrace *trace, const QString &debugContext, - QWidget *parent) + static IShaderViewer *DebugShader(ICaptureContext &ctx, const ShaderBindpointMapping *bind, + const ShaderReflection *shader, ShaderStage stage, + ShaderDebugTrace *trace, const QString &debugContext, + QWidget *parent) { ShaderViewer *ret = new ShaderViewer(ctx, parent); ret->debugShader(bind, shader, stage, trace, debugContext); return ret; } - static ShaderViewer *viewShader(CaptureContext &ctx, const ShaderBindpointMapping *bind, - const ShaderReflection *shader, ShaderStage stage, QWidget *parent) + static IShaderViewer *ViewShader(ICaptureContext &ctx, const ShaderBindpointMapping *bind, + const ShaderReflection *shader, ShaderStage stage, QWidget *parent) { - return ShaderViewer::debugShader(ctx, bind, shader, stage, NULL, "", parent); + return DebugShader(ctx, bind, shader, stage, NULL, "", parent); } ~ShaderViewer(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID); + // IShaderViewer + virtual QWidget *Widget() override { return this; } + virtual int CurrentStep() override; + virtual void SetCurrentStep(int step) override; - int currentStep(); - void setCurrentStep(int step); + virtual void ToggleBreakpoint(int instruction = -1) override; - void toggleBreakpoint(int instruction = -1); + virtual void ShowErrors(const QString &errors) override; - void showErrors(const QString &errors); + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override; private slots: // automatic slots @@ -124,13 +124,13 @@ public slots: void run(); private: - explicit ShaderViewer(CaptureContext &ctx, QWidget *parent = 0); + explicit ShaderViewer(ICaptureContext &ctx, QWidget *parent = 0); void editShader(bool customShader, const QString &entryPoint, const QStringMap &files); void debugShader(const ShaderBindpointMapping *bind, const ShaderReflection *shader, ShaderStage stage, ShaderDebugTrace *trace, const QString &debugContext); Ui::ShaderViewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; const ShaderBindpointMapping *m_Mapping = NULL; const ShaderReflection *m_ShaderDetails = NULL; ShaderStage m_Stage; diff --git a/qrenderdoc/Windows/StatisticsViewer.cpp b/qrenderdoc/Windows/StatisticsViewer.cpp index c8e95e6f7..845418855 100644 --- a/qrenderdoc/Windows/StatisticsViewer.cpp +++ b/qrenderdoc/Windows/StatisticsViewer.cpp @@ -168,7 +168,7 @@ void AppendInputAssemblerStatistics(QString &statisticsLog, const FrameDescripti vertices.bindslots)); } -void AppendShaderStatistics(CaptureContext &ctx, QString &statisticsLog, +void AppendShaderStatistics(ICaptureContext &ctx, QString &statisticsLog, const FrameDescription &frameInfo) { const ShaderChangeStats *shaders = frameInfo.stats.shaders; @@ -188,7 +188,7 @@ void AppendShaderStatistics(CaptureContext &ctx, QString &statisticsLog, { statisticsLog.append(QString("%1 calls: %2, non-null shader sets: %3, null shader sets: %4, " "redundant shader sets: %5\n") - .arg(ctx.CurPipelineState.Abbrev(StageFromIndex(s))) + .arg(ctx.CurPipelineState().Abbrev(StageFromIndex(s))) .arg(shaders[s].calls) .arg(shaders[s].sets) .arg(shaders[s].nulls) @@ -203,7 +203,7 @@ void AppendShaderStatistics(CaptureContext &ctx, QString &statisticsLog, .arg(totalShadersPerStage.redundants)); } -void AppendConstantBindStatistics(CaptureContext &ctx, QString &statisticsLog, +void AppendConstantBindStatistics(ICaptureContext &ctx, QString &statisticsLog, const FrameDescription &frameInfo) { // #mivance C++-side we guarantee all stages will have the same slots @@ -263,7 +263,7 @@ void AppendConstantBindStatistics(CaptureContext &ctx, QString &statisticsLog, for(auto s : indices()) { statisticsLog.append(QString("%1 calls: %2, non-null buffer sets: %3, null buffer sets: %4\n") - .arg(ctx.CurPipelineState.Abbrev(StageFromIndex(s))) + .arg(ctx.CurPipelineState().Abbrev(StageFromIndex(s))) .arg(totalConstantsPerStage[s].calls) .arg(totalConstantsPerStage[s].sets) .arg(totalConstantsPerStage[s].nulls)); @@ -299,7 +299,7 @@ void AppendConstantBindStatistics(CaptureContext &ctx, QString &statisticsLog, } } -void AppendSamplerBindStatistics(CaptureContext &ctx, QString &statisticsLog, +void AppendSamplerBindStatistics(ICaptureContext &ctx, QString &statisticsLog, const FrameDescription &frameInfo) { // #mivance see AppendConstantBindStatistics @@ -348,7 +348,7 @@ void AppendSamplerBindStatistics(CaptureContext &ctx, QString &statisticsLog, for(auto s : indices()) { statisticsLog.append(QString("%1 calls: %2, non-null sampler sets: %3, null sampler sets: %4\n") - .arg(ctx.CurPipelineState.Abbrev(StageFromIndex(s))) + .arg(ctx.CurPipelineState().Abbrev(StageFromIndex(s))) .arg(totalSamplersPerStage[s].calls) .arg(totalSamplersPerStage[s].sets) .arg(totalSamplersPerStage[s].nulls)); @@ -364,7 +364,7 @@ void AppendSamplerBindStatistics(CaptureContext &ctx, QString &statisticsLog, "Aggregate slot counts per invocation across all stages", totalSamplersForAllStages.bindslots)); } -void AppendResourceBindStatistics(CaptureContext &ctx, QString &statisticsLog, +void AppendResourceBindStatistics(ICaptureContext &ctx, QString &statisticsLog, const FrameDescription &frameInfo) { // #mivance see AppendConstantBindStatistics @@ -424,7 +424,7 @@ void AppendResourceBindStatistics(CaptureContext &ctx, QString &statisticsLog, for(auto s : indices()) { statisticsLog.append(QString("%1 calls: %2 non-null resource sets: %3 null resource sets: %4\n") - .arg(ctx.CurPipelineState.Abbrev(StageFromIndex(s))) + .arg(ctx.CurPipelineState().Abbrev(StageFromIndex(s))) .arg(totalResourcesPerStage[s].calls) .arg(totalResourcesPerStage[s].sets) .arg(totalResourcesPerStage[s].nulls)); @@ -584,7 +584,7 @@ void AppendOutputStatistics(QString &statisticsLog, const FrameDescription &fram statisticsLog.append(CreateSimpleIntegerHistogram("Outputs set", outputs.bindslots)); } -void AppendDetailedInformation(CaptureContext &ctx, QString &statisticsLog, +void AppendDetailedInformation(ICaptureContext &ctx, QString &statisticsLog, const FrameDescription &frameInfo) { if(!frameInfo.stats.recorded) @@ -665,7 +665,7 @@ QString AppendAPICallSummary(const FrameDescription &frameInfo, uint numAPICalls return calls; } -QString GenerateReport(CaptureContext &ctx) +QString GenerateReport(ICaptureContext &ctx) { QString statisticsLog; @@ -798,7 +798,7 @@ QString GenerateReport(CaptureContext &ctx) return statisticsLog; } -StatisticsViewer::StatisticsViewer(CaptureContext &ctx, QWidget *parent) +StatisticsViewer::StatisticsViewer(ICaptureContext &ctx, QWidget *parent) : QFrame(parent), ui(new Ui::StatisticsViewer), m_Ctx(ctx) { ui->setupUi(this); @@ -810,7 +810,7 @@ StatisticsViewer::StatisticsViewer(CaptureContext &ctx, QWidget *parent) StatisticsViewer::~StatisticsViewer() { - m_Ctx.windowClosed(this); + m_Ctx.BuiltinWindowClosed(this); m_Ctx.RemoveLogViewer(this); delete ui; diff --git a/qrenderdoc/Windows/StatisticsViewer.h b/qrenderdoc/Windows/StatisticsViewer.h index 312e731d0..959a78c5d 100644 --- a/qrenderdoc/Windows/StatisticsViewer.h +++ b/qrenderdoc/Windows/StatisticsViewer.h @@ -32,19 +32,22 @@ namespace Ui class StatisticsViewer; } -class StatisticsViewer : public QFrame, public ILogViewerForm +class StatisticsViewer : public QFrame, public IStatisticsViewer, public ILogViewerForm { Q_OBJECT public: - explicit StatisticsViewer(CaptureContext &ctx, QWidget *parent = 0); + explicit StatisticsViewer(ICaptureContext &ctx, QWidget *parent = 0); ~StatisticsViewer(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID) {} + // IStatisticsViewer + QWidget *Widget() override { return this; } + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override {} private: Ui::StatisticsViewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; }; diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 759472339..b022e4190 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -41,10 +41,6 @@ #include "Dialogs/TextureSaveDialog.h" #include "Widgets/ResourcePreview.h" #include "Widgets/TextureGoto.h" -#include "BufferViewer.h" -#include "MainWindow.h" -#include "PixelHistoryView.h" -#include "ShaderViewer.h" #include "ui_TextureViewer.h" float area(const QSizeF &s) @@ -88,35 +84,35 @@ bool Following::operator==(const Following &o) return Type == o.Type && Stage == o.Stage && index == o.index; } -void Following::GetDrawContext(CaptureContext &ctx, bool ©, bool &compute) +void Following::GetDrawContext(ICaptureContext &ctx, bool ©, bool &compute) { const DrawcallDescription *curDraw = ctx.CurDrawcall(); copy = curDraw != NULL && (curDraw->flags & (DrawFlags::Copy | DrawFlags::Resolve)); compute = curDraw != NULL && (curDraw->flags & DrawFlags::Dispatch) && - ctx.CurPipelineState.GetShader(ShaderStage::Compute) != ResourceId(); + ctx.CurPipelineState().GetShader(ShaderStage::Compute) != ResourceId(); } -int Following::GetHighestMip(CaptureContext &ctx) +int Following::GetHighestMip(ICaptureContext &ctx) { return GetBoundResource(ctx, arrayEl).HighestMip; } -int Following::GetFirstArraySlice(CaptureContext &ctx) +int Following::GetFirstArraySlice(ICaptureContext &ctx) { return GetBoundResource(ctx, arrayEl).FirstSlice; } -CompType Following::GetTypeHint(CaptureContext &ctx) +CompType Following::GetTypeHint(ICaptureContext &ctx) { return GetBoundResource(ctx, arrayEl).typeHint; } -ResourceId Following::GetResourceId(CaptureContext &ctx) +ResourceId Following::GetResourceId(ICaptureContext &ctx) { return GetBoundResource(ctx, arrayEl).Id; } -BoundResource Following::GetBoundResource(CaptureContext &ctx, int arrayIdx) +BoundResource Following::GetBoundResource(ICaptureContext &ctx, int arrayIdx) { BoundResource ret; @@ -163,7 +159,7 @@ BoundResource Following::GetBoundResource(CaptureContext &ctx, int arrayIdx) return ret; } -QVector Following::GetOutputTargets(CaptureContext &ctx) +QVector Following::GetOutputTargets(ICaptureContext &ctx) { const DrawcallDescription *curDraw = ctx.CurDrawcall(); bool copy = false, compute = false; @@ -179,7 +175,7 @@ QVector Following::GetOutputTargets(CaptureContext &ctx) } else { - QVector ret = ctx.CurPipelineState.GetOutputTargets(); + QVector ret = ctx.CurPipelineState().GetOutputTargets(); if(ret.isEmpty() && curDraw != NULL && (curDraw->flags & DrawFlags::Present)) { @@ -197,7 +193,7 @@ QVector Following::GetOutputTargets(CaptureContext &ctx) } } -BoundResource Following::GetDepthTarget(CaptureContext &ctx) +BoundResource Following::GetDepthTarget(ICaptureContext &ctx) { bool copy = false, compute = false; GetDrawContext(ctx, copy, compute); @@ -205,10 +201,10 @@ BoundResource Following::GetDepthTarget(CaptureContext &ctx) if(copy || compute) return BoundResource(ResourceId()); else - return ctx.CurPipelineState.GetDepthTarget(); + return ctx.CurPipelineState().GetDepthTarget(); } -QMap> Following::GetReadWriteResources(CaptureContext &ctx, +QMap> Following::GetReadWriteResources(ICaptureContext &ctx, ShaderStage stage) { bool copy = false, compute = false; @@ -222,22 +218,22 @@ QMap> Following::GetReadWriteResources(Capt { // only return compute resources for one stage if(stage == ShaderStage::Pixel || stage == ShaderStage::Compute) - return ctx.CurPipelineState.GetReadWriteResources(ShaderStage::Compute); + return ctx.CurPipelineState().GetReadWriteResources(ShaderStage::Compute); else return QMap>(); } else { - return ctx.CurPipelineState.GetReadWriteResources(stage); + return ctx.CurPipelineState().GetReadWriteResources(stage); } } -QMap> Following::GetReadWriteResources(CaptureContext &ctx) +QMap> Following::GetReadWriteResources(ICaptureContext &ctx) { return GetReadWriteResources(ctx, Stage); } -QMap> Following::GetReadOnlyResources(CaptureContext &ctx, +QMap> Following::GetReadOnlyResources(ICaptureContext &ctx, ShaderStage stage) { const DrawcallDescription *curDraw = ctx.CurDrawcall(); @@ -258,22 +254,22 @@ QMap> Following::GetReadOnlyResources(Captu { // only return compute resources for one stage if(stage == ShaderStage::Pixel || stage == ShaderStage::Compute) - return ctx.CurPipelineState.GetReadOnlyResources(ShaderStage::Compute); + return ctx.CurPipelineState().GetReadOnlyResources(ShaderStage::Compute); else return QMap>(); } else { - return ctx.CurPipelineState.GetReadOnlyResources(stage); + return ctx.CurPipelineState().GetReadOnlyResources(stage); } } -QMap> Following::GetReadOnlyResources(CaptureContext &ctx) +QMap> Following::GetReadOnlyResources(ICaptureContext &ctx) { return GetReadOnlyResources(ctx, Stage); } -const ShaderReflection *Following::GetReflection(CaptureContext &ctx, ShaderStage stage) +const ShaderReflection *Following::GetReflection(ICaptureContext &ctx, ShaderStage stage) { bool copy = false, compute = false; GetDrawContext(ctx, copy, compute); @@ -281,17 +277,17 @@ const ShaderReflection *Following::GetReflection(CaptureContext &ctx, ShaderStag if(copy) return NULL; else if(compute) - return ctx.CurPipelineState.GetShaderReflection(ShaderStage::Compute); + return ctx.CurPipelineState().GetShaderReflection(ShaderStage::Compute); else - return ctx.CurPipelineState.GetShaderReflection(stage); + return ctx.CurPipelineState().GetShaderReflection(stage); } -const ShaderReflection *Following::GetReflection(CaptureContext &ctx) +const ShaderReflection *Following::GetReflection(ICaptureContext &ctx) { return GetReflection(ctx, Stage); } -const ShaderBindpointMapping &Following::GetMapping(CaptureContext &ctx, ShaderStage stage) +const ShaderBindpointMapping &Following::GetMapping(ICaptureContext &ctx, ShaderStage stage) { bool copy = false, compute = false; GetDrawContext(ctx, copy, compute); @@ -310,15 +306,15 @@ const ShaderBindpointMapping &Following::GetMapping(CaptureContext &ctx, ShaderS } else if(compute) { - return ctx.CurPipelineState.GetBindpointMapping(ShaderStage::Compute); + return ctx.CurPipelineState().GetBindpointMapping(ShaderStage::Compute); } else { - return ctx.CurPipelineState.GetBindpointMapping(stage); + return ctx.CurPipelineState().GetBindpointMapping(stage); } } -const ShaderBindpointMapping &Following::GetMapping(CaptureContext &ctx) +const ShaderBindpointMapping &Following::GetMapping(ICaptureContext &ctx) { return GetMapping(ctx, Stage); } @@ -334,7 +330,7 @@ public: }; TextureListItemModel(QObject *parent) : QAbstractItemModel(parent) {} - void reset(FilterType type, const QString &filter, CaptureContext &ctx) + void reset(FilterType type, const QString &filter, ICaptureContext &ctx) { const rdctype::array src = ctx.GetTextures(); @@ -478,7 +474,7 @@ void TextureViewer::UI_UpdateCachedTexture() m_CachedTexture = m_Ctx.GetTexture(id); } -TextureViewer::TextureViewer(CaptureContext &ctx, QWidget *parent) +TextureViewer::TextureViewer(ICaptureContext &ctx, QWidget *parent) : QFrame(parent), ui(new Ui::TextureViewer), m_Ctx(ctx) { ui->setupUi(this); @@ -640,7 +636,7 @@ TextureViewer::TextureViewer(CaptureContext &ctx, QWidget *parent) TextureViewer::~TextureViewer() { - m_Ctx.windowClosed(this); + m_Ctx.BuiltinWindowClosed(this); m_Ctx.RemoveLogViewer(this); delete ui; } @@ -1033,7 +1029,7 @@ void TextureViewer::UI_OnTextureSelectionChanged(bool newdraw) bool newtex = (m_TexDisplay.texid != tex.ID); // save settings for this current texture - if(m_Ctx.Config.TextureViewer_PerTexSettings) + if(m_Ctx.Config().TextureViewer_PerTexSettings) { m_TextureSettings[m_TexDisplay.texid].r = ui->channelRed->isChecked(); m_TextureSettings[m_TexDisplay.texid].g = ui->channelGreen->isChecked(); @@ -1226,7 +1222,7 @@ void TextureViewer::UI_OnTextureSelectionChanged(bool newdraw) // even if we don't switch to a new texture. // Note that if the slice or mip was changed because that slice or mip is the selected one // at the API level, we leave this alone. - if(m_Ctx.Config.TextureViewer_PerTexSettings && m_TextureSettings.contains(tex.ID)) + if(m_Ctx.Config().TextureViewer_PerTexSettings && m_TextureSettings.contains(tex.ID)) { if(usemipsettings) ui->mipLevel->setCurrentIndex(m_TextureSettings[tex.ID].mip); @@ -1239,7 +1235,7 @@ void TextureViewer::UI_OnTextureSelectionChanged(bool newdraw) if(newtex) { // if we save certain settings per-texture, restore them (if we have any) - if(m_Ctx.Config.TextureViewer_PerTexSettings && m_TextureSettings.contains(tex.ID)) + if(m_Ctx.Config().TextureViewer_PerTexSettings && m_TextureSettings.contains(tex.ID)) { ui->channels->setCurrentIndex(m_TextureSettings[tex.ID].displayType); @@ -1258,7 +1254,7 @@ void TextureViewer::UI_OnTextureSelectionChanged(bool newdraw) m_TextureSettings[m_TexDisplay.texid].maxrange); m_NoRangePaint = false; } - else if(m_Ctx.Config.TextureViewer_PerTexSettings) + else if(m_Ctx.Config().TextureViewer_PerTexSettings) { // if we are using per-tex settings, reset back to RGB ui->channels->setCurrentIndex(0); @@ -1279,7 +1275,7 @@ void TextureViewer::UI_OnTextureSelectionChanged(bool newdraw) } // reset the range if desired - if(m_Ctx.Config.TextureViewer_ResetRange) + if(m_Ctx.Config().TextureViewer_ResetRange) { UI_SetHistogramRange(texptr, m_TexDisplay.typeHint); } @@ -1714,16 +1710,9 @@ void TextureViewer::ViewTexture(ResourceId ID, bool focus) BufferDescription *buf = m_Ctx.GetBuffer(ID); if(buf) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = m_Ctx.ViewBuffer(0, 0, ID); - viewer->ViewBuffer(0, 0, ID); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } @@ -1804,10 +1793,10 @@ void TextureViewer::OpenResourceContextMenu(ResourceId id, const rdctype::array< QObject::connect(&showDisabled, &QAction::triggered, this, &TextureViewer::showDisabled_triggered); QObject::connect(&showEmpty, &QAction::triggered, this, &TextureViewer::showEmpty_triggered); - if(m_Ctx.CurPipelineState.SupportsBarriers()) + if(m_Ctx.CurPipelineState().SupportsBarriers()) { contextMenu.addSeparator(); - imageLayout.setText(tr("Image is in layout ") + m_Ctx.CurPipelineState.GetImageLayout(id)); + imageLayout.setText(tr("Image is in layout ") + m_Ctx.CurPipelineState().GetImageLayout(id)); contextMenu.addAction(&imageLayout); } @@ -1916,7 +1905,8 @@ void TextureViewer::InitResourcePreview(ResourcePreview *prev, ResourceId id, Co prev->setResourceName(fullname); WId handle = prev->thumbWinId(); m_Ctx.Renderer().AsyncInvoke([this, handle, id, typeHint](IReplayRenderer *) { - m_Output->AddThumbnail(m_Ctx.m_CurWinSystem, m_Ctx.FillWindowingData(handle), id, typeHint); + m_Output->AddThumbnail(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(handle), id, + typeHint); }); } else if(bufptr != NULL) @@ -1934,8 +1924,8 @@ void TextureViewer::InitResourcePreview(ResourcePreview *prev, ResourceId id, Co prev->setResourceName(fullname); WId handle = prev->thumbWinId(); m_Ctx.Renderer().AsyncInvoke([this, handle](IReplayRenderer *) { - m_Output->AddThumbnail(m_Ctx.m_CurWinSystem, m_Ctx.FillWindowingData(handle), ResourceId(), - CompType::Typeless); + m_Output->AddThumbnail(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(handle), + ResourceId(), CompType::Typeless); }); } else @@ -1943,8 +1933,8 @@ void TextureViewer::InitResourcePreview(ResourcePreview *prev, ResourceId id, Co prev->setResourceName(""); WId handle = prev->thumbWinId(); m_Ctx.Renderer().AsyncInvoke([this, handle](IReplayRenderer *) { - m_Output->AddThumbnail(m_Ctx.m_CurWinSystem, m_Ctx.FillWindowingData(handle), ResourceId(), - CompType::Typeless); + m_Output->AddThumbnail(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(handle), + ResourceId(), CompType::Typeless); }); } @@ -1961,8 +1951,8 @@ void TextureViewer::InitResourcePreview(ResourcePreview *prev, ResourceId id, Co WId handle = prev->thumbWinId(); m_Ctx.Renderer().AsyncInvoke([this, handle](IReplayRenderer *) { - m_Output->AddThumbnail(m_Ctx.m_CurWinSystem, m_Ctx.FillWindowingData(handle), ResourceId(), - CompType::Typeless); + m_Output->AddThumbnail(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(handle), + ResourceId(), CompType::Typeless); }); } else @@ -2032,7 +2022,7 @@ void TextureViewer::InitStageResourcePreviews(ShaderStage stage, Following follow(rw ? FollowType::ReadWrite : FollowType::ReadOnly, stage, idx, arrayIdx); QString slotName = - QString("%1 %2%3").arg(m_Ctx.CurPipelineState.Abbrev(stage)).arg(rw ? "RW " : "").arg(idx); + QString("%1 %2%3").arg(m_Ctx.CurPipelineState().Abbrev(stage)).arg(rw ? "RW " : "").arg(idx); if(arrayLen > 1) slotName += QString("[%1]").arg(arrayIdx); @@ -2427,7 +2417,7 @@ void TextureViewer::on_renderVScroll_valueChanged(int position) void TextureViewer::UI_RecreatePanels() { - CaptureContext *ctx = &m_Ctx; + ICaptureContext *ctx = &m_Ctx; // while a log is loaded, pass NULL into the widget if(!m_Ctx.LogLoaded()) @@ -2486,10 +2476,10 @@ void TextureViewer::OnLogfileLoaded() FloatVector(lightBack.redF(), lightBack.greenF(), lightBack.blueF(), 1.0f); m_Ctx.Renderer().BlockInvoke([renderID, contextID, this](IReplayRenderer *r) { - m_Output = r->CreateOutput(m_Ctx.m_CurWinSystem, m_Ctx.FillWindowingData(renderID), + m_Output = r->CreateOutput(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(renderID), ReplayOutputType::Texture); - m_Output->SetPixelContext(m_Ctx.m_CurWinSystem, m_Ctx.FillWindowingData(contextID)); + m_Output->SetPixelContext(m_Ctx.CurWindowingSystem(), m_Ctx.FillWindowingData(contextID)); ui->render->setOutput(m_Output); ui->pixelContext->setOutput(m_Output); @@ -2499,7 +2489,7 @@ void TextureViewer::OnLogfileLoaded() GUIInvoke::call([this]() { OnEventChanged(m_Ctx.CurEvent()); }); }); - m_Watcher = new QFileSystemWatcher({m_Ctx.ConfigFile("")}, this); + m_Watcher = new QFileSystemWatcher({ConfigFilePath("")}, this); QObject::connect(m_Watcher, &QFileSystemWatcher::fileChanged, this, &TextureViewer::customShaderModified); @@ -2618,7 +2608,7 @@ void TextureViewer::OnEventChanged(uint32_t eventID) Following follow(FollowType::OutputColour, ShaderStage::Pixel, rt, 0); QString bindName = copy ? tr("Destination") : ""; QString slotName = - copy ? tr("DST") : (m_Ctx.CurPipelineState.OutputAbbrev() + QString::number(rt)); + copy ? tr("DST") : (m_Ctx.CurPipelineState().OutputAbbrev() + QString::number(rt)); InitResourcePreview(prev, RTs[rt].Id, RTs[rt].typeHint, false, follow, bindName, slotName); } @@ -3212,16 +3202,10 @@ void TextureViewer::on_viewTexBuffer_clicked() if(texptr) { - BufferViewer *viewer = new BufferViewer(m_Ctx, false, m_Ctx.mainWindow()); + IBufferViewer *viewer = + m_Ctx.ViewTextureAsBuffer(m_TexDisplay.sliceFace, m_TexDisplay.mip, texptr->ID); - viewer->ViewTexture(m_TexDisplay.sliceFace, m_TexDisplay.mip, texptr->ID); - - m_Ctx.setupDockWindow(viewer); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(viewer, ref); + m_Ctx.AddDockWindow(viewer->Widget(), DockReference::AddTo, this); } } @@ -3319,20 +3303,15 @@ void TextureViewer::on_debugPixelContext_clicked() QString debugContext = tr("Pixel %1,%2").arg(x).arg(y); const ShaderReflection *shaderDetails = - m_Ctx.CurPipelineState.GetShaderReflection(ShaderStage::Pixel); + m_Ctx.CurPipelineState().GetShaderReflection(ShaderStage::Pixel); const ShaderBindpointMapping &bindMapping = - m_Ctx.CurPipelineState.GetBindpointMapping(ShaderStage::Pixel); + m_Ctx.CurPipelineState().GetBindpointMapping(ShaderStage::Pixel); // viewer takes ownership of the trace - ShaderViewer *s = ShaderViewer::debugShader(m_Ctx, &bindMapping, shaderDetails, - ShaderStage::Pixel, trace, debugContext, this); + IShaderViewer *s = m_Ctx.DebugShader(&bindMapping, shaderDetails, ShaderStage::Pixel, trace, + debugContext, this); - m_Ctx.setupDockWindow(s); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(s, ref); + m_Ctx.AddDockWindow(s->Widget(), DockReference::AddTo, this); }); }); } @@ -3347,15 +3326,9 @@ void TextureViewer::on_pixelHistory_clicked() int x = m_PickedPoint.x() >> (int)m_TexDisplay.mip; int y = m_PickedPoint.y() >> (int)m_TexDisplay.mip; - PixelHistoryView *hist = - new PixelHistoryView(m_Ctx, texptr->ID, QPoint(x, y), m_TexDisplay, m_Ctx.mainWindow()); + IPixelHistoryView *hist = m_Ctx.ViewPixelHistory(texptr->ID, x, y, m_TexDisplay); - m_Ctx.setupDockWindow(hist); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::RightOf, manager->areaOf(this), 0.2f); - manager->addToolWindow(hist, ref); + m_Ctx.AddDockWindow(hist->Widget(), DockReference::RightOf, this, 0.2f); // add a short delay so that controls repainting after a new panel appears can get at the // render thread before we insert the long blocking pixel history task @@ -3367,7 +3340,7 @@ void TextureViewer::on_pixelHistory_clicked() m_TexDisplay.sampleIdx, m_TexDisplay.typeHint, history); GUIInvoke::call([hist, history] { - hist->setHistory(*history); + hist->SetHistory(*history); delete history; }); }); @@ -3481,8 +3454,8 @@ void TextureViewer::reloadCustomShaders(const QString &filter) } QStringList files = - QDir(m_Ctx.ConfigFile("")) - .entryList({QString("*.%1").arg(m_Ctx.CurPipelineState.GetShaderExtension())}, + QDir(ConfigFilePath("")) + .entryList({QString("*.%1").arg(m_Ctx.CurPipelineState().GetShaderExtension())}, QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase); QStringList watchedFiles = m_Watcher->files(); @@ -3493,11 +3466,11 @@ void TextureViewer::reloadCustomShaders(const QString &filter) QString fn = QFileInfo(f).baseName(); QString key = fn.toUpper(); - m_Watcher->addPath(m_Ctx.ConfigFile(f)); + m_Watcher->addPath(ConfigFilePath(f)); if(!m_CustomShaders.contains(key) && !m_CustomShadersBusy.contains(key)) { - QFile fileHandle(m_Ctx.ConfigFile(f)); + QFile fileHandle(ConfigFilePath(f)); if(fileHandle.open(QFile::ReadOnly | QFile::Text)) { QTextStream stream(&fileHandle); @@ -3515,8 +3488,8 @@ void TextureViewer::reloadCustomShaders(const QString &filter) if(m_CustomShaderEditor.contains(key)) { - ShaderViewer *editor = m_CustomShaderEditor[key]; - GUIInvoke::call([editor, errors]() { editor->showErrors(ToQStr(errors)); }); + IShaderViewer *editor = m_CustomShaderEditor[key]; + GUIInvoke::call([editor, errors]() { editor->ShowErrors(ToQStr(errors)); }); } GUIInvoke::call([this, fn, key, id]() { @@ -3555,7 +3528,7 @@ void TextureViewer::on_customCreate_clicked() return; } - QString path = m_Ctx.ConfigFile(filename + "." + m_Ctx.CurPipelineState.GetShaderExtension()); + QString path = ConfigFilePath(filename + "." + m_Ctx.CurPipelineState().GetShaderExtension()); QString src; @@ -3610,7 +3583,7 @@ void TextureViewer::on_customEdit_clicked() return; } - QString path = m_Ctx.ConfigFile(filename + "." + m_Ctx.CurPipelineState.GetShaderExtension()); + QString path = ConfigFilePath(filename + "." + m_Ctx.CurPipelineState().GetShaderExtension()); QString src; @@ -3632,10 +3605,10 @@ void TextureViewer::on_customEdit_clicked() QStringMap files; files[filename] = src; - ShaderViewer *s = ShaderViewer::editShader( - m_Ctx, true, "main", files, + IShaderViewer *s = m_Ctx.EditShader( + true, "main", files, // Save Callback - [this, key, filename, path](CaptureContext *ctx, ShaderViewer *viewer, + [this, key, filename, path](ICaptureContext *ctx, IShaderViewer *viewer, const QStringMap &updatedfiles) { { QFile fileHandle(path); @@ -3656,16 +3629,12 @@ void TextureViewer::on_customEdit_clicked() } }, - [this, key](CaptureContext *ctx) { m_CustomShaderEditor.remove(key); }, m_Ctx.mainWindow()); + [this, key](ICaptureContext *ctx) { m_CustomShaderEditor.remove(key); }, + m_Ctx.GetMainWindow()->Widget()); m_CustomShaderEditor[key] = s; - m_Ctx.setupDockWindow(s); - - ToolWindowManager *manager = ToolWindowManager::managerOf(this); - - ToolWindowManager::AreaReference ref(ToolWindowManager::AddTo, manager->areaOf(this)); - manager->addToolWindow(s, ref); + m_Ctx.AddDockWindow(s->Widget(), DockReference::AddTo, this); } void TextureViewer::on_customDelete_clicked() @@ -3693,7 +3662,7 @@ void TextureViewer::on_customDelete_clicked() if(res == QMessageBox::Yes) { - QString path = m_Ctx.ConfigFile(shaderName + "." + m_Ctx.CurPipelineState.GetShaderExtension()); + QString path = ConfigFilePath(shaderName + "." + m_Ctx.CurPipelineState().GetShaderExtension()); if(!QFileInfo::exists(path)) { RDDialog::critical( diff --git a/qrenderdoc/Windows/TextureViewer.h b/qrenderdoc/Windows/TextureViewer.h index 277d29ae3..dc86b2ee2 100644 --- a/qrenderdoc/Windows/TextureViewer.h +++ b/qrenderdoc/Windows/TextureViewer.h @@ -35,7 +35,6 @@ class TextureViewer; } class ResourcePreview; -class ShaderViewer; class ThumbnailStrip; class TextureGoto; class QFileSystemWatcher; @@ -63,34 +62,34 @@ struct Following bool operator==(const Following &o); bool operator!=(const Following &o); - static void GetDrawContext(CaptureContext &ctx, bool ©, bool &compute); + static void GetDrawContext(ICaptureContext &ctx, bool ©, bool &compute); - int GetHighestMip(CaptureContext &ctx); - int GetFirstArraySlice(CaptureContext &ctx); - CompType GetTypeHint(CaptureContext &ctx); + int GetHighestMip(ICaptureContext &ctx); + int GetFirstArraySlice(ICaptureContext &ctx); + CompType GetTypeHint(ICaptureContext &ctx); - ResourceId GetResourceId(CaptureContext &ctx); - BoundResource GetBoundResource(CaptureContext &ctx, int arrayIdx); + ResourceId GetResourceId(ICaptureContext &ctx); + BoundResource GetBoundResource(ICaptureContext &ctx, int arrayIdx); - static QVector GetOutputTargets(CaptureContext &ctx); + static QVector GetOutputTargets(ICaptureContext &ctx); - static BoundResource GetDepthTarget(CaptureContext &ctx); + static BoundResource GetDepthTarget(ICaptureContext &ctx); - QMap> GetReadWriteResources(CaptureContext &ctx); + QMap> GetReadWriteResources(ICaptureContext &ctx); - static QMap> GetReadWriteResources(CaptureContext &ctx, + static QMap> GetReadWriteResources(ICaptureContext &ctx, ShaderStage stage); - QMap> GetReadOnlyResources(CaptureContext &ctx); + QMap> GetReadOnlyResources(ICaptureContext &ctx); - static QMap> GetReadOnlyResources(CaptureContext &ctx, + static QMap> GetReadOnlyResources(ICaptureContext &ctx, ShaderStage stage); - const ShaderReflection *GetReflection(CaptureContext &ctx); - static const ShaderReflection *GetReflection(CaptureContext &ctx, ShaderStage stage); + const ShaderReflection *GetReflection(ICaptureContext &ctx); + static const ShaderReflection *GetReflection(ICaptureContext &ctx, ShaderStage stage); - const ShaderBindpointMapping &GetMapping(CaptureContext &ctx); - static const ShaderBindpointMapping &GetMapping(CaptureContext &ctx, ShaderStage stage); + const ShaderBindpointMapping &GetMapping(ICaptureContext &ctx); + static const ShaderBindpointMapping &GetMapping(ICaptureContext &ctx, ShaderStage stage); }; struct TexSettings @@ -115,7 +114,7 @@ struct TexSettings CompType typeHint; }; -class TextureViewer : public QFrame, public ILogViewerForm +class TextureViewer : public QFrame, public ITextureViewer, public ILogViewerForm { private: Q_OBJECT @@ -123,16 +122,19 @@ private: Q_PROPERTY(QVariant persistData READ persistData WRITE setPersistData DESIGNABLE false SCRIPTABLE false) public: - explicit TextureViewer(CaptureContext &ctx, QWidget *parent = 0); + explicit TextureViewer(ICaptureContext &ctx, QWidget *parent = 0); ~TextureViewer(); - void OnLogfileLoaded(); - void OnLogfileClosed(); - void OnSelectedEventChanged(uint32_t eventID) {} - void OnEventChanged(uint32_t eventID); + // ITextureViewer + QWidget *Widget() override { return this; } + void ViewTexture(ResourceId ID, bool focus) override; + void GotoLocation(int x, int y) override; - void GotoLocation(int x, int y); - void ViewTexture(ResourceId ID, bool focus); + // ILogViewerForm + void OnLogfileLoaded() override; + void OnLogfileClosed() override; + void OnSelectedEventChanged(uint32_t eventID) override {} + void OnEventChanged(uint32_t eventID) override; QVariant persistData(); void setPersistData(const QVariant &persistData); @@ -296,7 +298,7 @@ private: TextureGoto *m_Goto; Ui::TextureViewer *ui; - CaptureContext &m_Ctx; + ICaptureContext &m_Ctx; IReplayOutput *m_Output = NULL; TextureDescription *m_CachedTexture; @@ -306,7 +308,7 @@ private: QFileSystemWatcher *m_Watcher = NULL; QStringList m_CustomShadersBusy; QMap m_CustomShaders; - QMap m_CustomShaderEditor; + QMap m_CustomShaderEditor; void reloadCustomShaders(const QString &filter); diff --git a/qrenderdoc/qrenderdoc.pro b/qrenderdoc/qrenderdoc.pro index 1361b4649..f832836d1 100644 --- a/qrenderdoc/qrenderdoc.pro +++ b/qrenderdoc/qrenderdoc.pro @@ -146,15 +146,16 @@ win32 { SOURCES += Code/qrenderdoc.cpp \ Code/qprocessinfo.cpp \ Code/RenderManager.cpp \ - Code/CommonPipelineState.cpp \ - Code/PersistantConfig.cpp \ Code/CaptureContext.cpp \ Code/ScintillaSyntax.cpp \ Code/QRDUtils.cpp \ Code/FormatElement.cpp \ - Code/RemoteHost.cpp \ Code/Resources.cpp \ Code/pyrenderdoc/PythonContext.cpp \ + Code/Interface/QRDInterface.cpp \ + Code/Interface/CommonPipelineState.cpp \ + Code/Interface/PersistantConfig.cpp \ + Code/Interface/RemoteHost.cpp \ Windows/Dialogs/AboutDialog.cpp \ Windows/MainWindow.cpp \ Windows/EventBrowser.cpp \ @@ -201,13 +202,14 @@ SOURCES += Code/qrenderdoc.cpp \ HEADERS += Code/CaptureContext.h \ Code/qprocessinfo.h \ Code/RenderManager.h \ - Code/PersistantConfig.h \ - Code/CommonPipelineState.h \ Code/ScintillaSyntax.h \ - Code/RemoteHost.h \ Code/QRDUtils.h \ Code/Resources.h \ Code/pyrenderdoc/PythonContext.h \ + Code/Interface/QRDInterface.h \ + Code/Interface/CommonPipelineState.h \ + Code/Interface/PersistantConfig.h \ + Code/Interface/RemoteHost.h \ Windows/Dialogs/AboutDialog.h \ Windows/MainWindow.h \ Windows/EventBrowser.h \ diff --git a/qrenderdoc/qrenderdoc_local.vcxproj b/qrenderdoc/qrenderdoc_local.vcxproj index d69515f77..c6468dbda 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj +++ b/qrenderdoc/qrenderdoc_local.vcxproj @@ -614,13 +614,14 @@ 4458;%(DisableSpecificWarnings) _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - - + + + + - @@ -851,6 +852,10 @@ $(IntDir)generated\moc_%(Filename).cpp + + + + @@ -884,8 +889,6 @@ - - %(Fullpath);$(ProjectDir)3rdparty\qt\$(Platform)\bin\moc.exe;%(AdditionalInputs) @@ -899,7 +902,6 @@ MOC %(Filename).h $(IntDir)generated\moc_%(Filename).cpp - diff --git a/qrenderdoc/qrenderdoc_local.vcxproj.filters b/qrenderdoc/qrenderdoc_local.vcxproj.filters index 572d39cf3..581703e07 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj.filters +++ b/qrenderdoc/qrenderdoc_local.vcxproj.filters @@ -67,6 +67,9 @@ {4a14bfec-662c-410a-8d94-dccf5ba6cb0b} + + {7986f203-466f-4a74-93a2-6feeaec3b05b} + @@ -351,18 +354,12 @@ Widgets\Extended - - Code - Windows\Dialogs Windows\Dialogs - - Code - Code @@ -372,9 +369,6 @@ Windows - - Code - Windows\Dialogs @@ -567,6 +561,18 @@ Generated Files + + Code\Interface + + + Code\Interface + + + Code\Interface + + + Code\Interface + @@ -578,9 +584,6 @@ Code - - Code - Code @@ -764,15 +767,9 @@ Code - - Code - Resources - - Code - Code @@ -866,6 +863,18 @@ Generated Files + + Code\Interface + + + Code\Interface + + + Code\Interface + + + Code\Interface +