Layers
Layers are optional components that augment the Vulkan system, packaged as shared libraries that get dynamically loaded in by the loader. They can intercept, evaluate, and modify existing Vulkan functions on their way from the application down to the hardware.
For example, by design, minimal error checking is done inside a Vulkan driver, Vulkan Validation layer can be used to to assist developers in isolating incorrect usage, and in verifying that applications correctly use the API.
Layers are packaged as shared libraries that get dynamically loaded in by the loader and inserted between it and the application.
The layers can be either explicitly enabled or implicitly enabled. More details about implicit and explicit layers can be found in the Loader and Layer Interface.
Configuring Layers
A layers configuration consists in two operations: - Selecting and ordering layers - Configuring each layer themselves using settings
Layers can be configured using three different methods to match specific Vulkan developers' workflows:
- Using environment variables: Loader environment variables and per-layer settings environment variables
- Using dedicated Vulkan system files: vk_loader_settings.json and vk_layer_settings.txt
- Using the Vulkan API, programmably in the Vulkan application: vkCreateInstance and VK_EXT_layer_settings
Vulkan Configurator simplifies the usage of these three methods. Using the graphical user interface, we can create layers configuration. The tool automatically create and locate the vk_loader_settings.json and vk_layer_settings.txt files. It can also be used to generate environment variables scripts and a C++ header library that can be directly included within the Vulkan application code.
The Layer Configuration document is providing details on layer configuration.
Layers settings backward compatbility policy
Settings which are unknown by the layer will be ignored independently of the method. It’s the responsibility of the layer developer to ensure backward compatibility with previous versions of the layer.
This is to ensure the list of layer settings remain relatively stable across versions and that the responsibility of handling layer backward compatibility doesn’t fall on Vulkan application developers as this could quickly become untrackable.
Device Layers Deprecation
There used to be both instance layers and device layers, but device layers were deprecated early in Vulkan’s life and should be avoided.
Creating a Layer
Anyone can create a layer as long as it follows the loader to layer interface which is how the loader and layers agree to communicate with each other.
To ensure consistency and a smooth integration with Vulkan Configurator and other SDK tools, the Vulkan::LayerSettings should be used by the layer implementation.
Android
As of Android P (Android 9 / API level 28), if a device is in a debuggable state such that getprop ro.debuggable /data/local/debug/vulkan.
Starting in Android P (Android 9 / API level 28) implicit layers can be pushed using ADB if the application was built in debug mode.
There is no way other than the options above to use implicit layers.