The Loader implements the main VK library (e.g. "vulkan.dll" on Windows and "libvulkan.so" on Linux). It handles layer management and driver management. The loader fully supports multi-gpu operation. As part of this, it dispatches API calls to the correct driver, and to the correct layers, based on the GPU object selected by the application.
The loader's driver management includes finding driver libraries and loading them. When a driver is initialized, the loader sets up its dispatch tables, using a very light-weight "trampoline" mechanism. To do so, it reserves space for a pointer in API objects (see below for more information about this).
The loader's layer management includes finding layer libraries and activating them as requested. The loader correctly sets up each activated layer, and its own dispatch tables in order to support all activated layers. Each active layer can intercept a subset of the full API entrypoints. A layer which doesn't intercept a given entrypoint will be skipped for that entrypoint. The loader supports layers that operate on multiple GPUs.
See file LinuxICDs.txt and WindowsICDs.txt for description of how the loader finds ICD driver libraries.
#include "vkIcd.h" struct { VK_LOADER_DATA reservedForLoader; // Reserve space for pointer to loader's dispatch table myObjectClass myObj; // Your driver's C++ class } vkObj; vkObj alloc_icd_obj() { vkObj *newObj = alloc_obj(); ... // Initialize pointer to loader's dispatch table with ICD_LOADER_MAGIC set_loader_magic_value(newObj); ... return newObj; }
Additional Notes:
See file LinuxICDs.txt and WindowsICDs.txt for description of how the loader finds layer libraries.
TBD