1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
|
<!-- markdownlint-disable MD041 -->
[![Khronos Vulkan][1]][2]
[1]: https://vulkan.lunarg.com/img/Vulkan_100px_Dec16.png "https://www.khronos.org/vulkan/"
[2]: https://www.khronos.org/vulkan/
# Debugging The Vulkan Desktop Loader <!-- omit from toc -->
[![Creative Commons][3]][4]
<!-- Copyright © 2015-2023 LunarG, Inc. -->
[3]: https://i.creativecommons.org/l/by-nd/4.0/88x31.png "Creative Commons License"
[4]: https://creativecommons.org/licenses/by-nd/4.0/
## Table of Contents <!-- omit from toc -->
- [Debugging Issues](#debugging-issues)
- [Loader Logging](#loader-logging)
- [Debugging Possible Layer Issues](#debugging-possible-layer-issues)
- [Enable Layer Logging](#enable-layer-logging)
- [Disable Layers](#disable-layers)
- [Selectively Re-enable Layers](#selectively-re-enable-layers)
- [Allow specific layers to be ignored by VK\_LOADER\_LAYERS\_DISABLE](#allow-specific-layers-to-be-ignored-by-vk_loader_layers_disable)
- [Debugging Possible Driver Issues](#debugging-possible-driver-issues)
- [Enable Driver Logging](#enable-driver-logging)
- [Selectively Enable Specific Drivers](#selectively-enable-specific-drivers)
## Debugging Issues
If your application is crashing or behaving weirdly, the loader provides
several mechanisms for you to debug the issues.
**NOTE**: This functionality is all specific to the desktop Vulkan loader and
does not work for the Android loader.
## Loader Logging
The Vulkan desktop loader has added logging functionality that can be enabled by
using the `VK_LOADER_DEBUG` environment variable.
The results will be output to the standard output, but will also be passed to
any `VK_EXT_debug_utils` messengers present as well.
The variable can be set to a comma-delimited list of debug level options which
include:
* error Report any errors encountered by
the loader
* warn Report any warnings encountered by
the loader
* info Report info-level
messages generated by the loader
* debug Report debug-level messages generated by the
loader
* layer Report all layer-specific messages
generated by the loader
* driver Report all driver-specific messages
generated by the loader
* all Report all
messages generated by the loader (includes all of the above)
If you're not sure where the issue comes from, at least set it to output all
messages through the "info" level:
```
set VK_LOADER_DEBUG=error,warn,info
```
Then, you can search the list for any errors or warnings that might provide a
hint at why you're seeing issues.
For more info on enabling loader logging, refer to the
[Enable Loader Debug Layer Output](LoaderApplicationInterface.md#enable-loader-debug-layer-output)
and the
[Table of Debug Environment Variables](LoaderInterfaceArchitecture.md#table-of-debug-environment-variables)
below.
## Debugging Possible Layer Issues
### Enable Layer Logging
If you suspect a layer issue, set the loader logging to specifically output
layer messages in addition to warnings and errors:
```
set VK_LOADER_DEBUG=error,warn,layer
```
Most important layer messages should go out with error or warning levels set,
but this will provide more layer-specific info as well such as:
* What layers are found
* Where they were found
* If they are implicit, what environment variables can be used to disable them
* If there is any incompatibility with a given layer, this could include:
* The layer library file (.so/.dll) wasn't found
* The layer library is the wrong bit-depth for the executing application
(i.e. 32-bit vs 64-bit)
* The layer itself doesn't support the application desired version of Vulkan
* If any environment variables are disabling any layers
For example, the output of the loader looking for implicit layers may look like
the following:
```
[Vulkan Loader] LAYER: Searching for implicit layer manifest files
[Vulkan Loader] LAYER: In following locations:
[Vulkan Loader] LAYER: /home/${USER}/.config/vulkan/implicit_layer.d
[Vulkan Loader] LAYER: /etc/xdg/vulkan/implicit_layer.d
[Vulkan Loader] LAYER: /usr/local/etc/vulkan/implicit_layer.d
[Vulkan Loader] LAYER: /etc/vulkan/implicit_layer.d
[Vulkan Loader] LAYER: /home/${USER}/.local/share/vulkan/implicit_layer.d
[Vulkan Loader] LAYER: /home/${USER}/.local/share/flatpak/exports/share/vulkan/implicit_layer.d
[Vulkan Loader] LAYER: /var/lib/flatpak/exports/share/vulkan/implicit_layer.d
[Vulkan Loader] LAYER: /usr/local/share/vulkan/implicit_layer.d
[Vulkan Loader] LAYER: /usr/share/vulkan/implicit_layer.d
[Vulkan Loader] LAYER: Found the following files:
[Vulkan Loader] LAYER: /home/${USER}/.local/share/vulkan/implicit_layer.d/renderdoc_capture.json
[Vulkan Loader] LAYER: /home/${USER}/.local/share/vulkan/implicit_layer.d/steamfossilize_i386.json
[Vulkan Loader] LAYER: /home/${USER}/.local/share/vulkan/implicit_layer.d/steamfossilize_x86_64.json
[Vulkan Loader] LAYER: /home/${USER}/.local/share/vulkan/implicit_layer.d/steamoverlay_i386.json
[Vulkan Loader] LAYER: /home/${USER}/.local/share/vulkan/implicit_layer.d/steamoverlay_x86_64.json
[Vulkan Loader] LAYER: /usr/share/vulkan/implicit_layer.d/nvidia_layers.json
[Vulkan Loader] LAYER: /usr/share/vulkan/implicit_layer.d/VkLayer_MESA_device_select.json
```
Then, the loading of layer libraries is reported similar to this:
```
[Vulkan Loader] DEBUG | LAYER : Loading layer library libVkLayer_khronos_validation.so
[Vulkan Loader] INFO | LAYER : Insert instance layer VK_LAYER_KHRONOS_validation (libVkLayer_khronos_validation.so)
[Vulkan Loader] DEBUG | LAYER : Loading layer library libVkLayer_MESA_device_select.so
[Vulkan Loader] INFO | LAYER : Insert instance layer VK_LAYER_MESA_device_select (libVkLayer_MESA_device_select.so)
```
Finally, when the Vulkan instance is created, you can see the full instance
call-chain from a functional standpoint with output like this:
```
[Vulkan Loader] LAYER: vkCreateInstance layer callstack setup to:
[Vulkan Loader] LAYER: <Application>
[Vulkan Loader] LAYER: ||
[Vulkan Loader] LAYER: <Loader>
[Vulkan Loader] LAYER: ||
[Vulkan Loader] LAYER: VK_LAYER_MESA_device_select
[Vulkan Loader] LAYER: Type: Implicit
[Vulkan Loader] LAYER: Enabled By: Implicit Layer
[Vulkan Loader] LAYER: Disable Env Var: NODEVICE_SELECT
[Vulkan Loader] LAYER: Manifest: /usr/share/vulkan/implicit_layer.d/VkLayer_MESA_device_select.json
[Vulkan Loader] LAYER: Library: libVkLayer_MESA_device_select.so
[Vulkan Loader] LAYER: ||
[Vulkan Loader] LAYER: VK_LAYER_KHRONOS_validation
[Vulkan Loader] LAYER: Type: Explicit
[Vulkan Loader] LAYER: Enabled By: By the Application
[Vulkan Loader] LAYER: Manifest: /usr/share/vulkan/explicit_layer.d/VkLayer_khronos_validation.json
[Vulkan Loader] LAYER: Library: libVkLayer_khronos_validation.so
[Vulkan Loader] LAYER: ||
[Vulkan Loader] LAYER: <Drivers>
```
In this scenario, two layers were used (the same two that were loaded earlier):
* `VK_LAYER_MESA_device_select`
* `VK_LAYER_KHRONOS_validation`
This information now shows us that the `VK_LAYER_MESA_device_select` is loaded
first, followed by `VK_LAYER_KHRONOS_validation` which will then continue into
any available drivers.
It also shows that `VK_LAYER_MESA_device_select` is an implicit layer which
implies that it wasn't directly enabled by the application.
On the other hand, `VK_LAYER_KHRONOS_validation` is shown as an explicit layer
which indicates that it was likely enabled by the application.
### Disable Layers
**NOTE:** This functionality is only available with Loaders built with version
1.3.234 of the Vulkan headers and later.
Sometimes, implicit layers can cause issues with an application.
Because of this, the next step is to try to disable one or more of the listed
implicit layers.
You can use the filtering environment variables
(`VK_LOADER_LAYERS_ENABLE` and `VK_LOADER_LAYERS_DISABLE`) to selectively enable
or disable various layers.
If you're not sure what to do, try disabling all implicit layers manually by
setting `VK_LOADER_LAYERS_DISABLE` to `~implicit~`.
```
set VK_LOADER_LAYERS_DISABLE=~implicit~
```
This will disable all implicit layers and the loader will report any disabled
layers to the logging output when layer logging is enabled in the following way:
```
[Vulkan Loader] WARNING | LAYER: Implicit layer "VK_LAYER_MESA_device_select" forced disabled because name matches filter of env var 'VK_LOADER_LAYERS_DISABLE'.
[Vulkan Loader] WARNING | LAYER: Implicit layer "VK_LAYER_AMD_switchable_graphics_64" forced disabled because name matches filter of env var 'VK_LOADER_LAYERS_DISABLE'.
[Vulkan Loader] WARNING | LAYER: Implicit layer "VK_LAYER_Twitch_Overlay" forced disabled because name matches filter of env var 'VK_LOADER_LAYERS_DISABLE'.
```
### Selectively Re-enable Layers
**NOTE:** This functionality is only available with Loaders built with version
1.3.234 of the Vulkan headers and later.
When trying to diagnose problems caused by layers, it is useful to first disable
all layers and re-enable each layer individually.
If the problem reappears, then it is immediately clear which layer is the source
of the issue.
For example, from the above given list of disabled layers, let’s selectively
re-enable one:
```
set VK_LOADER_LAYERS_DISABLE=~implicit~
set VK_LOADER_LAYERS_ENABLE=*AMD*
```
This would keep both the "VK_LAYER_MESA_device_select" and
"VK_LAYER_Twitch_Overlay" layers disabled, while enabling the
"VK_LAYER_AMD_switchable_graphics_64" layer.
If everything continues to work, then the evidence seems to suggest the issue is
likely not related to the AMD layer.
This would lead to enabling one other layer and trying again:
```
set VK_LOADER_LAYERS_DISABLE=~implicit~
set VK_LOADER_LAYERS_ENABLE=*AMD*,*twitch*
```
And so forth.
For more info on how to use the filtering environment variables, refer to the
[Layer Filtering](LoaderLayerInterface.md#layer-filtering) section of the
[LoaderLayerInterface](LoaderLayerInterface.md) document.
## Allow specific layers to be ignored by VK_LOADER_LAYERS_DISABLE
**NOTE:** VK_LOADER_LAYERS_DISABLE is only available with Loaders built with version
1.3.262 of the Vulkan headers and later.
When using `VK_LOADER_LAYERS_DISABLE` to disable implicit layers, it is possible
to allow specific layers to be enabled using `VK_LOADER_LAYERS_ENABLE`.
However, this has the effect of *forcing* layers to be enabled, which is not
always desired.
Implicit layers have the ability to only be enabled when a layer specified
environment variable is set, allow for context dependent enablement.
`VK_LOADER_LAYERS_ENABLE` ignores that context.
Thus, a different environment variable is needed: `VK_LOADER_LAYERS_ALLOW`
The behavior of `VK_LOADER_LAYERS_ALLOW` is similar to `VK_LOADER_LAYERS_ENABLE`
except that it does not force a layer to be enabled.
The way to think about this environment variable is that every layer matching
`VK_LOADER_LAYERS_ALLOW` is excluded from being forcibly disabled by
`VK_LOADER_LAYERS_DISABLE`.
this allows for implicit layers that are context dependent to be enabled
depending on the relevant context instead of force enabling them.
Example: Disable all implicit layers except for any layers that have steam or
mesa in their name.
```
set VK_LOADER_LAYERS_DISABLE=~implicit~
set VK_LOADER_LAYERS_ALLOW=*steam*,*Mesa*
```
## Debugging Possible Driver Issues
### Enable Driver Logging
**NOTE:** This functionality is only available with Loaders built with version
1.3.234 of the Vulkan headers and later.
If you suspect a driver issue, set the loader logging to specifically output
driver messages:
```
set VK_LOADER_DEBUG=error,warn,driver
```
Most important driver messages should go out with error or warning levels set,
but this will provide more driver-specific info as well such as:
* What drivers are found
* Where they were found
* If there is any incompatibility with a given driver
* If any environment variables are disabling any of the drivers
For example, the output of the loader looking for drivers on a Linux system may
look like the following (NOTE: additional spaces have been removed from the
output for easier reading):
```
[Vulkan Loader] DRIVER: Searching for driver manifest files
[Vulkan Loader] DRIVER: In following folders:
[Vulkan Loader] DRIVER: /home/$(USER)/.config/vulkan/icd.d
[Vulkan Loader] DRIVER: /etc/xdg/vulkan/icd.d
[Vulkan Loader] DRIVER: /etc/vulkan/icd.d
[Vulkan Loader] DRIVER: /home/$(USER)/.local/share/vulkan/icd.d
[Vulkan Loader] DRIVER: /home/$(USER)/.local/share/flatpak/exports/share/vulkan/icd.d
[Vulkan Loader] DRIVER: /var/lib/flatpak/exports/share/vulkan/icd.d
[Vulkan Loader] DRIVER: /usr/local/share/vulkan/icd.d
[Vulkan Loader] DRIVER: /usr/share/vulkan/icd.d
[Vulkan Loader] DRIVER: Found the following files:
[Vulkan Loader] DRIVER: /usr/share/vulkan/icd.d/intel_icd.x86_64.json
[Vulkan Loader] DRIVER: /usr/share/vulkan/icd.d/lvp_icd.x86_64.json
[Vulkan Loader] DRIVER: /usr/share/vulkan/icd.d/radeon_icd.x86_64.json
[Vulkan Loader] DRIVER: /usr/share/vulkan/icd.d/lvp_icd.i686.json
[Vulkan Loader] DRIVER: /usr/share/vulkan/icd.d/radeon_icd.i686.json
[Vulkan Loader] DRIVER: /usr/share/vulkan/icd.d/intel_icd.i686.json
[Vulkan Loader] DRIVER: /usr/share/vulkan/icd.d/nvidia_icd.json
[Vulkan Loader] DRIVER: Found ICD manifest file /usr/share/vulkan/icd.d/intel_icd.x86_64.json, version "1.0.0"
[Vulkan Loader] DRIVER: Found ICD manifest file /usr/share/vulkan/icd.d/lvp_icd.x86_64.json, version "1.0.0"
[Vulkan Loader] DRIVER: Found ICD manifest file /usr/share/vulkan/icd.d/radeon_icd.x86_64.json, version "1.0.0"
[Vulkan Loader] DRIVER: Found ICD manifest file /usr/share/vulkan/icd.d/lvp_icd.i686.json, version "1.0.0"
[Vulkan Loader] DRIVER: Requested driver /usr/lib/libvulkan_lvp.so was wrong bit-type. Ignoring this JSON
[Vulkan Loader] DRIVER: Found ICD manifest file /usr/share/vulkan/icd.d/radeon_icd.i686.json, version "1.0.0"
[Vulkan Loader] DRIVER: Requested driver /usr/lib/libvulkan_radeon.so was wrong bit-type. Ignoring this JSON
[Vulkan Loader] DRIVER: Found ICD manifest file /usr/share/vulkan/icd.d/intel_icd.i686.json, version "1.0.0"
[Vulkan Loader] DRIVER: Requested driver /usr/lib/libvulkan_intel.so was wrong bit-type. Ignoring this JSON
[Vulkan Loader] DRIVER: Found ICD manifest file /usr/share/vulkan/icd.d/nvidia_icd.json, version "1.0.0"
```
Then when the application selects the device to use, you will see the Vulkan
device call chain reported in the following way (NOTE: additional spaces have
been removed from the output for easier reading):
```
[Vulkan Loader] DRIVER: vkCreateDevice layer callstack setup to:
[Vulkan Loader] DRIVER: <Application>
[Vulkan Loader] DRIVER: ||
[Vulkan Loader] DRIVER: <Loader>
[Vulkan Loader] DRIVER: ||
[Vulkan Loader] DRIVER: <Device>
[Vulkan Loader] DRIVER: Using "Intel(R) UHD Graphics 630 (CFL GT2)" with driver: "/usr/lib64/libvulkan_intel.so"
```
### Selectively Enable Specific Drivers
**NOTE:** This functionality is only available with Loaders built with version
1.3.234 of the Vulkan headers and later.
You can now use the filtering environment variables
(`VK_LOADER_DRIVERS_SELECT` and `VK_LOADER_DRIVERS_DISABLE`) to control what
drivers the loader will attempt to load.
For drivers, the string globs passed into the above environment variables will
be compared against the driver JSON file name since there is no driver name
known to the loader until much later in the Vulkan initialization process.
For example, to disable all drivers except Nvidia you could do the following:
```
set VK_LOADER_DRIVERS_DISABLE=*
set VK_LOADER_DRIVERS_SELECT=*nvidia*
```
The loader outputs messages like the following when the environment variables
are used:
```
[Vulkan Loader] WARNING | DRIVER: Driver "intel_icd.x86_64.json" ignored because not selected by env var 'VK_LOADER_DRIVERS_SELECT'
[Vulkan Loader] WARNING | DRIVER: Driver "radeon_icd.x86_64.json" ignored because it was disabled by env var 'VK_LOADER_DRIVERS_DISABLE'
```
For more info on how to use the filtering environment variables, refer to the
[Driver Filtering](LoaderDriverInterface.md#driver-filtering) section of the
[LoaderDriverInterface](LoaderDriverInterface.md) document.
|