You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapters/validation_overview.adoc
+25-57Lines changed: 25 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
// Copyright 2019-2022 The Khronos Group, Inc.
1
+
// Copyright 2019-2025 The Khronos Group, Inc.
2
2
// SPDX-License-Identifier: CC-BY-4.0
3
3
4
4
// Required for both single-page and combined guide xrefs to work
@@ -32,12 +32,35 @@ When an application supplies invalid input, according to the valid usages in the
32
32
33
33
**VERY IMPORTANT**: While undefined behavior might seem to work on one implementation, there is a good chance it will fail on another.
34
34
35
+
=== Undefined Value
36
+
37
+
There are few spots that will be __undefined value__. These are situation where it is not invalid to do something, but the value returned from the hardware might be garbage. Imagine the following code
38
+
39
+
[source,cpp]
40
+
----
41
+
int x;
42
+
print(x)
43
+
----
44
+
45
+
It will never crash, but the value can be anything and relying on the undefined value to be something like `0` is dangerous.
46
+
35
47
== Valid Usage ID (VUID)
36
48
37
49
A `VUID` is an unique ID given to each valid usage. This allows a way to point to a valid usage in the spec easily.
38
50
39
51
Using `VUID-vkBindImageMemory-memoryOffset-01046` as an example, it is as simple as adding the VUID to an anchor in the HTML version of the spec (link:https://docs.vulkan.org/spec/latest/chapters/resources.html#VUID-vkBindImageMemory-memoryOffset-01046[vkspec.html#VUID-vkBindImageMemory-memoryOffset-01046]) and it will jump right to the VUID.
40
52
53
+
=== Implicit vs Explicit
54
+
55
+
__Implicit Validation__ is the validation that is generated from the `vk.xml`. It will be the "obvious" things such as "`device` must be a valid `VkDevice` handle".
56
+
57
+
__Explicit Validation__ are the handwritten VUs found everywhere else
58
+
59
+
Simple way to detect which is which is by looking for a number in the VUID
60
+
61
+
- `VUID-vkBindImageMemory-image-01044` is explicit
62
+
- `VUID-vkBindImageMemory-memory-parameter` is implicit
63
+
41
64
[[khronos-validation-layer]]
42
65
== Khronos Validation Layer
43
66
@@ -59,62 +82,7 @@ The Validation Layers are constantly being updated and improved so it is always
59
82
60
83
== Breaking Down a Validation Error Message
61
84
62
-
The Validation Layers attempt to supply as much useful information as possible when an error occurs. The following examples are to help show how to get the most information out of the Validation Layers
63
-
64
-
=== Example 1 - Implicit Valid Usage
65
-
66
-
This example shows a case where an link:https://docs.vulkan.org/spec/latest/chapters/fundamentals.html#fundamentals-implicit-validity[implicit VU] is triggered. There will not be a number at the end of the VUID.
* The first thing to notice is the VUID is listed first in the message (`VUID-vkBindBufferMemory-memory-parameter`)
77
-
** There is also a link at the end of the message to the VUID in the spec
78
-
* `The Vulkan spec states:` is the quoted VUID from the spec.
79
-
* The `VK_OBJECT_TYPE_INSTANCE` is the link:https://docs.vulkan.org/spec/latest/chapters/debugging.html#VkObjectType[VkObjectType]
80
-
* `Invalid VkDeviceMemory Object 0x60000000006` is the link:https://docs.vulkan.org/spec/latest/chapters/fundamentals.html#fundamentals-objectmodel-overview[Dispatchable Handle] to help show which `VkDeviceMemory` handle was the cause of the error.
81
-
82
-
=== Example 2 - Explicit Valid Usage
83
-
84
-
This example shows an error where some `VkImage` is trying to be bound to 2 different `VkDeviceMemory` objects
name = myIconMemory, type = VK_OBJECT_TYPE_DEVICE_MEMORY; | MessageID = 0x6f3eac96 |
92
-
In vkBindImageMemory(), attempting to bind VkDeviceMemory 0x90000000009[myTextureMemory]
93
-
to VkImage 0x70000000007[] which has already been bound to VkDeviceMemory
94
-
0x90000000006[myIconMemory]. The Vulkan spec states: image must not already be
95
-
backed by a memory object (https://docs.vulkan.org/spec/latest/chapters/resources.html#VUID-vkBindImageMemory-image-01044)
96
-
----
97
-
98
-
* Example 2 is about the same as Example 1 with the exception that the `name` that was attached to the object (`name = myTextureMemory`). This was done using the link:https://www.lunarg.com/new-tutorial-for-vulkan-debug-utilities-extension/[VK_EXT_debug_util] extension (link:https://github.com/KhronosGroup/Vulkan-Samples/tree/main/samples/extensions/debug_utils[Sample of how to use the extension]). Note that the old way of using link:https://www.saschawillems.de/blog/2016/05/28/tutorial-on-using-vulkans-vk_ext_debug_marker-with-renderdoc/[VK_EXT_debug_report] might be needed on legacy devices that don't support `VK_EXT_debug_util`.
99
-
* There were 3 objects involved in causing this error.
100
-
** Object 0 is a `VkDeviceMemory` named `myTextureMemory`
101
-
** Object 1 is a `VkImage` with no name
102
-
** Object 2 is a `VkDeviceMemory` named `myIconMemory`
103
-
* With the names it is easy to see "`In `vkBindImageMemory()`, the `myTextureMemory` memory was attempting to bind to an image already been bound to the `myIconMemory` memory`".
104
-
105
-
Each error message contains a uniform logging pattern. This allows information to be easily found in any error. The pattern is as followed:
106
-
107
-
* Log status (ex. `Error:`, `Warning:`, etc)
108
-
* The VUID
109
-
* Array of objects involved
110
-
** Index of array
111
-
** Dispatch Handle value
112
-
** Optional name
113
-
** Object Type
114
-
* Function or struct error occurred in
115
-
* Message the layer has created to help describe the issue
116
-
* The full Valid Usage from the spec
117
-
* Link to the Valid Usage
85
+
This information can be found in the link:https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/main/docs/error_messages.md[Validation Layers documentation].
0 commit comments