From a5c3febc91aacac8be0fcc1f552234270b537513 Mon Sep 17 00:00:00 2001 From: Mark Lobodzinski Date: Wed, 3 Feb 2016 09:57:14 -0700 Subject: Revert "layers: Clang-format changes for files in layers dir of repo" This reverts commit e260acfb96ea20945149ede6a250ef622ca7fd03. The clang-format changes need to be postponed until just prior to public release to facilitate MRs. --- layers/vk_layer_config.cpp | 94 ++++++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 40 deletions(-) mode change 100644 => 100755 layers/vk_layer_config.cpp (limited to 'layers/vk_layer_config.cpp') diff --git a/layers/vk_layer_config.cpp b/layers/vk_layer_config.cpp old mode 100644 new mode 100755 index 58f82f16..1d2cfc7e --- a/layers/vk_layer_config.cpp +++ b/layers/vk_layer_config.cpp @@ -37,15 +37,16 @@ #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 m_valueMap; @@ -54,7 +55,8 @@ class ConfigFile { 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; @@ -66,10 +68,11 @@ 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; @@ -81,10 +84,11 @@ 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); @@ -94,32 +98,31 @@ 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)); @@ -155,7 +158,8 @@ VkDebugReportFlagsEXT getLayerOptionFlags(const char *_option, 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) { @@ -167,24 +171,32 @@ 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::const_iterator it; - if (!m_fileIsParsed) { + if (!m_fileIsParsed) + { parseFile("vk_layer_settings.txt"); } @@ -194,16 +206,18 @@ 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]; @@ -216,18 +230,20 @@ 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; @@ -236,7 +252,8 @@ 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; @@ -245,26 +262,23 @@ 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"); } } + -- cgit v1.2.3