blob: 72b1887b1cb817834e553178d7a5c308abc33e46 [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
Chia-I Wu62262232016-03-26 07:06:44 +080020#include <vulkan/vulkan.h>
Jesse Hall715b86a2016-01-16 16:34:29 -080021#include <shared_mutex>
Jesse Hall715b86a2016-01-16 16:34:29 -080022
23namespace vulkan {
Chia-I Wu62262232016-03-26 07:06:44 +080024namespace driver {
Jesse Hall715b86a2016-01-16 16:34:29 -080025
26// clang-format off
Chia-I Wu62262232016-03-26 07:06:44 +080027VKAPI_ATTR VkResult CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback);
28VKAPI_ATTR void DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator);
29VKAPI_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 Hall715b86a2016-01-16 16:34:29 -080030// clang-format on
31
32class 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 Wu62262232016-03-26 07:06:44 +080070} // namespace driver
Jesse Hall715b86a2016-01-16 16:34:29 -080071} // namespace vulkan
72
73#endif // LIBVULKAN_DEBUG_REPORT_H