layers: Add support for Windows DEBUG_OUTPUT logging
authorCourtney Goeltzenleuchter <courtney@LunarG.com>
Mon, 5 Oct 2015 20:41:34 +0000 (14:41 -0600)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 8 Oct 2015 22:55:33 +0000 (16:55 -0600)
include/vk_layer.h
layers/vk_layer_config.cpp
layers/vk_layer_logging.h

index 82b66ff..c41f2eb 100644 (file)
@@ -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;
 
 // ------------------------------------------------------------------------------------------------
index 66254c7..1d8bde2 100755 (executable)
@@ -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;
index c7ac17e..171861d 100644 (file)
@@ -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