[metacity] vulkan: setup debug callback
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] vulkan: setup debug callback
- Date: Fri, 10 Mar 2017 20:22:31 +0000 (UTC)
commit 18f7c07dd16da3090c7cbca4384f7d7f466dd96a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Mar 10 18:26:58 2017 +0200
vulkan: setup debug callback
src/compositor/meta-compositor-vulkan.c | 89 +++++++++++++++++++++++++++++--
1 files changed, 85 insertions(+), 4 deletions(-)
---
diff --git a/src/compositor/meta-compositor-vulkan.c b/src/compositor/meta-compositor-vulkan.c
index cfca90e..fb01894 100644
--- a/src/compositor/meta-compositor-vulkan.c
+++ b/src/compositor/meta-compositor-vulkan.c
@@ -27,13 +27,15 @@
struct _MetaCompositorVulkan
{
- MetaCompositor parent;
+ MetaCompositor parent;
- gboolean lunarg_validation_layer;
- gboolean debug_report_extension;
+ gboolean lunarg_validation_layer;
+ gboolean debug_report_extension;
#ifdef HAVE_VULKAN
- VkInstance instance;
+ VkInstance instance;
+
+ VkDebugReportCallbackEXT debug_callback;
#endif
};
@@ -214,6 +216,69 @@ create_instance (MetaCompositorVulkan *vulkan,
return TRUE;
}
+
+static VkBool32
+debug_report_cb (VkDebugReportFlagsEXT flags,
+ VkDebugReportObjectTypeEXT objectType,
+ uint64_t object,
+ size_t location,
+ int32_t messageCode,
+ const char *pLayerPrefix,
+ const char *pMessage,
+ void *pUserData)
+{
+ if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT)
+ g_critical ("%s: %s", pLayerPrefix, pMessage);
+ else if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT)
+ g_critical ("%s: %s", pLayerPrefix, pMessage);
+ else if (flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT)
+ g_warning ("%s: %s", pLayerPrefix, pMessage);
+ else
+ meta_topic (META_DEBUG_VULKAN, "%s: %s\n", pLayerPrefix, pMessage);
+
+ return VK_FALSE;
+}
+
+static void
+setup_debug_callback (MetaCompositorVulkan *vulkan)
+{
+ PFN_vkVoidFunction f;
+ VkDebugReportFlagsEXT flags;
+ VkDebugReportCallbackCreateInfoEXT info;
+ VkResult result;
+
+ if (!vulkan->lunarg_validation_layer || !vulkan->debug_report_extension)
+ return;
+
+ f = vkGetInstanceProcAddr (vulkan->instance, "vkCreateDebugReportCallbackEXT");
+
+ if (f == VK_NULL_HANDLE)
+ {
+ g_warning ("VK_EXT_debug_report not found");
+ return;
+ }
+
+ flags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT |
+ VK_DEBUG_REPORT_WARNING_BIT_EXT |
+ VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT |
+ VK_DEBUG_REPORT_ERROR_BIT_EXT |
+ VK_DEBUG_REPORT_DEBUG_BIT_EXT;
+
+ info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
+ info.pNext = NULL;
+ info.flags = flags;
+ info.pfnCallback = debug_report_cb;
+ info.pUserData = NULL;
+
+ result = ((PFN_vkCreateDebugReportCallbackEXT) f) (vulkan->instance,
+ &info, NULL,
+ &vulkan->debug_callback);
+
+ if (result != VK_SUCCESS)
+ {
+ g_warning ("Failed to set up debug callback");
+ }
+}
#endif
static void
@@ -224,6 +289,20 @@ meta_compositor_vulkan_finalize (GObject *object)
vulkan = META_COMPOSITOR_VULKAN (object);
+ if (vulkan->debug_callback != VK_NULL_HANDLE)
+ {
+ PFN_vkVoidFunction f;
+
+ f = vkGetInstanceProcAddr (vulkan->instance,
+ "vkDestroyDebugReportCallbackEXT");
+
+ ((PFN_vkDestroyDebugReportCallbackEXT) f) (vulkan->instance,
+ vulkan->debug_callback,
+ NULL);
+
+ vulkan->debug_callback = VK_NULL_HANDLE;
+ }
+
if (vulkan->instance != VK_NULL_HANDLE)
{
vkDestroyInstance (vulkan->instance, NULL);
@@ -249,6 +328,8 @@ meta_compositor_vulkan_manage (MetaCompositor *compositor,
if (!create_instance (vulkan, error))
return FALSE;
+ setup_debug_callback (vulkan);
+
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Not implemented");
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]