cube: Update debug report support
authorCourtney Goeltzenleuchter <courtneygo@google.com>
Tue, 1 Dec 2015 21:11:38 +0000 (14:11 -0700)
committerJon Ashburn <jon@lunarg.com>
Thu, 17 Dec 2015 18:20:07 +0000 (11:20 -0700)
Add break callback (it's been removed from the extension).
Grab function pointer for DebugReportMessageLUNARG.

demos/cube.c

index 59e4fef..277e53a 100644 (file)
@@ -31,6 +31,7 @@
 #include <string.h>
 #include <stdbool.h>
 #include <assert.h>
+#include <signal.h>
 
 #ifdef _WIN32
 #pragma comment(linker, "/subsystem:windows")
@@ -257,7 +258,7 @@ void dumpVec4(const char *note, vec4 vector)
 
 VkBool32 dbgFunc(
     VkFlags                             msgFlags,
-    VkDebugReportObjectTypeLUNARG                     objType,
+    VkDebugReportObjectTypeLUNARG       objType,
     uint64_t                            srcObject,
     size_t                              location,
     int32_t                             msgCode,
@@ -299,6 +300,25 @@ VkBool32 dbgFunc(
     return false;
 }
 
+VkBool32 BreakCallback(
+    VkFlags                             msgFlags,
+    VkDebugReportObjectTypeLUNARG       objType,
+    uint64_t                            srcObject,
+    size_t                              location,
+    int32_t                             msgCode,
+    const char*                         pLayerPrefix,
+    const char*                         pMsg,
+    const void*                         pUserData)
+{
+#ifndef WIN32
+    raise(SIGTRAP);
+#else
+    DebugBreak();
+#endif
+
+    return false;
+}
+
 typedef struct _SwapchainBuffers {
     VkImage image;
     VkCommandBuffer cmd;
@@ -397,8 +417,8 @@ struct demo {
     bool use_break;
     PFN_vkCreateDebugReportCallbackLUNARG CreateDebugReportCallback;
     PFN_vkDestroyDebugReportCallbackLUNARG DestroyDebugReportCallback;
-    PFN_vkDebugReportCallbackLUNARG dbgBreakCallback;
     VkDebugReportCallbackLUNARG msg_callback;
+    PFN_vkDebugReportMessageLUNARG DebugReportMessage;
 
     uint32_t current_buffer;
     uint32_t queue_count;
@@ -2325,6 +2345,11 @@ static void demo_init_vk(struct demo *demo)
             ERR_EXIT("GetProcAddr: Unable to find vkDestroyDebugReportCallbackLUNARG\n",
                      "vkGetProcAddr Failure");
         }
+        demo->DebugReportMessage = (PFN_vkDebugReportMessageLUNARG) vkGetInstanceProcAddr(demo->inst, "vkDebugReportMessageLUNARG");
+        if (!demo->DebugReportMessage) {
+            ERR_EXIT("GetProcAddr: Unable to find vkDebugReportMessageLUNARG\n",
+                     "vkGetProcAddr Failure");
+        }
 
         PFN_vkDebugReportCallbackLUNARG callback;