mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Support multiple custom shaders directories for Texture Viewer
This commit is contained in:
@@ -302,7 +302,7 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, bool, bool, TextureViewer_PerTexYFlip, false) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, QString, rdcstr, TextureViewer_CustomShadersDirectory, "") \
|
||||
CONFIG_SETTING(public, QVariantList, rdcarray<rdcstr>, TextureViewer_ShaderDirs) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, bool, bool, AlwaysReplayLocally, false) \
|
||||
\
|
||||
@@ -525,12 +525,9 @@ For more information about some of these settings that are user-facing see
|
||||
|
||||
Defaults to ``False``.
|
||||
|
||||
.. data:: TextureViewer_CustomShadersDirectory
|
||||
.. data:: TextureViewer_ShadersDirs
|
||||
|
||||
Path to the directory containing custom shader files for Texture Viewer. If left empty, config
|
||||
directory is used.
|
||||
|
||||
Defaults to ``""``
|
||||
List of the directories containing custom shader files for the Texture Viewer.
|
||||
|
||||
.. data:: AlwaysReplayLocally
|
||||
|
||||
|
||||
@@ -127,7 +127,6 @@ 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);
|
||||
|
||||
@@ -565,26 +564,48 @@ void SettingsDialog::on_TextureViewer_PerTexYFlip_toggled(bool checked)
|
||||
m_Ctx.Config().Save();
|
||||
}
|
||||
|
||||
void SettingsDialog::on_browseCustomShadersPath_clicked()
|
||||
void SettingsDialog::on_TextureViewer_ChooseShaderDirectories_clicked()
|
||||
{
|
||||
QString dir = RDDialog::getExistingDirectory(this, tr("Choose directory for custom shaders"),
|
||||
m_Ctx.Config().TextureViewer_CustomShadersDirectory);
|
||||
QDialog listEditor;
|
||||
|
||||
if(!dir.isEmpty())
|
||||
listEditor.setWindowTitle(tr("Custom shaders search directories"));
|
||||
listEditor.setWindowFlags(listEditor.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
OrderedListEditor list(tr("Shaders Directory"), BrowseMode::Folder);
|
||||
|
||||
QVBoxLayout layout;
|
||||
QDialogButtonBox okCancel;
|
||||
okCancel.setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
||||
layout.addWidget(&list);
|
||||
layout.addWidget(&okCancel);
|
||||
|
||||
QObject::connect(&okCancel, &QDialogButtonBox::accepted, &listEditor, &QDialog::accept);
|
||||
QObject::connect(&okCancel, &QDialogButtonBox::rejected, &listEditor, &QDialog::reject);
|
||||
|
||||
listEditor.setLayout(&layout);
|
||||
|
||||
QStringList items;
|
||||
for(const rdcstr &dir : m_Ctx.Config().TextureViewer_ShaderDirs)
|
||||
{
|
||||
m_Ctx.Config().TextureViewer_CustomShadersDirectory = dir;
|
||||
ui->TextureViewer_CustomShadersPath->setText(dir);
|
||||
items.append(dir);
|
||||
}
|
||||
|
||||
m_Ctx.Config().Save();
|
||||
}
|
||||
list.setItems(items);
|
||||
|
||||
void SettingsDialog::on_resetCustomShadersPath_clicked()
|
||||
{
|
||||
m_Ctx.Config().TextureViewer_CustomShadersDirectory = "";
|
||||
ui->TextureViewer_CustomShadersPath->setText(QString());
|
||||
int res = RDDialog::show(&listEditor);
|
||||
|
||||
m_Ctx.Config().Save();
|
||||
if(res)
|
||||
{
|
||||
items = list.getItems();
|
||||
|
||||
rdcarray<rdcstr> newDirs(items.size());
|
||||
for(int i = 0; i < items.size(); i++)
|
||||
{
|
||||
newDirs[i] = items[i];
|
||||
}
|
||||
|
||||
m_Ctx.Config().TextureViewer_ShaderDirs = newDirs;
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::on_TextureViewer_ResetRange_toggled(bool checked)
|
||||
|
||||
@@ -81,8 +81,7 @@ 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();
|
||||
void on_TextureViewer_ChooseShaderDirectories_clicked();
|
||||
|
||||
// shader viewer
|
||||
void on_ShaderViewer_FriendlyNaming_toggled(bool checked);
|
||||
|
||||
@@ -649,29 +649,61 @@ After interop is enabled you will need to reload any capture.</string>
|
||||
<string>Texture Viewer</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="browseCustomShadersPath">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="toolTip">
|
||||
<string>Browse for the directory with custom shaders for Texture Viewer</string>
|
||||
<string>List of the directories with custom shaders</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
<string>Custom shader directories</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="TextureViewer_ResetRange">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset visible range when changing event or texture</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset Range on changing selection</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="TextureViewer_PerTexSettings">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Settings such as visible channels (RGBA) and selected mip/slice are remembered and restored per-texture.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="TextureViewer_ChooseShaderDirectories">
|
||||
<property name="toolTip">
|
||||
<string>Choose custom shader search directories.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose directories</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -691,17 +723,42 @@ After interop is enabled you will need to reload any capture.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_29">
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="TextureViewer_PerTexYFlip">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Path to the directory with custom shaders for Texture Viewer</string>
|
||||
<string>Y-flipping state is remembered and restored per-texture, rather than treated as a global toggle.</string>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Custom shaders directory</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset visible range when changing event or texture</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset Range on changing selection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -714,38 +771,6 @@ After interop is enabled you will need to reload any capture.</string>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="TextureViewer_PerTexSettings">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Settings such as visible channels (RGBA) and selected mip/slice are remembered and restored per-texture.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="TextureViewer_ResetRange">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset visible range when changing event or texture</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="sizePolicy">
|
||||
@@ -762,39 +787,6 @@ After interop is enabled you will need to reload any capture.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="TextureViewer_PerTexYFlip">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Y-flipping state is remembered and restored per-texture, rather than treated as a global toggle.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLineEdit" name="TextureViewer_CustomShadersPath">
|
||||
<property name="toolTip">
|
||||
<string>Path to the directory with custom shaders for Texture Viewer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="resetCustomShadersPath">
|
||||
<property name="toolTip">
|
||||
<string>Reset custom shaders directory to default config path</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -4020,8 +4020,17 @@ void TextureViewer::reloadCustomShaders(const QString &filter)
|
||||
filters.push_back(lit("*.") + it.key());
|
||||
}
|
||||
|
||||
QStringList files = getCustomShadersDir()
|
||||
.entryList(filters, QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase);
|
||||
QStringList files;
|
||||
QList<QDir> shaderDirectories = getShaderDirectories();
|
||||
for(const QDir &dir : shaderDirectories)
|
||||
{
|
||||
QStringList currentDirFiles =
|
||||
dir.entryList(filters, QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase);
|
||||
for(const QString &f : currentDirFiles)
|
||||
{
|
||||
files.append(QDir::cleanPath(dir.absoluteFilePath(f)));
|
||||
}
|
||||
}
|
||||
|
||||
QStringList watchedFiles = m_Watcher->files();
|
||||
if(!watchedFiles.isEmpty())
|
||||
@@ -4037,12 +4046,11 @@ void TextureViewer::reloadCustomShaders(const QString &filter)
|
||||
if(!filter.isEmpty() && filter.toUpper() != key)
|
||||
continue;
|
||||
|
||||
QString filePath = QDir::cleanPath(getCustomShadersDir().absoluteFilePath(f));
|
||||
m_Watcher->addPath(filePath);
|
||||
m_Watcher->addPath(f);
|
||||
|
||||
if(!m_CustomShaders.contains(key) && !m_CustomShadersBusy.contains(key))
|
||||
{
|
||||
QFile fileHandle(filePath);
|
||||
QFile fileHandle(f);
|
||||
if(fileHandle.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
QTextStream stream(&fileHandle);
|
||||
@@ -4134,11 +4142,36 @@ void TextureViewer::reloadCustomShaders(const QString &filter)
|
||||
}
|
||||
}
|
||||
|
||||
QDir TextureViewer::getCustomShadersDir() const
|
||||
QList<QDir> TextureViewer::getShaderDirectories() const
|
||||
{
|
||||
return m_Ctx.Config().TextureViewer_CustomShadersDirectory.empty()
|
||||
? QDir(configFilePath(QString()))
|
||||
: QDir(m_Ctx.Config().TextureViewer_CustomShadersDirectory);
|
||||
QList<QDir> dirs;
|
||||
dirs.reserve(int(m_Ctx.Config().TextureViewer_ShaderDirs.size() + 1u));
|
||||
dirs.append(QDir(configFilePath(QString())));
|
||||
for(const rdcstr &dir : m_Ctx.Config().TextureViewer_ShaderDirs)
|
||||
{
|
||||
dirs.append(QDir(dir));
|
||||
}
|
||||
|
||||
return dirs;
|
||||
}
|
||||
|
||||
QString TextureViewer::getShaderPath(const QString &filename) const
|
||||
{
|
||||
QString path;
|
||||
QList<QDir> directories = getShaderDirectories();
|
||||
for(const QDir &dir : directories)
|
||||
{
|
||||
QStringList currentDirFiles =
|
||||
dir.entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase);
|
||||
|
||||
if(currentDirFiles.contains(filename, Qt::CaseInsensitive))
|
||||
{
|
||||
path = QDir::cleanPath(dir.absoluteFilePath(filename));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void TextureViewer::on_customCreate_clicked()
|
||||
@@ -4184,8 +4217,6 @@ void TextureViewer::on_customCreate_clicked()
|
||||
return;
|
||||
}
|
||||
|
||||
QString path = QDir::cleanPath(getCustomShadersDir().absoluteFilePath(filename));
|
||||
|
||||
QString src;
|
||||
|
||||
if(enc == ShaderEncoding::HLSL)
|
||||
@@ -4216,6 +4247,7 @@ void TextureViewer::on_customCreate_clicked()
|
||||
src = tr("Unknown format - no template available");
|
||||
}
|
||||
|
||||
QString path = QDir::cleanPath(QDir(configFilePath(QString())).absoluteFilePath(filename));
|
||||
QFile fileHandle(path);
|
||||
if(fileHandle.open(QFile::WriteOnly | QIODevice::Truncate | QIODevice::Text))
|
||||
{
|
||||
@@ -4247,8 +4279,7 @@ void TextureViewer::on_customEdit_clicked()
|
||||
return;
|
||||
}
|
||||
|
||||
QString path = QDir::cleanPath(getCustomShadersDir().absoluteFilePath(filename));
|
||||
|
||||
QString path = getShaderPath(filename);
|
||||
QString src;
|
||||
|
||||
QFile fileHandle(path);
|
||||
@@ -4339,7 +4370,8 @@ void TextureViewer::on_customDelete_clicked()
|
||||
|
||||
if(res == QMessageBox::Yes)
|
||||
{
|
||||
QString path = QDir::cleanPath(getCustomShadersDir().absoluteFilePath(shaderName));
|
||||
QString path = getShaderPath(shaderName);
|
||||
|
||||
if(!QFileInfo::exists(path))
|
||||
{
|
||||
RDDialog::critical(
|
||||
@@ -4358,6 +4390,7 @@ void TextureViewer::on_customDelete_clicked()
|
||||
|
||||
ui->customShader->setCurrentText(QString());
|
||||
UI_UpdateChannels();
|
||||
reloadCustomShaders(QString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDir>
|
||||
#include <QFrame>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
@@ -350,7 +351,8 @@ private:
|
||||
|
||||
bool canCompileCustomShader(ShaderEncoding encoding);
|
||||
void reloadCustomShaders(const QString &filter);
|
||||
QDir getCustomShadersDir() const;
|
||||
QList<QDir> getShaderDirectories() const;
|
||||
QString getShaderPath(const QString &filename) const;
|
||||
|
||||
TextureDisplay m_TexDisplay;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user