diff options
| author | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-06-11 16:01:11 -0600 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-06-18 10:22:55 -0600 |
| commit | 2b22c4d44ea9fa33eac780ae7c115132df651996 (patch) | |
| tree | 3d58f46579e64917e3568dd76750f6d2762e9b8d /loader | |
| parent | 05710abce080c2665c6095c5faf8f6c47af66cf6 (diff) | |
| download | usermoji-2b22c4d44ea9fa33eac780ae7c115132df651996.tar.xz | |
memtracker: Add persistent storage
This patch eliminates global variables and accesses
everything through pre-instance or per-device storage.
Have basic template supporting get_my_data_ptr function working.
Diffstat (limited to 'loader')
| -rw-r--r-- | loader/debug_report.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/loader/debug_report.c b/loader/debug_report.c index 8be7472b..1d6a186b 100644 --- a/loader/debug_report.c +++ b/loader/debug_report.c @@ -26,11 +26,16 @@ * Courtney Goeltzenleuchter <courtney@lunarg.com> */ +#include <stdio.h> #include <string.h> #include <stdlib.h> +#include <inttypes.h> +#include <alloca.h> #include "debug_report.h" #include "vkLayer.h" +typedef void (VKAPI *PFN_stringCallback)(char *message); + static const struct loader_extension_property debug_report_extension_info = { .info = { .sType = VK_STRUCTURE_TYPE_EXTENSION_PROPERTIES, @@ -225,6 +230,36 @@ VkResult loader_DbgDestroyMsgCallback( return res; } +static 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"); + } +} + // DebugReport utility callback functions static void VKAPI StringCallback( VkFlags msgFlags, @@ -236,7 +271,26 @@ static void VKAPI StringCallback( const char* pMsg, void* pUserData) { - + uint32_t buf_size; + char *buf; + char msg_flags[30]; + PFN_stringCallback callback = (PFN_stringCallback) pUserData; + + print_msg_flags(msgFlags, msg_flags); + + buf_size = strlen(msg_flags) + /* ReportFlags: i.e. (DEBUG,INFO,WARN,PERF,ERROR) */ + 20 + /* objType */ + 20 + /* srcObject */ + 20 + /* location */ + 20 + /* msgCode */ + strlen(pLayerPrefix) + + strlen(pMsg) + + 50 /* other / whitespace */; + buf = alloca(buf_size); + + snprintf(buf, buf_size, "%s (%s): object: 0x%" PRIxLEAST64 " type: %d location: %zu msgCode: %d: %s", + pLayerPrefix, msg_flags, srcObject, objType, location, msgCode, pMsg); + callback(buf); } static void VKAPI StdioCallback( @@ -249,7 +303,12 @@ static void VKAPI StdioCallback( const char* pMsg, void* pUserData) { + char msg_flags[30]; + + print_msg_flags(msgFlags, msg_flags); + fprintf((FILE *) pUserData, "%s(%s): object: 0x%" PRIxLEAST64 " type: %d location: %zu msgCode: %d: %s", + pLayerPrefix, msg_flags, srcObject, objType, location, msgCode, pMsg); } static void VKAPI BreakCallback( |
