Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame^] | 20 | #include <vulkan/vulkan.h> |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 21 | #include <shared_mutex> |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 22 | |
| 23 | namespace vulkan { |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame^] | 24 | namespace driver { |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 25 | |
| 26 | // clang-format off |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame^] | 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); |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 30 | // clang-format on |
| 31 | |
| 32 | class DebugReportCallbackList { |
| 33 | public: |
| 34 | DebugReportCallbackList() |
| 35 | : head_{nullptr, 0, nullptr, nullptr, VK_NULL_HANDLE} {} |
| 36 | DebugReportCallbackList(const DebugReportCallbackList&) = delete; |
| 37 | DebugReportCallbackList& operator=(const DebugReportCallbackList&) = delete; |
| 38 | ~DebugReportCallbackList() = default; |
| 39 | |
| 40 | VkResult CreateCallback( |
| 41 | VkInstance instance, |
| 42 | const VkDebugReportCallbackCreateInfoEXT* create_info, |
| 43 | const VkAllocationCallbacks* allocator, |
| 44 | VkDebugReportCallbackEXT* callback); |
| 45 | void DestroyCallback(VkInstance instance, |
| 46 | VkDebugReportCallbackEXT callback, |
| 47 | const VkAllocationCallbacks* allocator); |
| 48 | void Message(VkDebugReportFlagsEXT flags, |
| 49 | VkDebugReportObjectTypeEXT object_type, |
| 50 | uint64_t object, |
| 51 | size_t location, |
| 52 | int32_t message_code, |
| 53 | const char* layer_prefix, |
| 54 | const char* message); |
| 55 | |
| 56 | private: |
| 57 | struct Node { |
| 58 | Node* next; |
| 59 | VkDebugReportFlagsEXT flags; |
| 60 | PFN_vkDebugReportCallbackEXT callback; |
| 61 | void* data; |
| 62 | VkDebugReportCallbackEXT driver_callback; |
| 63 | }; |
| 64 | |
| 65 | // TODO(jessehall): replace with std::shared_mutex when available in libc++ |
| 66 | std::shared_timed_mutex rwmutex_; |
| 67 | Node head_; |
| 68 | }; |
| 69 | |
Chia-I Wu | 6226223 | 2016-03-26 07:06:44 +0800 | [diff] [blame^] | 70 | } // namespace driver |
Jesse Hall | 715b86a | 2016-01-16 16:34:29 -0800 | [diff] [blame] | 71 | } // namespace vulkan |
| 72 | |
| 73 | #endif // LIBVULKAN_DEBUG_REPORT_H |