st/glsl_to_nir: disable io lowering to temps for tess
[mesa.git] / src / intel / vulkan / anv_debug_report.c
1 /*
2 * Copyright © 2017 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include "anv_private.h"
25 #include "vk_util.h"
26
27 /* This file contains implementation for VK_EXT_debug_report. */
28
29 VkResult
30 anv_CreateDebugReportCallbackEXT(VkInstance _instance,
31 const VkDebugReportCallbackCreateInfoEXT* pCreateInfo,
32 const VkAllocationCallbacks* pAllocator,
33 VkDebugReportCallbackEXT* pCallback)
34 {
35 ANV_FROM_HANDLE(anv_instance, instance, _instance);
36
37 struct anv_debug_report_callback *cb =
38 vk_alloc2(&instance->alloc, pAllocator,
39 sizeof(struct anv_debug_report_callback), 8,
40 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
41
42 if (!cb)
43 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
44
45 cb->flags = pCreateInfo->flags;
46 cb->callback = pCreateInfo->pfnCallback;
47 cb->data = pCreateInfo->pUserData;
48
49 pthread_mutex_lock(&instance->callbacks_mutex);
50 list_addtail(&cb->link, &instance->callbacks);
51 pthread_mutex_unlock(&instance->callbacks_mutex);
52
53 *pCallback = anv_debug_report_callback_to_handle(cb);
54
55 return VK_SUCCESS;
56 }
57
58 void
59 anv_DestroyDebugReportCallbackEXT(VkInstance _instance,
60 VkDebugReportCallbackEXT _callback,
61 const VkAllocationCallbacks* pAllocator)
62 {
63 ANV_FROM_HANDLE(anv_instance, instance, _instance);
64 ANV_FROM_HANDLE(anv_debug_report_callback, callback, _callback);
65
66 /* Remove from list and destroy given callback. */
67 pthread_mutex_lock(&instance->callbacks_mutex);
68 list_del(&callback->link);
69 vk_free2(&instance->alloc, pAllocator, callback);
70 pthread_mutex_unlock(&instance->callbacks_mutex);
71 }
72
73 void
74 anv_DebugReportMessageEXT(VkInstance _instance,
75 VkDebugReportFlagsEXT flags,
76 VkDebugReportObjectTypeEXT objectType,
77 uint64_t object,
78 size_t location,
79 int32_t messageCode,
80 const char* pLayerPrefix,
81 const char* pMessage)
82 {
83 ANV_FROM_HANDLE(anv_instance, instance, _instance);
84 anv_debug_report(instance, flags, objectType, object,
85 location, messageCode, pLayerPrefix, pMessage);
86 }
87
88 void
89 anv_debug_report(struct anv_instance *instance,
90 VkDebugReportFlagsEXT flags,
91 VkDebugReportObjectTypeEXT object_type,
92 uint64_t handle,
93 size_t location,
94 int32_t messageCode,
95 const char* pLayerPrefix,
96 const char *pMessage)
97 {
98 /* Allow NULL for convinience, return if no callbacks registered. */
99 if (!instance || list_empty(&instance->callbacks))
100 return;
101
102 pthread_mutex_lock(&instance->callbacks_mutex);
103
104 /* Section 33.2 of the Vulkan 1.0.59 spec says:
105 *
106 * "callback is an externally synchronized object and must not be
107 * used on more than one thread at a time. This means that
108 * vkDestroyDebugReportCallbackEXT must not be called when a callback
109 * is active."
110 */
111 list_for_each_entry(struct anv_debug_report_callback, cb,
112 &instance->callbacks, link) {
113 if (cb->flags & flags)
114 cb->callback(flags, object_type, handle, location, messageCode,
115 pLayerPrefix, pMessage, cb->data);
116 }
117
118 pthread_mutex_unlock(&instance->callbacks_mutex);
119 }