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 #ifndef CTS_USES_VULKANSC 36 37 struct DebugReportMessage 38 { 39 VkDebugReportFlagsEXT flags; 40 VkDebugReportObjectTypeEXT objectType; 41 deUint64 object; 42 size_t location; 43 deInt32 messageCode; 44 std::string layerPrefix; 45 std::string message; 46 DebugReportMessagevk::DebugReportMessage47 DebugReportMessage (void) 48 : flags (0) 49 , objectType ((VkDebugReportObjectTypeEXT)0) 50 , object (0) 51 , location (0) 52 , messageCode (0) 53 {} 54 DebugReportMessagevk::DebugReportMessage55 DebugReportMessage (VkDebugReportFlagsEXT flags_, 56 VkDebugReportObjectTypeEXT objectType_, 57 deUint64 object_, 58 size_t location_, 59 deInt32 messageCode_, 60 const std::string& layerPrefix_, 61 const std::string& message_) 62 : flags (flags_) 63 , objectType (objectType_) 64 , object (object_) 65 , location (location_) 66 , messageCode (messageCode_) 67 , layerPrefix (layerPrefix_) 68 , message (message_) 69 {} 70 isErrorvk::DebugReportMessage71 bool isError () const 72 { 73 static const vk::VkDebugReportFlagsEXT errorFlags = vk::VK_DEBUG_REPORT_ERROR_BIT_EXT; 74 return ((flags & errorFlags) != 0u); 75 } 76 shouldBeLoggedvk::DebugReportMessage77 bool shouldBeLogged () const 78 { 79 // \note We are not logging INFORMATION and DEBUG messages 80 static const vk::VkDebugReportFlagsEXT otherFlags = vk::VK_DEBUG_REPORT_WARNING_BIT_EXT 81 | vk::VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; 82 return (isError() || ((flags & otherFlags) != 0u)); 83 } 84 }; 85 86 std::ostream& operator<< (std::ostream& str, const DebugReportMessage& message); 87 88 class DebugReportRecorder 89 { 90 public: 91 using MessageList = de::AppendList<DebugReportMessage>; 92 93 DebugReportRecorder (bool printValidationErrors); 94 ~DebugReportRecorder (void); 95 getMessages(void)96 MessageList& getMessages (void) { return m_messages; } clearMessages(void)97 void clearMessages (void) { m_messages.clear(); } errorPrinting(void) const98 bool errorPrinting (void) const { return m_print_errors; } 99 100 VkDebugReportCallbackCreateInfoEXT makeCreateInfo (void); 101 Move<VkDebugReportCallbackEXT> createCallback (const InstanceInterface& vki, VkInstance instance); 102 103 private: 104 MessageList m_messages; 105 const bool m_print_errors; 106 }; 107 108 #endif // CTS_USES_VULKANSC 109 110 bool isDebugReportSupported (const PlatformInterface& vkp); 111 112 } // vk 113 114 #endif // _VKDEBUGREPORTUTIL_HPP 115