Crash Diagnostic Layer

The Crash Diagnostic Layer (CDL) is a Vulkan layer to help track down and identify the cause of GPU hangs and crashes. It works by instrumenting command buffers with completion checkpoints. When an error is detected a dump file containing incomplete command buffers is written. Often the last complete or incomplete commands are responsible for the crash. The name of the layer is VK_LAYER_LUNARG_crash_diagnostic.

Building

See the associated BUILD.md file for details on how to build the Crash Diagnostic Layer for various platforms.

Runtime requirements

CDL uses the following extensions. If an extension is not present, some functionality might be disabled.

Running

CDL can be used as an explicit or implicit layer. The loader's documentation describes the difference between implicit and explicit layers, but the relevant bit here is that implicit layers are meant to be available to all applications on the system, even if the application doesn't explicitly enable the layer. On the other hand, explicit layers are easier to use when doing application development.

Explicit Layer

To use CDL as an explicit layer, enable it with vkconfig or do the following:

  1. The directory containing the file VkLayer_crash_diagnostic.json is included in the layer search path, by including it in either the VK_LAYER_PATH or VK_ADD_LAYER_PATH environment variable or by using vkconfig.
  2. Include the layer name in the VK_INSTANCE_LAYERS environment variable or the ppEnabledLayerNames field of VkInstanceCreateInfo.

Implicit Layer

When using CDL as an implicit layer, it is disabled by default. To enable the layer's functionality, set the CDL_ENABLE environment variable to 1.

Registering the Layer

In order to be discovered by the Vulkan loader at runtime, implicit layers must be registered. The registration process is platform-specific and is discussed in detail in the Vulkan-Loader documentation. In all cases, it is the layer manifest (the .json file) that is registered; the manifest contains a relative path to the layer library, which can be in a separate directory.

Basic Usage

Once the layer is enabled, if vkQueueSubmit() or other Vulkan functions returns a fatal error code (usually VK_ERROR_DEVICE_LOST), a dump file of the command buffers (and other state) that failed to execute are written to disk.

Logging

CDL outputs messages at runtime to indicate it is enabled, to trace certain commands, and to report when a gpu crash has occurred. The message_severity, log_file, trace_on and trace_all_semaphores configuration settings control which messages are output and where they are sent.

VK_EXT_debug_utils and VK_EXT_debug_report extensions can also be used to receive log messages directly in the application.

Dump files

A unique log file directory is created every time an application is run with CDL enabled. The log file directories are named with the timestamp of the format YYYY-MM-DD-HHMMSS. This prevents subsequent runs from overwriting old data, in case the application is non-deterministic and producing different crashes on each run. The location of these files is platform-specific:

The output directory for dump files can be changed using the output_path configuration setting, described below.

The name of the dump file is cdl_dump.yaml, since the file is in the YAML format. Other files, such as dumped shaders, may be present in the dump directory.

Configuration

This layer implements the VK_EXT_layer_settings extension, so it can be configured with vkconfig, programmatically, or with environment variables. See the manifest for this layer and the layer manifest schema for full details. The discussion below uses the key field to identify each setting, the env field defines the corresponding environment variable, and the label field defines the text you will see when using vkconfig.