VK_EXT_debug_report extension, developers can obtain much more detailed feedback on the application’s use of Vulkan. This extension defines a way for layers and the implementation to call back to the application for events of interest to the application.
VK_EXT_debug_report allows an application to register multiple callbacks with the validation layers. Some callbacks may log the information to a file, others may cause a debug break point or other application defined behavior. An application can register callbacks even when no validation layers are enabled, but they will only be called for loader and, if implemented, driver events.
To capture events that occur while creating or destroying an instance an application can link a VkDebugReportCallbackCreateInfoEXT structure to the pNext element of the VkInstanceCreateInfo structure given to CreateInstance.
Example uses: Create three callback objects. One will log errors and warnings to the debug console using Windows OutputDebugString. The second will cause the debugger to break at that callback when an error happens and the third will log warnings to stdout.
VkResult res;
VkDebugReportCallbackEXT cb1, cb2, cb3;
VkDebugReportCallbackCreateInfoEXT callback1 = {
.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
.pNext = NULL,
.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT |
VK_DEBUG_REPORT_WARNING_BIT_EXT,
.pfnCallback = myOutputDebugString,
.pUserData = NULL
};
res = vkCreateDebugReportCallbackEXT(instance, &callback1, &cb1);
if (res != VK_SUCCESS)
// Do error handling for VK_ERROR_OUT_OF_MEMORY
callback.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT;
callback.pfnCallback = myDebugBreak;
callback.pUserData = NULL;
res = vkCreateDebugReportCallbackEXT(instance, &callback, &cb2);
if (res != VK_SUCCESS)
// Do error handling for VK_ERROR_OUT_OF_MEMORY
VkDebugReportCallbackCreateInfoEXT callback3 = {
.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT,
.pNext = NULL,
.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT,
.pfnCallback = mystdOutLogger,
.pUserData = NULL
};
res = vkCreateDebugReportCallbackEXT(instance, &callback3, &cb3);
if (res != VK_SUCCESS)
// Do error handling for VK_ERROR_OUT_OF_MEMORY
...
// remove callbacks when cleaning up
vkDestroyDebugReportCallbackEXT(instance, cb1);
vkDestroyDebugReportCallbackEXT(instance, cb2);
vkDestroyDebugReportCallbackEXT(instance, cb3);
VK_EXT_debug_reportVK_EXT_debug_utils extension| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static int | nvkCreateDebugReportCallbackEXT(VkInstance instance, long pCreateInfo, long pAllocator, long pCallback)
Unsafe version of: |
| public static void | nvkDebugReportMessageEXT(VkInstance instance, int flags, int objectType, long object, long location, int messageCode, long pLayerPrefix, long pMessage)
Unsafe version of: |
| public static void | nvkDestroyDebugReportCallbackEXT(VkInstance instance, long callback, long pAllocator)
Unsafe version of: |
| public static int | vkCreateDebugReportCallbackEXT(VkInstance
the instance the callback will be logged on. instance, VkDebugReportCallbackCreateInfoEXT a pointer to a pCreateInfo, VkAllocationCallbacks VkDebugReportCallbackCreateInfoEXT structure defining the conditions under which this callback will be called.controls host memory allocation as described in the Memory Allocation chapter. pAllocator, LongBuffer a pointer to a pCallback)VkDebugReportCallbackEXT handle in which the created object is returned.Create a debug report callback object. |
| public static int | vkCreateDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackCreateInfoEXT pCreateInfo, VkAllocationCallbacks pAllocator, long[] pCallback)
Array version of: |
| public static void | vkDebugReportMessageEXT(VkInstance
the debug stream’s instance, int VkInstance.specifies the flags, int VkDebugReportFlagBitsEXT classification of this event/message.a objectType, long VkDebugReportObjectTypeEXT specifying the type of object being used or created at the time the event was triggered.the object where the issue was detected. object, long object can be NULL_HANDLE if there is no object associated with the event.an application defined value. location, int an application defined value. messageCode, ByteBuffer the abbreviation of the component making this event/message. pLayerPrefix, ByteBuffer a null-terminated string detailing the trigger conditions. pMessage)Inject a message into a debug stream. |
| public static void | vkDebugReportMessageEXT(VkInstance
the debug stream’s instance, int VkInstance.specifies the flags, int VkDebugReportFlagBitsEXT classification of this event/message.a objectType, long VkDebugReportObjectTypeEXT specifying the type of object being used or created at the time the event was triggered.the object where the issue was detected. object, long object can be NULL_HANDLE if there is no object associated with the event.an application defined value. location, int an application defined value. messageCode, CharSequence the abbreviation of the component making this event/message. pLayerPrefix, CharSequence a null-terminated string detailing the trigger conditions. pMessage)Inject a message into a debug stream. |
| public static void | vkDestroyDebugReportCallbackEXT(VkInstance
the instance where the callback was created. instance, long the callback, VkAllocationCallbacks VkDebugReportCallbackEXT object to destroy. callback is an externally synchronized object and must not be used on more than one thread at a time. This means that vkDestroyDebugReportCallbackEXT must not be called when a callback is active.controls host memory allocation as described in the Memory Allocation chapter. pAllocator)Destroy a debug report callback object. |