blob: b1eaf7c87bcaa903ae0ca260bee7636c5f694584 [file] [log] [blame] [view]
Jon Ashburnc2972682016-02-08 15:42:01 -07001# Vulkan Loader Specification and Architecture Overview
2
3
4Goals of this document
5----------------------
6
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07007Specify necessary functions and expected behavior of interface between the
8loader library and ICDs and layers for Windows, Linux and Android based
9systems. Also describe the application visible behaviors of the loader.
Jon Ashburnc2972682016-02-08 15:42:01 -070010
11Audience
12--------
13
14Application, Vulkan driver and Vulkan layer developers.
15
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070016Any developers interested in understanding more about loader and layer behavior
17and architecture.
Jon Ashburnc2972682016-02-08 15:42:01 -070018
19
20Loader goals
21------------
22
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070023- Support multiple ICDs (Installable Client Drivers) to co-exist on a system
24without interfering with each other.
Jon Ashburnc2972682016-02-08 15:42:01 -070025
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070026- Support optional modules (layers) that can be enabled by an application,
27developer or the system and have no impact when not enabled.
Jon Ashburnc2972682016-02-08 15:42:01 -070028
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070029- Negligible performance cost for an application calling through the loader
30to an ICD entry point.
Jon Ashburnc2972682016-02-08 15:42:01 -070031
32Architectural overview of layers and loader
33-------------------------------------------
34
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -070035Vulkan is a layered architecture. Layers can hook (intercept) Vulkan commands to
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070036achieve various functionality that a Vulkan driver (aka ICD) or loader doesn’t
37support. Functionality such as Vulkan API tracing and debugging, API usage
38validation, and other tools such as framebuffer overlays are all natural
39candidates for Vulkan layers. Layers are implemented as libraries that are
40inserted between the application and the driver.
Jon Ashburnc2972682016-02-08 15:42:01 -070041
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070042Not only is Vulkan a layered architecture but it also supports multiple GPUs
43and their drivers. Vulkan commands called by an application may wind up calling
44into a diverse set of modules: loader, layers, and ICDs. The loader is critical
45to managing the proper dispatching of Vulkan commands to the appropriate set of
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -070046layers and ICDs. The Vulkan object model allows the loader to insert layers
47into a call chain so the layers can process Vulkan commands prior to the
48ICD being called.
Jon Ashburnc2972682016-02-08 15:42:01 -070049
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070050Vulkan uses an object model to control the scope of a particular action /
51operation. The object to be acted on is always the first parameter of a Vulkan
52call and is a dispatchable object (see Vulkan specification section 2.2 Object
53Model). Under the covers, the dispatchable object handle is a pointer to a
54structure that contains a pointer to a dispatch table maintained by the loader.
55This dispatch table contains pointers to the Vulkan functions appropriate to
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -070056that object. There are two types of dispatch tables the loader maintains,
57Instance and Device. I.e. a VkInstance object’s dispatch table will point to Vulkan
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070058functions such as vkEnumeratePhysicalDevices, vkDestroyInstance,
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -070059vkCreateInstance, etc. Instance functions take a VkInstance or VkPhysicalDevice as
60their first argument.
Jon Ashburnc2972682016-02-08 15:42:01 -070061
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070062Device objects have a separate dispatch table containing the appropriate
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -070063function pointers. The device dispatch table is used for all functions that
64take a VkDevice, VkQueue or VkCommandBuffer as their first argument.
Jon Ashburnc2972682016-02-08 15:42:01 -070065
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070066These instance and device dispatch tables are constructed when the application
67calls vkCreateInstance and vkCreateDevice. At that time the application and/or
68system can specify optional layers to be included. The loader will initialize
69the specified layers to create a call chain for each Vulkan function and each
70entry of the dispatch table will point to the first element of that chain.
71Thus, the loader builds an instance call chain for each VkInstance that is
72created and a device call chain for each VkDevice that is created.
Jon Ashburnc2972682016-02-08 15:42:01 -070073
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070074For example, the diagram below represents what happens in the call chain for
75vkCreateInstance. After initializing the chain, the loader will call into the
76first layer’s vkCreateInstance which will call the next finally terminating in
77the loader again where this function calls every ICD’s vkCreateInstance and
78saves the results. This allows every enabled layer for this chain to set up
79what it needs based on the VkInstanceCreateInfo structure from the application.
Jon Ashburnc2505562016-02-15 10:19:26 -070080![Instance call chain](instance_call_chain.png)
Jon Ashburnc2972682016-02-08 15:42:01 -070081
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070082This also highlights some of the complexity the loader must manage when using
83instance chains. As shown here, the loader must aggregate information from
84multiple devices when they are present. This means that the loader has to know
85about instance level extensions to aggregate them correctly.
Jon Ashburnc2972682016-02-08 15:42:01 -070086
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -070087Device chains are created at vkCreateDevice and are generally simpler because
88they deal with only a single device and the ICD can always be the terminator of
89the chain. The below diagram also illustrates how layers (either device or
90instance) can skip intercepting any given Vulkan entry point.
Jon Ashburnc2505562016-02-15 10:19:26 -070091![Chain skipping layers](chain_skipping_layers.png)
Jon Ashburnc2972682016-02-08 15:42:01 -070092
93Application interface to loader
94-------------------------------
95
96In this section we’ll discuss how an application interacts with the loader.
97
98- Linking to loader library for core and WSI extension symbols.
99
100- Dynamic Vulkan command lookup & application dispatch table.
101
102- Loader library filenames for linking to different Vulkan ABI versions.
103
104- Layers
105
106- Extensions
107
108- vkGetInstanceProcAddr, vkGetDeviceProcAddr
109
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700110The loader library on Windows, Linux and Android will export all core Vulkan
111and all appropriate Window System Interface (WSI) extensions. This is done to
112make it simpler to get started with Vulkan development. When an application
113links directly to the loader library in this way, the Vulkan calls are simple
114trampoline functions that jump to the appropriate dispatch table entry for the
115object they are given.
Jon Ashburnc2972682016-02-08 15:42:01 -0700116
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700117Applications are not required to link directly to the loader library, instead
118they can use the appropriate platform specific dynamic symbol lookup on the
119loader library to initialize the application’s own dispatch table. This allows
Jeff Julianof1619872016-02-17 17:25:42 -0500120an application to fail gracefully if the loader cannot be found, and it
121provides the fastest mechanism for the application to call Vulkan functions. An
122application will only need to query (via system calls such as dlsym()) the
123address of vkGetInstanceProcAddr from the loader library. Using
124vkGetInstanceProcAddr the application can then discover the address of all
125instance and global functions and extensions, such as vkCreateInstance,
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700126vkEnumerateInstanceExtensionProperties and vkEnumerateInstanceLayerProperties
127in a platform independent way.
Jon Ashburnc2972682016-02-08 15:42:01 -0700128
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700129The Vulkan loader library will be distributed in various ways including Vulkan
130SDKs, OS package distributions and IHV driver packages. These details are
131beyond the scope of this document. However, the name and versioning of the
132Vulkan loader library is specified so an app can link to the correct Vulkan ABI
133library version. Vulkan versioning is such that ABI backwards compatibility is
Jeff Julianof1619872016-02-17 17:25:42 -0500134guaranteed for all versions with the same major number (e.g. 1.0 and 1.1). On
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700135Windows, the loader library encodes the ABI version in its name such that
136multiple ABI incompatible versions of the loader can peacefully coexist on a
Jeff Julianof1619872016-02-17 17:25:42 -0500137given system. The Vulkan loader library file name is “vulkan-<ABI
138version>.dll”. For example, for Vulkan version 1.X on Windows the library
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700139filename is vulkan-1.dll. And this library file can typically be found in the
140windows/system32 directory.
Jon Ashburnc2972682016-02-08 15:42:01 -0700141
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700142For Linux, shared libraries are versioned based on a suffix. Thus, the ABI
143number is not encoded in the base of the library filename as on Windows. On
144Linux an application wanting to link to the latest Vulkan ABI version would
145just link to the name vulkan (libvulkan.so). A specific Vulkan ABI version can
Jeff Julianof1619872016-02-17 17:25:42 -0500146also be linked to by applications (e.g. libvulkan.so.1).
Jon Ashburnc2972682016-02-08 15:42:01 -0700147
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700148Applications desiring Vulkan functionality beyond what the core API offers may
149use various layers or extensions. A layer cannot add new or modify existing
150Vulkan commands, but may offer extensions that do. A common use of layers is
151for API validation. A developer can use validation layers during application
152development, but during production the layers can be disabled by the
Jeff Julianof1619872016-02-17 17:25:42 -0500153application. Thus, eliminating the overhead of validating the application's
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700154usage of the API. Layers discovered by the loader can be reported to the
155application via vkEnumerateInstanceLayerProperties and
156vkEnumerateDeviceLayerProperties, for instance and device layers respectively.
157Instance layers are enabled at vkCreateInstance; device layers are enabled at
158vkCreateDevice. For example, the ppEnabledLayerNames array in the
159VkDeviceCreateInfo structure is used by the application to list the device
160layer names to be enabled at vkCreateDevice. At vkCreateInstance and
161vkCreateDevice, the loader will construct call chains that include the
162application specified (enabled) layers. Order is important in the
163ppEnabledLayerNames array; array element 0 is the topmost (closest to the
164application) layer inserted in the chain and the last array element is closest
165to the driver.
Jon Ashburnc2972682016-02-08 15:42:01 -0700166
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700167Developers may want to enable layers that are not enabled by the given
168application they are using. On Linux and Windows, the environment variables
169“VK\_INSTANCE\_LAYERS” and “VK\_DEVICE\_LAYERS” can be used to enable
170additional layers which are not specified (enabled) by the application at
171vkCreateInstance/vkCreateDevice. VK\_INSTANCE\_LAYERS is a colon
172(Linux)/semi-colon (Windows) separated list of layer names to enable. Order is
173relevant with the first layer in the list being the topmost layer (closest to
174the application) and the last layer in the list being the bottommost layer
175(closest to the driver).
Jon Ashburnc2972682016-02-08 15:42:01 -0700176
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700177Application specified layers and user specified layers (via environment
178variables) are aggregated and duplicates removed by the loader when enabling
179layers. Layers specified via environment variable are topmost (closest to the
180application) while layers specified by the application are bottommost.
Jon Ashburnc2972682016-02-08 15:42:01 -0700181
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700182An example of using these environment variables to activate the validation
183layer VK\_LAYER\_LUNARG\_param\_checker on Windows or Linux is as follows:
Jon Ashburnc2972682016-02-08 15:42:01 -0700184
185```
Mark Lobodzinski739391a2016-03-17 15:08:18 -0600186> $ export VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_parameter_validation
Jon Ashburnc2972682016-02-08 15:42:01 -0700187
Mark Lobodzinski739391a2016-03-17 15:08:18 -0600188> $ export VK_DEVICE_LAYERS=VK_LAYER_LUNARG_parameter_validation
Jon Ashburnc2972682016-02-08 15:42:01 -0700189```
190
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700191**Note**: Many layers, including all LunarG validation layers are “global”
192(i.e. both instance and device) layers and *must* be enabled on both the
193instance and device chains to function properly. This is required for “global”
194layers regardless of which method is used to enable the layer (application or
195environment variable).
Jon Ashburnc2972682016-02-08 15:42:01 -0700196
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700197Some platforms, including Linux and Windows, support layers which are enabled
198automatically by the loader rather than explicitly by the application (or via
199environment variable). Explicit layers are those layers enabled by the
200application (or environment variable) by providing the layer name. Implicit
201layers are those layers enabled by the loader automatically. Any implicit
202layers the loader discovers on the system in the appropriate location will be
203enabled (subject to environment variable overrides described later). Discovery
204of properly installed implicit and explicit layers is described later.
205Explicitly enabling a layer that is implicitly enabled has no additional
206effect: the layer will still be enabled implicitly by the loader.
Jon Ashburnc2972682016-02-08 15:42:01 -0700207
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700208Extensions are optional functionality provided by a layer, the loader or an
209ICD. Extensions can modify the behavior of the Vulkan API and need to be
210specified and registered with Khronos.
Jon Ashburnc2972682016-02-08 15:42:01 -0700211
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700212Instance extensions can be discovered via
213vkEnumerateInstanceExtensionProperties. Device extensions can be discovered via
214vkEnumerateDeviceExtensionProperties. The loader discovers and aggregates all
215extensions from layers (both explicit and implicit), ICDs and the loader before
216reporting them to the application in vkEnumerate\*ExtensionProperties. The
Jeff Julianof1619872016-02-17 17:25:42 -0500217pLayerName parameter in these functions is used to select either a single layer
218or the Vulkan platform implementation. If pLayerName is NULL, extensions from
219Vulkan implementation components (including loader, implicit layers, and ICDs)
220are enumerated. If pLayerName is equal to a discovered layer module name then
221any extensions from that layer (which may be implicit or explicit) are
222enumerated. Duplicate extensions (e.g. an implicit layer and ICD might report
Jon Ashburn859c7fb2016-03-02 17:26:31 -0700223support for the same extension) are eliminated by the loader. For duplicates, the
224ICD version is reported and the layer version is culled. Extensions must
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700225be enabled (in vkCreateInstance or vkCreateDevice) before they can be used.
Jon Ashburnc2972682016-02-08 15:42:01 -0700226
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700227Extension command entry points should be queried via vkGetInstanceProcAddr or
228vkGetDeviceProcAddr. vkGetDeviceProcAddr can only be used to query for device
229extension or core device entry points. Device entry points include any command
230that uses a VkDevice as the first parameter or a dispatchable object that is a
231child of a VkDevice (currently this includes VkQueue and VkCommandBuffer).
232vkGetInstanceProcAddr can be used to query either device or instance extension
233entry points in addition to all core entry points.
Jon Ashburnc2972682016-02-08 15:42:01 -0700234
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700235VkGetDeviceProcAddr is particularly interesting because it will provide the
236most efficient way to call into the ICD. For example, the diagram below shows
237what could happen if the application were to use vkGetDeviceProcAddr for the
238function “vkGetDeviceQueue” and “vkDestroyDevice” but not “vkAllocateMemory”.
239The resulting function pointer (fpGetDeviceQueue) would be the ICD’s entry
240point if the loader and any enabled layers do not need to see that call. Even
Jeff Julianof1619872016-02-17 17:25:42 -0500241if an enabled layer intercepts the call (e.g. vkDestroyDevice) the loader
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700242trampoline code is skipped for function pointers obtained via
243vkGetDeviceProcAddr. This also means that function pointers obtained via
244vkGetDeviceProcAddr will only work with the specific VkDevice it was created
245for, using it with another device has undefined results. For extensions,
246Get\*ProcAddr will often be the only way to access extension API features.
Jon Ashburnc2972682016-02-08 15:42:01 -0700247
Jon Ashburnc2505562016-02-15 10:19:26 -0700248![Get*ProcAddr efficiency](get_proc_addr.png)
Courtney Goeltzenleuchterab3a4662016-02-14 10:48:22 -0700249
Jon Ashburnc2972682016-02-08 15:42:01 -0700250
251Vulkan Installable Client Driver interface with the loader
252----------------------------------------------------------
253
254### ICD discovery
255
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700256Vulkan allows multiple drivers each with one or more devices (represented by a
257Vulkan VkPhysicalDevice object) to be used collectively. The loader is
258responsible for discovering available Vulkan ICDs on the system. Given a list
259of available ICDs, the loader can enumerate all the physical devices available
260for an application and return this information to the application. The process
261in which the loader discovers the available Installable Client Drivers (ICDs)
262on a system is platform dependent. Windows, Linux and Android ICD discovery
263details are listed below.
Jon Ashburnc2972682016-02-08 15:42:01 -0700264
265#### Windows
266
267##### Properly-Installed ICDs
268
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700269In order to find properly-installed ICDs, the Vulkan loader will scan the
270values in the following Windows registry key:
Jon Ashburnc2972682016-02-08 15:42:01 -0700271
272HKEY\_LOCAL\_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\Drivers
273
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700274For each value in this key which has DWORD data set to 0, the loader opens the
275JSON format text information file (a.k.a. "manifest file") specified by the
276name of the value. Each name must be a full pathname to the text manifest file.
277The Vulkan loader will open each manifest file to obtain the name or pathname
278of an ICD shared library (".dll") file. For example:
Jon Ashburnc2972682016-02-08 15:42:01 -0700279
Jon Ashburncc300a22016-02-11 14:57:30 -0700280 ```
281 {
Jon Ashburnc2972682016-02-08 15:42:01 -0700282 "file_format_version": "1.0.0",
283 "ICD": {
284 "library_path": "path to ICD library",
Tony Barbourd83f06c2016-03-08 14:50:03 -0700285 "api_version": "1.0.5"
Jon Ashburnc2972682016-02-08 15:42:01 -0700286 }
287 }
Jon Ashburncc300a22016-02-11 14:57:30 -0700288 ```
Jon Ashburnc2972682016-02-08 15:42:01 -0700289
290
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700291The "library\_path" specifies either a filename, a relative pathname, or a full
292pathname to an ICD shared library file, which the loader will attempt to load
293using LoadLibrary(). If the ICD is specified via a filename, the shared library
David Pinedo3e163ee2016-04-18 16:59:59 -0600294lives in the system's DLL search path (e.g. in the "C:\Windows\System32"
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700295folder). If the ICD is specified via a relative pathname, it is relative to the
296path of the manifest file. Relative pathnames are those that do not start with
297a drive specifier (e.g. "C:"), nor with a directory separator (i.e. the '\\'
298character), but do contain at least one directory separator.
Jon Ashburnc2972682016-02-08 15:42:01 -0700299
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700300The "file\_format\_version" specifies a major.minor.patch version number in
301case the format of the text information file changes in the future. If the same
302ICD shared library supports multiple, incompatible versions of text manifest
303file format versions, it must have multiple text info files (all of which may
304point to the same shared library).
Jon Ashburnc2972682016-02-08 15:42:01 -0700305
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700306The “api\_version” specifies the major.minor.patch version number of the Vulkan
307API that the shared library (referenced by "library\_path") was built with.
Jon Ashburnc2972682016-02-08 15:42:01 -0700308
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700309There are no rules about the name of the text information files (except the
310.json suffix).
Jon Ashburnc2972682016-02-08 15:42:01 -0700311
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700312There are no rules about the name of the ICD shared library files. For example,
313if the registry contains the following values,
Jon Ashburnc2972682016-02-08 15:42:01 -0700314
Jon Ashburncc300a22016-02-11 14:57:30 -0700315```
316[HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers\]
Jon Ashburnc2972682016-02-08 15:42:01 -0700317
David Pinedo3e163ee2016-04-18 16:59:59 -0600318"C:\vendor a\vk_vendora.json"=dword:00000000
Jon Ashburnc2972682016-02-08 15:42:01 -0700319
David Pinedo3e163ee2016-04-18 16:59:59 -0600320"C:\windows\system32\vendorb_vk.json"=dword:00000000
Jon Ashburnc2972682016-02-08 15:42:01 -0700321
David Pinedo3e163ee2016-04-18 16:59:59 -0600322"C:\windows\system32\vendorc_icd.json"=dword:00000000
Jon Ashburncc300a22016-02-11 14:57:30 -0700323```
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700324then the loader will open the following text information files, with the
325specified contents:
Jon Ashburnc2972682016-02-08 15:42:01 -0700326
Jon Ashburncc300a22016-02-11 14:57:30 -0700327| Text File Name | Text File Contents |
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -0700328|----------------|--------------------|
David Pinedo3e163ee2016-04-18 16:59:59 -0600329|vk\_vendora.json | "ICD": { "library\_path": "C:\VENDOR A\vk_vendora.dll", "api_version": "1.0.5" } |
Tony Barbourd83f06c2016-03-08 14:50:03 -0700330| vendorb\_vk.json | "ICD": { "library\_path": "vendorb\_vk.dll", "api_version": "1.0.5" } |
331|vendorc\_icd.json | "ICD": { "library\_path": "vedorc\_icd.dll", "api_version": "1.0.5" }|
Jon Ashburnc2972682016-02-08 15:42:01 -0700332
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700333Then the loader will open the three files mentioned in the "Text File Contents"
334column, and then try to load and use the three shared libraries indicated by
335the ICD.library\_path value.
Jon Ashburnc2972682016-02-08 15:42:01 -0700336
337##### Using Pre-Production ICDs
338
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700339IHV developers (and sometimes other developers) need to use special,
340pre-production ICDs. In some cases, a pre-production ICD may be in an
341installable package. In other cases, a pre-production ICD may simply be a
342shared library in the developer's build tree. In this latter case, we want to
343allow developers to point to such an ICD without modifying the
344properly-installed ICD(s) on their system.
Jon Ashburnc2972682016-02-08 15:42:01 -0700345
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700346This need is met with the use of the "VK\_ICD\_FILENAMES" environment variable,
347which will override the mechanism used for finding properly-installed ICDs. In
348other words, only the ICDs listed in "VK\_ICD\_FILENAMES" will be used. The
349"VK\_ICD\_FILENAMES" environment variable is a semi-colon-separated list of ICD
350text information files (aka manifest files), containing the following:
Jon Ashburnc2972682016-02-08 15:42:01 -0700351
Jon Ashburncc300a22016-02-11 14:57:30 -0700352- A full pathname (e.g. "C:\\my\_build\\my\_icd.json")
Jon Ashburnc2972682016-02-08 15:42:01 -0700353
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700354Typically, "VK\_ICD\_FILENAMES" will only contain a full pathname to one info
355file for a developer-built ICD. A semi-colon is only used if more than one ICD
356is listed.
Jon Ashburnc2972682016-02-08 15:42:01 -0700357
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700358For example, if a developer wants to refer to one ICD that they built, they
359could set the "VK\_ICD\_FILENAMES" environment variable to:
Jon Ashburnc2972682016-02-08 15:42:01 -0700360
Jon Ashburncc300a22016-02-11 14:57:30 -0700361C:\\my\_build\\my\_icd.json
Jon Ashburnc2972682016-02-08 15:42:01 -0700362
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700363If a developer wants to refer to two ICDs, one of which is a properly-installed
364ICD, they can use the full pathname of the text file:
Jon Ashburnc2972682016-02-08 15:42:01 -0700365
Jon Ashburncc300a22016-02-11 14:57:30 -0700366C:\\Windows\\System32\\vendorc\_icd.json;C:\\my\_build\\my\_icd.json
Jon Ashburnc2972682016-02-08 15:42:01 -0700367
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700368Notice the semi-colon between "C:\\Windows\\System32\\vendorc\_icd.json" and
369"C:\\my\_build\\my\_icd.json".
Jon Ashburnc2972682016-02-08 15:42:01 -0700370
371#### Linux
372
373##### Properly-Installed ICDs
374
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700375In order to find properly-installed ICDs, the Vulkan loader will scan the files
376in the following Linux directories:
Jon Ashburnc2972682016-02-08 15:42:01 -0700377
378/usr/share/vulkan/icd.d
Jon Ashburnc2972682016-02-08 15:42:01 -0700379/etc/vulkan/icd.d
Jon Ashburn7f00ca82016-02-24 12:00:55 -0700380$HOME/.local/share/vulkan/icd.d
381
382Where $HOME is the current home directory of the application's user id; this
383path will be ignored for suid programs.
Jon Ashburnc2972682016-02-08 15:42:01 -0700384
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700385These directories will contain text information files (a.k.a. "manifest
386files"), that use a JSON format.
Jon Ashburnc2972682016-02-08 15:42:01 -0700387
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700388The Vulkan loader will open each manifest file found to obtain the name or
389pathname of an ICD shared library (".so") file. For example:
Jon Ashburnc2972682016-02-08 15:42:01 -0700390
Jon Ashburncc300a22016-02-11 14:57:30 -0700391```
392{
Jon Ashburnc2972682016-02-08 15:42:01 -0700393 "file_format_version": "1.0.0",
394 "ICD": {
395 "library_path": "path to ICD library",
Tony Barbourd83f06c2016-03-08 14:50:03 -0700396 "api_version": "1.0.5"
Jon Ashburnc2972682016-02-08 15:42:01 -0700397 }
398}
Jon Ashburncc300a22016-02-11 14:57:30 -0700399```
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700400The "library\_path" specifies either a filename, a relative pathname, or a full
401pathname to an ICD shared library file. If the ICD is specified via a filename,
402the loader will attempt to open that file as a shared object using dlopen(),
403and the file must be in a directory that dlopen is configured to look in (Note:
404various distributions are configured differently). A distribution is free to
405create Vulkan-specific system directories (e.g. ".../vulkan/icd"), but is not
406required to do so. If the ICD is specified via a relative pathname, it is
407relative to the path of the info file. Relative pathnames are those that do not
408start with, but do contain at least one directory separator (i.e. the '/'
409character). For example, "lib/vendora.so" and "./vendora.so" are examples of
410relative pathnames.
Jon Ashburnc2972682016-02-08 15:42:01 -0700411
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700412The "file\_format\_version" provides a major.minor.patch version number in case
413the format of the manifest file changes in the future. If the same ICD shared
414library supports multiple, incompatible versions of manifest file format
415versions, it must have multiple manifest files (all of which may point to the
416same shared library).
Jon Ashburnc2972682016-02-08 15:42:01 -0700417
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700418The “api\_version” specifies the major.minor.patch version number of the Vulkan
419API that the shared library (referenced by "library\_path") was built with.
Jon Ashburnc2972682016-02-08 15:42:01 -0700420
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700421The "/usr/share/vulkan/icd.d" directory is for ICDs that are installed from
422Linux-distribution-provided packages. The "/etc/vulkan/icd.d" directory is for
423ICDs that are installed from non-Linux-distribution-provided packages.
Jon Ashburnc2972682016-02-08 15:42:01 -0700424
425There are no rules about the name of the text files (except the .json suffix).
426
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700427There are no rules about the name of the ICD shared library files. For example,
428if the "/usr/share/vulkan/icd.d" directory contain the following files, with
429the specified contents:
Jon Ashburnc2972682016-02-08 15:42:01 -0700430
Jon Ashburn26ed3f32016-02-14 21:54:52 -0700431| Text File Name | Text File Contents |
432|-------------------|------------------------|
Tony Barbourd83f06c2016-03-08 14:50:03 -0700433| vk\_vendora.json | "ICD": { "library\_path": "vendora.so", "api_version": "1.0.5" } |
434| vendorb\_vk.json | "ICD": { "library\_path": "vendorb\_vulkan\_icd.so", "api_version": "1.0.5" } |
435| vendorc\_icd.json | "ICD": { "library\_path": "/usr/lib/VENDORC/icd.so", "api_version": "1.0.5" } |
Jon Ashburnc2972682016-02-08 15:42:01 -0700436
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700437then the loader will open the three files mentioned in the "Text File Contents"
438column, and then try to load and use the three shared libraries indicated by
439the ICD.library\_path value.
Jon Ashburnc2972682016-02-08 15:42:01 -0700440
441##### Using Pre-Production ICDs
442
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700443IHV developers (and sometimes other developers) need to use special,
444pre-production ICDs. In some cases, a pre-production ICD may be in an
445installable package. In other cases, a pre-production ICD may simply be a
446shared library in the developer's build tree. In this latter case, we want to
447allow developers to point to such an ICD without modifying the
448properly-installed ICD(s) on their system.
Jon Ashburnc2972682016-02-08 15:42:01 -0700449
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700450This need is met with the use of the "VK\_ICD\_FILENAMES" environment variable,
451which will override the mechanism used for finding properly-installed ICDs. In
452other words, only the ICDs listed in "VK\_ICD\_FILENAMES" will be used.
Jon Ashburnc2972682016-02-08 15:42:01 -0700453
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700454The "VK\_ICD\_FILENAMES" environment variable is a colon-separated list of ICD
455manifest files, containing the following:
Jon Ashburnc2972682016-02-08 15:42:01 -0700456
Jon Ashburn7f00ca82016-02-24 12:00:55 -0700457- A filename (e.g. "libvkicd.json") in the "/usr/share/vulkan/icd.d", "/etc/vulkan/icd.d" "$HOME/.local/share/vulkan/icd.d" directories
Jon Ashburnc2972682016-02-08 15:42:01 -0700458
459- A full pathname (e.g. "/my\_build/my\_icd.json")
460
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700461Typically, "VK\_ICD\_FILENAMES" will only contain a full pathname to one info
462file for a developer-built ICD. A colon is only used if more than one ICD is
463listed.
Jon Ashburnc2972682016-02-08 15:42:01 -0700464
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700465For example, if a developer wants to refer to one ICD that they built, they
466could set the "VK\_ICD\_FILENAMES" environment variable to:
Jon Ashburnc2972682016-02-08 15:42:01 -0700467
468/my\_build/my\_icd.json
469
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700470If a developer wants to refer to two ICDs, one of which is a properly-installed
471ICD, they can use the name of the text file in the system directory:
Jon Ashburnc2972682016-02-08 15:42:01 -0700472
473vendorc\_vulkan.json:/my\_build/my\_icd.json
474
475Notice the colon between "vendorc\_vulkan.json" and "/my\_build/my\_icd.json".
476
477NOTE: this environment variable will be ignored for suid programs.
478
479#### Android
480
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -0700481The Android loader lives in the system library folder. The location cannot be
482changed. The loader will load the driver/ICD via hw_get_module with the ID
483of "vulkan". Due to security policies in Android none of this can be modified
484under normal use.
Jon Ashburnc2972682016-02-08 15:42:01 -0700485
486
Jon Ashburncc300a22016-02-11 14:57:30 -0700487ICD interface requirements
488----------------------------------------
Jon Ashburnc2972682016-02-08 15:42:01 -0700489
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700490Generally, for all Vulkan commands issued by an application, the loader can be
491viewed as a pass through. That is, the loader generally doesn’t modified the
Jon Ashburn54791f62016-04-22 14:40:07 -0600492commands or their parameters, but simply calls the ICDs entry point for that
493command. There are specific additional interface requirements an ICD needs to comply with that
494are over and above any requirements from the Vulkan specification including WSI extension specification.
495These addtional requirements are versioned to allow flexibility in the future.
496These interface requirements will be set forth in the following sections: 1) describing
497which "loader-ICD" interface version is available, 2) detailing the most recent interface version;
4983) the supported, older interface requirements will be described as differences
499from the most recent interface version.
Jon Ashburnc2972682016-02-08 15:42:01 -0700500
501#### Windows and Linux
502
Jon Ashburn54791f62016-04-22 14:40:07 -0600503##### Version Negotiation Between Loader and ICDs
Jon Ashburnc2972682016-02-08 15:42:01 -0700504
Jon Ashburn54791f62016-04-22 14:40:07 -0600505All ICDs (supporting interface version 2 or higher) must export the following
506function that is used for determination of the interface version that will be used.
507This entry point is not a part of the Vulkan API itself, only a private interface
508between the loader and ICDs.
Jon Ashburnc2972682016-02-08 15:42:01 -0700509
Jon Ashburn54791f62016-04-22 14:40:07 -0600510VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion);
Jon Ashburnc2972682016-02-08 15:42:01 -0700511
Jon Ashburn54791f62016-04-22 14:40:07 -0600512This entry point reports the "loader-ICD" interface version supported by both the loader and the ICD.
513The loader informs the ICD of it's desired interface version (typically the latest) via the
514pSupportedVersion parameter.
515This call is the first call made by the loader into the ICD (prior to any calls to
516vk\_icdGetInstanceProcAddr).
Jon Ashburnc2972682016-02-08 15:42:01 -0700517
Jon Ashburn54791f62016-04-22 14:40:07 -0600518If a loader sees that an ICD does not export this symbol it knows that it's dealing
519with a legacy ICD supporting either interface version 0 or 1.
520Similarly, if an ICD sees a call to vk\_icdGetInstanceProcAddr before a call to
521vk_icdGetLoaderICDInterfaceVersion then it knows that it's dealing with a legacy loader
522supporting version 0 or 1.
523Note if the loader calls vk\_icdGetInstanceProcAddr first it supports version 1,
524otherwise the loader only supports version 0.
Jon Ashburnc2972682016-02-08 15:42:01 -0700525
Jon Ashburn54791f62016-04-22 14:40:07 -0600526The pSupportedVersion parameter is both an input and output parameter.
527It is filled in by the loader before the call with the desired latest interface version supported by the loader.
Jeff Julianof1619872016-02-17 17:25:42 -0500528
Jon Ashburn54791f62016-04-22 14:40:07 -0600529If the ICD receiving the call no longer supports the interface version provided
530by the loader (due to deprecation) then it can report VK_ERROR_INCOMPATIBLE_DRIVER error,
531otherwise it sets the value pointed by pSupportedVersion to the latest interface
532version supported by both the ICD and the loader and returns VK_SUCCESS.
533The ICD should report VK_SUCCESS in case the loader provided interface version
534is newer than that supported by the ICD, as it's the loader's responsibility to
535determine whether it can support the older interface version supported by the ICD.
536The ICD should also report VK_SUCCESS in the case it's interface version is greater
537than the loader's, but return the loader's version. Thus, upon return of VK_SUCCESS
538the pSupportedVersion will contain the desired interface version to be used by the ICD.
Jon Ashburnc2972682016-02-08 15:42:01 -0700539
Jon Ashburn54791f62016-04-22 14:40:07 -0600540If the loader receives back an interface version from the ICD that the loader no longer
541supports (due to deprecation) or it receives a VK_ERROR_INCOMPATIBLE_DRIVER error
542instead of VK_SUCCESS then the loader will treat the ICD as incompatible
543and will not load it for use. In this case the application will not see the ICDs vkPhysicalDevice
544during enumeration.
Jon Ashburnc2972682016-02-08 15:42:01 -0700545
Jon Ashburn54791f62016-04-22 14:40:07 -0600546##### Loader Version 2 Interface Requirements
Jon Ashburnc2972682016-02-08 15:42:01 -0700547
Jon Ashburn54791f62016-04-22 14:40:07 -0600548Version 2 interface has requirements in three areas: 1) ICD Vulkan entry point discovery,
5492) KHR_surface related requirements in the WSI extensions, 3) Vulkan dispatchable object
550creation requirements.
Jon Ashburnc2972682016-02-08 15:42:01 -0700551
Jon Ashburn54791f62016-04-22 14:40:07 -0600552###### ICD Vulkan entry point discovery
553All ICDs must export the following function that is used for discovery of ICD Vulkan entry points.
554This entry point is not a part of the Vulkan API itself, only a private interface between the loader and ICDs for version 1 and higher interfaces.
Jon Ashburnc2972682016-02-08 15:42:01 -0700555
Jon Ashburn54791f62016-04-22 14:40:07 -0600556VKAPI\_ATTR PFN\_vkVoidFunction VKAPI\_CALL vk\_icdGetInstanceProcAddr(VkInstance instance, const char* pName);
557
558This function has very similar semantics to the Vulkan command vkGetInstanceProcAddr.
559vk\_icdGetInstanceProcAddr returns valid function pointers for all the global level
560and instance level Vulkan commands, and also for vkGetDeviceProcAddr.
561Global level commands are those
562which contain no dispatchable object as the first parameter, such as
563vkCreateInstance and vkEnumerateInstanceExtensionProperties. The ICD must
564support querying global level entry points by calling
565vk\_icdGetInstanceProcAddr with a NULL VkInstance parameter. Instance level
566commands are those that have either VkInstance, or VkPhysicalDevice as the
567first parameter dispatchable object. Both core entry points and any instance
568extension entry points the ICD supports should be available via
569vk\_icdGetInstanceProcAddr. Future Vulkan instance extensions may define and
570use new instance level dispatchable objects other than VkInstance and
571VkPhysicalDevice, in which case extension entry points using these newly
572defined dispatchable objects must be queryable via vk\_icdGetInstanceProcAddr.
573
574All other Vulkan entry points must either NOT be exported from the ICD
575library or else NOT use the official Vulkan function names if they are
576exported. This requirement is for ICD libraries that include other
577functionality (such as OpenGL library) and thus could be loaded by the
578application prior to when the Vulkan loader library is loaded by the
579application. In other words, the ICD library exported Vulkan symbols must not
580clash with the loader's exported Vulkan symbols.
581
582Beware of interposing by dynamic OS library loaders if the official Vulkan
583names are used. On Linux, if official names are used, the ICD library must be
584linked with -Bsymbolic.
585
586###### Handling KHR_surface objects in the WSI extensions
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700587Normally, ICDs handle object creation and destruction for various Vulkan
588objects. The WSI surface extensions for Linux and Windows
589(VK\_KHR\_win32\_surface, VK\_KHR\_xcb\_surface, VK\_KHR\_xlib\_surface,
590VK\_KHR\_mir\_surface, VK\_KHR\_wayland\_surface, and VK\_KHR\_surface) are
591handled differently. For these extensions, the VkSurfaceKHR object creation and
592destruction is handled by the loader as follows:
Jon Ashburnc2972682016-02-08 15:42:01 -0700593
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07005941. Loader handles the vkCreate\*SurfaceKHR() and vkDestroySurfaceKHR()
595 functions including creating/destroying the VkSurfaceKHR object.
Jon Ashburnc2972682016-02-08 15:42:01 -0700596
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07005972. VkSurfaceKHR objects have the underlying structure (VkIcdSurface\*) as
598 defined in include/vulkan/vk\_icd.h.
Jon Ashburnc2972682016-02-08 15:42:01 -0700599
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07006003. ICDs can cast any VkSurfaceKHR object to a pointer to the appropriate
601 VkIcdSurface\* structure.
Jon Ashburnc2972682016-02-08 15:42:01 -0700602
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07006034. VkIcdSurface\* structures include VkIcdSurfaceWin32, VkIcdSurfaceXcb,
Jeff Julianof1619872016-02-17 17:25:42 -0500604 VkIcdSurfaceXlib, VkIcdSurfaceMir, and VkIcdSurfaceWayland. The first field
605 in the structure is a VkIcdSurfaceBase enumerant that indicates whether the
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700606 surface object is Win32, Xcb, Xlib, Mir, or Wayland.
Jon Ashburnc2972682016-02-08 15:42:01 -0700607
Jon Ashburn54791f62016-04-22 14:40:07 -0600608###### ICD dispatchable object creation
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700609As previously covered, the loader requires dispatch tables to be accessible
610within Vulkan dispatchable objects, which include VkInstance, VkPhysicalDevice,
611VkDevice, VkQueue, and VkCommandBuffer. The specific requirements on all
612dispatchable objects created by ICDs are as follows:
Jon Ashburnc2972682016-02-08 15:42:01 -0700613
Jon Ashburncc300a22016-02-11 14:57:30 -0700614- All dispatchable objects created by an ICD can be cast to void \*\*
Jon Ashburnc2972682016-02-08 15:42:01 -0700615
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700616- The loader will replace the first entry with a pointer to the dispatch table
617 which is owned by the loader. This implies three things for ICD drivers:
Jon Ashburnc2972682016-02-08 15:42:01 -0700618
Jon Ashburncc300a22016-02-11 14:57:30 -07006191. The ICD must return a pointer for the opaque dispatchable object handle.
Jon Ashburnc2972682016-02-08 15:42:01 -0700620
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07006212. This pointer points to a regular C structure with the first entry being a
622 pointer. Note: for any C\++ ICD's that implement VK objects directly as C\++
623 classes. The C\++ compiler may put a vtable at offset zero if your class is
Jeff Julianof1619872016-02-17 17:25:42 -0500624 non-POD due to the use of a virtual function. In this case use a regular C
625 structure (see below).
Jon Ashburnc2972682016-02-08 15:42:01 -0700626
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07006273. The loader checks for a magic value (ICD\_LOADER\_MAGIC) in all the created
628 dispatchable objects, as follows (see include/vulkan/vk\_icd.h):
Jon Ashburnc2972682016-02-08 15:42:01 -0700629
630```
631
Jon Ashburncc300a22016-02-11 14:57:30 -0700632#include "vk_icd.h"
Jon Ashburnc2972682016-02-08 15:42:01 -0700633
Jon Ashburncc300a22016-02-11 14:57:30 -0700634union _VK_LOADER_DATA {
635 uintptr loadermagic;
636 void *loaderData;
637} VK_LOADER_DATA;
Jon Ashburnc2972682016-02-08 15:42:01 -0700638
Jon Ashburncc300a22016-02-11 14:57:30 -0700639vkObj alloc_icd_obj()
Jon Ashburnc2972682016-02-08 15:42:01 -0700640{
Jon Ashburncc300a22016-02-11 14:57:30 -0700641 vkObj *newObj = alloc_obj();
642 ...
643 // Initialize pointer to loader's dispatch table with ICD_LOADER_MAGIC
Jon Ashburnc2972682016-02-08 15:42:01 -0700644
Jon Ashburncc300a22016-02-11 14:57:30 -0700645 set_loader_magic_value(newObj);
646 ...
647 return newObj;
Jon Ashburnc2972682016-02-08 15:42:01 -0700648}
Jon Ashburnc2972682016-02-08 15:42:01 -0700649```
650
Jon Ashburn54791f62016-04-22 14:40:07 -0600651##### Loader Version 0 and 1 Interface Differences
652
653Version 0 and 1 interfaces do not support version negotiation via vk\_icdNegotiateLoaderICDInterfaceVersion.
654ICDs can distinguish version 0 and version 1 interfaces as follows:
655if the loader calls vk\_icdGetInstanceProcAddr first it supports version 1,
656otherwise the loader only supports version 0.
657
658Version 0 interface does not support vk\_icdGetInstanceProcAddr. Version 0 interface requirements for
659obtaining ICD Vulkan entry points are as follows:
660
661- vkGetInstanceProcAddr exported in the ICD library and returns valid function
662 pointers for all the Vulkan API entry points;
663
664- vkCreateInstance exported in the ICD library;
665
666- vkEnumerateInstanceExtensionProperties exported in the ICD library;
667
668
Jon Ashburnc2972682016-02-08 15:42:01 -0700669Additional Notes:
670
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700671- The loader will filter out extensions requested in vkCreateInstance and
672vkCreateDevice before calling into the ICD; Filtering will be of extensions
Jeff Julianof1619872016-02-17 17:25:42 -0500673advertised by entities (e.g. layers) different from the ICD in question.
674- The loader will not call the ICD for vkEnumerate\*LayerProperties() as layer
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700675properties are obtained from the layer libraries and layer JSON files.
676- If an ICD library wants to implement a layer it can do so by having the
677appropriate layer JSON manifest file refer to the ICD library file.
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -0700678- The loader will not call the ICD for
679 vkEnumerate\*ExtensionProperties(pLayerName != NULL).
Jon Ashburn2b2f6182016-04-04 16:37:37 -0600680- ICDs creating new dispatchable objects via device extensions need to initialize
Jon Ashburn54791f62016-04-22 14:40:07 -0600681the created dispatchable object. The loader has generic trampoline code for unknown
Jon Ashburn2b2f6182016-04-04 16:37:37 -0600682device extensions. This generic trampoline code doesn't initialize the dispatch table within
Jon Ashburn54791f62016-04-22 14:40:07 -0600683the newly created object. See the section for more information on how to initialize created
684dispatchable objects for extensions non known by the loader. [layer link](#creating-new-dispatchable-objects)
Jeff Julianof1619872016-02-17 17:25:42 -0500685
Jon Ashburnc2972682016-02-08 15:42:01 -0700686#### Android
687
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -0700688The Android loader uses the same protocol for initializing the dispatch
689table as described above. The only difference is that the Android
690loader queries layer and extension information directly from the
691respective libraries and does not use the json manifest files used
692by the Windows and Linux loaders.
Jon Ashburnc2972682016-02-08 15:42:01 -0700693
694Vulkan layer interface with the loader
695--------------------------------------
696
697### Layer discovery
698
699#### Windows
700
701##### Properly-Installed Layers
702
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700703In order to find properly-installed layers, the Vulkan loader will use a
704similar mechanism as used for ICDs. Text information files (aka manifest
705files), that use a JSON format, are read in order to identify the names and
706attributes of layers and their extensions. The use of manifest files allows the
707loader to avoid loading any shared library files when the application does not
708query nor request any extensions. Layers and extensions have additional
709complexity, and so their manifest files contain more information than ICD info
710files. For example, a layer shared library file may contain multiple
711layers/extensions (perhaps even an ICD).
Jon Ashburnc2972682016-02-08 15:42:01 -0700712
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700713In order to find properly-installed layers, the Vulkan loader will scan the
714values in the following Windows registry keys:
Jon Ashburnc2972682016-02-08 15:42:01 -0700715
716HKEY\_LOCAL\_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers
717
718HKEY\_LOCAL\_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ImplicitLayers
719
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700720Explicit layers are those which are enabled by an application (e.g. with the
721vkCreateInstance function), or by an environment variable (as mentioned
722previously).
Jon Ashburnc2972682016-02-08 15:42:01 -0700723
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700724Implicit layers are those which are enabled by their existence. For example,
725certain application environments (e.g. Steam or an automotive infotainment
726system) may have layers which they always want enabled for all applications
727that they start. Other implicit layers may be for all applications started on a
728given system (e.g. layers that overlay frames-per-second). Implicit layers are
729enabled automatically, whereas explicit layers must be enabled explicitly. What
730distinguishes a layer as implicit or explicit is by which registry key its
731layer information file is referenced by.
Jon Ashburnc2972682016-02-08 15:42:01 -0700732
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700733For each value in these keys which has DWORD data set to 0, the loader opens
734the JSON manifest file specified by the name of the value. Each name must be a
735full pathname to the manifest file.
Jon Ashburnc2972682016-02-08 15:42:01 -0700736
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700737The Vulkan loader will open each info file to obtain information about the
738layer, including the name or pathname of a shared library (".dll") file.
Jon Ashburnc2972682016-02-08 15:42:01 -0700739
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700740This manifest file is in the JSON format and contains the following
741information:
Jon Ashburnc2972682016-02-08 15:42:01 -0700742
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700743- (required) "file\_format\_version" - same as for ICDs, except that the format
744version can vary independently for ICDs and layers.
Jon Ashburnc2972682016-02-08 15:42:01 -0700745
746- (required) "name" - layer name
747
748- (required) "type" - which layer chains should the layer be activated on.
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700749Allowable values are "INSTANCE", "DEVICE", "GLOBAL". Global means activate on
750both device and instance chains.
Jon Ashburnc2972682016-02-08 15:42:01 -0700751
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700752- (required) "library\_path" - filename / full path / relative path to the
753library file
Jon Ashburnc2972682016-02-08 15:42:01 -0700754
755- (required) "api\_version" - same as for ICDs.
756
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700757- (required) "implementation\_version" - layer version, a single number
758increasing with backward compatible changes.
Jon Ashburnc2972682016-02-08 15:42:01 -0700759
760- (required) "description" - informative description of the layer.
761
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700762- (optional) "device\_extensions" or "instance\_extensions" - array of
763extension information as follows
Jon Ashburnc2972682016-02-08 15:42:01 -0700764
Jon Ashburncc300a22016-02-11 14:57:30 -0700765 - (required) extension "name" - Vulkan registered name
Jon Ashburnc2972682016-02-08 15:42:01 -0700766
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700767 - (required) extension "spec\_version" - extension specification version, a
768single number, increasing with backward compatible changes.
Jon Ashburnc2972682016-02-08 15:42:01 -0700769
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700770 - (required for device\_extensions with entry points) extension
Jeff Julianof1619872016-02-17 17:25:42 -0500771"entrypoints" - array of device extension entry points; not used for instance
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700772extensions
Jon Ashburnc2972682016-02-08 15:42:01 -0700773
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700774- (sometimes required) "functions" - mapping list of function entry points. If
775multiple layers exist within the same shared library (or if a layer is in the
776same shared library as an ICD), this must be specified to allow each layer to
Jeff Julianof1619872016-02-17 17:25:42 -0500777have its own vkGet\*ProcAddr entry points that can be found by the loader. At
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700778this time, only the following two functions are required:
Jon Ashburnc2972682016-02-08 15:42:01 -0700779
Jon Ashburncc300a22016-02-11 14:57:30 -0700780 - "vkGetInstanceProcAddr" name
Jon Ashburnc2972682016-02-08 15:42:01 -0700781
Jon Ashburncc300a22016-02-11 14:57:30 -0700782 - "vkGetDeviceProcAddr" name
Jon Ashburnc2972682016-02-08 15:42:01 -0700783
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700784- (optional for implicit layers) "enable\_environment" requirement(s) -
785environment variable and value required to enable an implicit layer. This
786environment variable (which should vary with each "version" of the layer, as in
787"ENABLE\_LAYER\_FOO\_1") must be set to the given value or else the implicit
788layer is not loaded. This is for application environments (e.g. Steam) which
789want to enable a layer(s) only for applications that they launch, and allows
790for applications run outside of an application environment to not get that
791implicit layer(s).
Jon Ashburnc2972682016-02-08 15:42:01 -0700792
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700793- (required for implicit layers) "disable\_environment" requirement(s) -
794environment variable and value required to disable an implicit layer. Note: in
795rare cases of an application not working with an implicit layer, the
796application can set this environment variable (before calling Vulkan functions)
797in order to "blacklist" the layer. This environment variable (which should vary
798with each "version" of the layer, as in "DISABLE\_LAYER\_FOO\_1") must be set
799(not particularly to any value). If both the "enable\_environment" and
800"disable\_environment" variables are set, the implicit layer is disabled.
Jon Ashburnc2972682016-02-08 15:42:01 -0700801
802For example:
803
Jon Ashburncc300a22016-02-11 14:57:30 -0700804```
Jon Ashburnc2972682016-02-08 15:42:01 -0700805{
Jon Ashburncc300a22016-02-11 14:57:30 -0700806"file_format_version" : "1.0.0",
807"layer": {
808 "name": "VK_LAYER_LUNARG_OverlayLayer",
809 "type": "DEVICE",
810 "library_path": "vkOverlayLayer.dll"
Tony Barbourd83f06c2016-03-08 14:50:03 -0700811 "api_version" : "1.0.5",
Jon Ashburncc300a22016-02-11 14:57:30 -0700812 "implementation_version" : "2",
813 "description" : "LunarG HUD layer",
814 "functions": {
815 "vkGetInstanceProcAddr": "OverlayLayer_GetInstanceProcAddr",
816 "vkGetDeviceProcAddr": "OverlayLayer_GetDeviceProcAddr"
817 },
Jon Ashburn26ed3f32016-02-14 21:54:52 -0700818 "instance_extensions": [
Jon Ashburncc300a22016-02-11 14:57:30 -0700819 {
820 "name": "VK_debug_report_EXT",
821 "spec_version": "1"
822 },
823 {
824 "name": "VK_VENDOR_DEBUG_X",
825 "spec_version": "3"
826 }
827 ],
Courtney Goeltzenleuchter84a75ce2016-02-15 15:07:54 -0700828 "device_extensions": [
Jon Ashburncc300a22016-02-11 14:57:30 -0700829 {
Jon Ashburn58048d02016-03-03 12:03:58 -0700830 "name": "VK_DEBUG_MARKER_EXT",
Jon Ashburncc300a22016-02-11 14:57:30 -0700831 "spec_version": "1",
832 "entrypoints": ["vkCmdDbgMarkerBegin", "vkCmdDbgMarkerEnd"]
833 }
834 ],
835 "disable_environment": {
836 "DISABLE_LAYER_OVERLAY_1": ""
837 }
Jon Ashburnc2972682016-02-08 15:42:01 -0700838}
Jon Ashburnc2972682016-02-08 15:42:01 -0700839}
Jon Ashburncc300a22016-02-11 14:57:30 -0700840```
Jon Ashburnc2972682016-02-08 15:42:01 -0700841
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700842The "library\_path" specifies either a filename, a relative pathname, or a full
843pathname to a layer shared library (".dll") file, which the loader will attempt
844to load using LoadLibrary(). If the layer is specified via a relative pathname,
845it is relative to the path of the info file (e.g. for cases when an application
846provides a layer that is in the same folder hierarchy as the rest of the
847application files). If the layer is specified via a filename, the shared
848library lives in the system's DLL search path (e.g. in the
849"C:\\Windows\\System32" folder).
Jon Ashburnc2972682016-02-08 15:42:01 -0700850
851There are no rules about the name of the text files (except the .json suffix).
852
853There are no rules about the name of the layer shared library files.
854
855##### Using Pre-Production Layers
856
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700857As with ICDs, developers may need to use special, pre-production layers,
858without modifying the properly-installed layers. This need is met with the use
859of the "VK\_LAYER\_PATH" environment variable, which will override the
860mechanism using for finding properly-installed layers. Because many layers may
861exist on a system, this environment variable is a semi-colon-separated list of
862folders that contain layer info files. Only the folder listed in
863"VK\_LAYER\_PATH" will be scanned for info files. Each semi-colon-separated
864entry is:
Jon Ashburnc2972682016-02-08 15:42:01 -0700865
866- The full pathname of a folder containing layer info files
867
868#### Linux
869
870##### Properly-Installed Layers
871
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700872In order to find properly-installed layers, the Vulkan loader will use a
873similar mechanism as used for ICDs. Text information files, that use a JSON
874format, are read in order to identify the names and attributes of layers and
875their extensions. The use of text info files allows the loader to avoid loading
876any shared library files when the application does not query nor request any
877extensions. Layers and extensions have additional complexity, and so their info
878files contain more information than ICD info files. For example, a layer shared
879library file may contain multiple layers/extensions (perhaps even an ICD).
Jon Ashburnc2972682016-02-08 15:42:01 -0700880
881The Vulkan loader will scan the files in the following Linux directories:
882
883/usr/share/vulkan/explicit\_layer.d
Jon Ashburnc2972682016-02-08 15:42:01 -0700884/usr/share/vulkan/implicit\_layer.d
Jon Ashburnc2972682016-02-08 15:42:01 -0700885/etc/vulkan/explicit\_layer.d
Jon Ashburnc2972682016-02-08 15:42:01 -0700886/etc/vulkan/implicit\_layer.d
David Pinedo3e163ee2016-04-18 16:59:59 -0600887\$HOME/.local/share/vulkan/explicit\_layer.d
888\$HOME/.local/share/vulkan/implicit\_layer.d
Jon Ashburn7f00ca82016-02-24 12:00:55 -0700889
890Where $HOME is the current home directory of the application's user id; this
891path will be ignored for suid programs.
Jon Ashburnc2972682016-02-08 15:42:01 -0700892
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700893Explicit layers are those which are enabled by an application (e.g. with the
894vkCreateInstance function), or by an environment variable (as mentioned
895previously). Implicit layers are those which are enabled by their existence.
896For example, certain application environments (e.g. Steam or an automotive
897infotainment system) may have layers which they always want enabled for all
898applications that they start. Other implicit layers may be for all applications
899started on a given system (e.g. layers that overlay frames-per-second).
900Implicit layers are enabled automatically, whereas explicit layers must be
901enabled explicitly. What distinguishes a layer as implicit or explicit is by
902which directory its layer information file exists in.
Jon Ashburnc2972682016-02-08 15:42:01 -0700903
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700904The "/usr/share/vulkan/\*\_layer.d" directories are for layers that are
905installed from Linux-distribution-provided packages. The
906"/etc/vulkan/\*\_layer.d" directories are for layers that are installed from
907non-Linux-distribution-provided packages.
Jon Ashburnc2972682016-02-08 15:42:01 -0700908
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700909The information file is in the JSON format and contains the following
910information:
Jon Ashburnc2972682016-02-08 15:42:01 -0700911
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700912- (required) "file\_format\_version" – same as for ICDs, except that the format
913version can vary independently for ICDs and layers.
Jon Ashburnc2972682016-02-08 15:42:01 -0700914
915- (required) "name" - layer name
916
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700917- (required) "type" - which layer chains should the layer be activated on.
918Allowable values are "INSTANCE", "DEVICE", "GLOBAL". Global means activate on
919both device and instance chains.
Jon Ashburnc2972682016-02-08 15:42:01 -0700920
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700921- (required) "library\_path" - filename / full path / relative path to the text
922file
Jon Ashburnc2972682016-02-08 15:42:01 -0700923
924- (required) "api\_version" – same as for ICDs.
925
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700926- (required) "implementation\_version" – layer version, a single number
927increasing with backward compatible changes.
Jon Ashburnc2972682016-02-08 15:42:01 -0700928
Jeff Julianof1619872016-02-17 17:25:42 -0500929- (required) "description" – informative description of the layer.
Jon Ashburnc2972682016-02-08 15:42:01 -0700930
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700931- (optional) "device\_extensions" or "instance\_extensions" - array of
932extension information as follows
Jon Ashburnc2972682016-02-08 15:42:01 -0700933
Jon Ashburncc300a22016-02-11 14:57:30 -0700934 - (required) extension "name" - Vulkan registered name
Jon Ashburnc2972682016-02-08 15:42:01 -0700935
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700936 - (required) extension "spec\_version" - extension specification version, a
937single number, increasing with backward compatible changes.
Jon Ashburnc2972682016-02-08 15:42:01 -0700938
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700939 - (required for device extensions with entry points) extension
Jeff Julianof1619872016-02-17 17:25:42 -0500940"entrypoints" - array of device extension entry points; not used for instance
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700941extensions
Jon Ashburnc2972682016-02-08 15:42:01 -0700942
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700943- (sometimes required) "functions" - mapping list of function entry points. If
944multiple layers exist within the same shared library (or if a layer is in the
945same shared library as an ICD), this must be specified to allow each layer to
Jeff Julianof1619872016-02-17 17:25:42 -0500946have its own vkGet\*ProcAddr entry points that can be found by the loader. At
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700947this time, only the following two functions are required:
Jon Ashburncc300a22016-02-11 14:57:30 -0700948 - "vkGetInstanceProcAddr" name
949 - "vkGetDeviceProcAddr" name
Jon Ashburnc2972682016-02-08 15:42:01 -0700950
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700951- (optional for implicit layers) "enable\_environment" requirement(s) -
952environment variable and value required to enable an implicit layer. This
953environment variable (which should vary with each "version" of the layer, as in
954"ENABLE\_LAYER\_FOO\_1") must be set to the given value or else the implicit
955layer is not loaded. This is for application environments (e.g. Steam) which
956want to enable a layer(s) only for applications that they launch, and allows
957for applications run outside of an application environment to not get that
958implicit layer(s).
Jon Ashburnc2972682016-02-08 15:42:01 -0700959
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -0700960- (required for implicit layers) "disable\_environment" requirement(s) -
961environment variable and value required to disable an implicit layer. Note: in
962rare cases of an application not working with an implicit layer, the
963application can set this environment variable (before calling Vulkan functions)
964in order to "blacklist" the layer. This environment variable (which should vary
965with each "version" of the layer, as in "DISABLE\_LAYER\_FOO\_1") must be set
966(not particularly to any value). If both the "enable\_environment" and
967"disable\_environment" variables are set, the implicit layer is disabled.
Jon Ashburnc2972682016-02-08 15:42:01 -0700968
969For example:
Jon Ashburncc300a22016-02-11 14:57:30 -0700970```
Jon Ashburnc2972682016-02-08 15:42:01 -0700971{
Jon Ashburncc300a22016-02-11 14:57:30 -0700972"file_format_version" : "1.0.0",
Jon Ashburnc2972682016-02-08 15:42:01 -0700973"layer": {
Jon Ashburncc300a22016-02-11 14:57:30 -0700974 "name": "VK_LAYER_LUNARG_OverlayLayer",
975 "type": "DEVICE",
976 "library_path": "vkOverlayLayer.dll"
Tony Barbourd83f06c2016-03-08 14:50:03 -0700977 "api_version" : "1.0.5",
Jon Ashburncc300a22016-02-11 14:57:30 -0700978 "implementation_version" : "2",
979 "description" : "LunarG HUD layer",
980 "functions": {
981 "vkGetInstanceProcAddr": "OverlayLayer_GetInstanceProcAddr",
982 "vkGetDeviceProcAddr": "OverlayLayer_GetDeviceProcAddr"
983 },
Jon Ashburn26ed3f32016-02-14 21:54:52 -0700984 "instance_extensions": [
Jon Ashburncc300a22016-02-11 14:57:30 -0700985 {
986 "name": "VK_debug_report_EXT",
987 "spec_version": "1"
988 },
989 {
990 "name": "VK_VENDOR_DEBUG_X",
991 "spec_version": "3"
992 }
993 ],
Courtney Goeltzenleuchter84a75ce2016-02-15 15:07:54 -0700994 "device_extensions": [
Jon Ashburncc300a22016-02-11 14:57:30 -0700995 {
Jon Ashburn58048d02016-03-03 12:03:58 -0700996 "name": "VK_DEBUG_MARKER_EXT",
Jon Ashburncc300a22016-02-11 14:57:30 -0700997 "spec_version": "1",
998 "entrypoints": ["vkCmdDbgMarkerBegin", "vkCmdDbgMarkerEnd"]
999 }
1000 ],
1001 "disable_environment": {
1002 "DISABLE_LAYER_OVERLAY_1": ""
1003 }
Jon Ashburnc2972682016-02-08 15:42:01 -07001004}
Jon Ashburnc2972682016-02-08 15:42:01 -07001005}
Jon Ashburncc300a22016-02-11 14:57:30 -07001006```
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001007The "library\_path" specifies either a filename, a relative pathname, or a full
1008pathname to a layer shared library (".so") file, which the loader will attempt
1009to load using dlopen(). If the layer is specified via a filename, the loader
1010will attempt to open that file as a shared object using dlopen(), and the file
1011must be in a directory that dlopen is configured to look in (Note: various
1012distributions are configured differently). A distribution is free to create
1013Vulkan-specific system directories (e.g. ".../vulkan/layers"), but is not
1014required to do so. If the layer is specified via a relative pathname, it is
1015relative to the path of the info file (e.g. for cases when an application
1016provides a layer that is in the same directory hierarchy as the rest of the
1017application files).
Jon Ashburnc2972682016-02-08 15:42:01 -07001018
1019There are no rules about the name of the text files (except the .json suffix).
1020
1021There are no rules about the name of the layer shared library files.
1022
1023##### Using Pre-Production Layers
1024
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001025As with ICDs, developers may need to use special, pre-production layers,
1026without modifying the properly-installed layers. This need is met with the use
1027of the "VK\_LAYER\_PATH" environment variable, which will override the
1028mechanism using for finding properly-installed layers. Because many layers may
1029exist on a system, this environment variable is a colon-separated list of
1030directories that contain layer info files. Only the directories listed in
1031"VK\_LAYER\_PATH" will be scanned for info files. Each colon-separated entry
1032is:
Jon Ashburnc2972682016-02-08 15:42:01 -07001033
1034- The full pathname of a directory containing layer info files
1035
1036NOTE: these environment variables will be ignored for suid programs.
1037
1038#### Android
1039
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -07001040The recommended way to enable layers is for applications
1041to programatically enable them. The layers are provided by the application
1042and must live in the application's library folder. The application
1043enables the layers at vkCreateInstance and vkCreateDevice as any Vulkan
1044application would.
1045An application enabled for debug has more options. It can enumerate and enable
1046layers located in /data/local/vulkan/debug.
Jon Ashburnc2972682016-02-08 15:42:01 -07001047
Jon Ashburncc300a22016-02-11 14:57:30 -07001048Layer interface requirements
1049------------------------------------------------------
Jon Ashburnc2972682016-02-08 15:42:01 -07001050
1051#### Architectural interface overview
1052
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001053There are two key architectural features that drive the loader to layer library
1054interface: 1) separate and distinct instance and device call chains, and 2)
1055distributed dispatch. First these architectural features will be described and
1056then the detailed interface will be specified.
Jon Ashburnc2972682016-02-08 15:42:01 -07001057
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001058Call chains are the links of calls for a given Vulkan command from layer module
1059to layer module with the loader and or the ICD being the bottom most command.
1060Call chains are constructed at both the instance level and the device level by
1061the loader with cooperation from the layer libraries. Instance call chains are
1062constructed by the loader when layers are enabled at vkCreateInstance. Device
1063call chains are constructed by the loader when layers are enabled at
ttyio0811cec2016-04-10 22:09:44 +08001064vkCreateDevice. A layer can intercept Vulkan instance commands, device commands
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001065or both. For a layer to intercept instance commands, it must participate in the
1066instance call chain. For a layer to intercept device commands, it must
1067participate in the device chain. Layers which participate in intercepting calls
Jeff Julianof1619872016-02-17 17:25:42 -05001068in both the instance and device chains are called global layers.
Jon Ashburnc2972682016-02-08 15:42:01 -07001069
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001070Normally, when a layer intercepts a given Vulkan command, it will call down the
1071instance or device chain as needed. The loader and all layer libraries that
1072participate in a call chain cooperate to ensure the correct sequencing of calls
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -07001073from one entity to the next. This group effort for call chain sequencing is
Jeff Julianof1619872016-02-17 17:25:42 -05001074hereinafter referred to as distributed dispatch. In distributed dispatch, since
1075each layer is responsible for properly calling the next entity in the device or
1076instance chain, a dispatch mechanism is required for all Vulkan commands a
1077layer intercepts. For Vulkan commands that are not intercepted by a layer, or
1078if the layer chooses to terminate a given Vulkan command by not calling down
1079the chain, then no dispatch mechanism is needed for that particular Vulkan
1080command. Only for those Vulkan commands, which may be a subset of all Vulkan
1081commands, that a layer intercepts is a dispatching mechanism by the layer
1082needed. The loader is responsible for dispatching all core and instance
1083extension Vulkan commands to the first entity in the chain.
Jon Ashburnc2972682016-02-08 15:42:01 -07001084
Jeff Julianof1619872016-02-17 17:25:42 -05001085Instance level Vulkan commands are those that have the dispatchable objects
1086VkInstance, or VkPhysicalDevice as the first parameter and also includes
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001087vkCreateInstance.
Jeff Julianof1619872016-02-17 17:25:42 -05001088
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001089Device level Vulkan commands are those that use VkDevice, VkQueue or
1090VkCommandBuffer as the first parameter and also include vkCreateDevice. Future
1091extensions may introduce new instance or device level dispatchable objects, so
1092the above lists may be extended in the future.
Jon Ashburnc2972682016-02-08 15:42:01 -07001093
Chia-I Wucb24fec2016-04-20 06:23:24 +08001094#### Layer Library Interface
Jeff Julianof1619872016-02-17 17:25:42 -05001095
Chia-I Wucb24fec2016-04-20 06:23:24 +08001096A layer library is a container of layers. This section defines an extensible
1097programming interface to discover layers contained in layer libraries. It
1098also specifies the minimal conventions and rules a layer must follow.
1099
1100Other sections might have other guidelines that layers, at least validation
1101layers, should follow.
1102
1103##### Layer Conventions and Rules
1104
1105A layer, when inserted into an otherwise compliant Vulkan implementation, must
1106still result in a compliant Vulkan implementation[\*]. It must additionally
1107follow some conventions and rules.
1108
1109A layer is always chained with other layers. It must not make invalid calls
1110to or rely on undefined behaviors of its lower layers. When it changes the
1111behavior of a command, it must make sure its upper layers do not make invalid
1112calls to or rely on undefined behaviors of its lower layers because of the
1113changed behavior. For example, when a layer intercepts an object creation
1114command to wrap the objects created by its lower layers, it must make sure its
1115lower layers never see the wrapping objects, directly from itself or
1116indirectly from its upper layers.
1117
1118When a layer requires host memory, it is free to scope the allocations to
1119itself, bypassing the provided allocators entirely.
1120
Chia-I Wuadac8342016-04-22 08:12:19 +08001121`vkEnumerateDeviceExtensionProperties` must handle the case where `pLayerName`
1122is `NULL`, usually by chaining to other layers.
Chia-I Wucb24fec2016-04-20 06:23:24 +08001123
1124`vkGetInstanceProcAddr` can intercept a command by returning a function
1125pointer different from what would be returned through chaining.
1126
1127`vkGetDeviceProcAddr` can intercept a command by returning a function pointer
1128different from what would be returned through chaining.
1129
1130`vkCreateInstance` must not generate an error for unrecognized layer names,
1131extension names, and `pNext` structs. It may assume the layer names and
1132extension names have been validated.
1133
1134`vkCreateDevice` must not generate an error for unrecognized layer names,
1135extension names, and `pNext` structs. It may assume the layer names and
1136extension names have been validated.
1137
1138[\*]: The intention is for layers to have a well-defined baseline behavior.
1139Some of the conventions or rules, for example, may be considered abuses of the
1140specification.
1141
1142###### Layer Library Interface Version 0
1143
1144A layer library supporting interface version 0 must define and export these
1145functions, unrelated to any Vulkan command despite the names, signatures, and
1146other similarities:
1147
1148 - `vkEnumerateInstanceLayerProperties` enumerates all instance layers in a
1149 layer library. This function never fails.
1150
1151 - `vkEnumerateInstanceExtensionProperties` enumerates instance extensions of
1152 instance layers in a layer library. `pLayerName` is always a valid
1153 instance layer name. This function never fails.
1154
1155 - `vkEnumerateDeviceLayerProperties` enumerates all device layers in a layer
1156 library. `physicalDevice` is always `VK_NULL_HANDLE`. This function never
1157 fails.
1158
1159 - `vkEnumerateDeviceExtensionProperties` enumerates device extensions of
1160 device layers in a layer library. `physicalDevice` is always
1161 `VK_NULL_HANDLE`. `pLayerName` is always a valid device layer name. This
1162 function never fails.
1163
1164 - `<layerName>GetInstanceProcAddr` behaves as if `<layerName>`'s
1165 `vkGetInstanceProcAddr` is called, except
1166
1167 - when `pName` is `vkEnumerateInstanceLayerProperties`,
1168 `vkEnumerateInstanceExtensionProperties`, or
1169 `vkEnumerateDeviceLayerProperties` (but _not_
1170 `vkEnumerateDeviceExtensionProperties`), it returns a function pointer to
1171 the function of the same name defined by this interface.
1172 - when `pName` is `vkGetInstanceProcAddr`, it returns a function pointer
1173 to itself.
1174 - when `pName` is `vkCreateDevice`, it ignores `instance`.
1175 - when `pName` is a device command defined by Vulkan 1.0 or
1176 `VK_KHR_swapchain` (but _not_ other device commands), it may chain to
1177 other layers without intercepting. A loader should avoid querying such
1178 device commands.
1179
1180 When a layer library contains only one layer, this function may
1181 alternatively be named `vkGetInstanceProcAddr`.
1182
1183 - `<layerName>GetDeviceProcAddr` behaves as if `<layerName>`'s
1184 `vkGetDeviceProcAddr` is called.
1185
1186 When a layer library contains only one layer, this function may
1187 alternatively be named `vkGetDeviceProcAddr`.
1188
1189All contained layers must support [`vk_layer.h`][]. They do not need to
1190implement commands that are not queryable. They are recommended not to export
1191any command.
1192
1193[`vk_layer.h`]: ../include/vulkan/vk_layer.h
1194
1195#### Layer Libraries and Manifest Files
1196
1197The layer libraries and the manifest files must be kept in sync. On Windows
1198and Linux, the loader uses manifest files to discover layer libraries and
1199layers. On Android, the loader inspects the layer libraries directly.
1200
1201The manifest file specifies in its "functions", "vkGetInstanceProcAddr" node
1202the function name the loader will use to discover
1203<layerName>GetInstanceProcAddr. When the layer library exports
1204<layerName>GetInstanceProcAddr, the JSON node must explicitly specify that
1205function name. When the layer library exports vkGetInstanceProcAddr, the JSON
1206node may be omitted. The layer library may additionally export another alias
1207and specify that in the JSON node.
1208
1209Similarly, the manifest file specifies in its "functions",
1210"vkGetDeviceProcAddr" node the function name the loader will use to discover
1211<layerName>GetDeviceProcAddr. When the layer library exports
1212<layerName>GetDeviceProcAddr, the JSON node must explicitly specify that
1213function name. When the layer library exports vkGetDeviceProcAddr, the JSON
1214node may be omitted. The layer library may additionally export another alias
1215and specify that in the JSON node.
Jon Ashburnc2972682016-02-08 15:42:01 -07001216
1217#### Layer intercept requirements
Jeff Julianof1619872016-02-17 17:25:42 -05001218
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001219- Layers intercept a Vulkan command by defining a C/C++ function with signature
1220identical to the Vulkan API for that command.
Chia-I Wucb24fec2016-04-20 06:23:24 +08001221- An instance layer must intercept at least vkGetInstanceProcAddr and
1222vkCreateInstance. A device layer must intercept at least vkGetDeviceProcAddr
1223and vkCreateDevice.
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001224- Other than the two vkGet*ProcAddr, all other functions intercepted by a layer
1225need NOT be exported by the layer.
1226- For any Vulkan command a layer intercepts which has a non-void return value,
1227an appropriate value must be returned by the layer intercept function.
1228- The layer intercept function must call down the chain to the corresponding
1229Vulkan command in the next entity. Undefined results will occur if a layer
1230doesn't propagate calls down the chain. The two exceptions to this requirement
1231are vkGetInstanceProcAddr and vkGetDeviceProcAddr which only call down the
1232chain for Vulkan commands that they do not intercept.
1233- Layer intercept functions may insert extra calls to Vulkan commands in
1234addition to the intercept. For example, a layer intercepting vkQueueSubmit may
1235want to add a call to vkQueueWaitIdle after calling down the chain for
1236vkQueueSubmit. Any additional calls inserted by a layer must be on the same
1237chain. They should call down the chain.
Jon Ashburnc2972682016-02-08 15:42:01 -07001238
1239#### Distributed dispatching requirements
Jeff Julianof1619872016-02-17 17:25:42 -05001240
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001241- For each entry point a layer intercepts, it must keep track of the entry
1242point residing in the next entity in the chain it will call down into. In other
1243words, the layer must have a list of pointers to functions of the appropriate
1244type to call into the next entity. This can be implemented in various ways but
1245for clarity will be referred to as a dispatch table.
1246- A layer can use the VkLayerDispatchTable structure as a device dispatch table
1247(see include/vulkan/vk_layer.h).
1248- A layer can use the VkLayerInstanceDispatchTable structure as a instance
1249dispatch table (see include/vulkan/vk_layer.h).
1250- Layers vkGetInstanceProcAddr function uses the next entity's
Jeff Julianof1619872016-02-17 17:25:42 -05001251vkGetInstanceProcAddr to call down the chain for unknown (i.e. non-intercepted)
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001252functions.
1253- Layers vkGetDeviceProcAddr function uses the next entity's
Jeff Julianof1619872016-02-17 17:25:42 -05001254vkGetDeviceProcAddr to call down the chain for unknown (i.e. non-intercepted)
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001255functions.
Jon Ashburnc2972682016-02-08 15:42:01 -07001256
1257#### Layer dispatch initialization
Jeff Julianof1619872016-02-17 17:25:42 -05001258
1259- A layer initializes its instance dispatch table within its vkCreateInstance
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001260function.
Jeff Julianof1619872016-02-17 17:25:42 -05001261- A layer initializes its device dispatch table within its vkCreateDevice
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001262function.
1263- The loader passes a linked list of initialization structures to layers via
1264the "pNext" field in the VkInstanceCreateInfo and VkDeviceCreateInfo structures
1265for vkCreateInstance and VkCreateDevice respectively.
1266- The head node in this linked list is of type VkLayerInstanceCreateInfo for
Courtney Goeltzenleuchter42c4cdb2016-02-14 11:42:24 -07001267instance and VkLayerDeviceCreateInfo for device. See file
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001268include/vulkan/vk_layer.h for details.
1269- A VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO is used by the loader for the
1270"sType" field in VkLayerInstanceCreateInfo.
1271- A VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO is used by the loader for the
1272"sType" field in VkLayerDeviceCreateInfo.
1273- The "function" field indicates how the union field "u" should be interpreted
1274within VkLayer*CreateInfo. The loader will set the "function" field to
1275VK_LAYER_LINK_INFO. This indicates "u" field should be VkLayerInstanceLink or
1276VkLayerDeviceLink.
Jon Ashburnc2972682016-02-08 15:42:01 -07001277- The VkLayerInstanceLink and VkLayerDeviceLink structures are the list nodes.
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001278- The VkLayerInstanceLink contains the next entity's vkGetInstanceProcAddr used
1279by a layer.
1280- The VkLayerDeviceLink contains the next entity's vkGetInstanceProcAddr and
1281vkGetDeviceProcAddr used by a layer.
1282- Given the above structures set up by the loader, layer must initialize their
1283dispatch table as follows:
1284 - Find the VkLayerInstanceCreateInfo/VkLayerDeviceCreateInfo structure in
1285the VkInstanceCreateInfo/VkDeviceCreateInfo structure.
Jon Ashburncc300a22016-02-11 14:57:30 -07001286 - Get the next entity's vkGet*ProcAddr from the "pLayerInfo" field.
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001287 - For CreateInstance get the next entity's vkCreateInstance by calling the
1288"pfnNextGetInstanceProcAddr":
Jon Ashburnc2972682016-02-08 15:42:01 -07001289 pfnNextGetInstanceProcAddr(NULL, "vkCreateInstance").
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001290 - For CreateDevice get the next entity's vkCreateDevice by calling the
1291"pfnNextGetInstanceProcAddr":
Jon Ashburnc2972682016-02-08 15:42:01 -07001292 pfnNextGetInstanceProcAddr(NULL, "vkCreateDevice").
Jon Ashburncc300a22016-02-11 14:57:30 -07001293 - Advanced the linked list to the next node: pLayerInfo = pLayerInfo->pNext.
1294 - Call down the chain either CreateDevice or CreateInstance
Courtney Goeltzenleuchtera1473762016-02-14 09:31:24 -07001295 - Initialize your layer dispatch table by calling the next entity's
1296Get*ProcAddr function once for each Vulkan command needed in your dispatch
1297table
Jon Ashburncc300a22016-02-11 14:57:30 -07001298
Courtney Goeltzenleuchterf6abc202016-02-15 15:05:16 -07001299#### Example code for CreateInstance
Jon Ashburnfe630fb2016-02-14 21:40:34 -07001300
Courtney Goeltzenleuchterf6abc202016-02-15 15:05:16 -07001301```cpp
1302VkResult vkCreateInstance(
1303 const VkInstanceCreateInfo *pCreateInfo,
1304 const VkAllocationCallbacks *pAllocator,
1305 VkInstance *pInstance)
1306{
1307 VkLayerInstanceCreateInfo *chain_info =
1308 get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
1309
1310 assert(chain_info->u.pLayerInfo);
1311 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr =
1312 chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
1313 PFN_vkCreateInstance fpCreateInstance =
1314 (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance");
1315 if (fpCreateInstance == NULL) {
1316 return VK_ERROR_INITIALIZATION_FAILED;
1317 }
1318
1319 // Advance the link info for the next element of the chain
1320 chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
1321
1322 // Continue call down the chain
1323 VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
1324 if (result != VK_SUCCESS)
1325 return result;
1326
Jon Ashburn2b2f6182016-04-04 16:37:37 -06001327 // Init layer's dispatch table using GetInstanceProcAddr of
Courtney Goeltzenleuchterf6abc202016-02-15 15:05:16 -07001328 // next layer in the chain.
Jon Ashburn2b2f6182016-04-04 16:37:37 -06001329 instance_dispatch_table = new VkLayerInstanceDispatchTable;
Courtney Goeltzenleuchterf6abc202016-02-15 15:05:16 -07001330 layer_init_instance_dispatch_table(
1331 *pInstance, my_data->instance_dispatch_table, fpGetInstanceProcAddr);
1332
Courtney Goeltzenleuchterf6abc202016-02-15 15:05:16 -07001333 // Other layer initialization
1334 ...
1335
1336 return VK_SUCCESS;
1337}
1338```
1339
1340#### Example code for CreateDevice
1341
1342```cpp
1343VkResult
1344vkCreateDevice(
1345 VkPhysicalDevice gpu,
1346 const VkDeviceCreateInfo *pCreateInfo,
1347 const VkAllocationCallbacks *pAllocator,
1348 VkDevice *pDevice)
1349{
1350 VkLayerDeviceCreateInfo *chain_info =
1351 get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO);
1352
1353 PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr =
1354 chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr;
1355 PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr =
1356 chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr;
1357 PFN_vkCreateDevice fpCreateDevice =
1358 (PFN_vkCreateDevice)fpGetInstanceProcAddr(NULL, "vkCreateDevice");
1359 if (fpCreateDevice == NULL) {
1360 return VK_ERROR_INITIALIZATION_FAILED;
1361 }
1362
1363 // Advance the link info for the next element on the chain
1364 chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
1365
1366 VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice);
1367 if (result != VK_SUCCESS) {
1368 return result;
1369 }
1370
Jon Ashburn2b2f6182016-04-04 16:37:37 -06001371 // initialize layer's dispatch table
1372 device_dispatch_table = new VkLayerDispatchTable;
Courtney Goeltzenleuchterf6abc202016-02-15 15:05:16 -07001373 layer_init_device_dispatch_table(
Jon Ashburn2b2f6182016-04-04 16:37:37 -06001374 *pDevice, device_dispatch_table, fpGetDeviceProcAddr);
Courtney Goeltzenleuchterf6abc202016-02-15 15:05:16 -07001375
1376 // Other layer initialization
1377 ...
1378
1379 return VK_SUCCESS;
1380}
1381```
Jon Ashburnfe630fb2016-02-14 21:40:34 -07001382
Jon Ashburncc300a22016-02-11 14:57:30 -07001383#### Special Considerations
Jon Ashburn2b2f6182016-04-04 16:37:37 -06001384##### Associating private data with Vulkan objects within a layer
Courtney Goeltzenleuchter7221a5a2016-02-15 14:59:37 -07001385A layer may want to associate it's own private data with one or more Vulkan
1386objects.
1387Two common methods to do this are hash maps and object wrapping. The loader
1388supports layers wrapping any Vulkan object including dispatchable objects.
1389Layers which wrap objects should ensure they always unwrap objects before
1390passing them down the chain. This implies the layer must intercept every Vulkan
1391command which uses the object in question. Layers above the object wrapping
Jon Ashburn859c7fb2016-03-02 17:26:31 -07001392layer will see the wrapped object. Layers which wrap dispatchable objects must
1393ensure that the first field in the wrapping structure is a pointer to a dispatch table
1394as defined in vk_layer.h. Specifically, an instance wrapped dispatchable object
1395could be as follows:
1396```
1397struct my_wrapped_instance_obj_ {
1398 VkLayerInstanceDispatchTable *disp;
1399 // whatever data layer wants to add to this object
1400};
1401```
1402A device wrapped dispatchable object could be as follows:
1403```
1404struct my_wrapped_instance_obj_ {
1405 VkLayerDispatchTable *disp;
1406 // whatever data layer wants to add to this object
1407};
1408```
Jeff Julianof1619872016-02-17 17:25:42 -05001409
1410Alternatively, a layer may want to use a hash map to associate data with a
Courtney Goeltzenleuchter7221a5a2016-02-15 14:59:37 -07001411given object. The key to the map could be the object. Alternatively, for
1412dispatchable objects at a given level (eg device or instance) the layer may
1413want data associated with the VkDevice or VkInstance objects. Since
Jeff Julianof1619872016-02-17 17:25:42 -05001414there are multiple dispatchable objects for a given VkInstance or VkDevice, the
1415VkDevice or VkInstance object is not a great map key. Instead the layer should
1416use the dispatch table pointer within the VkDevice or VkInstance since that
1417will be unique for a given VkInstance or VkDevice.
Jon Ashburnfe630fb2016-02-14 21:40:34 -07001418
Jon Ashburn2b2f6182016-04-04 16:37:37 -06001419##### Creating new dispatchable objects
Jon Ashburnfe630fb2016-02-14 21:40:34 -07001420Layers which create dispatchable objects take special care. Remember that loader
1421trampoline code normally fills in the dispatch table pointer in the newly
1422created object. Thus, the layer must fill in the dispatch table pointer if the
Jon Ashburn859c7fb2016-03-02 17:26:31 -07001423loader trampoline will not do so. Common cases where a layer (or ICD) may create a
Courtney Goeltzenleuchter7221a5a2016-02-15 14:59:37 -07001424dispatchable object without loader trampoline code is as follows:
Jon Ashburnfe630fb2016-02-14 21:40:34 -07001425- object wrapping layers that wrap dispatchable objects
1426- layers which add extensions that create dispatchable objects
1427- layers which insert extra Vulkan commands in the stream of commands they
1428intercept from the application
Jon Ashburn859c7fb2016-03-02 17:26:31 -07001429- ICDs which add extensions that create dispatchable objects
1430
Jon Ashburn2b2f6182016-04-04 16:37:37 -06001431The Windows/Linux loader provides a callback that can be used for initializing
1432a dispatchable object. The callback is passed as an extension structure via the
1433pNext field in VkInstanceCreateInfo and VkDeviceCreateInfo. The callback prototype
1434is defined as follows for instance and device callbacks respectively (see vk_layer.h):
1435```
1436VKAPI_ATTR VkResult VKAPI_CALL vkSetInstanceLoaderData(VkInstance instance, void *object);
1437VKAPI_ATTR VkResult VKAPI_CALL vkSetDeviceLoaderData)(VkDevice device, void *object);
1438```
1439To obtain these callbacks the layer must search through the list of structures
1440pointed to by the "pNext" field in the VkInstanceCreateInfo and VkDeviceCreateInfo parameters to find any callback structures inserted by the loader. The salient details are as follows:
1441- For CreateInstance the callback structure pointed to by "pNext" is VkLayerInstanceCreateInfo as defined in vk_layer.h.
1442- A "sType" field in of VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO within VkInstanceCreateInfo parameter indicates a loader structure.
1443- Within VkLayerInstanceCreateInfo, the "function" field indicates how the union field "u" should be interpreted.
1444- A "function" equal to VK_LOADER_DATA_CALLBACK indicates the "u" field will contain the callback in "pfnSetInstanceLoaderData".
1445- For CreateDevice the callback structure pointed to by "pNext" is VkLayerDeviceCreateInfo as defined in include/vulkan/vk_layer.h.
1446- A "sType" field in of VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO within VkDeviceCreateInfo parameter indicates a loader structure.
1447- Within VkLayerDeviceCreateInfo, the "function" field indicates how the union field "u" should be interpreted.
1448- A "function" equal to VK_LOADER_DATA_CALLBACK indicates the "u" field will contain the callback in "pfnSetDeviceLoaderData".
1449
1450Alternatively, if an older loader is being used that doesn't provide these callbacks, the layer may manually initialize the newly created dispatchable object.
Jon Ashburn859c7fb2016-03-02 17:26:31 -07001451To fill in the dispatch table pointer in newly created dispatchable object,
1452the layer should copy the dispatch pointer, which is always the first entry in the structure, from an existing parent object of the same level (instance versus
1453device). For example, if there is a newly created VkCommandBuffer object, then the dispatch pointer from the VkDevice object, which is the parent of the VkCommandBuffer object, should be copied into the newly created object.
Jon Ashburnc2972682016-02-08 15:42:01 -07001454