1// Copyright 2018-2024 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5[[debugging-debug-utils]] 6== Debug Utilities 7 8Vulkan provides flexible debugging utilities for debugging an application. 9 10The <<debugging-object-debug-annotation,Object Debug Annotation>> section 11describes how to associate either a name or binary data with a specific 12Vulkan object. 13 14The <<debugging-queue-labels,Queue Labels>> section describes how to 15annotate and group the work submitted to a queue. 16 17The <<debugging-command-buffer-labels,Command Buffer Labels>> section 18describes how to associate logical elements of the scene with commands in a 19slink:VkCommandBuffer. 20 21The <<debugging-debug-messengers,Debug Messengers>> section describes how to 22create debug messenger objects associated with an application supplied 23callback to capture debug messages from a variety of Vulkan components. 24 25 26[[debugging-object-debug-annotation]] 27=== Object Debug Annotation 28 29It can be useful for an application to provide its own content relative to a 30specific Vulkan object. 31 32The following commands allow application developers to associate 33user-defined information with Vulkan objects. 34These commands are device-level commands but they may: reference 35instance-level objects (such as slink:VkInstance) and physical device-level 36objects (such as slink:VkPhysicalDevice) with a few restrictions: 37 * The data for the corresponding object may: still be available after the 38 slink:VkDevice used in the corresponding API call to set it is 39 destroyed, but access to this data is not guaranteed and should be 40 avoided. 41 * Subsequent calls to change the data of the same object across multiple 42 sname:VkDevice objects, may: result in the data being changed to the 43 most recent version for all sname:VkDevice objects and not just the 44 sname:VkDevice used in the most recent API call. 45 46[[debugging-object-naming]] 47==== Object Naming 48 49An object can be provided a user-defined name by calling 50fname:vkSetDebugUtilsObjectNameEXT as defined below. 51 52[open,refpage='vkSetDebugUtilsObjectNameEXT',desc='Give a user-friendly name to an object',type='protos'] 53-- 54include::{generated}/api/protos/vkSetDebugUtilsObjectNameEXT.adoc[] 55 56 * pname:device is the device that is associated with the named object 57 passed in via pname:objectHandle. 58 * pname:pNameInfo is a pointer to a slink:VkDebugUtilsObjectNameInfoEXT 59 structure specifying parameters of the name to set on the object. 60 61.Valid Usage 62**** 63 * [[VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02587]] 64 pname:pNameInfo->objectType must: not be ename:VK_OBJECT_TYPE_UNKNOWN 65 * [[VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02588]] 66 pname:pNameInfo->objectHandle must: not be dlink:VK_NULL_HANDLE 67 * [[VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-07872]] 68 If pname:pNameInfo->objectHandle is the valid handle of an 69 instance-level object, the slink:VkDevice identified by pname:device 70 must: be a descendent of the same slink:VkInstance as the object 71 identified by pname:pNameInfo->objectHandle 72 * [[VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-07873]] 73 If pname:pNameInfo->objectHandle is the valid handle of a 74 physical-device-level object, the slink:VkDevice identified by 75 pname:device must: be a descendant of the same slink:VkPhysicalDevice as 76 the object identified by pname:pNameInfo->objectHandle 77 * [[VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-07874]] 78 If pname:pNameInfo->objectHandle is the valid handle of a device-level 79 object, that object must: be a descendent of the slink:VkDevice 80 identified by pname:device 81**** 82 83include::{generated}/validity/protos/vkSetDebugUtilsObjectNameEXT.adoc[] 84-- 85 86[open,refpage='VkDebugUtilsObjectNameInfoEXT',desc='Specify parameters of a name to give to an object',type='structs'] 87-- 88The sname:VkDebugUtilsObjectNameInfoEXT structure is defined as: 89 90include::{generated}/api/structs/VkDebugUtilsObjectNameInfoEXT.adoc[] 91 92 * pname:sType is a elink:VkStructureType value identifying this structure. 93 * pname:pNext is `NULL` or a pointer to a structure extending this 94 structure. 95 * pname:objectType is a elink:VkObjectType specifying the type of the 96 object to be named. 97 * pname:objectHandle is the object to be named. 98 * pname:pObjectName is either `NULL` or a null-terminated UTF-8 string 99 specifying the name to apply to pname:objectHandle. 100 101Applications may: change the name associated with an object simply by 102calling fname:vkSetDebugUtilsObjectNameEXT again with a new string. 103If pname:pObjectName is either `NULL` or an empty string, then any 104previously set name is removed. 105 106ifdef::VK_EXT_graphics_pipeline_library[] 107The <<features-graphicsPipelineLibrary, pname:graphicsPipelineLibrary>> 108feature allows the specification of pipelines without the creation of 109slink:VkShaderModule objects beforehand. 110In order to continue to allow naming these shaders independently, 111sname:VkDebugUtilsObjectNameInfoEXT can: be included in the pname:pNext 112chain of slink:VkPipelineShaderStageCreateInfo, which associates a static 113name with that particular shader. 114endif::VK_EXT_graphics_pipeline_library[] 115 116.Valid Usage 117**** 118 * [[VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589]] 119 If pname:objectType is ename:VK_OBJECT_TYPE_UNKNOWN, pname:objectHandle 120 must: not be dlink:VK_NULL_HANDLE 121 * [[VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02590]] 122 If pname:objectType is not ename:VK_OBJECT_TYPE_UNKNOWN, 123 pname:objectHandle must: be dlink:VK_NULL_HANDLE or a valid Vulkan 124 handle of the type associated with pname:objectType as defined in the 125 <<debugging-object-types, `VkObjectType` and Vulkan Handle 126 Relationship>> table 127**** 128 129include::{generated}/validity/structs/VkDebugUtilsObjectNameInfoEXT.adoc[] 130-- 131 132 133[[debugging-object-data-association]] 134==== Object Data Association 135 136In addition to setting a name for an object, debugging and validation layers 137may: have uses for additional binary data on a per-object basis that have no 138other place in the Vulkan API. 139 140For example, a sname:VkShaderModule could have additional debugging data 141attached to it to aid in offline shader tracing. 142 143Additional data can be attached to an object by calling 144fname:vkSetDebugUtilsObjectTagEXT as defined below. 145 146[open,refpage='vkSetDebugUtilsObjectTagEXT',desc='Attach arbitrary data to an object',type='protos'] 147-- 148include::{generated}/api/protos/vkSetDebugUtilsObjectTagEXT.adoc[] 149 150 * pname:device is the device that created the object. 151 * pname:pTagInfo is a pointer to a slink:VkDebugUtilsObjectTagInfoEXT 152 structure specifying parameters of the tag to attach to the object. 153 154.Valid Usage 155**** 156 * [[VUID-vkSetDebugUtilsObjectTagEXT-pNameInfo-07875]] 157 If pname:pNameInfo->objectHandle is the valid handle of an 158 instance-level object, the slink:VkDevice identified by pname:device 159 must: be a descendent of the same slink:VkInstance as the object 160 identified by pname:pNameInfo->objectHandle 161 * [[VUID-vkSetDebugUtilsObjectTagEXT-pNameInfo-07876]] 162 If pname:pNameInfo->objectHandle is the valid handle of a 163 physical-device-level object, the slink:VkDevice identified by 164 pname:device must: be a descendant of the same slink:VkPhysicalDevice as 165 the object identified by pname:pNameInfo->objectHandle 166 * [[VUID-vkSetDebugUtilsObjectTagEXT-pNameInfo-07877]] 167 If pname:pNameInfo->objectHandle is the valid handle of a device-level 168 object, that object must: be a descendent of the slink:VkDevice 169 identified by pname:device 170**** 171 172include::{generated}/validity/protos/vkSetDebugUtilsObjectTagEXT.adoc[] 173-- 174 175[open,refpage='VkDebugUtilsObjectTagInfoEXT',desc='Specify parameters of a tag to attach to an object',type='structs'] 176-- 177The sname:VkDebugUtilsObjectTagInfoEXT structure is defined as: 178 179include::{generated}/api/structs/VkDebugUtilsObjectTagInfoEXT.adoc[] 180 181 * pname:sType is a elink:VkStructureType value identifying this structure. 182 * pname:pNext is `NULL` or a pointer to a structure extending this 183 structure. 184 * pname:objectType is a elink:VkObjectType specifying the type of the 185 object to be named. 186 * pname:objectHandle is the object to be tagged. 187 * pname:tagName is a numerical identifier of the tag. 188 * pname:tagSize is the number of bytes of data to attach to the object. 189 * pname:pTag is a pointer to an array of pname:tagSize bytes containing 190 the data to be associated with the object. 191 192The pname:tagName parameter gives a name or identifier to the type of data 193being tagged. 194This can be used by debugging layers to easily filter for only data that can 195be used by that implementation. 196 197.Valid Usage 198**** 199 * [[VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908]] 200 pname:objectType must: not be ename:VK_OBJECT_TYPE_UNKNOWN 201 * [[VUID-VkDebugUtilsObjectTagInfoEXT-objectHandle-01910]] 202 pname:objectHandle must: be a valid Vulkan handle of the type associated 203 with pname:objectType as defined in the <<debugging-object-types, 204 `VkObjectType` and Vulkan Handle Relationship>> table 205**** 206 207include::{generated}/validity/structs/VkDebugUtilsObjectTagInfoEXT.adoc[] 208-- 209 210 211[[debugging-queue-labels]] 212=== Queue Labels 213 214All Vulkan work must be submitted using queues. 215It is possible for an application to use multiple queues, each containing 216multiple command buffers, when performing work. 217It can be useful to identify which queue, or even where in a queue, 218something has occurred. 219 220To begin identifying a region using a debug label inside a queue, you may 221use the flink:vkQueueBeginDebugUtilsLabelEXT command. 222 223Then, when the region of interest has passed, you may end the label region 224using flink:vkQueueEndDebugUtilsLabelEXT. 225 226Additionally, a single debug label may be inserted at any time using 227flink:vkQueueInsertDebugUtilsLabelEXT. 228 229[open,refpage='vkQueueBeginDebugUtilsLabelEXT',desc='Open a queue debug label region',type='protos'] 230-- 231A queue debug label region is opened by calling: 232 233include::{generated}/api/protos/vkQueueBeginDebugUtilsLabelEXT.adoc[] 234 235 * pname:queue is the queue in which to start a debug label region. 236 * pname:pLabelInfo is a pointer to a slink:VkDebugUtilsLabelEXT structure 237 specifying parameters of the label region to open. 238 239include::{generated}/validity/protos/vkQueueBeginDebugUtilsLabelEXT.adoc[] 240-- 241 242[open,refpage='VkDebugUtilsLabelEXT',desc='Specify parameters of a label region',type='structs'] 243-- 244The sname:VkDebugUtilsLabelEXT structure is defined as: 245 246include::{generated}/api/structs/VkDebugUtilsLabelEXT.adoc[] 247 248 * pname:sType is a elink:VkStructureType value identifying this structure. 249 * pname:pNext is `NULL` or a pointer to a structure extending this 250 structure. 251 * pname:pLabelName is a pointer to a null-terminated UTF-8 string 252 containing the name of the label. 253 * pname:color is an optional RGBA color value that can be associated with 254 the label. 255 A particular implementation may: choose to ignore this color value. 256 The values contain RGBA values in order, in the range 0.0 to 1.0. 257 If all elements in pname:color are set to 0.0 then it is ignored. 258 259include::{generated}/validity/structs/VkDebugUtilsLabelEXT.adoc[] 260-- 261 262[open,refpage='vkQueueEndDebugUtilsLabelEXT',desc='Close a queue debug label region',type='protos'] 263-- 264A queue debug label region is closed by calling: 265 266include::{generated}/api/protos/vkQueueEndDebugUtilsLabelEXT.adoc[] 267 268 * pname:queue is the queue in which a debug label region should be closed. 269 270The calls to flink:vkQueueBeginDebugUtilsLabelEXT and 271flink:vkQueueEndDebugUtilsLabelEXT must: be matched and balanced. 272 273.Valid Usage 274**** 275 * [[VUID-vkQueueEndDebugUtilsLabelEXT-None-01911]] 276 There must: be an outstanding fname:vkQueueBeginDebugUtilsLabelEXT 277 command prior to the fname:vkQueueEndDebugUtilsLabelEXT on the queue 278**** 279 280include::{generated}/validity/protos/vkQueueEndDebugUtilsLabelEXT.adoc[] 281-- 282 283[open,refpage='vkQueueInsertDebugUtilsLabelEXT',desc='Insert a label into a queue',type='protos'] 284-- 285A single label can be inserted into a queue by calling: 286 287include::{generated}/api/protos/vkQueueInsertDebugUtilsLabelEXT.adoc[] 288 289 * pname:queue is the queue into which a debug label will be inserted. 290 * pname:pLabelInfo is a pointer to a slink:VkDebugUtilsLabelEXT structure 291 specifying parameters of the label to insert. 292 293include::{generated}/validity/protos/vkQueueInsertDebugUtilsLabelEXT.adoc[] 294-- 295 296 297[[debugging-command-buffer-labels]] 298=== Command Buffer Labels 299 300Typical Vulkan applications will submit many command buffers in each frame, 301with each command buffer containing a large number of individual commands. 302Being able to logically annotate regions of command buffers that belong 303together as well as hierarchically subdivide the frame is important to a 304developer's ability to navigate the commands viewed holistically. 305 306To identify the beginning of a debug label region in a command buffer, 307flink:vkCmdBeginDebugUtilsLabelEXT can: be used as defined below. 308 309To indicate the end of a debug label region in a command buffer, 310flink:vkCmdEndDebugUtilsLabelEXT can: be used. 311 312To insert a single command buffer debug label inside of a command buffer, 313flink:vkCmdInsertDebugUtilsLabelEXT can: be used as defined below. 314 315[open,refpage='vkCmdBeginDebugUtilsLabelEXT',desc='Open a command buffer debug label region',type='protos'] 316-- 317A command buffer debug label region can be opened by calling: 318 319include::{generated}/api/protos/vkCmdBeginDebugUtilsLabelEXT.adoc[] 320 321 * pname:commandBuffer is the command buffer into which the command is 322 recorded. 323 * pname:pLabelInfo is a pointer to a slink:VkDebugUtilsLabelEXT structure 324 specifying parameters of the label region to open. 325 326include::{generated}/validity/protos/vkCmdBeginDebugUtilsLabelEXT.adoc[] 327-- 328 329[open,refpage='vkCmdEndDebugUtilsLabelEXT',desc='Close a command buffer label region',type='protos'] 330-- 331A command buffer label region can be closed by calling: 332 333include::{generated}/api/protos/vkCmdEndDebugUtilsLabelEXT.adoc[] 334 335 * pname:commandBuffer is the command buffer into which the command is 336 recorded. 337 338An application may: open a debug label region in one command buffer and 339close it in another, or otherwise split debug label regions across multiple 340command buffers or multiple queue submissions. 341When viewed from the linear series of submissions to a single queue, the 342calls to flink:vkCmdBeginDebugUtilsLabelEXT and 343flink:vkCmdEndDebugUtilsLabelEXT must: be matched and balanced. 344 345There can: be problems reporting command buffer debug labels during the 346recording process because command buffers may: be recorded out of sequence 347with the resulting execution order. 348Since the recording order may: be different, a solitary command buffer may: 349have an inconsistent view of the debug label regions by itself. 350Therefore, if an issue occurs during the recording of a command buffer, and 351the environment requires returning debug labels, the implementation may: 352return only those labels it is aware of. 353This is true even if the implementation is aware of only the debug labels 354within the command buffer being actively recorded. 355 356 357.Valid Usage 358**** 359 * [[VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912]] 360 There must: be an outstanding fname:vkCmdBeginDebugUtilsLabelEXT command 361 prior to the fname:vkCmdEndDebugUtilsLabelEXT on the queue that 362 pname:commandBuffer is submitted to 363 * [[VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01913]] 364 If pname:commandBuffer is a secondary command buffer, there must: be an 365 outstanding fname:vkCmdBeginDebugUtilsLabelEXT command recorded to 366 pname:commandBuffer that has not previously been ended by a call to 367 fname:vkCmdEndDebugUtilsLabelEXT 368**** 369 370include::{generated}/validity/protos/vkCmdEndDebugUtilsLabelEXT.adoc[] 371-- 372 373[open,refpage='vkCmdInsertDebugUtilsLabelEXT',desc='Insert a label into a command buffer',type='protos'] 374-- 375A single debug label can be inserted into a command buffer by calling: 376 377include::{generated}/api/protos/vkCmdInsertDebugUtilsLabelEXT.adoc[] 378 379 * pname:commandBuffer is the command buffer into which the command is 380 recorded. 381 * pname:pInfo is a pointer to a slink:VkDebugUtilsLabelEXT structure 382 specifying parameters of the label to insert. 383 384include::{generated}/validity/protos/vkCmdInsertDebugUtilsLabelEXT.adoc[] 385-- 386 387 388[[debugging-debug-messengers]] 389=== Debug Messengers 390 391Vulkan allows an application to register multiple callbacks with any Vulkan 392component wishing to report debug information. 393Some callbacks may log the information to a file, others may cause a debug 394break point or other application defined behavior. 395A primary producer of callback messages are the validation layers. 396An application can: register callbacks even when no validation layers are 397enabled, but they will only be called for the Vulkan loader and, if 398implemented, other layer and driver events. 399 400[open,refpage='VkDebugUtilsMessengerEXT',desc='Opaque handle to a debug messenger object',type='handles'] 401-- 402A sname:VkDebugUtilsMessengerEXT is a messenger object which handles passing 403along debug messages to a provided debug callback. 404 405include::{generated}/api/handles/VkDebugUtilsMessengerEXT.adoc[] 406 407The debug messenger will provide detailed feedback on the application's use 408of Vulkan when events of interest occur. 409When an event of interest does occur, the debug messenger will submit a 410debug message to the debug callback that was provided during its creation. 411Additionally, the debug messenger is responsible with filtering out debug 412messages that the callback is not interested in and will only provide 413desired debug messages. 414-- 415 416[open,refpage='vkCreateDebugUtilsMessengerEXT',desc='Create a debug messenger object',type='protos'] 417-- 418A debug messenger triggers a debug callback with a debug message when an 419event of interest occurs. 420To create a debug messenger which will trigger a debug callback, call: 421 422include::{generated}/api/protos/vkCreateDebugUtilsMessengerEXT.adoc[] 423 424 * pname:instance is the instance the messenger will be used with. 425 * pname:pCreateInfo is a pointer to a 426 slink:VkDebugUtilsMessengerCreateInfoEXT structure containing the 427 callback pointer, as well as defining conditions under which this 428 messenger will trigger the callback. 429 * pname:pAllocator controls host memory allocation as described in the 430 <<memory-allocation, Memory Allocation>> chapter. 431 * pname:pMessenger is a pointer to a slink:VkDebugUtilsMessengerEXT handle 432 in which the created object is returned. 433 434include::{generated}/validity/protos/vkCreateDebugUtilsMessengerEXT.adoc[] 435 436The application must: ensure that flink:vkCreateDebugUtilsMessengerEXT is 437not executed in parallel with any Vulkan command that is also called with 438pname:instance or child of pname:instance as the dispatchable argument. 439-- 440 441[open,refpage='VkDebugUtilsMessengerCreateInfoEXT',desc='Structure specifying parameters of a newly created debug messenger',type='structs'] 442-- 443The definition of sname:VkDebugUtilsMessengerCreateInfoEXT is: 444 445include::{generated}/api/structs/VkDebugUtilsMessengerCreateInfoEXT.adoc[] 446 447 * pname:sType is a elink:VkStructureType value identifying this structure. 448 * pname:pNext is `NULL` or a pointer to a structure extending this 449 structure. 450 * pname:flags is `0` and is reserved for future use. 451 * pname:messageSeverity is a bitmask of 452 elink:VkDebugUtilsMessageSeverityFlagBitsEXT specifying which severity 453 of event(s) will cause this callback to be called. 454 * pname:messageType is a bitmask of 455 elink:VkDebugUtilsMessageTypeFlagBitsEXT specifying which type of 456 event(s) will cause this callback to be called. 457 * pname:pfnUserCallback is the application callback function to call. 458 * pname:pUserData is user data to be passed to the callback. 459 460For each sname:VkDebugUtilsMessengerEXT that is created the 461sname:VkDebugUtilsMessengerCreateInfoEXT::pname:messageSeverity and 462sname:VkDebugUtilsMessengerCreateInfoEXT::pname:messageType determine when 463that sname:VkDebugUtilsMessengerCreateInfoEXT::pname:pfnUserCallback is 464called. 465The process to determine if the user's pname:pfnUserCallback is triggered 466when an event occurs is as follows: 467 468 . The implementation will perform a bitwise AND of the event's 469 elink:VkDebugUtilsMessageSeverityFlagBitsEXT with the 470 pname:messageSeverity provided during creation of the 471 slink:VkDebugUtilsMessengerEXT object. 472 .. If the value is 0, the message is skipped. 473 . The implementation will perform bitwise AND of the event's 474 elink:VkDebugUtilsMessageTypeFlagBitsEXT with the pname:messageType 475 provided during the creation of the slink:VkDebugUtilsMessengerEXT 476 object. 477 .. If the value is 0, the message is skipped. 478 . The callback will trigger a debug message for the current event 479 480The callback will come directly from the component that detected the event, 481unless some other layer intercepts the calls for its own purposes (filter 482them in a different way, log to a system error log, etc.). 483 484An application can: receive multiple callbacks if multiple 485sname:VkDebugUtilsMessengerEXT objects are created. 486A callback will always be executed in the same thread as the originating 487Vulkan call. 488 489A callback can: be called from multiple threads simultaneously (if the 490application is making Vulkan calls from multiple threads). 491 492.Valid Usage 493**** 494 * [[VUID-VkDebugUtilsMessengerCreateInfoEXT-pfnUserCallback-01914]] 495 pname:pfnUserCallback must: be a valid 496 tlink:PFN_vkDebugUtilsMessengerCallbackEXT 497**** 498 499include::{generated}/validity/structs/VkDebugUtilsMessengerCreateInfoEXT.adoc[] 500-- 501 502[open,refpage='VkDebugUtilsMessengerCreateFlagsEXT',desc='Reserved for future use',type='flags'] 503-- 504include::{generated}/api/flags/VkDebugUtilsMessengerCreateFlagsEXT.adoc[] 505 506tname:VkDebugUtilsMessengerCreateFlagsEXT is a bitmask type for setting a 507mask, but is currently reserved for future use. 508-- 509 510[open,refpage='VkDebugUtilsMessageSeverityFlagBitsEXT',desc='Bitmask specifying which severities of events cause a debug messenger callback',type='enums'] 511-- 512Bits which can: be set in 513slink:VkDebugUtilsMessengerCreateInfoEXT::pname:messageSeverity, specifying 514event severities which cause a debug messenger to call the callback, are: 515 516include::{generated}/api/enums/VkDebugUtilsMessageSeverityFlagBitsEXT.adoc[] 517 518 * ename:VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT specifies the most 519 verbose output indicating all diagnostic messages from the Vulkan 520 loader, layers, and drivers should be captured. 521 * ename:VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT specifies an 522 informational message such as resource details that may be handy when 523 debugging an application. 524 * ename:VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT specifies use of 525 Vulkan that may: expose an app bug. 526 Such cases may not be immediately harmful, such as a fragment shader 527 outputting to a location with no attachment. 528 Other cases may: point to behavior that is almost certainly bad when 529 unintended such as using an image whose memory has not been filled. 530 In general if you see a warning but you know that the behavior is 531 intended/desired, then simply ignore the warning. 532 * ename:VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT specifies that the 533 application has violated a valid usage condition of the specification. 534 535[NOTE] 536.Note 537==== 538The values of elink:VkDebugUtilsMessageSeverityFlagBitsEXT are sorted based 539on severity. 540The higher the flag value, the more severe the message. 541This allows for simple boolean operation comparisons when looking at 542elink:VkDebugUtilsMessageSeverityFlagBitsEXT values. 543 544For example: 545 546[source,c++] 547---- 548 if (messageSeverity >= VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { 549 // Do something for warnings and errors 550 } 551---- 552 553In addition, space has been left between the enums to allow for later 554addition of new severities in between the existing values. 555==== 556-- 557 558[open,refpage='VkDebugUtilsMessageSeverityFlagsEXT',desc='Bitmask of VkDebugUtilsMessageSeverityFlagBitsEXT',type='flags'] 559-- 560include::{generated}/api/flags/VkDebugUtilsMessageSeverityFlagsEXT.adoc[] 561 562tname:VkDebugUtilsMessageSeverityFlagsEXT is a bitmask type for setting a 563mask of zero or more elink:VkDebugUtilsMessageSeverityFlagBitsEXT. 564-- 565 566[open,refpage='VkDebugUtilsMessageTypeFlagBitsEXT',desc='Bitmask specifying which types of events cause a debug messenger callback',type='enums'] 567-- 568Bits which can: be set in 569slink:VkDebugUtilsMessengerCreateInfoEXT::pname:messageType, specifying 570event types which cause a debug messenger to call the callback, are: 571 572include::{generated}/api/enums/VkDebugUtilsMessageTypeFlagBitsEXT.adoc[] 573 574 * ename:VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT specifies that some 575 general event has occurred. 576 This is typically a non-specification, non-performance event. 577 * ename:VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT specifies that 578 something has occurred during validation against the Vulkan 579 specification that may indicate invalid behavior. 580 * ename:VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT specifies a 581 potentially non-optimal use of Vulkan, e.g. using 582 flink:vkCmdClearColorImage when setting 583 slink:VkAttachmentDescription::pname:loadOp to 584 ename:VK_ATTACHMENT_LOAD_OP_CLEAR would have worked. 585ifdef::VK_EXT_device_address_binding_report[] 586 * ename:VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT 587 specifies that the implementation has modified the set of GPU-visible 588 virtual addresses associated with a Vulkan object. 589endif::VK_EXT_device_address_binding_report[] 590-- 591 592[open,refpage='VkDebugUtilsMessageTypeFlagsEXT',desc='Bitmask of VkDebugUtilsMessageTypeFlagBitsEXT',type='flags'] 593-- 594include::{generated}/api/flags/VkDebugUtilsMessageTypeFlagsEXT.adoc[] 595 596tname:VkDebugUtilsMessageTypeFlagsEXT is a bitmask type for setting a mask 597of zero or more elink:VkDebugUtilsMessageTypeFlagBitsEXT. 598-- 599 600[open,refpage='PFN_vkDebugUtilsMessengerCallbackEXT',desc='Application-defined debug messenger callback function',type='funcpointers'] 601-- 602The prototype for the 603slink:VkDebugUtilsMessengerCreateInfoEXT::pname:pfnUserCallback function 604implemented by the application is: 605 606include::{generated}/api/funcpointers/PFN_vkDebugUtilsMessengerCallbackEXT.adoc[] 607 608 * pname:messageSeverity specifies the 609 elink:VkDebugUtilsMessageSeverityFlagBitsEXT that triggered this 610 callback. 611 * pname:messageTypes is a bitmask of 612 elink:VkDebugUtilsMessageTypeFlagBitsEXT specifying which type of 613 event(s) triggered this callback. 614 * pname:pCallbackData contains all the callback related data in the 615 slink:VkDebugUtilsMessengerCallbackDataEXT structure. 616 * pname:pUserData is the user data provided when the 617 slink:VkDebugUtilsMessengerEXT was created. 618 619The callback returns a basetype:VkBool32, which is interpreted in a 620layer-specified manner. 621The application should: always return ename:VK_FALSE. 622The ename:VK_TRUE value is reserved for use in layer development. 623 624.Valid Usage 625**** 626 * [[VUID-PFN_vkDebugUtilsMessengerCallbackEXT-None-04769]] 627 The callback must: not make calls to any Vulkan commands 628**** 629-- 630 631[open,refpage='VkDebugUtilsMessengerCallbackDataEXT',desc='Structure specifying parameters returned to the callback',type='structs'] 632-- 633The definition of sname:VkDebugUtilsMessengerCallbackDataEXT is: 634 635include::{generated}/api/structs/VkDebugUtilsMessengerCallbackDataEXT.adoc[] 636 637 * pname:sType is a elink:VkStructureType value identifying this structure. 638 * pname:pNext is `NULL` or a pointer to a structure extending this 639 structure. 640 * pname:flags is `0` and is reserved for future use. 641 * pname:pMessageIdName is a null-terminated string that identifies the 642 particular message ID that is associated with the provided message. 643 If the message corresponds to a validation layer message, then this 644 string may contain the portion of the Vulkan specification that is 645 believed to have been violated. 646 * pname:messageIdNumber is the ID number of the triggering message. 647 If the message corresponds to a validation layer message, then this 648 number is related to the internal number associated with the message 649 being triggered. 650 * pname:pMessage is a null-terminated string detailing the trigger 651 conditions. 652 * pname:queueLabelCount is a count of items contained in the 653 pname:pQueueLabels array. 654 * pname:pQueueLabels is `NULL` or a pointer to an array of 655 slink:VkDebugUtilsLabelEXT active in the current sname:VkQueue at the 656 time the callback was triggered. 657 Refer to <<debugging-queue-labels,Queue Labels>> for more information. 658 * pname:cmdBufLabelCount is a count of items contained in the 659 pname:pCmdBufLabels array. 660 * pname:pCmdBufLabels is `NULL` or a pointer to an array of 661 slink:VkDebugUtilsLabelEXT active in the current sname:VkCommandBuffer 662 at the time the callback was triggered. 663 Refer to <<debugging-command-buffer-labels, Command Buffer Labels>> for 664 more information. 665 * pname:objectCount is a count of items contained in the pname:pObjects 666 array. 667 * pname:pObjects is a pointer to an array of 668 slink:VkDebugUtilsObjectNameInfoEXT objects related to the detected 669 issue. 670 The array is roughly in order or importance, but the 0th element is 671 always guaranteed to be the most important object for this message. 672 673[NOTE] 674.Note 675==== 676This structure should only be considered valid during the lifetime of the 677triggered callback. 678==== 679 680Since adding queue and command buffer labels behaves like pushing and 681popping onto a stack, the order of both pname:pQueueLabels and 682pname:pCmdBufLabels is based on the order the labels were defined. 683The result is that the first label in either pname:pQueueLabels or 684pname:pCmdBufLabels will be the first defined (and therefore the oldest) 685while the last label in each list will be the most recent. 686 687[NOTE] 688.Note 689==== 690pname:pQueueLabels will only be non-`NULL` if one of the objects in 691pname:pObjects can be related directly to a defined sname:VkQueue which has 692had one or more labels associated with it. 693 694Likewise, pname:pCmdBufLabels will only be non-`NULL` if one of the objects 695in pname:pObjects can be related directly to a defined sname:VkCommandBuffer 696which has had one or more labels associated with it. 697Additionally, while command buffer labels allow for beginning and ending 698across different command buffers, the debug messaging framework cannot: 699guarantee that labels in pname:pCmdBufLables will contain those defined 700outside of the associated command buffer. 701This is partially due to the fact that the association of one command buffer 702with another may not have been defined at the time the debug message is 703triggered. 704==== 705 706include::{generated}/validity/structs/VkDebugUtilsMessengerCallbackDataEXT.adoc[] 707-- 708 709[open,refpage='VkDebugUtilsMessengerCallbackDataFlagsEXT',desc='Reserved for future use',type='flags'] 710-- 711include::{generated}/api/flags/VkDebugUtilsMessengerCallbackDataFlagsEXT.adoc[] 712 713tname:VkDebugUtilsMessengerCallbackDataFlagsEXT is a bitmask type for 714setting a mask, but is currently reserved for future use. 715-- 716 717ifdef::VK_EXT_device_address_binding_report[] 718[open,refpage='VkDeviceAddressBindingCallbackDataEXT',desc='Structure specifying parameters returned to the callback',type='structs'] 719-- 720The definition of sname:VkDeviceAddressBindingCallbackDataEXT is: 721 722include::{generated}/api/structs/VkDeviceAddressBindingCallbackDataEXT.adoc[] 723 724 * pname:sType is a elink:VkStructureType value identifying this structure. 725 * pname:pNext is `NULL` or a pointer to a structure extending this 726 structure. 727 * pname:flags is a bitmask of elink:VkDeviceAddressBindingFlagBitsEXT 728 specifying additional information about the binding event that caused 729 the callback to be called. 730 * pname:baseAddress is a GPU-accessible virtual address identifying the 731 start of a region of the virtual address space associated with a Vulkan 732 object, as identified by the pname:pObjects member of 733 slink:VkDebugUtilsMessengerCallbackDataEXT. 734 * pname:size is the size in bytes of a region of GPU-accessible virtual 735 address space. 736 * pname:bindingType is a elink:VkDeviceAddressBindingTypeEXT specifying 737 the type of binding event that caused the callback to be called. 738 739If the <<features-reportAddressBinding, pname:reportAddressBinding>> feature 740is enabled and the implementation binds or unbinds a region of virtual 741address space associated with a Vulkan object, the implementation must: 742submit a debug message with the following properties: 743 744 * pname:messageSeverity equal to 745 ename:VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT 746 * pname:messageType equal to 747 ename:VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT 748 * sname:VkDebugUtilsMessengerCallbackDataEXT::pname:pObjects must: 749 identify the associated Vulkan object 750 * sname:VkDeviceAddressBindingCallbackDataEXT must: be included in the 751 pname:pNext chain of sname:VkDebugUtilsMessengerCallbackDataEXT 752 753These debug messages must: be emitted both for GPU virtual address space 754regions that are explicitly bound to a Vulkan object via the 755sname:vkBind*Memory/sname:vkBind*Memory2 functions, and for those that are 756implicitly generated via memory allocation or importing external memory. 757 758An implementation may: report binding events associated with a Vulkan object 759via sname:VkDebugUtilsMessengerEXT prior to the object becoming visible to 760an application via other Vulkan commands. 761For example, object creation functions may: report binding events that occur 762during an objects creation. 763In such cases, sname:VkDeviceAddressBindingCallbackDataEXT::pname:flags 764must: include ename:VK_DEVICE_ADDRESS_BINDING_INTERNAL_OBJECT_BIT_EXT. 765 766Object handles reported in this manner are not 767<<fundamentals-validusage-handles, valid object handles>>, and must: not be 768used as an input parameter to any Vulkan command. 769 770Any valid object handle returned by an object creation function must: match 771the handle specified via any previously reported binding events associated 772with the object's creation. 773 774include::{generated}/validity/structs/VkDeviceAddressBindingCallbackDataEXT.adoc[] 775-- 776 777[open,refpage='VkDeviceAddressBindingFlagBitsEXT',desc='Bitmask specifying the additional information about a binding event',type='enums'] 778-- 779Bits which can: be set in 780slink:VkDeviceAddressBindingCallbackDataEXT::pname:flags specifying 781additional information about a binding event are: 782 783include::{generated}/api/enums/VkDeviceAddressBindingFlagBitsEXT.adoc[] 784 785 * ename:VK_DEVICE_ADDRESS_BINDING_INTERNAL_OBJECT_BIT_EXT specifies that 786 slink:VkDeviceAddressBindingCallbackDataEXT describes a Vulkan object 787 that has not been made visible to the application via a Vulkan command. 788-- 789 790[open,refpage='VkDeviceAddressBindingFlagsEXT',desc='Bitmask of VkDeviceAddressBindingFlagBitsEXT',type='flags'] 791-- 792include::{generated}/api/flags/VkDeviceAddressBindingFlagsEXT.adoc[] 793 794tlink:VkDeviceAddressBindingFlagsEXT is a bitmask type for setting a mask of 795zero or more elink:VkDeviceAddressBindingFlagBitsEXT. 796-- 797 798[open,refpage='VkDeviceAddressBindingTypeEXT',desc='Enum describing a change in device address bindings',type='enums'] 799-- 800The ename:VkDeviceAddressBindingTypeEXT enum is defined as: 801 802include::{generated}/api/enums/VkDeviceAddressBindingTypeEXT.adoc[] 803 804 * ename:VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT specifies that a new 805 GPU-accessible virtual address range has been bound. 806 * ename:VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT specifies that a 807 GPU-accessible virtual address range has been unbound. 808 809-- 810endif::VK_EXT_device_address_binding_report[] 811 812[open,refpage='vkSubmitDebugUtilsMessageEXT',desc='Inject a message into a debug stream',type='protos'] 813-- 814There may be times that a user wishes to intentionally submit a debug 815message. 816To do this, call: 817 818include::{generated}/api/protos/vkSubmitDebugUtilsMessageEXT.adoc[] 819 820 * pname:instance is the debug stream's slink:VkInstance. 821 * pname:messageSeverity is a elink:VkDebugUtilsMessageSeverityFlagBitsEXT 822 value specifying the severity of this event/message. 823 * pname:messageTypes is a bitmask of 824 elink:VkDebugUtilsMessageTypeFlagBitsEXT specifying which type of 825 event(s) to identify with this message. 826 * pname:pCallbackData contains all the callback related data in the 827 slink:VkDebugUtilsMessengerCallbackDataEXT structure. 828 829The call will propagate through the layers and generate callback(s) as 830indicated by the message's flags. 831The parameters are passed on to the callback in addition to the 832pname:pUserData value that was defined at the time the messenger was 833registered. 834 835.Valid Usage 836**** 837 * [[VUID-vkSubmitDebugUtilsMessageEXT-objectType-02591]] 838 The pname:objectType member of each element of 839 pname:pCallbackData->pObjects must: not be ename:VK_OBJECT_TYPE_UNKNOWN 840**** 841 842include::{generated}/validity/protos/vkSubmitDebugUtilsMessageEXT.adoc[] 843-- 844 845[open,refpage='vkDestroyDebugUtilsMessengerEXT',desc='Destroy a debug messenger object',type='protos'] 846-- 847To destroy a sname:VkDebugUtilsMessengerEXT object, call: 848 849include::{generated}/api/protos/vkDestroyDebugUtilsMessengerEXT.adoc[] 850 851 * pname:instance is the instance where the callback was created. 852 * pname:messenger is the slink:VkDebugUtilsMessengerEXT object to destroy. 853 pname:messenger is an externally synchronized object and must: not be 854 used on more than one thread at a time. 855 This means that fname:vkDestroyDebugUtilsMessengerEXT must: not be 856 called when a callback is active. 857 * pname:pAllocator controls host memory allocation as described in the 858 <<memory-allocation, Memory Allocation>> chapter. 859 860ifndef::VKSC_VERSION_1_0[] 861.Valid Usage 862**** 863 * [[VUID-vkDestroyDebugUtilsMessengerEXT-messenger-01915]] 864 If sname:VkAllocationCallbacks were provided when pname:messenger was 865 created, a compatible set of callbacks must: be provided here 866 * [[VUID-vkDestroyDebugUtilsMessengerEXT-messenger-01916]] 867 If no sname:VkAllocationCallbacks were provided when pname:messenger was 868 created, pname:pAllocator must: be `NULL` 869**** 870endif::VKSC_VERSION_1_0[] 871 872include::{generated}/validity/protos/vkDestroyDebugUtilsMessengerEXT.adoc[] 873 874The application must: ensure that flink:vkDestroyDebugUtilsMessengerEXT is 875not executed in parallel with any Vulkan command that is also called with 876pname:instance or child of pname:instance as the dispatchable argument. 877-- 878 879