1/*
2 * Copyright © 2018, Google Inc.
3 *
4 * based on the anv driver which is:
5 * Copyright © 2017 Intel Corporation
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * IN THE SOFTWARE.
25 */
26#ifndef VK_DEBUG_REPORT_H
27#define VK_DEBUG_REPORT_H
28
29#include <pthread.h>
30
31#include "util/list.h"
32#include <vulkan/vulkan.h>
33
34struct vk_debug_report_callback {
35   /* Link in the 'callbacks' list in anv_instance struct. */
36   struct list_head                             link;
37   VkDebugReportFlagsEXT                        flags;
38   PFN_vkDebugReportCallbackEXT                 callback;
39   void *                                       data;
40};
41
42struct vk_debug_report_instance {
43   /* VK_EXT_debug_report debug callbacks */
44   pthread_mutex_t                             callbacks_mutex;
45   struct list_head                            callbacks;
46};
47
48VkResult vk_debug_report_instance_init(struct vk_debug_report_instance *instance);
49void vk_debug_report_instance_destroy(struct vk_debug_report_instance *instance);
50
51VkResult
52vk_create_debug_report_callback(struct vk_debug_report_instance *instance,
53                                const VkDebugReportCallbackCreateInfoEXT* pCreateInfo,
54                                const VkAllocationCallbacks* pAllocator,
55                                const VkAllocationCallbacks* instance_allocator,
56                                VkDebugReportCallbackEXT* pCallback);
57void
58vk_destroy_debug_report_callback(struct vk_debug_report_instance *instance,
59                                 VkDebugReportCallbackEXT _callback,
60                                 const VkAllocationCallbacks* pAllocator,
61                                 const VkAllocationCallbacks* instance_allocator);
62
63void
64vk_debug_report(struct vk_debug_report_instance *instance,
65                VkDebugReportFlagsEXT flags,
66                VkDebugReportObjectTypeEXT object_type,
67                uint64_t handle,
68                size_t location,
69                int32_t messageCode,
70                const char* pLayerPrefix,
71                const char *pMessage);
72#endif
73