SpiecsEngine
 
Loading...
Searching...
No Matches
VulkanDebugUtils.cpp
Go to the documentation of this file.
1/**
2* @file VulkanDebugUtils.cpp.
3* @brief The VulkanDebugUtils Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9#include "Render/Vulkan/VulkanRenderBackend.h"
10
11namespace Spices {
12
13 void VulkanDebugUtils::BeginLabel(
14 VkCommandBuffer cmdBuffer ,
15 const std::string& caption ,
16 glm::vec4 color
17 )
18 {
20
21 /**
22 * @brief Instance a VkDebugUtilsObjectNameInfoEXT.
23 */
24 VkDebugUtilsLabelEXT labelInfo{};
25 labelInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
26 labelInfo.pLabelName = caption.c_str();
27
28 memcpy(labelInfo.color, &color[0], sizeof(float) * 4);
29
30 /**
31 * @brief Execute the function pointer.
32 */
33 VulkanRenderBackend::GetState().m_VkFunc.vkCmdBeginDebugUtilsLabelEXT(cmdBuffer, &labelInfo);
34 }
35
36 void VulkanDebugUtils::InsertLabel(
37 VkCommandBuffer cmdBuffer ,
38 const std::string& caption ,
39 glm::vec4 color
40 )
41 {
43
44 /**
45 * @brief Instance a VkDebugUtilsObjectNameInfoEXT.
46 */
47 VkDebugUtilsLabelEXT labelInfo{};
48 labelInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
49 labelInfo.pLabelName = caption.c_str();
50
51 memcpy(labelInfo.color, &color[0], sizeof(float) * 4);
52
53 /**
54 * @brief Execute the function pointer.
55 */
56 VulkanRenderBackend::GetState().m_VkFunc.vkCmdInsertDebugUtilsLabelEXT(cmdBuffer, &labelInfo);
57 }
58
59 void VulkanDebugUtils::EndLabel(VkCommandBuffer cmdBuffer)
60 {
62
63 /**
64 * @brief Execute the function pointer.
65 */
66 VulkanRenderBackend::GetState().m_VkFunc.vkCmdEndDebugUtilsLabelEXT(cmdBuffer);
67 }
68
69 void VulkanDebugUtils::BeginQueueLabel(
70 VkQueue queue ,
71 const std::string& caption ,
72 glm::vec4 color
73 )
74 {
76
77 /**
78 * @brief Instance a VkDebugUtilsObjectNameInfoEXT.
79 */
80 VkDebugUtilsLabelEXT labelInfo{};
81 labelInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
82 labelInfo.pLabelName = caption.c_str();
83
84 memcpy(labelInfo.color, &color[0], sizeof(float) * 4);
85
86 /**
87 * @brief Execute the function pointer.
88 */
89 VulkanRenderBackend::GetState().m_VkFunc.vkQueueBeginDebugUtilsLabelEXT(queue, &labelInfo);
90 }
91
92 void VulkanDebugUtils::EndQueueLabel(VkQueue queue)
93 {
95
96 /**
97 * @brief Execute the function pointer.
98 */
99 VulkanRenderBackend::GetState().m_VkFunc.vkQueueEndDebugUtilsLabelEXT(queue);
100 }
101
102 void VulkanDebugUtils::InsertQueueLabel(VkQueue queue, const std::string& caption, glm::vec4 color)
103 {
105
106 /**
107 * @brief Instance a VkDebugUtilsObjectNameInfoEXT.
108 */
109 VkDebugUtilsLabelEXT labelInfo{};
110 labelInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
111 labelInfo.pLabelName = caption.c_str();
112
113 memcpy(labelInfo.color, &color[0], sizeof(float) * 4);
114
115 /**
116 * @brief Execute the function pointer.
117 */
118 VulkanRenderBackend::GetState().m_VkFunc.vkQueueInsertDebugUtilsLabelEXT(queue, &labelInfo);
119 }
120
121 void VulkanDebugUtils::SetObjectName(
122 VkObjectType type ,
123 uint64_t handle ,
124 VkDevice& device ,
125 const std::string& caption
126 )
127 {
129
130 /**
131 * @brief Instance a VkDebugUtilsObjectNameInfoEXT.
132 */
133 VkDebugUtilsObjectNameInfoEXT name_info{};
134 name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
135 name_info.objectType = type;
136 name_info.objectHandle = handle;
137 name_info.pObjectName = caption.c_str();
138
139 /**
140 * @brief Execute the function pointer.
141 */
142 VK_CHECK(VulkanRenderBackend::GetState().m_VkFunc.vkSetDebugUtilsObjectNameEXT(device, &name_info))
143 }
144
145 void VulkanDebugUtils::SetObjectTag(
146 VkObjectType type ,
147 uint64_t handle ,
148 VkDevice& device ,
149 const std::vector<char*>& captions
150 )
151 {
153
154 /**
155 * @brief Instance a VkDebugUtilsObjectNameInfoEXT.
156 */
157 VkDebugUtilsObjectTagInfoEXT tag_info{};
158 tag_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_TAG_INFO_EXT;
159 tag_info.objectType = type;
160 tag_info.objectHandle = handle;
161 tag_info.tagName = 0;
162 tag_info.tagSize = captions.size();
163 tag_info.pTag = captions.data();
164
165 /**
166 * @brief Execute the function pointer.
167 */
168 VK_CHECK(VulkanRenderBackend::GetState().m_VkFunc.vkSetDebugUtilsObjectTagEXT(device, &tag_info))
169 }
170}
#define SPICES_PROFILE_ZONE
#define VK_CHECK(expr)
Vulkan Check macro. Verify Vulkan API Effectiveness.
Definition VulkanUtils.h:68
This Class Defines static function for helping vulkan debug.