5 * Copyright (c) 2015-2017 The Khronos Group Inc.
6 * Copyright (c) 2015-2017 Valve Corporation
7 * Copyright (c) 2015-2017 LunarG, Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 /* Need to define dispatch table
24 * Core struct can then have ptr to dispatch table at the top
25 * Along with object ptrs for current and next OBJ
30 #if defined(__GNUC__) && __GNUC__ >= 4
31 #define VK_LAYER_EXPORT __attribute__((visibility("default")))
32 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
33 #define VK_LAYER_EXPORT __attribute__((visibility("default")))
35 #define VK_LAYER_EXPORT
38 #define MAX_NUM_UNKNOWN_EXTS 250
40 // Loader-Layer version negotiation API. Versions add the following features:
41 // Versions 0/1 - Initial. Doesn't support vk_layerGetPhysicalDeviceProcAddr
42 // or vk_icdNegotiateLoaderLayerInterfaceVersion.
43 // Version 2 - Add support for vk_layerGetPhysicalDeviceProcAddr and
44 // vk_icdNegotiateLoaderLayerInterfaceVersion.
45 #define CURRENT_LOADER_LAYER_INTERFACE_VERSION 2
46 #define MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION 1
48 #define VK_CURRENT_CHAIN_VERSION 1
50 // Typedef for use in the interfaces below
51 typedef PFN_vkVoidFunction (VKAPI_PTR
*PFN_GetPhysicalDeviceProcAddr
)(VkInstance instance
, const char* pName
);
53 // Version negotiation values
54 typedef enum VkNegotiateLayerStructType
{
55 LAYER_NEGOTIATE_UNINTIALIZED
= 0,
56 LAYER_NEGOTIATE_INTERFACE_STRUCT
= 1,
57 } VkNegotiateLayerStructType
;
59 // Version negotiation structures
60 typedef struct VkNegotiateLayerInterface
{
61 VkNegotiateLayerStructType sType
;
63 uint32_t loaderLayerInterfaceVersion
;
64 PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr
;
65 PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr
;
66 PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr
;
67 } VkNegotiateLayerInterface
;
69 // Version negotiation functions
70 typedef VkResult (VKAPI_PTR
*PFN_vkNegotiateLoaderLayerInterfaceVersion
)(VkNegotiateLayerInterface
*pVersionStruct
);
72 // Function prototype for unknown physical device extension command
73 typedef VkResult(VKAPI_PTR
*PFN_PhysDevExt
)(VkPhysicalDevice phys_device
);
75 // ------------------------------------------------------------------------------------------------
76 // CreateInstance and CreateDevice support structures
78 /* Sub type of structure for instance and device loader ext of CreateInfo.
79 * When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
80 * or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
81 * then VkLayerFunction indicates struct type pointed to by pNext
83 typedef enum VkLayerFunction_
{
84 VK_LAYER_LINK_INFO
= 0,
85 VK_LOADER_DATA_CALLBACK
= 1,
86 VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK
= 2
89 typedef struct VkLayerInstanceLink_
{
90 struct VkLayerInstanceLink_
*pNext
;
91 PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr
;
92 PFN_GetPhysicalDeviceProcAddr pfnNextGetPhysicalDeviceProcAddr
;
93 } VkLayerInstanceLink
;
96 * When creating the device chain the loader needs to pass
97 * down information about it's device structure needed at
98 * the end of the chain. Passing the data via the
99 * VkLayerDeviceInfo avoids issues with finding the
100 * exact instance being used.
102 typedef struct VkLayerDeviceInfo_
{
104 PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr
;
107 typedef VkResult (VKAPI_PTR
*PFN_vkSetInstanceLoaderData
)(VkInstance instance
,
109 typedef VkResult (VKAPI_PTR
*PFN_vkSetDeviceLoaderData
)(VkDevice device
,
111 typedef VkResult (VKAPI_PTR
*PFN_vkLayerCreateDevice
)(VkInstance instance
, VkPhysicalDevice physicalDevice
, const VkDeviceCreateInfo
*pCreateInfo
,
112 const VkAllocationCallbacks
*pAllocator
, VkDevice
*pDevice
, PFN_vkGetInstanceProcAddr layerGIPA
, PFN_vkGetDeviceProcAddr
*nextGDPA
);
113 typedef void (VKAPI_PTR
*PFN_vkLayerDestroyDevice
)(VkDevice physicalDevice
, const VkAllocationCallbacks
*pAllocator
, PFN_vkDestroyDevice destroyFunction
);
115 VkStructureType sType
; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
117 VkLayerFunction function
;
119 VkLayerInstanceLink
*pLayerInfo
;
120 PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData
;
122 PFN_vkLayerCreateDevice pfnLayerCreateDevice
;
123 PFN_vkLayerDestroyDevice pfnLayerDestroyDevice
;
126 } VkLayerInstanceCreateInfo
;
128 typedef struct VkLayerDeviceLink_
{
129 struct VkLayerDeviceLink_
*pNext
;
130 PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr
;
131 PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr
;
135 VkStructureType sType
; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
137 VkLayerFunction function
;
139 VkLayerDeviceLink
*pLayerInfo
;
140 PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData
;
142 } VkLayerDeviceCreateInfo
;
148 VKAPI_ATTR VkResult VKAPI_CALL
vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface
*pVersionStruct
);
150 typedef enum VkChainType
{
151 VK_CHAIN_TYPE_UNKNOWN
= 0,
152 VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES
= 1,
153 VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES
= 2,
154 VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION
= 3,
157 typedef struct VkChainHeader
{
163 typedef struct VkEnumerateInstanceExtensionPropertiesChain
{
164 VkChainHeader header
;
165 VkResult(VKAPI_PTR
*pfnNextLayer
)(const struct VkEnumerateInstanceExtensionPropertiesChain
*, const char *, uint32_t *,
166 VkExtensionProperties
*);
167 const struct VkEnumerateInstanceExtensionPropertiesChain
*pNextLink
;
169 #if defined(__cplusplus)
170 inline VkResult
CallDown(const char *pLayerName
, uint32_t *pPropertyCount
, VkExtensionProperties
*pProperties
) const {
171 return pfnNextLayer(pNextLink
, pLayerName
, pPropertyCount
, pProperties
);
174 } VkEnumerateInstanceExtensionPropertiesChain
;
176 typedef struct VkEnumerateInstanceLayerPropertiesChain
{
177 VkChainHeader header
;
178 VkResult(VKAPI_PTR
*pfnNextLayer
)(const struct VkEnumerateInstanceLayerPropertiesChain
*, uint32_t *, VkLayerProperties
*);
179 const struct VkEnumerateInstanceLayerPropertiesChain
*pNextLink
;
181 #if defined(__cplusplus)
182 inline VkResult
CallDown(uint32_t *pPropertyCount
, VkLayerProperties
*pProperties
) const {
183 return pfnNextLayer(pNextLink
, pPropertyCount
, pProperties
);
186 } VkEnumerateInstanceLayerPropertiesChain
;
188 typedef struct VkEnumerateInstanceVersionChain
{
189 VkChainHeader header
;
190 VkResult(VKAPI_PTR
*pfnNextLayer
)(const struct VkEnumerateInstanceVersionChain
*, uint32_t *);
191 const struct VkEnumerateInstanceVersionChain
*pNextLink
;
193 #if defined(__cplusplus)
194 inline VkResult
CallDown(uint32_t *pApiVersion
) const {
195 return pfnNextLayer(pNextLink
, pApiVersion
);
198 } VkEnumerateInstanceVersionChain
;