mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-24 14:45:53 +00:00
Add configuration system for core renderdoc module
* This allows persistent config storage and registering tweak variables that works independent of the UI's configuration. * Config vars can be debug only, which means they will be compiled out in stable version releases. This allows for debug-logging tweaks that are available in all builds (including nightly builds) for diagnostic purposes, but have zero overhead in stable releases. * Variables have a loose hierarchy defined with _ or . to separate nodes.
This commit is contained in:
@@ -153,6 +153,16 @@ bool PersistantConfig::Serialize(const rdcstr &filename)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct LegacyData
|
||||
{
|
||||
QString _Android_SDKPath;
|
||||
QString _Android_JDKPath;
|
||||
uint32_t _Android_MaxConnectTimeout = 30;
|
||||
bool _ExternalTool_RGPIntegration = false;
|
||||
bool _ShaderViewer_FriendlyNaming = true;
|
||||
QVariantMap _ConfigSettings;
|
||||
};
|
||||
|
||||
QVariantMap PersistantConfig::storeValues() const
|
||||
{
|
||||
QVariantMap ret;
|
||||
@@ -167,6 +177,15 @@ QVariantMap PersistantConfig::storeValues() const
|
||||
|
||||
CONFIG_SETTINGS()
|
||||
|
||||
// store any legacy values even though we don't need them
|
||||
|
||||
ret[lit("Android_SDKPath")] = m_Legacy->_Android_SDKPath;
|
||||
ret[lit("Android_JDKPath")] = m_Legacy->_Android_JDKPath;
|
||||
ret[lit("Android_MaxConnectTimeout")] = m_Legacy->_Android_MaxConnectTimeout;
|
||||
ret[lit("ExternalTool_RGPIntegration")] = m_Legacy->_ExternalTool_RGPIntegration;
|
||||
ret[lit("ShaderViewer_FriendlyNaming")] = m_Legacy->_ShaderViewer_FriendlyNaming;
|
||||
ret[lit("ConfigSettings")] = m_Legacy->_ConfigSettings;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -197,6 +216,85 @@ void PersistantConfig::applyValues(const QVariantMap &values)
|
||||
// apply reasonable bounds to font scale to avoid invalid values
|
||||
// 25% - 400%
|
||||
Font_GlobalScale = qBound(0.25f, Font_GlobalScale, 4.0f);
|
||||
|
||||
// port old values that were saved here but are now saved in core.
|
||||
// We only want to do this once, but we want to leave these values in the config to allow for
|
||||
// people running old versions after running a new version - we don't want to remove all of their
|
||||
// settings yet.
|
||||
// So what we do is store an extra setting indicating that it's been ported - if that setting is
|
||||
// present we just store/save them blindly. This does mean they can change but we won't re-port
|
||||
// them.
|
||||
// After the new config ships in a stable release we can remove this as we don't generally support
|
||||
// forwards compatibility, only backwards compatibility, so it will be OK to drop the config
|
||||
// settings.
|
||||
bool processed = false;
|
||||
if(values.contains(lit("ConfigSettings")) &&
|
||||
values[lit("ConfigSettings")].toMap().contains(lit("modern.config.ported")))
|
||||
processed = true;
|
||||
|
||||
bool saveConfig = false;
|
||||
|
||||
#define CORE_SETTING(variantType, oldName, newName, data) \
|
||||
if(values.contains(lit(#oldName))) \
|
||||
{ \
|
||||
m_Legacy->_##oldName = values[lit(#oldName)].value<variantType>(); \
|
||||
if(!processed) \
|
||||
{ \
|
||||
SDObject *setting = RENDERDOC_SetConfigSetting(newName); \
|
||||
if(setting) \
|
||||
setting->data = m_Legacy->_##oldName; \
|
||||
saveConfig = true; \
|
||||
} \
|
||||
}
|
||||
|
||||
CORE_SETTING(QString, Android_SDKPath, "Android.SDKDirPath", data.str);
|
||||
CORE_SETTING(QString, Android_JDKPath, "Android.JDKDirPath", data.str);
|
||||
CORE_SETTING(uint32_t, Android_MaxConnectTimeout, "Android.MaxConnectTimeout", data.basic.u);
|
||||
CORE_SETTING(bool, ExternalTool_RGPIntegration, "AMD.RGP.Enable", data.basic.b);
|
||||
CORE_SETTING(bool, ShaderViewer_FriendlyNaming, "DXBC.Disassembly.FriendlyNaming", data.basic.b);
|
||||
|
||||
if(values.contains(lit("ConfigSettings")))
|
||||
{
|
||||
QVariantMap &settings = m_Legacy->_ConfigSettings;
|
||||
settings = values[lit("ConfigSettings")].toMap();
|
||||
|
||||
if(!processed)
|
||||
{
|
||||
if(settings.contains(lit("shader.debug.searchPaths")))
|
||||
{
|
||||
QStringList searchPaths = settings[lit("shader.debug.searchPaths")].toString().split(
|
||||
QLatin1Char(';'), QString::SkipEmptyParts);
|
||||
|
||||
SDObject *debug = RENDERDOC_SetConfigSetting("DXBC.Debug.SearchDirPaths");
|
||||
|
||||
debug->DeleteChildren();
|
||||
debug->data.children.resize(searchPaths.size());
|
||||
|
||||
for(int i = 0; i < searchPaths.size(); i++)
|
||||
debug->data.children[i] = makeSDString("$el", searchPaths[i]);
|
||||
}
|
||||
|
||||
if(settings.contains(lit("d3d12ShaderDebugging")))
|
||||
{
|
||||
RENDERDOC_SetConfigSetting("D3D12_ShaderDebugging")->data.basic.b =
|
||||
settings[lit("d3d12ShaderDebugging")].toBool();
|
||||
}
|
||||
|
||||
if(settings.contains(lit("vulkanShaderDebugging")))
|
||||
{
|
||||
RENDERDOC_SetConfigSetting("Vulkan_ShaderDebugging")->data.basic.b =
|
||||
settings[lit("vulkanShaderDebugging")].toBool();
|
||||
}
|
||||
|
||||
saveConfig = true;
|
||||
}
|
||||
|
||||
// mark the settings as ported so we don't do it again
|
||||
settings[lit("modern.config.ported")] = true;
|
||||
}
|
||||
|
||||
if(saveConfig)
|
||||
RENDERDOC_SaveConfigSettings();
|
||||
}
|
||||
|
||||
static QMutex RemoteHostLock;
|
||||
@@ -265,20 +363,6 @@ void PersistantConfig::RemoveRemoteHost(RemoteHost host)
|
||||
|
||||
void PersistantConfig::UpdateEnumeratedProtocolDevices()
|
||||
{
|
||||
QString androidSDKPath = (!Android_SDKPath.isEmpty() && QFile::exists(Android_SDKPath))
|
||||
? QString(Android_SDKPath)
|
||||
: QString();
|
||||
|
||||
SetConfigSetting("androidSDKPath", androidSDKPath);
|
||||
|
||||
QString androidJDKPath = (!Android_JDKPath.isEmpty() && QFile::exists(Android_JDKPath))
|
||||
? QString(Android_JDKPath)
|
||||
: QString();
|
||||
|
||||
SetConfigSetting("androidJDKPath", androidJDKPath);
|
||||
|
||||
SetConfigSetting("MaxConnectTimeout", QString::number(Android_MaxConnectTimeout));
|
||||
|
||||
rdcarray<RemoteHost> enumeratedDevices;
|
||||
|
||||
rdcarray<rdcstr> protocols;
|
||||
@@ -350,24 +434,20 @@ bool PersistantConfig::SetStyle()
|
||||
return false;
|
||||
}
|
||||
|
||||
PersistantConfig::PersistantConfig()
|
||||
{
|
||||
m_Legacy = new LegacyData;
|
||||
}
|
||||
|
||||
PersistantConfig::~PersistantConfig()
|
||||
{
|
||||
delete m_Legacy;
|
||||
}
|
||||
|
||||
bool PersistantConfig::Load(const rdcstr &filename)
|
||||
{
|
||||
bool ret = Deserialize(filename);
|
||||
|
||||
// perform some sanitisation to make sure config is always in sensible state
|
||||
for(const rdcstrpair &key : ConfigSettings)
|
||||
{
|
||||
// redundantly set each setting so it is flushed to the core dll
|
||||
SetConfigSetting(key.first, key.second);
|
||||
}
|
||||
|
||||
RENDERDOC_SetConfigSetting("Disassembly_FriendlyNaming", ShaderViewer_FriendlyNaming ? "1" : "0");
|
||||
RENDERDOC_SetConfigSetting("ExternalTool_RGPIntegration", ExternalTool_RGPIntegration ? "1" : "0");
|
||||
|
||||
RDDialog::DefaultBrowsePath = LastFileBrowsePath;
|
||||
|
||||
// localhost should always be available as a remote host
|
||||
@@ -501,9 +581,6 @@ bool PersistantConfig::Save()
|
||||
if(m_Filename.isEmpty())
|
||||
return true;
|
||||
|
||||
RENDERDOC_SetConfigSetting("Disassembly_FriendlyNaming", ShaderViewer_FriendlyNaming ? "1" : "0");
|
||||
RENDERDOC_SetConfigSetting("ExternalTool_RGPIntegration", ExternalTool_RGPIntegration ? "1" : "0");
|
||||
|
||||
LastFileBrowsePath = RDDialog::DefaultBrowsePath;
|
||||
|
||||
// truncate the lists to a maximum of 9 items, allow more to exist in memory
|
||||
@@ -557,36 +634,6 @@ void AddRecentFile(rdcarray<rdcstr> &recentList, const rdcstr &file)
|
||||
recentList.push_back(path);
|
||||
}
|
||||
|
||||
void PersistantConfig::SetConfigSetting(const rdcstr &name, const rdcstr &value)
|
||||
{
|
||||
if(name.isEmpty())
|
||||
return;
|
||||
|
||||
bool found = false;
|
||||
for(rdcstrpair &kv : ConfigSettings)
|
||||
{
|
||||
if(kv.first == name)
|
||||
{
|
||||
kv.second = value;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found)
|
||||
ConfigSettings.push_back(make_rdcpair(name, value));
|
||||
RENDERDOC_SetConfigSetting(name.data(), value.data());
|
||||
}
|
||||
|
||||
rdcstr PersistantConfig::GetConfigSetting(const rdcstr &name)
|
||||
{
|
||||
for(const rdcstrpair &kv : ConfigSettings)
|
||||
if(kv.first == name)
|
||||
return kv.second;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
ShaderProcessingTool::ShaderProcessingTool(const QVariant &var)
|
||||
{
|
||||
QVariantMap map = var.toMap();
|
||||
|
||||
@@ -302,8 +302,6 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, bool, bool, TextureViewer_PerTexYFlip, false) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, bool, bool, ShaderViewer_FriendlyNaming, true) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, bool, bool, AlwaysReplayLocally, false) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, int, int, LocalProxyAPI, -1) \
|
||||
@@ -336,12 +334,6 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, bool, bool, Font_PreferMonospaced, false) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, QString, rdcstr, Android_SDKPath, "") \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, QString, rdcstr, Android_JDKPath, "") \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, int, int, Android_MaxConnectTimeout, 30) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, QDateTime, rdcdatetime, UnsupportedAndroid_LastUpdate, \
|
||||
rdcdatetime(2015, 01, 01)) \
|
||||
\
|
||||
@@ -359,8 +351,6 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
CONFIG_SETTING_VAL(public, QDateTime, rdcdatetime, DegradedCapture_LastUpdate, \
|
||||
rdcdatetime(2015, 01, 01)) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, bool, bool, ExternalTool_RGPIntegration, false) \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, QString, rdcstr, ExternalTool_RadeonGPUProfiler, "") \
|
||||
\
|
||||
CONFIG_SETTING_VAL(public, bool, bool, Tips_HasSeenFirst, false) \
|
||||
@@ -385,8 +375,6 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
\
|
||||
CONFIG_SETTING(public, QVariantList, rdcarray<rdcstr>, AlwaysLoad_Extensions) \
|
||||
\
|
||||
CONFIG_SETTING(private, QVariantMap, rdcstrpairs, ConfigSettings) \
|
||||
\
|
||||
CONFIG_SETTING(private, QVariantList, rdcarray<RemoteHost>, RemoteHostList)
|
||||
|
||||
DOCUMENT(R"(The unit that GPU durations are displayed in.
|
||||
@@ -458,6 +446,8 @@ As the name suggests, this is used for tracking a 'recent file' list.
|
||||
)");
|
||||
void RemoveRecentFile(rdcarray<rdcstr> &recentList, const rdcstr &file);
|
||||
|
||||
struct LegacyData;
|
||||
|
||||
DOCUMENT2(R"(A persistant config file that is automatically loaded and saved, which contains any
|
||||
settings and information that needs to be preserved from one run to the next.
|
||||
|
||||
@@ -533,13 +523,6 @@ For more information about some of these settings that are user-facing see
|
||||
|
||||
Defaults to ``False``.
|
||||
|
||||
.. data:: ShaderViewer_FriendlyNaming
|
||||
|
||||
``True`` if the :class:`ShaderViewer` should replace register names with the high-level language
|
||||
variable names where possible.
|
||||
|
||||
Defaults to ``True``.
|
||||
|
||||
.. data:: AlwaysReplayLocally
|
||||
|
||||
``True`` if when loading a capture that was originally captured on a remote device but uses an
|
||||
@@ -655,24 +638,6 @@ For more information about some of these settings that are user-facing see
|
||||
|
||||
Defaults to ``False``.
|
||||
|
||||
.. data:: Android_SDKPath
|
||||
|
||||
The path to the root of the android SDK, to locate android tools to use for android remote hosts.
|
||||
|
||||
Defaults to using the tools distributed with RenderDoc.
|
||||
|
||||
.. data:: Android_JDKPath
|
||||
|
||||
The path to the root of the Java JDK, to locate java for running android java tools.
|
||||
|
||||
Defaults to using the JAVA_HOME environment variable, if set.
|
||||
|
||||
.. data:: Android_MaxConnectTimeout
|
||||
|
||||
The maximum timeout in seconds to wait when launching an Android package.
|
||||
|
||||
Defaults to ``30``.
|
||||
|
||||
.. data:: UnsupportedAndroid_LastUpdate
|
||||
|
||||
A date containing the last time that the user was warned about an Android device being older than
|
||||
@@ -713,10 +678,6 @@ For more information about some of these settings that are user-facing see
|
||||
A date containing the last time that the user was warned about captures being loaded in degraded
|
||||
support. This prevents the user being spammed if their hardware is low spec.
|
||||
|
||||
.. data:: ExternalTool_RGPIntegration
|
||||
|
||||
Whether to enable integration with the external Radeon GPU Profiler tool.
|
||||
|
||||
.. data:: ExternalTool_RadeonGPUProfiler
|
||||
|
||||
The path to the executable of the external Radeon GPU Profiler tool.
|
||||
@@ -788,7 +749,6 @@ For more information about some of these settings that are user-facing see
|
||||
A list of strings with extension packages to always load on startup, without needing manual
|
||||
enabling.
|
||||
|
||||
|
||||
)");
|
||||
class PersistantConfig
|
||||
{
|
||||
@@ -822,7 +782,7 @@ public:
|
||||
DOCUMENT("");
|
||||
CONFIG_SETTINGS()
|
||||
public:
|
||||
PersistantConfig() {}
|
||||
PersistantConfig();
|
||||
~PersistantConfig();
|
||||
|
||||
DOCUMENT(R"(Loads the config from a given filename. This happens automatically on startup, so it's
|
||||
@@ -854,21 +814,6 @@ loading. It can explicitly save and close before relaunching.
|
||||
DOCUMENT("Configures the :class:`Formatter` class with the settings from this config.");
|
||||
void SetupFormatting();
|
||||
|
||||
DOCUMENT(R"(Sets an arbitrary dynamic setting similar to a key-value store. This can be used for
|
||||
storing custom settings to be persisted without needing to modify code.
|
||||
|
||||
:param str name: The name of the setting. Any existing setting will be overwritten.
|
||||
:param str value: The contents of the setting.
|
||||
)");
|
||||
void SetConfigSetting(const rdcstr &name, const rdcstr &value);
|
||||
DOCUMENT(R"(Retrieves an arbitrary dynamic setting. See :meth:`SetConfigSetting`.
|
||||
|
||||
:param str name: The name of the setting.
|
||||
:return: The value of the setting, or the empty string if the setting did not exist.
|
||||
:rtype: ``str``
|
||||
)");
|
||||
rdcstr GetConfigSetting(const rdcstr &name);
|
||||
|
||||
DOCUMENT(R"(Sets the UI style to the value in :data:`UIStyle`.
|
||||
|
||||
Changing the style after the application has started may not properly update everything, so to be
|
||||
@@ -891,4 +836,8 @@ private:
|
||||
#endif
|
||||
|
||||
rdcstr m_Filename;
|
||||
|
||||
// legacy storage for config settings that were ported into the core config. We keep them here
|
||||
// so we can store them out again, to keep the config the same for a while even if it's unused
|
||||
LegacyData *m_Legacy;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user