Add a way for UI to pass arbitrary settings strings into the core module

This commit is contained in:
baldurk
2016-05-10 22:35:48 +02:00
parent d65bacc118
commit 91afc2b391
5 changed files with 81 additions and 1 deletions
+2
View File
@@ -432,3 +432,5 @@ extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_TriggerExceptionHandler(voi
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_LogText(const char *text);
extern "C" RENDERDOC_API bool32 RENDERDOC_CC RENDERDOC_GetThumbnail(const char *filename, byte *buf, uint32_t &len);
extern "C" RENDERDOC_API const char* RENDERDOC_CC RENDERDOC_GetVersionString();
extern "C" RENDERDOC_API const char* RENDERDOC_CC RENDERDOC_GetConfigSetting(const char *name);
extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetConfigSetting(const char *name, const char *value);
+5
View File
@@ -187,6 +187,9 @@ class RenderDoc
void SetReplayApp(bool replay) { m_Replay = replay; }
bool IsReplayApp() const { return m_Replay; }
string GetConfigSetting(string name) { return m_ConfigSettings[name]; }
void SetConfigSetting(string name, string value) { m_ConfigSettings[name] = value; }
void BecomeReplayHost(volatile uint32_t &killReplay);
void SetCaptureOptions(const CaptureOptions &opts);
@@ -326,6 +329,8 @@ class RenderDoc
Threading::CriticalSection m_ChildLock;
vector< pair<uint32_t, uint32_t> > m_Children;
map<string, string> m_ConfigSettings;
map<RDCDriver, string> m_DriverNames;
map<RDCDriver, ReplayDriverProvider> m_ReplayDriverProviders;
map<RDCDriver, RemoteDriverProvider> m_RemoteDriverProviders;
+12
View File
@@ -242,6 +242,18 @@ const char* RENDERDOC_CC RENDERDOC_GetVersionString()
return RENDERDOC_VERSION_STRING;
}
extern "C" RENDERDOC_API
const char* RENDERDOC_CC RENDERDOC_GetConfigSetting(const char *name)
{
return RenderDoc::Inst().GetConfigSetting(name).c_str();
}
extern "C" RENDERDOC_API
void RENDERDOC_CC RENDERDOC_SetConfigSetting(const char *name, const char *value)
{
RenderDoc::Inst().SetConfigSetting(name, value);
}
extern "C" RENDERDOC_API
void RENDERDOC_CC RENDERDOC_LogText(const char *text)
{
+34 -1
View File
@@ -62,6 +62,24 @@ namespace renderdocui.Code
public List<SerializableKeyValuePair<string, string>> PreviouslyUsedHosts = new List<SerializableKeyValuePair<string, string>>();
[XmlIgnore] // not directly serializable
public Dictionary<string, string> ConfigSettings = new Dictionary<string, string>();
private List<SerializableKeyValuePair<string, string>> ConfigSettingsValues = new List<SerializableKeyValuePair<string, string>>();
public void SetConfigSetting(string name, string value)
{
ConfigSettings[name] = value;
StaticExports.SetConfigSetting(name, value);
}
public string GetConfigSetting(string name)
{
if(ConfigSettings.ContainsKey(name))
return ConfigSettings[name];
return "";
}
public enum TimeUnit
{
Seconds = 0,
@@ -158,6 +176,10 @@ namespace renderdocui.Code
foreach (var kv in ReplayHosts)
ReplayHostKeyValues.Add(new SerializableKeyValuePair<string, string>(kv.Key, kv.Value));
ConfigSettingsValues.Clear();
foreach (var kv in ConfigSettings)
ConfigSettingsValues.Add(new SerializableKeyValuePair<string, string>(kv.Key, kv.Value));
XmlSerializer xs = new XmlSerializer(this.GetType());
StreamWriter writer = File.CreateText(file);
xs.Serialize(writer, this);
@@ -182,7 +204,18 @@ namespace renderdocui.Code
{
if (kv.Key != null && kv.Key.Length > 0 &&
kv.Value != null)
c.ReplayHosts.Add(kv.Key, kv.Value);
{
c.ReplayHosts.Add(kv.Key, kv.Value);
}
}
foreach (var kv in c.ConfigSettingsValues)
{
if (kv.Key != null && kv.Key.Length > 0 &&
kv.Value != null)
{
c.SetConfigSetting(kv.Key, kv.Value);
}
}
return c;
+28
View File
@@ -71,6 +71,12 @@ namespace renderdoc
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr RENDERDOC_GetLogFile();
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr RENDERDOC_GetConfigSetting(IntPtr name);
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern void RENDERDOC_SetConfigSetting(IntPtr name, IntPtr value);
[DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
private static extern bool RENDERDOC_GetThumbnail(IntPtr filename, byte[] outmem, ref UInt32 len);
@@ -234,6 +240,28 @@ namespace renderdoc
return CustomMarshal.PtrToStringUTF8(RENDERDOC_GetLogFile());
}
public static string GetConfigSetting(string name)
{
IntPtr name_mem = CustomMarshal.MakeUTF8String(name);
string ret = CustomMarshal.PtrToStringUTF8(RENDERDOC_GetConfigSetting(name_mem));
CustomMarshal.Free(name_mem);
return ret;
}
public static void SetConfigSetting(string name, string value)
{
IntPtr name_mem = CustomMarshal.MakeUTF8String(name);
IntPtr value_mem = CustomMarshal.MakeUTF8String(value);
RENDERDOC_SetConfigSetting(name_mem, value_mem);
CustomMarshal.Free(name_mem);
CustomMarshal.Free(value_mem);
}
public static byte[] GetThumbnail(string filename)
{
UInt32 len = 0;