From 3e077bf28ce67da08250a9a061ad14b38fbf47ec Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Mon, 5 Oct 2015 14:41:34 -0600 Subject: layers: Add support for Windows DEBUG_OUTPUT logging --- include/vk_layer.h | 3 ++- layers/vk_layer_config.cpp | 4 ++++ layers/vk_layer_logging.h | 25 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/vk_layer.h b/include/vk_layer.h index 82b66ffc..c41f2ebc 100644 --- a/include/vk_layer.h +++ b/include/vk_layer.h @@ -203,7 +203,8 @@ typedef enum VkLayerDbgAction_ VK_DBG_LAYER_ACTION_IGNORE = 0x0, VK_DBG_LAYER_ACTION_CALLBACK = 0x1, VK_DBG_LAYER_ACTION_LOG_MSG = 0x2, - VK_DBG_LAYER_ACTION_BREAK = 0x4 + VK_DBG_LAYER_ACTION_BREAK = 0x4, + VK_DBG_LAYER_ACTION_DEBUG_OUTPUT = 0x8, } VkLayerDbgAction; // ------------------------------------------------------------------------------------------------ diff --git a/layers/vk_layer_config.cpp b/layers/vk_layer_config.cpp index 66254c74..1d8bde27 100755 --- a/layers/vk_layer_config.cpp +++ b/layers/vk_layer_config.cpp @@ -59,6 +59,10 @@ static VkLayerDbgAction stringToDbgAction(const char *_enum) return VK_DBG_LAYER_ACTION_IGNORE; else if (!strcmp(_enum, "VK_DBG_LAYER_ACTION_LOG_MSG")) return VK_DBG_LAYER_ACTION_LOG_MSG; +#ifdef WIN32 + else if (!strcmp(_enum, "VK_DBG_LAYER_ACTION_DEBUG_OUTPUT")) + return VK_DBG_LAYER_ACTION_DEBUG_OUTPUT; +#endif else if (!strcmp(_enum, "VK_DBG_LAYER_ACTION_BREAK")) return VK_DBG_LAYER_ACTION_BREAK; return (VkLayerDbgAction) 0; diff --git a/layers/vk_layer_logging.h b/layers/vk_layer_logging.h index c7ac17e6..171861da 100644 --- a/layers/vk_layer_logging.h +++ b/layers/vk_layer_logging.h @@ -299,4 +299,29 @@ static inline VkBool32 VKAPI log_callback( return false; } + +static inline VkBool32 VKAPI win32_debug_output_msg( + VkFlags msgFlags, + VkDbgObjectType objType, + uint64_t srcObject, + size_t location, + int32_t msgCode, + const char* pLayerPrefix, + const char* pMsg, + void* pUserData) +{ +#ifdef WIN32 + char msg_flags[30]; + char buf[2048]; + + print_msg_flags(msgFlags, msg_flags); + _snprintf(buf, sizeof(buf)-1, "%s (%s): object: 0x%" PRIxLEAST64 " type: %d location: %zu msgCode: %d: %s\n", + pLayerPrefix, msg_flags, srcObject, objType, location, msgCode, pMsg); + + OutputDebugString(buf); +#endif + + return false; +} + #endif // LAYER_LOGGING_H -- cgit v1.2.3