From 9f2bb1de5e410ee25cd86afd052f9e8e9c2c87ee Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Fri, 3 Jul 2015 10:15:26 -0600 Subject: layers: Rename all layer headers to begin with "vk_layer_" prefix --- layers/CMakeLists.txt | 26 ++-- layers/basic.cpp | 2 +- layers/draw_state.cpp | 12 +- layers/image.cpp | 8 +- layers/layer_data.h | 55 ------- layers/layer_logging.h | 266 --------------------------------- layers/layers_config.cpp | 260 -------------------------------- layers/layers_config.h | 41 ----- layers/layers_debug_marker_table.cpp | 60 -------- layers/layers_debug_marker_table.h | 39 ----- layers/layers_msg.h | 153 ------------------- layers/layers_table.cpp | 198 ------------------------ layers/layers_table.h | 51 ------- layers/mem_tracker.cpp | 8 +- layers/param_checker.cpp | 8 +- layers/screenshot.cpp | 4 +- layers/shader_checker.cpp | 6 +- layers/vk_layer_config.cpp | 260 ++++++++++++++++++++++++++++++++ layers/vk_layer_config.h | 41 +++++ layers/vk_layer_data.h | 55 +++++++ layers/vk_layer_debug_marker_table.cpp | 60 ++++++++ layers/vk_layer_debug_marker_table.h | 39 +++++ layers/vk_layer_logging.h | 266 +++++++++++++++++++++++++++++++++ layers/vk_layer_msg.h | 153 +++++++++++++++++++ layers/vk_layer_table.cpp | 198 ++++++++++++++++++++++++ layers/vk_layer_table.h | 51 +++++++ vk-layer-generate.py | 26 ++-- 27 files changed, 1173 insertions(+), 1173 deletions(-) delete mode 100644 layers/layer_data.h delete mode 100644 layers/layer_logging.h delete mode 100644 layers/layers_config.cpp delete mode 100644 layers/layers_config.h delete mode 100644 layers/layers_debug_marker_table.cpp delete mode 100644 layers/layers_debug_marker_table.h delete mode 100644 layers/layers_msg.h delete mode 100644 layers/layers_table.cpp delete mode 100644 layers/layers_table.h create mode 100644 layers/vk_layer_config.cpp create mode 100644 layers/vk_layer_config.h create mode 100644 layers/vk_layer_data.h create mode 100644 layers/vk_layer_debug_marker_table.cpp create mode 100644 layers/vk_layer_debug_marker_table.h create mode 100644 layers/vk_layer_logging.h create mode 100644 layers/vk_layer_msg.h create mode 100644 layers/vk_layer_table.cpp create mode 100644 layers/vk_layer_table.h diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt index a71931dc..8f521d65 100644 --- a/layers/CMakeLists.txt +++ b/layers/CMakeLists.txt @@ -88,23 +88,23 @@ run_vk_layer_generate(APIDump api_dump.cpp) run_vk_layer_generate(ObjectTracker object_track.cpp) run_vk_layer_generate(Threading threading.cpp) -add_library(layer_utils SHARED layers_config.cpp) +add_library(layer_utils SHARED vk_layer_config.cpp) if (WIN32) - add_library(layer_utils_static STATIC layers_config.cpp) + add_library(layer_utils_static STATIC vk_layer_config.cpp) set_target_properties(layer_utils_static PROPERTIES OUTPUT_NAME layer_utils) target_link_libraries(layer_utils) endif() -add_vk_layer(Basic basic.cpp layers_table.cpp) +add_vk_layer(Basic basic.cpp vk_layer_table.cpp) add_vk_layer(Multi multi.cpp) -add_vk_layer(DrawState draw_state.cpp layers_debug_marker_table.cpp layers_table.cpp) -add_vk_layer(MemTracker mem_tracker.cpp layers_table.cpp) -add_vk_layer(ShaderChecker shader_checker.cpp layers_table.cpp) -add_vk_layer(Image image.cpp layers_table.cpp) +add_vk_layer(DrawState draw_state.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp) +add_vk_layer(MemTracker mem_tracker.cpp vk_layer_table.cpp) +add_vk_layer(ShaderChecker shader_checker.cpp vk_layer_table.cpp) +add_vk_layer(Image image.cpp vk_layer_table.cpp) # generated -add_vk_layer(Generic generic_layer.cpp layers_table.cpp) -add_vk_layer(APIDump api_dump.cpp layers_table.cpp) -add_vk_layer(ObjectTracker object_track.cpp layers_table.cpp) -add_vk_layer(ParamChecker param_checker.cpp layers_debug_marker_table.cpp layers_table.cpp) -add_vk_layer(Threading threading.cpp layers_table.cpp) -add_vk_layer(ScreenShot screenshot.cpp layers_table.cpp) +add_vk_layer(Generic generic_layer.cpp vk_layer_table.cpp) +add_vk_layer(APIDump api_dump.cpp vk_layer_table.cpp) +add_vk_layer(ObjectTracker object_track.cpp vk_layer_table.cpp) +add_vk_layer(ParamChecker param_checker.cpp vk_layer_debug_marker_table.cpp vk_layer_table.cpp) +add_vk_layer(Threading threading.cpp vk_layer_table.cpp) +add_vk_layer(ScreenShot screenshot.cpp vk_layer_table.cpp) diff --git a/layers/basic.cpp b/layers/basic.cpp index b9bf17df..c2ef53d1 100644 --- a/layers/basic.cpp +++ b/layers/basic.cpp @@ -27,7 +27,7 @@ #include "loader_platform.h" #include "vk_dispatch_table_helper.h" #include "vk_layer.h" -#include "layers_table.h" +#include "vk_layer_table.h" // The following is #included again to catch certain OS-specific functions // being used: #include "loader_platform.h" diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index fa3b36aa..da47329e 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -39,16 +39,16 @@ #endif #include "vk_struct_size_helper.h" #include "draw_state.h" -#include "layers_config.h" +#include "vk_layer_config.h" #include "vk_debug_marker_layer.h" // The following is #included again to catch certain OS-specific functions // being used: #include "loader_platform.h" -#include "layers_msg.h" -#include "layers_table.h" -#include "layers_debug_marker_table.h" -#include "layer_data.h" -#include "layer_logging.h" +#include "vk_layer_msg.h" +#include "vk_layer_table.h" +#include "vk_layer_debug_marker_table.h" +#include "vk_layer_data.h" +#include "vk_layer_logging.h" typedef struct _layer_data { debug_report_data *report_data; diff --git a/layers/image.cpp b/layers/image.cpp index 8012e9ba..d42cf2a6 100644 --- a/layers/image.cpp +++ b/layers/image.cpp @@ -33,15 +33,15 @@ #include "loader_platform.h" #include "vk_layer.h" -#include "layers_config.h" +#include "vk_layer_config.h" #include "vk_enum_validate_helper.h" #include "vk_struct_validate_helper.h" //The following is #included again to catch certain OS-specific functions being used: #include "loader_platform.h" -#include "layers_table.h" -#include "layer_data.h" -#include "layer_logging.h" +#include "vk_layer_table.h" +#include "vk_layer_data.h" +#include "vk_layer_logging.h" typedef struct _layer_data { debug_report_data *report_data; diff --git a/layers/layer_data.h b/layers/layer_data.h deleted file mode 100644 index 4cfe0562..00000000 --- a/layers/layer_data.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Vulkan - * - * Copyright (C) 2014 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Courtney Goeltzenleuchter - */ - -#ifndef LAYER_DATA_H -#define LAYER_DATA_H - -#include -#include "layers_table.h" - -template -DATA_T *get_my_data_ptr(void *data_key, - std::unordered_map &layer_data_map) -{ - DATA_T *debug_data; - typename std::unordered_map::const_iterator got; - - got = layer_data_map.find(data_key); - - if ( got == layer_data_map.end() ) { - debug_data = new DATA_T; - memset(debug_data, 0, sizeof(*debug_data)); - layer_data_map[(void *) data_key] = debug_data; - } else { - debug_data = got->second; - } - - return debug_data; -} - -#endif // LAYER_DATA_H - diff --git a/layers/layer_logging.h b/layers/layer_logging.h deleted file mode 100644 index 8a7e2929..00000000 --- a/layers/layer_logging.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Vulkan - * - * Copyright (C) 2014 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Courtney Goeltzenleuchter - */ - -#ifndef LAYER_LOGGING_H -#define LAYER_LOGGING_H - -#include -#include -#include -#include -#include "vk_layer.h" -#include "layer_data.h" -#include "layers_table.h" - -typedef struct _debug_report_data { - VkLayerDbgFunctionNode *g_pDbgFunctionHead; - VkFlags active_flags; - bool g_DEBUG_REPORT; -} debug_report_data; - -template debug_report_data *get_my_data_ptr( - void *data_key, - std::unordered_map &data_map); - -// Utility function to handle reporting -static inline void debug_report_log_msg( - debug_report_data *debug_data, - VkFlags msgFlags, - VkObjectType objectType, - VkObject srcObject, - size_t location, - int32_t msgCode, - const char* pLayerPrefix, - const char* pMsg) -{ - VkLayerDbgFunctionNode *pTrav = debug_data->g_pDbgFunctionHead; - while (pTrav) { - if (pTrav->msgFlags & msgFlags) { - pTrav->pfnMsgCallback(msgFlags, - objectType, srcObject, - location, - msgCode, - pLayerPrefix, - pMsg, - (void *) pTrav->pUserData); - } - pTrav = pTrav->pNext; - } -} - -static inline debug_report_data *debug_report_create_instance( - VkLayerInstanceDispatchTable *table, - VkInstance inst, - uint32_t extension_count, - const VkExtensionProperties* pEnabledExtensions) // layer or extension name to be enabled -{ - debug_report_data *debug_data; - PFN_vkGetInstanceProcAddr gpa = table->GetInstanceProcAddr; - - table->DbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback) gpa(inst, "vkDbgCreateMsgCallback"); - table->DbgDestroyMsgCallback = (PFN_vkDbgDestroyMsgCallback) gpa(inst, "vkDbgDestroyMsgCallback"); - - debug_data = (debug_report_data *) malloc(sizeof(debug_report_data)); - if (!debug_data) return NULL; - - memset(debug_data, 0, sizeof(debug_report_data)); - for (uint32_t i = 0; i < extension_count; i++) { - /* TODO: Check other property fields */ - if (strcmp(pEnabledExtensions[i].name, DEBUG_REPORT_EXTENSION_NAME) == 0) { - debug_data->g_DEBUG_REPORT = true; - } - } - return debug_data; -} - -static inline void layer_debug_report_destroy_instance(debug_report_data *debug_data) -{ - VkLayerDbgFunctionNode *pTrav; - VkLayerDbgFunctionNode *pTravNext; - - if (!debug_data) { - return; - } - - pTrav = debug_data->g_pDbgFunctionHead; - /* Clear out any leftover callbacks */ - while (pTrav) { - pTravNext = pTrav->pNext; - - debug_report_log_msg( - debug_data, VK_DBG_REPORT_WARN_BIT, - VK_OBJECT_TYPE_MSG_CALLBACK, pTrav->msgCallback, - 0, DEBUG_REPORT_CALLBACK_REF, - "DebugReport", - "Debug Report callbacks not removed before DestroyInstance"); - - free(pTrav); - pTrav = pTravNext; - } - debug_data->g_pDbgFunctionHead = NULL; - - free(debug_data); -} - -static inline debug_report_data *layer_debug_report_create_device( - debug_report_data *instance_debug_data, - VkDevice device) -{ - /* DEBUG_REPORT shares data between Instance and Device, - * so just return instance's data pointer */ - return instance_debug_data; -} - -static inline void layer_debug_report_destroy_device(VkDevice device) -{ - /* Nothing to do since we're using instance data record */ -} - -static inline VkResult layer_create_msg_callback( - debug_report_data *debug_data, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void *pUserData, - VkDbgMsgCallback *pMsgCallback) -{ - VkLayerDbgFunctionNode *pNewDbgFuncNode = (VkLayerDbgFunctionNode*)malloc(sizeof(VkLayerDbgFunctionNode)); - if (!pNewDbgFuncNode) - return VK_ERROR_OUT_OF_HOST_MEMORY; - - pNewDbgFuncNode->msgCallback = *pMsgCallback; - pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; - pNewDbgFuncNode->msgFlags = msgFlags; - pNewDbgFuncNode->pUserData = pUserData; - pNewDbgFuncNode->pNext = debug_data->g_pDbgFunctionHead; - - debug_data->g_pDbgFunctionHead = pNewDbgFuncNode; - debug_data->active_flags |= msgFlags; - - debug_report_log_msg( - debug_data, VK_DBG_REPORT_DEBUG_BIT, - VK_OBJECT_TYPE_MSG_CALLBACK, *pMsgCallback, - 0, DEBUG_REPORT_CALLBACK_REF, - "DebugReport", - "Added callback"); - return VK_SUCCESS; -} - -static inline void layer_destroy_msg_callback( - debug_report_data *debug_data, - VkDbgMsgCallback msg_callback) -{ - VkLayerDbgFunctionNode *pTrav = debug_data->g_pDbgFunctionHead; - VkLayerDbgFunctionNode *pPrev = pTrav; - - debug_data->active_flags = 0; - while (pTrav) { - if (pTrav->msgCallback == msg_callback) { - pPrev->pNext = pTrav->pNext; - if (debug_data->g_pDbgFunctionHead == pTrav) { - debug_data->g_pDbgFunctionHead = pTrav->pNext; - } - free(pTrav); - debug_report_log_msg( - debug_data, VK_DBG_REPORT_DEBUG_BIT, - VK_OBJECT_TYPE_MSG_CALLBACK, pTrav->msgCallback, - 0, DEBUG_REPORT_NONE, - "DebugReport", - "Destroyed callback"); - } - debug_data->active_flags |= pTrav->msgFlags; - pPrev = pTrav; - pTrav = pTrav->pNext; - } -} - -static inline void* debug_report_get_instance_proc_addr( - debug_report_data *debug_data, - const char *funcName) -{ - if (!debug_data || !debug_data->g_DEBUG_REPORT) { - return NULL; - } - - if (!strcmp(funcName, "vkDbgCreateMsgCallback")) { - return (void *) vkDbgCreateMsgCallback; - } - if (!strcmp(funcName, "vkDbgDestroyMsgCallback")) { - return (void *) vkDbgDestroyMsgCallback; - } - - return NULL; -} - -/* - * Output log message via DEBUG_REPORT - * Takes format and variable arg list so that output string - * is only computed if a message needs to be logged - */ -static inline void log_msg( - debug_report_data *debug_data, - VkFlags msgFlags, - VkObjectType objectType, - VkObject srcObject, - size_t location, - int32_t msgCode, - const char* pLayerPrefix, - const char* format, - ...) -{ - if (!debug_data || !(debug_data->active_flags & msgFlags)) { - /* message is not wanted */ - return; - } - - char str[1024]; - va_list argptr; - va_start(argptr, format); - vsnprintf(str, 1024, format, argptr); - va_end(argptr); - debug_report_log_msg(debug_data, msgFlags, objectType, - srcObject, location, msgCode, - pLayerPrefix, str); -} - -static inline void VKAPI log_callback( - VkFlags msgFlags, - VkObjectType objType, - VkObject srcObject, - size_t location, - int32_t msgCode, - const char* pLayerPrefix, - const char* pMsg, - void* pUserData) -{ - char msg_flags[30]; - - print_msg_flags(msgFlags, msg_flags); - - fprintf((FILE *) pUserData, "%s(%s): object: 0x%p type: %d location: %zu msgCode: %d: %s\n", - pLayerPrefix, msg_flags, srcObject, objType, location, msgCode, pMsg); -} -#endif // LAYER_LOGGING_H diff --git a/layers/layers_config.cpp b/layers/layers_config.cpp deleted file mode 100644 index ad49e4d3..00000000 --- a/layers/layers_config.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/************************************************************************** - * - * Copyright 2014 Lunarg, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - **************************************************************************/ -#include -#include -#include -#include -#include -#include "loader_platform.h" -#include "layers_config.h" -// The following is #included again to catch certain OS-specific functions -// being used: -#include "loader_platform.h" - -#define MAX_CHARS_PER_LINE 4096 - -class ConfigFile -{ -public: - ConfigFile(); - ~ConfigFile(); - - const char *getOption(const std::string &_option); - void setOption(const std::string &_option, const std::string &_val); - -private: - bool m_fileIsParsed; - std::map m_valueMap; - - void parseFile(const char *filename); -}; - -static ConfigFile g_configFileObj; - -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; - else if (!strcmp(_enum, "VK_DBG_LAYER_ACTION_LOG_MSG")) - return VK_DBG_LAYER_ACTION_LOG_MSG; - else if (!strcmp(_enum, "VK_DBG_LAYER_ACTION_BREAK")) - return VK_DBG_LAYER_ACTION_BREAK; - return (VkLayerDbgAction) 0; -} - -static VkFlags stringToDbgReportFlags(const char *_enum) -{ - // only handles single enum values - if (!strcmp(_enum, "VK_DBG_REPORT_INFO")) - return VK_DBG_REPORT_INFO_BIT; - else if (!strcmp(_enum, "VK_DBG_REPORT_WARN")) - return VK_DBG_REPORT_WARN_BIT; - else if (!strcmp(_enum, "VK_DBG_REPORT_PERF_WARN")) - return VK_DBG_REPORT_PERF_WARN_BIT; - else if (!strcmp(_enum, "VK_DBG_REPORT_ERROR")) - return VK_DBG_REPORT_ERROR_BIT; - else if (!strcmp(_enum, "VK_DBG_REPORT_DEBUG")) - return VK_DBG_REPORT_DEBUG_BIT; - return (VkFlags) 0; -} - -static unsigned int convertStringEnumVal(const char *_enum) -{ - unsigned int ret; - - ret = stringToDbgAction(_enum); - if (ret) - return ret; - - return stringToDbgReportFlags(_enum); -} - -const char *getLayerOption(const char *_option) -{ - return g_configFileObj.getOption(_option); -} - -uint32_t getLayerOptionFlags(const char *_option, uint32_t optionDefault) -{ - uint32_t flags = optionDefault; - const char *option = (g_configFileObj.getOption(_option)); - - /* parse comma-separated options */ - while (option) { - const char *p = strchr(option, ','); - size_t len; - - if (p) - len = p - option; - else - len = strlen(option); - - if (len > 0) { - if (strncmp(option, "warn", len) == 0) { - flags |= VK_DBG_REPORT_WARN_BIT; - } else if (strncmp(option, "info", len) == 0) { - flags |= VK_DBG_REPORT_INFO_BIT; - } else if (strncmp(option, "perf", len) == 0) { - flags |= VK_DBG_REPORT_PERF_WARN_BIT; - } else if (strncmp(option, "error", len) == 0) { - flags |= VK_DBG_REPORT_ERROR_BIT; - } else if (strncmp(option, "debug", len) == 0) { - flags |= VK_DBG_REPORT_DEBUG_BIT; - } - } - - if (!p) - break; - - option = p + 1; - } - return flags; -} - -bool getLayerOptionEnum(const char *_option, uint32_t *optionDefault) -{ - bool res; - const char *option = (g_configFileObj.getOption(_option)); - if (option != NULL) { - *optionDefault = convertStringEnumVal(option); - res = false; - } else { - res = true; - } - return res; -} - -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) -{ - g_configFileObj.setOption(_option, _val); -} - -ConfigFile::ConfigFile() : m_fileIsParsed(false) -{ -} - -ConfigFile::~ConfigFile() -{ -} - -const char *ConfigFile::getOption(const std::string &_option) -{ - std::map::const_iterator it; - if (!m_fileIsParsed) - { - parseFile("vk_layer_settings.txt"); - } - - if ((it = m_valueMap.find(_option)) == m_valueMap.end()) - return NULL; - else - return it->second.c_str(); -} - -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) -{ - std::ifstream file; - char buf[MAX_CHARS_PER_LINE]; - - m_fileIsParsed = true; - m_valueMap.clear(); - - file.open(filename); - if (!file.good()) - return; - - // read tokens from the file and form option, value pairs - file.getline(buf, MAX_CHARS_PER_LINE); - while (!file.eof()) - { - char option[512]; - char value[512]; - - char *pComment; - - //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) - { - std::string optStr(option); - std::string valStr(value); - m_valueMap[optStr] = valStr; - } - file.getline(buf, MAX_CHARS_PER_LINE); - } -} - -void print_msg_flags(VkFlags msgFlags, char *msg_flags) -{ - bool separator = false; - - msg_flags[0] = 0; - if (msgFlags & VK_DBG_REPORT_DEBUG_BIT) { - strcat(msg_flags, "DEBUG"); - separator = true; - } - if (msgFlags & VK_DBG_REPORT_INFO_BIT) { - if (separator) strcat(msg_flags, ","); - strcat(msg_flags, "INFO"); - separator = true; - } - if (msgFlags & VK_DBG_REPORT_WARN_BIT) { - if (separator) strcat(msg_flags, ","); - strcat(msg_flags, "WARN"); - separator = true; - } - if (msgFlags & VK_DBG_REPORT_PERF_WARN_BIT) { - if (separator) strcat(msg_flags, ","); - strcat(msg_flags, "PERF"); - separator = true; - } - if (msgFlags & VK_DBG_REPORT_ERROR_BIT) { - if (separator) strcat(msg_flags, ","); - strcat(msg_flags, "ERROR"); - } -} - diff --git a/layers/layers_config.h b/layers/layers_config.h deleted file mode 100644 index 0fe3dc42..00000000 --- a/layers/layers_config.h +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************** - * - * Copyright 2014 Lunarg, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - **************************************************************************/ -#pragma once -#include - -#ifdef __cplusplus -extern "C" { -#endif - -const char *getLayerOption(const char *_option); -uint32_t getLayerOptionFlags(const char *_option, uint32_t optionDefault); -bool getLayerOptionEnum(const char *_option, uint32_t *optionDefault); - -void setLayerOption(const char *_option, const char *_val); -void setLayerOptionEnum(const char *_option, const char *_valEnum); -void print_msg_flags(VkFlags msgFlags, char *msg_flags); -#ifdef __cplusplus -} -#endif diff --git a/layers/layers_debug_marker_table.cpp b/layers/layers_debug_marker_table.cpp deleted file mode 100644 index 47c93b10..00000000 --- a/layers/layers_debug_marker_table.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Vulkan - * - * Copyright (C) 2014 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include "vk_debug_marker_layer.h" -std::unordered_map tableDebugMarkerMap; - -/* Various dispatchable objects will use the same underlying dispatch table if they - * are created from that "parent" object. Thus use pointer to dispatch table - * as the key to these table maps. - * Instance -> PhysicalDevice - * Device -> CmdBuffer or Queue - * If use the object themselves as key to map then implies Create entrypoints have to be intercepted - * and a new key inserted into map */ -VkLayerDebugMarkerDispatchTable * initDebugMarkerTable(VkDevice device) -{ - VkLayerDebugMarkerDispatchTable *pTable; - VkLayerDebugMarkerDispatchTable *pDebugMarkerTable; - - assert(device); - VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; - - std::unordered_map::const_iterator it = tableDebugMarkerMap.find((void *) pDisp); - if (it == tableDebugMarkerMap.end()) - { - pDebugMarkerTable = new VkLayerDebugMarkerDispatchTable; - tableDebugMarkerMap[(void *) pDisp] = pDebugMarkerTable; - } else - { - return it->second; - } - - pDebugMarkerTable->CmdDbgMarkerBegin = (PFN_vkCmdDbgMarkerBegin) pDisp->GetDeviceProcAddr(device, "vkCmdDbgMarkerBegin"); - pDebugMarkerTable->CmdDbgMarkerEnd = (PFN_vkCmdDbgMarkerEnd) pDisp->GetDeviceProcAddr(device, "vkCmdDbgMarkerEnd"); - pDebugMarkerTable->DbgSetObjectTag = (PFN_vkDbgSetObjectTag) pDisp->GetDeviceProcAddr(device, "vkDbgSetObjectTag"); - pDebugMarkerTable->DbgSetObjectName = (PFN_vkDbgSetObjectName) pDisp->GetDeviceProcAddr(device, "vkDbgSetObjectName"); - - return pTable; -} \ No newline at end of file diff --git a/layers/layers_debug_marker_table.h b/layers/layers_debug_marker_table.h deleted file mode 100644 index 8fc6e2e8..00000000 --- a/layers/layers_debug_marker_table.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Vulkan - * - * Copyright (C) 2014 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#pragma once - -#include - -extern std::unordered_map tableDebugMarkerMap; -VkLayerDebugMarkerDispatchTable * initDebugMarkerTable(VkDevice dev); - -// Map lookup must be thread safe -static inline VkLayerDebugMarkerDispatchTable *debug_marker_dispatch_table(VkObject object) -{ - VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) object; - std::unordered_map::const_iterator it = tableDebugMarkerMap.find((void *) pDisp); - assert(it != tableDebugMarkerMap.end() && "Not able to find debug marker dispatch entry"); - return it->second; -} - diff --git a/layers/layers_msg.h b/layers/layers_msg.h deleted file mode 100644 index 2d0e31d6..00000000 --- a/layers/layers_msg.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Vulkan - * - * Copyright (C) 2014 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include "vk_layer.h" - -static VkLayerDbgFunctionNode *g_pDbgFunctionHead = NULL; -static VkFlags g_reportFlags = (VkFlags) 0; -static VkLayerDbgAction g_debugAction = VK_DBG_LAYER_ACTION_LOG_MSG; -static bool g_actionIsDefault = true; -static bool g_DEBUG_REPORT = false; -static FILE *g_logFile = NULL; - -static void enable_debug_report( - uint32_t extension_count, - const VkExtensionProperties* pEnabledExtensions) // layer or extension name to be enabled -{ - for (uint32_t i = 0; i < extension_count; i++) { - /* TODO: Check other property fields */ - if (strcmp(pEnabledExtensions[i].name, DEBUG_REPORT_EXTENSION_NAME) == 0) { - g_DEBUG_REPORT = true; - } - } -} - -static VkResult layer_create_msg_callback( - VkInstance instance, - VkLayerInstanceDispatchTable* nextTable, - VkFlags msgFlags, - const PFN_vkDbgMsgCallback pfnMsgCallback, - void* pUserData, - VkDbgMsgCallback* pMsgCallback) -{ - VkLayerDbgFunctionNode *pNewDbgFuncNode = (VkLayerDbgFunctionNode*)malloc(sizeof(VkLayerDbgFunctionNode)); - if (!pNewDbgFuncNode) - return VK_ERROR_OUT_OF_HOST_MEMORY; - VkResult result = nextTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); - if (result == VK_SUCCESS) { - pNewDbgFuncNode->msgCallback = *pMsgCallback; - pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; - pNewDbgFuncNode->msgFlags = msgFlags; - pNewDbgFuncNode->pUserData = pUserData; - pNewDbgFuncNode->pNext = g_pDbgFunctionHead; - - /* TODO: This should be a per-instance resource */ - g_pDbgFunctionHead = pNewDbgFuncNode; - } else { - free(pNewDbgFuncNode); - } - return result; -} - -static VkResult layer_destroy_msg_callback( - VkInstance instance, - VkLayerInstanceDispatchTable *nextTable, - VkDbgMsgCallback msg_callback) -{ - VkLayerDbgFunctionNode *pTrav = g_pDbgFunctionHead; - VkLayerDbgFunctionNode *pPrev = pTrav; - - VkResult result = nextTable->DbgDestroyMsgCallback(instance, msg_callback); - - while (pTrav) { - if (pTrav->msgCallback == msg_callback) { - pPrev->pNext = pTrav->pNext; - if (g_pDbgFunctionHead == pTrav) - g_pDbgFunctionHead = pTrav->pNext; - free(pTrav); - break; - } - pPrev = pTrav; - pTrav = pTrav->pNext; - } - - return result; -} - -static inline void debug_report_init_instance_extension_dispatch_table( - VkLayerInstanceDispatchTable *table, - PFN_vkGetInstanceProcAddr gpa, - VkInstance inst) -{ - table->DbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback) gpa(inst, "vkDbgCreateMsgCallback"); - table->DbgDestroyMsgCallback = (PFN_vkDbgDestroyMsgCallback) gpa(inst, "vkDbgDestroyMsgCallback"); -} - -static void* msg_callback_get_proc_addr( - const char *funcName) -{ - if (!g_DEBUG_REPORT) { - return NULL; - } - - if (!strcmp(funcName, "vkDbgCreateMsgCallback")) { - return (void *) vkDbgCreateMsgCallback; - } - if (!strcmp(funcName, "vkDbgDestroyMsgCallback")) { - return (void *) vkDbgDestroyMsgCallback; - } - - return NULL; -} - -// Utility function to handle reporting -// If callbacks are enabled, use them, otherwise use printf -static void layerCbMsg( - VkFlags msgFlags, - VkObjectType objectType, - VkObject srcObject, - size_t location, - int32_t msgCode, - const char* pLayerPrefix, - const char* pMsg) -{ - if (g_logFile == NULL) { - g_logFile = stdout; - } - - VkLayerDbgFunctionNode *pTrav = g_pDbgFunctionHead; - while (pTrav) { - if (pTrav->msgFlags & msgFlags) { - pTrav->pfnMsgCallback(msgFlags, - objectType, srcObject, - location, - msgCode, - pLayerPrefix, - pMsg, - (void *) pTrav->pUserData); - } - pTrav = pTrav->pNext; - } -} diff --git a/layers/layers_table.cpp b/layers/layers_table.cpp deleted file mode 100644 index 363cd01b..00000000 --- a/layers/layers_table.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Vulkan - * - * Copyright (C) 2014 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#include -#include -#include "vk_dispatch_table_helper.h" -#include "vk_layer.h" -#include "layers_table.h" -static device_table_map tableMap; -static instance_table_map tableInstanceMap; - -#define DISPATCH_MAP_DEBUG 0 - -// Map lookup must be thread safe -VkLayerDispatchTable *device_dispatch_table(VkObject object) -{ - dispatch_key key = get_dispatch_key(object); - device_table_map::const_iterator it = tableMap.find((void *) key); - assert(it != tableMap.end() && "Not able to find device dispatch entry"); - return it->second; -} - -VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object) -{ - dispatch_key key = get_dispatch_key(object); - instance_table_map::const_iterator it = tableInstanceMap.find((void *) key); -#if DISPATCH_MAP_DEBUG - if (it != tableInstanceMap.end()) { - fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: %p\n", &tableInstanceMap, object, key, it->second); - } else { - fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: UNKNOWN\n", &tableInstanceMap, object, key); - } -#endif - assert(it != tableInstanceMap.end() && "Not able to find instance dispatch entry"); - return it->second; -} - -void destroy_dispatch_table(device_table_map &map, dispatch_key key) -{ - device_table_map::const_iterator it = map.find((void *) key); -#if DISPATCH_MAP_DEBUG - if (it != map.end()) { - fprintf(stderr, "destroy device dispatch_table: map: %p, key: %p, table: %p\n", &map, key, it->second); - } else { - fprintf(stderr, "destroy device dispatch table: map: %p, key: %p, table: UNKNOWN\n", &map, key); - assert(it != map.end()); - } -#endif - map.erase(key); -} - -void destroy_dispatch_table(instance_table_map &map, dispatch_key key) -{ - instance_table_map::const_iterator it = map.find((void *) key); -#if DISPATCH_MAP_DEBUG - if (it != map.end()) { - fprintf(stderr, "destroy instance dispatch_table: map: %p, key: %p, table: %p\n", &map, key, it->second); - } else { - fprintf(stderr, "destroy instance dispatch table: map: %p, key: %p, table: UNKNOWN\n", &map, key); - assert(it != map.end()); - } -#endif - map.erase(key); -} - -void destroy_device_dispatch_table(dispatch_key key) -{ - destroy_dispatch_table(tableMap, key); -} - -void destroy_instance_dispatch_table(dispatch_key key) -{ - destroy_dispatch_table(tableInstanceMap, key); -} - -VkLayerDispatchTable *get_dispatch_table(device_table_map &map, VkObject object) -{ - dispatch_key key = get_dispatch_key(object); - device_table_map::const_iterator it = map.find((void *) key); -#if DISPATCH_MAP_DEBUG - if (it != map.end()) { - fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: %p\n", &tableInstanceMap, object, key, it->second); - } else { - fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: UNKNOWN\n", &tableInstanceMap, object, key); - } -#endif - assert(it != map.end() && "Not able to find device dispatch entry"); - return it->second; -} - -VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, VkObject object) -{ -// VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) object; - dispatch_key key = get_dispatch_key(object); - instance_table_map::const_iterator it = map.find((void *) key); -#if DISPATCH_MAP_DEBUG - if (it != map.end()) { - fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: %p\n", &tableInstanceMap, object, key, it->second); - } else { - fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: UNKNOWN\n", &tableInstanceMap, object, key); - } -#endif - assert(it != map.end() && "Not able to find instance dispatch entry"); - return it->second; -} - -/* Various dispatchable objects will use the same underlying dispatch table if they - * are created from that "parent" object. Thus use pointer to dispatch table - * as the key to these table maps. - * Instance -> PhysicalDevice - * Device -> CmdBuffer or Queue - * If use the object themselves as key to map then implies Create entrypoints have to be intercepted - * and a new key inserted into map */ -VkLayerInstanceDispatchTable * initInstanceTable(instance_table_map &map, const VkBaseLayerObject *instancew) -{ - VkLayerInstanceDispatchTable *pTable; - assert(instancew); - VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instancew->baseObject; - - std::unordered_map::const_iterator it = map.find((void *) *ppDisp); - if (it == map.end()) - { - pTable = new VkLayerInstanceDispatchTable; - map[(void *) *ppDisp] = pTable; -#if DISPATCH_MAP_DEBUG - fprintf(stderr, "New, Instance: map: %p, base object: %p, key: %p, table: %p\n", &map, instancew, *ppDisp, pTable); -#endif - assert(map.size() <= 1 && "Instance dispatch table map has more than one entry"); - } else - { -#if DISPATCH_MAP_DEBUG - fprintf(stderr, "Instance: map: %p, base object: %p, key: %p, table: %p\n", &map, instancew, *ppDisp, it->second); -#endif - return it->second; - } - - layer_init_instance_dispatch_table(pTable, instancew); - - return pTable; -} - -VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instancew) -{ - return initInstanceTable(tableInstanceMap, instancew); -} - -VkLayerDispatchTable * initDeviceTable(device_table_map &map, const VkBaseLayerObject *devw) -{ - VkLayerDispatchTable *layer_device_table = NULL; - assert(devw); - VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject); - VkLayerDispatchTable *base_device_table = *ppDisp; - - std::unordered_map::const_iterator it = map.find((void *) base_device_table); - if (it == map.end()) - { - layer_device_table = new VkLayerDispatchTable; - map[(void *) base_device_table] = layer_device_table; -#if DISPATCH_MAP_DEBUG - fprintf(stderr, "New, Device: map: %p, base object: %p, key: %p, table: %p\n", &map, devw, *ppDisp, layer_device_table); -#endif - } else - { -#if DISPATCH_MAP_DEBUG - fprintf(stderr, "Device: map: %p, base object: %p, key: %p, table: %p\n", &map, devw, *ppDisp, it->second); -#endif - return it->second; - } - - layer_initialize_dispatch_table(layer_device_table, devw); - - return layer_device_table; -} - -VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) -{ - return initDeviceTable(tableMap, devw); -} diff --git a/layers/layers_table.h b/layers/layers_table.h deleted file mode 100644 index 24f0bd4e..00000000 --- a/layers/layers_table.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Vulkan - * - * Copyright (C) 2014 LunarG, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ -#pragma once - -#include - -typedef std::unordered_map device_table_map; -typedef std::unordered_map instance_table_map; -VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw); -VkLayerDispatchTable * initDeviceTable(device_table_map &map, const VkBaseLayerObject *devw); -VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instancew); -VkLayerInstanceDispatchTable * initInstanceTable(instance_table_map &map, const VkBaseLayerObject *instancew); - -typedef void *dispatch_key; - -static inline dispatch_key get_dispatch_key(VkObject object) -{ - return (dispatch_key) *(VkLayerDispatchTable **) object; -} - -VkLayerDispatchTable *device_dispatch_table(VkObject object); - -VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object); - -VkLayerDispatchTable *get_dispatch_table(device_table_map &map, VkObject object); - -VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, VkObject object); - -void destroy_device_dispatch_table(dispatch_key key); -void destroy_instance_dispatch_table(dispatch_key key); diff --git a/layers/mem_tracker.cpp b/layers/mem_tracker.cpp index e4db2928..ab36022f 100644 --- a/layers/mem_tracker.cpp +++ b/layers/mem_tracker.cpp @@ -36,13 +36,13 @@ using namespace std; #include "vk_dispatch_table_helper.h" #include "vk_struct_string_helper_cpp.h" #include "mem_tracker.h" -#include "layers_config.h" +#include "vk_layer_config.h" // The following is #included again to catch certain OS-specific functions // being used: #include "loader_platform.h" -#include "layers_table.h" -#include "layer_data.h" -#include "layer_logging.h" +#include "vk_layer_table.h" +#include "vk_layer_data.h" +#include "vk_layer_logging.h" static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); typedef struct _layer_data { diff --git a/layers/param_checker.cpp b/layers/param_checker.cpp index 2fb07575..e9befd24 100644 --- a/layers/param_checker.cpp +++ b/layers/param_checker.cpp @@ -34,15 +34,15 @@ #include "loader_platform.h" #include "vk_layer.h" -#include "layers_config.h" +#include "vk_layer_config.h" #include "vk_enum_validate_helper.h" #include "vk_struct_validate_helper.h" //The following is #included again to catch certain OS-specific functions being used: #include "loader_platform.h" -#include "layers_table.h" -#include "layer_data.h" -#include "layer_logging.h" +#include "vk_layer_table.h" +#include "vk_layer_data.h" +#include "vk_layer_logging.h" typedef struct _layer_data { debug_report_data *report_data; diff --git a/layers/screenshot.cpp b/layers/screenshot.cpp index 8a968e66..89725cd1 100644 --- a/layers/screenshot.cpp +++ b/layers/screenshot.cpp @@ -40,11 +40,11 @@ using namespace std; #include "loader_platform.h" #include "vk_dispatch_table_helper.h" #include "vk_struct_string_helper_cpp.h" -#include "layers_config.h" +#include "vk_layer_config.h" // The following is #included again to catch certain OS-specific functions // being used: #include "loader_platform.h" -#include "layers_table.h" +#include "vk_layer_table.h" struct devExts { diff --git a/layers/shader_checker.cpp b/layers/shader_checker.cpp index 854ccc6e..3bfcfe00 100644 --- a/layers/shader_checker.cpp +++ b/layers/shader_checker.cpp @@ -32,9 +32,9 @@ #include "loader_platform.h" #include "vk_dispatch_table_helper.h" #include "vk_layer.h" -#include "layers_config.h" -#include "layers_msg.h" -#include "layers_table.h" +#include "vk_layer_config.h" +#include "vk_layer_msg.h" +#include "vk_layer_table.h" #include "vk_enum_string_helper.h" #include "shader_checker.h" // The following is #included again to catch certain OS-specific functions diff --git a/layers/vk_layer_config.cpp b/layers/vk_layer_config.cpp new file mode 100644 index 00000000..99044694 --- /dev/null +++ b/layers/vk_layer_config.cpp @@ -0,0 +1,260 @@ +/************************************************************************** + * + * Copyright 2014 Lunarg, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ +#include +#include +#include +#include +#include +#include "loader_platform.h" +#include "vk_layer_config.h" +// The following is #included again to catch certain OS-specific functions +// being used: +#include "loader_platform.h" + +#define MAX_CHARS_PER_LINE 4096 + +class ConfigFile +{ +public: + ConfigFile(); + ~ConfigFile(); + + const char *getOption(const std::string &_option); + void setOption(const std::string &_option, const std::string &_val); + +private: + bool m_fileIsParsed; + std::map m_valueMap; + + void parseFile(const char *filename); +}; + +static ConfigFile g_configFileObj; + +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; + else if (!strcmp(_enum, "VK_DBG_LAYER_ACTION_LOG_MSG")) + return VK_DBG_LAYER_ACTION_LOG_MSG; + else if (!strcmp(_enum, "VK_DBG_LAYER_ACTION_BREAK")) + return VK_DBG_LAYER_ACTION_BREAK; + return (VkLayerDbgAction) 0; +} + +static VkFlags stringToDbgReportFlags(const char *_enum) +{ + // only handles single enum values + if (!strcmp(_enum, "VK_DBG_REPORT_INFO")) + return VK_DBG_REPORT_INFO_BIT; + else if (!strcmp(_enum, "VK_DBG_REPORT_WARN")) + return VK_DBG_REPORT_WARN_BIT; + else if (!strcmp(_enum, "VK_DBG_REPORT_PERF_WARN")) + return VK_DBG_REPORT_PERF_WARN_BIT; + else if (!strcmp(_enum, "VK_DBG_REPORT_ERROR")) + return VK_DBG_REPORT_ERROR_BIT; + else if (!strcmp(_enum, "VK_DBG_REPORT_DEBUG")) + return VK_DBG_REPORT_DEBUG_BIT; + return (VkFlags) 0; +} + +static unsigned int convertStringEnumVal(const char *_enum) +{ + unsigned int ret; + + ret = stringToDbgAction(_enum); + if (ret) + return ret; + + return stringToDbgReportFlags(_enum); +} + +const char *getLayerOption(const char *_option) +{ + return g_configFileObj.getOption(_option); +} + +uint32_t getLayerOptionFlags(const char *_option, uint32_t optionDefault) +{ + uint32_t flags = optionDefault; + const char *option = (g_configFileObj.getOption(_option)); + + /* parse comma-separated options */ + while (option) { + const char *p = strchr(option, ','); + size_t len; + + if (p) + len = p - option; + else + len = strlen(option); + + if (len > 0) { + if (strncmp(option, "warn", len) == 0) { + flags |= VK_DBG_REPORT_WARN_BIT; + } else if (strncmp(option, "info", len) == 0) { + flags |= VK_DBG_REPORT_INFO_BIT; + } else if (strncmp(option, "perf", len) == 0) { + flags |= VK_DBG_REPORT_PERF_WARN_BIT; + } else if (strncmp(option, "error", len) == 0) { + flags |= VK_DBG_REPORT_ERROR_BIT; + } else if (strncmp(option, "debug", len) == 0) { + flags |= VK_DBG_REPORT_DEBUG_BIT; + } + } + + if (!p) + break; + + option = p + 1; + } + return flags; +} + +bool getLayerOptionEnum(const char *_option, uint32_t *optionDefault) +{ + bool res; + const char *option = (g_configFileObj.getOption(_option)); + if (option != NULL) { + *optionDefault = convertStringEnumVal(option); + res = false; + } else { + res = true; + } + return res; +} + +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) +{ + g_configFileObj.setOption(_option, _val); +} + +ConfigFile::ConfigFile() : m_fileIsParsed(false) +{ +} + +ConfigFile::~ConfigFile() +{ +} + +const char *ConfigFile::getOption(const std::string &_option) +{ + std::map::const_iterator it; + if (!m_fileIsParsed) + { + parseFile("vk_layer_settings.txt"); + } + + if ((it = m_valueMap.find(_option)) == m_valueMap.end()) + return NULL; + else + return it->second.c_str(); +} + +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) +{ + std::ifstream file; + char buf[MAX_CHARS_PER_LINE]; + + m_fileIsParsed = true; + m_valueMap.clear(); + + file.open(filename); + if (!file.good()) + return; + + // read tokens from the file and form option, value pairs + file.getline(buf, MAX_CHARS_PER_LINE); + while (!file.eof()) + { + char option[512]; + char value[512]; + + char *pComment; + + //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) + { + std::string optStr(option); + std::string valStr(value); + m_valueMap[optStr] = valStr; + } + file.getline(buf, MAX_CHARS_PER_LINE); + } +} + +void print_msg_flags(VkFlags msgFlags, char *msg_flags) +{ + bool separator = false; + + msg_flags[0] = 0; + if (msgFlags & VK_DBG_REPORT_DEBUG_BIT) { + strcat(msg_flags, "DEBUG"); + separator = true; + } + if (msgFlags & VK_DBG_REPORT_INFO_BIT) { + if (separator) strcat(msg_flags, ","); + strcat(msg_flags, "INFO"); + separator = true; + } + if (msgFlags & VK_DBG_REPORT_WARN_BIT) { + if (separator) strcat(msg_flags, ","); + strcat(msg_flags, "WARN"); + separator = true; + } + if (msgFlags & VK_DBG_REPORT_PERF_WARN_BIT) { + if (separator) strcat(msg_flags, ","); + strcat(msg_flags, "PERF"); + separator = true; + } + if (msgFlags & VK_DBG_REPORT_ERROR_BIT) { + if (separator) strcat(msg_flags, ","); + strcat(msg_flags, "ERROR"); + } +} + diff --git a/layers/vk_layer_config.h b/layers/vk_layer_config.h new file mode 100644 index 00000000..0fe3dc42 --- /dev/null +++ b/layers/vk_layer_config.h @@ -0,0 +1,41 @@ +/************************************************************************** + * + * Copyright 2014 Lunarg, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + **************************************************************************/ +#pragma once +#include + +#ifdef __cplusplus +extern "C" { +#endif + +const char *getLayerOption(const char *_option); +uint32_t getLayerOptionFlags(const char *_option, uint32_t optionDefault); +bool getLayerOptionEnum(const char *_option, uint32_t *optionDefault); + +void setLayerOption(const char *_option, const char *_val); +void setLayerOptionEnum(const char *_option, const char *_valEnum); +void print_msg_flags(VkFlags msgFlags, char *msg_flags); +#ifdef __cplusplus +} +#endif diff --git a/layers/vk_layer_data.h b/layers/vk_layer_data.h new file mode 100644 index 00000000..5028ca0a --- /dev/null +++ b/layers/vk_layer_data.h @@ -0,0 +1,55 @@ +/* + * Vulkan + * + * Copyright (C) 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Courtney Goeltzenleuchter + */ + +#ifndef LAYER_DATA_H +#define LAYER_DATA_H + +#include +#include "vk_layer_table.h" + +template +DATA_T *get_my_data_ptr(void *data_key, + std::unordered_map &layer_data_map) +{ + DATA_T *debug_data; + typename std::unordered_map::const_iterator got; + + got = layer_data_map.find(data_key); + + if ( got == layer_data_map.end() ) { + debug_data = new DATA_T; + memset(debug_data, 0, sizeof(*debug_data)); + layer_data_map[(void *) data_key] = debug_data; + } else { + debug_data = got->second; + } + + return debug_data; +} + +#endif // LAYER_DATA_H + diff --git a/layers/vk_layer_debug_marker_table.cpp b/layers/vk_layer_debug_marker_table.cpp new file mode 100644 index 00000000..47c93b10 --- /dev/null +++ b/layers/vk_layer_debug_marker_table.cpp @@ -0,0 +1,60 @@ +/* + * Vulkan + * + * Copyright (C) 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include "vk_debug_marker_layer.h" +std::unordered_map tableDebugMarkerMap; + +/* Various dispatchable objects will use the same underlying dispatch table if they + * are created from that "parent" object. Thus use pointer to dispatch table + * as the key to these table maps. + * Instance -> PhysicalDevice + * Device -> CmdBuffer or Queue + * If use the object themselves as key to map then implies Create entrypoints have to be intercepted + * and a new key inserted into map */ +VkLayerDebugMarkerDispatchTable * initDebugMarkerTable(VkDevice device) +{ + VkLayerDebugMarkerDispatchTable *pTable; + VkLayerDebugMarkerDispatchTable *pDebugMarkerTable; + + assert(device); + VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; + + std::unordered_map::const_iterator it = tableDebugMarkerMap.find((void *) pDisp); + if (it == tableDebugMarkerMap.end()) + { + pDebugMarkerTable = new VkLayerDebugMarkerDispatchTable; + tableDebugMarkerMap[(void *) pDisp] = pDebugMarkerTable; + } else + { + return it->second; + } + + pDebugMarkerTable->CmdDbgMarkerBegin = (PFN_vkCmdDbgMarkerBegin) pDisp->GetDeviceProcAddr(device, "vkCmdDbgMarkerBegin"); + pDebugMarkerTable->CmdDbgMarkerEnd = (PFN_vkCmdDbgMarkerEnd) pDisp->GetDeviceProcAddr(device, "vkCmdDbgMarkerEnd"); + pDebugMarkerTable->DbgSetObjectTag = (PFN_vkDbgSetObjectTag) pDisp->GetDeviceProcAddr(device, "vkDbgSetObjectTag"); + pDebugMarkerTable->DbgSetObjectName = (PFN_vkDbgSetObjectName) pDisp->GetDeviceProcAddr(device, "vkDbgSetObjectName"); + + return pTable; +} \ No newline at end of file diff --git a/layers/vk_layer_debug_marker_table.h b/layers/vk_layer_debug_marker_table.h new file mode 100644 index 00000000..8fc6e2e8 --- /dev/null +++ b/layers/vk_layer_debug_marker_table.h @@ -0,0 +1,39 @@ +/* + * Vulkan + * + * Copyright (C) 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#pragma once + +#include + +extern std::unordered_map tableDebugMarkerMap; +VkLayerDebugMarkerDispatchTable * initDebugMarkerTable(VkDevice dev); + +// Map lookup must be thread safe +static inline VkLayerDebugMarkerDispatchTable *debug_marker_dispatch_table(VkObject object) +{ + VkLayerDebugMarkerDispatchTable *pDisp = *(VkLayerDebugMarkerDispatchTable **) object; + std::unordered_map::const_iterator it = tableDebugMarkerMap.find((void *) pDisp); + assert(it != tableDebugMarkerMap.end() && "Not able to find debug marker dispatch entry"); + return it->second; +} + diff --git a/layers/vk_layer_logging.h b/layers/vk_layer_logging.h new file mode 100644 index 00000000..617c3b2d --- /dev/null +++ b/layers/vk_layer_logging.h @@ -0,0 +1,266 @@ +/* + * Vulkan + * + * Copyright (C) 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Courtney Goeltzenleuchter + */ + +#ifndef LAYER_LOGGING_H +#define LAYER_LOGGING_H + +#include +#include +#include +#include +#include "vk_layer.h" +#include "vk_layer_data.h" +#include "vk_layer_table.h" + +typedef struct _debug_report_data { + VkLayerDbgFunctionNode *g_pDbgFunctionHead; + VkFlags active_flags; + bool g_DEBUG_REPORT; +} debug_report_data; + +template debug_report_data *get_my_data_ptr( + void *data_key, + std::unordered_map &data_map); + +// Utility function to handle reporting +static inline void debug_report_log_msg( + debug_report_data *debug_data, + VkFlags msgFlags, + VkObjectType objectType, + VkObject srcObject, + size_t location, + int32_t msgCode, + const char* pLayerPrefix, + const char* pMsg) +{ + VkLayerDbgFunctionNode *pTrav = debug_data->g_pDbgFunctionHead; + while (pTrav) { + if (pTrav->msgFlags & msgFlags) { + pTrav->pfnMsgCallback(msgFlags, + objectType, srcObject, + location, + msgCode, + pLayerPrefix, + pMsg, + (void *) pTrav->pUserData); + } + pTrav = pTrav->pNext; + } +} + +static inline debug_report_data *debug_report_create_instance( + VkLayerInstanceDispatchTable *table, + VkInstance inst, + uint32_t extension_count, + const VkExtensionProperties* pEnabledExtensions) // layer or extension name to be enabled +{ + debug_report_data *debug_data; + PFN_vkGetInstanceProcAddr gpa = table->GetInstanceProcAddr; + + table->DbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback) gpa(inst, "vkDbgCreateMsgCallback"); + table->DbgDestroyMsgCallback = (PFN_vkDbgDestroyMsgCallback) gpa(inst, "vkDbgDestroyMsgCallback"); + + debug_data = (debug_report_data *) malloc(sizeof(debug_report_data)); + if (!debug_data) return NULL; + + memset(debug_data, 0, sizeof(debug_report_data)); + for (uint32_t i = 0; i < extension_count; i++) { + /* TODO: Check other property fields */ + if (strcmp(pEnabledExtensions[i].name, DEBUG_REPORT_EXTENSION_NAME) == 0) { + debug_data->g_DEBUG_REPORT = true; + } + } + return debug_data; +} + +static inline void layer_debug_report_destroy_instance(debug_report_data *debug_data) +{ + VkLayerDbgFunctionNode *pTrav; + VkLayerDbgFunctionNode *pTravNext; + + if (!debug_data) { + return; + } + + pTrav = debug_data->g_pDbgFunctionHead; + /* Clear out any leftover callbacks */ + while (pTrav) { + pTravNext = pTrav->pNext; + + debug_report_log_msg( + debug_data, VK_DBG_REPORT_WARN_BIT, + VK_OBJECT_TYPE_MSG_CALLBACK, pTrav->msgCallback, + 0, DEBUG_REPORT_CALLBACK_REF, + "DebugReport", + "Debug Report callbacks not removed before DestroyInstance"); + + free(pTrav); + pTrav = pTravNext; + } + debug_data->g_pDbgFunctionHead = NULL; + + free(debug_data); +} + +static inline debug_report_data *layer_debug_report_create_device( + debug_report_data *instance_debug_data, + VkDevice device) +{ + /* DEBUG_REPORT shares data between Instance and Device, + * so just return instance's data pointer */ + return instance_debug_data; +} + +static inline void layer_debug_report_destroy_device(VkDevice device) +{ + /* Nothing to do since we're using instance data record */ +} + +static inline VkResult layer_create_msg_callback( + debug_report_data *debug_data, + VkFlags msgFlags, + const PFN_vkDbgMsgCallback pfnMsgCallback, + void *pUserData, + VkDbgMsgCallback *pMsgCallback) +{ + VkLayerDbgFunctionNode *pNewDbgFuncNode = (VkLayerDbgFunctionNode*)malloc(sizeof(VkLayerDbgFunctionNode)); + if (!pNewDbgFuncNode) + return VK_ERROR_OUT_OF_HOST_MEMORY; + + pNewDbgFuncNode->msgCallback = *pMsgCallback; + pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; + pNewDbgFuncNode->msgFlags = msgFlags; + pNewDbgFuncNode->pUserData = pUserData; + pNewDbgFuncNode->pNext = debug_data->g_pDbgFunctionHead; + + debug_data->g_pDbgFunctionHead = pNewDbgFuncNode; + debug_data->active_flags |= msgFlags; + + debug_report_log_msg( + debug_data, VK_DBG_REPORT_DEBUG_BIT, + VK_OBJECT_TYPE_MSG_CALLBACK, *pMsgCallback, + 0, DEBUG_REPORT_CALLBACK_REF, + "DebugReport", + "Added callback"); + return VK_SUCCESS; +} + +static inline void layer_destroy_msg_callback( + debug_report_data *debug_data, + VkDbgMsgCallback msg_callback) +{ + VkLayerDbgFunctionNode *pTrav = debug_data->g_pDbgFunctionHead; + VkLayerDbgFunctionNode *pPrev = pTrav; + + debug_data->active_flags = 0; + while (pTrav) { + if (pTrav->msgCallback == msg_callback) { + pPrev->pNext = pTrav->pNext; + if (debug_data->g_pDbgFunctionHead == pTrav) { + debug_data->g_pDbgFunctionHead = pTrav->pNext; + } + free(pTrav); + debug_report_log_msg( + debug_data, VK_DBG_REPORT_DEBUG_BIT, + VK_OBJECT_TYPE_MSG_CALLBACK, pTrav->msgCallback, + 0, DEBUG_REPORT_NONE, + "DebugReport", + "Destroyed callback"); + } + debug_data->active_flags |= pTrav->msgFlags; + pPrev = pTrav; + pTrav = pTrav->pNext; + } +} + +static inline void* debug_report_get_instance_proc_addr( + debug_report_data *debug_data, + const char *funcName) +{ + if (!debug_data || !debug_data->g_DEBUG_REPORT) { + return NULL; + } + + if (!strcmp(funcName, "vkDbgCreateMsgCallback")) { + return (void *) vkDbgCreateMsgCallback; + } + if (!strcmp(funcName, "vkDbgDestroyMsgCallback")) { + return (void *) vkDbgDestroyMsgCallback; + } + + return NULL; +} + +/* + * Output log message via DEBUG_REPORT + * Takes format and variable arg list so that output string + * is only computed if a message needs to be logged + */ +static inline void log_msg( + debug_report_data *debug_data, + VkFlags msgFlags, + VkObjectType objectType, + VkObject srcObject, + size_t location, + int32_t msgCode, + const char* pLayerPrefix, + const char* format, + ...) +{ + if (!debug_data || !(debug_data->active_flags & msgFlags)) { + /* message is not wanted */ + return; + } + + char str[1024]; + va_list argptr; + va_start(argptr, format); + vsnprintf(str, 1024, format, argptr); + va_end(argptr); + debug_report_log_msg(debug_data, msgFlags, objectType, + srcObject, location, msgCode, + pLayerPrefix, str); +} + +static inline void VKAPI log_callback( + VkFlags msgFlags, + VkObjectType objType, + VkObject srcObject, + size_t location, + int32_t msgCode, + const char* pLayerPrefix, + const char* pMsg, + void* pUserData) +{ + char msg_flags[30]; + + print_msg_flags(msgFlags, msg_flags); + + fprintf((FILE *) pUserData, "%s(%s): object: 0x%p type: %d location: %zu msgCode: %d: %s\n", + pLayerPrefix, msg_flags, srcObject, objType, location, msgCode, pMsg); +} +#endif // LAYER_LOGGING_H diff --git a/layers/vk_layer_msg.h b/layers/vk_layer_msg.h new file mode 100644 index 00000000..2d0e31d6 --- /dev/null +++ b/layers/vk_layer_msg.h @@ -0,0 +1,153 @@ +/* + * Vulkan + * + * Copyright (C) 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include "vk_layer.h" + +static VkLayerDbgFunctionNode *g_pDbgFunctionHead = NULL; +static VkFlags g_reportFlags = (VkFlags) 0; +static VkLayerDbgAction g_debugAction = VK_DBG_LAYER_ACTION_LOG_MSG; +static bool g_actionIsDefault = true; +static bool g_DEBUG_REPORT = false; +static FILE *g_logFile = NULL; + +static void enable_debug_report( + uint32_t extension_count, + const VkExtensionProperties* pEnabledExtensions) // layer or extension name to be enabled +{ + for (uint32_t i = 0; i < extension_count; i++) { + /* TODO: Check other property fields */ + if (strcmp(pEnabledExtensions[i].name, DEBUG_REPORT_EXTENSION_NAME) == 0) { + g_DEBUG_REPORT = true; + } + } +} + +static VkResult layer_create_msg_callback( + VkInstance instance, + VkLayerInstanceDispatchTable* nextTable, + VkFlags msgFlags, + const PFN_vkDbgMsgCallback pfnMsgCallback, + void* pUserData, + VkDbgMsgCallback* pMsgCallback) +{ + VkLayerDbgFunctionNode *pNewDbgFuncNode = (VkLayerDbgFunctionNode*)malloc(sizeof(VkLayerDbgFunctionNode)); + if (!pNewDbgFuncNode) + return VK_ERROR_OUT_OF_HOST_MEMORY; + VkResult result = nextTable->DbgCreateMsgCallback(instance, msgFlags, pfnMsgCallback, pUserData, pMsgCallback); + if (result == VK_SUCCESS) { + pNewDbgFuncNode->msgCallback = *pMsgCallback; + pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; + pNewDbgFuncNode->msgFlags = msgFlags; + pNewDbgFuncNode->pUserData = pUserData; + pNewDbgFuncNode->pNext = g_pDbgFunctionHead; + + /* TODO: This should be a per-instance resource */ + g_pDbgFunctionHead = pNewDbgFuncNode; + } else { + free(pNewDbgFuncNode); + } + return result; +} + +static VkResult layer_destroy_msg_callback( + VkInstance instance, + VkLayerInstanceDispatchTable *nextTable, + VkDbgMsgCallback msg_callback) +{ + VkLayerDbgFunctionNode *pTrav = g_pDbgFunctionHead; + VkLayerDbgFunctionNode *pPrev = pTrav; + + VkResult result = nextTable->DbgDestroyMsgCallback(instance, msg_callback); + + while (pTrav) { + if (pTrav->msgCallback == msg_callback) { + pPrev->pNext = pTrav->pNext; + if (g_pDbgFunctionHead == pTrav) + g_pDbgFunctionHead = pTrav->pNext; + free(pTrav); + break; + } + pPrev = pTrav; + pTrav = pTrav->pNext; + } + + return result; +} + +static inline void debug_report_init_instance_extension_dispatch_table( + VkLayerInstanceDispatchTable *table, + PFN_vkGetInstanceProcAddr gpa, + VkInstance inst) +{ + table->DbgCreateMsgCallback = (PFN_vkDbgCreateMsgCallback) gpa(inst, "vkDbgCreateMsgCallback"); + table->DbgDestroyMsgCallback = (PFN_vkDbgDestroyMsgCallback) gpa(inst, "vkDbgDestroyMsgCallback"); +} + +static void* msg_callback_get_proc_addr( + const char *funcName) +{ + if (!g_DEBUG_REPORT) { + return NULL; + } + + if (!strcmp(funcName, "vkDbgCreateMsgCallback")) { + return (void *) vkDbgCreateMsgCallback; + } + if (!strcmp(funcName, "vkDbgDestroyMsgCallback")) { + return (void *) vkDbgDestroyMsgCallback; + } + + return NULL; +} + +// Utility function to handle reporting +// If callbacks are enabled, use them, otherwise use printf +static void layerCbMsg( + VkFlags msgFlags, + VkObjectType objectType, + VkObject srcObject, + size_t location, + int32_t msgCode, + const char* pLayerPrefix, + const char* pMsg) +{ + if (g_logFile == NULL) { + g_logFile = stdout; + } + + VkLayerDbgFunctionNode *pTrav = g_pDbgFunctionHead; + while (pTrav) { + if (pTrav->msgFlags & msgFlags) { + pTrav->pfnMsgCallback(msgFlags, + objectType, srcObject, + location, + msgCode, + pLayerPrefix, + pMsg, + (void *) pTrav->pUserData); + } + pTrav = pTrav->pNext; + } +} diff --git a/layers/vk_layer_table.cpp b/layers/vk_layer_table.cpp new file mode 100644 index 00000000..5fbec8ae --- /dev/null +++ b/layers/vk_layer_table.cpp @@ -0,0 +1,198 @@ +/* + * Vulkan + * + * Copyright (C) 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include "vk_dispatch_table_helper.h" +#include "vk_layer.h" +#include "vk_layer_table.h" +static device_table_map tableMap; +static instance_table_map tableInstanceMap; + +#define DISPATCH_MAP_DEBUG 0 + +// Map lookup must be thread safe +VkLayerDispatchTable *device_dispatch_table(VkObject object) +{ + dispatch_key key = get_dispatch_key(object); + device_table_map::const_iterator it = tableMap.find((void *) key); + assert(it != tableMap.end() && "Not able to find device dispatch entry"); + return it->second; +} + +VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object) +{ + dispatch_key key = get_dispatch_key(object); + instance_table_map::const_iterator it = tableInstanceMap.find((void *) key); +#if DISPATCH_MAP_DEBUG + if (it != tableInstanceMap.end()) { + fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: %p\n", &tableInstanceMap, object, key, it->second); + } else { + fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: UNKNOWN\n", &tableInstanceMap, object, key); + } +#endif + assert(it != tableInstanceMap.end() && "Not able to find instance dispatch entry"); + return it->second; +} + +void destroy_dispatch_table(device_table_map &map, dispatch_key key) +{ + device_table_map::const_iterator it = map.find((void *) key); +#if DISPATCH_MAP_DEBUG + if (it != map.end()) { + fprintf(stderr, "destroy device dispatch_table: map: %p, key: %p, table: %p\n", &map, key, it->second); + } else { + fprintf(stderr, "destroy device dispatch table: map: %p, key: %p, table: UNKNOWN\n", &map, key); + assert(it != map.end()); + } +#endif + map.erase(key); +} + +void destroy_dispatch_table(instance_table_map &map, dispatch_key key) +{ + instance_table_map::const_iterator it = map.find((void *) key); +#if DISPATCH_MAP_DEBUG + if (it != map.end()) { + fprintf(stderr, "destroy instance dispatch_table: map: %p, key: %p, table: %p\n", &map, key, it->second); + } else { + fprintf(stderr, "destroy instance dispatch table: map: %p, key: %p, table: UNKNOWN\n", &map, key); + assert(it != map.end()); + } +#endif + map.erase(key); +} + +void destroy_device_dispatch_table(dispatch_key key) +{ + destroy_dispatch_table(tableMap, key); +} + +void destroy_instance_dispatch_table(dispatch_key key) +{ + destroy_dispatch_table(tableInstanceMap, key); +} + +VkLayerDispatchTable *get_dispatch_table(device_table_map &map, VkObject object) +{ + dispatch_key key = get_dispatch_key(object); + device_table_map::const_iterator it = map.find((void *) key); +#if DISPATCH_MAP_DEBUG + if (it != map.end()) { + fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: %p\n", &tableInstanceMap, object, key, it->second); + } else { + fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: UNKNOWN\n", &tableInstanceMap, object, key); + } +#endif + assert(it != map.end() && "Not able to find device dispatch entry"); + return it->second; +} + +VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, VkObject object) +{ +// VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) object; + dispatch_key key = get_dispatch_key(object); + instance_table_map::const_iterator it = map.find((void *) key); +#if DISPATCH_MAP_DEBUG + if (it != map.end()) { + fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: %p\n", &tableInstanceMap, object, key, it->second); + } else { + fprintf(stderr, "instance_dispatch_table: map: %p, object: %p, key: %p, table: UNKNOWN\n", &tableInstanceMap, object, key); + } +#endif + assert(it != map.end() && "Not able to find instance dispatch entry"); + return it->second; +} + +/* Various dispatchable objects will use the same underlying dispatch table if they + * are created from that "parent" object. Thus use pointer to dispatch table + * as the key to these table maps. + * Instance -> PhysicalDevice + * Device -> CmdBuffer or Queue + * If use the object themselves as key to map then implies Create entrypoints have to be intercepted + * and a new key inserted into map */ +VkLayerInstanceDispatchTable * initInstanceTable(instance_table_map &map, const VkBaseLayerObject *instancew) +{ + VkLayerInstanceDispatchTable *pTable; + assert(instancew); + VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instancew->baseObject; + + std::unordered_map::const_iterator it = map.find((void *) *ppDisp); + if (it == map.end()) + { + pTable = new VkLayerInstanceDispatchTable; + map[(void *) *ppDisp] = pTable; +#if DISPATCH_MAP_DEBUG + fprintf(stderr, "New, Instance: map: %p, base object: %p, key: %p, table: %p\n", &map, instancew, *ppDisp, pTable); +#endif + assert(map.size() <= 1 && "Instance dispatch table map has more than one entry"); + } else + { +#if DISPATCH_MAP_DEBUG + fprintf(stderr, "Instance: map: %p, base object: %p, key: %p, table: %p\n", &map, instancew, *ppDisp, it->second); +#endif + return it->second; + } + + layer_init_instance_dispatch_table(pTable, instancew); + + return pTable; +} + +VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instancew) +{ + return initInstanceTable(tableInstanceMap, instancew); +} + +VkLayerDispatchTable * initDeviceTable(device_table_map &map, const VkBaseLayerObject *devw) +{ + VkLayerDispatchTable *layer_device_table = NULL; + assert(devw); + VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject); + VkLayerDispatchTable *base_device_table = *ppDisp; + + std::unordered_map::const_iterator it = map.find((void *) base_device_table); + if (it == map.end()) + { + layer_device_table = new VkLayerDispatchTable; + map[(void *) base_device_table] = layer_device_table; +#if DISPATCH_MAP_DEBUG + fprintf(stderr, "New, Device: map: %p, base object: %p, key: %p, table: %p\n", &map, devw, *ppDisp, layer_device_table); +#endif + } else + { +#if DISPATCH_MAP_DEBUG + fprintf(stderr, "Device: map: %p, base object: %p, key: %p, table: %p\n", &map, devw, *ppDisp, it->second); +#endif + return it->second; + } + + layer_initialize_dispatch_table(layer_device_table, devw); + + return layer_device_table; +} + +VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw) +{ + return initDeviceTable(tableMap, devw); +} diff --git a/layers/vk_layer_table.h b/layers/vk_layer_table.h new file mode 100644 index 00000000..24f0bd4e --- /dev/null +++ b/layers/vk_layer_table.h @@ -0,0 +1,51 @@ +/* + * Vulkan + * + * Copyright (C) 2014 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#pragma once + +#include + +typedef std::unordered_map device_table_map; +typedef std::unordered_map instance_table_map; +VkLayerDispatchTable * initDeviceTable(const VkBaseLayerObject *devw); +VkLayerDispatchTable * initDeviceTable(device_table_map &map, const VkBaseLayerObject *devw); +VkLayerInstanceDispatchTable * initInstanceTable(const VkBaseLayerObject *instancew); +VkLayerInstanceDispatchTable * initInstanceTable(instance_table_map &map, const VkBaseLayerObject *instancew); + +typedef void *dispatch_key; + +static inline dispatch_key get_dispatch_key(VkObject object) +{ + return (dispatch_key) *(VkLayerDispatchTable **) object; +} + +VkLayerDispatchTable *device_dispatch_table(VkObject object); + +VkLayerInstanceDispatchTable *instance_dispatch_table(VkObject object); + +VkLayerDispatchTable *get_dispatch_table(device_table_map &map, VkObject object); + +VkLayerInstanceDispatchTable *get_dispatch_table(instance_table_map &map, VkObject object); + +void destroy_device_dispatch_table(dispatch_key key); +void destroy_instance_dispatch_table(dispatch_key key); diff --git a/vk-layer-generate.py b/vk-layer-generate.py index 276f0fed..97f4767e 100755 --- a/vk-layer-generate.py +++ b/vk-layer-generate.py @@ -599,9 +599,9 @@ class GenericLayerSubcommand(Subcommand): gen_header.append('//The following is #included again to catch certain OS-specific functions being used:') gen_header.append('') gen_header.append('#include "loader_platform.h"') - gen_header.append('#include "layers_config.h"') - gen_header.append('#include "layers_msg.h"') - gen_header.append('#include "layers_table.h"') + gen_header.append('#include "vk_layer_config.h"') + gen_header.append('#include "vk_layer_msg.h"') + gen_header.append('#include "vk_layer_table.h"') gen_header.append('') gen_header.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);') gen_header.append('struct devExts {') @@ -744,7 +744,7 @@ class APIDumpSubcommand(Subcommand): header_txt.append('#include "loader_platform.h"') header_txt.append('#include "vk_layer.h"') header_txt.append('#include "vk_struct_string_helper_cpp.h"') - header_txt.append('#include "layers_table.h"') + header_txt.append('#include "vk_layer_table.h"') header_txt.append('#include ') header_txt.append('') header_txt.append('// The following is #included again to catch certain OS-specific functions being used:') @@ -800,7 +800,7 @@ class APIDumpSubcommand(Subcommand): func_body = [] func_body.append('%s' % self.lineinfo.get()) func_body.append('#include "vk_dispatch_table_helper.h"') - func_body.append('#include "layers_config.h"') + func_body.append('#include "vk_layer_config.h"') func_body.append('') func_body.append('static void init%s(void)' % self.layer_name) func_body.append('{') @@ -1076,12 +1076,12 @@ class ObjectTrackerSubcommand(Subcommand): header_txt.append('using namespace std;') header_txt.append('// The following is #included again to catch certain OS-specific functions being used:') header_txt.append('#include "loader_platform.h"') - header_txt.append('#include "layers_config.h"') - header_txt.append('#include "layers_msg.h"') + header_txt.append('#include "vk_layer_config.h"') + header_txt.append('#include "vk_layer_msg.h"') header_txt.append('#include "vk_debug_report_lunarg.h"') - header_txt.append('#include "layers_table.h"') - header_txt.append('#include "layer_data.h"') - header_txt.append('#include "layer_logging.h"') + header_txt.append('#include "vk_layer_table.h"') + header_txt.append('#include "vk_layer_data.h"') + header_txt.append('#include "vk_layer_logging.h"') header_txt.append('') # NOTE: The non-autoGenerated code is in the object_track.h header file header_txt.append('#include "object_track.h"') @@ -1228,13 +1228,13 @@ class ThreadingSubcommand(Subcommand): header_txt.append('#include "loader_platform.h"') header_txt.append('#include "vk_layer.h"') header_txt.append('#include "threading.h"') - header_txt.append('#include "layers_config.h"') + header_txt.append('#include "vk_layer_config.h"') header_txt.append('#include "vk_enum_validate_helper.h"') header_txt.append('#include "vk_struct_validate_helper.h"') header_txt.append('//The following is #included again to catch certain OS-specific functions being used:') header_txt.append('#include "loader_platform.h"\n') - header_txt.append('#include "layers_msg.h"\n') - header_txt.append('#include "layers_table.h"\n') + header_txt.append('#include "vk_layer_msg.h"\n') + header_txt.append('#include "vk_layer_table.h"\n') header_txt.append('') header_txt.append('') header_txt.append('static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(initOnce);') -- cgit v1.2.3