1/*
2 * Copyright (c) 2015-2021 The Khronos Group Inc.
3 * Copyright (c) 2015-2021 Valve Corporation
4 * Copyright (c) 2015-2021 LunarG, Inc.
5 * Copyright (C) 2015-2016 Google Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *     http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
20 * Author: Jon Ashburn <jon@lunarg.com>
21 * Author: Mark Young <markyk@lunarg.com>
22 * Author: Charles Giessen <charles@lunarg.com>
23 */
24
25#pragma once
26
27#include "loader_common.h"
28
29// General utilities
30
31VkResult add_debug_extensions_to_ext_list(const struct loader_instance *inst, struct loader_extension_list *ext_list);
32void check_for_enabled_debug_extensions(struct loader_instance *ptr_instance, const VkInstanceCreateInfo *pCreateInfo);
33bool debug_extensions_InstanceGpa(struct loader_instance *ptr_instance, const char *name, void **addr);
34bool debug_utils_ReportFlagsToAnnotFlags(VkDebugReportFlagsEXT dr_flags, bool default_flag_is_spec,
35                                         VkDebugUtilsMessageSeverityFlagBitsEXT *da_severity,
36                                         VkDebugUtilsMessageTypeFlagsEXT *da_type);
37bool debug_utils_AnnotFlagsToReportFlags(VkDebugUtilsMessageSeverityFlagBitsEXT da_severity,
38                                         VkDebugUtilsMessageTypeFlagsEXT da_type, VkDebugReportFlagsEXT *dr_flags);
39bool debug_utils_ReportObjectToAnnotObject(VkDebugReportObjectTypeEXT dr_object_type, uint64_t object_handle,
40                                           VkDebugUtilsObjectNameInfoEXT *da_object_name_info);
41bool debug_utils_AnnotObjectToDebugReportObject(const VkDebugUtilsObjectNameInfoEXT *da_object_name_info,
42                                                VkDebugReportObjectTypeEXT *dr_object_type, uint64_t *dr_object_handle);
43
44void destroy_debug_callbacks_chain(struct loader_instance *inst, const VkAllocationCallbacks *pAllocator);
45
46// VK_EXT_debug_utils related items
47
48VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugUtilsMessengerEXT(VkInstance instance,
49                                                                       const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo,
50                                                                       const VkAllocationCallbacks *pAllocator,
51                                                                       VkDebugUtilsMessengerEXT *pMessenger);
52VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger,
53                                                                    const VkAllocationCallbacks *pAllocator);
54VKAPI_ATTR void VKAPI_CALL terminator_SubmitDebugUtilsMessageEXT(VkInstance instance,
55                                                                 VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
56                                                                 VkDebugUtilsMessageTypeFlagsEXT messageTypes,
57                                                                 const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData);
58VkResult util_CreateDebugUtilsMessengers(struct loader_instance *inst, const void *pChain, const VkAllocationCallbacks *pAllocator);
59VkBool32 util_SubmitDebugUtilsMessageEXT(const struct loader_instance *inst, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
60                                         VkDebugUtilsMessageTypeFlagsEXT messageTypes,
61                                         const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData);
62
63// VK_EXT_debug_report related items
64
65VKAPI_ATTR VkResult VKAPI_CALL terminator_CreateDebugReportCallbackEXT(VkInstance instance,
66                                                                       const VkDebugReportCallbackCreateInfoEXT *pCreateInfo,
67                                                                       const VkAllocationCallbacks *pAllocator,
68                                                                       VkDebugReportCallbackEXT *pCallback);
69
70VKAPI_ATTR void VKAPI_CALL terminator_DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback,
71                                                                    const VkAllocationCallbacks *pAllocator);
72
73VKAPI_ATTR void VKAPI_CALL terminator_DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags,
74                                                            VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location,
75                                                            int32_t msgCode, const char *pLayerPrefix, const char *pMsg);
76
77VkResult util_CreateDebugReportCallbacks(struct loader_instance *inst, const void *pChain, const VkAllocationCallbacks *pAllocator);
78VkBool32 util_DebugReportMessage(const struct loader_instance *inst, VkFlags msgFlags, VkDebugReportObjectTypeEXT objectType,
79                                 uint64_t srcObject, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg);
80