Selecting the Required Validation Layers

Validation layers ensure the API is being used correctly

Vulkan has very little in-built error checking. This is an intentional design choice to limit the driver overhead in Vulkan applications. However, error checking can be enabled through the use of validation layers.

What are validation layers?

Validation layers are very useful during application development. They ensure the API is being used correctly, by providing debugging and error checking functionality which is not enabled by default in the core Vulkan layer. If validation layers are not enabled, Vulkan assumes the API is being used correctly so any mistakes can result in undefined behaviour.

The LunarG Vulkan SDK provides various validation layers which enable standard error checking. The choice of validation layers to enable is completely up to the developer.

For development, the most useful layer that comes with this SDK is VK_LAYER_LUNARG_standard_validation. This is actually a large meta layer containing all of the most commonly used validation layers. These layers offer features such as printing API calls, tracking objects, and validating the use of image formats.

Example: initLayers()

In the example code, the function initLayers() selects the required layers to be enabled. The VK_LAYER_LUNARG_standard_validation metalayer is chosen. If this metalayer is not available, then the individual layers are chosen one by one.