15db71995Sopenharmony_ci<!-- markdownlint-disable MD041 --> 25db71995Sopenharmony_ci[![Khronos Vulkan][1]][2] 35db71995Sopenharmony_ci 45db71995Sopenharmony_ci[1]: https://vulkan.lunarg.com/img/Vulkan_100px_Dec16.png "https://www.khronos.org/vulkan/" 55db71995Sopenharmony_ci[2]: https://www.khronos.org/vulkan/ 65db71995Sopenharmony_ci 75db71995Sopenharmony_ci# Driver interface to the Vulkan Loader <!-- omit from toc --> 85db71995Sopenharmony_ci[![Creative Commons][3]][4] 95db71995Sopenharmony_ci 105db71995Sopenharmony_ci<!-- Copyright © 2015-2023 LunarG, Inc. --> 115db71995Sopenharmony_ci 125db71995Sopenharmony_ci[3]: https://i.creativecommons.org/l/by-nd/4.0/88x31.png "Creative Commons License" 135db71995Sopenharmony_ci[4]: https://creativecommons.org/licenses/by-nd/4.0/ 145db71995Sopenharmony_ci 155db71995Sopenharmony_ci 165db71995Sopenharmony_ci## Table of Contents <!-- omit from toc --> 175db71995Sopenharmony_ci 185db71995Sopenharmony_ci- [Overview](#overview) 195db71995Sopenharmony_ci- [Driver Discovery](#driver-discovery) 205db71995Sopenharmony_ci - [Overriding the Default Driver Discovery](#overriding-the-default-driver-discovery) 215db71995Sopenharmony_ci - [Additional Driver Discovery](#additional-driver-discovery) 225db71995Sopenharmony_ci - [Driver Filtering](#driver-filtering) 235db71995Sopenharmony_ci - [Driver Select Filtering](#driver-select-filtering) 245db71995Sopenharmony_ci - [Driver Disable Filtering](#driver-disable-filtering) 255db71995Sopenharmony_ci - [Exception for Elevated Privileges](#exception-for-elevated-privileges) 265db71995Sopenharmony_ci - [Examples](#examples) 275db71995Sopenharmony_ci - [On Windows](#on-windows) 285db71995Sopenharmony_ci - [On Linux](#on-linux) 295db71995Sopenharmony_ci - [On macOS](#on-macos) 305db71995Sopenharmony_ci - [Driver Manifest File Usage](#driver-manifest-file-usage) 315db71995Sopenharmony_ci - [Driver Discovery on Windows](#driver-discovery-on-windows) 325db71995Sopenharmony_ci - [Driver Discovery on Linux](#driver-discovery-on-linux) 335db71995Sopenharmony_ci - [Example Linux Driver Search Path](#example-linux-driver-search-path) 345db71995Sopenharmony_ci - [Driver Discovery on Fuchsia](#driver-discovery-on-fuchsia) 355db71995Sopenharmony_ci - [Driver Discovery on macOS](#driver-discovery-on-macos) 365db71995Sopenharmony_ci - [Example macOS Driver Search Path](#example-macos-driver-search-path) 375db71995Sopenharmony_ci - [Additional Settings For Driver Debugging](#additional-settings-for-driver-debugging) 385db71995Sopenharmony_ci - [Driver Discovery using the`VK_LUNARG_direct_driver_loading` extension](#driver-discovery-using-thevk_lunarg_direct_driver_loading-extension) 395db71995Sopenharmony_ci - [How to use `VK_LUNARG_direct_driver_loading`](#how-to-use-vk_lunarg_direct_driver_loading) 405db71995Sopenharmony_ci - [Interactions with other driver discovery mechanisms](#interactions-with-other-driver-discovery-mechanisms) 415db71995Sopenharmony_ci - [Limitations of `VK_LUNARG_direct_driver_loading`](#limitations-of-vk_lunarg_direct_driver_loading) 425db71995Sopenharmony_ci - [Using Pre-Production ICDs or Software Drivers](#using-pre-production-icds-or-software-drivers) 435db71995Sopenharmony_ci - [Driver Discovery on Android](#driver-discovery-on-android) 445db71995Sopenharmony_ci- [Driver Manifest File Format](#driver-manifest-file-format) 455db71995Sopenharmony_ci - [Driver Manifest File Versions](#driver-manifest-file-versions) 465db71995Sopenharmony_ci - [Driver Manifest File Version 1.0.0](#driver-manifest-file-version-100) 475db71995Sopenharmony_ci - [Driver Manifest File Version 1.0.1](#driver-manifest-file-version-101) 485db71995Sopenharmony_ci- [Driver Vulkan Entry Point Discovery](#driver-vulkan-entry-point-discovery) 495db71995Sopenharmony_ci- [Driver API Version](#driver-api-version) 505db71995Sopenharmony_ci- [Mixed Driver Instance Extension Support](#mixed-driver-instance-extension-support) 515db71995Sopenharmony_ci - [Filtering Out Instance Extension Names](#filtering-out-instance-extension-names) 525db71995Sopenharmony_ci - [Loader Instance Extension Emulation Support](#loader-instance-extension-emulation-support) 535db71995Sopenharmony_ci- [Driver Unknown Physical Device Extensions](#driver-unknown-physical-device-extensions) 545db71995Sopenharmony_ci - [Reason for adding `vk_icdGetPhysicalDeviceProcAddr`](#reason-for-adding-vk_icdgetphysicaldeviceprocaddr) 555db71995Sopenharmony_ci- [Physical Device Sorting](#physical-device-sorting) 565db71995Sopenharmony_ci- [Driver Dispatchable Object Creation](#driver-dispatchable-object-creation) 575db71995Sopenharmony_ci- [Handling KHR Surface Objects in WSI Extensions](#handling-khr-surface-objects-in-wsi-extensions) 585db71995Sopenharmony_ci- [Loader and Driver Interface Negotiation](#loader-and-driver-interface-negotiation) 595db71995Sopenharmony_ci - [Windows, Linux and macOS Driver Negotiation](#windows-linux-and-macos-driver-negotiation) 605db71995Sopenharmony_ci - [Version Negotiation Between the Loader and Drivers](#version-negotiation-between-the-loader-and-drivers) 615db71995Sopenharmony_ci - [Interfacing With Legacy Drivers or Loaders](#interfacing-with-legacy-drivers-or-loaders) 625db71995Sopenharmony_ci - [Loader and Driver Interface Version 7 Requirements](#loader-and-driver-interface-version-7-requirements) 635db71995Sopenharmony_ci - [Loader and Driver Interface Version 6 Requirements](#loader-and-driver-interface-version-6-requirements) 645db71995Sopenharmony_ci - [Loader and Driver Interface Version 5 Requirements](#loader-and-driver-interface-version-5-requirements) 655db71995Sopenharmony_ci - [Loader and Driver Interface Version 4 Requirements](#loader-and-driver-interface-version-4-requirements) 665db71995Sopenharmony_ci - [Loader and Driver Interface Version 3 Requirements](#loader-and-driver-interface-version-3-requirements) 675db71995Sopenharmony_ci - [Loader and Driver Interface Version 2 Requirements](#loader-and-driver-interface-version-2-requirements) 685db71995Sopenharmony_ci - [Loader and Driver Interface Version 1 Requirements](#loader-and-driver-interface-version-1-requirements) 695db71995Sopenharmony_ci - [Loader and Driver Interface Version 0 Requirements](#loader-and-driver-interface-version-0-requirements) 705db71995Sopenharmony_ci - [Additional Interface Notes:](#additional-interface-notes) 715db71995Sopenharmony_ci - [Android Driver Negotiation](#android-driver-negotiation) 725db71995Sopenharmony_ci- [Loader implementation of VK\_KHR\_portability\_enumeration](#loader-implementation-of-vk_khr_portability_enumeration) 735db71995Sopenharmony_ci- [Loader and Driver Policy](#loader-and-driver-policy) 745db71995Sopenharmony_ci - [Number Format](#number-format) 755db71995Sopenharmony_ci - [Android Differences](#android-differences) 765db71995Sopenharmony_ci - [Requirements of Well-Behaved Drivers](#requirements-of-well-behaved-drivers) 775db71995Sopenharmony_ci - [Removed Driver Policies](#removed-driver-policies) 785db71995Sopenharmony_ci - [Requirements of a Well-Behaved Loader](#requirements-of-a-well-behaved-loader) 795db71995Sopenharmony_ci 805db71995Sopenharmony_ci 815db71995Sopenharmony_ci## Overview 825db71995Sopenharmony_ci 835db71995Sopenharmony_ciThis is the Driver-centric view of working with the Vulkan loader. 845db71995Sopenharmony_ciFor the complete overview of all sections of the loader, please refer to the 855db71995Sopenharmony_ci[LoaderInterfaceArchitecture.md](LoaderInterfaceArchitecture.md) file. 865db71995Sopenharmony_ci 875db71995Sopenharmony_ci**NOTE:** While many of the interfaces still use the "icd" sub-string to 885db71995Sopenharmony_ciidentify various behavior associated with drivers, this is purely 895db71995Sopenharmony_cihistorical and should not indicate that the implementing code do so through 905db71995Sopenharmony_cithe traditional ICD interface. 915db71995Sopenharmony_ciGranted, the majority of drivers to this date are ICD drivers 925db71995Sopenharmony_citargeting specific GPU hardware. 935db71995Sopenharmony_ci 945db71995Sopenharmony_ci## Driver Discovery 955db71995Sopenharmony_ci 965db71995Sopenharmony_ciVulkan allows multiple drivers each with one or more devices 975db71995Sopenharmony_ci(represented by a Vulkan `VkPhysicalDevice` object) to be used collectively. 985db71995Sopenharmony_ciThe loader is responsible for discovering available Vulkan drivers on 995db71995Sopenharmony_cithe system. 1005db71995Sopenharmony_ciGiven a list of available drivers, the loader can enumerate all the 1015db71995Sopenharmony_ciphysical devices available for an application and return this information to the 1025db71995Sopenharmony_ciapplication. 1035db71995Sopenharmony_ciThe process in which the loader discovers the available drivers on a 1045db71995Sopenharmony_cisystem is platform-dependent. 1055db71995Sopenharmony_ciWindows, Linux, Android, and macOS Driver Discovery details are listed 1065db71995Sopenharmony_cibelow. 1075db71995Sopenharmony_ci 1085db71995Sopenharmony_ci### Overriding the Default Driver Discovery 1095db71995Sopenharmony_ci 1105db71995Sopenharmony_ciThere may be times that a developer wishes to force the loader to use a specific 1115db71995Sopenharmony_ciDriver. 1125db71995Sopenharmony_ciThis could be for many reasons including using a beta driver, or forcing the 1135db71995Sopenharmony_ciloader to skip a problematic driver. 1145db71995Sopenharmony_ciIn order to support this, the loader can be forced to look at specific 1155db71995Sopenharmony_cidrivers with either the `VK_DRIVER_FILES` or the older `VK_ICD_FILENAMES` 1165db71995Sopenharmony_cienvironment variable. 1175db71995Sopenharmony_ciBoth these environment variables behave the same, but `VK_ICD_FILENAMES` 1185db71995Sopenharmony_cishould be considered deprecated. 1195db71995Sopenharmony_ciIf both `VK_DRIVER_FILES` and `VK_ICD_FILENAMES` environment variables are 1205db71995Sopenharmony_cipresent, then the newer `VK_DRIVER_FILES` will be used, and the values in 1215db71995Sopenharmony_ci`VK_ICD_FILENAMES` will be ignored. 1225db71995Sopenharmony_ci 1235db71995Sopenharmony_ciThe `VK_DRIVER_FILES` environment variable is a list of paths to Driver Manifest 1245db71995Sopenharmony_cifiles, containing the full path to the driver JSON Manifest file, and/or paths 1255db71995Sopenharmony_cito folders containing Driver Manifest files. 1265db71995Sopenharmony_ciThis list is colon-separated on Linux and macOS, and semicolon-separated on 1275db71995Sopenharmony_ciWindows. 1285db71995Sopenharmony_ciTypically, `VK_DRIVER_FILES` will only contain a full pathname to one info 1295db71995Sopenharmony_cifile for a single driver. 1305db71995Sopenharmony_ciA separator (colon or semicolon) is only used if more than one driver is needed. 1315db71995Sopenharmony_ci 1325db71995Sopenharmony_ci### Additional Driver Discovery 1335db71995Sopenharmony_ci 1345db71995Sopenharmony_ciThere may be times that a developer wishes to force the loader to use a specific 1355db71995Sopenharmony_ciDriver in addition to the standard drivers (without replacing the standard 1365db71995Sopenharmony_cisearch paths. 1375db71995Sopenharmony_ciThe `VK_ADD_DRIVER_FILES` environment variable can be used to add a list of 1385db71995Sopenharmony_ciDriver Manifest files, containing the full path to the driver JSON Manifest 1395db71995Sopenharmony_cifile, and/or paths to folders containing Driver Manifest files. 1405db71995Sopenharmony_ciThis list is colon-separated on Linux and macOS, and semicolon-separated on 1415db71995Sopenharmony_ciWindows. 1425db71995Sopenharmony_ciIt will be added prior to the standard driver search files. 1435db71995Sopenharmony_ciIf `VK_DRIVER_FILES` or `VK_ICD_FILENAMES` is present, then 1445db71995Sopenharmony_ci`VK_ADD_DRIVER_FILES` will not be used by the loader and any values will be 1455db71995Sopenharmony_ciignored. 1465db71995Sopenharmony_ci 1475db71995Sopenharmony_ci### Driver Filtering 1485db71995Sopenharmony_ci 1495db71995Sopenharmony_ci**NOTE:** This functionality is only available with Loaders built with version 1505db71995Sopenharmony_ci1.3.234 of the Vulkan headers and later. 1515db71995Sopenharmony_ci 1525db71995Sopenharmony_ciThe loader supports filter environment variables which can forcibly select and 1535db71995Sopenharmony_cidisable known drivers. 1545db71995Sopenharmony_ciKnown driver manifests are those files that are already found by the loader 1555db71995Sopenharmony_citaking into account default search paths and other environment variables (like 1565db71995Sopenharmony_ci`VK_ICD_FILENAMES` or `VK_ADD_DRIVER_FILES`). 1575db71995Sopenharmony_ci 1585db71995Sopenharmony_ciThe filter variables will be compared against the driver's manifest filename. 1595db71995Sopenharmony_ci 1605db71995Sopenharmony_ciThe filters must also follow the behaviors define in the 1615db71995Sopenharmony_ci[Filter Environment Variable Behaviors](LoaderInterfaceArchitecture.md#filter-environment-variable-behaviors) 1625db71995Sopenharmony_cisection of the [LoaderLayerInterface](LoaderLayerInterface.md) document. 1635db71995Sopenharmony_ci 1645db71995Sopenharmony_ci#### Driver Select Filtering 1655db71995Sopenharmony_ci 1665db71995Sopenharmony_ciThe driver select environment variable `VK_LOADER_DRIVERS_SELECT` is a 1675db71995Sopenharmony_cicomma-delimited list of globs to search for in known drivers. 1685db71995Sopenharmony_ci 1695db71995Sopenharmony_ciIf a driver is not selected when using the `VK_LOADER_DRIVERS_SELECT` filter, 1705db71995Sopenharmony_ciand loader logging is set to emit either warnings or driver messages, then a 1715db71995Sopenharmony_cimessage will show for each driver that has been ignored. 1725db71995Sopenharmony_ciThis message will look like the following: 1735db71995Sopenharmony_ci 1745db71995Sopenharmony_ci``` 1755db71995Sopenharmony_ciWARNING | DRIVER: Driver "intel_icd.x86_64.json" ignored because not selected by env var 'VK_LOADER_DRIVERS_SELECT' 1765db71995Sopenharmony_ci``` 1775db71995Sopenharmony_ci 1785db71995Sopenharmony_ciIf no drivers are found with a manifest filename that matches any of the 1795db71995Sopenharmony_ciprovided globs, then no driver is enabled and may result in failures for 1805db71995Sopenharmony_ciany Vulkan application that is run. 1815db71995Sopenharmony_ci 1825db71995Sopenharmony_ci#### Driver Disable Filtering 1835db71995Sopenharmony_ci 1845db71995Sopenharmony_ciThe driver disable environment variable `VK_LOADER_DRIVERS_DISABLE` is a 1855db71995Sopenharmony_cicomma-delimited list of globs to search for in known drivers. 1865db71995Sopenharmony_ci 1875db71995Sopenharmony_ciWhen a driver is disabled using the `VK_LOADER_DRIVERS_DISABLE` filter, and 1885db71995Sopenharmony_ciloader logging is set to emit either warnings or driver messages, then a message 1895db71995Sopenharmony_ciwill show for each driver that has been forcibly disabled. 1905db71995Sopenharmony_ciThis message will look like the following: 1915db71995Sopenharmony_ci 1925db71995Sopenharmony_ci``` 1935db71995Sopenharmony_ciWARNING | DRIVER: Driver "radeon_icd.x86_64.json" ignored because it was disabled by env var 'VK_LOADER_DRIVERS_DISABLE' 1945db71995Sopenharmony_ci``` 1955db71995Sopenharmony_ci 1965db71995Sopenharmony_ciIf no drivers are found with a manifest filename that matches any of the 1975db71995Sopenharmony_ciprovided globs, then no driver is disabled. 1985db71995Sopenharmony_ci 1995db71995Sopenharmony_ci### Exception for Elevated Privileges 2005db71995Sopenharmony_ci 2015db71995Sopenharmony_ciFor security reasons, `VK_ICD_FILENAMES`, `VK_DRIVER_FILES`, and 2025db71995Sopenharmony_ci`VK_ADD_DRIVER_FILES` are all ignored if running the Vulkan application 2035db71995Sopenharmony_ciwith elevated privileges. 2045db71995Sopenharmony_ciThis is because they may insert new libraries into the executable process that 2055db71995Sopenharmony_ciare not normally found by the loader. 2065db71995Sopenharmony_ciBecause of this, these environment variables can only be used for applications 2075db71995Sopenharmony_cithat do not use elevated privileges. 2085db71995Sopenharmony_ci 2095db71995Sopenharmony_ciFor more information see 2105db71995Sopenharmony_ci[Elevated Privilege Caveats](LoaderInterfaceArchitecture.md#elevated-privilege-caveats) 2115db71995Sopenharmony_ciin the top-level 2125db71995Sopenharmony_ci[LoaderInterfaceArchitecture.md](LoaderInterfaceArchitecture.md) document. 2135db71995Sopenharmony_ci 2145db71995Sopenharmony_ci#### Examples 2155db71995Sopenharmony_ci 2165db71995Sopenharmony_ciIn order to use the setting, simply set it to a properly delimited list of 2175db71995Sopenharmony_ciDriver Manifest files. 2185db71995Sopenharmony_ciIn this case, please provide the global path to these files to reduce issues. 2195db71995Sopenharmony_ci 2205db71995Sopenharmony_ciFor example: 2215db71995Sopenharmony_ci 2225db71995Sopenharmony_ci##### On Windows 2235db71995Sopenharmony_ci 2245db71995Sopenharmony_ci``` 2255db71995Sopenharmony_ciset VK_DRIVER_FILES=\windows\system32\nv-vk64.json 2265db71995Sopenharmony_ci``` 2275db71995Sopenharmony_ci 2285db71995Sopenharmony_ciThis is an example which is using the `VK_DRIVER_FILES` override on Windows to 2295db71995Sopenharmony_cipoint to the Nvidia Vulkan Driver's Manifest file. 2305db71995Sopenharmony_ci 2315db71995Sopenharmony_ci``` 2325db71995Sopenharmony_ciset VK_ADD_DRIVER_FILES=\windows\system32\nv-vk64.json 2335db71995Sopenharmony_ci``` 2345db71995Sopenharmony_ci 2355db71995Sopenharmony_ciThis is an example which is using the `VK_ADD_DRIVER_FILES` on Windows to 2365db71995Sopenharmony_cipoint to the Nvidia Vulkan Driver's Manifest file which will be loaded first 2375db71995Sopenharmony_cibefore all other drivers. 2385db71995Sopenharmony_ci 2395db71995Sopenharmony_ci##### On Linux 2405db71995Sopenharmony_ci 2415db71995Sopenharmony_ci``` 2425db71995Sopenharmony_ciexport VK_DRIVER_FILES=/home/user/dev/mesa/share/vulkan/icd.d/intel_icd.x86_64.json 2435db71995Sopenharmony_ci``` 2445db71995Sopenharmony_ci 2455db71995Sopenharmony_ciThis is an example which is using the `VK_DRIVER_FILES` override on Linux to 2465db71995Sopenharmony_cipoint to the Intel Mesa Driver's Manifest file. 2475db71995Sopenharmony_ci 2485db71995Sopenharmony_ci``` 2495db71995Sopenharmony_ciexport VK_ADD_DRIVER_FILES=/home/user/dev/mesa/share/vulkan/icd.d/intel_icd.x86_64.json 2505db71995Sopenharmony_ci``` 2515db71995Sopenharmony_ci 2525db71995Sopenharmony_ciThis is an example which is using the `VK_ADD_DRIVER_FILES` on Linux to 2535db71995Sopenharmony_cipoint to the Intel Mesa Driver's Manifest file which will be loaded first 2545db71995Sopenharmony_cibefore all other drivers. 2555db71995Sopenharmony_ci 2565db71995Sopenharmony_ci##### On macOS 2575db71995Sopenharmony_ci 2585db71995Sopenharmony_ci``` 2595db71995Sopenharmony_ciexport VK_DRIVER_FILES=/home/user/MoltenVK/Package/Latest/MoltenVK/macOS/MoltenVK_icd.json 2605db71995Sopenharmony_ci``` 2615db71995Sopenharmony_ci 2625db71995Sopenharmony_ciThis is an example which is using the `VK_DRIVER_FILES` override on macOS to 2635db71995Sopenharmony_cipoint to an installation and build of the MoltenVK GitHub repository that 2645db71995Sopenharmony_cicontains the MoltenVK driver. 2655db71995Sopenharmony_ci 2665db71995Sopenharmony_ciSee the 2675db71995Sopenharmony_ci[Table of Debug Environment Variables](LoaderInterfaceArchitecture.md#table-of-debug-environment-variables) 2685db71995Sopenharmony_ciin the [LoaderInterfaceArchitecture.md document](LoaderInterfaceArchitecture.md) 2695db71995Sopenharmony_cifor more details 2705db71995Sopenharmony_ci 2715db71995Sopenharmony_ci 2725db71995Sopenharmony_ci### Driver Manifest File Usage 2735db71995Sopenharmony_ci 2745db71995Sopenharmony_ciAs with layers, on Windows, Linux and macOS systems, JSON-formatted manifest 2755db71995Sopenharmony_cifiles are used to store driver information. 2765db71995Sopenharmony_ciIn order to find system-installed drivers, the Vulkan loader will read the JSON 2775db71995Sopenharmony_cifiles to identify the names and attributes of each driver. 2785db71995Sopenharmony_ciNotice that Driver Manifest files are much simpler than the corresponding 2795db71995Sopenharmony_cilayer Manifest files. 2805db71995Sopenharmony_ci 2815db71995Sopenharmony_ciSee the 2825db71995Sopenharmony_ci[Current Driver Manifest File Format](#driver-manifest-file-format) 2835db71995Sopenharmony_cisection for more details. 2845db71995Sopenharmony_ci 2855db71995Sopenharmony_ci 2865db71995Sopenharmony_ci### Driver Discovery on Windows 2875db71995Sopenharmony_ci 2885db71995Sopenharmony_ciIn order to find available drivers (including installed ICDs), the 2895db71995Sopenharmony_ciloader scans through registry keys specific to Display Adapters and all Software 2905db71995Sopenharmony_ciComponents associated with these adapters for the locations of JSON manifest 2915db71995Sopenharmony_cifiles. 2925db71995Sopenharmony_ciThese keys are located in device keys created during driver installation and 2935db71995Sopenharmony_cicontain configuration information for base settings, including OpenGL and 2945db71995Sopenharmony_ciDirect3D locations. 2955db71995Sopenharmony_ci 2965db71995Sopenharmony_ciThe Device Adapter and Software Component key paths will be obtained by first 2975db71995Sopenharmony_cienumerating DXGI adapters. 2985db71995Sopenharmony_ciShould that fail it will use the PnP Configuration Manager API. 2995db71995Sopenharmony_ciThe `000X` key will be a numbered key, where each device is assigned a different 3005db71995Sopenharmony_cinumber. 3015db71995Sopenharmony_ci 3025db71995Sopenharmony_ci``` 3035db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Adapter GUID}\000X\VulkanDriverName 3045db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{SoftwareComponent GUID}\000X\VulkanDriverName 3055db71995Sopenharmony_ci``` 3065db71995Sopenharmony_ci 3075db71995Sopenharmony_ciIn addition, on 64-bit systems there may be another set of registry values, 3085db71995Sopenharmony_cilisted below. 3095db71995Sopenharmony_ciThese values record the locations of 32-bit layers on 64-bit operating systems, 3105db71995Sopenharmony_ciin the same way as the Windows-on-Windows functionality. 3115db71995Sopenharmony_ci 3125db71995Sopenharmony_ci``` 3135db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{Adapter GUID}\000X\VulkanDriverNameWow 3145db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Class\{SoftwareComponent GUID}\000X\VulkanDriverNameWow 3155db71995Sopenharmony_ci``` 3165db71995Sopenharmony_ci 3175db71995Sopenharmony_ciIf any of the above values exist and is of type `REG_SZ`, the loader will open 3185db71995Sopenharmony_cithe JSON manifest file specified by the key value. 3195db71995Sopenharmony_ciEach value must be a full absolute path to a JSON manifest file. 3205db71995Sopenharmony_ciThe values may also be of type `REG_MULTI_SZ`, in which case the value will be 3215db71995Sopenharmony_ciinterpreted as a list of paths to JSON manifest files. 3225db71995Sopenharmony_ci 3235db71995Sopenharmony_ciAdditionally, the Vulkan loader will scan the values in the following Windows 3245db71995Sopenharmony_ciregistry key: 3255db71995Sopenharmony_ci 3265db71995Sopenharmony_ci``` 3275db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers 3285db71995Sopenharmony_ci``` 3295db71995Sopenharmony_ci 3305db71995Sopenharmony_ciFor 32-bit applications on 64-bit Windows, the loader scan's the 32-bit 3315db71995Sopenharmony_ciregistry location: 3325db71995Sopenharmony_ci 3335db71995Sopenharmony_ci``` 3345db71995Sopenharmony_ciHKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Khronos\Vulkan\Drivers 3355db71995Sopenharmony_ci``` 3365db71995Sopenharmony_ci 3375db71995Sopenharmony_ciEvery driver in these locations should be given as a DWORD, with value 0, where 3385db71995Sopenharmony_cithe name of the value is the full path to a JSON manifest file. 3395db71995Sopenharmony_ciThe Vulkan loader will attempt to open each manifest file to obtain the 3405db71995Sopenharmony_ciinformation about a driver's shared library (".dll") file. 3415db71995Sopenharmony_ci 3425db71995Sopenharmony_ciFor example, let us assume the registry contains the following data: 3435db71995Sopenharmony_ci 3445db71995Sopenharmony_ci``` 3455db71995Sopenharmony_ci[HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\Vulkan\Drivers\] 3465db71995Sopenharmony_ci 3475db71995Sopenharmony_ci"C:\vendor a\vk_vendor_a.json"=dword:00000000 3485db71995Sopenharmony_ci"C:\windows\system32\vendor_b_vk.json"=dword:00000001 3495db71995Sopenharmony_ci"C:\windows\system32\vendor_c_icd.json"=dword:00000000 3505db71995Sopenharmony_ci``` 3515db71995Sopenharmony_ci 3525db71995Sopenharmony_ciIn this case, the loader will step through each entry, and check the value. 3535db71995Sopenharmony_ciIf the value is 0, then the loader will attempt to load the file. 3545db71995Sopenharmony_ciIn this case, the loader will open the first and last listings, but not the 3555db71995Sopenharmony_cimiddle. 3565db71995Sopenharmony_ciThis is because the value of 1 for vendor_b_vk.json disables the driver. 3575db71995Sopenharmony_ci 3585db71995Sopenharmony_ciAdditionally, the Vulkan loader will scan the system for well-known Windows 3595db71995Sopenharmony_ciAppX/MSIX packages. 3605db71995Sopenharmony_ciIf a package is found, the loader will scan the root directory of this installed 3615db71995Sopenharmony_cipackage for JSON manifest files. At this time, the only package that is known is 3625db71995Sopenharmony_ciMicrosoft's 3635db71995Sopenharmony_ci[OpenCL™ and OpenGL® Compatibility Pack](https://apps.microsoft.com/store/detail/9NQPSL29BFFF?hl=en-us&gl=US). 3645db71995Sopenharmony_ci 3655db71995Sopenharmony_ciThe Vulkan loader will open each enabled manifest file found to obtain the name 3665db71995Sopenharmony_cior pathname of a driver's shared library (".DLL") file. 3675db71995Sopenharmony_ci 3685db71995Sopenharmony_ciDrivers should use the registry locations from the PnP Configuration 3695db71995Sopenharmony_ciManager wherever practical. 3705db71995Sopenharmony_ciTypically, this is most important for drivers, and the location clearly 3715db71995Sopenharmony_cities the driver to a given device. 3725db71995Sopenharmony_ciThe `SOFTWARE\Khronos\Vulkan\Drivers` location is the older method for locating 3735db71995Sopenharmony_cidrivers, but is the primary location for software based drivers. 3745db71995Sopenharmony_ci 3755db71995Sopenharmony_ciSee the 3765db71995Sopenharmony_ci[Driver Manifest File Format](#driver-manifest-file-format) 3775db71995Sopenharmony_cisection for more details. 3785db71995Sopenharmony_ci 3795db71995Sopenharmony_ci 3805db71995Sopenharmony_ci### Driver Discovery on Linux 3815db71995Sopenharmony_ci 3825db71995Sopenharmony_ciOn Linux, the Vulkan loader will scan for Driver Manifest files using 3835db71995Sopenharmony_cienvironment variables or corresponding fallback values if the corresponding 3845db71995Sopenharmony_cienvironment variable is not defined: 3855db71995Sopenharmony_ci 3865db71995Sopenharmony_ci<table style="width:100%"> 3875db71995Sopenharmony_ci <tr> 3885db71995Sopenharmony_ci <th>Search Order</th> 3895db71995Sopenharmony_ci <th>Directory/Environment Variable</th> 3905db71995Sopenharmony_ci <th>Fallback</th> 3915db71995Sopenharmony_ci <th>Additional Notes</th> 3925db71995Sopenharmony_ci </tr> 3935db71995Sopenharmony_ci <tr> 3945db71995Sopenharmony_ci <td>1</td> 3955db71995Sopenharmony_ci <td>$XDG_CONFIG_HOME</td> 3965db71995Sopenharmony_ci <td>$HOME/.config</td> 3975db71995Sopenharmony_ci <td><b>This path is ignored when running with elevated privileges such as 3985db71995Sopenharmony_ci setuid, setgid, or filesystem capabilities</b>.<br/> 3995db71995Sopenharmony_ci This is done because under these scenarios it is not safe to trust 4005db71995Sopenharmony_ci that the environment variables are non-malicious.<br/> 4015db71995Sopenharmony_ci See <a href="LoaderInterfaceArchitecture.md#elevated-privilege-caveats"> 4025db71995Sopenharmony_ci Elevated Privilege Caveats</a> for more information. 4035db71995Sopenharmony_ci </td> 4045db71995Sopenharmony_ci </tr> 4055db71995Sopenharmony_ci <tr> 4065db71995Sopenharmony_ci <td>1</td> 4075db71995Sopenharmony_ci <td>$XDG_CONFIG_DIRS</td> 4085db71995Sopenharmony_ci <td>/etc/xdg</td> 4095db71995Sopenharmony_ci <td></td> 4105db71995Sopenharmony_ci </tr> 4115db71995Sopenharmony_ci <tr> 4125db71995Sopenharmony_ci <td>2</td> 4135db71995Sopenharmony_ci <td>SYSCONFDIR</td> 4145db71995Sopenharmony_ci <td>/etc</td> 4155db71995Sopenharmony_ci <td>Compile-time option set to possible location of drivers 4165db71995Sopenharmony_ci installed from non-Linux-distribution-provided packages. 4175db71995Sopenharmony_ci </td> 4185db71995Sopenharmony_ci </tr> 4195db71995Sopenharmony_ci <tr> 4205db71995Sopenharmony_ci <td>3</td> 4215db71995Sopenharmony_ci <td>EXTRASYSCONFDIR</td> 4225db71995Sopenharmony_ci <td>/etc</td> 4235db71995Sopenharmony_ci <td>Compile-time option set to possible location of drivers 4245db71995Sopenharmony_ci installed from non-Linux-distribution-provided packages. 4255db71995Sopenharmony_ci Typically only set if SYSCONFDIR is set to something other than /etc 4265db71995Sopenharmony_ci </td> 4275db71995Sopenharmony_ci </tr> 4285db71995Sopenharmony_ci <tr> 4295db71995Sopenharmony_ci <td>4</td> 4305db71995Sopenharmony_ci <td>$XDG_DATA_HOME</td> 4315db71995Sopenharmony_ci <td>$HOME/.local/share</td> 4325db71995Sopenharmony_ci <td><b>This path is ignored when running with elevated privileges such as 4335db71995Sopenharmony_ci setuid, setgid, or filesystem capabilities</b>.<br/> 4345db71995Sopenharmony_ci This is done because under these scenarios it is not safe to trust 4355db71995Sopenharmony_ci that the environment variables are non-malicious.<br/> 4365db71995Sopenharmony_ci See <a href="LoaderInterfaceArchitecture.md#elevated-privilege-caveats"> 4375db71995Sopenharmony_ci Elevated Privilege Caveats</a> for more information. 4385db71995Sopenharmony_ci </td> 4395db71995Sopenharmony_ci </tr> 4405db71995Sopenharmony_ci <tr> 4415db71995Sopenharmony_ci <td>5</td> 4425db71995Sopenharmony_ci <td>$XDG_DATA_DIRS</td> 4435db71995Sopenharmony_ci <td>/usr/local/share/:/usr/share/</td> 4445db71995Sopenharmony_ci <td></td> 4455db71995Sopenharmony_ci </tr> 4465db71995Sopenharmony_ci</table> 4475db71995Sopenharmony_ci 4485db71995Sopenharmony_ciThe directory lists are concatenated together using the standard platform path 4495db71995Sopenharmony_ciseparator (:). 4505db71995Sopenharmony_ciThe loader then selects each path, and applies the "/vulkan/icd.d" suffix onto 4515db71995Sopenharmony_cieach and looks in that specific folder for manifest files. 4525db71995Sopenharmony_ci 4535db71995Sopenharmony_ciThe Vulkan loader will open each manifest file found to obtain the name or 4545db71995Sopenharmony_cipathname of a driver's shared library (".so") file. 4555db71995Sopenharmony_ci 4565db71995Sopenharmony_ci**NOTE** While the order of folders searched for manifest files is well 4575db71995Sopenharmony_cidefined, the order contents are read by the loader in each directory is 4585db71995Sopenharmony_ci[random due to the behavior of readdir](https://www.ibm.com/support/pages/order-directory-contents-returned-calls-readdir). 4595db71995Sopenharmony_ci 4605db71995Sopenharmony_ciSee the 4615db71995Sopenharmony_ci[Driver Manifest File Format](#driver-manifest-file-format) 4625db71995Sopenharmony_cisection for more details. 4635db71995Sopenharmony_ci 4645db71995Sopenharmony_ciIt is also important to note that while `VK_DRIVER_FILES` will point the loader 4655db71995Sopenharmony_cito finding the manifest files, it does not guarantee the library files mentioned 4665db71995Sopenharmony_ciby the manifest will immediately be found. 4675db71995Sopenharmony_ciOften, the Driver Manifest file will point to the library file using a 4685db71995Sopenharmony_cirelative or absolute path. 4695db71995Sopenharmony_ciWhen a relative or absolute path is used, the loader can typically find the 4705db71995Sopenharmony_cilibrary file without querying the operating system. 4715db71995Sopenharmony_ciHowever, if a library is listed only by name, the loader may not find it, 4725db71995Sopenharmony_ciunless the driver is installed placing the library in an operating system 4735db71995Sopenharmony_cisearchable default location. 4745db71995Sopenharmony_ciIf problems occur finding a library file associated with a driver, try updating 4755db71995Sopenharmony_cithe `LD_LIBRARY_PATH` environment variable to point at the location of the 4765db71995Sopenharmony_cicorresponding `.so` file. 4775db71995Sopenharmony_ci 4785db71995Sopenharmony_ci 4795db71995Sopenharmony_ci#### Example Linux Driver Search Path 4805db71995Sopenharmony_ci 4815db71995Sopenharmony_ciFor a fictional user "me" the Driver Manifest search path might look 4825db71995Sopenharmony_cilike the following: 4835db71995Sopenharmony_ci 4845db71995Sopenharmony_ci``` 4855db71995Sopenharmony_ci /home/me/.config/vulkan/icd.d 4865db71995Sopenharmony_ci /etc/xdg/vulkan/icd.d 4875db71995Sopenharmony_ci /usr/local/etc/vulkan/icd.d 4885db71995Sopenharmony_ci /etc/vulkan/icd.d 4895db71995Sopenharmony_ci /home/me/.local/share/vulkan/icd.d 4905db71995Sopenharmony_ci /usr/local/share/vulkan/icd.d 4915db71995Sopenharmony_ci /usr/share/vulkan/icd.d 4925db71995Sopenharmony_ci``` 4935db71995Sopenharmony_ci 4945db71995Sopenharmony_ci 4955db71995Sopenharmony_ci### Driver Discovery on Fuchsia 4965db71995Sopenharmony_ci 4975db71995Sopenharmony_ciOn Fuchsia, the Vulkan loader will scan for manifest files using environment 4985db71995Sopenharmony_civariables or corresponding fallback values if the corresponding environment 4995db71995Sopenharmony_civariable is not defined in the same way as 5005db71995Sopenharmony_ci[Linux](#linux-driver-discovery). 5015db71995Sopenharmony_ciThe **only** difference is that Fuchsia does not allow fallback values for 5025db71995Sopenharmony_ci*$XDG_DATA_DIRS* or *$XDG_HOME_DIRS*. 5035db71995Sopenharmony_ci 5045db71995Sopenharmony_ci 5055db71995Sopenharmony_ci### Driver Discovery on macOS 5065db71995Sopenharmony_ci 5075db71995Sopenharmony_ciOn macOS, the Vulkan loader will scan for Driver Manifest files using 5085db71995Sopenharmony_cithe application resource folder as well as environment variables or 5095db71995Sopenharmony_cicorresponding fallback values if the corresponding environment variable is not 5105db71995Sopenharmony_cidefined. 5115db71995Sopenharmony_ciThe order is similar to the search path on Linux with the exception that 5125db71995Sopenharmony_cithe application's bundle resources are searched first: 5135db71995Sopenharmony_ci`(bundle)/Contents/Resources/`. 5145db71995Sopenharmony_ci 5155db71995Sopenharmony_ciSystem installed drivers will be ignored if drivers are found inside of the app 5165db71995Sopenharmony_cibundle. 5175db71995Sopenharmony_ciThis is because there is not a standard mechanism in which to distinguish drivers 5185db71995Sopenharmony_cithat happen to be duplicates. 5195db71995Sopenharmony_ciFor example, MoltenVK is commonly placed inside application bundles. 5205db71995Sopenharmony_ciIf there exists a system installed MoltenVK, the loader will load both the app 5215db71995Sopenharmony_cibundled and the system installed MoltenVK, leading to potential issues or crashes. 5225db71995Sopenharmony_ciDrivers found through environment variables, such as `VK_DRIVER_FILES`, will be 5235db71995Sopenharmony_ciused regardless of whether there are bundled drivers present or not. 5245db71995Sopenharmony_ci 5255db71995Sopenharmony_ci 5265db71995Sopenharmony_ci#### Example macOS Driver Search Path 5275db71995Sopenharmony_ci 5285db71995Sopenharmony_ciFor a fictional user "Me" the Driver Manifest search path might look 5295db71995Sopenharmony_cilike the following: 5305db71995Sopenharmony_ci 5315db71995Sopenharmony_ci``` 5325db71995Sopenharmony_ci <bundle>/Contents/Resources/vulkan/icd.d 5335db71995Sopenharmony_ci /Users/Me/.config/vulkan/icd.d 5345db71995Sopenharmony_ci /etc/xdg/vulkan/icd.d 5355db71995Sopenharmony_ci /usr/local/etc/vulkan/icd.d 5365db71995Sopenharmony_ci /etc/vulkan/icd.d 5375db71995Sopenharmony_ci /Users/Me/.local/share/vulkan/icd.d 5385db71995Sopenharmony_ci /usr/local/share/vulkan/icd.d 5395db71995Sopenharmony_ci /usr/share/vulkan/icd.d 5405db71995Sopenharmony_ci``` 5415db71995Sopenharmony_ci 5425db71995Sopenharmony_ci 5435db71995Sopenharmony_ci#### Additional Settings For Driver Debugging 5445db71995Sopenharmony_ci 5455db71995Sopenharmony_ciSometimes, the driver may encounter issues when loading. 5465db71995Sopenharmony_ciA useful option may be to enable the `LD_BIND_NOW` environment variable 5475db71995Sopenharmony_cito debug the issue. 5485db71995Sopenharmony_ciThis forces every dynamic library's symbols to be fully resolved on load. 5495db71995Sopenharmony_ciIf there is a problem with a driver missing symbols on the current system, this 5505db71995Sopenharmony_ciwill expose it and cause the Vulkan loader to fail on loading the driver. 5515db71995Sopenharmony_ciIt is recommended that `LD_BIND_NOW` along with `VK_LOADER_DEBUG=error,warn` 5525db71995Sopenharmony_cito expose any issues. 5535db71995Sopenharmony_ci 5545db71995Sopenharmony_ci### Driver Discovery using the`VK_LUNARG_direct_driver_loading` extension 5555db71995Sopenharmony_ci 5565db71995Sopenharmony_ciThe `VK_LUNARG_direct_driver_loading` extension allows for applications to 5575db71995Sopenharmony_ciprovide a driver or drivers to the Loader during vkCreateInstance. 5585db71995Sopenharmony_ciThis allows drivers to be included with an application without requiring 5595db71995Sopenharmony_ciinstallation and is capable of being used in any execution environment, such as 5605db71995Sopenharmony_cia process running with elevated privileges. 5615db71995Sopenharmony_ci 5625db71995Sopenharmony_ciWhen calling `vkEnumeratePhysicalDevices` with the 5635db71995Sopenharmony_ci`VK_LUNARG_direct_driver_loading` extension enabled, the `VkPhysicalDevice`s 5645db71995Sopenharmony_cifrom system installed drivers and environment variable specified drivers will 5655db71995Sopenharmony_ciappear before any `VkPhysicalDevice`s that originate from drivers from the 5665db71995Sopenharmony_ci`VkDirectDriverLoadingListLUNARG::pDrivers` list. 5675db71995Sopenharmony_ci 5685db71995Sopenharmony_ci#### How to use `VK_LUNARG_direct_driver_loading` 5695db71995Sopenharmony_ci 5705db71995Sopenharmony_ciTo use this extension, it must first be enabled on the VkInstance. 5715db71995Sopenharmony_ciThis requires enabling the `VK_LUNARG_direct_driver_loading` extension through 5725db71995Sopenharmony_cithe `enabledExtensionCount` and `ppEnabledExtensionNames`members of 5735db71995Sopenharmony_ci`VkInstanceCreateInfo`. 5745db71995Sopenharmony_ci 5755db71995Sopenharmony_ci```c 5765db71995Sopenharmony_ciconst char* extensions[] = {VK_LUNARG_DIRECT_DRIVER_LOADING_EXTENSION_NAME, <other extensions>}; 5775db71995Sopenharmony_ciVkInstanceCreateInfo instance_create_info = {}; 5785db71995Sopenharmony_ciinstance_create_info.enabledExtensionCount = <size of extension list>; 5795db71995Sopenharmony_ciinstance_create_info.ppEnabledExtensionNames = extensions; 5805db71995Sopenharmony_ci``` 5815db71995Sopenharmony_ci 5825db71995Sopenharmony_ciThe `VkDirectDriverLoadingInfoLUNARG` structure contains a 5835db71995Sopenharmony_ci`VkDirectDriverLoadingFlagsLUNARG` member (reserved for future use) and a 5845db71995Sopenharmony_ci`PFN_vkGetInstanceProcAddrLUNARG` member which provides the loader with the 5855db71995Sopenharmony_cifunction pointer for the driver's `vkGetInstanceProcAddr`. 5865db71995Sopenharmony_ci 5875db71995Sopenharmony_ciThe `VkDirectDriverLoadingListLUNARG` structure contains a count and pointer 5885db71995Sopenharmony_cimembers which provide the size of and pointer to an application provided array of 5895db71995Sopenharmony_ci`VkDirectDriverLoadingInfoLUNARG` structures. 5905db71995Sopenharmony_ci 5915db71995Sopenharmony_ciCreating those structures looks like the following 5925db71995Sopenharmony_ci```c 5935db71995Sopenharmony_ciVkDirectDriverLoadingInfoLUNARG direct_loading_info = {}; 5945db71995Sopenharmony_cidirect_loading_info.sType = VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_INFO_LUNARG 5955db71995Sopenharmony_cidirect_loading_info.pfnGetInstanceProcAddr = <put the PFN_vkGetInstanceProcAddr of the driver here> 5965db71995Sopenharmony_ci 5975db71995Sopenharmony_ciVkDirectDriverLoadingListLUNARG direct_driver_list = {}; 5985db71995Sopenharmony_cidirect_driver_list.sType = VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG; 5995db71995Sopenharmony_cidirect_driver_list.mode = VK_DIRECT_DRIVER_LOADING_MODE_INCLUSIVE_LUNARG; // or VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG 6005db71995Sopenharmony_cidirect_driver_list.driverCount = 1; 6015db71995Sopenharmony_cidirect_driver_list.pDrivers = &direct_loading_info; // can include multiple drivers here if so desired 6025db71995Sopenharmony_ci``` 6035db71995Sopenharmony_ci 6045db71995Sopenharmony_ciThe `VkDirectDriverLoadingListLUNARG` structure contains the enum 6055db71995Sopenharmony_ci`VkDirectDriverLoadingModeLUNARG`. 6065db71995Sopenharmony_ciThere are two modes: 6075db71995Sopenharmony_ci* `VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG` - specifies that the only drivers 6085db71995Sopenharmony_cito be loaded will come from the `VkDirectDriverLoadingListLUNARG` structure. 6095db71995Sopenharmony_ci* `VK_DIRECT_DRIVER_LOADING_MODE_INCLUSIVE_LUNARG` - specifies that drivers 6105db71995Sopenharmony_cifrom the `VkDirectDriverLoadingModeLUNARG` structure will be used in addition to 6115db71995Sopenharmony_ciany system installed drivers and environment variable specified drivers. 6125db71995Sopenharmony_ci 6135db71995Sopenharmony_ci 6145db71995Sopenharmony_ci 6155db71995Sopenharmony_ciThen, the `VkDirectDriverLoadingListLUNARG` structure *must* be appended to the 6165db71995Sopenharmony_ci`pNext` chain of `VkInstanceCreateInfo`. 6175db71995Sopenharmony_ci 6185db71995Sopenharmony_ci```c 6195db71995Sopenharmony_ciinstance_create_info.pNext = (const void*)&direct_driver_list; 6205db71995Sopenharmony_ci``` 6215db71995Sopenharmony_ci 6225db71995Sopenharmony_ciFinally, create the instance like normal. 6235db71995Sopenharmony_ci 6245db71995Sopenharmony_ci#### Interactions with other driver discovery mechanisms 6255db71995Sopenharmony_ci 6265db71995Sopenharmony_ciIf the `VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG` mode is specified in the 6275db71995Sopenharmony_ci`VkDirectDriverLoadingListLUNARG` structure, then no system installed drivers 6285db71995Sopenharmony_ciare loaded. 6295db71995Sopenharmony_ciThis applies equally to all platforms. 6305db71995Sopenharmony_ciAdditionally, the following environment variables have no effect: 6315db71995Sopenharmony_ci 6325db71995Sopenharmony_ci* `VK_DRIVER_FILES` 6335db71995Sopenharmony_ci* `VK_ICD_FILENAMES` 6345db71995Sopenharmony_ci* `VK_ADD_DRIVER_FILES` 6355db71995Sopenharmony_ci* `VK_LOADER_DRIVERS_SELECT` 6365db71995Sopenharmony_ci* `VK_LOADER_DRIVERS_DISABLE` 6375db71995Sopenharmony_ci 6385db71995Sopenharmony_ciExclusive mode will also disable MacOS bundle manifest discovery of drivers. 6395db71995Sopenharmony_ci 6405db71995Sopenharmony_ci#### Limitations of `VK_LUNARG_direct_driver_loading` 6415db71995Sopenharmony_ci 6425db71995Sopenharmony_ciBecause `VkDirectDriverLoadingListLUNARG` is provided to the loader at instance 6435db71995Sopenharmony_cicreation, there is no mechanism for the loader to query the list of instance 6445db71995Sopenharmony_ciextensions that originate from `VkDirectDriverLoadingListLUNARG` drivers during 6455db71995Sopenharmony_ci`vkEnumerateInstanceExtensionProperties`. 6465db71995Sopenharmony_ciApplications can instead manually load the `vkEnumerateInstanceExtensionProperties` 6475db71995Sopenharmony_cifunction pointer directly from the drivers the application provides to the loader 6485db71995Sopenharmony_ciusing the `pfnGetInstanceProcAddrLUNARG` for each driver. 6495db71995Sopenharmony_ciThen the application can call each driver's 6505db71995Sopenharmony_ci`vkEnumerateInstanceExtensionProperties` and append non-duplicate entriees to the 6515db71995Sopenharmony_cilist from the loader's `vkEnumerateInstanceExtensionProperties` to get the full 6525db71995Sopenharmony_cilist of supported instance extensions. 6535db71995Sopenharmony_ciAlternatively, because the Application is providing drivers, it is reasonable for 6545db71995Sopenharmony_cithe application to already know which instance extensions are available with the 6555db71995Sopenharmony_ciprovided drivers, preventing the need to manually query them. 6565db71995Sopenharmony_ci 6575db71995Sopenharmony_ciHowever, there are limitations. 6585db71995Sopenharmony_ciIf there are any active implicit layers which intercept 6595db71995Sopenharmony_ci`vkEnumerateInstanceExtensionProperties` to remove unsupported extensions, then 6605db71995Sopenharmony_cithose layers will not be able to remove unsupported extensions from drivers that 6615db71995Sopenharmony_ciare provided by the application. 6625db71995Sopenharmony_ciThis is due to `vkEnumerateInstanceExtensionProperties` not having a mechanism 6635db71995Sopenharmony_cito extend it. 6645db71995Sopenharmony_ci 6655db71995Sopenharmony_ci 6665db71995Sopenharmony_ci### Using Pre-Production ICDs or Software Drivers 6675db71995Sopenharmony_ci 6685db71995Sopenharmony_ciBoth software and pre-production ICDs can use an alternative mechanism to 6695db71995Sopenharmony_cidetect their drivers. 6705db71995Sopenharmony_ciIndependent Hardware Vendor (IHV) may not want to fully install a pre-production 6715db71995Sopenharmony_ciICD and so it can't be found in the standard location. 6725db71995Sopenharmony_ciFor example, a pre-production ICD may simply be a shared library in the 6735db71995Sopenharmony_cideveloper's build tree. 6745db71995Sopenharmony_ciIn this case, there should be a way to allow developers to point to such an 6755db71995Sopenharmony_ciICD without modifying the system-installed ICD(s) on their system. 6765db71995Sopenharmony_ci 6775db71995Sopenharmony_ciThis need is met with the use of the `VK_DRIVER_FILES` environment variable, 6785db71995Sopenharmony_ciwhich will override the mechanism used for finding system-installed 6795db71995Sopenharmony_cidrivers. 6805db71995Sopenharmony_ci 6815db71995Sopenharmony_ciIn other words, only the drivers listed in `VK_DRIVER_FILES` will be 6825db71995Sopenharmony_ciused. 6835db71995Sopenharmony_ci 6845db71995Sopenharmony_ciSee 6855db71995Sopenharmony_ci[Overriding the Default Driver Discovery](#overriding-the-default-driver-discovery) 6865db71995Sopenharmony_cifor more information on this. 6875db71995Sopenharmony_ci 6885db71995Sopenharmony_ci 6895db71995Sopenharmony_ci### Driver Discovery on Android 6905db71995Sopenharmony_ci 6915db71995Sopenharmony_ciThe Android loader lives in the system library folder. 6925db71995Sopenharmony_ciThe location cannot be changed. 6935db71995Sopenharmony_ciThe loader will load the driver via `hw_get_module` with the ID of "vulkan". 6945db71995Sopenharmony_ci**Due to security policies in Android, none of this can be modified under** 6955db71995Sopenharmony_ci**normal use.** 6965db71995Sopenharmony_ci 6975db71995Sopenharmony_ci 6985db71995Sopenharmony_ci## Driver Manifest File Format 6995db71995Sopenharmony_ci 7005db71995Sopenharmony_ciThe following section discusses the details of the Driver Manifest JSON file 7015db71995Sopenharmony_ciformat. 7025db71995Sopenharmony_ciThe JSON file itself does not have any requirements for naming. 7035db71995Sopenharmony_ciThe only requirement is that the extension suffix of the file is ".json". 7045db71995Sopenharmony_ci 7055db71995Sopenharmony_ciHere is an example driver JSON Manifest file: 7065db71995Sopenharmony_ci 7075db71995Sopenharmony_ci```json 7085db71995Sopenharmony_ci{ 7095db71995Sopenharmony_ci "file_format_version": "1.0.1", 7105db71995Sopenharmony_ci "ICD": { 7115db71995Sopenharmony_ci "library_path": "path to driver library", 7125db71995Sopenharmony_ci "api_version": "1.2.205", 7135db71995Sopenharmony_ci "library_arch" : "64", 7145db71995Sopenharmony_ci "is_portability_driver": false 7155db71995Sopenharmony_ci } 7165db71995Sopenharmony_ci} 7175db71995Sopenharmony_ci``` 7185db71995Sopenharmony_ci 7195db71995Sopenharmony_ci<table style="width:100%"> 7205db71995Sopenharmony_ci <tr> 7215db71995Sopenharmony_ci <th>Field Name</th> 7225db71995Sopenharmony_ci <th>Field Value</th> 7235db71995Sopenharmony_ci </tr> 7245db71995Sopenharmony_ci <tr> 7255db71995Sopenharmony_ci <td>"file_format_version"</td> 7265db71995Sopenharmony_ci <td>The JSON format major.minor.patch version number of this file.<br/> 7275db71995Sopenharmony_ci Supported versions are: 1.0.0 and 1.0.1.</td> 7285db71995Sopenharmony_ci </tr> 7295db71995Sopenharmony_ci <tr> 7305db71995Sopenharmony_ci <td>"ICD"</td> 7315db71995Sopenharmony_ci <td>The identifier used to group all driver information together. 7325db71995Sopenharmony_ci <br/> 7335db71995Sopenharmony_ci <b>NOTE:</b> Even though this is labelled <i>ICD</i> it is historical 7345db71995Sopenharmony_ci and just as accurate to use for other drivers.</td> 7355db71995Sopenharmony_ci </tr> 7365db71995Sopenharmony_ci <tr> 7375db71995Sopenharmony_ci <td>"library_path"</td> 7385db71995Sopenharmony_ci <td>The "library_path" specifies either a filename, a relative pathname, or 7395db71995Sopenharmony_ci a full pathname to a driver shared library file. <br /> 7405db71995Sopenharmony_ci If "library_path" specifies a relative pathname, it is relative to the 7415db71995Sopenharmony_ci path of the JSON manifest file. <br /> 7425db71995Sopenharmony_ci If "library_path" specifies a filename, the library must live in the 7435db71995Sopenharmony_ci system's shared object search path. <br /> 7445db71995Sopenharmony_ci There are no rules about the name of the driver's shared library file 7455db71995Sopenharmony_ci other than it should end with the appropriate suffix (".DLL" on 7465db71995Sopenharmony_ci Windows, ".so" on Linux and ".dylib" on macOS).</td> 7475db71995Sopenharmony_ci </tr> 7485db71995Sopenharmony_ci <tr> 7495db71995Sopenharmony_ci <td>"library_arch"</td> 7505db71995Sopenharmony_ci <td>Optional field which specifies the architecture of the binary associated 7515db71995Sopenharmony_ci with "library_path". <br /> 7525db71995Sopenharmony_ci Allows the loader to quickly determine if the architecture of the driver 7535db71995Sopenharmony_ci matches that of the running application. <br /> 7545db71995Sopenharmony_ci The only valid values are "32" and "64".</td> 7555db71995Sopenharmony_ci </tr> 7565db71995Sopenharmony_ci <tr> 7575db71995Sopenharmony_ci <td>"api_version" </td> 7585db71995Sopenharmony_ci <td>The major.minor.patch version number of the maximum Vulkan API supported 7595db71995Sopenharmony_ci by the driver. 7605db71995Sopenharmony_ci However, just because the driver supports the specific Vulkan API 7615db71995Sopenharmony_ci version, it does not guarantee that the hardware on a user's system can 7625db71995Sopenharmony_ci support that version. 7635db71995Sopenharmony_ci Information on what the underlying physical device can support must be 7645db71995Sopenharmony_ci queried by the user using the <i>vkGetPhysicalDeviceProperties</i> API 7655db71995Sopenharmony_ci call.<br/> 7665db71995Sopenharmony_ci For example: 1.0.33.</td> 7675db71995Sopenharmony_ci </tr> 7685db71995Sopenharmony_ci <tr> 7695db71995Sopenharmony_ci <td>"is_portability_driver" </td> 7705db71995Sopenharmony_ci <td>Defines whether the driver contains any VkPhysicalDevices which 7715db71995Sopenharmony_ci implement the VK_KHR_portability_subset extension.<br/> 7725db71995Sopenharmony_ci </td> 7735db71995Sopenharmony_ci </tr> 7745db71995Sopenharmony_ci</table> 7755db71995Sopenharmony_ci 7765db71995Sopenharmony_ci**NOTE:** If the same driver shared library supports multiple, incompatible 7775db71995Sopenharmony_civersions of text manifest file format versions, it must have separate JSON files 7785db71995Sopenharmony_cifor each (all of which may point to the same shared library). 7795db71995Sopenharmony_ci 7805db71995Sopenharmony_ci### Driver Manifest File Versions 7815db71995Sopenharmony_ci 7825db71995Sopenharmony_ciThe current highest supported Layer Manifest file format supported is 1.0.1. 7835db71995Sopenharmony_ciInformation about each version is detailed in the following sub-sections: 7845db71995Sopenharmony_ci 7855db71995Sopenharmony_ci#### Driver Manifest File Version 1.0.0 7865db71995Sopenharmony_ci 7875db71995Sopenharmony_ciThe initial version of the Driver Manifest file specified the basic 7885db71995Sopenharmony_ciformat and fields of a layer JSON file. 7895db71995Sopenharmony_ciThe fields supported in version 1.0.0 of the file format include: 7905db71995Sopenharmony_ci * "file\_format\_version" 7915db71995Sopenharmony_ci * "ICD" 7925db71995Sopenharmony_ci * "library\_path" 7935db71995Sopenharmony_ci * "api\_version" 7945db71995Sopenharmony_ci 7955db71995Sopenharmony_ci#### Driver Manifest File Version 1.0.1 7965db71995Sopenharmony_ci 7975db71995Sopenharmony_ciAdded the `is_portability_driver` boolean field for drivers to self report that 7985db71995Sopenharmony_cithey contain VkPhysicalDevices which support the VK_KHR_portability_subset 7995db71995Sopenharmony_ciextension. This is an optional field. Omitting the field has the same effect as 8005db71995Sopenharmony_cisetting the field to `false`. 8015db71995Sopenharmony_ci 8025db71995Sopenharmony_ciAdded the "library\_arch" field to the driver manifest to allow the loader to 8035db71995Sopenharmony_ciquickly determine if the driver matches the architecture of the current running 8045db71995Sopenharmony_ciapplication. This field is optional. 8055db71995Sopenharmony_ci 8065db71995Sopenharmony_ci## Driver Vulkan Entry Point Discovery 8075db71995Sopenharmony_ci 8085db71995Sopenharmony_ciThe Vulkan symbols exported by a driver must not clash with the loader's 8095db71995Sopenharmony_ciexported Vulkan symbols. 8105db71995Sopenharmony_ciBecause of this, all drivers must export the following function that is 8115db71995Sopenharmony_ciused for discovery of driver Vulkan entry-points. 8125db71995Sopenharmony_ciThis entry-point is not a part of the Vulkan API itself, only a private 8135db71995Sopenharmony_ciinterface between the loader and drivers for version 1 and higher 8145db71995Sopenharmony_ciinterfaces. 8155db71995Sopenharmony_ci 8165db71995Sopenharmony_ci```cpp 8175db71995Sopenharmony_ciVKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL 8185db71995Sopenharmony_ci vk_icdGetInstanceProcAddr( 8195db71995Sopenharmony_ci VkInstance instance, 8205db71995Sopenharmony_ci const char* pName); 8215db71995Sopenharmony_ci``` 8225db71995Sopenharmony_ci 8235db71995Sopenharmony_ciThis function has very similar semantics to `vkGetInstanceProcAddr`. 8245db71995Sopenharmony_ci`vk_icdGetInstanceProcAddr` returns valid function pointers for all the 8255db71995Sopenharmony_ciglobal-level and instance-level Vulkan functions, and also for 8265db71995Sopenharmony_ci`vkGetDeviceProcAddr`. 8275db71995Sopenharmony_ciGlobal-level functions are those which contain no dispatchable object as the 8285db71995Sopenharmony_cifirst parameter, such as `vkCreateInstance` and 8295db71995Sopenharmony_ci`vkEnumerateInstanceExtensionProperties`. 8305db71995Sopenharmony_ciThe driver must support querying global-level entry points by calling 8315db71995Sopenharmony_ci`vk_icdGetInstanceProcAddr` with a NULL `VkInstance` parameter. 8325db71995Sopenharmony_ciInstance-level functions are those that have either `VkInstance`, or 8335db71995Sopenharmony_ci`VkPhysicalDevice` as the first parameter dispatchable object. 8345db71995Sopenharmony_ciBoth core entry points and any instance extension entry points the 8355db71995Sopenharmony_cidriver supports should be available via `vk_icdGetInstanceProcAddr`. 8365db71995Sopenharmony_ciFuture Vulkan instance extensions may define and use new instance-level 8375db71995Sopenharmony_cidispatchable objects other than `VkInstance` and `VkPhysicalDevice`, in which 8385db71995Sopenharmony_cicase extension entry points using these newly defined dispatchable objects must 8395db71995Sopenharmony_cibe queryable via `vk_icdGetInstanceProcAddr`. 8405db71995Sopenharmony_ci 8415db71995Sopenharmony_ciAll other Vulkan entry points must either: 8425db71995Sopenharmony_ci * NOT be exported directly from the driver library 8435db71995Sopenharmony_ci * or NOT use the official Vulkan function names if they are exported 8445db71995Sopenharmony_ci 8455db71995Sopenharmony_ciThis requirement is for driver libraries that include other functionality (such 8465db71995Sopenharmony_cias OpenGL) and thus could be loaded by the application prior to when the Vulkan 8475db71995Sopenharmony_ciloader library is loaded by the application. 8485db71995Sopenharmony_ci 8495db71995Sopenharmony_ciBeware of interposing by dynamic OS library loaders if the official Vulkan 8505db71995Sopenharmony_cinames are used. 8515db71995Sopenharmony_ciOn Linux, if official names are used, the driver library must be linked with 8525db71995Sopenharmony_ci`-Bsymbolic`. 8535db71995Sopenharmony_ci 8545db71995Sopenharmony_ci 8555db71995Sopenharmony_ci## Driver API Version 8565db71995Sopenharmony_ci 8575db71995Sopenharmony_ciWhen an application calls `vkCreateInstance`, it can optionally include a 8585db71995Sopenharmony_ci`VkApplicationInfo` struct, which includes an `apiVersion` field. 8595db71995Sopenharmony_ciA Vulkan 1.0 driver was required to return `VK_ERROR_INCOMPATIBLE_DRIVER` if it 8605db71995Sopenharmony_cidid not support the API version that the user passed. 8615db71995Sopenharmony_ciBeginning with Vulkan 1.1, drivers are not allowed to return this error 8625db71995Sopenharmony_cifor any value of `apiVersion`. 8635db71995Sopenharmony_ciThis creates a problem when working with multiple drivers, where one is 8645db71995Sopenharmony_cia 1.0 driver and another is newer. 8655db71995Sopenharmony_ci 8665db71995Sopenharmony_ciA loader that is newer than 1.0 will always give the version it supports when 8675db71995Sopenharmony_cithe application calls `vkEnumerateInstanceVersion`, regardless of the API 8685db71995Sopenharmony_civersion supported by the drivers on the system. 8695db71995Sopenharmony_ciThis means that when the application calls `vkCreateInstance`, the loader will 8705db71995Sopenharmony_cibe forced to pass a copy of the `VkApplicationInfo` struct where `apiVersion` is 8715db71995Sopenharmony_ci1.0 to any 1.0 drivers in order to prevent an error. 8725db71995Sopenharmony_ciTo determine if this must be done, the loader will perform the following steps: 8735db71995Sopenharmony_ci 8745db71995Sopenharmony_ci1. Check the driver's JSON manifest file for the "api_version" field. 8755db71995Sopenharmony_ci2. If the JSON version is greater than or equal to 1.1, Load the driver's 8765db71995Sopenharmony_cidynamic library 8775db71995Sopenharmony_ci3. Call the driver's `vkGetInstanceProcAddr` command to get a pointer to 8785db71995Sopenharmony_ci`vkEnumerateInstanceVersion` 8795db71995Sopenharmony_ci4. If the pointer to `vkEnumerateInstanceVersion` is not `NULL`, it will be 8805db71995Sopenharmony_cicalled to get the driver's supported API version 8815db71995Sopenharmony_ci 8825db71995Sopenharmony_ciThe driver will be treated as a 1.0 driver if any of the following conditions 8835db71995Sopenharmony_ciare met: 8845db71995Sopenharmony_ci 8855db71995Sopenharmony_ci- The JSON manifest's "api_version" field is less that version 1.1 8865db71995Sopenharmony_ci- The function pointer to `vkEnumerateInstanceVersion` is `NULL` 8875db71995Sopenharmony_ci- The version returned by `vkEnumerateInstanceVersion` is less than 1.1 8885db71995Sopenharmony_ci- `vkEnumerateInstanceVersion` returns anything other than `VK_SUCCESS` 8895db71995Sopenharmony_ci 8905db71995Sopenharmony_ciIf the driver only supports Vulkan 1.0, the loader will ensure that any 8915db71995Sopenharmony_ci`VkApplicationInfo` struct that is passed to the driver will have an 8925db71995Sopenharmony_ci`apiVersion` field set to Vulkan 1.0. 8935db71995Sopenharmony_ciOtherwise, the loader will pass the struct to the driver without any 8945db71995Sopenharmony_cichanges. 8955db71995Sopenharmony_ci 8965db71995Sopenharmony_ci 8975db71995Sopenharmony_ci## Mixed Driver Instance Extension Support 8985db71995Sopenharmony_ci 8995db71995Sopenharmony_ciOn a system with more than one driver, a special case can arise. 9005db71995Sopenharmony_ciSome drivers may expose an instance extension that the loader is already 9015db71995Sopenharmony_ciaware of. 9025db71995Sopenharmony_ciOther drivers on that same system may not support the same instance 9035db71995Sopenharmony_ciextension. 9045db71995Sopenharmony_ci 9055db71995Sopenharmony_ciIn that scenario, the loader has some additional responsibilities: 9065db71995Sopenharmony_ci 9075db71995Sopenharmony_ci 9085db71995Sopenharmony_ci### Filtering Out Instance Extension Names 9095db71995Sopenharmony_ci 9105db71995Sopenharmony_ciDuring a call to `vkCreateInstance`, the list of requested instance extensions 9115db71995Sopenharmony_ciis passed down to each driver. 9125db71995Sopenharmony_ciSince the driver may not support one or more of these instance extensions, the 9135db71995Sopenharmony_ciloader will filter out any instance extensions that are not supported by the 9145db71995Sopenharmony_cidriver. 9155db71995Sopenharmony_ciThis is done per driver since different drivers may support different instance 9165db71995Sopenharmony_ciextensions. 9175db71995Sopenharmony_ci 9185db71995Sopenharmony_ci 9195db71995Sopenharmony_ci### Loader Instance Extension Emulation Support 9205db71995Sopenharmony_ci 9215db71995Sopenharmony_ciIn the same scenario, the loader must emulate the instance extension 9225db71995Sopenharmony_cientry-points, to the best of its ability, for each driver that does not support 9235db71995Sopenharmony_cian instance extension directly. 9245db71995Sopenharmony_ciThis must work correctly when combined with calling into the other 9255db71995Sopenharmony_cidrivers which do support the extension natively. 9265db71995Sopenharmony_ciIn this fashion, the application will be unaware of what drivers are 9275db71995Sopenharmony_cimissing support for this extension. 9285db71995Sopenharmony_ci 9295db71995Sopenharmony_ci 9305db71995Sopenharmony_ci## Driver Unknown Physical Device Extensions 9315db71995Sopenharmony_ci 9325db71995Sopenharmony_ciDrivers that implement entrypoints which take a `VkPhysicalDevice` as the first 9335db71995Sopenharmony_ciparameter *should* support `vk_icdGetPhysicalDeviceProcAddr`. 9345db71995Sopenharmony_ciThis function is added to the Loader and Driver Driver Interface Version 4, 9355db71995Sopenharmony_ciallowing the loader to distinguish between entrypoints which take `VkDevice` 9365db71995Sopenharmony_ciand `VkPhysicalDevice` as the first parameter. 9375db71995Sopenharmony_ciThis allows the loader to properly support entrypoints that are unknown to it 9385db71995Sopenharmony_cigracefully. 9395db71995Sopenharmony_ciThis entry point is not a part of the Vulkan API itself, only a private 9405db71995Sopenharmony_ciinterface between the loader and drivers. 9415db71995Sopenharmony_ciNote: Loader and Driver Interface Version 7 makes exporting 9425db71995Sopenharmony_ci`vk_icdGetPhysicalDeviceProcAddr` optional. 9435db71995Sopenharmony_ciInstead, drivers *must* expose it through `vk_icdGetInstanceProcAddr`. 9445db71995Sopenharmony_ci 9455db71995Sopenharmony_ci```cpp 9465db71995Sopenharmony_ciPFN_vkVoidFunction 9475db71995Sopenharmony_ci vk_icdGetPhysicalDeviceProcAddr( 9485db71995Sopenharmony_ci VkInstance instance, 9495db71995Sopenharmony_ci const char* pName); 9505db71995Sopenharmony_ci``` 9515db71995Sopenharmony_ci 9525db71995Sopenharmony_ciThis function behaves similar to `vkGetInstanceProcAddr` and 9535db71995Sopenharmony_ci`vkGetDeviceProcAddr` except it should only return values for physical device 9545db71995Sopenharmony_ciextension entry points. 9555db71995Sopenharmony_ciIn this way, it compares "pName" to every physical device function supported in 9565db71995Sopenharmony_cithe driver. 9575db71995Sopenharmony_ci 9585db71995Sopenharmony_ciImplementations of the function should have the following behavior: 9595db71995Sopenharmony_ci* If `pName` is the name of a Vulkan API entrypoint that takes a 9605db71995Sopenharmony_ci `VkPhysicalDevice` as its primary dispatch handle, and the driver supports the 9615db71995Sopenharmony_ci entrypoint, then the driver **must** return the valid function pointer to the 9625db71995Sopenharmony_ci driver's implementation of that entrypoint. 9635db71995Sopenharmony_ci* If `pName` is the name of a Vulkan API entrypoint that takes something other 9645db71995Sopenharmony_ci than a `VkPhysicalDevice` as its primary dispatch handle, then the driver 9655db71995Sopenharmony_ci **must** return `NULL`. 9665db71995Sopenharmony_ci* If the driver is unaware of any entrypoint with the name `pName`, it **must** 9675db71995Sopenharmony_ci return `NULL`. 9685db71995Sopenharmony_ci 9695db71995Sopenharmony_ciIf a driver intends to support functions that take VkPhysicalDevice as the 9705db71995Sopenharmony_cidispatchable parameter, then the driver should support 9715db71995Sopenharmony_ci`vk_icdGetPhysicalDeviceProcAddr`. This is because if these functions aren't 9725db71995Sopenharmony_ciknown to the loader, such as those from unreleased extensions or because 9735db71995Sopenharmony_cithe loader is an older build thus doesn't know about them _yet_, the loader 9745db71995Sopenharmony_ciwon't be able to distinguish whether this is a device or physical device 9755db71995Sopenharmony_cifunction. 9765db71995Sopenharmony_ci 9775db71995Sopenharmony_ciIf a driver does implement this support, it must export the function from the 9785db71995Sopenharmony_cidriver library using the name `vk_icdGetPhysicalDeviceProcAddr` so that the 9795db71995Sopenharmony_cisymbol can be located through the platform's dynamic linking utilities, or if 9805db71995Sopenharmony_cithe driver supports Loader and Driver Interface Version 7, exposed through 9815db71995Sopenharmony_ci`vk_icdGetInstanceProcAddr` instead. 9825db71995Sopenharmony_ci 9835db71995Sopenharmony_ciThe behavior of the loader's `vkGetInstanceProcAddr` with support for the 9845db71995Sopenharmony_ci`vk_icdGetPhysicalDeviceProcAddr` function is as follows: 9855db71995Sopenharmony_ci 1. Check if core function: 9865db71995Sopenharmony_ci - If it is, return the function pointer 9875db71995Sopenharmony_ci 2. Check if known instance or device extension function: 9885db71995Sopenharmony_ci - If it is, return the function pointer 9895db71995Sopenharmony_ci 3. Call the layer/driver `GetPhysicalDeviceProcAddr` 9905db71995Sopenharmony_ci - If it returns `non-NULL`, return a trampoline to a generic physical device 9915db71995Sopenharmony_cifunction, and set up a generic terminator which will pass it to the proper 9925db71995Sopenharmony_cidriver. 9935db71995Sopenharmony_ci 4. Call down using `GetInstanceProcAddr` 9945db71995Sopenharmony_ci - If it returns non-NULL, treat it as an unknown logical device command. 9955db71995Sopenharmony_ciThis means setting up a generic trampoline function that takes in a `VkDevice` 9965db71995Sopenharmony_cias the first parameter and adjusting the dispatch table to call the 9975db71995Sopenharmony_cidriver/layer's function after getting the dispatch table from the 9985db71995Sopenharmony_ci`VkDevice`. 9995db71995Sopenharmony_ciThen, return the pointer to the corresponding trampoline function. 10005db71995Sopenharmony_ci 5. Return `NULL` 10015db71995Sopenharmony_ci 10025db71995Sopenharmony_ciThe result is that if the command gets promoted to Vulkan core later, it will no 10035db71995Sopenharmony_cilonger be set up using `vk_icdGetPhysicalDeviceProcAddr`. 10045db71995Sopenharmony_ciAdditionally, if the loader adds direct support for the extension, it will no 10055db71995Sopenharmony_cilonger get to step 3, because step 2 will return a valid function pointer. 10065db71995Sopenharmony_ciHowever, the driver should continue to support the command query via 10075db71995Sopenharmony_ci`vk_icdGetPhysicalDeviceProcAddr`, until at least a Vulkan version bump, because 10085db71995Sopenharmony_cian older loader may still be attempting to use the commands. 10095db71995Sopenharmony_ci 10105db71995Sopenharmony_ci### Reason for adding `vk_icdGetPhysicalDeviceProcAddr` 10115db71995Sopenharmony_ci 10125db71995Sopenharmony_ciOriginally, when the loader's `vkGetInstanceProcAddr` was called, it would 10135db71995Sopenharmony_ciresult in the following behavior: 10145db71995Sopenharmony_ci 1. The loader would check if it was a core function: 10155db71995Sopenharmony_ci - If so, it would return the function pointer 10165db71995Sopenharmony_ci 2. The loader would check if it was a known extension function: 10175db71995Sopenharmony_ci - If so, it would return the function pointer 10185db71995Sopenharmony_ci 3. If the loader knew nothing about it, it would call down using 10195db71995Sopenharmony_ci`GetInstanceProcAddr` 10205db71995Sopenharmony_ci - If it returned `non-NULL`, treat it as an unknown logical device command. 10215db71995Sopenharmony_ci - This meant setting up a generic trampoline function that takes in a 10225db71995Sopenharmony_ciVkDevice as the first parameter and adjusting the dispatch table to call the 10235db71995Sopenharmony_cidriver/layer's function after getting the dispatch table from the 10245db71995Sopenharmony_ci`VkDevice`. 10255db71995Sopenharmony_ci 4. If all the above failed, the loader would return `NULL` to the application. 10265db71995Sopenharmony_ci 10275db71995Sopenharmony_ciThis caused problems when a driver attempted to expose new physical device 10285db71995Sopenharmony_ciextensions the loader knew nothing about, but an application was aware of. 10295db71995Sopenharmony_ciBecause the loader knew nothing about it, the loader would get to step 3 in the 10305db71995Sopenharmony_ciabove process and would treat the function as an unknown logical device command. 10315db71995Sopenharmony_ciThe problem is, this would create a generic `VkDevice` trampoline function 10325db71995Sopenharmony_ciwhich, on the first call, would attempt to dereference the VkPhysicalDevice as a 10335db71995Sopenharmony_ci`VkDevice`. 10345db71995Sopenharmony_ciThis would lead to a crash or corruption. 10355db71995Sopenharmony_ci 10365db71995Sopenharmony_ci## Physical Device Sorting 10375db71995Sopenharmony_ci 10385db71995Sopenharmony_ciWhen an application selects a GPU to use, it must enumerate physical devices or 10395db71995Sopenharmony_ciphysical device groups. 10405db71995Sopenharmony_ciThese API functions do not specify which order the physical devices or physical 10415db71995Sopenharmony_cidevice groups will be presented in. 10425db71995Sopenharmony_ciOn Windows, the loader will attempt to sort these objects so that the system 10435db71995Sopenharmony_cipreference will be listed first. 10445db71995Sopenharmony_ciThis mechanism does not force an application to use any particular GPU — 10455db71995Sopenharmony_ciit merely changes the order in which they are presented. 10465db71995Sopenharmony_ci 10475db71995Sopenharmony_ciThis mechanism requires that a driver provide The Loader and Driver Interface 10485db71995Sopenharmony_ciVersion 6. 10495db71995Sopenharmony_ciThis version defines a new exported function, `vk_icdEnumerateAdapterPhysicalDevices`, 10505db71995Sopenharmony_cidetailed below, that Drivers may provide on Windows. 10515db71995Sopenharmony_ciThis entry point is not a part of the Vulkan API itself, only a private 10525db71995Sopenharmony_ciinterface between the loader and drivers. 10535db71995Sopenharmony_ciNote: Loader and Driver Interface Version 7 makes exporting 10545db71995Sopenharmony_ci`vk_icdEnumerateAdapterPhysicalDevices` optional. 10555db71995Sopenharmony_ciInstead, drivers *must* expose it through `vk_icdGetInstanceProcAddr`. 10565db71995Sopenharmony_ci 10575db71995Sopenharmony_ci```c 10585db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL 10595db71995Sopenharmony_ci vk_icdEnumerateAdapterPhysicalDevices( 10605db71995Sopenharmony_ci VkInstance instance, 10615db71995Sopenharmony_ci LUID adapterLUID, 10625db71995Sopenharmony_ci uint32_t* pPhysicalDeviceCount, 10635db71995Sopenharmony_ci VkPhysicalDevice* pPhysicalDevices); 10645db71995Sopenharmony_ci``` 10655db71995Sopenharmony_ci 10665db71995Sopenharmony_ci 10675db71995Sopenharmony_ciThis function takes an adapter LUID as input, and enumerates all Vulkan physical 10685db71995Sopenharmony_cidevices that are associated with that LUID. 10695db71995Sopenharmony_ciThis works in the same way as other Vulkan enumerations — if 10705db71995Sopenharmony_ci`pPhysicalDevices` is `NULL`, then the count will be provided. 10715db71995Sopenharmony_ciOtherwise, the physical devices associated with the queried adapter will be 10725db71995Sopenharmony_ciprovided. 10735db71995Sopenharmony_ciThe function must provide multiple physical devices when the LUID refers to a 10745db71995Sopenharmony_cilinked adapter. 10755db71995Sopenharmony_ciThis allows the loader to translate the adapter into Vulkan physical device 10765db71995Sopenharmony_cigroups. 10775db71995Sopenharmony_ci 10785db71995Sopenharmony_ciWhile the loader attempts to match the system's preference for GPU ordering, 10795db71995Sopenharmony_cithere are some limitations. 10805db71995Sopenharmony_ciBecause this feature requires a new driver interface, only physical devices from 10815db71995Sopenharmony_cidrivers that support this function will be sorted. 10825db71995Sopenharmony_ciAll unsorted physical devices will be listed at the end of the list, in an 10835db71995Sopenharmony_ciindeterminate order. 10845db71995Sopenharmony_ciFurthermore, only physical devices that correspond to an adapter may be sorted. 10855db71995Sopenharmony_ciThis means that a software driver would likely not be sorted. 10865db71995Sopenharmony_ciFinally, this API only applies to Windows systems and will only work on versions 10875db71995Sopenharmony_ciof Windows 10 that support GPU selection through the OS. 10885db71995Sopenharmony_ciOther platforms may be included in the future, but they will require separate 10895db71995Sopenharmony_ciplatform-specific interfaces. 10905db71995Sopenharmony_ci 10915db71995Sopenharmony_ciA requirement of `vk_icdEnumerateAdapterPhysicalDevices` is that it *must* 10925db71995Sopenharmony_cireturn the same `VkPhysicalDevice` handle values for the same physical 10935db71995Sopenharmony_cidevices that are returned by `vkEnumeratePhysicalDevices`. 10945db71995Sopenharmony_ciThis is because the loader calls both functions on the driver then 10955db71995Sopenharmony_cide-duplicates the physical devices using the `VkPhysicalDevice` handles. 10965db71995Sopenharmony_ciSince not all physical devices in a driver will have a LUID, such as for 10975db71995Sopenharmony_cisoftware implementations, this step is necessary to allow drivers to 10985db71995Sopenharmony_cienumerate all available physical devices. 10995db71995Sopenharmony_ci 11005db71995Sopenharmony_ci## Driver Dispatchable Object Creation 11015db71995Sopenharmony_ci 11025db71995Sopenharmony_ciAs previously covered, the loader requires dispatch tables to be accessible 11035db71995Sopenharmony_ciwithin Vulkan dispatchable objects, such as: `VkInstance`, `VkPhysicalDevice`, 11045db71995Sopenharmony_ci`VkDevice`, `VkQueue`, and `VkCommandBuffer`. 11055db71995Sopenharmony_ciThe specific requirements on all dispatchable objects created by drivers 11065db71995Sopenharmony_ciare as follows: 11075db71995Sopenharmony_ci 11085db71995Sopenharmony_ci- All dispatchable objects created by a driver can be cast to void \*\* 11095db71995Sopenharmony_ci- The loader will replace the first entry with a pointer to the dispatch table 11105db71995Sopenharmony_ciwhich is owned by the loader. 11115db71995Sopenharmony_ciThis implies three things for drivers: 11125db71995Sopenharmony_ci 1. The driver must return a pointer for the opaque dispatchable object handle 11135db71995Sopenharmony_ci 2. This pointer points to a regular C structure with the first entry being a 11145db71995Sopenharmony_ci pointer. 11155db71995Sopenharmony_ci * **NOTE:** For any C\++ drivers that implement VK objects directly 11165db71995Sopenharmony_cias C\++ classes: 11175db71995Sopenharmony_ci * The C\++ compiler may put a vtable at offset zero if the class is 11185db71995Sopenharmony_cinon-POD due to the use of a virtual function. 11195db71995Sopenharmony_ci * In this case use a regular C structure (see below). 11205db71995Sopenharmony_ci 3. The loader checks for a magic value (ICD\_LOADER\_MAGIC) in all the created 11215db71995Sopenharmony_ci dispatchable objects, as follows (see `include/vulkan/vk_icd.h`): 11225db71995Sopenharmony_ci 11235db71995Sopenharmony_ci```cpp 11245db71995Sopenharmony_ci#include "vk_icd.h" 11255db71995Sopenharmony_ci 11265db71995Sopenharmony_ciunion _VK_LOADER_DATA { 11275db71995Sopenharmony_ci uintptr loadermagic; 11285db71995Sopenharmony_ci void * loaderData; 11295db71995Sopenharmony_ci} VK_LOADER_DATA; 11305db71995Sopenharmony_ci 11315db71995Sopenharmony_civkObj 11325db71995Sopenharmony_ci alloc_icd_obj() 11335db71995Sopenharmony_ci{ 11345db71995Sopenharmony_ci vkObj *newObj = alloc_obj(); 11355db71995Sopenharmony_ci ... 11365db71995Sopenharmony_ci // Initialize pointer to loader's dispatch table with ICD_LOADER_MAGIC 11375db71995Sopenharmony_ci 11385db71995Sopenharmony_ci set_loader_magic_value(newObj); 11395db71995Sopenharmony_ci ... 11405db71995Sopenharmony_ci return newObj; 11415db71995Sopenharmony_ci} 11425db71995Sopenharmony_ci``` 11435db71995Sopenharmony_ci 11445db71995Sopenharmony_ci 11455db71995Sopenharmony_ci## Handling KHR Surface Objects in WSI Extensions 11465db71995Sopenharmony_ci 11475db71995Sopenharmony_ciNormally, drivers handle object creation and destruction for various Vulkan 11485db71995Sopenharmony_ciobjects. 11495db71995Sopenharmony_ciThe WSI surface extensions for Linux, Windows, macOS, and QNX 11505db71995Sopenharmony_ci("VK\_KHR\_win32\_surface", "VK\_KHR\_xcb\_surface", "VK\_KHR\_xlib\_surface", 11515db71995Sopenharmony_ci"VK\_KHR\_wayland\_surface", "VK\_MVK\_macos\_surface", 11525db71995Sopenharmony_ci"VK\_QNX\_screen\_surface" and "VK\_KHR\_surface") are handled differently. 11535db71995Sopenharmony_ciFor these extensions, the `VkSurfaceKHR` object creation and destruction may be 11545db71995Sopenharmony_cihandled by either the loader or a driver. 11555db71995Sopenharmony_ci 11565db71995Sopenharmony_ciIf the loader handles the management of the `VkSurfaceKHR` objects: 11575db71995Sopenharmony_ci 1. The loader will handle the calls to `vkCreateXXXSurfaceKHR` and 11585db71995Sopenharmony_ci`vkDestroySurfaceKHR` 11595db71995Sopenharmony_ci functions without involving the drivers. 11605db71995Sopenharmony_ci * Where XXX stands for the Windowing System name: 11615db71995Sopenharmony_ci * Wayland 11625db71995Sopenharmony_ci * XCB 11635db71995Sopenharmony_ci * Xlib 11645db71995Sopenharmony_ci * Windows 11655db71995Sopenharmony_ci * Android 11665db71995Sopenharmony_ci * MacOS (`vkCreateMacOSSurfaceMVK`) 11675db71995Sopenharmony_ci * QNX (`vkCreateScreenSurfaceQNX`) 11685db71995Sopenharmony_ci 2. The loader creates a `VkIcdSurfaceXXX` object for the corresponding 11695db71995Sopenharmony_ci`vkCreateXXXSurfaceKHR` call. 11705db71995Sopenharmony_ci * The `VkIcdSurfaceXXX` structures are defined in `include/vulkan/vk_icd.h`. 11715db71995Sopenharmony_ci 3. Drivers can cast any `VkSurfaceKHR` object to a pointer to the 11725db71995Sopenharmony_ciappropriate `VkIcdSurfaceXXX` structure. 11735db71995Sopenharmony_ci 4. The first field of all the `VkIcdSurfaceXXX` structures is a 11745db71995Sopenharmony_ci`VkIcdSurfaceBase` enumerant that indicates whether the 11755db71995Sopenharmony_ci surface object is Win32, XCB, Xlib, Wayland, or Screen. 11765db71995Sopenharmony_ci 11775db71995Sopenharmony_ciThe driver may choose to handle `VkSurfaceKHR` object creation instead. 11785db71995Sopenharmony_ciIf a driver desires to handle creating and destroying it must do the following: 11795db71995Sopenharmony_ci 1. Support Loader and Driver Interface Version 3 or newer. 11805db71995Sopenharmony_ci 2. Expose and handle all functions that take in a `VkSurfaceKHR` object, 11815db71995Sopenharmony_ciincluding: 11825db71995Sopenharmony_ci * `vkCreateXXXSurfaceKHR` 11835db71995Sopenharmony_ci * `vkGetPhysicalDeviceSurfaceSupportKHR` 11845db71995Sopenharmony_ci * `vkGetPhysicalDeviceSurfaceCapabilitiesKHR` 11855db71995Sopenharmony_ci * `vkGetPhysicalDeviceSurfaceFormatsKHR` 11865db71995Sopenharmony_ci * `vkGetPhysicalDeviceSurfacePresentModesKHR` 11875db71995Sopenharmony_ci * `vkCreateSwapchainKHR` 11885db71995Sopenharmony_ci * `vkDestroySurfaceKHR` 11895db71995Sopenharmony_ci 11905db71995Sopenharmony_ciBecause the `VkSurfaceKHR` object is an instance-level object, one object can be 11915db71995Sopenharmony_ciassociated with multiple drivers. 11925db71995Sopenharmony_ciTherefore, when the loader receives the `vkCreateXXXSurfaceKHR` call, it still 11935db71995Sopenharmony_cicreates an internal `VkSurfaceIcdXXX` object. 11945db71995Sopenharmony_ciThis object acts as a container for each driver's version of the 11955db71995Sopenharmony_ci`VkSurfaceKHR` object. 11965db71995Sopenharmony_ciIf a driver does not support the creation of its own `VkSurfaceKHR` object, the 11975db71995Sopenharmony_ciloader's container stores a NULL for that driver. 11985db71995Sopenharmony_ciOn the other hand, if the driver does support `VkSurfaceKHR` creation, the 11995db71995Sopenharmony_ciloader will make the appropriate `vkCreateXXXSurfaceKHR` call to the 12005db71995Sopenharmony_cidriver, and store the returned pointer in its container object. 12015db71995Sopenharmony_ciThe loader then returns the `VkSurfaceIcdXXX` as a `VkSurfaceKHR` object back up 12025db71995Sopenharmony_cithe call chain. 12035db71995Sopenharmony_ciFinally, when the loader receives the `vkDestroySurfaceKHR` call, it 12045db71995Sopenharmony_cisubsequently calls `vkDestroySurfaceKHR` for each driver whose internal 12055db71995Sopenharmony_ci`VkSurfaceKHR` object is not NULL. 12065db71995Sopenharmony_ciThen the loader destroys the container object before returning. 12075db71995Sopenharmony_ci 12085db71995Sopenharmony_ci 12095db71995Sopenharmony_ci## Loader and Driver Interface Negotiation 12105db71995Sopenharmony_ci 12115db71995Sopenharmony_ciGenerally, for functions issued by an application, the loader can be viewed as a 12125db71995Sopenharmony_cipass through. 12135db71995Sopenharmony_ciThat is, the loader generally doesn't modify the functions or their parameters, 12145db71995Sopenharmony_cibut simply calls the driver's entry point for that function. 12155db71995Sopenharmony_ciThere are specific additional interface requirements a driver needs to comply 12165db71995Sopenharmony_ciwith that are not part of any requirements from the Vulkan specification. 12175db71995Sopenharmony_ciThese additional requirements are versioned to allow flexibility in the future. 12185db71995Sopenharmony_ci 12195db71995Sopenharmony_ci 12205db71995Sopenharmony_ci### Windows, Linux and macOS Driver Negotiation 12215db71995Sopenharmony_ci 12225db71995Sopenharmony_ci 12235db71995Sopenharmony_ci#### Version Negotiation Between the Loader and Drivers 12245db71995Sopenharmony_ci 12255db71995Sopenharmony_ciAll drivers supporting Loader and Driver Interface Version 2 or higher must 12265db71995Sopenharmony_ciexport the following function that is used for determination of the interface 12275db71995Sopenharmony_civersion that will be used. 12285db71995Sopenharmony_ciThis entry point is not a part of the Vulkan API itself, only a private 12295db71995Sopenharmony_ciinterface between the loader and drivers. 12305db71995Sopenharmony_ciNote: Loader and Driver Interface Version 7 makes exporting 12315db71995Sopenharmony_ci`vk_icdNegotiateLoaderICDInterfaceVersion` optional. 12325db71995Sopenharmony_ciInstead, drivers *must* expose it through `vk_icdGetInstanceProcAddr`. 12335db71995Sopenharmony_ci 12345db71995Sopenharmony_ci```cpp 12355db71995Sopenharmony_ciVKAPI_ATTR VkResult VKAPI_CALL 12365db71995Sopenharmony_ci vk_icdNegotiateLoaderICDInterfaceVersion( 12375db71995Sopenharmony_ci uint32_t* pSupportedVersion); 12385db71995Sopenharmony_ci``` 12395db71995Sopenharmony_ci 12405db71995Sopenharmony_ciThis function allows the loader and driver to agree on an interface version to 12415db71995Sopenharmony_ciuse. 12425db71995Sopenharmony_ciThe "pSupportedVersion" parameter is both an input and output parameter. 12435db71995Sopenharmony_ci"pSupportedVersion" is filled in by the loader with the desired latest interface 12445db71995Sopenharmony_civersion supported by the loader (typically the latest). 12455db71995Sopenharmony_ciThe driver receives this and returns back the version it desires in the same 12465db71995Sopenharmony_cifield. 12475db71995Sopenharmony_ciBecause it is setting up the interface version between the loader and 12485db71995Sopenharmony_cidriver, this should be the first call made by a loader to the driver (even prior 12495db71995Sopenharmony_cito any calls to `vk_icdGetInstanceProcAddr`). 12505db71995Sopenharmony_ci 12515db71995Sopenharmony_ciIf the driver receiving the call no longer supports the interface version 12525db71995Sopenharmony_ciprovided by the loader (due to deprecation), then it should report a 12535db71995Sopenharmony_ci`VK_ERROR_INCOMPATIBLE_DRIVER` error. 12545db71995Sopenharmony_ciOtherwise it sets the value pointed by "pSupportedVersion" to the latest 12555db71995Sopenharmony_ciinterface version supported by both the driver and the loader and returns 12565db71995Sopenharmony_ci`VK_SUCCESS`. 12575db71995Sopenharmony_ci 12585db71995Sopenharmony_ciThe driver should report `VK_SUCCESS` in case the loader-provided interface 12595db71995Sopenharmony_civersion is newer than that supported by the driver, as it's the loader's 12605db71995Sopenharmony_ciresponsibility to determine whether it can support the older interface version 12615db71995Sopenharmony_cisupported by the driver. 12625db71995Sopenharmony_ciThe driver should also report `VK_SUCCESS` in the case its interface version is 12635db71995Sopenharmony_cigreater than the loader's, but return the loader's version. 12645db71995Sopenharmony_ciThus, upon return of `VK_SUCCESS` the "pSupportedVersion" will contain the 12655db71995Sopenharmony_cidesired interface version to be used by the driver. 12665db71995Sopenharmony_ci 12675db71995Sopenharmony_ciIf the loader receives an interface version from the driver that the loader no 12685db71995Sopenharmony_cilonger supports (due to deprecation), or it receives a 12695db71995Sopenharmony_ci`VK_ERROR_INCOMPATIBLE_DRIVER` error instead of `VK_SUCCESS`, then the loader 12705db71995Sopenharmony_ciwill treat the driver as incompatible and will not load it for use. 12715db71995Sopenharmony_ciIn this case, the application will not see the driver's `vkPhysicalDevice` 12725db71995Sopenharmony_ciduring enumeration. 12735db71995Sopenharmony_ci 12745db71995Sopenharmony_ci#### Interfacing With Legacy Drivers or Loaders 12755db71995Sopenharmony_ci 12765db71995Sopenharmony_ciIf a loader sees that a driver does not export or expose the 12775db71995Sopenharmony_ci`vk_icdNegotiateLoaderICDInterfaceVersion` function, then the loader assumes the 12785db71995Sopenharmony_cicorresponding driver only supports either interface version 0 or 1. 12795db71995Sopenharmony_ci 12805db71995Sopenharmony_ciFrom the other side of the interface, if a driver sees a call to 12815db71995Sopenharmony_ci`vk_icdGetInstanceProcAddr` before a call to 12825db71995Sopenharmony_ci`vk_icdNegotiateLoaderICDInterfaceVersion`, then the loader is either a legacy 12835db71995Sopenharmony_ciloader with only support for interface version 0 or 1, or the loader is using 12845db71995Sopenharmony_ciinterface version 7 or newer. 12855db71995Sopenharmony_ci 12865db71995Sopenharmony_ciIf the first call to `vk_icdGetInstanceProcAddr` is to query for 12875db71995Sopenharmony_ci`vk_icdNegotiateLoaderICDInterfaceVersion`, then that means the loader is using 12885db71995Sopenharmony_ciinterface version 7. 12895db71995Sopenharmony_ciThis only occurs when the driver does not export 12905db71995Sopenharmony_ci`vk_icdNegotiateLoaderICDInterfaceVersion`. 12915db71995Sopenharmony_ciDrivers which export `vk_icdNegotiateLoaderICDInterfaceVersion` will have it 12925db71995Sopenharmony_cicalled first. 12935db71995Sopenharmony_ci 12945db71995Sopenharmony_ciIf the first call to `vk_icdGetInstanceProcAddr` is **not** querying for 12955db71995Sopenharmony_ci`vk_icdNegotiateLoaderICDInterfaceVersion`, then loader is a legacy loader only 12965db71995Sopenharmony_ciwhich supports version 0 or 1. 12975db71995Sopenharmony_ciIn this case, if the loader calls `vk_icdGetInstanceProcAddr` first, it supports 12985db71995Sopenharmony_ciat least interface version 1. 12995db71995Sopenharmony_ciOtherwise, the loader only supports version 0. 13005db71995Sopenharmony_ci 13015db71995Sopenharmony_ci#### Loader and Driver Interface Version 7 Requirements 13025db71995Sopenharmony_ci 13035db71995Sopenharmony_ciVersion 7 relaxes the requirement that Loader and Driver Interface functions 13045db71995Sopenharmony_cimust be exported. 13055db71995Sopenharmony_ciInstead, it only requires that those functions be queryable through 13065db71995Sopenharmony_ci`vk_icdGetInstanceProcAddr`. 13075db71995Sopenharmony_ciThe functions are: 13085db71995Sopenharmony_ci `vk_icdNegotiateLoaderICDInterfaceVersion` 13095db71995Sopenharmony_ci `vk_icdGetPhysicalDeviceProcAddr` 13105db71995Sopenharmony_ci `vk_icdEnumerateAdapterPhysicalDevices` (Windows only) 13115db71995Sopenharmony_ciThese functions are considered global for the purposes of retrieval, so the 13125db71995Sopenharmony_ci`VkInstance` parameter of `vk_icdGetInstanceProcAddr` will be **NULL**. 13135db71995Sopenharmony_ciWhile exporting these functions is no longer a requirement, drivers may still 13145db71995Sopenharmony_ciexport them for compatibility with older loaders. 13155db71995Sopenharmony_ciThe changes in this version allow drivers provided through the 13165db71995Sopenharmony_ci`VK_LUNARG_direct_driver_loading` extension to support the entire Loader and 13175db71995Sopenharmony_ciDriver Interface. 13185db71995Sopenharmony_ci 13195db71995Sopenharmony_ci#### Loader and Driver Interface Version 6 Requirements 13205db71995Sopenharmony_ci 13215db71995Sopenharmony_ciVersion 6 provides a mechanism to allow the loader to sort physical devices. 13225db71995Sopenharmony_ciThe loader will only attempt to sort physical devices on a driver if version 6 13235db71995Sopenharmony_ciof the interface is supported. 13245db71995Sopenharmony_ciThis version provides the `vk_icdEnumerateAdapterPhysicalDevices` function 13255db71995Sopenharmony_cidefined earlier in this document. 13265db71995Sopenharmony_ci 13275db71995Sopenharmony_ci#### Loader and Driver Interface Version 5 Requirements 13285db71995Sopenharmony_ci 13295db71995Sopenharmony_ciThis interface version has no changes to the actual interface. 13305db71995Sopenharmony_ciIf the loader requests interface version 5 or greater, it is simply 13315db71995Sopenharmony_cian indication to drivers that the loader is now evaluating whether the API 13325db71995Sopenharmony_ciVersion info passed into vkCreateInstance is a valid version for the loader. 13335db71995Sopenharmony_ciIf it is not, the loader will catch this during vkCreateInstance and fail with a 13345db71995Sopenharmony_ci`VK_ERROR_INCOMPATIBLE_DRIVER` error. 13355db71995Sopenharmony_ci 13365db71995Sopenharmony_ciOn the other hand, if version 5 or newer is not requested by the loader, then it 13375db71995Sopenharmony_ciindicates to the driver that the loader is ignorant of the API version being 13385db71995Sopenharmony_cirequested. 13395db71995Sopenharmony_ciBecause of this, it falls on the driver to validate that the API Version is not 13405db71995Sopenharmony_cigreater than major = 1 and minor = 0. 13415db71995Sopenharmony_ciIf it is, then the driver should automatically fail with a 13425db71995Sopenharmony_ci`VK_ERROR_INCOMPATIBLE_DRIVER` error since the loader is a 1.0 loader, and is 13435db71995Sopenharmony_ciunaware of the version. 13445db71995Sopenharmony_ci 13455db71995Sopenharmony_ciHere is a table of the expected behaviors: 13465db71995Sopenharmony_ci 13475db71995Sopenharmony_ci<table style="width:100%"> 13485db71995Sopenharmony_ci <tr> 13495db71995Sopenharmony_ci <th>Loader Supports I/f Version</th> 13505db71995Sopenharmony_ci <th>Driver Supports I/f Version</th> 13515db71995Sopenharmony_ci <th>Result</th> 13525db71995Sopenharmony_ci </tr> 13535db71995Sopenharmony_ci <tr> 13545db71995Sopenharmony_ci <td>4 or Earlier</td> 13555db71995Sopenharmony_ci <td>Any Version</td> 13565db71995Sopenharmony_ci <td>Driver <b>must fail</b> with <b>VK_ERROR_INCOMPATIBLE_DRIVER</b> 13575db71995Sopenharmony_ci for all vkCreateInstance calls with apiVersion set to > Vulkan 1.0 13585db71995Sopenharmony_ci because the loader is still at interface version <= 4.<br/> 13595db71995Sopenharmony_ci Otherwise, the driver should behave as normal. 13605db71995Sopenharmony_ci </td> 13615db71995Sopenharmony_ci </tr> 13625db71995Sopenharmony_ci <tr> 13635db71995Sopenharmony_ci <td>5 or Newer</td> 13645db71995Sopenharmony_ci <td>4 or Earlier</td> 13655db71995Sopenharmony_ci <td>Loader <b>must fail</b> with <b>VK_ERROR_INCOMPATIBLE_DRIVER</b> if it 13665db71995Sopenharmony_ci can't handle the apiVersion. 13675db71995Sopenharmony_ci Driver may pass for all apiVersions, but since its interface is 13685db71995Sopenharmony_ci <= 4, it is best if it assumes it needs to do the work of rejecting 13695db71995Sopenharmony_ci anything > Vulkan 1.0 and fail with <b>VK_ERROR_INCOMPATIBLE_DRIVER</b>. 13705db71995Sopenharmony_ci <br/> 13715db71995Sopenharmony_ci Otherwise, the driver should behave as normal. 13725db71995Sopenharmony_ci </td> 13735db71995Sopenharmony_ci </tr> 13745db71995Sopenharmony_ci <tr> 13755db71995Sopenharmony_ci <td>5 or Newer</td> 13765db71995Sopenharmony_ci <td>5 or Newer</td> 13775db71995Sopenharmony_ci <td>Loader <b>must fail</b> with <b>VK_ERROR_INCOMPATIBLE_DRIVER</b> if it 13785db71995Sopenharmony_ci can't handle the apiVersion, and drivers should fail with 13795db71995Sopenharmony_ci <b>VK_ERROR_INCOMPATIBLE_DRIVER</b> <i>only if</i> they can not support 13805db71995Sopenharmony_ci the specified apiVersion. <br/> 13815db71995Sopenharmony_ci Otherwise, the driver should behave as normal. 13825db71995Sopenharmony_ci </td> 13835db71995Sopenharmony_ci </tr> 13845db71995Sopenharmony_ci</table> 13855db71995Sopenharmony_ci 13865db71995Sopenharmony_ci#### Loader and Driver Interface Version 4 Requirements 13875db71995Sopenharmony_ci 13885db71995Sopenharmony_ciThe major change to version 4 of this interface version is the support of 13895db71995Sopenharmony_ci[Unknown Physical Device Extensions](#driver-unknown-physical-device-extensions) 13905db71995Sopenharmony_ciusing the `vk_icdGetPhysicalDeviceProcAddr` function. 13915db71995Sopenharmony_ciThis function is purely optional. 13925db71995Sopenharmony_ciHowever, if a driver supports a physical device extension, it must provide a 13935db71995Sopenharmony_ci`vk_icdGetPhysicalDeviceProcAddr` function. 13945db71995Sopenharmony_ciOtherwise, the loader will continue to treat any unknown functions as VkDevice 13955db71995Sopenharmony_cifunctions and cause invalid behavior. 13965db71995Sopenharmony_ci 13975db71995Sopenharmony_ci 13985db71995Sopenharmony_ci#### Loader and Driver Interface Version 3 Requirements 13995db71995Sopenharmony_ci 14005db71995Sopenharmony_ciThe primary change that occurred in this interface version is to allow a driver 14015db71995Sopenharmony_cito handle creation and destruction of their own KHR_surfaces. 14025db71995Sopenharmony_ciUp until this point, the loader created a surface object that was used by all 14035db71995Sopenharmony_cidrivers. 14045db71995Sopenharmony_ciHowever, some drivers *may* want to provide their own surface handles. 14055db71995Sopenharmony_ciIf a driver chooses to enable this support, it must support Loader and Driver 14065db71995Sopenharmony_ciInterface Version 3, as well as any Vulkan function that uses a `VkSurfaceKHR` 14075db71995Sopenharmony_cihandle, such as: 14085db71995Sopenharmony_ci- `vkCreateXXXSurfaceKHR` (where XXX is the platform-specific identifier [i.e. 14095db71995Sopenharmony_ci`vkCreateWin32SurfaceKHR` for Windows]) 14105db71995Sopenharmony_ci- `vkDestroySurfaceKHR` 14115db71995Sopenharmony_ci- `vkCreateSwapchainKHR` 14125db71995Sopenharmony_ci- `vkGetPhysicalDeviceSurfaceSupportKHR` 14135db71995Sopenharmony_ci- `vkGetPhysicalDeviceSurfaceCapabilitiesKHR` 14145db71995Sopenharmony_ci- `vkGetPhysicalDeviceSurfaceFormatsKHR` 14155db71995Sopenharmony_ci- `vkGetPhysicalDeviceSurfacePresentModesKHR` 14165db71995Sopenharmony_ci 14175db71995Sopenharmony_ciA driver which does not participate in this functionality can opt out by 14185db71995Sopenharmony_cisimply not exposing the above `vkCreateXXXSurfaceKHR` and 14195db71995Sopenharmony_ci`vkDestroySurfaceKHR` functions. 14205db71995Sopenharmony_ci 14215db71995Sopenharmony_ci 14225db71995Sopenharmony_ci#### Loader and Driver Interface Version 2 Requirements 14235db71995Sopenharmony_ci 14245db71995Sopenharmony_ciInterface Version 2 requires that drivers export 14255db71995Sopenharmony_ci`vk_icdNegotiateLoaderICDInterfaceVersion`. 14265db71995Sopenharmony_ciFor more information, see [Version Negotiation Between Loader and Drivers](#version-negotiation-between-loader-and-drivers). 14275db71995Sopenharmony_ci 14285db71995Sopenharmony_ciAdditional, version 2 requires that Vulkan dispatchable objects created by 14295db71995Sopenharmony_cidrivers must be created in accordance to the 14305db71995Sopenharmony_ci[Driver Dispatchable Object Creation](#driver-dispatchable-object-creation) 14315db71995Sopenharmony_cisection. 14325db71995Sopenharmony_ci 14335db71995Sopenharmony_ci 14345db71995Sopenharmony_ci#### Loader and Driver Interface Version 1 Requirements 14355db71995Sopenharmony_ci 14365db71995Sopenharmony_ciVersion 1 of the interface added the driver-specific entry-point 14375db71995Sopenharmony_ci`vk_icdGetInstanceProcAddr`. 14385db71995Sopenharmony_ciSince this is before the creation of the 14395db71995Sopenharmony_ci`vk_icdNegotiateLoaderICDInterfaceVersion` entry-point, the loader has no 14405db71995Sopenharmony_cinegotiation process for determine what interface version the driver 14415db71995Sopenharmony_cisupports. 14425db71995Sopenharmony_ciBecause of this, the loader detects support for version 1 of the interface 14435db71995Sopenharmony_ciby the absence of the negotiate function, but the presence of the 14445db71995Sopenharmony_ci`vk_icdGetInstanceProcAddr`. 14455db71995Sopenharmony_ciNo other entry-points need to be exported by the driver as the loader will query 14465db71995Sopenharmony_cithe appropriate function pointers using that. 14475db71995Sopenharmony_ci 14485db71995Sopenharmony_ci 14495db71995Sopenharmony_ci#### Loader and Driver Interface Version 0 Requirements 14505db71995Sopenharmony_ci 14515db71995Sopenharmony_ciVersion 0 does not support either `vk_icdGetInstanceProcAddr` or 14525db71995Sopenharmony_ci`vk_icdNegotiateLoaderICDInterfaceVersion`. 14535db71995Sopenharmony_ciBecause of this, the loader will assume the driver supports only version 0 of 14545db71995Sopenharmony_cithe interface unless one of those functions exists. 14555db71995Sopenharmony_ci 14565db71995Sopenharmony_ciAdditionally, for Version 0, the driver must expose at least the following core 14575db71995Sopenharmony_ciVulkan entry-points so the loader may build up the interface to the driver: 14585db71995Sopenharmony_ci 14595db71995Sopenharmony_ci- The function `vkGetInstanceProcAddr` **must be exported** in the driver 14605db71995Sopenharmony_cilibrary and returns valid function pointers for all the Vulkan API entry points. 14615db71995Sopenharmony_ci- `vkCreateInstance` **must be exported** by the driver library. 14625db71995Sopenharmony_ci- `vkEnumerateInstanceExtensionProperties` **must be exported** by the driver 14635db71995Sopenharmony_cilibrary. 14645db71995Sopenharmony_ci 14655db71995Sopenharmony_ci 14665db71995Sopenharmony_ci#### Additional Interface Notes: 14675db71995Sopenharmony_ci 14685db71995Sopenharmony_ci- The loader will filter out extensions requested in `vkCreateInstance` and 14695db71995Sopenharmony_ci`vkCreateDevice` before calling into the driver; filtering will be of extensions 14705db71995Sopenharmony_ciadvertised by entities (e.g. layers) different from the driver in question. 14715db71995Sopenharmony_ci- The loader will not call the driver for `vkEnumerate*LayerProperties` 14725db71995Sopenharmony_cias layer properties are obtained from the layer libraries and layer JSON files. 14735db71995Sopenharmony_ci- If a driver library author wants to implement a layer, it can do so by having 14745db71995Sopenharmony_cithe appropriate layer JSON manifest file refer to the driver library file. 14755db71995Sopenharmony_ci- The loader will not call the driver for `vkEnumerate*ExtensionProperties` if 14765db71995Sopenharmony_ci"pLayerName" is not equal to `NULL`. 14775db71995Sopenharmony_ci- Drivers creating new dispatchable objects via device extensions need 14785db71995Sopenharmony_cito initialize the created dispatchable object. 14795db71995Sopenharmony_ciThe loader has generic *trampoline* code for unknown device extensions. 14805db71995Sopenharmony_ciThis generic *trampoline* code doesn't initialize the dispatch table within the 14815db71995Sopenharmony_cinewly created object. 14825db71995Sopenharmony_ciSee the 14835db71995Sopenharmony_ci[Driver Dispatchable Object Creation](#driver-dispatchable-object-creation) 14845db71995Sopenharmony_cisection for more information on how to initialize created dispatchable objects 14855db71995Sopenharmony_cifor extensions non known by the loader. 14865db71995Sopenharmony_ci 14875db71995Sopenharmony_ci 14885db71995Sopenharmony_ci### Android Driver Negotiation 14895db71995Sopenharmony_ci 14905db71995Sopenharmony_ciThe Android loader uses the same protocol for initializing the dispatch table as 14915db71995Sopenharmony_cidescribed above. 14925db71995Sopenharmony_ciThe only difference is that the Android loader queries layer and extension 14935db71995Sopenharmony_ciinformation directly from the respective libraries and does not use the JSON 14945db71995Sopenharmony_cimanifest files used by the Windows, Linux and macOS loaders. 14955db71995Sopenharmony_ci 14965db71995Sopenharmony_ci 14975db71995Sopenharmony_ci## Loader implementation of VK_KHR_portability_enumeration 14985db71995Sopenharmony_ci 14995db71995Sopenharmony_ciThe loader implements the `VK_KHR_portability_enumeration` instance extension, 15005db71995Sopenharmony_ciwhich filters out any drivers that report support for the portability subset 15015db71995Sopenharmony_cidevice extension. Unless the application explicitly requests enumeration of 15025db71995Sopenharmony_ciportability devices by setting the 15035db71995Sopenharmony_ci`VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR` bit in the 15045db71995Sopenharmony_ciVkInstanceCreateInfo::flags, the loader does not load any drivers that declare 15055db71995Sopenharmony_cithemselves to be portability drivers. 15065db71995Sopenharmony_ci 15075db71995Sopenharmony_ciDrivers declare whether they are portability drivers or not in the Driver 15085db71995Sopenharmony_ciManifest Json file, with the `is_portability_driver` boolean field. 15095db71995Sopenharmony_ci[More information here](#driver-manifest-file-version-101) 15105db71995Sopenharmony_ci 15115db71995Sopenharmony_ciThe initial support for this extension only reported errors when an application 15125db71995Sopenharmony_cidid not enable the portability enumeration feature. It did not filter out 15135db71995Sopenharmony_ciportability drivers. This was done to give a grace period for applications to 15145db71995Sopenharmony_ciupdate their instance creation logic without outright breaking the application. 15155db71995Sopenharmony_ci 15165db71995Sopenharmony_ci## Loader and Driver Policy 15175db71995Sopenharmony_ci 15185db71995Sopenharmony_ciThis section is intended to define proper behavior expected between the loader 15195db71995Sopenharmony_ciand drivers. 15205db71995Sopenharmony_ciMuch of this section is additive to the Vulkan spec, and necessary for 15215db71995Sopenharmony_cimaintaining consistency across platforms. 15225db71995Sopenharmony_ciIn fact, much of the language can be found throughout this document, but is 15235db71995Sopenharmony_cisummarized here for convenience. 15245db71995Sopenharmony_ciAdditionally, there should be a way to identify bad or non-conformant behavior 15255db71995Sopenharmony_ciin a driver and remedy it as soon as possible. 15265db71995Sopenharmony_ciTherefore, a policy numbering system is provided to clearly identify each 15275db71995Sopenharmony_cipolicy statement in a unique way. 15285db71995Sopenharmony_ci 15295db71995Sopenharmony_ciFinally, based on the goal of making the loader efficient and performant, 15305db71995Sopenharmony_cisome of these policy statements defining proper driver behavior may not 15315db71995Sopenharmony_cibe testable (and therefore aren't enforceable by the loader). 15325db71995Sopenharmony_ciHowever, that should not detract from the requirement in order to provide the 15335db71995Sopenharmony_cibest experience to end-users and developers. 15345db71995Sopenharmony_ci 15355db71995Sopenharmony_ci 15365db71995Sopenharmony_ci### Number Format 15375db71995Sopenharmony_ci 15385db71995Sopenharmony_ciLoader and Driver policy items start with the prefix `LDP_` (short for 15395db71995Sopenharmony_ciLoader and Driver Policy) which is followed by an identifier based on what 15405db71995Sopenharmony_cicomponent the policy is targeted against. 15415db71995Sopenharmony_ciIn this case there are only two possible components: 15425db71995Sopenharmony_ci - Drivers: which will have the string `DRIVER_` as part of the policy number. 15435db71995Sopenharmony_ci - The Loader: which will have the string `LOADER_` as part of the policy 15445db71995Sopenharmony_ci number. 15455db71995Sopenharmony_ci 15465db71995Sopenharmony_ci 15475db71995Sopenharmony_ci### Android Differences 15485db71995Sopenharmony_ci 15495db71995Sopenharmony_ciAs stated before, the Android Loader is actually separate from the Khronos 15505db71995Sopenharmony_ciLoader. 15515db71995Sopenharmony_ciBecause of this and other platform requirements, not all of these policy 15525db71995Sopenharmony_cistatements apply to Android. 15535db71995Sopenharmony_ciEach table also has a column titled "Applicable to Android?" 15545db71995Sopenharmony_ciwhich indicates which policy statements apply to drivers that are focused 15555db71995Sopenharmony_cionly on Android support. 15565db71995Sopenharmony_ciFurther information on the Android loader can be found in the 15575db71995Sopenharmony_ci<a href="https://source.android.com/devices/graphics/implement-vulkan"> 15585db71995Sopenharmony_ciAndroid Vulkan documentation</a>. 15595db71995Sopenharmony_ci 15605db71995Sopenharmony_ci 15615db71995Sopenharmony_ci### Requirements of Well-Behaved Drivers 15625db71995Sopenharmony_ci 15635db71995Sopenharmony_ci<table style="width:100%"> 15645db71995Sopenharmony_ci <tr> 15655db71995Sopenharmony_ci <th>Requirement Number</th> 15665db71995Sopenharmony_ci <th>Requirement Description</th> 15675db71995Sopenharmony_ci <th>Result of Non-Compliance</th> 15685db71995Sopenharmony_ci <th>Applicable to Android?</th> 15695db71995Sopenharmony_ci <th>Enforceable by Loader?</th> 15705db71995Sopenharmony_ci <th>Reference Section</th> 15715db71995Sopenharmony_ci </tr> 15725db71995Sopenharmony_ci <tr> 15735db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_1</b></small></td> 15745db71995Sopenharmony_ci <td>A driver <b>must not</b> cause other drivers to fail, crash, or 15755db71995Sopenharmony_ci otherwise misbehave. 15765db71995Sopenharmony_ci </td> 15775db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 15785db71995Sopenharmony_ci <td>Yes</td> 15795db71995Sopenharmony_ci <td>No</td> 15805db71995Sopenharmony_ci <td><small>N/A</small></td> 15815db71995Sopenharmony_ci </tr> 15825db71995Sopenharmony_ci <tr> 15835db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_2</b></small></td> 15845db71995Sopenharmony_ci <td>A driver <b>must not</b> crash if it detects that there are no supported 15855db71995Sopenharmony_ci Vulkan Physical Devices (<i>VkPhysicalDevice</i>) on the system when a 15865db71995Sopenharmony_ci call to that driver is made using any Vulkan instance of physical device 15875db71995Sopenharmony_ci API.<br/> 15885db71995Sopenharmony_ci This is because some devices can be hot-plugged. 15895db71995Sopenharmony_ci </td> 15905db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 15915db71995Sopenharmony_ci <td>Yes</td> 15925db71995Sopenharmony_ci <td>No<br/> 15935db71995Sopenharmony_ci The loader has no direct knowledge of what devices (virtual or physical) 15945db71995Sopenharmony_ci may be supported by a given driver.</td> 15955db71995Sopenharmony_ci <td><small>N/A</small> 15965db71995Sopenharmony_ci </td> 15975db71995Sopenharmony_ci </tr> 15985db71995Sopenharmony_ci <tr> 15995db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_3</b></small></td> 16005db71995Sopenharmony_ci <td>A driver <b>must</b> be able to negotiate a supported version of the 16015db71995Sopenharmony_ci Loader and Driver Interface with the loader in accordance with the stated 16025db71995Sopenharmony_ci negotiation process. 16035db71995Sopenharmony_ci </td> 16045db71995Sopenharmony_ci <td>The driver will not be loaded.</td> 16055db71995Sopenharmony_ci <td>No</td> 16065db71995Sopenharmony_ci <td>Yes</td> 16075db71995Sopenharmony_ci <td><small> 16085db71995Sopenharmony_ci <a href="#loader-and-driver-interface-negotiation"> 16095db71995Sopenharmony_ci Interface Negotiation</a></small> 16105db71995Sopenharmony_ci </td> 16115db71995Sopenharmony_ci </tr> 16125db71995Sopenharmony_ci <tr> 16135db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_4</b></small></td> 16145db71995Sopenharmony_ci <td>A driver <b>must</b> have a valid JSON manifest file for the loader to 16155db71995Sopenharmony_ci process that ends with the ".json" suffix. 16165db71995Sopenharmony_ci </td> 16175db71995Sopenharmony_ci <td>The driver will not be loaded.</td> 16185db71995Sopenharmony_ci <td>No</td> 16195db71995Sopenharmony_ci <td>Yes</td> 16205db71995Sopenharmony_ci <td><small> 16215db71995Sopenharmony_ci <a href="#driver-manifest-file-format">Manifest File Format</a> 16225db71995Sopenharmony_ci </small> 16235db71995Sopenharmony_ci </td> 16245db71995Sopenharmony_ci </tr> 16255db71995Sopenharmony_ci <tr> 16265db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_5</b></small></td> 16275db71995Sopenharmony_ci <td>A driver <b>must</b> pass conformance with the results submitted, 16285db71995Sopenharmony_ci verified, and approved by Khronos before reporting a conformance version 16295db71995Sopenharmony_ci through any mechanism provided by Vulkan (examples include inside the 16305db71995Sopenharmony_ci <i>VkPhysicalDeviceVulkan12Properties</i> and the 16315db71995Sopenharmony_ci <i>VkPhysicalDeviceDriverProperties</i> structs).<br/> 16325db71995Sopenharmony_ci Otherwise, when such a structure containing a conformance version is 16335db71995Sopenharmony_ci encountered, the driver <b>must</b> return a conformance version 16345db71995Sopenharmony_ci of 0.0.0.0 to indicate it hasn't been so verified and approved. 16355db71995Sopenharmony_ci </td> 16365db71995Sopenharmony_ci <td>Yes</td> 16375db71995Sopenharmony_ci <td>No</td> 16385db71995Sopenharmony_ci <td>The loader and/or the application may make assumptions about the 16395db71995Sopenharmony_ci capabilities of the driver resulting in undefined behavior 16405db71995Sopenharmony_ci possibly including crashes or corruption. 16415db71995Sopenharmony_ci </td> 16425db71995Sopenharmony_ci <td><small> 16435db71995Sopenharmony_ci <a href="https://github.com/KhronosGroup/VK-GL-CTS/blob/main/external/openglcts/README.md"> 16445db71995Sopenharmony_ci Vulkan CTS Documentation</a> 16455db71995Sopenharmony_ci </small> 16465db71995Sopenharmony_ci </td> 16475db71995Sopenharmony_ci </tr> 16485db71995Sopenharmony_ci <tr> 16495db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_6</b></small></td> 16505db71995Sopenharmony_ci <td>Removed - See 16515db71995Sopenharmony_ci <a href="#removed-driver-policies">Removed Driver Policies</a> 16525db71995Sopenharmony_ci </td> 16535db71995Sopenharmony_ci <td>-</td> 16545db71995Sopenharmony_ci <td>-</td> 16555db71995Sopenharmony_ci <td>-</td> 16565db71995Sopenharmony_ci <td>-</td> 16575db71995Sopenharmony_ci </tr> 16585db71995Sopenharmony_ci <tr> 16595db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_7</b></small></td> 16605db71995Sopenharmony_ci <td>If a driver desires to support Vulkan API 1.1 or newer, it <b>must</b> 16615db71995Sopenharmony_ci expose support for Loader and Driver Interface Version 5 or newer. 16625db71995Sopenharmony_ci </td> 16635db71995Sopenharmony_ci <td>The driver will be used when it shouldn't be and will cause 16645db71995Sopenharmony_ci undefined behavior possibly including crashes or corruption. 16655db71995Sopenharmony_ci </td> 16665db71995Sopenharmony_ci <td>No</td> 16675db71995Sopenharmony_ci <td>Yes</td> 16685db71995Sopenharmony_ci <td><small> 16695db71995Sopenharmony_ci <a href="#loader-version-5-interface-requirements"> 16705db71995Sopenharmony_ci Version 5 Interface Requirements</a></small> 16715db71995Sopenharmony_ci </td> 16725db71995Sopenharmony_ci </tr> 16735db71995Sopenharmony_ci <tr> 16745db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_8</b></small></td> 16755db71995Sopenharmony_ci <td>If a driver wishes to handle its own <i>VkSurfaceKHR</i> object 16765db71995Sopenharmony_ci creation, it <b>must</b> implement the Loader and Driver Interface Version 3 or 16775db71995Sopenharmony_ci newer and support querying all the relevant surface functions via 16785db71995Sopenharmony_ci <i>vk_icdGetInstanceProcAddr</i>. 16795db71995Sopenharmony_ci </td> 16805db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 16815db71995Sopenharmony_ci <td>No</td> 16825db71995Sopenharmony_ci <td>Yes</td> 16835db71995Sopenharmony_ci <td><small> 16845db71995Sopenharmony_ci <a href="#handling-khr-surface-objects-in-wsi-extensions"> 16855db71995Sopenharmony_ci Handling KHR Surface Objects</a></small> 16865db71995Sopenharmony_ci </td> 16875db71995Sopenharmony_ci </tr> 16885db71995Sopenharmony_ci <tr> 16895db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_9</b></small></td> 16905db71995Sopenharmony_ci <td>If version negotiation results in a driver using the Loader 16915db71995Sopenharmony_ci and Driver Interface Version 4 or earlier, the driver <b>must</b> verify 16925db71995Sopenharmony_ci that the Vulkan API version passed into <i>vkCreateInstance</i> (through 16935db71995Sopenharmony_ci <i>VkInstanceCreateInfo</i>’s <i>VkApplicationInfo</i>'s 16945db71995Sopenharmony_ci <i>apiVersion</i>) is supported. 16955db71995Sopenharmony_ci If the requested Vulkan API version can not be supported by the driver, 16965db71995Sopenharmony_ci it <b>must</b> return <b>VK_ERROR_INCOMPATIBLE_DRIVER</b>. <br/> 16975db71995Sopenharmony_ci This is not required if the interface version is 5 or newer because the 16985db71995Sopenharmony_ci loader is responsible for this check. 16995db71995Sopenharmony_ci </td> 17005db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 17015db71995Sopenharmony_ci <td>No</td> 17025db71995Sopenharmony_ci <td>No</td> 17035db71995Sopenharmony_ci <td><small> 17045db71995Sopenharmony_ci <a href="#loader-version-5-interface-requirements"> 17055db71995Sopenharmony_ci Version 5 Interface Requirements</a></small> 17065db71995Sopenharmony_ci </td> 17075db71995Sopenharmony_ci </tr> 17085db71995Sopenharmony_ci <tr> 17095db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_10</b></small></td> 17105db71995Sopenharmony_ci <td>If version negotiation results in a driver using the Loader and Driver Interface 17115db71995Sopenharmony_ci Version 5 or newer, the driver <b>must</b> not return 17125db71995Sopenharmony_ci <b>VK_ERROR_INCOMPATIBLE_DRIVER</b> if the Vulkan API version 17135db71995Sopenharmony_ci passed into <i>vkCreateInstance</i> (through 17145db71995Sopenharmony_ci <i>VkInstanceCreateInfo</i>’s <i>VkApplicationInfo</i>'s 17155db71995Sopenharmony_ci <i>apiVersion</i>) is not supported by the driver. This check is performed 17165db71995Sopenharmony_ci by the loader on the drivers behalf. 17175db71995Sopenharmony_ci </td> 17185db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 17195db71995Sopenharmony_ci <td>No</td> 17205db71995Sopenharmony_ci <td>No</td> 17215db71995Sopenharmony_ci <td><small> 17225db71995Sopenharmony_ci <a href="#loader-version-5-interface-requirements"> 17235db71995Sopenharmony_ci Version 5 Interface Requirements</a></small> 17245db71995Sopenharmony_ci </td> 17255db71995Sopenharmony_ci </tr> 17265db71995Sopenharmony_ci <tr> 17275db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_11</b></small></td> 17285db71995Sopenharmony_ci <td>A driver <b>must</b> remove all Manifest files and references to those 17295db71995Sopenharmony_ci files (i.e. Registry entries on Windows) when uninstalling. 17305db71995Sopenharmony_ci <br/> 17315db71995Sopenharmony_ci Similarly, on updating the driver files, the old files <b>must</b> be 17325db71995Sopenharmony_ci all updated or removed. 17335db71995Sopenharmony_ci </td> 17345db71995Sopenharmony_ci <td>If an old file is left pointing to an incorrect library, it will 17355db71995Sopenharmony_ci result in undefined behavior which may include crashes or corruption. 17365db71995Sopenharmony_ci </td> 17375db71995Sopenharmony_ci <td>No</td> 17385db71995Sopenharmony_ci <td>No<br/> 17395db71995Sopenharmony_ci The loader has no idea what driver files are new, old, or incorrect. 17405db71995Sopenharmony_ci Any type of driver file verification would quickly become very complex 17415db71995Sopenharmony_ci since it would require the loader to maintain an internal database 17425db71995Sopenharmony_ci tracking badly behaving drivers based on the driver vendor, driver 17435db71995Sopenharmony_ci version, targeted platform(s), and possibly other criteria. 17445db71995Sopenharmony_ci </td> 17455db71995Sopenharmony_ci <td><small>N/A</small></td> 17465db71995Sopenharmony_ci </tr> 17475db71995Sopenharmony_ci <tr> 17485db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_12</b></small></td> 17495db71995Sopenharmony_ci <td>To work properly with the public Khronos Loader, a driver 17505db71995Sopenharmony_ci <b>must not</b> expose platform interface extensions without first 17515db71995Sopenharmony_ci publishing them with Khronos.<br/> 17525db71995Sopenharmony_ci Platforms under development may use modified versions of the Khronos 17535db71995Sopenharmony_ci Loader until the design because stable and/or public. 17545db71995Sopenharmony_ci </td> 17555db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 17565db71995Sopenharmony_ci <td>Yes (specifically for Android extensions)</td> 17575db71995Sopenharmony_ci <td>No</td> 17585db71995Sopenharmony_ci <td><small>N/A</small></td> 17595db71995Sopenharmony_ci </tr> 17605db71995Sopenharmony_ci</table> 17615db71995Sopenharmony_ci 17625db71995Sopenharmony_ci#### Removed Driver Policies 17635db71995Sopenharmony_ci 17645db71995Sopenharmony_ciThese policies were in the loader source at some point but later removed. 17655db71995Sopenharmony_ciThey are documented here for reference. 17665db71995Sopenharmony_ci 17675db71995Sopenharmony_ci<table> 17685db71995Sopenharmony_ci <tr> 17695db71995Sopenharmony_ci <th>Requirement Number</th> 17705db71995Sopenharmony_ci <th>Requirement Description</th> 17715db71995Sopenharmony_ci <th>Removal Reason</th> 17725db71995Sopenharmony_ci </tr> 17735db71995Sopenharmony_ci <tr> 17745db71995Sopenharmony_ci <td><small><b>LDP_DRIVER_6</b></small></td> 17755db71995Sopenharmony_ci <td>A driver supporting Loader and Driver Interface Version 1 or newer <b>must 17765db71995Sopenharmony_ci not</b> directly export standard Vulkan entry-points. 17775db71995Sopenharmony_ci <br/> 17785db71995Sopenharmony_ci Instead, it <b>must</b> export only the loader interface functions 17795db71995Sopenharmony_ci required by the interface versions it does support (for example 17805db71995Sopenharmony_ci <i>vk_icdGetInstanceProcAddr</i>). <br/> 17815db71995Sopenharmony_ci This is because the dynamic linking on some platforms has been 17825db71995Sopenharmony_ci problematic in the past and incorrectly links to exported functions from 17835db71995Sopenharmony_ci the wrong dynamic library at times. <br/> 17845db71995Sopenharmony_ci <b>NOTE:</b> This is actually true for all exports. 17855db71995Sopenharmony_ci When in doubt, don't export any items from a driver that could cause 17865db71995Sopenharmony_ci conflicts in other libraries.<br/> 17875db71995Sopenharmony_ci </td> 17885db71995Sopenharmony_ci <td> 17895db71995Sopenharmony_ci This policy has been removed due to there being valid circumstances for 17905db71995Sopenharmony_ci drivers to export core entrypoints. 17915db71995Sopenharmony_ci Additionally, it was not found that dynamic linking would cause many 17925db71995Sopenharmony_ci issues in practice. 17935db71995Sopenharmony_ci </td> 17945db71995Sopenharmony_ci </tr> 17955db71995Sopenharmony_ci</table> 17965db71995Sopenharmony_ci 17975db71995Sopenharmony_ci### Requirements of a Well-Behaved Loader 17985db71995Sopenharmony_ci 17995db71995Sopenharmony_ci<table style="width:100%"> 18005db71995Sopenharmony_ci <tr> 18015db71995Sopenharmony_ci <th>Requirement Number</th> 18025db71995Sopenharmony_ci <th>Requirement Description</th> 18035db71995Sopenharmony_ci <th>Result of Non-Compliance</th> 18045db71995Sopenharmony_ci <th>Applicable to Android?</th> 18055db71995Sopenharmony_ci <th>Reference Section</th> 18065db71995Sopenharmony_ci </tr> 18075db71995Sopenharmony_ci <tr> 18085db71995Sopenharmony_ci <td><small><b>LDP_LOADER_1</b></small></td> 18095db71995Sopenharmony_ci <td>A loader <b>must</b> return <b>VK_ERROR_INCOMPATIBLE_DRIVER</b> if it 18105db71995Sopenharmony_ci fails to find and load a valid Vulkan driver on the system. 18115db71995Sopenharmony_ci </td> 18125db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 18135db71995Sopenharmony_ci <td>Yes</td> 18145db71995Sopenharmony_ci <td><small>N/A</small></td> 18155db71995Sopenharmony_ci </tr> 18165db71995Sopenharmony_ci <tr> 18175db71995Sopenharmony_ci <td><small><b>LDP_LOADER_2</b></small></td> 18185db71995Sopenharmony_ci <td>A loader <b>must</b> attempt to load any driver's Manifest file it 18195db71995Sopenharmony_ci discovers and determines is formatted in accordance with this document. 18205db71995Sopenharmony_ci <br/> 18215db71995Sopenharmony_ci The <b>only</b> exception is on platforms which determines driver 18225db71995Sopenharmony_ci location and functionality through some other mechanism. 18235db71995Sopenharmony_ci </td> 18245db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 18255db71995Sopenharmony_ci <td>Yes</td> 18265db71995Sopenharmony_ci <td><small> 18275db71995Sopenharmony_ci <a href="#driver-discovery">Driver Discovery</a></small> 18285db71995Sopenharmony_ci </td> 18295db71995Sopenharmony_ci </tr> 18305db71995Sopenharmony_ci <tr> 18315db71995Sopenharmony_ci <td><small><b>LDP_LOADER_3</b></small></td> 18325db71995Sopenharmony_ci <td>A loader <b>must</b> support a mechanism to load driver in one or more 18335db71995Sopenharmony_ci non-standard locations.<br/> 18345db71995Sopenharmony_ci This is to allow support for fully software drivers as well as 18355db71995Sopenharmony_ci evaluating in-development ICDs. <br/> 18365db71995Sopenharmony_ci The <b>only</b> exception to this rule is if the OS does not wish to 18375db71995Sopenharmony_ci support this due to security policies. 18385db71995Sopenharmony_ci </td> 18395db71995Sopenharmony_ci <td>It will be more difficult to use a Vulkan loader by certain 18405db71995Sopenharmony_ci tools and driver developers.</td> 18415db71995Sopenharmony_ci <td>No</td> 18425db71995Sopenharmony_ci <td><small> 18435db71995Sopenharmony_ci <a href="#using-pre-production-icds-or-software-drivers"> 18445db71995Sopenharmony_ci Pre-Production ICDs or SW</a></small> 18455db71995Sopenharmony_ci </td> 18465db71995Sopenharmony_ci </tr> 18475db71995Sopenharmony_ci <tr> 18485db71995Sopenharmony_ci <td><small><b>LDP_LOADER_4</b></small></td> 18495db71995Sopenharmony_ci <td>A loader <b>must not</b> load a Vulkan driver which defines an API 18505db71995Sopenharmony_ci version that is incompatible with itself. 18515db71995Sopenharmony_ci </td> 18525db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 18535db71995Sopenharmony_ci <td>Yes</td> 18545db71995Sopenharmony_ci <td><small> 18555db71995Sopenharmony_ci <a href="#driver-discovery">Driver Discovery</a></small> 18565db71995Sopenharmony_ci </td> 18575db71995Sopenharmony_ci </tr> 18585db71995Sopenharmony_ci <tr> 18595db71995Sopenharmony_ci <td><small><b>LDP_LOADER_5</b></small></td> 18605db71995Sopenharmony_ci <td>A loader <b>must</b> ignore any driver for which a compatible 18615db71995Sopenharmony_ci Loader and Driver Interface Version can not be negotiated. 18625db71995Sopenharmony_ci </td> 18635db71995Sopenharmony_ci <td>The loader would load a driver improperly resulting in undefined 18645db71995Sopenharmony_ci behavior possibly including crashes or corruption. 18655db71995Sopenharmony_ci </td> 18665db71995Sopenharmony_ci <td>No</td> 18675db71995Sopenharmony_ci <td><small> 18685db71995Sopenharmony_ci <a href="#loader-and-driver-interface-negotiation"> 18695db71995Sopenharmony_ci Interface Negotiation</a></small> 18705db71995Sopenharmony_ci </td> 18715db71995Sopenharmony_ci </tr> 18725db71995Sopenharmony_ci <tr> 18735db71995Sopenharmony_ci <td><small><b>LDP_LOADER_6</b></small></td> 18745db71995Sopenharmony_ci <td>If a driver negotiation results in the loader using Loader and Driver 18755db71995Sopenharmony_ci Interface Version 5 or newer, a loader <b>must</b> verify that the Vulkan 18765db71995Sopenharmony_ci API version passed into <i>vkCreateInstance</i> (through 18775db71995Sopenharmony_ci <i>VkInstanceCreateInfo</i>’s <i>VkApplicationInfo</i>'s 18785db71995Sopenharmony_ci <i>apiVersion</i>) is supported by at least one driver. 18795db71995Sopenharmony_ci If the requested Vulkan API version can not be supported by any 18805db71995Sopenharmony_ci driver, the loader <b>must</b> return 18815db71995Sopenharmony_ci <b>VK_ERROR_INCOMPATIBLE_DRIVER</b>.<br/> 18825db71995Sopenharmony_ci This is not required if the Loader and Driver Interface Version is 4 or 18835db71995Sopenharmony_ci earlier because the responsibility for this check falls on the drivers. 18845db71995Sopenharmony_ci </td> 18855db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 18865db71995Sopenharmony_ci <td>No</td> 18875db71995Sopenharmony_ci <td><small> 18885db71995Sopenharmony_ci <a href="#loader-version-5-interface-requirements"> 18895db71995Sopenharmony_ci Version 5 Interface Requirements</a></small> 18905db71995Sopenharmony_ci </td> 18915db71995Sopenharmony_ci </tr> 18925db71995Sopenharmony_ci <tr> 18935db71995Sopenharmony_ci <td><small><b>LDP_LOADER_7</b></small></td> 18945db71995Sopenharmony_ci <td>If there exist more than one driver on a system, and some of those 18955db71995Sopenharmony_ci drivers support <i>only</i> Vulkan API version 1.0 while other drivers 18965db71995Sopenharmony_ci support a newer Vulkan API version, then a loader <b>must</b> adjust 18975db71995Sopenharmony_ci the <i>apiVersion</i> field of the <i>VkInstanceCreateInfo</i>’s 18985db71995Sopenharmony_ci <i>VkApplicationInfo</i> to version 1.0 for all the drivers that are 18995db71995Sopenharmony_ci only aware of Vulkan API version 1.0.<br/> 19005db71995Sopenharmony_ci Otherwise, the drivers that support Vulkan API version 1.0 will 19015db71995Sopenharmony_ci return <b>VK_ERROR_INCOMPATIBLE_DRIVER</b> during 19025db71995Sopenharmony_ci <i>vkCreateInstance</i> since 1.0 drivers were not aware of future 19035db71995Sopenharmony_ci versions. 19045db71995Sopenharmony_ci </td> 19055db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 19065db71995Sopenharmony_ci <td>No</td> 19075db71995Sopenharmony_ci <td><small> 19085db71995Sopenharmony_ci <a href="#driver-api-version">Driver API Version</a> 19095db71995Sopenharmony_ci </small> 19105db71995Sopenharmony_ci </td> 19115db71995Sopenharmony_ci </tr> 19125db71995Sopenharmony_ci <tr> 19135db71995Sopenharmony_ci <td><small><b>LDP_LOADER_8</b></small></td> 19145db71995Sopenharmony_ci <td>If more than one driver is present, and at least one driver <i>does not 19155db71995Sopenharmony_ci support</i> instance-level functionality that other drivers support; 19165db71995Sopenharmony_ci then a loader <b>must</b> support the instance-level functionality in 19175db71995Sopenharmony_ci some fashion for the non-supporting drivers. 19185db71995Sopenharmony_ci </td> 19195db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 19205db71995Sopenharmony_ci <td>No</td> 19215db71995Sopenharmony_ci <td><small> 19225db71995Sopenharmony_ci <a href="#loader-instance-extension-emulation-support"> 19235db71995Sopenharmony_ci Loader Instance Extension Emulation Support</a></small> 19245db71995Sopenharmony_ci </td> 19255db71995Sopenharmony_ci </tr> 19265db71995Sopenharmony_ci <tr> 19275db71995Sopenharmony_ci <td><small><b>LDP_LOADER_9</b></small></td> 19285db71995Sopenharmony_ci <td>A loader <b>must</b> filter out instance extensions from the 19295db71995Sopenharmony_ci <i>VkInstanceCreateInfo</i> structure's <i>ppEnabledExtensionNames</i> 19305db71995Sopenharmony_ci field that the driver does not support during a call to the driver's 19315db71995Sopenharmony_ci <i>vkCreateInstance</i>.<br/> 19325db71995Sopenharmony_ci This is because the application has no way of knowing which 19335db71995Sopenharmony_ci drivers support which extensions.<br/> 19345db71995Sopenharmony_ci This ties in directly with <i>LDP_LOADER_8</i> above. 19355db71995Sopenharmony_ci </td> 19365db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 19375db71995Sopenharmony_ci <td>No</td> 19385db71995Sopenharmony_ci <td><small> 19395db71995Sopenharmony_ci <a href="#filtering-out-instance-extension-names"> 19405db71995Sopenharmony_ci Filtering Out Instance Extension Names</a></small> 19415db71995Sopenharmony_ci </td> 19425db71995Sopenharmony_ci </tr> 19435db71995Sopenharmony_ci <tr> 19445db71995Sopenharmony_ci <td><small><b>LDP_LOADER_10</b></small></td> 19455db71995Sopenharmony_ci <td>A loader <b>must</b> support creating <i>VkSurfaceKHR</i> handles 19465db71995Sopenharmony_ci that <b>may</b> be shared by all underlying drivers. 19475db71995Sopenharmony_ci </td> 19485db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 19495db71995Sopenharmony_ci <td>Yes</td> 19505db71995Sopenharmony_ci <td><small> 19515db71995Sopenharmony_ci <a href="#handling-khr-surface-objects-in-wsi-extensions"> 19525db71995Sopenharmony_ci Handling KHR Surface Objects</a></small> 19535db71995Sopenharmony_ci </td> 19545db71995Sopenharmony_ci </tr> 19555db71995Sopenharmony_ci <tr> 19565db71995Sopenharmony_ci <td><small><b>LDP_LOADER_11</b></small></td> 19575db71995Sopenharmony_ci <td>If a driver exposes the appropriate <i>VkSurfaceKHR</i> 19585db71995Sopenharmony_ci creation/handling entry-points, a loader <b>must</b> support creating 19595db71995Sopenharmony_ci the driver-specific surface object handle and provide it, and not the 19605db71995Sopenharmony_ci shared <i>VkSurfaceKHR</i> handle, back to that driver when requested. 19615db71995Sopenharmony_ci <br/> 19625db71995Sopenharmony_ci Otherwise, a loader <b>must</b> provide the loader created 19635db71995Sopenharmony_ci <i>VkSurfaceKHR</i> handle. 19645db71995Sopenharmony_ci </td> 19655db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 19665db71995Sopenharmony_ci <td>No</td> 19675db71995Sopenharmony_ci <td><small> 19685db71995Sopenharmony_ci <a href="#handling-khr-surface-objects-in-wsi-extensions"> 19695db71995Sopenharmony_ci Handling KHR Surface Objects</a></small> 19705db71995Sopenharmony_ci </td> 19715db71995Sopenharmony_ci </tr> 19725db71995Sopenharmony_ci <tr> 19735db71995Sopenharmony_ci <td><small><b>LDP_LOADER_12</b></small></td> 19745db71995Sopenharmony_ci <td>A loader <b>must not</b> call any <i>vkEnumerate*ExtensionProperties</i> 19755db71995Sopenharmony_ci entry-points in a driver if <i>pLayerName</i> is not <b>NULL</b>. 19765db71995Sopenharmony_ci </td> 19775db71995Sopenharmony_ci <td>The behavior is undefined and may result in crashes or corruption.</td> 19785db71995Sopenharmony_ci <td>Yes</td> 19795db71995Sopenharmony_ci <td><small> 19805db71995Sopenharmony_ci <a href="#additional-interface-notes"> 19815db71995Sopenharmony_ci Additional Interface Notes</a></small> 19825db71995Sopenharmony_ci </td> 19835db71995Sopenharmony_ci </tr> 19845db71995Sopenharmony_ci <tr> 19855db71995Sopenharmony_ci <td><small><b>LDP_LOADER_13</b></small></td> 19865db71995Sopenharmony_ci <td>A loader <b>must</b> not load from user-defined paths (including the 19875db71995Sopenharmony_ci use of any of <i>VK_ICD_FILENAMES</i>, <i>VK_DRIVER_FILES</i>, or 19885db71995Sopenharmony_ci <i>VK_ADD_DRIVER_FILES</i> environment variables) when running elevated 19895db71995Sopenharmony_ci (Administrator/Super-user) applications.<br/> 19905db71995Sopenharmony_ci <b>This is for security reasons.</b> 19915db71995Sopenharmony_ci </td> 19925db71995Sopenharmony_ci <td>The behavior is undefined and may result in computer security lapses, 19935db71995Sopenharmony_ci crashes or corruption. 19945db71995Sopenharmony_ci </td> 19955db71995Sopenharmony_ci <td>No</td> 19965db71995Sopenharmony_ci <td><small> 19975db71995Sopenharmony_ci <a href="#exception-for-administrator-and-super-user-mode"> 19985db71995Sopenharmony_ci Exception for Administrator and Super-User mode 19995db71995Sopenharmony_ci </a></small> 20005db71995Sopenharmony_ci </td> 20015db71995Sopenharmony_ci </tr> 20025db71995Sopenharmony_ci</table> 20035db71995Sopenharmony_ci 20045db71995Sopenharmony_ci<br/> 20055db71995Sopenharmony_ci 20065db71995Sopenharmony_ci[Return to the top-level LoaderInterfaceArchitecture.md file.](LoaderInterfaceArchitecture.md) 2007