| 1 |
/* |
| 2 |
* Copyright 2015-2023 The Khronos Group Inc. |
| 3 |
* Copyright 2015-2023 Valve Corporation |
| 4 |
* Copyright 2015-2023 LunarG, Inc. |
| 5 |
* |
| 6 |
* SPDX-License-Identifier: Apache-2.0 |
| 7 |
*/ |
| 8 |
#pragma once |
| 9 |
|
| 10 |
/* Need to define dispatch table |
| 11 |
* Core struct can then have ptr to dispatch table at the top |
| 12 |
* Along with object ptrs for current and next OBJ |
| 13 |
*/ |
| 14 |
|
| 15 |
#include "vulkan_core.h" |
| 16 |
|
| 17 |
#define MAX_NUM_UNKNOWN_EXTS 250 |
| 18 |
|
| 19 |
// Loader-Layer version negotiation API. Versions add the following features: |
| 20 |
// Versions 0/1 - Initial. Doesn't support vk_layerGetPhysicalDeviceProcAddr |
| 21 |
// or vk_icdNegotiateLoaderLayerInterfaceVersion. |
| 22 |
// Version 2 - Add support for vk_layerGetPhysicalDeviceProcAddr and |
| 23 |
// vk_icdNegotiateLoaderLayerInterfaceVersion. |
| 24 |
#define CURRENT_LOADER_LAYER_INTERFACE_VERSION 2 |
| 25 |
#define MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION 1 |
| 26 |
|
| 27 |
#define VK_CURRENT_CHAIN_VERSION 1 |
| 28 |
|
| 29 |
// Typedef for use in the interfaces below |
| 30 |
#ifndef IS_DEFINED_PFN_GetPhysicalDeviceProcAddr |
| 31 |
typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName); |
| 32 |
#define IS_DEFINED_PFN_GetPhysicalDeviceProcAddr |
| 33 |
#endif |
| 34 |
|
| 35 |
// Version negotiation values |
| 36 |
typedef enum VkNegotiateLayerStructType { |
| 37 |
LAYER_NEGOTIATE_UNINTIALIZED = 0, |
| 38 |
LAYER_NEGOTIATE_INTERFACE_STRUCT = 1, |
| 39 |
} VkNegotiateLayerStructType; |
| 40 |
|
| 41 |
// Version negotiation structures |
| 42 |
typedef struct VkNegotiateLayerInterface { |
| 43 |
VkNegotiateLayerStructType sType; |
| 44 |
void *pNext; |
| 45 |
uint32_t loaderLayerInterfaceVersion; |
| 46 |
PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr; |
| 47 |
PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr; |
| 48 |
PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr; |
| 49 |
} VkNegotiateLayerInterface; |
| 50 |
|
| 51 |
// Version negotiation functions |
| 52 |
typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderLayerInterfaceVersion)(VkNegotiateLayerInterface *pVersionStruct); |
| 53 |
|
| 54 |
// Function prototype for unknown physical device extension command |
| 55 |
typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device); |
| 56 |
|
| 57 |
// ------------------------------------------------------------------------------------------------ |
| 58 |
// CreateInstance and CreateDevice support structures |
| 59 |
|
| 60 |
/* Sub type of structure for instance and device loader ext of CreateInfo. |
| 61 |
* When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO |
| 62 |
* or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO |
| 63 |
* then VkLayerFunction indicates struct type pointed to by pNext |
| 64 |
*/ |
| 65 |
typedef enum VkLayerFunction_ { |
| 66 |
VK_LAYER_LINK_INFO = 0, |
| 67 |
VK_LOADER_DATA_CALLBACK = 1, |
| 68 |
VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK = 2, |
| 69 |
VK_LOADER_FEATURES = 3, |
| 70 |
} VkLayerFunction; |
| 71 |
|
| 72 |
typedef struct VkLayerInstanceLink_ { |
| 73 |
struct VkLayerInstanceLink_ *pNext; |
| 74 |
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; |
| 75 |
PFN_GetPhysicalDeviceProcAddr pfnNextGetPhysicalDeviceProcAddr; |
| 76 |
} VkLayerInstanceLink; |
| 77 |
|
| 78 |
/* |
| 79 |
* When creating the device chain the loader needs to pass |
| 80 |
* down information about it's device structure needed at |
| 81 |
* the end of the chain. Passing the data via the |
| 82 |
* VkLayerDeviceInfo avoids issues with finding the |
| 83 |
* exact instance being used. |
| 84 |
*/ |
| 85 |
typedef struct VkLayerDeviceInfo_ { |
| 86 |
void *device_info; |
| 87 |
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; |
| 88 |
} VkLayerDeviceInfo; |
| 89 |
|
| 90 |
typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance, |
| 91 |
void *object); |
| 92 |
typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device, |
| 93 |
void *object); |
| 94 |
typedef VkResult (VKAPI_PTR *PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 95 |
const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA); |
| 96 |
typedef void (VKAPI_PTR *PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction); |
| 97 |
|
| 98 |
typedef enum VkLoaderFeastureFlagBits { |
| 99 |
VK_LOADER_FEATURE_PHYSICAL_DEVICE_SORTING = 0x00000001, |
| 100 |
} VkLoaderFlagBits; |
| 101 |
typedef VkFlags VkLoaderFeatureFlags; |
| 102 |
|
| 103 |
typedef struct { |
| 104 |
VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO |
| 105 |
const void *pNext; |
| 106 |
VkLayerFunction function; |
| 107 |
union { |
| 108 |
VkLayerInstanceLink *pLayerInfo; |
| 109 |
PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData; |
| 110 |
struct { |
| 111 |
PFN_vkLayerCreateDevice pfnLayerCreateDevice; |
| 112 |
PFN_vkLayerDestroyDevice pfnLayerDestroyDevice; |
| 113 |
} layerDevice; |
| 114 |
VkLoaderFeatureFlags loaderFeatures; |
| 115 |
} u; |
| 116 |
} VkLayerInstanceCreateInfo; |
| 117 |
|
| 118 |
typedef struct VkLayerDeviceLink_ { |
| 119 |
struct VkLayerDeviceLink_ *pNext; |
| 120 |
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; |
| 121 |
PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr; |
| 122 |
} VkLayerDeviceLink; |
| 123 |
|
| 124 |
typedef struct { |
| 125 |
VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO |
| 126 |
const void *pNext; |
| 127 |
VkLayerFunction function; |
| 128 |
union { |
| 129 |
VkLayerDeviceLink *pLayerInfo; |
| 130 |
PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData; |
| 131 |
} u; |
| 132 |
} VkLayerDeviceCreateInfo; |
| 133 |
|
| 134 |
#ifdef __cplusplus |
| 135 |
extern "C" { |
| 136 |
#endif |
| 137 |
|
| 138 |
VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct); |
| 139 |
|
| 140 |
typedef enum VkChainType { |
| 141 |
VK_CHAIN_TYPE_UNKNOWN = 0, |
| 142 |
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES = 1, |
| 143 |
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES = 2, |
| 144 |
VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION = 3, |
| 145 |
} VkChainType; |
| 146 |
|
| 147 |
typedef struct VkChainHeader { |
| 148 |
VkChainType type; |
| 149 |
uint32_t version; |
| 150 |
uint32_t size; |
| 151 |
} VkChainHeader; |
| 152 |
|
| 153 |
typedef struct VkEnumerateInstanceExtensionPropertiesChain { |
| 154 |
VkChainHeader header; |
| 155 |
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *, const char *, uint32_t *, |
| 156 |
VkExtensionProperties *); |
| 157 |
const struct VkEnumerateInstanceExtensionPropertiesChain *pNextLink; |
| 158 |
|
| 159 |
#if defined(__cplusplus) |
| 160 |
inline VkResult CallDown(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const { |
| 161 |
return pfnNextLayer(pNextLink, pLayerName, pPropertyCount, pProperties); |
| 162 |
} |
| 163 |
#endif |
| 164 |
} VkEnumerateInstanceExtensionPropertiesChain; |
| 165 |
|
| 166 |
typedef struct VkEnumerateInstanceLayerPropertiesChain { |
| 167 |
VkChainHeader header; |
| 168 |
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *, uint32_t *, VkLayerProperties *); |
| 169 |
const struct VkEnumerateInstanceLayerPropertiesChain *pNextLink; |
| 170 |
|
| 171 |
#if defined(__cplusplus) |
| 172 |
inline VkResult CallDown(uint32_t *pPropertyCount, VkLayerProperties *pProperties) const { |
| 173 |
return pfnNextLayer(pNextLink, pPropertyCount, pProperties); |
| 174 |
} |
| 175 |
#endif |
| 176 |
} VkEnumerateInstanceLayerPropertiesChain; |
| 177 |
|
| 178 |
typedef struct VkEnumerateInstanceVersionChain { |
| 179 |
VkChainHeader header; |
| 180 |
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceVersionChain *, uint32_t *); |
| 181 |
const struct VkEnumerateInstanceVersionChain *pNextLink; |
| 182 |
|
| 183 |
#if defined(__cplusplus) |
| 184 |
inline VkResult CallDown(uint32_t *pApiVersion) const { |
| 185 |
return pfnNextLayer(pNextLink, pApiVersion); |
| 186 |
} |
| 187 |
#endif |
| 188 |
} VkEnumerateInstanceVersionChain; |
| 189 |
|
| 190 |
#ifdef __cplusplus |
| 191 |
} |
| 192 |
#endif |