2 * Copyright 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef LIBVULKAN_DEBUG_REPORT_H
18 #define LIBVULKAN_DEBUG_REPORT_H 1
20 #include <vulkan/vulkan.h>
21 #include <shared_mutex>
27 VKAPI_ATTR VkResult CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback);
28 VKAPI_ATTR void DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator);
29 VKAPI_ATTR void DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage);
32 class DebugReportCallbackList {
34 // forward declaration
38 DebugReportCallbackList()
39 : head_{nullptr, 0, nullptr, nullptr, VK_NULL_HANDLE} {}
40 DebugReportCallbackList(const DebugReportCallbackList&) = delete;
41 DebugReportCallbackList& operator=(const DebugReportCallbackList&) = delete;
42 ~DebugReportCallbackList() = default;
44 Node* AddCallback(const VkDebugReportCallbackCreateInfoEXT& info,
45 VkDebugReportCallbackEXT driver_handle,
46 const VkAllocationCallbacks& allocator);
47 void RemoveCallback(Node* node, const VkAllocationCallbacks& allocator);
49 void Message(VkDebugReportFlagsEXT flags,
50 VkDebugReportObjectTypeEXT object_type,
54 const char* layer_prefix,
55 const char* message) const;
57 static Node* FromHandle(VkDebugReportCallbackEXT handle) {
58 return reinterpret_cast<Node*>(uintptr_t(handle));
61 static VkDebugReportCallbackEXT GetHandle(const Node* node) {
62 return VkDebugReportCallbackEXT(reinterpret_cast<uintptr_t>(node));
65 static VkDebugReportCallbackEXT GetDriverHandle(const Node* node) {
66 return node->driver_handle;
73 VkDebugReportFlagsEXT flags;
74 PFN_vkDebugReportCallbackEXT callback;
77 VkDebugReportCallbackEXT driver_handle;
80 // TODO(jessehall): replace with std::shared_mutex when available in libc++
81 mutable std::shared_timed_mutex rwmutex_;
88 #endif // LIBVULKAN_DEBUG_REPORT_H