HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vk_layer.h
Go to the documentation of this file.
1 //
2 // File: vk_layer.h
3 //
4 /*
5  * Copyright (c) 2015-2017 The Khronos Group Inc.
6  * Copyright (c) 2015-2017 Valve Corporation
7  * Copyright (c) 2015-2017 LunarG, Inc.
8  *
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
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
21  */
22 
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
26  */
27 #pragma once
28 
29 #include "vulkan.h"
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")))
34 #else
35 #define VK_LAYER_EXPORT
36 #endif
37 
38 #define MAX_NUM_UNKNOWN_EXTS 250
39 
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
47 
48 #define VK_CURRENT_CHAIN_VERSION 1
49 
50 // Typedef for use in the interfaces below
51 typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName);
52 
53 // Version negotiation values
58 
59 // Version negotiation structures
60 typedef struct VkNegotiateLayerInterface {
62  void *pNext;
68 
69 // Version negotiation functions
71 
72 // Function prototype for unknown physical device extension command
73 typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device);
74 
75 // ------------------------------------------------------------------------------------------------
76 // CreateInstance and CreateDevice support structures
77 
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
82  */
83 typedef enum VkLayerFunction_ {
89 
90 typedef struct VkLayerInstanceLink_ {
95 
96 /*
97  * When creating the device chain the loader needs to pass
98  * down information about it's device structure needed at
99  * the end of the chain. Passing the data via the
100  * VkLayerDeviceInfo avoids issues with finding the
101  * exact instance being used.
102  */
103 typedef struct VkLayerDeviceInfo_ {
104  void *device_info;
107 
108 typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance,
109  void *object);
110 typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device,
111  void *object);
112 typedef VkResult (VKAPI_PTR *PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
113  const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA);
114 typedef void (VKAPI_PTR *PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction);
115 
120 
121 typedef struct {
122  VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO
123  const void *pNext;
124  VkLayerFunction function;
125  union {
128  struct {
131  } layerDevice;
133  } u;
135 
136 typedef struct VkLayerDeviceLink_ {
141 
142 typedef struct {
143  VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO
144  const void *pNext;
145  VkLayerFunction function;
146  union {
149  } u;
151 
152 #ifdef __cplusplus
153 extern "C" {
154 #endif
155 
157 
158 typedef enum VkChainType {
163 } VkChainType;
164 
165 typedef struct VkChainHeader {
167  uint32_t version;
168  uint32_t size;
169 } VkChainHeader;
170 
173  VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *, const char *, uint32_t *,
176 
177 #if defined(__cplusplus)
178  inline VkResult CallDown(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const {
179  return pfnNextLayer(pNextLink, pLayerName, pPropertyCount, pProperties);
180  }
181 #endif
183 
186  VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *, uint32_t *, VkLayerProperties *);
188 
189 #if defined(__cplusplus)
190  inline VkResult CallDown(uint32_t *pPropertyCount, VkLayerProperties *pProperties) const {
191  return pfnNextLayer(pNextLink, pPropertyCount, pProperties);
192  }
193 #endif
195 
198  VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceVersionChain *, uint32_t *);
200 
201 #if defined(__cplusplus)
202  inline VkResult CallDown(uint32_t *pApiVersion) const {
203  return pfnNextLayer(pNextLink, pApiVersion);
204  }
205 #endif
207 
208 #ifdef __cplusplus
209 }
210 #endif
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *
VkStructureType
Definition: vulkan_core.h:208
uint32_t size
Definition: vk_layer.h:168
struct VkLayerInstanceLink_ VkLayerInstanceLink
PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr
Definition: vk_layer.h:66
uint32_t VkLayerProperties *const struct VkEnumerateInstanceLayerPropertiesChain * pNextLink
Definition: vk_layer.h:187
VkResult
Definition: vulkan_core.h:139
VkFlags VkLoaderFeatureFlags
Definition: vk_layer.h:119
#define VKAPI_CALL
Definition: vk_platform.h:57
PFN_vkLayerCreateDevice pfnLayerCreateDevice
Definition: vk_layer.h:129
struct VkEnumerateInstanceVersionChain VkEnumerateInstanceVersionChain
void
Definition: png.h:1083
struct VkEnumerateInstanceLayerPropertiesChain VkEnumerateInstanceLayerPropertiesChain
PFN_vkVoidFunction(VKAPI_PTR * PFN_vkGetDeviceProcAddr)(VkDevice device, const char *pName)
Definition: vulkan_core.h:3916
VkResult(VKAPI_PTR * PFN_PhysDevExt)(VkPhysicalDevice phys_device)
Definition: vk_layer.h:73
struct VkEnumerateInstanceExtensionPropertiesChain VkEnumerateInstanceExtensionPropertiesChain
const char uint32_t VkExtensionProperties *const struct VkEnumerateInstanceExtensionPropertiesChain * pNextLink
Definition: vk_layer.h:175
PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr
Definition: vk_layer.h:105
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceVersionChain *
VkNegotiateLayerStructType sType
Definition: vk_layer.h:61
VkLoaderFeatureFlags loaderFeatures
Definition: vk_layer.h:132
#define VKAPI_PTR
Definition: vk_platform.h:58
#define VKAPI_ATTR
Definition: vk_platform.h:56
PFN_vkVoidFunction(VKAPI_PTR * PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName)
Definition: vk_layer.h:51
PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData
Definition: vk_layer.h:127
VkNegotiateLayerStructType
Definition: vk_layer.h:54
VkChainType
Definition: vk_layer.h:158
struct VkChainHeader VkChainHeader
VkChainType type
Definition: vk_layer.h:166
enum VkLoaderFeastureFlagBits VkLoaderFlagBits
void(VKAPI_PTR * PFN_vkVoidFunction)(void)
Definition: vulkan_core.h:2918
VkLayerInstanceLink * pLayerInfo
Definition: vk_layer.h:126
VkResult(VKAPI_PTR * PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA)
Definition: vk_layer.h:112
PFN_vkVoidFunction(VKAPI_PTR * PFN_vkGetInstanceProcAddr)(VkInstance instance, const char *pName)
Definition: vulkan_core.h:3915
PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr
Definition: vk_layer.h:64
uint32_t *const struct VkEnumerateInstanceVersionChain * pNextLink
Definition: vk_layer.h:199
VkResult(VKAPI_PTR * PFN_vkSetDeviceLoaderData)(VkDevice device, void *object)
Definition: vk_layer.h:110
uint32_t version
Definition: vk_layer.h:167
struct VkLayerDeviceInfo_ VkLayerDeviceInfo
uint32_t loaderLayerInterfaceVersion
Definition: vk_layer.h:63
PFN_vkLayerDestroyDevice pfnLayerDestroyDevice
Definition: vk_layer.h:130
void(VKAPI_PTR * PFN_vkDestroyDevice)(VkDevice device, const VkAllocationCallbacks *pAllocator)
Definition: vulkan_core.h:3918
PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr
Definition: vk_layer.h:65
const void * pNext
Definition: vk_layer.h:144
VkLayerFunction_
Definition: vk_layer.h:83
uint32_t VkFlags
Definition: vulkan_core.h:96
PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData
Definition: vk_layer.h:148
VkStructureType sType
Definition: vk_layer.h:143
VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct)
VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *
VkStructureType sType
Definition: vk_layer.h:122
void(VKAPI_PTR * PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction)
Definition: vk_layer.h:114
void * device_info
Definition: vk_layer.h:104
VkResult(VKAPI_PTR * PFN_vkNegotiateLoaderLayerInterfaceVersion)(VkNegotiateLayerInterface *pVersionStruct)
Definition: vk_layer.h:70
struct VkLayerDeviceLink_ VkLayerDeviceLink
VkLayerDeviceLink * pLayerInfo
Definition: vk_layer.h:147
enum VkLayerFunction_ VkLayerFunction
VkLoaderFeastureFlagBits
Definition: vk_layer.h:116
VkResult(VKAPI_PTR * PFN_vkSetInstanceLoaderData)(VkInstance instance, void *object)
Definition: vk_layer.h:108
struct VkNegotiateLayerInterface VkNegotiateLayerInterface