From 9ba81634b4bb1d9f90a734bf20071709b7c04f6e Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 3 Apr 2020 12:46:02 +0100 Subject: [PATCH] Improve the title of shader edit windows --- qrenderdoc/Code/CaptureContext.cpp | 6 +++--- qrenderdoc/Code/CaptureContext.h | 2 +- qrenderdoc/Code/Interface/QRDInterface.h | 5 +++-- .../PipelineState/PipelineStateViewer.cpp | 2 +- qrenderdoc/Windows/PythonShell.cpp | 8 ++++---- qrenderdoc/Windows/ShaderViewer.cpp | 17 +++++++++++------ qrenderdoc/Windows/ShaderViewer.h | 6 +++--- qrenderdoc/Windows/TextureViewer.cpp | 2 +- 8 files changed, 27 insertions(+), 21 deletions(-) diff --git a/qrenderdoc/Code/CaptureContext.cpp b/qrenderdoc/Code/CaptureContext.cpp index 15883cfbb..2b7939f25 100644 --- a/qrenderdoc/Code/CaptureContext.cpp +++ b/qrenderdoc/Code/CaptureContext.cpp @@ -2163,14 +2163,14 @@ void CaptureContext::ShowResourceInspector() m_MainWindow->showResourceInspector(); } -IShaderViewer *CaptureContext::EditShader(bool customShader, ShaderStage stage, +IShaderViewer *CaptureContext::EditShader(ResourceId id, ShaderStage stage, const rdcstr &entryPoint, const rdcstrpairs &files, ShaderEncoding shaderEncoding, ShaderCompileFlags flags, IShaderViewer::SaveCallback saveCallback, IShaderViewer::CloseCallback closeCallback) { - return ShaderViewer::EditShader(*this, customShader, stage, entryPoint, files, shaderEncoding, - flags, saveCallback, closeCallback, m_MainWindow->Widget()); + return ShaderViewer::EditShader(*this, id, stage, entryPoint, files, shaderEncoding, flags, + saveCallback, closeCallback, m_MainWindow->Widget()); } IShaderViewer *CaptureContext::DebugShader(const ShaderBindpointMapping *bind, diff --git a/qrenderdoc/Code/CaptureContext.h b/qrenderdoc/Code/CaptureContext.h index d4506d674..4429b84d3 100644 --- a/qrenderdoc/Code/CaptureContext.h +++ b/qrenderdoc/Code/CaptureContext.h @@ -234,7 +234,7 @@ public: void ShowPythonShell() override; void ShowResourceInspector() override; - IShaderViewer *EditShader(bool customShader, ShaderStage stage, const rdcstr &entryPoint, + IShaderViewer *EditShader(ResourceId id, ShaderStage stage, const rdcstr &entryPoint, const rdcstrpairs &files, ShaderEncoding shaderEncoding, ShaderCompileFlags flags, IShaderViewer::SaveCallback saveCallback, IShaderViewer::CloseCallback closeCallback) override; diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index 7ba72a58e..eea25519c 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -1837,7 +1837,8 @@ place if needed. DOCUMENT(R"(Show a new :class:`ShaderViewer` window, showing an editable view of a given shader. -:param bool customShader: ``True`` if the shader being edited is a custom display shader. +:param ~renderdoc.ResourceId id: The shader object, if applicable, that's being edited. If this edit + corresponds to no shader object (such as if it's a custom shader) this can be a null ID. :param ~renderdoc.ShaderStage stage: The shader stage for this shader. :param str entryPoint: The entry point to be used when compiling the edited shader. :param list files: The files stored in a ``list`` with 2-tuples of ``str``. The first element being @@ -1851,7 +1852,7 @@ place if needed. :return: The new :class:`ShaderViewer` window opened but not shown for editing. :rtype: ShaderViewer )"); - virtual IShaderViewer *EditShader(bool customShader, ShaderStage stage, const rdcstr &entryPoint, + virtual IShaderViewer *EditShader(ResourceId id, ShaderStage stage, const rdcstr &entryPoint, const rdcstrpairs &files, ShaderEncoding shaderEncoding, ShaderCompileFlags flags, IShaderViewer::SaveCallback saveCallback, diff --git a/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp index 981c969ab..b58863d68 100644 --- a/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/PipelineStateViewer.cpp @@ -853,7 +853,7 @@ IShaderViewer *PipelineStateViewer::EditShader(ResourceId id, ShaderStage shader }); }; - IShaderViewer *sv = m_Ctx.EditShader(false, shaderType, entry, files, encoding, compileFlags, + IShaderViewer *sv = m_Ctx.EditShader(id, shaderType, entry, files, encoding, compileFlags, saveCallback, closeCallback); m_Ctx.AddDockWindow(sv->Widget(), DockReference::AddTo, this); diff --git a/qrenderdoc/Windows/PythonShell.cpp b/qrenderdoc/Windows/PythonShell.cpp index 863037b3a..8a60f7be6 100644 --- a/qrenderdoc/Windows/PythonShell.cpp +++ b/qrenderdoc/Windows/PythonShell.cpp @@ -405,15 +405,15 @@ struct CaptureContextInvoker : ICaptureContext { InvokeVoidFunction(&ICaptureContext::ShowResourceInspector); } - virtual IShaderViewer *EditShader(bool customShader, ShaderStage stage, const rdcstr &entryPoint, + virtual IShaderViewer *EditShader(ResourceId id, ShaderStage stage, const rdcstr &entryPoint, const rdcstrpairs &files, ShaderEncoding shaderEncoding, ShaderCompileFlags flags, IShaderViewer::SaveCallback saveCallback, IShaderViewer::CloseCallback closeCallback) override { - return InvokeRetFunction(&ICaptureContext::EditShader, customShader, stage, - entryPoint, files, shaderEncoding, flags, - saveCallback, closeCallback); + return InvokeRetFunction(&ICaptureContext::EditShader, id, stage, entryPoint, + files, shaderEncoding, flags, saveCallback, + closeCallback); } virtual IShaderViewer *DebugShader(const ShaderBindpointMapping *bind, diff --git a/qrenderdoc/Windows/ShaderViewer.cpp b/qrenderdoc/Windows/ShaderViewer.cpp index 0bb1900f0..489e857d1 100644 --- a/qrenderdoc/Windows/ShaderViewer.cpp +++ b/qrenderdoc/Windows/ShaderViewer.cpp @@ -183,7 +183,7 @@ ShaderViewer::ShaderViewer(ICaptureContext &ctx, QWidget *parent) m_Ctx.AddCaptureViewer(this); } -void ShaderViewer::editShader(bool customShader, ShaderStage stage, const QString &entryPoint, +void ShaderViewer::editShader(ResourceId id, ShaderStage stage, const QString &entryPoint, const rdcstrpairs &files, ShaderEncoding shaderEncoding, ShaderCompileFlags flags) { @@ -195,7 +195,7 @@ void ShaderViewer::editShader(bool customShader, ShaderStage stage, const QStrin m_Stage = stage; m_Flags = flags; - m_CustomShader = customShader; + m_CustomShader = (id == ResourceId()); // set up compilation parameters for(ShaderEncoding i : values()) @@ -221,7 +221,7 @@ void ShaderViewer::editShader(bool customShader, ShaderStage stage, const QStrin // if it's a custom shader, hide the group entirely (don't allow customisation of compile // parameters). We can still use it to store the parameters passed in. When visible we collapse it // by default. - if(customShader) + if(m_CustomShader) ui->compilationGroup->hide(); // hide debugging windows @@ -231,7 +231,7 @@ void ShaderViewer::editShader(bool customShader, ShaderStage stage, const QStrin ui->callstack->hide(); ui->sourceVars->hide(); - ui->snippets->setVisible(customShader); + ui->snippets->setVisible(m_CustomShader); // hide debugging toolbar buttons ui->debugSep->hide(); @@ -283,12 +283,17 @@ void ShaderViewer::editShader(bool customShader, ShaderStage stage, const QStrin sel = scintilla; if(sel == scintilla || title.isEmpty()) - title = tr("%1 - Edit (%2)").arg(entryPoint).arg(name); + title = tr(" - %1 - %2()").arg(name).arg(entryPoint); } if(sel != NULL) ToolWindowManager::raiseToolWindow(sel); + if(m_CustomShader) + title.prepend(tr("Editing %1 Shader").arg(ToQStr(stage, m_Ctx.APIProps().pipelineType))); + else + title.prepend(tr("Editing %1").arg(m_Ctx.GetResourceNameUnsuffixed(id))); + setWindowTitle(title); if(files.count() > 2) @@ -311,7 +316,7 @@ void ShaderViewer::editShader(bool customShader, ShaderStage stage, const QStrin ui->docking->setToolWindowProperties( m_Errors, ToolWindowManager::HideCloseButton | ToolWindowManager::DisallowFloatWindow); - if(!customShader) + if(!m_CustomShader) { ui->compilationGroup->setWindowTitle(tr("Compilation Settings")); ui->docking->addToolWindow(ui->compilationGroup, diff --git a/qrenderdoc/Windows/ShaderViewer.h b/qrenderdoc/Windows/ShaderViewer.h index f8e30f76c..7729d4769 100644 --- a/qrenderdoc/Windows/ShaderViewer.h +++ b/qrenderdoc/Windows/ShaderViewer.h @@ -61,7 +61,7 @@ class ShaderViewer : public QFrame, public IShaderViewer, public ICaptureViewer Q_OBJECT public: - static IShaderViewer *EditShader(ICaptureContext &ctx, bool customShader, ShaderStage stage, + static IShaderViewer *EditShader(ICaptureContext &ctx, ResourceId id, ShaderStage stage, const QString &entryPoint, const rdcstrpairs &files, ShaderEncoding shaderEncoding, ShaderCompileFlags flags, IShaderViewer::SaveCallback saveCallback, @@ -70,7 +70,7 @@ public: ShaderViewer *ret = new ShaderViewer(ctx, parent); ret->m_SaveCallback = saveCallback; ret->m_CloseCallback = closeCallback; - ret->editShader(customShader, stage, entryPoint, files, shaderEncoding, flags); + ret->editShader(id, stage, entryPoint, files, shaderEncoding, flags); return ret; } @@ -154,7 +154,7 @@ public slots: private: explicit ShaderViewer(ICaptureContext &ctx, QWidget *parent = 0); - void editShader(bool customShader, ShaderStage stage, const QString &entryPoint, + void editShader(ResourceId id, ShaderStage stage, const QString &entryPoint, const rdcstrpairs &files, ShaderEncoding shaderEncoding, ShaderCompileFlags flags); void debugShader(const ShaderBindpointMapping *bind, const ShaderReflection *shader, ResourceId pipeline, ShaderDebugTrace *trace, const QString &debugContext); diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 43d07e0c2..0b3928f77 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -4225,7 +4225,7 @@ void TextureViewer::on_customEdit_clicked() QPointer thisPointer(this); IShaderViewer *s = m_Ctx.EditShader( - true, ShaderStage::Fragment, lit("main"), files, + ResourceId(), ShaderStage::Fragment, lit("main"), files, encodingExtensions[QFileInfo(filename).completeSuffix()], ShaderCompileFlags(), // Save Callback [thisPointer, key, filename, path](ICaptureContext *ctx, IShaderViewer *viewer,