mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 17:40:39 +00:00
Return settings by value with temporaries
* This is slightly less efficient but this isn't high-performance code, and it makes settings like shader debug SearchDirPaths safe to access on multiple threads.
This commit is contained in:
@@ -367,29 +367,24 @@ static bool MergeConfigValues(const rdcstr &prefix, SDObject *dstConfig, const S
|
||||
return ret;
|
||||
}
|
||||
|
||||
const bool &ConfigVarRegistration<bool>::value()
|
||||
bool ConfigVarRegistration<bool>::value() const
|
||||
{
|
||||
// avoid warnings on stupid compilers
|
||||
(void)tmp;
|
||||
return obj->data.basic.b;
|
||||
}
|
||||
|
||||
const uint64_t &ConfigVarRegistration<uint64_t>::value()
|
||||
uint64_t ConfigVarRegistration<uint64_t>::value() const
|
||||
{
|
||||
(void)tmp;
|
||||
return obj->data.basic.u;
|
||||
}
|
||||
|
||||
const uint32_t &ConfigVarRegistration<uint32_t>::value()
|
||||
uint32_t ConfigVarRegistration<uint32_t>::value() const
|
||||
{
|
||||
tmp = obj->data.basic.u & 0xFFFFFFFFU;
|
||||
return tmp;
|
||||
return obj->data.basic.u & 0xFFFFFFFFU;
|
||||
}
|
||||
|
||||
const rdcstr &ConfigVarRegistration<rdcstr>::value()
|
||||
rdcstr ConfigVarRegistration<rdcstr>::value() const
|
||||
{
|
||||
tmp = obj->data.str;
|
||||
return tmp;
|
||||
return obj->data.str;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -399,8 +394,9 @@ rdcstr DefValString(const T &el)
|
||||
}
|
||||
|
||||
// this one needs a special implementation unfortunately to convert
|
||||
const rdcarray<rdcstr> &ConfigVarRegistration<rdcarray<rdcstr>>::value()
|
||||
rdcarray<rdcstr> ConfigVarRegistration<rdcarray<rdcstr>>::value() const
|
||||
{
|
||||
rdcarray<rdcstr> tmp;
|
||||
tmp.resize(obj->NumChildren());
|
||||
for(size_t i = 0; i < tmp.size(); i++)
|
||||
tmp[i] = obj->GetChild(i)->data.str;
|
||||
|
||||
@@ -40,11 +40,10 @@ struct ConfigVarRegistration;
|
||||
{ \
|
||||
ConfigVarRegistration(rdcliteral name, const T &defaultValue, bool debugOnly, \
|
||||
rdcliteral description); \
|
||||
const T &value(); \
|
||||
T value() const; \
|
||||
\
|
||||
private: \
|
||||
SDObject *obj; \
|
||||
T tmp; \
|
||||
};
|
||||
|
||||
CONFIG_SUPPORT_TYPE(rdcstr);
|
||||
@@ -58,11 +57,11 @@ CONFIG_SUPPORT_TYPE(rdcarray<rdcstr>);
|
||||
#define RDOC_CONFIG(type, name, defaultValue, description) \
|
||||
static ConfigVarRegistration<type> CONCAT(config, __LINE__)( \
|
||||
STRING_LITERAL(STRINGIZE(name)), defaultValue, false, STRING_LITERAL(description)); \
|
||||
const type &name() \
|
||||
type name() \
|
||||
{ \
|
||||
return CONCAT(config, __LINE__).value(); \
|
||||
}
|
||||
#define RDOC_EXTERN_CONFIG(type, name) extern const type &name();
|
||||
#define RDOC_EXTERN_CONFIG(type, name) extern type name();
|
||||
|
||||
// debug configs get set to constants in official stable builds, they will remain configurable
|
||||
// in nightly builds and of course in development builds
|
||||
@@ -71,7 +70,7 @@ CONFIG_SUPPORT_TYPE(rdcarray<rdcstr>);
|
||||
#define RDOC_DEBUG_CONFIG(type, name, defaultValue, description) \
|
||||
static ConfigVarRegistration<type> CONCAT(config, __LINE__)( \
|
||||
STRING_LITERAL(STRINGIZE(name)), defaultValue, true, STRING_LITERAL(description)); \
|
||||
const type &name() \
|
||||
type name() \
|
||||
{ \
|
||||
static const type ret = defaultValue; \
|
||||
return ret; \
|
||||
@@ -81,7 +80,7 @@ CONFIG_SUPPORT_TYPE(rdcarray<rdcstr>);
|
||||
#define RDOC_DEBUG_CONFIG(type, name, defaultValue, description) \
|
||||
static ConfigVarRegistration<type> CONCAT(config, __LINE__)( \
|
||||
STRING_LITERAL(STRINGIZE(name)), defaultValue, true, STRING_LITERAL(description)); \
|
||||
const type &name() \
|
||||
type name() \
|
||||
{ \
|
||||
return CONCAT(config, __LINE__).value(); \
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user