15db71995Sopenharmony_ci<!-- markdownlint-disable MD041 -->
25db71995Sopenharmony_ci[![Khronos Vulkan][1]][2]
35db71995Sopenharmony_ci
45db71995Sopenharmony_ci[1]: https://vulkan.lunarg.com/img/Vulkan_100px_Dec16.png "https://www.khronos.org/vulkan/"
55db71995Sopenharmony_ci[2]: https://www.khronos.org/vulkan/
65db71995Sopenharmony_ci
75db71995Sopenharmony_ci# Layer Interface to the Loader <!-- omit from toc -->
85db71995Sopenharmony_ci[![Creative Commons][3]][4]
95db71995Sopenharmony_ci
105db71995Sopenharmony_ci<!-- Copyright &copy; 2015-2023 LunarG, Inc. -->
115db71995Sopenharmony_ci
125db71995Sopenharmony_ci[3]: https://i.creativecommons.org/l/by-nd/4.0/88x31.png "Creative Commons License"
135db71995Sopenharmony_ci[4]: https://creativecommons.org/licenses/by-nd/4.0/
145db71995Sopenharmony_ci
155db71995Sopenharmony_ci
165db71995Sopenharmony_ci## Table of Contents <!-- omit from toc -->
175db71995Sopenharmony_ci
185db71995Sopenharmony_ci- [Overview](#overview)
195db71995Sopenharmony_ci- [Layer Discovery](#layer-discovery)
205db71995Sopenharmony_ci  - [Layer Manifest File Usage](#layer-manifest-file-usage)
215db71995Sopenharmony_ci  - [Android Layer Discovery](#android-layer-discovery)
225db71995Sopenharmony_ci  - [Windows Layer Discovery](#windows-layer-discovery)
235db71995Sopenharmony_ci  - [Linux Layer Discovery](#linux-layer-discovery)
245db71995Sopenharmony_ci    - [Example Linux Explicit Layer Search Path](#example-linux-explicit-layer-search-path)
255db71995Sopenharmony_ci  - [Fuchsia Layer Discovery](#fuchsia-layer-discovery)
265db71995Sopenharmony_ci  - [macOS Layer Discovery](#macos-layer-discovery)
275db71995Sopenharmony_ci    - [Example macOS Implicit Layer Search Path](#example-macos-implicit-layer-search-path)
285db71995Sopenharmony_ci  - [Layer Filtering](#layer-filtering)
295db71995Sopenharmony_ci    - [Layer Enable Filtering](#layer-enable-filtering)
305db71995Sopenharmony_ci    - [Layer Disable Filtering](#layer-disable-filtering)
315db71995Sopenharmony_ci    - [Layer Special Case Disable](#layer-special-case-disable)
325db71995Sopenharmony_ci    - [Layer Disable Warning](#layer-disable-warning)
335db71995Sopenharmony_ci    - [Allow certain Layers to ignore Layer Disabling](#allow-certain-layers-to-ignore-layer-disabling)
345db71995Sopenharmony_ci      - [`VK_INSTANCE_LAYERS`](#vk_instance_layers)
355db71995Sopenharmony_ci  - [Exception for Elevated Privileges](#exception-for-elevated-privileges)
365db71995Sopenharmony_ci- [Layer Version Negotiation](#layer-version-negotiation)
375db71995Sopenharmony_ci- [Layer Call Chains and Distributed Dispatch](#layer-call-chains-and-distributed-dispatch)
385db71995Sopenharmony_ci- [Layer Unknown Physical Device Extensions](#layer-unknown-physical-device-extensions)
395db71995Sopenharmony_ci  - [Reason for adding `vk_layerGetPhysicalDeviceProcAddr`](#reason-for-adding-vk_layergetphysicaldeviceprocaddr)
405db71995Sopenharmony_ci- [Layer Intercept Requirements](#layer-intercept-requirements)
415db71995Sopenharmony_ci- [Distributed Dispatching Requirements](#distributed-dispatching-requirements)
425db71995Sopenharmony_ci- [Layer Conventions and Rules](#layer-conventions-and-rules)
435db71995Sopenharmony_ci- [Layer Dispatch Initialization](#layer-dispatch-initialization)
445db71995Sopenharmony_ci- [Example Code for CreateInstance](#example-code-for-createinstance)
455db71995Sopenharmony_ci- [Example Code for CreateDevice](#example-code-for-createdevice)
465db71995Sopenharmony_ci- [Meta-layers](#meta-layers)
475db71995Sopenharmony_ci  - [Override Meta-Layer](#override-meta-layer)
485db71995Sopenharmony_ci- [Pre-Instance Functions](#pre-instance-functions)
495db71995Sopenharmony_ci- [Special Considerations](#special-considerations)
505db71995Sopenharmony_ci  - [Associating Private Data with Vulkan Objects Within a Layer](#associating-private-data-with-vulkan-objects-within-a-layer)
515db71995Sopenharmony_ci    - [Wrapping](#wrapping)
525db71995Sopenharmony_ci    - [Cautions About Wrapping](#cautions-about-wrapping)
535db71995Sopenharmony_ci    - [Hash Maps](#hash-maps)
545db71995Sopenharmony_ci  - [Creating New Dispatchable Objects](#creating-new-dispatchable-objects)
555db71995Sopenharmony_ci  - [Versioning and Activation Interactions](#versioning-and-activation-interactions)
565db71995Sopenharmony_ci- [Layer Manifest File Format](#layer-manifest-file-format)
575db71995Sopenharmony_ci  - [Layer Manifest File Version History](#layer-manifest-file-version-history)
585db71995Sopenharmony_ci  - [Layer Manifest File Version 1.2.1](#layer-manifest-file-version-121)
595db71995Sopenharmony_ci    - [Layer Manifest File Version 1.2.0](#layer-manifest-file-version-120)
605db71995Sopenharmony_ci    - [Layer Manifest File Version 1.1.2](#layer-manifest-file-version-112)
615db71995Sopenharmony_ci    - [Layer Manifest File Version 1.1.1](#layer-manifest-file-version-111)
625db71995Sopenharmony_ci    - [Layer Manifest File Version 1.1.0](#layer-manifest-file-version-110)
635db71995Sopenharmony_ci    - [Layer Manifest File Version 1.0.1](#layer-manifest-file-version-101)
645db71995Sopenharmony_ci    - [Layer Manifest File Version 1.0.0](#layer-manifest-file-version-100)
655db71995Sopenharmony_ci- [Layer Interface Versions](#layer-interface-versions)
665db71995Sopenharmony_ci  - [Layer Interface Version 2](#layer-interface-version-2)
675db71995Sopenharmony_ci  - [Layer Interface Version 1](#layer-interface-version-1)
685db71995Sopenharmony_ci  - [Layer Interface Version 0](#layer-interface-version-0)
695db71995Sopenharmony_ci- [Loader and Layer Interface Policy](#loader-and-layer-interface-policy)
705db71995Sopenharmony_ci  - [Number Format](#number-format)
715db71995Sopenharmony_ci  - [Android Differences](#android-differences)
725db71995Sopenharmony_ci  - [Requirements of Well-Behaved Layers](#requirements-of-well-behaved-layers)
735db71995Sopenharmony_ci  - [Requirements of a Well-Behaved Loader](#requirements-of-a-well-behaved-loader)
745db71995Sopenharmony_ci
755db71995Sopenharmony_ci
765db71995Sopenharmony_ci## Overview
775db71995Sopenharmony_ci
785db71995Sopenharmony_ciThis is the Layer-centric view of working with the Vulkan loader.
795db71995Sopenharmony_ciFor the complete overview of all sections of the loader, please refer
805db71995Sopenharmony_cito the [LoaderInterfaceArchitecture.md](LoaderInterfaceArchitecture.md) file.
815db71995Sopenharmony_ci
825db71995Sopenharmony_ci
835db71995Sopenharmony_ci## Layer Discovery
845db71995Sopenharmony_ci
855db71995Sopenharmony_ciAs mentioned in the
865db71995Sopenharmony_ci[Implicit versus Explicit](LoaderApplicationInterface.md#implicit-vs-explicit-layers),
875db71995Sopenharmony_cisection of the
885db71995Sopenharmony_ci[LoaderApplicationInterface.md](LoaderApplicationInterface.md) document, layers
895db71995Sopenharmony_cican be categorized into two categories:
905db71995Sopenharmony_ci * Implicit Layers
915db71995Sopenharmony_ci * Explicit Layers
925db71995Sopenharmony_ci
935db71995Sopenharmony_ciThe main difference between the two is that implicit layers are automatically
945db71995Sopenharmony_cienabled, unless overridden, and explicit layers must be enabled.
955db71995Sopenharmony_ciRemember, implicit layers are not present on all Operating Systems (like
965db71995Sopenharmony_ciAndroid).
975db71995Sopenharmony_ci
985db71995Sopenharmony_ciOn any system, the loader looks in specific areas for information on the layers
995db71995Sopenharmony_cithat it can load at a user's request.
1005db71995Sopenharmony_ciThe process of finding the available layers on a system is known as Layer
1015db71995Sopenharmony_ciDiscovery.
1025db71995Sopenharmony_ciDuring discovery, the loader determines what layers are available, the layer
1035db71995Sopenharmony_ciname, the layer version, and any extensions supported by the layer.
1045db71995Sopenharmony_ciThis information is provided back to an application through
1055db71995Sopenharmony_ci`vkEnumerateInstanceLayerProperties`.
1065db71995Sopenharmony_ci
1075db71995Sopenharmony_ciThe group of layers available to the loader is known as the `Layer Library`.
1085db71995Sopenharmony_ciThis section defines an extensible interface to discover what layers are
1095db71995Sopenharmony_cicontained in the `Layer Library`.
1105db71995Sopenharmony_ci
1115db71995Sopenharmony_ciThis section also specifies the minimal conventions and rules a layer must
1125db71995Sopenharmony_cifollow, especially with regards to interacting with the loader and other
1135db71995Sopenharmony_cilayers.
1145db71995Sopenharmony_ci
1155db71995Sopenharmony_ciWhen searching for a layer, the loader will look through the `Layer Library` in
1165db71995Sopenharmony_cithe order it detected them and load the layer if the name matches.
1175db71995Sopenharmony_ciIf multiple instances of the same library exist in different locations
1185db71995Sopenharmony_cithroughout the user's system, then the one appearing first in the search order
1195db71995Sopenharmony_ciwill be used.
1205db71995Sopenharmony_ciEach OS has its own search order that is defined in its layer discovery
1215db71995Sopenharmony_cisection below.
1225db71995Sopenharmony_ciIf multiple manifest files in the same directory define the same layer, but
1235db71995Sopenharmony_cipoint to different library files, the order which the layers is loaded is
1245db71995Sopenharmony_ci[random due to the behavior of readdir](https://www.ibm.com/support/pages/order-directory-contents-returned-calls-readdir).
1255db71995Sopenharmony_ci
1265db71995Sopenharmony_ciAdditionally, any duplicate layer names in either the component layer list, or
1275db71995Sopenharmony_ciglobally among all enabled layers, during calls to `vkCreateInstance` or
1285db71995Sopenharmony_ci`vkCreateDevice` will simply be ignored by the loader.
1295db71995Sopenharmony_ciOnly the first occurrence of any layer name will be used.
1305db71995Sopenharmony_ci
1315db71995Sopenharmony_ci
1325db71995Sopenharmony_ci### Layer Manifest File Usage
1335db71995Sopenharmony_ci
1345db71995Sopenharmony_ciOn Windows, Linux, and macOS systems, JSON-formatted manifest files are used to
1355db71995Sopenharmony_cistore layer information.
1365db71995Sopenharmony_ciIn order to find system-installed layers, the Vulkan loader will read the JSON
1375db71995Sopenharmony_cifiles to identify the names and attributes of layers and their extensions.
1385db71995Sopenharmony_ciThe use of manifest files allows the loader to avoid loading any shared library
1395db71995Sopenharmony_cifiles when the application does not query nor request any extensions.
1405db71995Sopenharmony_ciThe format of [Layer Manifest File](#layer-manifest-file-format) is detailed
1415db71995Sopenharmony_cibelow.
1425db71995Sopenharmony_ci
1435db71995Sopenharmony_ciThe Android loader does not use manifest files.
1445db71995Sopenharmony_ciInstead, the loader queries the layer properties using special functions known
1455db71995Sopenharmony_cias "introspection" functions.
1465db71995Sopenharmony_ciThe intent of these functions is to determine the same required information
1475db71995Sopenharmony_cigathered from reading the manifest files.
1485db71995Sopenharmony_ciThese introspection functions are not used by the Khronos loader but should be
1495db71995Sopenharmony_cipresent in layers to maintain consistency.
1505db71995Sopenharmony_ciThe specific "introspection" functions are called out in the
1515db71995Sopenharmony_ci[Layer Manifest File Format](#layer-manifest-file-format) table.
1525db71995Sopenharmony_ci
1535db71995Sopenharmony_ci
1545db71995Sopenharmony_ci### Android Layer Discovery
1555db71995Sopenharmony_ci
1565db71995Sopenharmony_ciOn Android, the loader looks for layers to enumerate in the
1575db71995Sopenharmony_ci`/data/local/debug/vulkan` folder.
1585db71995Sopenharmony_ciAn application enabled for debug has the ability to enumerate and enable any
1595db71995Sopenharmony_cilayers in that location.
1605db71995Sopenharmony_ci
1615db71995Sopenharmony_ci
1625db71995Sopenharmony_ci### Windows Layer Discovery
1635db71995Sopenharmony_ci
1645db71995Sopenharmony_ciIn order to find system-installed layers, the Vulkan loader will scan the
1655db71995Sopenharmony_civalues in the following Windows registry keys:
1665db71995Sopenharmony_ci
1675db71995Sopenharmony_ci```
1685db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\ExplicitLayers
1695db71995Sopenharmony_ciHKEY_CURRENT_USER\SOFTWARE\Khronos\Vulkan\ExplicitLayers
1705db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\ImplicitLayers
1715db71995Sopenharmony_ciHKEY_CURRENT_USER\SOFTWARE\Khronos\Vulkan\ImplicitLayers
1725db71995Sopenharmony_ci```
1735db71995Sopenharmony_ci
1745db71995Sopenharmony_ciExcept when running a 32-bit application on 64-bit Windows, when the loader
1755db71995Sopenharmony_ciwill instead scan the 32-bit registry location:
1765db71995Sopenharmony_ci
1775db71995Sopenharmony_ci```
1785db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers
1795db71995Sopenharmony_ciHKEY_CURRENT_USER\SOFTWARE\WOW6432Node\Khronos\Vulkan\ExplicitLayers
1805db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Khronos\Vulkan\ImplicitLayers
1815db71995Sopenharmony_ciHKEY_CURRENT_USER\SOFTWARE\WOW6432Node\Khronos\Vulkan\ImplicitLayers
1825db71995Sopenharmony_ci```
1835db71995Sopenharmony_ci
1845db71995Sopenharmony_ciFor each value in these keys which has DWORD data set to 0, the loader opens
1855db71995Sopenharmony_cithe JSON manifest file specified by the name of the value.
1865db71995Sopenharmony_ciEach name must be an absolute path to the manifest file.
1875db71995Sopenharmony_ciAdditionally, the `HKEY_CURRENT_USER` locations will only be searched if an
1885db71995Sopenharmony_ciapplication is not being executed with administrative privileges.
1895db71995Sopenharmony_ciThis is done to ensure that an application with administrative privileges does
1905db71995Sopenharmony_cinot run layers that did not need administrator access to install.
1915db71995Sopenharmony_ci
1925db71995Sopenharmony_ciBecause some layers are installed alongside drivers, the loader will scan
1935db71995Sopenharmony_cithrough registry keys specific to Display Adapters and all Software Components
1945db71995Sopenharmony_ciassociated with these adapters for the locations of JSON manifest files.
1955db71995Sopenharmony_ciThese keys are located in device keys created during driver installation and
1965db71995Sopenharmony_cicontain configuration information for base settings, including Vulkan, OpenGL,
1975db71995Sopenharmony_ciand Direct3D ICD location.
1985db71995Sopenharmony_ci
1995db71995Sopenharmony_ciThe Device Adapter and Software Component key paths should be obtained through
2005db71995Sopenharmony_cithe PnP Configuration Manager API.
2015db71995Sopenharmony_ciThe `000X` key will be a numbered key, where each device is assigned a
2025db71995Sopenharmony_cidifferent number.
2035db71995Sopenharmony_ci
2045db71995Sopenharmony_ci```
2055db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Adapter GUID}\000X\VulkanExplicitLayers
2065db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Adapter GUID}\000X\VulkanImplicitLayers
2075db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Software Component GUID}\000X\VulkanExplicitLayers
2085db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Software Component GUID}\000X\VulkanImplicitLayers
2095db71995Sopenharmony_ci```
2105db71995Sopenharmony_ci
2115db71995Sopenharmony_ciIn addition, on 64-bit systems there may be another set of registry values,
2125db71995Sopenharmony_cilisted below.
2135db71995Sopenharmony_ciThese values record the locations of 32-bit layers on 64-bit operating systems,
2145db71995Sopenharmony_ciin the same way as the Windows-on-Windows functionality.
2155db71995Sopenharmony_ci
2165db71995Sopenharmony_ci```
2175db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Adapter GUID}\000X\VulkanExplicitLayersWow
2185db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Adapter GUID}\000X\VulkanImplicitLayersWow
2195db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Software Component GUID}\000X\VulkanExplicitLayersWow
2205db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Software Component GUID}\000X\VulkanImplicitLayersWow
2215db71995Sopenharmony_ci```
2225db71995Sopenharmony_ci
2235db71995Sopenharmony_ciIf any of the above values exist and is of type `REG_SZ`, the loader will open
2245db71995Sopenharmony_cithe JSON manifest file specified by the key value.
2255db71995Sopenharmony_ciEach value must be an absolute path to a JSON manifest file.
2265db71995Sopenharmony_ciA key value may also be of type `REG_MULTI_SZ`, in which case the value will be
2275db71995Sopenharmony_ciinterpreted as a list of paths to JSON manifest files.
2285db71995Sopenharmony_ci
2295db71995Sopenharmony_ciIn general, applications should install layers into the
2305db71995Sopenharmony_ci`SOFTWARE\Khronos\Vulkan` paths.
2315db71995Sopenharmony_ciThe PnP registry locations are intended specifically for layers that are
2325db71995Sopenharmony_cidistributed as part of a driver installation.
2335db71995Sopenharmony_ciAn application installer should not modify the device-specific registries,
2345db71995Sopenharmony_ciwhile a device driver should not modify the system registries.
2355db71995Sopenharmony_ci
2365db71995Sopenharmony_ciThe Vulkan loader will open each manifest file to obtain information about the
2375db71995Sopenharmony_cilayer, including the name or pathname of a shared library (".dll") file.
2385db71995Sopenharmony_ci
2395db71995Sopenharmony_ciIf `VK_LAYER_PATH` is defined, then the loader will look at the paths defined by
2405db71995Sopenharmony_cithat variable for explicit layer manifest files instead of using the information
2415db71995Sopenharmony_ciprovided by the explicit layer registry keys.
2425db71995Sopenharmony_ci
2435db71995Sopenharmony_ciIf `VK_ADD_LAYER_PATH` is defined, then the loader will look at the provided
2445db71995Sopenharmony_cipaths for explicit layer manifest files in addition to using the information
2455db71995Sopenharmony_ciprovided by the explicit layer registry keys.
2465db71995Sopenharmony_ciThe paths provided by `VK_ADD_LAYER_PATH` are added before the standard list
2475db71995Sopenharmony_ciof search folders and will therefore be searched first.
2485db71995Sopenharmony_ci
2495db71995Sopenharmony_ciIf `VK_LAYER_PATH` is present, then `VK_ADD_LAYER_PATH` will not be used by the
2505db71995Sopenharmony_ciloader and any values will be ignored.
2515db71995Sopenharmony_ci
2525db71995Sopenharmony_ciFor security reasons, both `VK_LAYER_PATH` and `VK_ADD_LAYER_PATH` are ignored
2535db71995Sopenharmony_ciif running with elevated privileges.
2545db71995Sopenharmony_ciSee [Exception for Elevated Privileges](#exception-for-elevated-privileges)
2555db71995Sopenharmony_cifor more info.
2565db71995Sopenharmony_ci
2575db71995Sopenharmony_ciSee
2585db71995Sopenharmony_ci[Forcing Layer Source Folders](LoaderApplicationInterface.md#forcing-layer-source-folders)
2595db71995Sopenharmony_ciin the [LoaderApplicationInterface.md document](LoaderApplicationInterface.md)
2605db71995Sopenharmony_cifor more information on this.
2615db71995Sopenharmony_ci
2625db71995Sopenharmony_ci
2635db71995Sopenharmony_ci### Linux Layer Discovery
2645db71995Sopenharmony_ci
2655db71995Sopenharmony_ciOn Linux, the Vulkan loader will scan for manifest files using environment
2665db71995Sopenharmony_civariables or corresponding fallback values if the corresponding environment
2675db71995Sopenharmony_civariable is not defined:
2685db71995Sopenharmony_ci
2695db71995Sopenharmony_ci<table style="width:100%">
2705db71995Sopenharmony_ci  <tr>
2715db71995Sopenharmony_ci    <th>Search Order</th>
2725db71995Sopenharmony_ci    <th>Directory/Environment Variable</th>
2735db71995Sopenharmony_ci    <th>Fallback</th>
2745db71995Sopenharmony_ci    <th>Additional Notes</th>
2755db71995Sopenharmony_ci  </tr>
2765db71995Sopenharmony_ci  <tr>
2775db71995Sopenharmony_ci    <td>1</td>
2785db71995Sopenharmony_ci    <td>$XDG_CONFIG_HOME</td>
2795db71995Sopenharmony_ci    <td>$HOME/.config</td>
2805db71995Sopenharmony_ci    <td><b>This path is ignored when running with elevated privileges such as
2815db71995Sopenharmony_ci           setuid, setgid, or filesystem capabilities</b>.<br/>
2825db71995Sopenharmony_ci        This is done because under these scenarios it is not safe to trust
2835db71995Sopenharmony_ci        that the environment variables are non-malicious.
2845db71995Sopenharmony_ci    </td>
2855db71995Sopenharmony_ci  </tr>
2865db71995Sopenharmony_ci  <tr>
2875db71995Sopenharmony_ci    <td>1</td>
2885db71995Sopenharmony_ci    <td>$XDG_CONFIG_DIRS</td>
2895db71995Sopenharmony_ci    <td>/etc/xdg</td>
2905db71995Sopenharmony_ci    <td></td>
2915db71995Sopenharmony_ci  </tr>
2925db71995Sopenharmony_ci  <tr>
2935db71995Sopenharmony_ci    <td>2</td>
2945db71995Sopenharmony_ci    <td>SYSCONFDIR</td>
2955db71995Sopenharmony_ci    <td>/etc</td>
2965db71995Sopenharmony_ci    <td>Compile-time option set to possible location of layers installed from
2975db71995Sopenharmony_ci        non-Linux-distribution-provided packages.
2985db71995Sopenharmony_ci    </td>
2995db71995Sopenharmony_ci  </tr>
3005db71995Sopenharmony_ci  <tr>
3015db71995Sopenharmony_ci    <td>3</td>
3025db71995Sopenharmony_ci    <td>EXTRASYSCONFDIR</td>
3035db71995Sopenharmony_ci    <td>/etc</td>
3045db71995Sopenharmony_ci    <td>Compile-time option set to possible location of layers installed from
3055db71995Sopenharmony_ci        non-Linux-distribution-provided packages.
3065db71995Sopenharmony_ci        Typically only set if SYSCONFDIR is set to something other than /etc
3075db71995Sopenharmony_ci    </td>
3085db71995Sopenharmony_ci  </tr>
3095db71995Sopenharmony_ci  <tr>
3105db71995Sopenharmony_ci    <td>4</td>
3115db71995Sopenharmony_ci    <td>$XDG_DATA_HOME</td>
3125db71995Sopenharmony_ci    <td>$HOME/.local/share</td>
3135db71995Sopenharmony_ci    <td><b>This path is ignored when running with elevated privileges such as
3145db71995Sopenharmony_ci           setuid, setgid, or filesystem capabilities</b>.<br/>
3155db71995Sopenharmony_ci        This is done because under these scenarios it is not safe to trust
3165db71995Sopenharmony_ci        that the environment variables are non-malicious.
3175db71995Sopenharmony_ci    </td>
3185db71995Sopenharmony_ci  </tr>
3195db71995Sopenharmony_ci  <tr>
3205db71995Sopenharmony_ci    <td>5</td>
3215db71995Sopenharmony_ci    <td>$XDG_DATA_DIRS</td>
3225db71995Sopenharmony_ci    <td>/usr/local/share/:/usr/share/</td>
3235db71995Sopenharmony_ci    <td></td>
3245db71995Sopenharmony_ci  </tr>
3255db71995Sopenharmony_ci</table>
3265db71995Sopenharmony_ci
3275db71995Sopenharmony_ciThe directory lists are concatenated together using the standard platform path
3285db71995Sopenharmony_ciseparator (:).
3295db71995Sopenharmony_ciThe loader then selects each path, and applies a suffix onto it for the specific
3305db71995Sopenharmony_citype of layer being searched for and looks in that specific folder for
3315db71995Sopenharmony_cimanifest files:
3325db71995Sopenharmony_ci
3335db71995Sopenharmony_ci  * Implicit Layers:  Suffix =  /vulkan/implicit_layer.d
3345db71995Sopenharmony_ci  * Explicit Layers:  Suffix =  /vulkan/explicit_layer.d
3355db71995Sopenharmony_ci
3365db71995Sopenharmony_ciIf `VK_LAYER_PATH` is defined, then the loader will look at the paths defined by
3375db71995Sopenharmony_cithat variable for explicit layer manifest files instead of using the information
3385db71995Sopenharmony_ciprovided by the standard explicit layer paths mentioned above.
3395db71995Sopenharmony_ci
3405db71995Sopenharmony_ciIf `VK_ADD_LAYER_PATH` is defined, then the loader will look at the provided
3415db71995Sopenharmony_cipaths for explicit layer manifest files in addition to using the information
3425db71995Sopenharmony_ciprovided by the standard explicit layer paths mentioned above.
3435db71995Sopenharmony_ciThe paths provided by `VK_ADD_LAYER_PATH` are added before the standard list
3445db71995Sopenharmony_ciof search folders and will therefore be searched first.
3455db71995Sopenharmony_ci
3465db71995Sopenharmony_ciIf `VK_LAYER_PATH` is present, then `VK_ADD_LAYER_PATH` will not be used by the
3475db71995Sopenharmony_ciloader and any values will be ignored.
3485db71995Sopenharmony_ci
3495db71995Sopenharmony_ciFor security reasons, both `VK_LAYER_PATH` and `VK_ADD_LAYER_PATH` are ignored
3505db71995Sopenharmony_ciif running with elevated privileges.
3515db71995Sopenharmony_ciSee [Exception for Elevated Privileges](#exception-for-elevated-privileges)
3525db71995Sopenharmony_cifor more info.
3535db71995Sopenharmony_ci
3545db71995Sopenharmony_ci**NOTE** While the order of folders searched for manifest files is well
3555db71995Sopenharmony_cidefined, the order contents are read by the loader in each directory is
3565db71995Sopenharmony_ci[random due to the behavior of readdir](https://www.ibm.com/support/pages/order-directory-contents-returned-calls-readdir).
3575db71995Sopenharmony_ci
3585db71995Sopenharmony_ciSee
3595db71995Sopenharmony_ci[Forcing Layer Source Folders](LoaderApplicationInterface.md#forcing-layer-source-folders)
3605db71995Sopenharmony_ciin the [LoaderApplicationInterface.md document](LoaderApplicationInterface.md)
3615db71995Sopenharmony_cifor more information on this.
3625db71995Sopenharmony_ci
3635db71995Sopenharmony_ciIt is also important to note that while both `VK_LAYER_PATH` and
3645db71995Sopenharmony_ci`VK_ADD_LAYER_PATH` will point the loader paths to search for finding the
3655db71995Sopenharmony_cimanifest files, it does not guarantee the library files mentioned by the
3665db71995Sopenharmony_cimanifest will immediately be found.
3675db71995Sopenharmony_ciOften, the layer manifest file will point to the library file using a relative
3685db71995Sopenharmony_cior absolute path.
3695db71995Sopenharmony_ciWhen a relative or absolute path is used, the loader can typically find the
3705db71995Sopenharmony_cilibrary file without querying the operating system.
3715db71995Sopenharmony_ciHowever, if a library is listed only by name, the loader may not find it.
3725db71995Sopenharmony_ciIf problems occur finding a library file associated with a layer, try updating
3735db71995Sopenharmony_cithe `LD_LIBRARY_PATH` environment variable to point at the location of the
3745db71995Sopenharmony_cicorresponding `.so` file.
3755db71995Sopenharmony_ci
3765db71995Sopenharmony_ci
3775db71995Sopenharmony_ci#### Example Linux Explicit Layer Search Path
3785db71995Sopenharmony_ci
3795db71995Sopenharmony_ciFor a fictional user "me" the layer manifest search path might look like the
3805db71995Sopenharmony_cifollowing:
3815db71995Sopenharmony_ci
3825db71995Sopenharmony_ci```
3835db71995Sopenharmony_ci  /home/me/.config/vulkan/explicit_layer.d
3845db71995Sopenharmony_ci  /etc/xdg/vulkan/explicit_layer.d
3855db71995Sopenharmony_ci  /usr/local/etc/vulkan/explicit_layer.d
3865db71995Sopenharmony_ci  /etc/vulkan/explicit_layer.d
3875db71995Sopenharmony_ci  /home/me/.local/share/vulkan/explicit_layer.d
3885db71995Sopenharmony_ci  /usr/local/share/vulkan/explicit_layer.d
3895db71995Sopenharmony_ci  /usr/share/vulkan/explicit_layer.d
3905db71995Sopenharmony_ci```
3915db71995Sopenharmony_ci
3925db71995Sopenharmony_ci### Fuchsia Layer Discovery
3935db71995Sopenharmony_ci
3945db71995Sopenharmony_ciOn Fuchsia, the Vulkan loader will scan for manifest files using environment
3955db71995Sopenharmony_civariables or corresponding fallback values if the corresponding environment
3965db71995Sopenharmony_civariable is not defined in the same way as [Linux](#linux-layer-discovery).
3975db71995Sopenharmony_ciThe **only** difference is that Fuchsia does not allow fallback values for
3985db71995Sopenharmony_ci*$XDG_DATA_DIRS* or *$XDG_HOME_DIRS*.
3995db71995Sopenharmony_ci
4005db71995Sopenharmony_ci
4015db71995Sopenharmony_ci### macOS Layer Discovery
4025db71995Sopenharmony_ci
4035db71995Sopenharmony_ciOn macOS, the Vulkan loader will scan for manifest files using the application
4045db71995Sopenharmony_ciresource folder as well as environment variables or corresponding fallback
4055db71995Sopenharmony_civalues if the corresponding environment variable is not defined.
4065db71995Sopenharmony_ciThe order is similar to the search path on Linux with the exception that
4075db71995Sopenharmony_cithe application's bundle resources are searched first:
4085db71995Sopenharmony_ci`(bundle)/Contents/Resources/`.
4095db71995Sopenharmony_ci
4105db71995Sopenharmony_ci#### Example macOS Implicit Layer Search Path
4115db71995Sopenharmony_ci
4125db71995Sopenharmony_ciFor a fictional user "Me" the layer manifest search path might look like the
4135db71995Sopenharmony_cifollowing:
4145db71995Sopenharmony_ci
4155db71995Sopenharmony_ci```
4165db71995Sopenharmony_ci  <bundle>/Contents/Resources/vulkan/implicit_layer.d
4175db71995Sopenharmony_ci  /Users/Me/.config/vulkan/implicit_layer.d
4185db71995Sopenharmony_ci  /etc/xdg/vulkan/implicit_layer.d
4195db71995Sopenharmony_ci  /usr/local/etc/vulkan/implicit_layer.d
4205db71995Sopenharmony_ci  /etc/vulkan/implicit_layer.d
4215db71995Sopenharmony_ci  /Users/Me/.local/share/vulkan/implicit_layer.d
4225db71995Sopenharmony_ci  /usr/local/share/vulkan/implicit_layer.d
4235db71995Sopenharmony_ci  /usr/share/vulkan/implicit_layer.d
4245db71995Sopenharmony_ci```
4255db71995Sopenharmony_ci
4265db71995Sopenharmony_ci### Layer Filtering
4275db71995Sopenharmony_ci
4285db71995Sopenharmony_ci**NOTE:** This functionality is only available with Loaders built with version
4295db71995Sopenharmony_ci1.3.234 of the Vulkan headers and later.
4305db71995Sopenharmony_ci
4315db71995Sopenharmony_ciThe loader supports filter environment variables which can forcibly enable and
4325db71995Sopenharmony_cidisable known layers.
4335db71995Sopenharmony_ciKnown layers are those that are already found by the loader taking into account
4345db71995Sopenharmony_cidefault search paths and other environment variables
4355db71995Sopenharmony_ci(like `VK_LAYER_PATH` or `VK_ADD_LAYER_PATH`).
4365db71995Sopenharmony_ci
4375db71995Sopenharmony_ciThe filter variables will be compared against the layer name provided in the
4385db71995Sopenharmony_cilayer's manifest file.
4395db71995Sopenharmony_ci
4405db71995Sopenharmony_ciThe filters must also follow the behaviors define in the
4415db71995Sopenharmony_ci[Filter Environment Variable Behaviors](LoaderInterfaceArchitecture.md#filter-environment-variable-behaviors)
4425db71995Sopenharmony_cisection of the [LoaderLayerInterface](LoaderLayerInterface.md) document.
4435db71995Sopenharmony_ci
4445db71995Sopenharmony_ci#### Layer Enable Filtering
4455db71995Sopenharmony_ci
4465db71995Sopenharmony_ciThe layer enable environment variable `VK_LOADER_LAYERS_ENABLE` is a
4475db71995Sopenharmony_cicomma-delimited list of globs to search for in known layers.
4485db71995Sopenharmony_ciThe layer names are compared against the globs listed in the environment
4495db71995Sopenharmony_civariable, and if they match, they will automatically be added to the enabled
4505db71995Sopenharmony_cilayer list in the loader for each application.
4515db71995Sopenharmony_ciThese layers are enabled after implicit layers but before other explicit layers.
4525db71995Sopenharmony_ci
4535db71995Sopenharmony_ciWhen a layer is enabled using the `VK_LOADER_LAYERS_ENABLE` filter, and
4545db71995Sopenharmony_ciloader logging is set to emit either warnings or layer messages, then a message
4555db71995Sopenharmony_ciwill show for each layer that has been forced on.
4565db71995Sopenharmony_ciThis message will look like the following:
4575db71995Sopenharmony_ci
4585db71995Sopenharmony_ci```
4595db71995Sopenharmony_ciWARNING | LAYER:  Layer "VK_LAYER_LUNARG_wrap_objects" force enabled due to env var 'VK_LOADER_LAYERS_ENABLE'
4605db71995Sopenharmony_ci```
4615db71995Sopenharmony_ci
4625db71995Sopenharmony_ci#### Layer Disable Filtering
4635db71995Sopenharmony_ci
4645db71995Sopenharmony_ciThe layer disable environment variable `VK_LOADER_LAYERS_DISABLE` is a
4655db71995Sopenharmony_cicomma-delimited list of globs to search for in known layers.
4665db71995Sopenharmony_ciThe layer names are compared against the globs listed in the environment
4675db71995Sopenharmony_civariable, and if they match, they will automatically be disabled (whether or not
4685db71995Sopenharmony_cithe layer is Implicit or Explicit).
4695db71995Sopenharmony_ciThis means that they will not be added to the enabled layer list in the loader
4705db71995Sopenharmony_cifor each application.
4715db71995Sopenharmony_ciThis could mean that layers requested by an application are also not enabled
4725db71995Sopenharmony_cisuch as `VK_KHRONOS_LAYER_synchronization2` which could cause some applications
4735db71995Sopenharmony_cito misbehave.
4745db71995Sopenharmony_ci
4755db71995Sopenharmony_ciWhen a layer is disabled using the `VK_LOADER_LAYERS_DISABLE` filter, and
4765db71995Sopenharmony_ciloader logging is set to emit either warnings or layer messages, then a message
4775db71995Sopenharmony_ciwill show for each layer that has been forcibly disabled.
4785db71995Sopenharmony_ciThis message will look like the following:
4795db71995Sopenharmony_ci
4805db71995Sopenharmony_ci```
4815db71995Sopenharmony_ciWARNING | LAYER:  Layer "VK_LAYER_LUNARG_wrap_objects" disabled because name matches filter of env var 'VK_LOADER_LAYERS_DISABLE'
4825db71995Sopenharmony_ci```
4835db71995Sopenharmony_ci
4845db71995Sopenharmony_ci#### Layer Special Case Disable
4855db71995Sopenharmony_ci
4865db71995Sopenharmony_ciBecause there are different types of layers, there are 3 additional special
4875db71995Sopenharmony_cidisable options available when using the `VK_LOADER_LAYERS_DISABLE` environment
4885db71995Sopenharmony_civariable.
4895db71995Sopenharmony_ci
4905db71995Sopenharmony_ciThese are:
4915db71995Sopenharmony_ci
4925db71995Sopenharmony_ci  * `~all~`
4935db71995Sopenharmony_ci  * `~implicit~`
4945db71995Sopenharmony_ci  * `~explicit~`
4955db71995Sopenharmony_ci
4965db71995Sopenharmony_ci`~all~` will effectively disable every layer.
4975db71995Sopenharmony_ciThis enables a developer to disable all layers on the system.
4985db71995Sopenharmony_ci`~implicit~` will effectively disable every implicit layer (leaving explicit
4995db71995Sopenharmony_cilayers still present in the application call chain).
5005db71995Sopenharmony_ci`~explicit~` will effectively disable every explicit layer (leaving implicit
5015db71995Sopenharmony_cilayers still present in the application call chain).
5025db71995Sopenharmony_ci
5035db71995Sopenharmony_ci#### Layer Disable Warning
5045db71995Sopenharmony_ci
5055db71995Sopenharmony_ciDisabling layers, whether just through normal usage of
5065db71995Sopenharmony_ci`VK_LOADER_LAYERS_DISABLE` or by evoking one of the special disable options like
5075db71995Sopenharmony_ci`~all~` or `~explicit~` could cause application breakage if the application is
5085db71995Sopenharmony_cirelying on features provided by one or more explicit layers.
5095db71995Sopenharmony_ci
5105db71995Sopenharmony_ci#### Allow certain Layers to ignore Layer Disabling
5115db71995Sopenharmony_ci
5125db71995Sopenharmony_ci**NOTE:** VK_LOADER_LAYERS_DISABLE is only available with Loaders built with version
5135db71995Sopenharmony_ci1.3.262 of the Vulkan headers and later.
5145db71995Sopenharmony_ci
5155db71995Sopenharmony_ciThe layer allow environment variable `VK_LOADER_LAYERS_ALLOW` is a
5165db71995Sopenharmony_cicomma-delimited list of globs to search for in known layers.
5175db71995Sopenharmony_ciThe layer names are compared against the globs listed in the environment
5185db71995Sopenharmony_civariable, and if they match, they will not be able to be disabled by
5195db71995Sopenharmony_ci`VK_LOADER_LAYERS_DISABLE`.
5205db71995Sopenharmony_ci
5215db71995Sopenharmony_ciImplicit layers have the ability to only be enabled when a layer specified
5225db71995Sopenharmony_cienvironment variable is set, allow for context dependent enablement.
5235db71995Sopenharmony_ci`VK_LOADER_LAYERS_ENABLE` ignores that context.
5245db71995Sopenharmony_ci`VK_LOADER_LAYERS_ALLOW` behaves similar to `VK_LOADER_LAYERS_ENABLE` while
5255db71995Sopenharmony_cialso respecting the context which is normally used to determine whether an
5265db71995Sopenharmony_ciimplicit layer should be enabled.
5275db71995Sopenharmony_ci
5285db71995Sopenharmony_ci`VK_LOADER_LAYERS_ALLOW` effectively negates the behavior of
5295db71995Sopenharmony_ci`VK_LOADER_LAYERS_DISABLE`.
5305db71995Sopenharmony_ciExplicit layers listed by `VK_LOADER_LAYERS_ALLOW` will not be enabled.
5315db71995Sopenharmony_ciImplicit layers listed by ``VK_LOADER_LAYERS_ALLOW` which are always active,
5325db71995Sopenharmony_cii.e. they do not require any external context to be enabled, will be enabled.
5335db71995Sopenharmony_ci
5345db71995Sopenharmony_ci##### `VK_INSTANCE_LAYERS`
5355db71995Sopenharmony_ci
5365db71995Sopenharmony_ciThe original `VK_INSTANCE_LAYERS` can be viewed as a special case of the new
5375db71995Sopenharmony_ci`VK_LOADER_LAYERS_ENABLE`.
5385db71995Sopenharmony_ciBecause of this, any layers enabled via `VK_INSTANCE_LAYERS` will be treated the
5395db71995Sopenharmony_cisame as layers enabled with `VK_LOADER_LAYERS_ENABLE` and will therefore
5405db71995Sopenharmony_cioverride any disables supplied in `VK_LOADER_LAYERS_DISABLE`.
5415db71995Sopenharmony_ci
5425db71995Sopenharmony_ci### Exception for Elevated Privileges
5435db71995Sopenharmony_ci
5445db71995Sopenharmony_ciFor security reasons, `VK_LAYER_PATH` and `VK_ADD_LAYER_PATH` are ignored if
5455db71995Sopenharmony_cirunning the Vulkan application with elevated privileges.
5465db71995Sopenharmony_ciThis is because they may insert new libraries into the executable process that
5475db71995Sopenharmony_ciare not normally found by the loader.
5485db71995Sopenharmony_ciBecause of this, these environment variables can only be used for applications
5495db71995Sopenharmony_cithat do not use elevated privileges.
5505db71995Sopenharmony_ci
5515db71995Sopenharmony_ciFor more information see
5525db71995Sopenharmony_ci[Elevated Privilege Caveats](LoaderInterfaceArchitecture.md#elevated-privilege-caveats)
5535db71995Sopenharmony_ciin the top-level
5545db71995Sopenharmony_ci[LoaderInterfaceArchitecture.md][LoaderInterfaceArchitecture.md] document.
5555db71995Sopenharmony_ci
5565db71995Sopenharmony_ci## Layer Version Negotiation
5575db71995Sopenharmony_ci
5585db71995Sopenharmony_ciNow that a layer has been discovered, an application can choose to load it, or
5595db71995Sopenharmony_ciin the case of implicit layers, it can be loaded by default.
5605db71995Sopenharmony_ciWhen the loader attempts to load the layer, the first thing it does is attempt
5615db71995Sopenharmony_cito negotiate the version of the loader to layer interface.
5625db71995Sopenharmony_ciIn order to negotiate the loader/layer interface version, the layer must
5635db71995Sopenharmony_ciimplement the `vkNegotiateLoaderLayerInterfaceVersion` function.
5645db71995Sopenharmony_ciThe following information is provided for this interface in
5655db71995Sopenharmony_ciinclude/vulkan/vk_layer.h:
5665db71995Sopenharmony_ci
5675db71995Sopenharmony_ci```cpp
5685db71995Sopenharmony_citypedef enum VkNegotiateLayerStructType {
5695db71995Sopenharmony_ci    LAYER_NEGOTIATE_INTERFACE_STRUCT = 1,
5705db71995Sopenharmony_ci} VkNegotiateLayerStructType;
5715db71995Sopenharmony_ci
5725db71995Sopenharmony_citypedef struct VkNegotiateLayerInterface {
5735db71995Sopenharmony_ci    VkNegotiateLayerStructType sType;
5745db71995Sopenharmony_ci    void *pNext;
5755db71995Sopenharmony_ci    uint32_t loaderLayerInterfaceVersion;
5765db71995Sopenharmony_ci    PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr;
5775db71995Sopenharmony_ci    PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr;
5785db71995Sopenharmony_ci    PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr;
5795db71995Sopenharmony_ci} VkNegotiateLayerInterface;
5805db71995Sopenharmony_ci
5815db71995Sopenharmony_ciVkResult
5825db71995Sopenharmony_ci   vkNegotiateLoaderLayerInterfaceVersion(
5835db71995Sopenharmony_ci      VkNegotiateLayerInterface *pVersionStruct);
5845db71995Sopenharmony_ci```
5855db71995Sopenharmony_ci
5865db71995Sopenharmony_ciThe `VkNegotiateLayerInterface` structure is similar to other Vulkan structures.
5875db71995Sopenharmony_ciThe "sType" field, in this case takes a new enum defined just for internal
5885db71995Sopenharmony_ciloader/layer interfacing use.
5895db71995Sopenharmony_ciThe valid values for "sType" could grow in the future, but right now only
5905db71995Sopenharmony_cihas the one value "LAYER_NEGOTIATE_INTERFACE_STRUCT".
5915db71995Sopenharmony_ci
5925db71995Sopenharmony_ciThis function (`vkNegotiateLoaderLayerInterfaceVersion`) should be exported by
5935db71995Sopenharmony_cithe layer so that using "GetProcAddress" on Windows or "dlsym" on Linux or
5945db71995Sopenharmony_cimacOS, should return a valid function pointer to it.
5955db71995Sopenharmony_ciOnce the loader has grabbed a valid address to the layers function, the loader
5965db71995Sopenharmony_ciwill create a variable of type `VkNegotiateLayerInterface` and initialize it
5975db71995Sopenharmony_ciin the following ways:
5985db71995Sopenharmony_ci 1. Set the structure "sType" to "LAYER_NEGOTIATE_INTERFACE_STRUCT"
5995db71995Sopenharmony_ci 2. Set pNext to NULL.
6005db71995Sopenharmony_ci     - This is for future growth
6015db71995Sopenharmony_ci 3. Set "loaderLayerInterfaceVersion" to the current version the loader desires
6025db71995Sopenharmony_cito set the interface to.
6035db71995Sopenharmony_ci      - The minimum value sent by the loader will be 2 since it is the first
6045db71995Sopenharmony_civersion supporting this function.
6055db71995Sopenharmony_ci
6065db71995Sopenharmony_ciThe loader will then individually call each layer’s
6075db71995Sopenharmony_ci`vkNegotiateLoaderLayerInterfaceVersion` function with the filled out
6085db71995Sopenharmony_ci“VkNegotiateLayerInterface”.
6095db71995Sopenharmony_ci
6105db71995Sopenharmony_ciThis function allows the loader and layer to agree on an interface version to
6115db71995Sopenharmony_ciuse.
6125db71995Sopenharmony_ciThe "loaderLayerInterfaceVersion" field is both an input and output parameter.
6135db71995Sopenharmony_ci"loaderLayerInterfaceVersion" is filled in by the loader with the desired
6145db71995Sopenharmony_cilatest interface version supported by the loader (typically the latest).
6155db71995Sopenharmony_ciThe layer receives this and returns back the version it desires in the same
6165db71995Sopenharmony_cifield.
6175db71995Sopenharmony_ciBecause it is setting up the interface version between the loader and layer,
6185db71995Sopenharmony_cithis should be the first call made by a loader to the layer (even prior to any
6195db71995Sopenharmony_cicalls to `vkGetInstanceProcAddr`).
6205db71995Sopenharmony_ci
6215db71995Sopenharmony_ciIf the layer receiving the call no longer supports the interface version
6225db71995Sopenharmony_ciprovided by the loader (due to deprecation), then it should report a
6235db71995Sopenharmony_ci`VK_ERROR_INITIALIZATION_FAILED` error.
6245db71995Sopenharmony_ciOtherwise it sets the value pointed by "loaderLayerInterfaceVersion" to the
6255db71995Sopenharmony_cilatest interface version supported by both the layer and the loader and returns
6265db71995Sopenharmony_ci`VK_SUCCESS`.
6275db71995Sopenharmony_ci
6285db71995Sopenharmony_ciThe layer should report `VK_SUCCESS` in case the loader-provided interface
6295db71995Sopenharmony_civersion is newer than that supported by the layer, as it's the loader's
6305db71995Sopenharmony_ciresponsibility to determine whether it can support the older interface version
6315db71995Sopenharmony_cisupported by the layer.
6325db71995Sopenharmony_ciThe layer should also report `VK_SUCCESS` in the case its interface version is
6335db71995Sopenharmony_cigreater than the loader's, but return the loader's version.
6345db71995Sopenharmony_ciThus, upon return of `VK_SUCCESS` the "loaderLayerInterfaceVersion" will contain
6355db71995Sopenharmony_cithe desired interface version to be used by the layer.
6365db71995Sopenharmony_ci
6375db71995Sopenharmony_ciIf the loader receives `VK_ERROR_INITIALIZATION_FAILED` instead of `VK_SUCCESS`,
6385db71995Sopenharmony_cithen the loader will treat the layer as unusable and will not load it.
6395db71995Sopenharmony_ciIn this case, the application will not see the layer during enumeration.
6405db71995Sopenharmony_ci*Note that the loader is currently backwards compatible with all layer
6415db71995Sopenharmony_ciinterface versions, so a layer should not be able to request a version
6425db71995Sopenharmony_ciolder than what the loader supports.*
6435db71995Sopenharmony_ci
6445db71995Sopenharmony_ciThis function **MUST NOT** call down the layer chain to the next layer.
6455db71995Sopenharmony_ciThe loader will work with each layer individually.
6465db71995Sopenharmony_ci
6475db71995Sopenharmony_ciIf the layer supports the new interface and reports version 2 or greater, then
6485db71995Sopenharmony_ciThe layer should fill in the function pointer values to its internal
6495db71995Sopenharmony_cifunctions:
6505db71995Sopenharmony_ci    - "pfnGetInstanceProcAddr" should be set to the layer’s internal
6515db71995Sopenharmony_ci`GetInstanceProcAddr` function.
6525db71995Sopenharmony_ci    - "pfnGetDeviceProcAddr" should be set to the layer’s internal
6535db71995Sopenharmony_ci`GetDeviceProcAddr` function.
6545db71995Sopenharmony_ci    - "pfnGetPhysicalDeviceProcAddr" should be set to the layer’s internal
6555db71995Sopenharmony_ci`GetPhysicalDeviceProcAddr` function.
6565db71995Sopenharmony_ci      - If the layer supports no physical device extensions, it may set the
6575db71995Sopenharmony_civalue to NULL.
6585db71995Sopenharmony_ci      - More on this function later
6595db71995Sopenharmony_cithe loader will use the “fpGetInstanceProcAddr” and “fpGetDeviceProcAddr”
6605db71995Sopenharmony_cifunctions from the “VkNegotiateLayerInterface” structure.
6615db71995Sopenharmony_ciPrior to these changes, the loader would query each of those functions using
6625db71995Sopenharmony_ci"GetProcAddress" on Windows or "dlsym" on Linux or macOS.
6635db71995Sopenharmony_ci
6645db71995Sopenharmony_ci
6655db71995Sopenharmony_ci## Layer Call Chains and Distributed Dispatch
6665db71995Sopenharmony_ci
6675db71995Sopenharmony_ciThere are two key architectural features that drive the loader to
6685db71995Sopenharmony_ci`Layer Library` interface:
6695db71995Sopenharmony_ci 1. Separate and distinct instance and device call chains
6705db71995Sopenharmony_ci 2. Distributed dispatch.
6715db71995Sopenharmony_ci
6725db71995Sopenharmony_ciFor further information, read the overview of dispatch tables and call chains
6735db71995Sopenharmony_ciabove in the
6745db71995Sopenharmony_ci[Dispatch Tables and Call Chains](LoaderInterfaceArchitecture.md#dispatch-tables-and-call-chains)
6755db71995Sopenharmony_cisection of the
6765db71995Sopenharmony_ci[LoaderInterfaceArchitecture.md document](LoaderInterfaceArchitecture.md).
6775db71995Sopenharmony_ci
6785db71995Sopenharmony_ciWhat's important to note here is that a layer can intercept Vulkan instance
6795db71995Sopenharmony_cifunctions, device functions or both.
6805db71995Sopenharmony_ciFor a layer to intercept instance functions, it must participate in the
6815db71995Sopenharmony_ciinstance call chain.
6825db71995Sopenharmony_ciFor a layer to intercept device functions, it must participate in the device
6835db71995Sopenharmony_cicall chain.
6845db71995Sopenharmony_ci
6855db71995Sopenharmony_ciRemember, a layer does not need to intercept all instance or device functions,
6865db71995Sopenharmony_ciinstead, it can choose to intercept only a subset of those functions.
6875db71995Sopenharmony_ci
6885db71995Sopenharmony_ciNormally, when a layer intercepts a given Vulkan function, it will call down
6895db71995Sopenharmony_cithe instance or device call chain as needed.
6905db71995Sopenharmony_ciThe loader and all layer libraries that participate in a call chain cooperate
6915db71995Sopenharmony_cito ensure the correct sequencing of calls from one entity to the next.
6925db71995Sopenharmony_ciThis group effort for call chain sequencing is hereinafter referred to as
6935db71995Sopenharmony_ci**distributed dispatch**.
6945db71995Sopenharmony_ci
6955db71995Sopenharmony_ciIn distributed dispatch each layer is responsible for properly calling the next
6965db71995Sopenharmony_cientity in the call chain.
6975db71995Sopenharmony_ciThis means that a dispatch mechanism is required for all Vulkan functions that
6985db71995Sopenharmony_cia layer intercepts.
6995db71995Sopenharmony_ciIf a Vulkan function is not intercepted by a layer, or if a layer chooses to
7005db71995Sopenharmony_citerminate the function by not calling down the chain, then no dispatch is
7015db71995Sopenharmony_cineeded for that particular function.
7025db71995Sopenharmony_ci
7035db71995Sopenharmony_ciFor example, if the enabled layers intercepted only certain instance functions,
7045db71995Sopenharmony_cithe call chain would look as follows:
7055db71995Sopenharmony_ci![Instance Function Chain](./images/function_instance_chain.png)
7065db71995Sopenharmony_ci
7075db71995Sopenharmony_ciLikewise, if the enabled layers intercepted only a few of the device functions,
7085db71995Sopenharmony_cithe call chain could look this way:
7095db71995Sopenharmony_ci![Device Function Chain](./images/function_device_chain.png)
7105db71995Sopenharmony_ci
7115db71995Sopenharmony_ciThe loader is responsible for dispatching all core and instance extension Vulkan
7125db71995Sopenharmony_cifunctions to the first entity in the call chain.
7135db71995Sopenharmony_ci
7145db71995Sopenharmony_ci
7155db71995Sopenharmony_ci## Layer Unknown Physical Device Extensions
7165db71995Sopenharmony_ci
7175db71995Sopenharmony_ciLayers that intercept entrypoints which take a `VkPhysicalDevice` as the first
7185db71995Sopenharmony_ciparameter *should* support `vk_layerGetPhysicalDeviceProcAddr`. This function
7195db71995Sopenharmony_ciis added to the Layer Interface Version 2 and allows the loader to distinguish
7205db71995Sopenharmony_cibetween entrypoints which take `VkDevice` and `VkPhysicalDevice` as the first
7215db71995Sopenharmony_ciparameter. This allows the loader to properly support entrypoints that are
7225db71995Sopenharmony_ciunknown to it gracefully.
7235db71995Sopenharmony_ci
7245db71995Sopenharmony_ci```cpp
7255db71995Sopenharmony_ciPFN_vkVoidFunction
7265db71995Sopenharmony_ci   vk_layerGetPhysicalDeviceProcAddr(
7275db71995Sopenharmony_ci      VkInstance instance,
7285db71995Sopenharmony_ci      const char* pName);
7295db71995Sopenharmony_ci```
7305db71995Sopenharmony_ci
7315db71995Sopenharmony_ciThis function behaves similar to `vkGetInstanceProcAddr` and
7325db71995Sopenharmony_ci`vkGetDeviceProcAddr` except it should only return values for physical device
7335db71995Sopenharmony_ciextension entry-points.
7345db71995Sopenharmony_ciIn this way, it compares "pName" to every physical device function supported
7355db71995Sopenharmony_ciin the layer.
7365db71995Sopenharmony_ci
7375db71995Sopenharmony_ciImplementations of the function should have the following behavior:
7385db71995Sopenharmony_ci  * If it is the name of a physical device function supported by the layer,
7395db71995Sopenharmony_cithe pointer to the layer's corresponding function should be returned.
7405db71995Sopenharmony_ci  * If it is the name of a valid function which is **not** a physical device
7415db71995Sopenharmony_cifunction (i.e. an instance, device, or other function implemented by the
7425db71995Sopenharmony_cilayer), then the value of NULL should be returned.
7435db71995Sopenharmony_ci    * The layer doesn't call down since the command is not a physical device
7445db71995Sopenharmony_ci extension.
7455db71995Sopenharmony_ci  * If the layer has no idea what this function is, it should call down the
7465db71995Sopenharmony_cilayer chain to the next `vk_layerGetPhysicalDeviceProcAddr` call.
7475db71995Sopenharmony_ci    * This can be retrieved in one of two ways:
7485db71995Sopenharmony_ci      * During `vkCreateInstance`, it is passed to a layer in the chain
7495db71995Sopenharmony_ciinformation passed to a layer in the `VkLayerInstanceCreateInfo` structure.
7505db71995Sopenharmony_ci        * Use `get_chain_info()` to get the pointer to the
7515db71995Sopenharmony_ci`VkLayerInstanceCreateInfo` structure.  Let's call it chain_info.
7525db71995Sopenharmony_ci        * The address is then under
7535db71995Sopenharmony_cichain_info->u.pLayerInfo->pfnNextGetPhysicalDeviceProcAddr
7545db71995Sopenharmony_ci        * See
7555db71995Sopenharmony_ci[Example Code for CreateInstance](#example-code-for-createinstance)
7565db71995Sopenharmony_ci      * Using the next layer’s `GetInstanceProcAddr` function to query for
7575db71995Sopenharmony_ci`vk_layerGetPhysicalDeviceProcAddr`.
7585db71995Sopenharmony_ci
7595db71995Sopenharmony_ciIf a layer intends to support functions that take VkPhysicalDevice as the
7605db71995Sopenharmony_cidispatchable parameter, then layer should support
7615db71995Sopenharmony_ci`vk_layerGetPhysicalDeviceProcAddr`.
7625db71995Sopenharmony_ciThis is because if these functions aren't known to the loader, such as those
7635db71995Sopenharmony_cifrom unreleased extensions or because the loader is an older build thus doesn't
7645db71995Sopenharmony_ciknow about them _yet_, the loader won't be able to distinguish whether this is
7655db71995Sopenharmony_cia device or physical device function.
7665db71995Sopenharmony_ci
7675db71995Sopenharmony_ciIf a layer does implement `vk_layerGetPhysicalDeviceProcAddr`, it should return
7685db71995Sopenharmony_cithe address of its `vk_layerGetPhysicalDeviceProcAddr` function in the
7695db71995Sopenharmony_ci"pfnGetPhysicalDeviceProcAddr" member of the `VkNegotiateLayerInterface`
7705db71995Sopenharmony_cistructure during [Layer Version Negotiation](#layer-version-negotiation).
7715db71995Sopenharmony_ciAdditionally, the layer should also make sure `vkGetInstanceProcAddr` returns a
7725db71995Sopenharmony_civalid function pointer to a query of `vk_layerGetPhysicalDeviceProcAddr`.
7735db71995Sopenharmony_ci
7745db71995Sopenharmony_ciNote: If a layer wraps the VkInstance handle, support for
7755db71995Sopenharmony_ci`vk_layerGetPhysicalDeviceProcAddr` is *NOT* optional and must be implemented.
7765db71995Sopenharmony_ci
7775db71995Sopenharmony_ciThe behavior of the loader's `vkGetInstanceProcAddr` with support for the
7785db71995Sopenharmony_ci`vk_layerGetPhysicalDeviceProcAddr` function is as follows:
7795db71995Sopenharmony_ci 1. Check if core function:
7805db71995Sopenharmony_ci    - If it is, return the function pointer
7815db71995Sopenharmony_ci 2. Check if known instance or device extension function:
7825db71995Sopenharmony_ci    - If it is, return the function pointer
7835db71995Sopenharmony_ci 3. Call the layer/driver `GetPhysicalDeviceProcAddr`
7845db71995Sopenharmony_ci    - If it returns non-NULL, return a trampoline to a generic physical device
7855db71995Sopenharmony_cifunction, and set up a generic terminator which will pass it to the proper
7865db71995Sopenharmony_cidriver.
7875db71995Sopenharmony_ci 4. Call down using `GetInstanceProcAddr`
7885db71995Sopenharmony_ci    - If it returns non-NULL, treat it as an unknown logical device command.
7895db71995Sopenharmony_ciThis means setting up a generic trampoline function that takes in a `VkDevice`
7905db71995Sopenharmony_cias the first parameter and adjusting the dispatch table to call the
7915db71995Sopenharmony_cidriver/layer's function after getting the dispatch table from the `VkDevice`.
7925db71995Sopenharmony_ciThen, return the pointer to corresponding trampoline function.
7935db71995Sopenharmony_ci 5. Return NULL
7945db71995Sopenharmony_ci
7955db71995Sopenharmony_ciThen, if the command gets promoted to core later, it will no
7965db71995Sopenharmony_cilonger be set up using `vk_layerGetPhysicalDeviceProcAddr`.
7975db71995Sopenharmony_ciAdditionally, if the loader adds direct support for the extension, it will no
7985db71995Sopenharmony_cilonger get to step 3, because step 2 will return a valid function pointer.
7995db71995Sopenharmony_ciHowever, the layer should continue to support the command query via
8005db71995Sopenharmony_ci`vk_layerGetPhysicalDeviceProcAddr`, until at least a Vulkan version bump,
8015db71995Sopenharmony_cibecause an older loader may still be attempting to use the commands.
8025db71995Sopenharmony_ci
8035db71995Sopenharmony_ci### Reason for adding `vk_layerGetPhysicalDeviceProcAddr`
8045db71995Sopenharmony_ci
8055db71995Sopenharmony_ciOriginally, if `vkGetInstanceProcAddr` was called in the loader, it would
8065db71995Sopenharmony_ciresult in the following behavior:
8075db71995Sopenharmony_ci 1. The loader would check if core function:
8085db71995Sopenharmony_ci    - If it was, it would return the function pointer
8095db71995Sopenharmony_ci 2. The loader would check if known extension function:
8105db71995Sopenharmony_ci    - If it was, it would return the function pointer
8115db71995Sopenharmony_ci 3. If the loader knew nothing about it, it would call down using
8125db71995Sopenharmony_ci`GetInstanceProcAddr`
8135db71995Sopenharmony_ci    - If it returned non-NULL, treat it as an unknown logical device command.
8145db71995Sopenharmony_ci    - This meant setting up a generic trampoline function that takes in a
8155db71995Sopenharmony_ciVkDevice as the first parameter and adjusting the dispatch table to call the
8165db71995Sopenharmony_ciDriver/Layer's function after getting the dispatch table from the `VkDevice`.
8175db71995Sopenharmony_ci 4. If all the above failed, the loader would return NULL to the application.
8185db71995Sopenharmony_ci
8195db71995Sopenharmony_ciThis caused problems when a layer attempted to expose new physical device
8205db71995Sopenharmony_ciextensions the loader knew nothing about, but an application did.
8215db71995Sopenharmony_ciBecause the loader knew nothing about it, the loader would get to step 3 in the
8225db71995Sopenharmony_ciabove process and would treat the function as an unknown logical device
8235db71995Sopenharmony_cicommand.
8245db71995Sopenharmony_ciThe problem is, this would create a generic VkDevice trampoline function which,
8255db71995Sopenharmony_cion the first call, would attempt to dereference the VkPhysicalDevice as a
8265db71995Sopenharmony_ciVkDevice.
8275db71995Sopenharmony_ciThis would lead to a crash or corruption.
8285db71995Sopenharmony_ci
8295db71995Sopenharmony_ci
8305db71995Sopenharmony_ci## Layer Intercept Requirements
8315db71995Sopenharmony_ci
8325db71995Sopenharmony_ci  * Layers intercept a Vulkan function by defining a C/C++ function with
8335db71995Sopenharmony_cisignature **identical** to the Vulkan API for that function.
8345db71995Sopenharmony_ci  * A layer **must intercept at least** `vkGetInstanceProcAddr` and
8355db71995Sopenharmony_ci`vkCreateInstance` to participate in the instance call chain.
8365db71995Sopenharmony_ci  * A layer **may also intercept** `vkGetDeviceProcAddr` and `vkCreateDevice`
8375db71995Sopenharmony_cito participate in the device call chain.
8385db71995Sopenharmony_ci  * For any Vulkan function a layer intercepts which has a non-void return
8395db71995Sopenharmony_civalue, **an appropriate value must be returned** by the layer intercept
8405db71995Sopenharmony_cifunction.
8415db71995Sopenharmony_ci  * Most functions a layer intercepts **should call down the chain** to the
8425db71995Sopenharmony_cicorresponding Vulkan function in the next entity.
8435db71995Sopenharmony_ci    * The common behavior for a layer is to intercept a call, perform some
8445db71995Sopenharmony_cibehavior, then pass it down to the next entity.
8455db71995Sopenharmony_ci      * If a layer doesn't pass the information down, undefined behavior may
8465db71995Sopenharmony_ci        occur.
8475db71995Sopenharmony_ci      * This is because the function will not be received by layers further
8485db71995Sopenharmony_cidown the chain, or any drivers.
8495db71995Sopenharmony_ci    * One function that **must never call down the chain** is:
8505db71995Sopenharmony_ci      * `vkNegotiateLoaderLayerInterfaceVersion`
8515db71995Sopenharmony_ci    * Three common functions that **may not call down the chain** are:
8525db71995Sopenharmony_ci      * `vkGetInstanceProcAddr`
8535db71995Sopenharmony_ci      * `vkGetDeviceProcAddr`
8545db71995Sopenharmony_ci      * `vk_layerGetPhysicalDeviceProcAddr`
8555db71995Sopenharmony_ci      * These functions only call down the chain for Vulkan functions that they
8565db71995Sopenharmony_cido not intercept.
8575db71995Sopenharmony_ci  * Layer intercept functions **may insert extra calls** to Vulkan functions in
8585db71995Sopenharmony_ciaddition to the intercept.
8595db71995Sopenharmony_ci    * For example, a layer intercepting `vkQueueSubmit` may want to add a call
8605db71995Sopenharmony_cito `vkQueueWaitIdle` after calling down the chain for `vkQueueSubmit`.
8615db71995Sopenharmony_ci    * This would result in two calls down the chain: First a call down the
8625db71995Sopenharmony_ci`vkQueueSubmit` chain, followed by a call down the `vkQueueWaitIdle` chain.
8635db71995Sopenharmony_ci    * Any additional calls inserted by a layer must be on the same chain
8645db71995Sopenharmony_ci      * If the function is a device function, only other device functions
8655db71995Sopenharmony_cishould be added.
8665db71995Sopenharmony_ci      * Likewise, if the function is an instance function, only other instance
8675db71995Sopenharmony_cifunctions should be added.
8685db71995Sopenharmony_ci
8695db71995Sopenharmony_ci
8705db71995Sopenharmony_ci## Distributed Dispatching Requirements
8715db71995Sopenharmony_ci
8725db71995Sopenharmony_ci- For each entry-point a layer intercepts, it must keep track of the
8735db71995Sopenharmony_cientry-point residing in the next entity in the chain it will call down into.
8745db71995Sopenharmony_ci  * In other words, the layer must have a list of pointers to functions of the
8755db71995Sopenharmony_ciappropriate type to call into the next entity.
8765db71995Sopenharmony_ci  * This can be implemented in various ways but
8775db71995Sopenharmony_cifor clarity, will be referred to as a dispatch table.
8785db71995Sopenharmony_ci- A layer can use the `VkLayerDispatchTable` structure as a device dispatch
8795db71995Sopenharmony_citable (see include/vulkan/vk_dispatch_table_helper.h).
8805db71995Sopenharmony_ci- A layer can use the `VkLayerInstanceDispatchTable` structure as a instance
8815db71995Sopenharmony_cidispatch table (see include/vulkan/vk_dispatch_table_helper.h).
8825db71995Sopenharmony_ci- A Layer's `vkGetInstanceProcAddr` function uses the next entity's
8835db71995Sopenharmony_ci`vkGetInstanceProcAddr` to call down the chain for unknown (i.e.
8845db71995Sopenharmony_cinon-intercepted) functions.
8855db71995Sopenharmony_ci- A Layer's `vkGetDeviceProcAddr` function uses the next entity's
8865db71995Sopenharmony_ci`vkGetDeviceProcAddr` to call down the chain for unknown (i.e. non-intercepted)
8875db71995Sopenharmony_cifunctions.
8885db71995Sopenharmony_ci- A Layer's `vk_layerGetPhysicalDeviceProcAddr` function uses the next entity's
8895db71995Sopenharmony_ci`vk_layerGetPhysicalDeviceProcAddr` to call down the chain for unknown (i.e.
8905db71995Sopenharmony_cinon-intercepted) functions.
8915db71995Sopenharmony_ci
8925db71995Sopenharmony_ci
8935db71995Sopenharmony_ci## Layer Conventions and Rules
8945db71995Sopenharmony_ci
8955db71995Sopenharmony_ciA layer, when inserted into an otherwise compliant Vulkan driver, <b>must</b>
8965db71995Sopenharmony_cistill result in a compliant Vulkan driver.
8975db71995Sopenharmony_ciThe intention is for layers to have a well-defined baseline behavior.
8985db71995Sopenharmony_ciTherefore, it must follow some conventions and rules defined below.
8995db71995Sopenharmony_ci
9005db71995Sopenharmony_ciIn order for layers to have unique names, and reduce the chance of conflicts
9015db71995Sopenharmony_cithat could occur when the loader attempts to load these layers, layers
9025db71995Sopenharmony_ci<b>must</b> adhere to the following naming standard:
9035db71995Sopenharmony_ci * Start with `VK_LAYER_` prefix
9045db71995Sopenharmony_ci * Follow the prefix with either an organization or company name (LunarG),
9055db71995Sopenharmony_ci   a unique company identifier (NV for Nvidia) or a software product name
9065db71995Sopenharmony_ci   (RenderDoc) in ALL CAPS
9075db71995Sopenharmony_ci * Follow that with the specific name of the layer (typically lower-case but not
9085db71995Sopenharmony_ci   required to be)
9095db71995Sopenharmony_ci   * NOTE: The specific name, if more than one word, <b>must</b> be underscore
9105db71995Sopenharmony_ci     delimited
9115db71995Sopenharmony_ci
9125db71995Sopenharmony_ciExamples of valid layer names include:
9135db71995Sopenharmony_ci * <b>VK_LAYER_KHRONOS_validation</b>
9145db71995Sopenharmony_ci   * Organization = "KHRONOS"
9155db71995Sopenharmony_ci   * Specific name = "validation"
9165db71995Sopenharmony_ci * <b>VK_LAYER_RENDERDOC_Capture</b>
9175db71995Sopenharmony_ci   * Application = "RENDERDOC"
9185db71995Sopenharmony_ci   * Specific name = "Capture"
9195db71995Sopenharmony_ci * <b>VK_LAYER_VALVE_steam_fossilize_32</b>
9205db71995Sopenharmony_ci   * Organization = "VALVE"
9215db71995Sopenharmony_ci   * Application = "steam"
9225db71995Sopenharmony_ci   * Specific name = "fossilize"
9235db71995Sopenharmony_ci   * OS-modifier = "32"  (for 32-bit version)
9245db71995Sopenharmony_ci * <b>VK_LAYER_NV_nsight</b>
9255db71995Sopenharmony_ci   * Organization Acronym = "NV" (for Nvidia)
9265db71995Sopenharmony_ci   * Specific name = "nsight"
9275db71995Sopenharmony_ci
9285db71995Sopenharmony_ciMore details on layer naming can be found in the
9295db71995Sopenharmony_ci[Vulkan style-guide](https://www.khronos.org/registry/vulkan/specs/1.2/styleguide.html#extensions-naming-conventions)
9305db71995Sopenharmony_ciunder section 3.4 "Version, Extension, and Layer Naming Conventions".
9315db71995Sopenharmony_ci
9325db71995Sopenharmony_ciA layer is always chained with other layers.
9335db71995Sopenharmony_ciIt must not make invalid calls to, or rely on undefined behaviors of, its lower
9345db71995Sopenharmony_cilayers.
9355db71995Sopenharmony_ciWhen it changes the behavior of a function, it must make sure its upper layers
9365db71995Sopenharmony_cido not make invalid calls to or rely on undefined behaviors of its lower layers
9375db71995Sopenharmony_cibecause of the changed behavior.
9385db71995Sopenharmony_ciFor example, when a layer intercepts an object creation function to wrap the
9395db71995Sopenharmony_ciobjects created by its lower layers, it must make sure its lower layers never
9405db71995Sopenharmony_cisee the wrapping objects, directly from itself or indirectly from its upper
9415db71995Sopenharmony_cilayers.
9425db71995Sopenharmony_ci
9435db71995Sopenharmony_ciWhen a layer requires host memory, it may ignore the provided allocators.
9445db71995Sopenharmony_ciIt is preferred that the layer use any provided memory allocators if the layer
9455db71995Sopenharmony_ciis intended to run in a production environment.
9465db71995Sopenharmony_ciFor example, this usually applies to implicit layers that are always enabled.
9475db71995Sopenharmony_ciThat will allow applications to include the layer's memory usage.
9485db71995Sopenharmony_ci
9495db71995Sopenharmony_ciAdditional rules include:
9505db71995Sopenharmony_ci  - `vkEnumerateInstanceLayerProperties` **must** enumerate and **only**
9515db71995Sopenharmony_cienumerate the layer itself.
9525db71995Sopenharmony_ci  - `vkEnumerateInstanceExtensionProperties` **must** handle the case where
9535db71995Sopenharmony_ci`pLayerName` is itself.
9545db71995Sopenharmony_ci    - It **must** return `VK_ERROR_LAYER_NOT_PRESENT` otherwise, including when
9555db71995Sopenharmony_ci`pLayerName` is `NULL`.
9565db71995Sopenharmony_ci  - `vkEnumerateDeviceLayerProperties` **is deprecated and may be omitted**.
9575db71995Sopenharmony_ci    - Using this will result in undefined behavior.
9585db71995Sopenharmony_ci  - `vkEnumerateDeviceExtensionProperties` **must** handle the case where
9595db71995Sopenharmony_ci`pLayerName` is itself.
9605db71995Sopenharmony_ci    - In other cases, it should chain to other layers.
9615db71995Sopenharmony_ci  - `vkCreateInstance` **must not** generate an error for unrecognized layer
9625db71995Sopenharmony_cinames and extension names.
9635db71995Sopenharmony_ci    - It may assume the layer names and extension names have been validated.
9645db71995Sopenharmony_ci  - `vkGetInstanceProcAddr` intercepts a Vulkan function by returning a local
9655db71995Sopenharmony_cientry-point
9665db71995Sopenharmony_ci    - Otherwise it returns the value obtained by calling down the instance call
9675db71995Sopenharmony_cichain.
9685db71995Sopenharmony_ci  - `vkGetDeviceProcAddr` intercepts a Vulkan function by returning a local
9695db71995Sopenharmony_cientry-point
9705db71995Sopenharmony_ci    - Otherwise it returns the value obtained by calling down the device call
9715db71995Sopenharmony_cichain.
9725db71995Sopenharmony_ci    - These additional functions must be intercepted if the layer implements
9735db71995Sopenharmony_cidevice-level call chaining:
9745db71995Sopenharmony_ci      - `vkGetDeviceProcAddr`
9755db71995Sopenharmony_ci      - `vkCreateDevice`(only required for any device-level chaining)
9765db71995Sopenharmony_ci         - **NOTE:** older layer libraries may expect that
9775db71995Sopenharmony_ci           `vkGetInstanceProcAddr`
9785db71995Sopenharmony_ciignore `instance` when `pName` is `vkCreateDevice`.
9795db71995Sopenharmony_ci  - The specification **requires** `NULL` to be returned from
9805db71995Sopenharmony_ci`vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` for disabled functions.
9815db71995Sopenharmony_ci    - A layer may return `NULL` itself or rely on the following layers to do so.
9825db71995Sopenharmony_ci
9835db71995Sopenharmony_ci
9845db71995Sopenharmony_ci## Layer Dispatch Initialization
9855db71995Sopenharmony_ci
9865db71995Sopenharmony_ci- A layer initializes its instance dispatch table within its `vkCreateInstance`
9875db71995Sopenharmony_cifunction.
9885db71995Sopenharmony_ci- A layer initializes its device dispatch table within its `vkCreateDevice`
9895db71995Sopenharmony_cifunction.
9905db71995Sopenharmony_ci- The loader passes a linked list of initialization structures to layers via
9915db71995Sopenharmony_cithe "pNext" field in the `VkInstanceCreateInfo` and `VkDeviceCreateInfo`
9925db71995Sopenharmony_cistructures for `vkCreateInstance` and `VkCreateDevice` respectively.
9935db71995Sopenharmony_ci- The head node in this linked list is of type `VkLayerInstanceCreateInfo` for
9945db71995Sopenharmony_ciinstance and VkLayerDeviceCreateInfo for device.
9955db71995Sopenharmony_ciSee file `include/vulkan/vk_layer.h` for details.
9965db71995Sopenharmony_ci- A VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO is used by the loader for the
9975db71995Sopenharmony_ci"sType" field in `VkLayerInstanceCreateInfo`.
9985db71995Sopenharmony_ci- A VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO is used by the loader for the
9995db71995Sopenharmony_ci"sType" field in `VkLayerDeviceCreateInfo`.
10005db71995Sopenharmony_ci- The "function" field indicates how the union field "u" should be interpreted
10015db71995Sopenharmony_ciwithin `VkLayer*CreateInfo`.
10025db71995Sopenharmony_ciThe loader will set the "function" field to VK_LAYER_LINK_INFO.
10035db71995Sopenharmony_ciThis indicates "u" field should be `VkLayerInstanceLink` or
10045db71995Sopenharmony_ci`VkLayerDeviceLink`.
10055db71995Sopenharmony_ci- The `VkLayerInstanceLink` and `VkLayerDeviceLink` structures are the list
10065db71995Sopenharmony_cinodes.
10075db71995Sopenharmony_ci- The `VkLayerInstanceLink` contains the next entity's `vkGetInstanceProcAddr`
10085db71995Sopenharmony_ciused by a layer.
10095db71995Sopenharmony_ci- The `VkLayerDeviceLink` contains the next entity's `vkGetInstanceProcAddr`
10105db71995Sopenharmony_ciand `vkGetDeviceProcAddr` used by a layer.
10115db71995Sopenharmony_ci- Given the above structures set up by the loader, layer must initialize their
10125db71995Sopenharmony_cidispatch table as follows:
10135db71995Sopenharmony_ci  - Find the `VkLayerInstanceCreateInfo`/`VkLayerDeviceCreateInfo` structure in
10145db71995Sopenharmony_cithe `VkInstanceCreateInfo`/`VkDeviceCreateInfo` structure.
10155db71995Sopenharmony_ci  - Get the next entity's vkGet*ProcAddr from the "pLayerInfo" field.
10165db71995Sopenharmony_ci  - For CreateInstance get the next entity's `vkCreateInstance` by calling the
10175db71995Sopenharmony_ci"pfnNextGetInstanceProcAddr":
10185db71995Sopenharmony_ci     pfnNextGetInstanceProcAddr(NULL, "vkCreateInstance").
10195db71995Sopenharmony_ci  - For CreateDevice get the next entity's `vkCreateDevice` by calling the
10205db71995Sopenharmony_ci"pfnNextGetInstanceProcAddr":
10215db71995Sopenharmony_cipfnNextGetInstanceProcAddr(instance, "vkCreateDevice"), passing the
10225db71995Sopenharmony_cialready created instance handle.
10235db71995Sopenharmony_ci  - Advanced the linked list to the next node: pLayerInfo = pLayerInfo->pNext.
10245db71995Sopenharmony_ci  - Call down the chain either `vkCreateDevice` or `vkCreateInstance`
10255db71995Sopenharmony_ci  - Initialize the layer dispatch table by calling the next entity's
10265db71995Sopenharmony_ciGet*ProcAddr function once for each Vulkan function needed in the dispatch
10275db71995Sopenharmony_citable
10285db71995Sopenharmony_ci
10295db71995Sopenharmony_ci## Example Code for CreateInstance
10305db71995Sopenharmony_ci
10315db71995Sopenharmony_ci```cpp
10325db71995Sopenharmony_ciVkResult
10335db71995Sopenharmony_ci   vkCreateInstance(
10345db71995Sopenharmony_ci      const VkInstanceCreateInfo *pCreateInfo,
10355db71995Sopenharmony_ci      const VkAllocationCallbacks *pAllocator,
10365db71995Sopenharmony_ci      VkInstance *pInstance)
10375db71995Sopenharmony_ci{
10385db71995Sopenharmony_ci   VkLayerInstanceCreateInfo *chain_info =
10395db71995Sopenharmony_ci        get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
10405db71995Sopenharmony_ci
10415db71995Sopenharmony_ci    assert(chain_info->u.pLayerInfo);
10425db71995Sopenharmony_ci    PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr =
10435db71995Sopenharmony_ci        chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
10445db71995Sopenharmony_ci    PFN_vkCreateInstance fpCreateInstance =
10455db71995Sopenharmony_ci        (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance");
10465db71995Sopenharmony_ci    if (fpCreateInstance == NULL) {
10475db71995Sopenharmony_ci        return VK_ERROR_INITIALIZATION_FAILED;
10485db71995Sopenharmony_ci    }
10495db71995Sopenharmony_ci
10505db71995Sopenharmony_ci    // Advance the link info for the next element of the chain.
10515db71995Sopenharmony_ci    // This ensures that the next layer gets it's layer info and not
10525db71995Sopenharmony_ci    // the info for our current layer.
10535db71995Sopenharmony_ci    chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
10545db71995Sopenharmony_ci
10555db71995Sopenharmony_ci    // Continue call down the chain
10565db71995Sopenharmony_ci    VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
10575db71995Sopenharmony_ci    if (result != VK_SUCCESS)
10585db71995Sopenharmony_ci        return result;
10595db71995Sopenharmony_ci
10605db71995Sopenharmony_ci    // Init layer's dispatch table using GetInstanceProcAddr of
10615db71995Sopenharmony_ci    // next layer in the chain.
10625db71995Sopenharmony_ci    instance_dispatch_table = new VkLayerInstanceDispatchTable;
10635db71995Sopenharmony_ci    layer_init_instance_dispatch_table(
10645db71995Sopenharmony_ci        *pInstance, my_data->instance_dispatch_table, fpGetInstanceProcAddr);
10655db71995Sopenharmony_ci
10665db71995Sopenharmony_ci    // Other layer initialization
10675db71995Sopenharmony_ci    ...
10685db71995Sopenharmony_ci
10695db71995Sopenharmony_ci    return VK_SUCCESS;
10705db71995Sopenharmony_ci}
10715db71995Sopenharmony_ci```
10725db71995Sopenharmony_ci
10735db71995Sopenharmony_ci## Example Code for CreateDevice
10745db71995Sopenharmony_ci
10755db71995Sopenharmony_ci```cpp
10765db71995Sopenharmony_ciVkResult
10775db71995Sopenharmony_ci   vkCreateDevice(
10785db71995Sopenharmony_ci      VkPhysicalDevice gpu,
10795db71995Sopenharmony_ci      const VkDeviceCreateInfo *pCreateInfo,
10805db71995Sopenharmony_ci      const VkAllocationCallbacks *pAllocator,
10815db71995Sopenharmony_ci      VkDevice *pDevice)
10825db71995Sopenharmony_ci{
10835db71995Sopenharmony_ci    VkInstance instance = GetInstanceFromPhysicalDevice(gpu);
10845db71995Sopenharmony_ci    VkLayerDeviceCreateInfo *chain_info =
10855db71995Sopenharmony_ci        get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
10865db71995Sopenharmony_ci
10875db71995Sopenharmony_ci    PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr =
10885db71995Sopenharmony_ci        chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
10895db71995Sopenharmony_ci    PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr =
10905db71995Sopenharmony_ci        chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
10915db71995Sopenharmony_ci    PFN_vkCreateDevice fpCreateDevice =
10925db71995Sopenharmony_ci        (PFN_vkCreateDevice)fpGetInstanceProcAddr(instance, "vkCreateDevice");
10935db71995Sopenharmony_ci    if (fpCreateDevice == NULL) {
10945db71995Sopenharmony_ci        return VK_ERROR_INITIALIZATION_FAILED;
10955db71995Sopenharmony_ci    }
10965db71995Sopenharmony_ci
10975db71995Sopenharmony_ci    // Advance the link info for the next element on the chain.
10985db71995Sopenharmony_ci    // This ensures that the next layer gets it's layer info and not
10995db71995Sopenharmony_ci    // the info for our current layer.
11005db71995Sopenharmony_ci    chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
11015db71995Sopenharmony_ci
11025db71995Sopenharmony_ci    VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
11035db71995Sopenharmony_ci    if (result != VK_SUCCESS) {
11045db71995Sopenharmony_ci        return result;
11055db71995Sopenharmony_ci    }
11065db71995Sopenharmony_ci
11075db71995Sopenharmony_ci    // initialize layer's dispatch table
11085db71995Sopenharmony_ci    device_dispatch_table = new VkLayerDispatchTable;
11095db71995Sopenharmony_ci    layer_init_device_dispatch_table(
11105db71995Sopenharmony_ci        *pDevice, device_dispatch_table, fpGetDeviceProcAddr);
11115db71995Sopenharmony_ci
11125db71995Sopenharmony_ci    // Other layer initialization
11135db71995Sopenharmony_ci    ...
11145db71995Sopenharmony_ci
11155db71995Sopenharmony_ci    return VK_SUCCESS;
11165db71995Sopenharmony_ci}
11175db71995Sopenharmony_ci```
11185db71995Sopenharmony_ciIn this case the function `GetInstanceFromPhysicalDevice` is called to get the
11195db71995Sopenharmony_ciinstance handle.
11205db71995Sopenharmony_ciIn practice, this would be done by any method a layer chooses to get an
11215db71995Sopenharmony_ciinstance handle from the physical device.
11225db71995Sopenharmony_ci
11235db71995Sopenharmony_ci
11245db71995Sopenharmony_ci## Meta-layers
11255db71995Sopenharmony_ci
11265db71995Sopenharmony_ciMeta-layers are a special kind of layer which is only available through the
11275db71995Sopenharmony_ciKhronos loader.
11285db71995Sopenharmony_ciWhile normal layers are associated with one particular library, a meta-layer
11295db71995Sopenharmony_ciis actually a collection layer which contains an ordered list of other layers
11305db71995Sopenharmony_ci(called component layers).
11315db71995Sopenharmony_ci
11325db71995Sopenharmony_ciThe benefits of a meta-layer are:
11335db71995Sopenharmony_ci 1. More than one layer may be activated using a single layer name by simply
11345db71995Sopenharmony_cigrouping multiple layers in a meta-layer.
11355db71995Sopenharmony_ci 2. The order of individual component layers is loaded can be defined within
11365db71995Sopenharmony_cithe meta-layer.
11375db71995Sopenharmony_ci 3. Layer configurations (internal to the meta-layer manifest file) can easily
11385db71995Sopenharmony_cibe shared with others.
11395db71995Sopenharmony_ci 4. The loader will automatically collate all instance and device extensions in
11405db71995Sopenharmony_cia meta-layer's component layers, and report them as the meta-layer's properties
11415db71995Sopenharmony_cito the application when queried.
11425db71995Sopenharmony_ci
11435db71995Sopenharmony_ciRestrictions to defining and using a meta-layer are:
11445db71995Sopenharmony_ci 1. A Meta-layer Manifest file **must** be a properly formatted that contains
11455db71995Sopenharmony_cione or more component layers.
11465db71995Sopenharmony_ci 3. All component layers **must be** present on a system for the meta-layer to
11475db71995Sopenharmony_cibe used.
11485db71995Sopenharmony_ci 4. All component layers **must be** at the same Vulkan API major and minor
11495db71995Sopenharmony_civersion as the meta-layer for the meta-layer to be used.
11505db71995Sopenharmony_ci
11515db71995Sopenharmony_ciThe ordering of a meta-layer's component layers in the instance or device call-
11525db71995Sopenharmony_cichain is simple:
11535db71995Sopenharmony_ci  * The first layer listed will be the layer closest to the application.
11545db71995Sopenharmony_ci  * The last layer listed will be the layer closest to the drivers.
11555db71995Sopenharmony_ci
11565db71995Sopenharmony_ciInside the meta-layer Manifest file, each component layer is listed by its
11575db71995Sopenharmony_cilayer name.
11585db71995Sopenharmony_ciThis is the "name" tag's value associated with each component layer's Manifest
11595db71995Sopenharmony_cifile under the "layer" or "layers" tag.
11605db71995Sopenharmony_ciThis is also the name that would normally be used when activating a layer
11615db71995Sopenharmony_ciduring `vkCreateInstance`.
11625db71995Sopenharmony_ci
11635db71995Sopenharmony_ciAny duplicate layer names in either the component layer list, or globally among
11645db71995Sopenharmony_ciall enabled layers, will simply be ignored by the loader.
11655db71995Sopenharmony_ciOnly the first instance of any layer name will be used.
11665db71995Sopenharmony_ci
11675db71995Sopenharmony_ciFor example, if a layer is enabled using the environment variable
11685db71995Sopenharmony_ci`VK_INSTANCE_LAYERS` and have that same layer listed in a meta-layer, then the
11695db71995Sopenharmony_cienvironment-variable-enabled layer will be used and the component layer will
11705db71995Sopenharmony_cibe dropped.
11715db71995Sopenharmony_ciLikewise, if a person were to enable a meta-layer and then separately enable
11725db71995Sopenharmony_cione of the component layers afterwards, the second instantiation of the layer
11735db71995Sopenharmony_ciname would be ignored.
11745db71995Sopenharmony_ci
11755db71995Sopenharmony_ciThe Manifest file formatting necessary to define a meta-layer can be found in
11765db71995Sopenharmony_cithe [Layer Manifest File Format](#layer-manifest-file-format) section.
11775db71995Sopenharmony_ci
11785db71995Sopenharmony_ci### Override Meta-Layer
11795db71995Sopenharmony_ci
11805db71995Sopenharmony_ciIf an implicit meta-layer was found on the system with the name
11815db71995Sopenharmony_ci`VK_LAYER_LUNARG_override`, the loader uses it as an 'override' layer.
11825db71995Sopenharmony_ciThis is used to selectively enable and disable other layers from being loaded.
11835db71995Sopenharmony_ciIt can be applied globally or to a specific application or applications.
11845db71995Sopenharmony_ciThe override meta layer can have the following additional keys:
11855db71995Sopenharmony_ci  * `blacklisted_layers` - List of explicit layer names that should not be
11865db71995Sopenharmony_ciloaded even if requested by the application.
11875db71995Sopenharmony_ci  * `app_keys` - List of paths to executables that the override layer applies
11885db71995Sopenharmony_cito.
11895db71995Sopenharmony_ci  * `override_paths` - List of paths which will be used as the search location
11905db71995Sopenharmony_cifor component layers.
11915db71995Sopenharmony_ci
11925db71995Sopenharmony_ciWhen an application starts up and the override layer is present, the loader
11935db71995Sopenharmony_cifirst checks to see if the application is in the list.
11945db71995Sopenharmony_ciIf it isn't, the override layer is not applied.
11955db71995Sopenharmony_ciIf the list is empty or if `app_keys` doesn't exist, the loader makes the
11965db71995Sopenharmony_cioverride layer global and applies it to every application upon startup.
11975db71995Sopenharmony_ci
11985db71995Sopenharmony_ciIf the override layer contains `override_paths`, then it uses this list of
11995db71995Sopenharmony_cipaths exclusively for component layers.
12005db71995Sopenharmony_ciThus, it ignores both the default explicit and implicit layer layer search
12015db71995Sopenharmony_cilocations as well as paths set by environment variables like `VK_LAYER_PATH`.
12025db71995Sopenharmony_ciIf any component layer is not present in the provided override paths, the meta
12035db71995Sopenharmony_cilayer is disabled.
12045db71995Sopenharmony_ci
12055db71995Sopenharmony_ciThe override meta-layer is primarily enabled when using the
12065db71995Sopenharmony_ci[VkConfig](https://github.com/LunarG/VulkanTools/blob/main/vkconfig/README.md)
12075db71995Sopenharmony_citool included in the Vulkan SDK.
12085db71995Sopenharmony_ciIt is typically only available while the VkConfig tool is actually executing.
12095db71995Sopenharmony_ciPlease refer to that documentation for more information.
12105db71995Sopenharmony_ci
12115db71995Sopenharmony_ci## Pre-Instance Functions
12125db71995Sopenharmony_ci
12135db71995Sopenharmony_ciVulkan includes a small number of functions which are called without any
12145db71995Sopenharmony_cidispatchable object.
12155db71995Sopenharmony_ci<b>Most layers do not intercept these functions</b>, as layers are enabled when
12165db71995Sopenharmony_cian instance is created.
12175db71995Sopenharmony_ciHowever, under certain conditions it is possible for a layer to intercept
12185db71995Sopenharmony_cithese functions.
12195db71995Sopenharmony_ci
12205db71995Sopenharmony_ciOne reason why a layer may desire to intercept these pre-instance functions is
12215db71995Sopenharmony_cito filter out extensions that would normally be returned from Vulkan drivers to
12225db71995Sopenharmony_cithe application.
12235db71995Sopenharmony_ci[RenderDoc](https://renderdoc.org/) is one such layer which intercepts these
12245db71995Sopenharmony_cipre-instance functions so that it may disable extensions it doesn't support.
12255db71995Sopenharmony_ci
12265db71995Sopenharmony_ciIn order to intercept the pre-instance functions, several conditions must be
12275db71995Sopenharmony_cimet:
12285db71995Sopenharmony_ci* The layer must be implicit
12295db71995Sopenharmony_ci* The layer manifest version must be 1.1.2 or later
12305db71995Sopenharmony_ci* The layer must export the entry-point symbols for each intercepted function
12315db71995Sopenharmony_ci* The layer manifest must specify the name of each intercepted function in a
12325db71995Sopenharmony_ci`pre_instance_functions` JSON object
12335db71995Sopenharmony_ci
12345db71995Sopenharmony_ciThe functions that may be intercepted in this way are:
12355db71995Sopenharmony_ci* `vkEnumerateInstanceExtensionProperties`
12365db71995Sopenharmony_ci* `vkEnumerateInstanceLayerProperties`
12375db71995Sopenharmony_ci* `vkEnumerateInstanceVersion`
12385db71995Sopenharmony_ci
12395db71995Sopenharmony_ciPre-instance functions work differently from all other layer intercept
12405db71995Sopenharmony_cifunctions.
12415db71995Sopenharmony_ciOther intercept functions have a function prototype identical to that of the
12425db71995Sopenharmony_cifunction they are intercepting.
12435db71995Sopenharmony_ciThey then rely on data that was passed to the layer at instance or device
12445db71995Sopenharmony_cicreation so that layers can call down the chain.
12455db71995Sopenharmony_ciBecause there is no need to create an instance before calling the pre-instance
12465db71995Sopenharmony_cifunctions, these functions must use a separate mechanism for constructing the
12475db71995Sopenharmony_cicall chain.
12485db71995Sopenharmony_ciThis mechanism consists of an extra parameter that will be passed to the layer
12495db71995Sopenharmony_ciintercept function when it is called.
12505db71995Sopenharmony_ciThis parameter will be a pointer to a struct, defined as follows:
12515db71995Sopenharmony_ci
12525db71995Sopenharmony_ci```cpp
12535db71995Sopenharmony_citypedef struct Vk...Chain
12545db71995Sopenharmony_ci{
12555db71995Sopenharmony_ci    struct {
12565db71995Sopenharmony_ci        VkChainType type;
12575db71995Sopenharmony_ci        uint32_t version;
12585db71995Sopenharmony_ci        uint32_t size;
12595db71995Sopenharmony_ci    } header;
12605db71995Sopenharmony_ci    PFN_vkVoidFunction pfnNextLayer;
12615db71995Sopenharmony_ci    const struct Vk...Chain* pNextLink;
12625db71995Sopenharmony_ci} Vk...Chain;
12635db71995Sopenharmony_ci```
12645db71995Sopenharmony_ci
12655db71995Sopenharmony_ciThese structs are defined in the `vk_layer.h` file so that it is not necessary
12665db71995Sopenharmony_cito redefine the chain structs in any external code.
12675db71995Sopenharmony_ciThe name of each struct is be similar to the name of the function it
12685db71995Sopenharmony_cicorresponds to, but the leading "V" is capitalized, and the word "Chain" is
12695db71995Sopenharmony_ciadded to the end.
12705db71995Sopenharmony_ciFor example, the struct for `vkEnumerateInstanceExtensionProperties` is called
12715db71995Sopenharmony_ci`VkEnumerateInstanceExtensionPropertiesChain`.
12725db71995Sopenharmony_ciFurthermore, the `pfnNextLayer` struct member is not actually a void function
12735db71995Sopenharmony_cipointer &mdash; its type will be the actual type of each function in the call
12745db71995Sopenharmony_cichain.
12755db71995Sopenharmony_ci
12765db71995Sopenharmony_ciEach layer intercept function must have a prototype that is the same as the
12775db71995Sopenharmony_ciprototype of the function being intercepted, except that the first parameter
12785db71995Sopenharmony_cimust be that function's chain struct (passed as a const pointer).
12795db71995Sopenharmony_ciFor example, a function that wishes to intercept
12805db71995Sopenharmony_ci`vkEnumerateInstanceExtensionProperties` would have the prototype:
12815db71995Sopenharmony_ci
12825db71995Sopenharmony_ci```cpp
12835db71995Sopenharmony_ciVkResult
12845db71995Sopenharmony_ci   InterceptFunctionName(
12855db71995Sopenharmony_ci      const VkEnumerateInstanceExtensionPropertiesChain* pChain,
12865db71995Sopenharmony_ci      const char* pLayerName,
12875db71995Sopenharmony_ci      uint32_t* pPropertyCount,
12885db71995Sopenharmony_ci      VkExtensionProperties* pProperties);
12895db71995Sopenharmony_ci```
12905db71995Sopenharmony_ci
12915db71995Sopenharmony_ciThe name of the function is arbitrary; it can be anything provided that it is
12925db71995Sopenharmony_cigiven in the layer manifest file (see
12935db71995Sopenharmony_ci[Layer Manifest File Format](#layer-manifest-file-format)).
12945db71995Sopenharmony_ciThe implementation of each intercept function is responsible for calling the
12955db71995Sopenharmony_cinext item in the call chain, using the chain parameter.
12965db71995Sopenharmony_ciThis is done by calling the `pfnNextLayer` member of the chain struct, passing
12975db71995Sopenharmony_ci`pNextLink` as the first argument, and passing the remaining function arguments
12985db71995Sopenharmony_ciafter that.
12995db71995Sopenharmony_ciFor example, a simple implementation for
13005db71995Sopenharmony_ci`vkEnumerateInstanceExtensionProperties` that does nothing but call down the
13015db71995Sopenharmony_cichain would look like:
13025db71995Sopenharmony_ci
13035db71995Sopenharmony_ci```cpp
13045db71995Sopenharmony_ciVkResult
13055db71995Sopenharmony_ci   InterceptFunctionName(
13065db71995Sopenharmony_ci      const VkEnumerateInstanceExtensionPropertiesChain* pChain,
13075db71995Sopenharmony_ci      const char* pLayerName,
13085db71995Sopenharmony_ci      uint32_t* pPropertyCount,
13095db71995Sopenharmony_ci      VkExtensionProperties* pProperties)
13105db71995Sopenharmony_ci{
13115db71995Sopenharmony_ci   return pChain->pfnNextLayer(
13125db71995Sopenharmony_ci      pChain->pNextLink, pLayerName, pPropertyCount, pProperties);
13135db71995Sopenharmony_ci}
13145db71995Sopenharmony_ci```
13155db71995Sopenharmony_ci
13165db71995Sopenharmony_ciWhen using a C++ compiler, each chain type also defines a function named
13175db71995Sopenharmony_ci`CallDown` which can be used to automatically handle the first argument.
13185db71995Sopenharmony_ciImplementing the above function using this method would look like:
13195db71995Sopenharmony_ci
13205db71995Sopenharmony_ci```cpp
13215db71995Sopenharmony_ciVkResult
13225db71995Sopenharmony_ci   InterceptFunctionName(
13235db71995Sopenharmony_ci      const VkEnumerateInstanceExtensionPropertiesChain* pChain,
13245db71995Sopenharmony_ci      const char* pLayerName,
13255db71995Sopenharmony_ci      uint32_t* pPropertyCount,
13265db71995Sopenharmony_ci      VkExtensionProperties* pProperties)
13275db71995Sopenharmony_ci{
13285db71995Sopenharmony_ci   return pChain->CallDown(pLayerName, pPropertyCount, pProperties);
13295db71995Sopenharmony_ci}
13305db71995Sopenharmony_ci```
13315db71995Sopenharmony_ci
13325db71995Sopenharmony_ciUnlike with other functions in layers, the layer may not save any global data
13335db71995Sopenharmony_cibetween these function calls.
13345db71995Sopenharmony_ciBecause Vulkan does not store any state until an instance has been created, all
13355db71995Sopenharmony_cilayer libraries are released at the end of each pre-instance call.
13365db71995Sopenharmony_ciThis means that implicit layers can use pre-instance intercepts to modify data
13375db71995Sopenharmony_cithat is returned by the functions, but they cannot be used to record that data.
13385db71995Sopenharmony_ci
13395db71995Sopenharmony_ci## Special Considerations
13405db71995Sopenharmony_ci
13415db71995Sopenharmony_ci
13425db71995Sopenharmony_ci### Associating Private Data with Vulkan Objects Within a Layer
13435db71995Sopenharmony_ci
13445db71995Sopenharmony_ciA layer may want to associate its own private data with one or more Vulkan
13455db71995Sopenharmony_ciobjects.
13465db71995Sopenharmony_ciTwo common methods to do this are hash maps and object wrapping.
13475db71995Sopenharmony_ci
13485db71995Sopenharmony_ci
13495db71995Sopenharmony_ci#### Wrapping
13505db71995Sopenharmony_ci
13515db71995Sopenharmony_ciThe loader supports layers wrapping any Vulkan object, including dispatchable
13525db71995Sopenharmony_ciobjects.
13535db71995Sopenharmony_ciFor functions that return object handles, each layer does not touch the value
13545db71995Sopenharmony_cipassed down the call chain.
13555db71995Sopenharmony_ciThis is because lower items may need to use the original value.
13565db71995Sopenharmony_ciHowever, when the value is returned from a lower-level layer (possibly the
13575db71995Sopenharmony_cidriver), the layer saves the handle and returns its own handle to the
13585db71995Sopenharmony_cilayer above it (possibly the application).
13595db71995Sopenharmony_ciWhen a layer receives a Vulkan function using something that it previously
13605db71995Sopenharmony_cireturned a handle for, the layer is required to unwrap the handle and pass
13615db71995Sopenharmony_cialong the saved handle to the layer below it.
13625db71995Sopenharmony_ciThis means that the layer **must intercept every Vulkan function which uses**
13635db71995Sopenharmony_ci**the object in question**, and wrap or unwrap the object, as appropriate.
13645db71995Sopenharmony_ciThis includes adding support for all extensions with functions using any
13655db71995Sopenharmony_ciobject the layer wraps as well as any loader-layer interface functions such as
13665db71995Sopenharmony_ci`vk_layerGetPhysicalDeviceProcAddr`.
13675db71995Sopenharmony_ci
13685db71995Sopenharmony_ciLayers above the object wrapping layer will see the wrapped object.
13695db71995Sopenharmony_ciLayers which wrap dispatchable objects must ensure that the first field in the
13705db71995Sopenharmony_ciwrapping structure is a pointer to a dispatch table as defined in `vk_layer.h`.
13715db71995Sopenharmony_ciSpecifically, an instance wrapped dispatchable object could be as follows:
13725db71995Sopenharmony_ci
13735db71995Sopenharmony_ci```cpp
13745db71995Sopenharmony_cistruct my_wrapped_instance_obj_ {
13755db71995Sopenharmony_ci    VkLayerInstanceDispatchTable *disp;
13765db71995Sopenharmony_ci    // whatever data layer wants to add to this object
13775db71995Sopenharmony_ci};
13785db71995Sopenharmony_ci```
13795db71995Sopenharmony_ciA device wrapped dispatchable object could be as follows:
13805db71995Sopenharmony_ci```cpp
13815db71995Sopenharmony_cistruct my_wrapped_instance_obj_ {
13825db71995Sopenharmony_ci    VkLayerDispatchTable *disp;
13835db71995Sopenharmony_ci    // whatever data layer wants to add to this object
13845db71995Sopenharmony_ci};
13855db71995Sopenharmony_ci```
13865db71995Sopenharmony_ci
13875db71995Sopenharmony_ciLayers that wrap dispatchable objects must follow the guidelines for creating
13885db71995Sopenharmony_cinew dispatchable objects (below).
13895db71995Sopenharmony_ci
13905db71995Sopenharmony_ci#### Cautions About Wrapping
13915db71995Sopenharmony_ci
13925db71995Sopenharmony_ciLayers are generally discouraged from wrapping objects, because of the
13935db71995Sopenharmony_cipotential for incompatibilities with new extensions.
13945db71995Sopenharmony_ciFor example, let's say that a layer wraps `VkImage` objects, and properly wraps
13955db71995Sopenharmony_ciand unwraps `VkImage` object handles for all core functions.
13965db71995Sopenharmony_ciIf a new extension is created which has functions that take `VkImage` objects
13975db71995Sopenharmony_cias parameters, and if the layer does not support those new functions, an
13985db71995Sopenharmony_ciapplication that uses both the layer and the new extension will have undefined
13995db71995Sopenharmony_cibehavior when those new functions are called (e.g. the application may crash).
14005db71995Sopenharmony_ciThis is because the lower-level layers and drivers won't receive the handle that
14015db71995Sopenharmony_cithey generated.
14025db71995Sopenharmony_ciInstead, they will receive a handle that is only known by the layer that is
14035db71995Sopenharmony_ciwrapping the object.
14045db71995Sopenharmony_ci
14055db71995Sopenharmony_ciBecause of the potential for incompatibilities with unsupported extensions,
14065db71995Sopenharmony_cilayers that wrap objects must check which extensions are being used by the
14075db71995Sopenharmony_ciapplication, and take appropriate action if the layer is used with unsupported
14085db71995Sopenharmony_ciextensions such as issuing a warning/error message to the user.
14095db71995Sopenharmony_ci
14105db71995Sopenharmony_ciThe reason that the validation layers wrap objects is to track the proper use
14115db71995Sopenharmony_ciand destruction of each object.
14125db71995Sopenharmony_ciThey issue a validation error if used with unsupported extensions, alerting the
14135db71995Sopenharmony_ciuser to the potential for undefined behavior.
14145db71995Sopenharmony_ci
14155db71995Sopenharmony_ci
14165db71995Sopenharmony_ci#### Hash Maps
14175db71995Sopenharmony_ci
14185db71995Sopenharmony_ciAlternatively, a layer may want to use a hash map to associate data with a
14195db71995Sopenharmony_cigiven object.
14205db71995Sopenharmony_ciThe key to the map could be the object. Alternatively, for dispatchable objects
14215db71995Sopenharmony_ciat a given level (eg device or instance) the layer may want data associated
14225db71995Sopenharmony_ciwith the `VkDevice` or `VkInstance` objects.
14235db71995Sopenharmony_ciSince there are multiple dispatchable objects for a given `VkInstance` or
14245db71995Sopenharmony_ci`VkDevice`, the `VkDevice` or `VkInstance` object is not a great map key.
14255db71995Sopenharmony_ciInstead the layer should use the dispatch table pointer within the `VkDevice`
14265db71995Sopenharmony_cior `VkInstance` since that will be unique for a given `VkInstance` or
14275db71995Sopenharmony_ci`VkDevice`.
14285db71995Sopenharmony_ci
14295db71995Sopenharmony_ci
14305db71995Sopenharmony_ci### Creating New Dispatchable Objects
14315db71995Sopenharmony_ci
14325db71995Sopenharmony_ciLayers which create dispatchable objects must take special care.
14335db71995Sopenharmony_ciRemember that loader *trampoline* code normally fills in the dispatch table
14345db71995Sopenharmony_cipointer in the newly created object.
14355db71995Sopenharmony_ciThus, the layer must fill in the dispatch table pointer if the loader
14365db71995Sopenharmony_ci*trampoline* will not do so.
14375db71995Sopenharmony_ciCommon cases where a layer (or driver) may create a dispatchable object without
14385db71995Sopenharmony_ciloader *trampoline* code is as follows:
14395db71995Sopenharmony_ci- Layers that wrap dispatchable objects
14405db71995Sopenharmony_ci- Layers which add extensions that create dispatchable objects
14415db71995Sopenharmony_ci- Layers which insert extra Vulkan functions in the stream of functions they
14425db71995Sopenharmony_ciintercept from the application
14435db71995Sopenharmony_ci- Drivers which add extensions that create dispatchable objects
14445db71995Sopenharmony_ci
14455db71995Sopenharmony_ciThe Khronos loader provides a callback that can be used for initializing a
14465db71995Sopenharmony_cidispatchable object.
14475db71995Sopenharmony_ciThe callback is passed as an extension structure via the `pNext` field in the
14485db71995Sopenharmony_cicreate info structure when creating an instance (`VkInstanceCreateInfo`) or
14495db71995Sopenharmony_cidevice (`VkDeviceCreateInfo`).
14505db71995Sopenharmony_ciThe callback prototype is defined as follows for instance and device callbacks
14515db71995Sopenharmony_cirespectively (see `vk_layer.h`):
14525db71995Sopenharmony_ci
14535db71995Sopenharmony_ci```cpp
14545db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL
14555db71995Sopenharmony_ci   vkSetInstanceLoaderData(
14565db71995Sopenharmony_ci      VkInstance instance,
14575db71995Sopenharmony_ci      void *object);
14585db71995Sopenharmony_ci
14595db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL
14605db71995Sopenharmony_ci   vkSetDeviceLoaderData(
14615db71995Sopenharmony_ci      VkDevice device,
14625db71995Sopenharmony_ci      void *object);
14635db71995Sopenharmony_ci```
14645db71995Sopenharmony_ci
14655db71995Sopenharmony_ciTo obtain these callbacks the layer must search through the list of structures
14665db71995Sopenharmony_cipointed to by the "pNext" field in the `VkInstanceCreateInfo` and
14675db71995Sopenharmony_ci`VkDeviceCreateInfo` parameters to find any callback structures inserted by the
14685db71995Sopenharmony_ciloader.
14695db71995Sopenharmony_ciThe salient details are as follows:
14705db71995Sopenharmony_ci- For `VkInstanceCreateInfo` the callback structure pointed to by "pNext" is
14715db71995Sopenharmony_ci`VkLayerInstanceCreateInfo` as defined in `include/vulkan/vk_layer.h`.
14725db71995Sopenharmony_ci- A "sType" field in of VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO within
14735db71995Sopenharmony_ci`VkInstanceCreateInfo` parameter indicates a loader structure.
14745db71995Sopenharmony_ci- Within `VkLayerInstanceCreateInfo`, the "function" field indicates how the
14755db71995Sopenharmony_ciunion field "u" should be interpreted.
14765db71995Sopenharmony_ci- A "function" equal to VK_LOADER_DATA_CALLBACK indicates the "u" field will
14775db71995Sopenharmony_cicontain the callback in "pfnSetInstanceLoaderData".
14785db71995Sopenharmony_ci- For `VkDeviceCreateInfo` the callback structure pointed to by "pNext" is
14795db71995Sopenharmony_ci`VkLayerDeviceCreateInfo` as defined in `include/vulkan/vk_layer.h`.
14805db71995Sopenharmony_ci- A "sType" field in of VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO within
14815db71995Sopenharmony_ci`VkDeviceCreateInfo` parameter indicates a loader structure.
14825db71995Sopenharmony_ci- Within `VkLayerDeviceCreateInfo`, the "function" field indicates how the union
14835db71995Sopenharmony_cifield "u" should be interpreted.
14845db71995Sopenharmony_ci- A "function" equal to VK_LOADER_DATA_CALLBACK indicates the "u" field will
14855db71995Sopenharmony_cicontain the callback in "pfnSetDeviceLoaderData".
14865db71995Sopenharmony_ci
14875db71995Sopenharmony_ciAlternatively, if an older loader is being used that doesn't provide these
14885db71995Sopenharmony_cicallbacks, the layer may manually initialize the newly created dispatchable
14895db71995Sopenharmony_ciobject.
14905db71995Sopenharmony_ciTo fill in the dispatch table pointer in newly created dispatchable object, the
14915db71995Sopenharmony_cilayer should copy the dispatch pointer, which is always the first entry in the
14925db71995Sopenharmony_cistructure, from an existing parent object of the same level (instance versus
14935db71995Sopenharmony_cidevice).
14945db71995Sopenharmony_ci
14955db71995Sopenharmony_ciFor example, if there is a newly created `VkCommandBuffer` object, then the
14965db71995Sopenharmony_cidispatch pointer from the `VkDevice` object, which is the parent of the
14975db71995Sopenharmony_ci`VkCommandBuffer` object, should be copied into the newly created object.
14985db71995Sopenharmony_ci
14995db71995Sopenharmony_ci### Versioning and Activation Interactions
15005db71995Sopenharmony_ci
15015db71995Sopenharmony_ciThere are several interacting rules concerning the activation of layers with
15025db71995Sopenharmony_cinon-obvious results.
15035db71995Sopenharmony_ciThis not an exhaustive list but should better clarify the behavior of the
15045db71995Sopenharmony_ciloader in complex situations.
15055db71995Sopenharmony_ci
15065db71995Sopenharmony_ci* The Vulkan Loader in versions 1.3.228 and above will enable implicit layers
15075db71995Sopenharmony_ciregardless of the API version specified by the application in
15085db71995Sopenharmony_ci`VkApplicationInfo::apiVersion`.
15095db71995Sopenharmony_ciPrevious loader versions (1.3.227 and below) used to have a requirement where
15105db71995Sopenharmony_ciimplicit layer's API version must be equal to or greater than the API version
15115db71995Sopenharmony_ciof the application for the layer to be enabled.
15125db71995Sopenharmony_ciThe change relaxed the implicit layer loading requirements because it was
15135db71995Sopenharmony_cidetermined that the perceived protection of preventing older layers running
15145db71995Sopenharmony_ciwith newer applications wasn't enough to justify the friction it caused.
15155db71995Sopenharmony_ciThis was due to older layers no longer working with newer applications
15165db71995Sopenharmony_cifor no apparent reason, as well as older layers having to update the manifest
15175db71995Sopenharmony_cito work with newer applications.
15185db71995Sopenharmony_ciThe layer didn't need to do anything else to get their layer working again,
15195db71995Sopenharmony_ciwhich meant that a layer didn't need to prove that their layer worked with
15205db71995Sopenharmony_cinewer API versions.
15215db71995Sopenharmony_ciThus, the disabling caused confusion for users but didn't protect them from
15225db71995Sopenharmony_cipotentially badly behaving layers.
15235db71995Sopenharmony_ci
15245db71995Sopenharmony_ci* An implicit layer will ignore its disable environment variable being set if
15255db71995Sopenharmony_ciit is a component in an active meta layer.
15265db71995Sopenharmony_ci
15275db71995Sopenharmony_ci* The environment `VK_LAYER_PATH` only affects explicit layer searching, not
15285db71995Sopenharmony_ciimplicit.
15295db71995Sopenharmony_ciLayers found in this path are treated as explicit, even if they contain all the
15305db71995Sopenharmony_cirequisite fields to be an implicit layer.
15315db71995Sopenharmony_ciThis means they will not be implicitly enabled.
15325db71995Sopenharmony_ci
15335db71995Sopenharmony_ci* Meta layers do not have to be implicit - they can be explicit.
15345db71995Sopenharmony_ciIt cannot be assumed that because a meta layer is present that it will be active.
15355db71995Sopenharmony_ci
15365db71995Sopenharmony_ci* The `blacklisted_layers` member of the override meta layer will prevent both
15375db71995Sopenharmony_ciimplicitly enabled and explicitely enabled layers from activating.
15385db71995Sopenharmony_ciAny layers in an application's `VkInstanceCreateInfo::ppEnabledLayerNames` that
15395db71995Sopenharmony_ciare in the blacklist will not be enabled.
15405db71995Sopenharmony_ci
15415db71995Sopenharmony_ci* The `app_keys` member of the override meta layer will make a meta layer apply
15425db71995Sopenharmony_cito only applications found in this list.
15435db71995Sopenharmony_ciIf there are any items in the app keys list, the meta layer isn't enabled for
15445db71995Sopenharmony_ciany application except those found in the list.
15455db71995Sopenharmony_ci
15465db71995Sopenharmony_ci* The `override_paths` member of the override meta layer, if present, will
15475db71995Sopenharmony_cireplace the search paths the loader uses to find component layers.
15485db71995Sopenharmony_ciIf any component layer isn't present in the override paths, the override meta
15495db71995Sopenharmony_cilayer is not applied.
15505db71995Sopenharmony_ciSo if an override meta layer wants to mix default and custom layer locations,
15515db71995Sopenharmony_cithe override paths must contain both custom and default layer locations.
15525db71995Sopenharmony_ci
15535db71995Sopenharmony_ci* If the override layer is both present and contains `override_paths`, the
15545db71995Sopenharmony_cipaths from the environment variable `VK_LAYER_PATH` are ignored when searching
15555db71995Sopenharmony_cifor explicit layers.
15565db71995Sopenharmony_ciFor example, when both the meta layer override paths and `VK_LAYER_PATH` are
15575db71995Sopenharmony_cipresent, none of the layers in `VK_LAYER_PATH` are discoverable, and the
15585db71995Sopenharmony_ciloader will not find them.
15595db71995Sopenharmony_ci
15605db71995Sopenharmony_ci
15615db71995Sopenharmony_ci## Layer Manifest File Format
15625db71995Sopenharmony_ci
15635db71995Sopenharmony_ciThe Khronos loader uses manifest files to discover available layer libraries
15645db71995Sopenharmony_ciand layers.
15655db71995Sopenharmony_ciIt doesn't directly query the layer's dynamic library except during chaining.
15665db71995Sopenharmony_ciThis is to reduce the likelihood of loading a malicious layer into memory.
15675db71995Sopenharmony_ciInstead, details are read from the Manifest file, which are then provided
15685db71995Sopenharmony_cifor applications to determine what layers should actually be loaded.
15695db71995Sopenharmony_ci
15705db71995Sopenharmony_ciThe following section discusses the details of the Layer Manifest JSON file
15715db71995Sopenharmony_ciformat.
15725db71995Sopenharmony_ciThe JSON file itself does not have any requirements for naming.
15735db71995Sopenharmony_ciThe only requirement is that the extension suffix of the file is ".json".
15745db71995Sopenharmony_ci
15755db71995Sopenharmony_ciHere is an example layer JSON Manifest file with a single layer:
15765db71995Sopenharmony_ci
15775db71995Sopenharmony_ci```json
15785db71995Sopenharmony_ci{
15795db71995Sopenharmony_ci   "file_format_version" : "1.2.1",
15805db71995Sopenharmony_ci   "layer": {
15815db71995Sopenharmony_ci       "name": "VK_LAYER_LUNARG_overlay",
15825db71995Sopenharmony_ci       "type": "INSTANCE",
15835db71995Sopenharmony_ci       "library_path": "vkOverlayLayer.dll",
15845db71995Sopenharmony_ci       "library_arch" : "64",
15855db71995Sopenharmony_ci       "api_version" : "1.0.5",
15865db71995Sopenharmony_ci       "implementation_version" : "2",
15875db71995Sopenharmony_ci       "description" : "LunarG HUD layer",
15885db71995Sopenharmony_ci       "functions": {
15895db71995Sopenharmony_ci           "vkNegotiateLoaderLayerInterfaceVersion":
15905db71995Sopenharmony_ci               "OverlayLayer_NegotiateLoaderLayerInterfaceVersion"
15915db71995Sopenharmony_ci       },
15925db71995Sopenharmony_ci       "instance_extensions": [
15935db71995Sopenharmony_ci           {
15945db71995Sopenharmony_ci               "name": "VK_EXT_debug_report",
15955db71995Sopenharmony_ci               "spec_version": "1"
15965db71995Sopenharmony_ci           },
15975db71995Sopenharmony_ci           {
15985db71995Sopenharmony_ci               "name": "VK_VENDOR_ext_x",
15995db71995Sopenharmony_ci               "spec_version": "3"
16005db71995Sopenharmony_ci            }
16015db71995Sopenharmony_ci       ],
16025db71995Sopenharmony_ci       "device_extensions": [
16035db71995Sopenharmony_ci           {
16045db71995Sopenharmony_ci               "name": "VK_EXT_debug_marker",
16055db71995Sopenharmony_ci               "spec_version": "1",
16065db71995Sopenharmony_ci               "entrypoints": ["vkCmdDbgMarkerBegin", "vkCmdDbgMarkerEnd"]
16075db71995Sopenharmony_ci           }
16085db71995Sopenharmony_ci       ],
16095db71995Sopenharmony_ci       "enable_environment": {
16105db71995Sopenharmony_ci           "ENABLE_LAYER_OVERLAY_1": "1"
16115db71995Sopenharmony_ci       },
16125db71995Sopenharmony_ci       "disable_environment": {
16135db71995Sopenharmony_ci           "DISABLE_LAYER_OVERLAY_1": ""
16145db71995Sopenharmony_ci       }
16155db71995Sopenharmony_ci   }
16165db71995Sopenharmony_ci}
16175db71995Sopenharmony_ci```
16185db71995Sopenharmony_ci
16195db71995Sopenharmony_ciHere's a snippet with the changes required to support multiple layers per
16205db71995Sopenharmony_cimanifest file:
16215db71995Sopenharmony_ci```json
16225db71995Sopenharmony_ci{
16235db71995Sopenharmony_ci   "file_format_version" : "1.0.1",
16245db71995Sopenharmony_ci   "layers": [
16255db71995Sopenharmony_ci      {
16265db71995Sopenharmony_ci           "name": "VK_LAYER_layer_name1",
16275db71995Sopenharmony_ci           "type": "INSTANCE",
16285db71995Sopenharmony_ci           ...
16295db71995Sopenharmony_ci      },
16305db71995Sopenharmony_ci      {
16315db71995Sopenharmony_ci           "name": "VK_LAYER_layer_name2",
16325db71995Sopenharmony_ci           "type": "INSTANCE",
16335db71995Sopenharmony_ci           ...
16345db71995Sopenharmony_ci      }
16355db71995Sopenharmony_ci   ]
16365db71995Sopenharmony_ci}
16375db71995Sopenharmony_ci```
16385db71995Sopenharmony_ci
16395db71995Sopenharmony_ciHere's an example of a meta-layer manifest file:
16405db71995Sopenharmony_ci```json
16415db71995Sopenharmony_ci{
16425db71995Sopenharmony_ci   "file_format_version" : "1.1.1",
16435db71995Sopenharmony_ci   "layer": {
16445db71995Sopenharmony_ci       "name": "VK_LAYER_META_layer",
16455db71995Sopenharmony_ci       "type": "GLOBAL",
16465db71995Sopenharmony_ci       "api_version" : "1.0.40",
16475db71995Sopenharmony_ci       "implementation_version" : "1",
16485db71995Sopenharmony_ci       "description" : "LunarG Meta-layer example",
16495db71995Sopenharmony_ci       "component_layers": [
16505db71995Sopenharmony_ci           "VK_LAYER_KHRONOS_validation",
16515db71995Sopenharmony_ci           "VK_LAYER_LUNARG_api_dump"
16525db71995Sopenharmony_ci       ]
16535db71995Sopenharmony_ci   }
16545db71995Sopenharmony_ci}
16555db71995Sopenharmony_ci```
16565db71995Sopenharmony_ci
16575db71995Sopenharmony_ci
16585db71995Sopenharmony_ci<table style="width:100%">
16595db71995Sopenharmony_ci  <tr>
16605db71995Sopenharmony_ci    <th>JSON Node</th>
16615db71995Sopenharmony_ci    <th>Description and Notes</th>
16625db71995Sopenharmony_ci    <th>Restrictions</th>
16635db71995Sopenharmony_ci    <th>Parent</th>
16645db71995Sopenharmony_ci    <th>Introspection Query</th>
16655db71995Sopenharmony_ci  </tr>
16665db71995Sopenharmony_ci  <tr>
16675db71995Sopenharmony_ci    <td>"api_version"</td>
16685db71995Sopenharmony_ci    <td>The major.minor.patch version number of the Vulkan API that the layer
16695db71995Sopenharmony_ci        supports.
16705db71995Sopenharmony_ci        It does not require the application to make use of that API version.
16715db71995Sopenharmony_ci        It simply is an indication that the layer can support Vulkan API
16725db71995Sopenharmony_ci        instance and device functions up to and including that API version.</br>
16735db71995Sopenharmony_ci        For example: 1.0.33.
16745db71995Sopenharmony_ci    </td>
16755db71995Sopenharmony_ci    <td>None</td>
16765db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
16775db71995Sopenharmony_ci    <td><small>vkEnumerateInstanceLayerProperties</small></td>
16785db71995Sopenharmony_ci  </tr>
16795db71995Sopenharmony_ci  <tr>
16805db71995Sopenharmony_ci    <td>"app_keys"</td>
16815db71995Sopenharmony_ci    <td>List of paths to executables that the meta-layer applies to.
16825db71995Sopenharmony_ci    </td>
16835db71995Sopenharmony_ci    <td><b>Meta-layers Only</b></td>
16845db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
16855db71995Sopenharmony_ci    <td><small>N/A</small></td>
16865db71995Sopenharmony_ci  </tr>
16875db71995Sopenharmony_ci  <tr>
16885db71995Sopenharmony_ci    <td>"blacklisted_layers"</td>
16895db71995Sopenharmony_ci    <td>List of explicit layer names that should not be loaded even if
16905db71995Sopenharmony_ci        requested by the application.
16915db71995Sopenharmony_ci    </td>
16925db71995Sopenharmony_ci    <td><b>Meta-layers Only</b></td>
16935db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
16945db71995Sopenharmony_ci    <td><small>N/A</small></td>
16955db71995Sopenharmony_ci  </tr>
16965db71995Sopenharmony_ci  <tr>
16975db71995Sopenharmony_ci    <td>"component_layers"</td>
16985db71995Sopenharmony_ci    <td>Indicates the component layer names that are
16995db71995Sopenharmony_ci        part of a meta-layer.
17005db71995Sopenharmony_ci        The names listed must be the "name" identified in each of the component
17015db71995Sopenharmony_ci        layer's Mainfest file "name" tag (this is the same as the name of the
17025db71995Sopenharmony_ci        layer that is passed to the `vkCreateInstance` command).
17035db71995Sopenharmony_ci        All component layers must be present on the system and found by the
17045db71995Sopenharmony_ci        loader in order for this meta-layer to be available and activated. <br/>
17055db71995Sopenharmony_ci        <b>This field must not be present if "library_path" is defined</b>.
17065db71995Sopenharmony_ci    </td>
17075db71995Sopenharmony_ci    <td><b>Meta-layers Only</b></td>
17085db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
17095db71995Sopenharmony_ci    <td><small>N/A</small></td>
17105db71995Sopenharmony_ci  </tr>
17115db71995Sopenharmony_ci  <tr>
17125db71995Sopenharmony_ci    <td>"description"</td>
17135db71995Sopenharmony_ci    <td>A high-level description of the layer and its intended use.</td>
17145db71995Sopenharmony_ci    <td>None</td>
17155db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
17165db71995Sopenharmony_ci    <td><small>vkEnumerateInstanceLayerProperties</small></td>
17175db71995Sopenharmony_ci  </tr>
17185db71995Sopenharmony_ci  <tr>
17195db71995Sopenharmony_ci    <td>"device_extensions"</td>
17205db71995Sopenharmony_ci    <td><b>OPTIONAL:</b> Contains the list of device extension names supported
17215db71995Sopenharmony_ci        by this layer. One "device\_extensions" node with an array of one or
17225db71995Sopenharmony_ci        more elements is required if any device extensions are supported by a
17235db71995Sopenharmony_ci        layer; otherwise the node is optional.
17245db71995Sopenharmony_ci        Each element of the array must have the nodes "name" and "spec_version"
17255db71995Sopenharmony_ci        which correspond to `VkExtensionProperties` "extensionName" and
17265db71995Sopenharmony_ci        "specVersion" respectively.
17275db71995Sopenharmony_ci        Additionally, each element of the array of device extensions must have
17285db71995Sopenharmony_ci        the node "entrypoints" if the device extension adds Vulkan API
17295db71995Sopenharmony_ci        functions; otherwise this node is not required.
17305db71995Sopenharmony_ci        The "entrypoint" node is an array of the names of all entry-points added
17315db71995Sopenharmony_ci        by the supported extension.
17325db71995Sopenharmony_ci    </td>
17335db71995Sopenharmony_ci    <td>None</td>
17345db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
17355db71995Sopenharmony_ci    <td><small>vkEnumerateDeviceExtensionProperties</small></td>
17365db71995Sopenharmony_ci  </tr>
17375db71995Sopenharmony_ci  <tr>
17385db71995Sopenharmony_ci    <td>"disable_environment"</td>
17395db71995Sopenharmony_ci    <td><b>REQUIRED:</b> Indicates an environment variable used to disable the
17405db71995Sopenharmony_ci        Implicit Layer (when defined to any non-empty string value).<br/>
17415db71995Sopenharmony_ci        In rare cases of an application not working with an implicit layer, the
17425db71995Sopenharmony_ci        application can set this environment variable (before calling Vulkan
17435db71995Sopenharmony_ci        functions) in order to "blacklist" the layer.
17445db71995Sopenharmony_ci        This environment variable (which may vary with each variation of the
17455db71995Sopenharmony_ci        layer) must be set (not particularly to any value).
17465db71995Sopenharmony_ci        If both the "enable_environment" and "disable_environment" variables are
17475db71995Sopenharmony_ci        set, the implicit layer is disabled.
17485db71995Sopenharmony_ci    </td>
17495db71995Sopenharmony_ci    <td><b>Implicit Layers Only</b></td>
17505db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
17515db71995Sopenharmony_ci    <td><small>N/A</small></td>
17525db71995Sopenharmony_ci  </tr>
17535db71995Sopenharmony_ci  <tr>
17545db71995Sopenharmony_ci    <td>"enable_environment"</td>
17555db71995Sopenharmony_ci    <td><b>OPTIONAL:</b> Indicates an environment variable used to enable the
17565db71995Sopenharmony_ci        Implicit Layer (when defined to any non-empty string value).<br/>
17575db71995Sopenharmony_ci        This environment variable (which may vary with each variation of the
17585db71995Sopenharmony_ci        layer) must be set to the given value or else the implicit layer is not
17595db71995Sopenharmony_ci        loaded.
17605db71995Sopenharmony_ci        This is for application environments (e.g. Steam) which want to enable a
17615db71995Sopenharmony_ci        layer(s) only for applications that they launch, and allows for
17625db71995Sopenharmony_ci        applications run outside of an application environment to not get that
17635db71995Sopenharmony_ci        implicit layer(s).
17645db71995Sopenharmony_ci    </td>
17655db71995Sopenharmony_ci    <td><b>Implicit Layers Only</b></td>
17665db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
17675db71995Sopenharmony_ci    <td><small>N/A</small></td>
17685db71995Sopenharmony_ci  </tr>
17695db71995Sopenharmony_ci  <tr>
17705db71995Sopenharmony_ci    <td>"file_format_version"</td>
17715db71995Sopenharmony_ci    <td>Manifest format major.minor.patch version number.<br/>
17725db71995Sopenharmony_ci        Supported versions are: 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.1.2 and 1.2.0.
17735db71995Sopenharmony_ci    </td>
17745db71995Sopenharmony_ci    <td>None</td>
17755db71995Sopenharmony_ci    <td>None</td>
17765db71995Sopenharmony_ci    <td><small>N/A</small></td>
17775db71995Sopenharmony_ci  </tr>
17785db71995Sopenharmony_ci  <tr>
17795db71995Sopenharmony_ci    <td>"functions"</td>
17805db71995Sopenharmony_ci    <td><b>OPTIONAL:</b> This section can be used to identify a different
17815db71995Sopenharmony_ci        function name for the loader to use in place of standard layer interface
17825db71995Sopenharmony_ci        functions.
17835db71995Sopenharmony_ci        The "functions" node is required if the layer is using an alternative
17845db71995Sopenharmony_ci        name for `vkNegotiateLoaderLayerInterfaceVersion`.
17855db71995Sopenharmony_ci    </td>
17865db71995Sopenharmony_ci    <td>None</td>
17875db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
17885db71995Sopenharmony_ci    <td><small>vkGet*ProcAddr</small></td>
17895db71995Sopenharmony_ci  </tr>
17905db71995Sopenharmony_ci  <tr>
17915db71995Sopenharmony_ci    <td>"implementation_version"</td>
17925db71995Sopenharmony_ci    <td>The version of the layer implemented.
17935db71995Sopenharmony_ci        If the layer itself has any major changes, this number should change so
17945db71995Sopenharmony_ci        the loader and/or application can identify it properly.
17955db71995Sopenharmony_ci    </td>
17965db71995Sopenharmony_ci    <td>None</td>
17975db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
17985db71995Sopenharmony_ci    <td><small>vkEnumerateInstanceLayerProperties</small></td>
17995db71995Sopenharmony_ci  </tr>
18005db71995Sopenharmony_ci  <tr>
18015db71995Sopenharmony_ci    <td>"instance_extensions"</td>
18025db71995Sopenharmony_ci    <td><b>OPTIONAL:</b> Contains the list of instance extension names
18035db71995Sopenharmony_ci        supported by this layer.
18045db71995Sopenharmony_ci        One "instance_extensions" node with an array of one or more elements is
18055db71995Sopenharmony_ci        required if any instance extensions are supported by a layer; otherwise
18065db71995Sopenharmony_ci        the node is optional.
18075db71995Sopenharmony_ci        Each element of the array must have the nodes "name" and "spec_version"
18085db71995Sopenharmony_ci        which correspond to `VkExtensionProperties` "extensionName" and
18095db71995Sopenharmony_ci        "specVersion" respectively.
18105db71995Sopenharmony_ci    </td>
18115db71995Sopenharmony_ci    <td>None</td>
18125db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
18135db71995Sopenharmony_ci    <td><small>vkEnumerateInstanceExtensionProperties</small></td>
18145db71995Sopenharmony_ci  </tr>
18155db71995Sopenharmony_ci  <tr>
18165db71995Sopenharmony_ci    <td>"layer"</td>
18175db71995Sopenharmony_ci    <td>The identifier used to group a single layer's information together.
18185db71995Sopenharmony_ci    </td>
18195db71995Sopenharmony_ci    <td>None</td>
18205db71995Sopenharmony_ci    <td>None</td>
18215db71995Sopenharmony_ci    <td><small>vkEnumerateInstanceLayerProperties</small></td>
18225db71995Sopenharmony_ci  </tr>
18235db71995Sopenharmony_ci  <tr>
18245db71995Sopenharmony_ci    <td>"layers"</td>
18255db71995Sopenharmony_ci    <td>The identifier used to group multiple layers' information together.
18265db71995Sopenharmony_ci        This requires a minimum Manifest file format version of 1.0.1.
18275db71995Sopenharmony_ci    </td>
18285db71995Sopenharmony_ci    <td>None</td>
18295db71995Sopenharmony_ci    <td>None</td>
18305db71995Sopenharmony_ci    <td><small>vkEnumerateInstanceLayerProperties</small></td>
18315db71995Sopenharmony_ci  </tr>
18325db71995Sopenharmony_ci  <tr>
18335db71995Sopenharmony_ci    <td>"library_path"</td>
18345db71995Sopenharmony_ci    <td>Specifies either a filename, a relative pathname, or a full pathname to
18355db71995Sopenharmony_ci        a layer shared library file.
18365db71995Sopenharmony_ci        If "library_path" specifies a relative pathname, it is relative to the
18375db71995Sopenharmony_ci        path of the JSON manifest file (e.g. for cases when an application
18385db71995Sopenharmony_ci        provides a layer that is in the same folder hierarchy as the rest of the
18395db71995Sopenharmony_ci        application files).
18405db71995Sopenharmony_ci        If "library_path" specifies a filename, the library must live in the
18415db71995Sopenharmony_ci        system's shared object search path.
18425db71995Sopenharmony_ci        There are no rules about the name of the layer shared library files
18435db71995Sopenharmony_ci        other than it should end with the appropriate suffix (".DLL" on Windows,
18445db71995Sopenharmony_ci        ".so" on Linux, and ".dylib" on macOS).<br/>
18455db71995Sopenharmony_ci        <b>This field must not be present if "component_layers" is defined</b>.
18465db71995Sopenharmony_ci    </td>
18475db71995Sopenharmony_ci    <td><b>Not Valid For Meta-layers</b></td>
18485db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
18495db71995Sopenharmony_ci    <td><small>N/A</small></td>
18505db71995Sopenharmony_ci  </tr>
18515db71995Sopenharmony_ci  <td>"library_arch"</td>
18525db71995Sopenharmony_ci    <td>Optional field which specifies the architecture of the binary associated
18535db71995Sopenharmony_ci        with "library_path". <br />
18545db71995Sopenharmony_ci        Allows the loader to quickly determine if the architecture of the layer
18555db71995Sopenharmony_ci        matches that of the running application. <br />
18565db71995Sopenharmony_ci        The only valid values are "32" and "64".</td>
18575db71995Sopenharmony_ci    <td><small>N/A</small></td>
18585db71995Sopenharmony_ci  </tr>
18595db71995Sopenharmony_ci  <tr>
18605db71995Sopenharmony_ci  <tr>
18615db71995Sopenharmony_ci    <td>"name"</td>
18625db71995Sopenharmony_ci    <td>The string used to uniquely identify this layer to applications.</td>
18635db71995Sopenharmony_ci    <td>None</td>
18645db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
18655db71995Sopenharmony_ci    <td><small>vkEnumerateInstanceLayerProperties</small></td>
18665db71995Sopenharmony_ci  </tr>
18675db71995Sopenharmony_ci  <tr>
18685db71995Sopenharmony_ci    <td>"override_paths"</td>
18695db71995Sopenharmony_ci    <td>List of paths which will be used as the search location for component
18705db71995Sopenharmony_ci        layers.
18715db71995Sopenharmony_ci    </td>
18725db71995Sopenharmony_ci    <td><b>Meta-layers Only</b></td>
18735db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
18745db71995Sopenharmony_ci    <td><small>N/A</small></td>
18755db71995Sopenharmony_ci  </tr>
18765db71995Sopenharmony_ci  <tr>
18775db71995Sopenharmony_ci    <td>"pre_instance_functions"</td>
18785db71995Sopenharmony_ci    <td><b>OPTIONAL:</b> Indicates which functions the layer wishes to
18795db71995Sopenharmony_ci        intercept, that do not require that an instance has been created.
18805db71995Sopenharmony_ci        This should be an object where each function to be intercepted is
18815db71995Sopenharmony_ci        defined as a string entry where the key is the Vulkan function name and
18825db71995Sopenharmony_ci        the value is the name of the intercept function in the layer's dynamic
18835db71995Sopenharmony_ci        library.
18845db71995Sopenharmony_ci        Available in layer manifest versions 1.1.2 and up. <br/>
18855db71995Sopenharmony_ci        See <a href="#pre-instance-functions">Pre-Instance Functions</a> for
18865db71995Sopenharmony_ci        more information.
18875db71995Sopenharmony_ci    </td>
18885db71995Sopenharmony_ci    <td><b>Implicit Layers Only</b></td>
18895db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
18905db71995Sopenharmony_ci    <td><small>vkEnumerateInstance*Properties</small></td>
18915db71995Sopenharmony_ci  </tr>
18925db71995Sopenharmony_ci  <tr>
18935db71995Sopenharmony_ci    <td>"type"</td>
18945db71995Sopenharmony_ci    <td>This field indicates the type of layer.  The values can be: GLOBAL, or
18955db71995Sopenharmony_ci        INSTANCE.<br/>
18965db71995Sopenharmony_ci        <b> NOTE: </b> Prior to deprecation, the "type" node was used to
18975db71995Sopenharmony_ci        indicate which layer chain(s) to activate the layer upon: instance,
18985db71995Sopenharmony_ci        device, or both.
18995db71995Sopenharmony_ci        Distinct instance and device layers are deprecated; there are now just
19005db71995Sopenharmony_ci        instance layers.
19015db71995Sopenharmony_ci        Originally, allowable values were "INSTANCE", "GLOBAL" and, "DEVICE."
19025db71995Sopenharmony_ci        But now "DEVICE" layers are skipped over by the loader as if they were
19035db71995Sopenharmony_ci        not found.
19045db71995Sopenharmony_ci    </td>
19055db71995Sopenharmony_ci    <td>None</td>
19065db71995Sopenharmony_ci    <td>"layer"/"layers"</td>
19075db71995Sopenharmony_ci    <td><small>vkEnumerate*LayerProperties</small></td>
19085db71995Sopenharmony_ci  </tr>
19095db71995Sopenharmony_ci</table>
19105db71995Sopenharmony_ci
19115db71995Sopenharmony_ci### Layer Manifest File Version History
19125db71995Sopenharmony_ci
19135db71995Sopenharmony_ciThe current highest supported Layer Manifest file format supported is 1.2.0.
19145db71995Sopenharmony_ciInformation about each version is detailed in the following sub-sections:
19155db71995Sopenharmony_ci
19165db71995Sopenharmony_ci### Layer Manifest File Version 1.2.1
19175db71995Sopenharmony_ci
19185db71995Sopenharmony_ciAdded the "library\_arch" field to the layer manifest to allow the loader to
19195db71995Sopenharmony_ciquickly determine if the layer matches the architecture of the current running
19205db71995Sopenharmony_ciapplication.
19215db71995Sopenharmony_ci
19225db71995Sopenharmony_ci#### Layer Manifest File Version 1.2.0
19235db71995Sopenharmony_ci
19245db71995Sopenharmony_ciThe ability to define the layer settings as defined by the
19255db71995Sopenharmony_ci[layer manifest schema](https://github.com/LunarG/VulkanTools/blob/main/vkconfig_core/layers/layers_schema.json).
19265db71995Sopenharmony_ci
19275db71995Sopenharmony_ciThe ability to briefly document the layer thanks to the fields:
19285db71995Sopenharmony_ci * "introduction": Presentation of the purpose of the layer in a paragraph.
19295db71995Sopenharmony_ci * "url": A link the the layer home page.
19305db71995Sopenharmony_ci * "platforms": The list of supported platforms of the layer
19315db71995Sopenharmony_ci * "status": The life cycle of the layer: Alpha, Beta, Stable, or Deprecated
19325db71995Sopenharmony_ci
19335db71995Sopenharmony_ciThese changes were made to enable third-party layers to expose their features
19345db71995Sopenharmony_ciwithin
19355db71995Sopenharmony_ci[Vulkan Configurator](https://github.com/LunarG/VulkanTools/blob/main/vkconfig/README.md)
19365db71995Sopenharmony_cior other tools.
19375db71995Sopenharmony_ci
19385db71995Sopenharmony_ci#### Layer Manifest File Version 1.1.2
19395db71995Sopenharmony_ci
19405db71995Sopenharmony_ciVersion 1.1.2 introduced the ability of layers to intercept function calls that
19415db71995Sopenharmony_cido not have an instance.
19425db71995Sopenharmony_ci
19435db71995Sopenharmony_ci#### Layer Manifest File Version 1.1.1
19445db71995Sopenharmony_ci
19455db71995Sopenharmony_ciThe ability to define custom metalayers was added.
19465db71995Sopenharmony_ciTo support metalayers, the "component_layers" section was added, and the
19475db71995Sopenharmony_cirequirement for a "library_path" section to be present was removed when the
19485db71995Sopenharmony_ci"component_layers" section is present.
19495db71995Sopenharmony_ci
19505db71995Sopenharmony_ci#### Layer Manifest File Version 1.1.0
19515db71995Sopenharmony_ci
19525db71995Sopenharmony_ciLayer Manifest File Version 1.1.0 is tied to changes exposed by the
19535db71995Sopenharmony_ciLoader/Layer interface version 2.
19545db71995Sopenharmony_ci  1. Renaming "vkGetInstanceProcAddr" in the "functions" section is deprecated
19555db71995Sopenharmony_cisince the loader no longer needs to query the layer about
19565db71995Sopenharmony_ci"vkGetInstanceProcAddr" directly.
19575db71995Sopenharmony_ciIt is now returned during the layer negotiation, so this field will be
19585db71995Sopenharmony_ciignored.
19595db71995Sopenharmony_ci  2. Renaming "vkGetDeviceProcAddr" in the "functions" section is
19605db71995Sopenharmony_cideprecated since the loader no longer needs to query the layer about
19615db71995Sopenharmony_ci"vkGetDeviceProcAddr" directly.
19625db71995Sopenharmony_ciIt too is now returned during the layer negotiation, so this field will be
19635db71995Sopenharmony_ciignored.
19645db71995Sopenharmony_ci  3. Renaming the "vkNegotiateLoaderLayerInterfaceVersion" function is being
19655db71995Sopenharmony_ciadded to the "functions" section, since this is now the only function the
19665db71995Sopenharmony_ciloader needs to query using OS-specific calls.
19675db71995Sopenharmony_ci      - NOTE: This is an optional field and, as the two previous fields, only
19685db71995Sopenharmony_cineeded if the layer requires changing the name of the function for some reason.
19695db71995Sopenharmony_ci
19705db71995Sopenharmony_ciThe layer manifest file does not need to to be updated if the names of any
19715db71995Sopenharmony_cilisted functions has not changed.
19725db71995Sopenharmony_ci
19735db71995Sopenharmony_ci#### Layer Manifest File Version 1.0.1
19745db71995Sopenharmony_ci
19755db71995Sopenharmony_ciThe ability to define multiple layers using the "layers" array was added.
19765db71995Sopenharmony_ciThis JSON array field can be used when defining a single layer or multiple
19775db71995Sopenharmony_cilayers.
19785db71995Sopenharmony_ciThe "layer" field is still present and valid for a single layer definition.
19795db71995Sopenharmony_ci
19805db71995Sopenharmony_ci#### Layer Manifest File Version 1.0.0
19815db71995Sopenharmony_ci
19825db71995Sopenharmony_ciThe initial version of the layer manifest file specified the basic format and
19835db71995Sopenharmony_cifields of a layer JSON file.
19845db71995Sopenharmony_ciThe fields of the 1.0.0 file format include:
19855db71995Sopenharmony_ci * "file\_format\_version"
19865db71995Sopenharmony_ci * "layer"
19875db71995Sopenharmony_ci * "name"
19885db71995Sopenharmony_ci * "type"
19895db71995Sopenharmony_ci * "library\_path"
19905db71995Sopenharmony_ci * "api\_version"
19915db71995Sopenharmony_ci * "implementation\_version"
19925db71995Sopenharmony_ci * "description"
19935db71995Sopenharmony_ci * "functions"
19945db71995Sopenharmony_ci * "instance\_extensions"
19955db71995Sopenharmony_ci * "device\_extensions"
19965db71995Sopenharmony_ci * "enable\_environment"
19975db71995Sopenharmony_ci * "disable\_environment"
19985db71995Sopenharmony_ci
19995db71995Sopenharmony_ciIt was also during this time that the value of "DEVICE" was deprecated from
20005db71995Sopenharmony_cithe "type" field.
20015db71995Sopenharmony_ci
20025db71995Sopenharmony_ci
20035db71995Sopenharmony_ci## Layer Interface Versions
20045db71995Sopenharmony_ci
20055db71995Sopenharmony_ciThe current loader/layer interface is at version 2.
20065db71995Sopenharmony_ciThe following sections detail the differences between the various versions.
20075db71995Sopenharmony_ci
20085db71995Sopenharmony_ci### Layer Interface Version 2
20095db71995Sopenharmony_ci
20105db71995Sopenharmony_ciIntroduced the concept of
20115db71995Sopenharmony_ci[loader and layer interface](#layer-version-negotiation) using the
20125db71995Sopenharmony_ci`vkNegotiateLoaderLayerInterfaceVersion` function.
20135db71995Sopenharmony_ciAdditionally, it introduced the concept of
20145db71995Sopenharmony_ci[Layer Unknown Physical Device Extensions](#layer-unknown-physical-device-extensions)
20155db71995Sopenharmony_ciand the associated `vk_layerGetPhysicalDeviceProcAddr` function.
20165db71995Sopenharmony_ciFinally, it changed the manifest file definition to 1.1.0.
20175db71995Sopenharmony_ci
20185db71995Sopenharmony_ciNote: If a layer wraps the VkInstance handle, support for
20195db71995Sopenharmony_ci`vk_layerGetPhysicalDeviceProcAddr` is *NOT* optional and must be implemented.
20205db71995Sopenharmony_ci
20215db71995Sopenharmony_ci### Layer Interface Version 1
20225db71995Sopenharmony_ci
20235db71995Sopenharmony_ciA layer supporting interface version 1 had the following behavior:
20245db71995Sopenharmony_ci 1. `vkGetInstanceProcAddr` and `vkGetDeviceProcAddr` were directly exported
20255db71995Sopenharmony_ci 2. The layer manifest file was able to override the names of the
20265db71995Sopenharmony_ci`GetInstanceProcAddr` and `GetDeviceProcAddr`functions.
20275db71995Sopenharmony_ci
20285db71995Sopenharmony_ci### Layer Interface Version 0
20295db71995Sopenharmony_ci
20305db71995Sopenharmony_ciA layer supporting interface version 0 must define and export these
20315db71995Sopenharmony_ciintrospection functions, unrelated to any Vulkan function despite the names,
20325db71995Sopenharmony_cisignatures, and other similarities:
20335db71995Sopenharmony_ci
20345db71995Sopenharmony_ci- `vkEnumerateInstanceLayerProperties` enumerates all layers in a
20355db71995Sopenharmony_ci`Layer Library`.
20365db71995Sopenharmony_ci  - This function never fails.
20375db71995Sopenharmony_ci  - When the `Layer Library` contains only one layer, this function may be an
20385db71995Sopenharmony_ci   alias to that one layer's `vkEnumerateInstanceLayerProperties`.
20395db71995Sopenharmony_ci- `vkEnumerateInstanceExtensionProperties` enumerates instance extensions of
20405db71995Sopenharmony_ci   layers in the `Layer Library`.
20415db71995Sopenharmony_ci  - "pLayerName" is always a valid layer name.
20425db71995Sopenharmony_ci  - This function never fails.
20435db71995Sopenharmony_ci  - When the `Layer Library` contains only one layer, this function may be an
20445db71995Sopenharmony_ci   alias to the one layer's `vkEnumerateInstanceExtensionProperties`.
20455db71995Sopenharmony_ci- `vkEnumerateDeviceLayerProperties` enumerates a subset (can be full,
20465db71995Sopenharmony_ci   proper, or empty subset) of layers in the `Layer Library`.
20475db71995Sopenharmony_ci  - "physicalDevice" is always `VK_NULL_HANDLE`.
20485db71995Sopenharmony_ci  - This function never fails.
20495db71995Sopenharmony_ci  - If a layer is not enumerated by this function, it will not participate in
20505db71995Sopenharmony_ci   device function interception.
20515db71995Sopenharmony_ci- `vkEnumerateDeviceExtensionProperties` enumerates device extensions of
20525db71995Sopenharmony_ci   layers in the `Layer Library`.
20535db71995Sopenharmony_ci  - "physicalDevice" is always `VK_NULL_HANDLE`.
20545db71995Sopenharmony_ci  - "pLayerName" is always a valid layer name.
20555db71995Sopenharmony_ci  - This function never fails.
20565db71995Sopenharmony_ci
20575db71995Sopenharmony_ciIt must also define and export these functions once for each layer in the
20585db71995Sopenharmony_cilibrary:
20595db71995Sopenharmony_ci
20605db71995Sopenharmony_ci- `<layerName>GetInstanceProcAddr(instance, pName)` behaves identically to a
20615db71995Sopenharmony_cilayer's vkGetInstanceProcAddr except it is exported.
20625db71995Sopenharmony_ci
20635db71995Sopenharmony_ci   When the `Layer Library` contains only one layer, this function may
20645db71995Sopenharmony_ci   alternatively be named `vkGetInstanceProcAddr`.
20655db71995Sopenharmony_ci
20665db71995Sopenharmony_ci- `<layerName>GetDeviceProcAddr`  behaves identically to a layer's
20675db71995Sopenharmony_civkGetDeviceProcAddr except it is exported.
20685db71995Sopenharmony_ci
20695db71995Sopenharmony_ci   When the `Layer Library` contains only one layer, this function may
20705db71995Sopenharmony_ci   alternatively be named `vkGetDeviceProcAddr`.
20715db71995Sopenharmony_ci
20725db71995Sopenharmony_ciAll layers contained within a library must support `vk_layer.h`.
20735db71995Sopenharmony_ciThey do not need to implement functions that they do not intercept.
20745db71995Sopenharmony_ciThey are recommended not to export any functions.
20755db71995Sopenharmony_ci
20765db71995Sopenharmony_ci
20775db71995Sopenharmony_ci## Loader and Layer Interface Policy
20785db71995Sopenharmony_ci
20795db71995Sopenharmony_ciThis section is intended to define proper behavior expected between the loader
20805db71995Sopenharmony_ciand layers.
20815db71995Sopenharmony_ciMuch of this section is additive to the Vulkan spec, and necessary for
20825db71995Sopenharmony_cimaintaining consistency across platforms.
20835db71995Sopenharmony_ciIn fact, much of the language can be found throughout this document, but is
20845db71995Sopenharmony_cisummarized here for convenience.
20855db71995Sopenharmony_ciAdditionally, there should be a way to identify bad or non-conformant behavior
20865db71995Sopenharmony_ciin a layer and remedy it as soon as possible.
20875db71995Sopenharmony_ciTherefore, a policy numbering system is provided to clearly identify each
20885db71995Sopenharmony_cipolicy statement in a unique way.
20895db71995Sopenharmony_ci
20905db71995Sopenharmony_ciFinally, based on the goal of making the loader efficient and performant,
20915db71995Sopenharmony_cisome of these policy statements defining proper layer behavior may not be
20925db71995Sopenharmony_citestable (and therefore aren't enforceable by the loader).
20935db71995Sopenharmony_ciHowever, that should not detract from the requirement in order to provide the
20945db71995Sopenharmony_cibest experience to end-users and developers.
20955db71995Sopenharmony_ci
20965db71995Sopenharmony_ci
20975db71995Sopenharmony_ci### Number Format
20985db71995Sopenharmony_ci
20995db71995Sopenharmony_ciLoader/Layer policy items start with the prefix `LLP_` (short for
21005db71995Sopenharmony_ciLoader/Layer Policy) which is followed by an identifier based on what
21015db71995Sopenharmony_cicomponent the policy is targeted against.
21025db71995Sopenharmony_ciIn this case there are only two possible components:
21035db71995Sopenharmony_ci - Layers: which will have the string `LAYER_` as part of the policy number.
21045db71995Sopenharmony_ci - The Loader: which will have the string `LOADER_` as part of the policy
21055db71995Sopenharmony_ci   number.
21065db71995Sopenharmony_ci
21075db71995Sopenharmony_ci
21085db71995Sopenharmony_ci### Android Differences
21095db71995Sopenharmony_ci
21105db71995Sopenharmony_ciAs stated before, the Android Loader is actually separate from the Khronos
21115db71995Sopenharmony_ciLoader.
21125db71995Sopenharmony_ciBecause of this and other platform requirements, not all of these policy
21135db71995Sopenharmony_cistatements apply to Android.
21145db71995Sopenharmony_ciEach table also has a column titled "Applicable to Android?"
21155db71995Sopenharmony_ciwhich indicates which policy statements apply to layers that are focused
21165db71995Sopenharmony_cionly on Android support.
21175db71995Sopenharmony_ciFurther information on the Android loader can be found in the
21185db71995Sopenharmony_ci<a href="https://source.android.com/devices/graphics/implement-vulkan">
21195db71995Sopenharmony_ciAndroid Vulkan documentation</a>.
21205db71995Sopenharmony_ci
21215db71995Sopenharmony_ci
21225db71995Sopenharmony_ci### Requirements of Well-Behaved Layers
21235db71995Sopenharmony_ci
21245db71995Sopenharmony_ci<table style="width:100%">
21255db71995Sopenharmony_ci  <tr>
21265db71995Sopenharmony_ci    <th>Requirement Number</th>
21275db71995Sopenharmony_ci    <th>Requirement Description</th>
21285db71995Sopenharmony_ci    <th>Result of Non-Compliance</th>
21295db71995Sopenharmony_ci    <th>Applicable to Android?</th>
21305db71995Sopenharmony_ci    <th>Enforceable by Loader?</th>
21315db71995Sopenharmony_ci    <th>Reference Section</th>
21325db71995Sopenharmony_ci  </tr>
21335db71995Sopenharmony_ci  <tr>
21345db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_1</b></small></td>
21355db71995Sopenharmony_ci    <td>A layer, when inserted into an otherwise compliant Vulkan
21365db71995Sopenharmony_ci        environment, <b>must</b> still result in a compliant Vulkan environment
21375db71995Sopenharmony_ci        unless it intends to mimic non-compliant behavior (such as a device
21385db71995Sopenharmony_ci        simulation layer).
21395db71995Sopenharmony_ci    </td>
21405db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
21415db71995Sopenharmony_ci    <td>Yes</td>
21425db71995Sopenharmony_ci    <td>No<br/>
21435db71995Sopenharmony_ci        It is not a simple task for the loader to find the cause of failure
21445db71995Sopenharmony_ci        in a layer chain.</td>
21455db71995Sopenharmony_ci    <td><small>
21465db71995Sopenharmony_ci        <a href="#layer-conventions-and-rules">Layer Conventions and Rules</a>
21475db71995Sopenharmony_ci        </small>
21485db71995Sopenharmony_ci    </td>
21495db71995Sopenharmony_ci  </tr>
21505db71995Sopenharmony_ci  <tr>
21515db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_2</b></small></td>
21525db71995Sopenharmony_ci    <td>A layer <b>must not</b> cause other layers or drivers to fail, crash, or
21535db71995Sopenharmony_ci        otherwise misbehave.<br/>
21545db71995Sopenharmony_ci        It <b>must not</b> make invalid calls to, or rely on undefined behaviors
21555db71995Sopenharmony_ci        of the layers or drivers below it.
21565db71995Sopenharmony_ci    </td>
21575db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
21585db71995Sopenharmony_ci    <td>Yes</td>
21595db71995Sopenharmony_ci    <td>No<br/>
21605db71995Sopenharmony_ci        It is not a simple task for the loader to find the cause of failure
21615db71995Sopenharmony_ci        in a layer chain.</td>
21625db71995Sopenharmony_ci    <td><small>
21635db71995Sopenharmony_ci        <a href="#layer-conventions-and-rules">Layer Conventions and Rules</a>
21645db71995Sopenharmony_ci        </small>
21655db71995Sopenharmony_ci    </td>
21665db71995Sopenharmony_ci  </tr>
21675db71995Sopenharmony_ci  <tr>
21685db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_3</b></small></td>
21695db71995Sopenharmony_ci    <td>Any new layer developed <b>should</b> adhere to the naming rules defined
21705db71995Sopenharmony_ci        in the "Layer Conventions and Rules" section which also correspond to
21715db71995Sopenharmony_ci        the naming rules defined in the Vulkan Style Guide section 3.4 on
21725db71995Sopenharmony_ci        "Version, Extension, and Layer Naming Conventions".
21735db71995Sopenharmony_ci    </td>
21745db71995Sopenharmony_ci    <td>Layer developers could produce conflicting names causing unexpected
21755db71995Sopenharmony_ci        behavior if more than one layer with the same name is available on a
21765db71995Sopenharmony_ci        user's platform.
21775db71995Sopenharmony_ci    </td>
21785db71995Sopenharmony_ci    <td>Yes</td>
21795db71995Sopenharmony_ci    <td>Yes<br/>
21805db71995Sopenharmony_ci        Can not immediately enforce since it will cause some shipping layers
21815db71995Sopenharmony_ci        to stop working.</td>
21825db71995Sopenharmony_ci    <td><small>
21835db71995Sopenharmony_ci        <a href="https://www.khronos.org/registry/vulkan/specs/1.2/styleguide.html#extensions-naming-conventions">
21845db71995Sopenharmony_ci            Vulkan Style Guide section 3.4</a> <br/>
21855db71995Sopenharmony_ci        <a href="#layer-conventions-and-rules">Layer Conventions and Rules</a>
21865db71995Sopenharmony_ci        </small>
21875db71995Sopenharmony_ci    </td>
21885db71995Sopenharmony_ci  </tr>
21895db71995Sopenharmony_ci  <tr>
21905db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_4</b></small></td>
21915db71995Sopenharmony_ci    <td>A layer <b>should</b> export the
21925db71995Sopenharmony_ci        <i>vkNegotiateLoaderLayerInterfaceVersion</i> entry-point to negotiate
21935db71995Sopenharmony_ci        an interface version.<br/>
21945db71995Sopenharmony_ci        A layer using interface 2 or newer <b>must</b> export this function.<br/>
21955db71995Sopenharmony_ci    </td>
21965db71995Sopenharmony_ci    <td>The layer will not be loaded.</td>
21975db71995Sopenharmony_ci    <td>No</td>
21985db71995Sopenharmony_ci    <td>Yes</td>
21995db71995Sopenharmony_ci    <td><small>
22005db71995Sopenharmony_ci        <a href="#layer-version-negotiation">Layer Version Negotiation</a>
22015db71995Sopenharmony_ci        </small>
22025db71995Sopenharmony_ci    </td>
22035db71995Sopenharmony_ci  </tr>
22045db71995Sopenharmony_ci  <tr>
22055db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_5</b></small></td>
22065db71995Sopenharmony_ci    <td>A layer <b>must</b> be able to negotiate a supported version of the
22075db71995Sopenharmony_ci        loader/layer interface with the loader in accordance with the stated
22085db71995Sopenharmony_ci        negotiation process.
22095db71995Sopenharmony_ci    </td>
22105db71995Sopenharmony_ci    <td>The layer will not be loaded.</td>
22115db71995Sopenharmony_ci    <td>No</td>
22125db71995Sopenharmony_ci    <td>Yes</td>
22135db71995Sopenharmony_ci    <td><small>
22145db71995Sopenharmony_ci        <a href="#loader-and-layer-interface-negotiation">
22155db71995Sopenharmony_ci        Interface Negotiation</a></small>
22165db71995Sopenharmony_ci    </td>
22175db71995Sopenharmony_ci  </tr>
22185db71995Sopenharmony_ci  <tr>
22195db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_6</b></small></td>
22205db71995Sopenharmony_ci    <td>A layer <b>must</b> have a valid JSON manifest file for the
22215db71995Sopenharmony_ci        loader to process that ends with the ".json" suffix.
22225db71995Sopenharmony_ci        It is recommended validating the layer manifest file against
22235db71995Sopenharmony_ci        <a href="https://github.com/LunarG/VulkanTools/blob/main/vkconfig_core/layers/layers_schema.json">
22245db71995Sopenharmony_ci        the layer schema</a> prior to publication.</br>
22255db71995Sopenharmony_ci        The <b>only</b> exception is on Android which determines layer
22265db71995Sopenharmony_ci        functionality through the introspection functions defined in
22275db71995Sopenharmony_ci        <a href="#layer-library-api-version-0">Layer Library API Version 0</a>
22285db71995Sopenharmony_ci        section and in the
22295db71995Sopenharmony_ci        <a href="#layer-manifest-file-format">Layer Manifest File Format</a>
22305db71995Sopenharmony_ci        table.
22315db71995Sopenharmony_ci    </td>
22325db71995Sopenharmony_ci    <td>The layer will not be loaded.</td>
22335db71995Sopenharmony_ci    <td>No</td>
22345db71995Sopenharmony_ci    <td>Yes</td>
22355db71995Sopenharmony_ci    <td><small>
22365db71995Sopenharmony_ci        <a href="#layer-manifest-file-usage">Manifest File Usage</a></small>
22375db71995Sopenharmony_ci    </td>
22385db71995Sopenharmony_ci  </tr>
22395db71995Sopenharmony_ci  <tr>
22405db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_7</b></small></td>
22415db71995Sopenharmony_ci    <td>If a layer is a Meta-layer, each component layer in its manifest file
22425db71995Sopenharmony_ci        <b>must</b> be present on the system.
22435db71995Sopenharmony_ci    </td>
22445db71995Sopenharmony_ci    <td>The layer will not be loaded.</td>
22455db71995Sopenharmony_ci    <td>No</td>
22465db71995Sopenharmony_ci    <td>Yes</td>
22475db71995Sopenharmony_ci    <td><small>
22485db71995Sopenharmony_ci        <a href="#meta-layers">Meta-Layers</a></small>
22495db71995Sopenharmony_ci    </td>
22505db71995Sopenharmony_ci  </tr>
22515db71995Sopenharmony_ci  <tr>
22525db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_8</b></small></td>
22535db71995Sopenharmony_ci    <td>If a layer is a Meta-layer, each component layer in its manifest file
22545db71995Sopenharmony_ci        <b>must</b> report the same or a newer Vulkan API major and minor
22555db71995Sopenharmony_ci        version than the meta-layer.
22565db71995Sopenharmony_ci    </td>
22575db71995Sopenharmony_ci    <td>The layer will not be loaded.</td>
22585db71995Sopenharmony_ci    <td>No</td>
22595db71995Sopenharmony_ci    <td>Yes</td>
22605db71995Sopenharmony_ci    <td><small>
22615db71995Sopenharmony_ci        <a href="#meta-layers">Meta-Layers</a></small>
22625db71995Sopenharmony_ci    </td>
22635db71995Sopenharmony_ci  </tr>
22645db71995Sopenharmony_ci  <tr>
22655db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_9</b></small></td>
22665db71995Sopenharmony_ci    <td>A layer installed as an Implicit Layer <b>must</b> define a disable
22675db71995Sopenharmony_ci        environment variable so it can be disabled globally.
22685db71995Sopenharmony_ci    </td>
22695db71995Sopenharmony_ci    <td>The layer will not be loaded if it does not define the environment
22705db71995Sopenharmony_ci        variable.
22715db71995Sopenharmony_ci    </td>
22725db71995Sopenharmony_ci    <td>Yes</td>
22735db71995Sopenharmony_ci    <td>Yes</td>
22745db71995Sopenharmony_ci    <td><small>
22755db71995Sopenharmony_ci        <a href="#layer-manifest-file-format">Manifest File Format</a>, see
22765db71995Sopenharmony_ci        "disable_environment" variable</small>
22775db71995Sopenharmony_ci    </td>
22785db71995Sopenharmony_ci  </tr>
22795db71995Sopenharmony_ci  <tr>
22805db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_10</b></small></td>
22815db71995Sopenharmony_ci    <td>If a layer wraps individual object handles, it <b>must</b> unwrap those
22825db71995Sopenharmony_ci        handles when passing the handles down the chain to the next layer.
22835db71995Sopenharmony_ci    </td>
22845db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
22855db71995Sopenharmony_ci    </td>
22865db71995Sopenharmony_ci    <td>Yes</td>
22875db71995Sopenharmony_ci    <td>No</td>
22885db71995Sopenharmony_ci    <td><small>
22895db71995Sopenharmony_ci      <a href="#cautions-about-wrapping">Cautions About Wrapping</a></small>
22905db71995Sopenharmony_ci    </td>
22915db71995Sopenharmony_ci  </tr>
22925db71995Sopenharmony_ci  <tr>
22935db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_11</b></small></td>
22945db71995Sopenharmony_ci    <td>Any layer shipped with a driver <b>must</b> be validated against
22955db71995Sopenharmony_ci        conformance with the corresponding driver.
22965db71995Sopenharmony_ci    </td>
22975db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
22985db71995Sopenharmony_ci    <td>Yes</td>
22995db71995Sopenharmony_ci    <td>No</td>
23005db71995Sopenharmony_ci    <td><small>
23015db71995Sopenharmony_ci        <a href="https://github.com/KhronosGroup/VK-GL-CTS/blob/main/external/openglcts/README.md">
23025db71995Sopenharmony_ci        Vulkan CTS Documentation</a>
23035db71995Sopenharmony_ci        </small>
23045db71995Sopenharmony_ci    </td>
23055db71995Sopenharmony_ci  </tr>
23065db71995Sopenharmony_ci  <tr>
23075db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_12</b></small></td>
23085db71995Sopenharmony_ci    <td> During <i>vkCreateInstance</i>, a layer <b>must</b> process the
23095db71995Sopenharmony_ci         <i>VkLayerInstanceCreateInfo</i> chain links appropriately.<br/>
23105db71995Sopenharmony_ci         This includes getting the next layer's <i>vkGetInstanceProcAddr</i>
23115db71995Sopenharmony_ci         function for building a dispatch table as well as updating the
23125db71995Sopenharmony_ci         <i>VkLayerInstanceCreateInfo</i> chain link to point to the next
23135db71995Sopenharmony_ci         structure in the chain for the next layer prior to calling down to the
23145db71995Sopenharmony_ci         next layer's <i>vkCreateInstance</i> function. <br/>
23155db71995Sopenharmony_ci         An example of such usage is shown in detail in the
23165db71995Sopenharmony_ci         <a href=#example-code-for-createinstance>Example Code for
23175db71995Sopenharmony_ci         CreateInstance</a> section.
23185db71995Sopenharmony_ci    </td>
23195db71995Sopenharmony_ci    <td>The behavior will result in crashes or corruption as any following
23205db71995Sopenharmony_ci        layers will access incorrect content.</td>
23215db71995Sopenharmony_ci    <td>Yes</td>
23225db71995Sopenharmony_ci    <td>No<br/>
23235db71995Sopenharmony_ci        With the current loader/layer design, it is difficult for the loader
23245db71995Sopenharmony_ci        to diagnose this without adding additional overhead that could impact
23255db71995Sopenharmony_ci        performance.<br/>
23265db71995Sopenharmony_ci        This is because the loader calls all layers at once and has no data on
23275db71995Sopenharmony_ci        the intermediate state of the <i>pNext</i> chain contents.
23285db71995Sopenharmony_ci        This could be done in the future, but requires re-designing the layer
23295db71995Sopenharmony_ci        initialization process.
23305db71995Sopenharmony_ci    </td>
23315db71995Sopenharmony_ci    <td><small>
23325db71995Sopenharmony_ci        <a href=""#layer-dispatch-initialization">
23335db71995Sopenharmony_ci           Layer Dispatch Initialization</a>
23345db71995Sopenharmony_ci        </small>
23355db71995Sopenharmony_ci    </td>
23365db71995Sopenharmony_ci  </tr>
23375db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_13</b></small></td>
23385db71995Sopenharmony_ci    <td> During <i>vkCreateDevice</i>, a layer <b>must</b> process the
23395db71995Sopenharmony_ci         <i>VkLayerDeviceCreateInfo</i> chain links appropriately.<br/>
23405db71995Sopenharmony_ci         This includes updating the <i>VkLayerDeviceCreateInfo</i> chain link to
23415db71995Sopenharmony_ci         point to the next structure in the chain for the next layer prior to
23425db71995Sopenharmony_ci         calling down to the next layer's <i>vkCreateDevice</i> function. <br/>
23435db71995Sopenharmony_ci         An example of such usage is shown in detail in the
23445db71995Sopenharmony_ci         <a href="#example-code-for-createdevice">Example Code for
23455db71995Sopenharmony_ci         CreateDevice</a> section.
23465db71995Sopenharmony_ci    </td>
23475db71995Sopenharmony_ci    <td>The behavior will result in crashes or corruption as any following
23485db71995Sopenharmony_ci        layers will access incorrect content.</td>
23495db71995Sopenharmony_ci    <td>Yes</td>
23505db71995Sopenharmony_ci    <td>No<br/>
23515db71995Sopenharmony_ci        With the current loader/layer design, it is difficult for the loader
23525db71995Sopenharmony_ci        to diagnose this without adding additional overhead that could impact
23535db71995Sopenharmony_ci        performance.</td>
23545db71995Sopenharmony_ci    <td><small>
23555db71995Sopenharmony_ci        <a href="#layer-dispatch-initialization">
23565db71995Sopenharmony_ci           Layer Dispatch Initialization</a>
23575db71995Sopenharmony_ci        </small>
23585db71995Sopenharmony_ci    </td>
23595db71995Sopenharmony_ci  </tr>
23605db71995Sopenharmony_ci  <tr>
23615db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_14</b></small></td>
23625db71995Sopenharmony_ci    <td>A layer <b>should</b> use the application provided memory allocator
23635db71995Sopenharmony_ci        functions when they are provided so that applications can keep track of
23645db71995Sopenharmony_ci        allocated memory.
23655db71995Sopenharmony_ci    </td>
23665db71995Sopenharmony_ci    <td>The allocator functions may be provided for the purpose of limiting
23675db71995Sopenharmony_ci        or tracking the memory used by the Vulkan components.
23685db71995Sopenharmony_ci        Because of this, if a layer ignores these allocators, it may result in
23695db71995Sopenharmony_ci        undefined behavior possibly including crashes or corruption.
23705db71995Sopenharmony_ci    </td>
23715db71995Sopenharmony_ci    <td>Yes</td>
23725db71995Sopenharmony_ci    <td>No</td>
23735db71995Sopenharmony_ci    <td><small>
23745db71995Sopenharmony_ci        <a href="#layer-conventions-and-rules">Layer Conventions and Rules</a>
23755db71995Sopenharmony_ci        </small>
23765db71995Sopenharmony_ci    </td>
23775db71995Sopenharmony_ci  </tr>
23785db71995Sopenharmony_ci  <tr>
23795db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_15</b></small></td>
23805db71995Sopenharmony_ci    <td>A layer <b>must</b> enumerate only its own extension properties during a
23815db71995Sopenharmony_ci        call of <i>vkEnumerateInstanceExtensionProperties</i> when
23825db71995Sopenharmony_ci        <i>pLayerName</i> refers to itself.<br/>
23835db71995Sopenharmony_ci        Otherwise, it <b>must</b> return <i>VK_ERROR_LAYER_NOT_PRESENT</i>,
23845db71995Sopenharmony_ci        including when <i>pLayerName</i> is <b>NULL</b>.
23855db71995Sopenharmony_ci    </td>
23865db71995Sopenharmony_ci    <td>The loader could become confused on what support is present in a
23875db71995Sopenharmony_ci        specific layer which will result in undefined behavior possibly
23885db71995Sopenharmony_ci        including crashes or corruption.
23895db71995Sopenharmony_ci    </td>
23905db71995Sopenharmony_ci    <td>Yes</td>
23915db71995Sopenharmony_ci    <td>No</td>
23925db71995Sopenharmony_ci    <td><small>
23935db71995Sopenharmony_ci        <a href="#layer-conventions-and-rules">Layer Conventions and Rules</a>
23945db71995Sopenharmony_ci        </small>
23955db71995Sopenharmony_ci    </td>
23965db71995Sopenharmony_ci  </tr>
23975db71995Sopenharmony_ci  <tr>
23985db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_16</b></small></td>
23995db71995Sopenharmony_ci    <td>A layer <b>must</b> enumerate only its own extension properties during a
24005db71995Sopenharmony_ci        call of <i>vkEnumerateDeviceExtensionProperties</i> when
24015db71995Sopenharmony_ci        <i>pLayerName</i> refers to itself.<br/>
24025db71995Sopenharmony_ci        Otherwise, it <b>must</b> ignore the call other than passing it down
24035db71995Sopenharmony_ci        the standard call chain.
24045db71995Sopenharmony_ci    </td>
24055db71995Sopenharmony_ci    <td>The loader could become confused on what support is present in a
24065db71995Sopenharmony_ci        specific layer which will result in undefined behavior possibly
24075db71995Sopenharmony_ci        including crashes or corruption.
24085db71995Sopenharmony_ci    </td>
24095db71995Sopenharmony_ci    <td>Yes</td>
24105db71995Sopenharmony_ci    <td>No</td>
24115db71995Sopenharmony_ci    <td><small>
24125db71995Sopenharmony_ci        <a href="#layer-conventions-and-rules">Layer Conventions and Rules</a>
24135db71995Sopenharmony_ci        </small>
24145db71995Sopenharmony_ci    </td>
24155db71995Sopenharmony_ci  </tr>
24165db71995Sopenharmony_ci  <tr>
24175db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_17</b></small></td>
24185db71995Sopenharmony_ci    <td>A layer's <i>vkCreateInstance</i> <b>must not</b> generate an error for
24195db71995Sopenharmony_ci        unrecognized extension names as the extension could be implemented by
24205db71995Sopenharmony_ci        a lower layer or driver.
24215db71995Sopenharmony_ci    </td>
24225db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
24235db71995Sopenharmony_ci    <td>Yes</td>
24245db71995Sopenharmony_ci    <td>Yes</td>
24255db71995Sopenharmony_ci    <td><small>
24265db71995Sopenharmony_ci        <a href="#layer-conventions-and-rules">Layer Conventions and Rules</a>
24275db71995Sopenharmony_ci        </small>
24285db71995Sopenharmony_ci    </td>
24295db71995Sopenharmony_ci  </tr>
24305db71995Sopenharmony_ci  <tr>
24315db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_18</b></small></td>
24325db71995Sopenharmony_ci    <td>A layer <b>must</b> return <b>NULL</b> from <i>vkGetInstanceProcAddr</i>
24335db71995Sopenharmony_ci        or <i>vkGetDeviceProcAddr</i> for entry-points that it does not support
24345db71995Sopenharmony_ci        or that have not been enabled properly (for example not enabling the
24355db71995Sopenharmony_ci        extension certain entry-points are associated with should result in
24365db71995Sopenharmony_ci        <i>vkGetInstanceProcAddr</i> returning <b>NULL</b> when requesting
24375db71995Sopenharmony_ci        them).
24385db71995Sopenharmony_ci    </td>
24395db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
24405db71995Sopenharmony_ci    <td>Yes</td>
24415db71995Sopenharmony_ci    <td>No<br/>
24425db71995Sopenharmony_ci        With the current loader/layer design, it is difficult for the loader
24435db71995Sopenharmony_ci        to determine this without adding additional overhead that could impact
24445db71995Sopenharmony_ci        performance.</td>
24455db71995Sopenharmony_ci    <td><small>
24465db71995Sopenharmony_ci        <a href="#layer-conventions-and-rules">Layer Conventions and Rules</a>
24475db71995Sopenharmony_ci        </small>
24485db71995Sopenharmony_ci    </td>
24495db71995Sopenharmony_ci  </tr>
24505db71995Sopenharmony_ci  <tr>
24515db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_19</b></small></td>
24525db71995Sopenharmony_ci    <td>If a layer creates dispatchable objects, either because it is
24535db71995Sopenharmony_ci        wrapping objects or implementing an extension not supported by
24545db71995Sopenharmony_ci        the loader or underlying drivers, it <b>must</b> create the dispatch
24555db71995Sopenharmony_ci        table appropriately for all created dispatchable objects.
24565db71995Sopenharmony_ci    </td>
24575db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
24585db71995Sopenharmony_ci    <td>Yes</td>
24595db71995Sopenharmony_ci    <td>No</td>
24605db71995Sopenharmony_ci    <td><small>
24615db71995Sopenharmony_ci        <a href="#creating-new-dispatchable-objects">
24625db71995Sopenharmony_ci          Creating New Dispatchable Objects</a>
24635db71995Sopenharmony_ci        </small>
24645db71995Sopenharmony_ci    </td>
24655db71995Sopenharmony_ci  </tr>
24665db71995Sopenharmony_ci  <tr>
24675db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_20</b></small></td>
24685db71995Sopenharmony_ci    <td>A layer <b>must</b> remove all manifest files and references
24695db71995Sopenharmony_ci        to those files (i.e. Registry entries on Windows) when uninstalling.
24705db71995Sopenharmony_ci        <br/>
24715db71995Sopenharmony_ci        Similarly, on updating the layer files, the old files <b>must</b> be all
24725db71995Sopenharmony_ci        updated or removed.
24735db71995Sopenharmony_ci    </td>
24745db71995Sopenharmony_ci    <td>The loader ignores duplicate attempts to load the same manifest file,
24755db71995Sopenharmony_ci        but if an old file is left pointing to an incorrect library, it will
24765db71995Sopenharmony_ci        result in undefined behavior which may include crashes or corruption.
24775db71995Sopenharmony_ci    </td>
24785db71995Sopenharmony_ci    <td>No</td>
24795db71995Sopenharmony_ci    <td>No<br/>
24805db71995Sopenharmony_ci        The loader has no idea what layer files are new, old, or incorrect.
24815db71995Sopenharmony_ci        Any type of layer file verification would quickly become very complex
24825db71995Sopenharmony_ci        since it would require the loader to maintain an internal database
24835db71995Sopenharmony_ci        tracking badly behaving layers based on the layer name, version,
24845db71995Sopenharmony_ci        targeted platform(s), and possibly other criteria.
24855db71995Sopenharmony_ci    <td><small>N/A</small></td>
24865db71995Sopenharmony_ci  </tr>
24875db71995Sopenharmony_ci  <tr>
24885db71995Sopenharmony_ci    <td><small><b>LLP_LAYER_21</b></small></td>
24895db71995Sopenharmony_ci    <td>During <i>vkCreateInstance</i>, a layer <b>must not</b> modify the
24905db71995Sopenharmony_ci        <i>pInstance</i> pointer during prior to calling down to the lower
24915db71995Sopenharmony_ci        layers.<br/>
24925db71995Sopenharmony_ci        This is because the loader passes information in this pointer that is
24935db71995Sopenharmony_ci        necessary for the initialization code in the loader's terminator
24945db71995Sopenharmony_ci        function.<br/>
24955db71995Sopenharmony_ci        Instead, if the layer is overriding the <i>pInstance</i> pointer, it
24965db71995Sopenharmony_ci        <b>must</b> do so only after the call to the lower layers returns.
24975db71995Sopenharmony_ci    </td>
24985db71995Sopenharmony_ci    <td>The loader will likely crash.</td>
24995db71995Sopenharmony_ci    <td>No</td>
25005db71995Sopenharmony_ci    <td>Yes</td>
25015db71995Sopenharmony_ci    <td><small>N/A</small></td>
25025db71995Sopenharmony_ci  </tr>
25035db71995Sopenharmony_ci  <tr>
25045db71995Sopenharmony_ci  <td><small><b>LLP_LAYER_22</b></small></td>
25055db71995Sopenharmony_ci    <td>During <i>vkCreateDevice</i>, a layer <b>must not</b> modify the
25065db71995Sopenharmony_ci        <i>pDevice</i> pointer during prior to calling down to the lower
25075db71995Sopenharmony_ci        layers.<br/>
25085db71995Sopenharmony_ci        This is because the loader passes information in this pointer that is
25095db71995Sopenharmony_ci        necessary for the initialization code in the loader's terminator
25105db71995Sopenharmony_ci        function.<br/>
25115db71995Sopenharmony_ci        Instead, if the layer is overriding the <i>pDevice</i> pointer, it
25125db71995Sopenharmony_ci        <b>must</b> do so only after the call to the lower layers returns.
25135db71995Sopenharmony_ci    </td>
25145db71995Sopenharmony_ci    <td>The loader will likely crash.</td>
25155db71995Sopenharmony_ci    <td>No</td>
25165db71995Sopenharmony_ci    <td>Yes</td>
25175db71995Sopenharmony_ci    <td><small>N/A</small></td>
25185db71995Sopenharmony_ci  </tr>
25195db71995Sopenharmony_ci</table>
25205db71995Sopenharmony_ci
25215db71995Sopenharmony_ci
25225db71995Sopenharmony_ci### Requirements of a Well-Behaved Loader
25235db71995Sopenharmony_ci
25245db71995Sopenharmony_ci<table style="width:100%">
25255db71995Sopenharmony_ci  <tr>
25265db71995Sopenharmony_ci    <th>Requirement Number</th>
25275db71995Sopenharmony_ci    <th>Requirement Description</th>
25285db71995Sopenharmony_ci    <th>Result of Non-Compliance</th>
25295db71995Sopenharmony_ci    <th>Applicable to Android?</th>
25305db71995Sopenharmony_ci    <th>Reference Section</th>
25315db71995Sopenharmony_ci  </tr>
25325db71995Sopenharmony_ci  <tr>
25335db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_1</b></small></td>
25345db71995Sopenharmony_ci    <td>A loader <b>must</b> support Vulkan layers.</td>
25355db71995Sopenharmony_ci    <td>Users will not have access to critical parts of the Vulkan ecosystem
25365db71995Sopenharmony_ci        such as Validation Layers, GfxReconstruct, or RenderDoc.</td>
25375db71995Sopenharmony_ci    <td>Yes</td>
25385db71995Sopenharmony_ci    <td><small>N/A</small></td>
25395db71995Sopenharmony_ci  </tr>
25405db71995Sopenharmony_ci  <tr>
25415db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_2</b></small></td>
25425db71995Sopenharmony_ci    <td>A loader <b>must</b> support a mechanism to load layers in one or
25435db71995Sopenharmony_ci        more non-standard locations.<br/>
25445db71995Sopenharmony_ci        This is to allow application/engine-specific layers as well as
25455db71995Sopenharmony_ci        evaluating in-development layers without global installation.
25465db71995Sopenharmony_ci    </td>
25475db71995Sopenharmony_ci    <td>It will be more difficult to use a Vulkan loader by certain
25485db71995Sopenharmony_ci        tools and driver developers.</td>
25495db71995Sopenharmony_ci    <td>No</td>
25505db71995Sopenharmony_ci    <td><small><a href="#layer-discovery">Layer Discovery</a></small></td>
25515db71995Sopenharmony_ci  </tr>
25525db71995Sopenharmony_ci  <tr>
25535db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_3</b></small></td>
25545db71995Sopenharmony_ci    <td>A loader <b>must</b> filter out duplicate layer names in the various
25555db71995Sopenharmony_ci        enable lists, keeping only the first occurrence.
25565db71995Sopenharmony_ci    </td>
25575db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
25585db71995Sopenharmony_ci    <td>Yes</td>
25595db71995Sopenharmony_ci    <td><small><a href="#layer-discovery">Layer Discovery</a></small></td>
25605db71995Sopenharmony_ci  </tr>
25615db71995Sopenharmony_ci  <tr>
25625db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_4</b></small></td>
25635db71995Sopenharmony_ci    <td>A loader <b>must not</b> load a Vulkan layer which defines an
25645db71995Sopenharmony_ci        API version that is incompatible with itself.
25655db71995Sopenharmony_ci    </td>
25665db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
25675db71995Sopenharmony_ci    <td>Yes</td>
25685db71995Sopenharmony_ci    <td><small><a href="#layer-discovery">Layer Discovery</a></small></td>
25695db71995Sopenharmony_ci  </tr>
25705db71995Sopenharmony_ci  <tr>
25715db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_5</b></small></td>
25725db71995Sopenharmony_ci    <td>A loader <b>must</b> ignore any layer for which a compatible interface
25735db71995Sopenharmony_ci        version can not be negotiated.
25745db71995Sopenharmony_ci    </td>
25755db71995Sopenharmony_ci    <td>The loader would load a layer improperly resulting in undefined behavior
25765db71995Sopenharmony_ci        which may include crashes or corruption.</td>
25775db71995Sopenharmony_ci    <td>No</td>
25785db71995Sopenharmony_ci    <td><small>
25795db71995Sopenharmony_ci        <a href="#loader-and-layer-interface-negotiation">
25805db71995Sopenharmony_ci        Interface Negotiation</a></small>
25815db71995Sopenharmony_ci    </td>
25825db71995Sopenharmony_ci  </tr>
25835db71995Sopenharmony_ci  <tr>
25845db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_6</b></small></td>
25855db71995Sopenharmony_ci    <td>If a layer is implicit, and it has an enable environment variable,
25865db71995Sopenharmony_ci        then a loader <b>must not</b> consider the layer enabled unless that
25875db71995Sopenharmony_ci        enable environment variable is defined.<br/>
25885db71995Sopenharmony_ci        If an implicit layer does not have an enable environment variable,
25895db71995Sopenharmony_ci        it will be considered enabled by default.
25905db71995Sopenharmony_ci    </td>
25915db71995Sopenharmony_ci    <td>Some layers may be used when not intended.</td>
25925db71995Sopenharmony_ci    <td>No</td>
25935db71995Sopenharmony_ci    <td><small>
25945db71995Sopenharmony_ci        <a href="#layer-manifest-file-format">Manifest File Format</a>, see
25955db71995Sopenharmony_ci        "enable_environment" variable</small>
25965db71995Sopenharmony_ci    </td>
25975db71995Sopenharmony_ci  </tr>
25985db71995Sopenharmony_ci  <tr>
25995db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_7</b></small></td>
26005db71995Sopenharmony_ci    <td>If an implicit layer is enabled, but has been disabled by some other
26015db71995Sopenharmony_ci        mechanism (such as the defining of the layer's disable environment
26025db71995Sopenharmony_ci        variable or through the blacklisting mechanism of the Override Layer),
26035db71995Sopenharmony_ci        then a loader <b>must not</b> load that layer.
26045db71995Sopenharmony_ci    </td>
26055db71995Sopenharmony_ci    <td>Some layers may be used when not intended.</td>
26065db71995Sopenharmony_ci    <td>No</td>
26075db71995Sopenharmony_ci    <td><small>
26085db71995Sopenharmony_ci        <a href="#layer-manifest-file-format">Manifest File Format</a>, see
26095db71995Sopenharmony_ci        "disable_environment" variable</small>
26105db71995Sopenharmony_ci    </td>
26115db71995Sopenharmony_ci  </tr>
26125db71995Sopenharmony_ci  <tr>
26135db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_8</b></small></td>
26145db71995Sopenharmony_ci    <td>A loader <b>must</b> pass a linked list of initialization structures
26155db71995Sopenharmony_ci        to each layer via the <i>VkLayerInstanceCreateInfo</i> structure in the
26165db71995Sopenharmony_ci        <i>pNext</i> field of the <i>VkInstanceCreateInfo</i> structure.
26175db71995Sopenharmony_ci        This contains necessary information for setting up the instance call
26185db71995Sopenharmony_ci        chain including providing a function pointer to the next links
26195db71995Sopenharmony_ci        <i>vkGetInstanceProcAddr</i>.
26205db71995Sopenharmony_ci    </td>
26215db71995Sopenharmony_ci    <td>Layers will crash as they attempt to load invalid data.</td>
26225db71995Sopenharmony_ci    <td>Yes</td>
26235db71995Sopenharmony_ci    <td><small>
26245db71995Sopenharmony_ci        <a href="#layer-dispatch-initialization">
26255db71995Sopenharmony_ci           Layer Dispatch Initialization</a>
26265db71995Sopenharmony_ci        </small>
26275db71995Sopenharmony_ci    </td>
26285db71995Sopenharmony_ci  </tr>
26295db71995Sopenharmony_ci  <tr>
26305db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_9</b></small></td>
26315db71995Sopenharmony_ci    <td>A loader <b>must</b> pass a linked list of initialization structures
26325db71995Sopenharmony_ci        to each layer via the <i>VkLayerDeviceCreateInfo</i> structure in the
26335db71995Sopenharmony_ci        <i>pNext</i> field of the <i>VkDeviceCreateInfo</i> structure.
26345db71995Sopenharmony_ci        This contains necessary information for setting up the device call chain
26355db71995Sopenharmony_ci        including providing a function pointer to the next links
26365db71995Sopenharmony_ci        <i>vkGetDeviceProcAddr</i>.
26375db71995Sopenharmony_ci    <td>Layers will crash as they attempt to load invalid data.</td>
26385db71995Sopenharmony_ci    <td>Yes</td>
26395db71995Sopenharmony_ci    <td><small>
26405db71995Sopenharmony_ci        <a href="#layer-dispatch-initialization">
26415db71995Sopenharmony_ci           Layer Dispatch Initialization</a>
26425db71995Sopenharmony_ci        </small>
26435db71995Sopenharmony_ci    </td>
26445db71995Sopenharmony_ci  </tr>
26455db71995Sopenharmony_ci  <tr>
26465db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_10</b></small></td>
26475db71995Sopenharmony_ci    <td>A loader <b>must</b> verify that all meta-layers contain valid
26485db71995Sopenharmony_ci        component layers that the loader can find on the system and that also
26495db71995Sopenharmony_ci        report the same Vulkan API version as the meta-layer itself before it
26505db71995Sopenharmony_ci        loads the meta-layer.
26515db71995Sopenharmony_ci    </td>
26525db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
26535db71995Sopenharmony_ci    <td>No</td>
26545db71995Sopenharmony_ci    <td><small>
26555db71995Sopenharmony_ci        <a href="#meta-layers">Meta-Layers</a></small>
26565db71995Sopenharmony_ci    </td>
26575db71995Sopenharmony_ci  </tr>
26585db71995Sopenharmony_ci  <tr>
26595db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_11</b></small></td>
26605db71995Sopenharmony_ci    <td>If the override meta-layer is present, a loader <b>must</b> load it
26615db71995Sopenharmony_ci        and corresponding component layers after all other implicit layers have
26625db71995Sopenharmony_ci        been added to the call chain.
26635db71995Sopenharmony_ci    </td>
26645db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
26655db71995Sopenharmony_ci    <td>No</td>
26665db71995Sopenharmony_ci    <td><small>
26675db71995Sopenharmony_ci        <a href="#override-meta-layer">Override Meta-Layer</a></small>
26685db71995Sopenharmony_ci    </td>
26695db71995Sopenharmony_ci  </tr>
26705db71995Sopenharmony_ci  <tr>
26715db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_12</b></small></td>
26725db71995Sopenharmony_ci    <td>If the override meta-layer is present and has a blacklist of layers to
26735db71995Sopenharmony_ci        remove, a loader <b>must</b> disable all layers listed in the blacklist.
26745db71995Sopenharmony_ci    </td>
26755db71995Sopenharmony_ci    <td>The behavior is undefined and may result in crashes or corruption.</td>
26765db71995Sopenharmony_ci    <td>No</td>
26775db71995Sopenharmony_ci    <td><small>
26785db71995Sopenharmony_ci        <a href="#override-meta-layer">Override Meta-Layer</a></small>
26795db71995Sopenharmony_ci    </td>
26805db71995Sopenharmony_ci  </tr>
26815db71995Sopenharmony_ci  <tr>
26825db71995Sopenharmony_ci    <td><small><b>LLP_LOADER_13</b></small></td>
26835db71995Sopenharmony_ci    <td>A loader <b>must</b> not load from user-defined paths (including the
26845db71995Sopenharmony_ci        use of either <i>VK_LAYER_PATH</i> or <i>VK_ADD_LAYER_PATH</i>
26855db71995Sopenharmony_ci        environment variables) when running elevated (Administrator/Super-user)
26865db71995Sopenharmony_ci        applications.<br/>
26875db71995Sopenharmony_ci        <b>This is for security reasons.</b>
26885db71995Sopenharmony_ci    </td>
26895db71995Sopenharmony_ci    <td>The behavior is undefined and may result in computer security lapses,
26905db71995Sopenharmony_ci        crashes or corruption.
26915db71995Sopenharmony_ci    </td>
26925db71995Sopenharmony_ci    <td>No</td>
26935db71995Sopenharmony_ci    <td><small><a href="#layer-discovery">Layer Discovery</a></small></td>
26945db71995Sopenharmony_ci  </tr>
26955db71995Sopenharmony_ci</table>
26965db71995Sopenharmony_ci
26975db71995Sopenharmony_ci<br/>
26985db71995Sopenharmony_ci
26995db71995Sopenharmony_ci[Return to the top-level LoaderInterfaceArchitecture.md file.](LoaderInterfaceArchitecture.md)
2700