• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _VKDEBUGREPORTUTIL_HPP
2 #define _VKDEBUGREPORTUTIL_HPP
3 /*-------------------------------------------------------------------------
4  * Vulkan CTS Framework
5  * --------------------
6  *
7  * Copyright (c) 2016 Google Inc.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief VK_EXT_debug_report utilities
24  *//*--------------------------------------------------------------------*/
25 
26 #include "vkDefs.hpp"
27 #include "vkRef.hpp"
28 #include "deAppendList.hpp"
29 
30 #include <ostream>
31 
32 namespace vk
33 {
34 
35 struct DebugReportMessage
36 {
37 	VkDebugReportFlagsEXT		flags;
38 	VkDebugReportObjectTypeEXT	objectType;
39 	deUint64					object;
40 	size_t						location;
41 	deInt32						messageCode;
42 	std::string					layerPrefix;
43 	std::string					message;
44 
DebugReportMessagevk::DebugReportMessage45 	DebugReportMessage (void)
46 		: flags			(0)
47 		, objectType	((VkDebugReportObjectTypeEXT)0)
48 		, object		(0)
49 		, location		(0)
50 		, messageCode	(0)
51 	{}
52 
DebugReportMessagevk::DebugReportMessage53 	DebugReportMessage (VkDebugReportFlagsEXT		flags_,
54 						VkDebugReportObjectTypeEXT	objectType_,
55 						deUint64					object_,
56 						size_t						location_,
57 						deInt32						messageCode_,
58 						const std::string&			layerPrefix_,
59 						const std::string&			message_)
60 		: flags			(flags_)
61 		, objectType	(objectType_)
62 		, object		(object_)
63 		, location		(location_)
64 		, messageCode	(messageCode_)
65 		, layerPrefix	(layerPrefix_)
66 		, message		(message_)
67 	{}
68 
isErrorvk::DebugReportMessage69 	bool isError		() const
70 	{
71 		static const vk::VkDebugReportFlagsEXT errorFlags = vk::VK_DEBUG_REPORT_ERROR_BIT_EXT;
72 		return ((flags & errorFlags) != 0u);
73 	}
74 
shouldBeLoggedvk::DebugReportMessage75 	bool shouldBeLogged	() const
76 	{
77 		// \note We are not logging INFORMATION and DEBUG messages
78 		static const vk::VkDebugReportFlagsEXT otherFlags	= vk::VK_DEBUG_REPORT_WARNING_BIT_EXT
79 															| vk::VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
80 		return (isError() || ((flags & otherFlags) != 0u));
81 	}
82 };
83 
84 std::ostream& operator<< (std::ostream& str, const DebugReportMessage& message);
85 
86 class DebugReportRecorder
87 {
88 public:
89 	using MessageList = de::AppendList<DebugReportMessage>;
90 
91 											DebugReportRecorder		(bool printValidationErrors);
92 											~DebugReportRecorder	(void);
93 
getMessages(void)94 	MessageList&							getMessages				(void) { return m_messages; }
clearMessages(void)95 	void									clearMessages			(void) { m_messages.clear(); }
errorPrinting(void) const96 	bool									errorPrinting			(void) const { return m_print_errors; }
97 
98 	VkDebugReportCallbackCreateInfoEXT		makeCreateInfo			(void);
99 	Move<VkDebugReportCallbackEXT>			createCallback			(const InstanceInterface& vki, VkInstance instance);
100 
101 private:
102 	MessageList								m_messages;
103 	const bool								m_print_errors;
104 };
105 
106 bool isDebugReportSupported (const PlatformInterface& vkp);
107 
108 } // vk
109 
110 #endif // _VKDEBUGREPORTUTIL_HPP
111