diff --git a/qrenderdoc/Code/Interface/PersistantConfig.h b/qrenderdoc/Code/Interface/PersistantConfig.h index 7d08eceeb..7b4e1447b 100644 --- a/qrenderdoc/Code/Interface/PersistantConfig.h +++ b/qrenderdoc/Code/Interface/PersistantConfig.h @@ -302,6 +302,8 @@ DECLARE_REFLECTION_STRUCT(BugReport); \ CONFIG_SETTING_VAL(public, bool, bool, TextureViewer_PerTexYFlip, false) \ \ + CONFIG_SETTING_VAL(public, QString, rdcstr, TextureViewer_CustomShadersDirectory, "") \ + \ CONFIG_SETTING_VAL(public, bool, bool, AlwaysReplayLocally, false) \ \ CONFIG_SETTING_VAL(public, int, int, LocalProxyAPI, -1) \ @@ -523,6 +525,13 @@ For more information about some of these settings that are user-facing see Defaults to ``False``. +.. data:: TextureViewer_CustomShadersDirectory + + Path to the directory containing custom shader files for Texture Viewer. If left empty, config + directory is used. + + Defaults to ``""`` + .. data:: AlwaysReplayLocally ``True`` if when loading a capture that was originally captured on a remote device but uses an diff --git a/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp b/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp index 8dddcdf3d..e7c09a0a3 100644 --- a/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp +++ b/qrenderdoc/Windows/Dialogs/SettingsDialog.cpp @@ -127,6 +127,7 @@ SettingsDialog::SettingsDialog(ICaptureContext &ctx, QWidget *parent) ui->TextureViewer_ResetRange->setChecked(m_Ctx.Config().TextureViewer_ResetRange); ui->TextureViewer_PerTexSettings->setChecked(m_Ctx.Config().TextureViewer_PerTexSettings); ui->TextureViewer_PerTexYFlip->setChecked(m_Ctx.Config().TextureViewer_PerTexYFlip); + ui->TextureViewer_CustomShadersPath->setText(m_Ctx.Config().TextureViewer_CustomShadersDirectory); ui->CheckUpdate_AllowChecks->setChecked(m_Ctx.Config().CheckUpdate_AllowChecks); ui->Font_PreferMonospaced->setChecked(m_Ctx.Config().Font_PreferMonospaced); @@ -564,6 +565,28 @@ void SettingsDialog::on_TextureViewer_PerTexYFlip_toggled(bool checked) m_Ctx.Config().Save(); } +void SettingsDialog::on_browseCustomShadersPath_clicked() +{ + QString dir = RDDialog::getExistingDirectory(this, tr("Choose directory for custom shaders"), + m_Ctx.Config().TextureViewer_CustomShadersDirectory); + + if(!dir.isEmpty()) + { + m_Ctx.Config().TextureViewer_CustomShadersDirectory = dir; + ui->TextureViewer_CustomShadersPath->setText(dir); + } + + m_Ctx.Config().Save(); +} + +void SettingsDialog::on_resetCustomShadersPath_clicked() +{ + m_Ctx.Config().TextureViewer_CustomShadersDirectory = ""; + ui->TextureViewer_CustomShadersPath->setText(QString()); + + m_Ctx.Config().Save(); +} + void SettingsDialog::on_TextureViewer_ResetRange_toggled(bool checked) { m_Ctx.Config().TextureViewer_ResetRange = ui->TextureViewer_ResetRange->isChecked(); diff --git a/qrenderdoc/Windows/Dialogs/SettingsDialog.h b/qrenderdoc/Windows/Dialogs/SettingsDialog.h index 149b1705e..b1573ab08 100644 --- a/qrenderdoc/Windows/Dialogs/SettingsDialog.h +++ b/qrenderdoc/Windows/Dialogs/SettingsDialog.h @@ -81,6 +81,8 @@ private slots: void on_TextureViewer_PerTexSettings_toggled(bool checked); void on_TextureViewer_ResetRange_toggled(bool checked); void on_TextureViewer_PerTexYFlip_toggled(bool checked); + void on_browseCustomShadersPath_clicked(); + void on_resetCustomShadersPath_clicked(); // shader viewer void on_ShaderViewer_FriendlyNaming_toggled(bool checked); diff --git a/qrenderdoc/Windows/Dialogs/SettingsDialog.ui b/qrenderdoc/Windows/Dialogs/SettingsDialog.ui index 84594e55a..a4fef3bd2 100644 --- a/qrenderdoc/Windows/Dialogs/SettingsDialog.ui +++ b/qrenderdoc/Windows/Dialogs/SettingsDialog.ui @@ -6,8 +6,8 @@ 0 0 - 561 - 519 + 564 + 530 @@ -410,7 +410,7 @@ e.g. 1000 * 10 = 1e4 A global scale for all fonts in the program. This will only scale text, icons and other UI elements will be scaled according to DPI settings as normal. - true + true @@ -649,6 +649,16 @@ After interop is enabled you will need to reload any capture. Texture Viewer + + + + Browse for the directory with custom shaders for Texture Viewer + + + Browse + + + @@ -665,22 +675,6 @@ After interop is enabled you will need to reload any capture. - - - - - 50 - 0 - - - - Reset visible range when changing event or texture - - - - - - @@ -697,6 +691,29 @@ After interop is enabled you will need to reload any capture. + + + + Path to the directory with custom shaders for Texture Viewer + + + Custom shaders directory + + + + + + + Qt::Vertical + + + + 20 + 378 + + + + @@ -713,6 +730,22 @@ After interop is enabled you will need to reload any capture. + + + + + 50 + 0 + + + + Reset visible range when changing event or texture + + + + + + @@ -745,18 +778,22 @@ After interop is enabled you will need to reload any capture. - - - - Qt::Vertical + + + + Path to the directory with custom shaders for Texture Viewer - - - 20 - 378 - + + + + + + Reset custom shaders directory to default config path - + + Reset + + diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 50a0d0baa..80656ab98 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -4020,8 +4020,7 @@ void TextureViewer::reloadCustomShaders(const QString &filter) filters.push_back(lit("*.") + it.key()); } - QStringList files = - QDir(configFilePath(QString())) + QStringList files = getCustomShadersDir() .entryList(filters, QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase); QStringList watchedFiles = m_Watcher->files(); @@ -4038,11 +4037,12 @@ void TextureViewer::reloadCustomShaders(const QString &filter) if(!filter.isEmpty() && filter.toUpper() != key) continue; - m_Watcher->addPath(configFilePath(f)); + QString filePath = QDir::cleanPath(getCustomShadersDir().absoluteFilePath(f)); + m_Watcher->addPath(filePath); if(!m_CustomShaders.contains(key) && !m_CustomShadersBusy.contains(key)) { - QFile fileHandle(configFilePath(f)); + QFile fileHandle(filePath); if(fileHandle.open(QFile::ReadOnly | QFile::Text)) { QTextStream stream(&fileHandle); @@ -4134,6 +4134,13 @@ void TextureViewer::reloadCustomShaders(const QString &filter) } } +QDir TextureViewer::getCustomShadersDir() const +{ + return m_Ctx.Config().TextureViewer_CustomShadersDirectory.empty() + ? QDir(configFilePath(QString())) + : QDir(m_Ctx.Config().TextureViewer_CustomShadersDirectory); +} + void TextureViewer::on_customCreate_clicked() { QString filename = ui->customShader->currentText(); @@ -4177,7 +4184,7 @@ void TextureViewer::on_customCreate_clicked() return; } - QString path = configFilePath(filename); + QString path = QDir::cleanPath(getCustomShadersDir().absoluteFilePath(filename)); QString src; @@ -4240,7 +4247,7 @@ void TextureViewer::on_customEdit_clicked() return; } - QString path = configFilePath(filename); + QString path = QDir::cleanPath(getCustomShadersDir().absoluteFilePath(filename)); QString src; @@ -4332,7 +4339,7 @@ void TextureViewer::on_customDelete_clicked() if(res == QMessageBox::Yes) { - QString path = configFilePath(shaderName); + QString path = QDir::cleanPath(getCustomShadersDir().absoluteFilePath(shaderName)); if(!QFileInfo::exists(path)) { RDDialog::critical( diff --git a/qrenderdoc/Windows/TextureViewer.h b/qrenderdoc/Windows/TextureViewer.h index b3458184b..e28fc153f 100644 --- a/qrenderdoc/Windows/TextureViewer.h +++ b/qrenderdoc/Windows/TextureViewer.h @@ -350,6 +350,7 @@ private: bool canCompileCustomShader(ShaderEncoding encoding); void reloadCustomShaders(const QString &filter); + QDir getCustomShadersDir() const; TextureDisplay m_TexDisplay; };