blob: c6f757015204e0cafe90ef5c53c82b9df5d116ec [file] [log] [blame]
Jesse Hall715b86a2016-01-16 16:34:29 -08001/*
2 * Copyright 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef LIBVULKAN_DEBUG_REPORT_H
18#define LIBVULKAN_DEBUG_REPORT_H 1
19
20#include <shared_mutex>
Jesse Hall715b86a2016-01-16 16:34:29 -080021
22namespace vulkan {
23
24// clang-format off
25VKAPI_ATTR VkResult CreateDebugReportCallbackEXT_Bottom(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback);
26VKAPI_ATTR void DestroyDebugReportCallbackEXT_Bottom(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator);
27VKAPI_ATTR void DebugReportMessageEXT_Bottom(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage);
28// clang-format on
29
30class DebugReportCallbackList {
31 public:
32 DebugReportCallbackList()
33 : head_{nullptr, 0, nullptr, nullptr, VK_NULL_HANDLE} {}
34 DebugReportCallbackList(const DebugReportCallbackList&) = delete;
35 DebugReportCallbackList& operator=(const DebugReportCallbackList&) = delete;
36 ~DebugReportCallbackList() = default;
37
38 VkResult CreateCallback(
39 VkInstance instance,
40 const VkDebugReportCallbackCreateInfoEXT* create_info,
41 const VkAllocationCallbacks* allocator,
42 VkDebugReportCallbackEXT* callback);
43 void DestroyCallback(VkInstance instance,
44 VkDebugReportCallbackEXT callback,
45 const VkAllocationCallbacks* allocator);
46 void Message(VkDebugReportFlagsEXT flags,
47 VkDebugReportObjectTypeEXT object_type,
48 uint64_t object,
49 size_t location,
50 int32_t message_code,
51 const char* layer_prefix,
52 const char* message);
53
54 private:
55 struct Node {
56 Node* next;
57 VkDebugReportFlagsEXT flags;
58 PFN_vkDebugReportCallbackEXT callback;
59 void* data;
60 VkDebugReportCallbackEXT driver_callback;
61 };
62
63 // TODO(jessehall): replace with std::shared_mutex when available in libc++
64 std::shared_timed_mutex rwmutex_;
65 Node head_;
66};
67
68} // namespace vulkan
69
70#endif // LIBVULKAN_DEBUG_REPORT_H