diff options
Diffstat (limited to 'layers/vk_layer_config.cpp')
| -rw-r--r--[-rwxr-xr-x] | layers/vk_layer_config.cpp | 94 |
1 files changed, 40 insertions, 54 deletions
diff --git a/layers/vk_layer_config.cpp b/layers/vk_layer_config.cpp index 1d2cfc7e..58f82f16 100755..100644 --- a/layers/vk_layer_config.cpp +++ b/layers/vk_layer_config.cpp @@ -37,16 +37,15 @@ #define MAX_CHARS_PER_LINE 4096 -class ConfigFile -{ -public: +class ConfigFile { + public: ConfigFile(); ~ConfigFile(); const char *getOption(const std::string &_option); void setOption(const std::string &_option, const std::string &_val); -private: + private: bool m_fileIsParsed; std::map<std::string, std::string> m_valueMap; @@ -55,8 +54,7 @@ private: static ConfigFile g_configFileObj; -static VkLayerDbgAction stringToDbgAction(const char *_enum) -{ +static VkLayerDbgAction stringToDbgAction(const char *_enum) { // only handles single enum values if (!strcmp(_enum, "VK_DBG_LAYER_ACTION_IGNORE")) return VK_DBG_LAYER_ACTION_IGNORE; @@ -68,11 +66,10 @@ static VkLayerDbgAction stringToDbgAction(const char *_enum) #endif else if (!strcmp(_enum, "VK_DBG_LAYER_ACTION_BREAK")) return VK_DBG_LAYER_ACTION_BREAK; - return (VkLayerDbgAction) 0; + return (VkLayerDbgAction)0; } -static VkFlags stringToDbgReportFlags(const char *_enum) -{ +static VkFlags stringToDbgReportFlags(const char *_enum) { // only handles single enum values if (!strcmp(_enum, "VK_DEBUG_REPORT_INFO")) return VK_DEBUG_REPORT_INFO_BIT_EXT; @@ -84,11 +81,10 @@ static VkFlags stringToDbgReportFlags(const char *_enum) return VK_DEBUG_REPORT_ERROR_BIT_EXT; else if (!strcmp(_enum, "VK_DEBUG_REPORT_DEBUG")) return VK_DEBUG_REPORT_DEBUG_BIT_EXT; - return (VkFlags) 0; + return (VkFlags)0; } -static unsigned int convertStringEnumVal(const char *_enum) -{ +static unsigned int convertStringEnumVal(const char *_enum) { unsigned int ret; ret = stringToDbgAction(_enum); @@ -98,31 +94,32 @@ static unsigned int convertStringEnumVal(const char *_enum) return stringToDbgReportFlags(_enum); } -const char *getLayerOption(const char *_option) -{ +const char *getLayerOption(const char *_option) { return g_configFileObj.getOption(_option); } // If option is NULL or stdout, return stdout, otherwise try to open option // as a filename. If successful, return file handle, otherwise stdout -FILE* getLayerLogOutput(const char *_option, const char *layerName) -{ - FILE* log_output = NULL; +FILE *getLayerLogOutput(const char *_option, const char *layerName) { + FILE *log_output = NULL; if (!_option || !strcmp("stdout", _option)) log_output = stdout; else { log_output = fopen(_option, "w"); if (log_output == NULL) { if (_option) - std::cout << std::endl << layerName << " ERROR: Bad output filename specified: " << _option << ". Writing to STDOUT instead" << std::endl << std::endl; + std::cout << std::endl << layerName + << " ERROR: Bad output filename specified: " + << _option << ". Writing to STDOUT instead" + << std::endl << std::endl; log_output = stdout; } } return log_output; } -VkDebugReportFlagsEXT getLayerOptionFlags(const char *_option, uint32_t optionDefault) -{ +VkDebugReportFlagsEXT getLayerOptionFlags(const char *_option, + uint32_t optionDefault) { VkDebugReportFlagsEXT flags = optionDefault; const char *option = (g_configFileObj.getOption(_option)); @@ -158,8 +155,7 @@ VkDebugReportFlagsEXT getLayerOptionFlags(const char *_option, uint32_t optionDe return flags; } -bool getLayerOptionEnum(const char *_option, uint32_t *optionDefault) -{ +bool getLayerOptionEnum(const char *_option, uint32_t *optionDefault) { bool res; const char *option = (g_configFileObj.getOption(_option)); if (option != NULL) { @@ -171,32 +167,24 @@ bool getLayerOptionEnum(const char *_option, uint32_t *optionDefault) return res; } -void setLayerOptionEnum(const char *_option, const char *_valEnum) -{ +void setLayerOptionEnum(const char *_option, const char *_valEnum) { unsigned int val = convertStringEnumVal(_valEnum); char strVal[24]; snprintf(strVal, 24, "%u", val); g_configFileObj.setOption(_option, strVal); } -void setLayerOption(const char *_option, const char *_val) -{ +void setLayerOption(const char *_option, const char *_val) { g_configFileObj.setOption(_option, _val); } -ConfigFile::ConfigFile() : m_fileIsParsed(false) -{ -} +ConfigFile::ConfigFile() : m_fileIsParsed(false) {} -ConfigFile::~ConfigFile() -{ -} +ConfigFile::~ConfigFile() {} -const char *ConfigFile::getOption(const std::string &_option) -{ +const char *ConfigFile::getOption(const std::string &_option) { std::map<std::string, std::string>::const_iterator it; - if (!m_fileIsParsed) - { + if (!m_fileIsParsed) { parseFile("vk_layer_settings.txt"); } @@ -206,18 +194,16 @@ const char *ConfigFile::getOption(const std::string &_option) return it->second.c_str(); } -void ConfigFile::setOption(const std::string &_option, const std::string &_val) -{ - if (!m_fileIsParsed) - { +void ConfigFile::setOption(const std::string &_option, + const std::string &_val) { + if (!m_fileIsParsed) { parseFile("vk_layer_settings.txt"); } m_valueMap[_option] = _val; } -void ConfigFile::parseFile(const char *filename) -{ +void ConfigFile::parseFile(const char *filename) { std::ifstream file; char buf[MAX_CHARS_PER_LINE]; @@ -230,20 +216,18 @@ void ConfigFile::parseFile(const char *filename) // read tokens from the file and form option, value pairs file.getline(buf, MAX_CHARS_PER_LINE); - while (!file.eof()) - { + while (!file.eof()) { char option[512]; char value[512]; char *pComment; - //discard any comments delimited by '#' in the line + // discard any comments delimited by '#' in the line pComment = strchr(buf, '#'); if (pComment) *pComment = '\0'; - if (sscanf(buf, " %511[^\n\t =] = %511[^\n \t]", option, value) == 2) - { + if (sscanf(buf, " %511[^\n\t =] = %511[^\n \t]", option, value) == 2) { std::string optStr(option); std::string valStr(value); m_valueMap[optStr] = valStr; @@ -252,8 +236,7 @@ void ConfigFile::parseFile(const char *filename) } } -void print_msg_flags(VkFlags msgFlags, char *msg_flags) -{ +void print_msg_flags(VkFlags msgFlags, char *msg_flags) { bool separator = false; msg_flags[0] = 0; @@ -262,23 +245,26 @@ void print_msg_flags(VkFlags msgFlags, char *msg_flags) separator = true; } if (msgFlags & VK_DEBUG_REPORT_INFO_BIT_EXT) { - if (separator) strcat(msg_flags, ","); + if (separator) + strcat(msg_flags, ","); strcat(msg_flags, "INFO"); separator = true; } if (msgFlags & VK_DEBUG_REPORT_WARN_BIT_EXT) { - if (separator) strcat(msg_flags, ","); + if (separator) + strcat(msg_flags, ","); strcat(msg_flags, "WARN"); separator = true; } if (msgFlags & VK_DEBUG_REPORT_PERF_WARN_BIT_EXT) { - if (separator) strcat(msg_flags, ","); + if (separator) + strcat(msg_flags, ","); strcat(msg_flags, "PERF"); separator = true; } if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { - if (separator) strcat(msg_flags, ","); + if (separator) + strcat(msg_flags, ","); strcat(msg_flags, "ERROR"); } } - |
