Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 1 | // |
| 2 | // File: vk_layer.h |
| 3 | // |
| 4 | /* |
Mark Young | 0f183a8 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 5 | * Copyright (c) 2015-2017 The Khronos Group Inc. |
| 6 | * Copyright (c) 2015-2017 Valve Corporation |
| 7 | * Copyright (c) 2015-2017 LunarG, Inc. |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 8 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 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 |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 12 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 14 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 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. |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 20 | * |
| 21 | */ |
| 22 | |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 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 | |
Karl Schultz | 1aec29c | 2016-02-10 15:41:43 -0700 | [diff] [blame] | 29 | #include "vulkan.h" |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 30 | #if defined(__GNUC__) && __GNUC__ >= 4 |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 31 | #define VK_LAYER_EXPORT __attribute__((visibility("default"))) |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 32 | #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 33 | #define VK_LAYER_EXPORT __attribute__((visibility("default"))) |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 34 | #else |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 35 | #define VK_LAYER_EXPORT |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 36 | #endif |
| 37 | |
Mark Young | 0f183a8 | 2017-02-28 09:58:04 -0700 | [diff] [blame] | 38 | // Definition for VkLayerDispatchTable and VkLayerInstanceDispatchTable now appear in externally generated header |
| 39 | #include "vk_layer_dispatch_table.h" |
| 40 | |
Mark Young | 3938987 | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 41 | #define MAX_NUM_UNKNOWN_EXTS 250 |
| 42 | |
| 43 | // Loader-Layer version negotiation API. Versions add the following features: |
| 44 | // Versions 0/1 - Initial. Doesn't support vk_layerGetPhysicalDeviceProcAddr |
| 45 | // or vk_icdNegotiateLoaderLayerInterfaceVersion. |
| 46 | // Version 2 - Add support for vk_layerGetPhysicalDeviceProcAddr and |
| 47 | // vk_icdNegotiateLoaderLayerInterfaceVersion. |
| 48 | #define CURRENT_LOADER_LAYER_INTERFACE_VERSION 2 |
| 49 | #define MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION 1 |
| 50 | |
Lenny Komow | 3cf3ac7 | 2017-12-19 16:38:37 -0700 | [diff] [blame] | 51 | #define VK_CURRENT_CHAIN_VERSION 1 |
| 52 | |
Mark Young | 3938987 | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 53 | // Version negotiation values |
| 54 | typedef enum VkNegotiateLayerStructType { |
| 55 | LAYER_NEGOTIATE_UNINTIALIZED = 0, |
| 56 | LAYER_NEGOTIATE_INTERFACE_STRUCT = 1, |
| 57 | } VkNegotiateLayerStructType; |
| 58 | |
| 59 | // Version negotiation structures |
| 60 | typedef struct VkNegotiateLayerInterface { |
| 61 | VkNegotiateLayerStructType sType; |
| 62 | void *pNext; |
| 63 | uint32_t loaderLayerInterfaceVersion; |
| 64 | PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr; |
| 65 | PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr; |
| 66 | PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr; |
| 67 | } VkNegotiateLayerInterface; |
| 68 | |
| 69 | // Version negotiation functions |
| 70 | typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderLayerInterfaceVersion)(VkNegotiateLayerInterface *pVersionStruct); |
| 71 | |
| 72 | // Function prototype for unknown physical device extension command |
Mark Young | c0e0b1c | 2017-04-05 15:58:44 -0600 | [diff] [blame] | 73 | typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device); |
Mark Young | 3938987 | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 74 | |
Courtney Goeltzenleuchter | 64d1a71 | 2015-04-08 18:04:29 -0600 | [diff] [blame] | 75 | // ------------------------------------------------------------------------------------------------ |
Courtney Goeltzenleuchter | 8286acc | 2016-01-08 11:40:27 -0700 | [diff] [blame] | 76 | // CreateInstance and CreateDevice support structures |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 77 | |
Jon Ashburn | c3c5877 | 2016-03-29 11:16:01 -0600 | [diff] [blame] | 78 | /* Sub type of structure for instance and device loader ext of CreateInfo. |
ttyio | 37c6484 | 2016-04-10 22:07:28 +0800 | [diff] [blame] | 79 | * When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO |
| 80 | * or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO |
Jon Ashburn | c3c5877 | 2016-03-29 11:16:01 -0600 | [diff] [blame] | 81 | * then VkLayerFunction indicates struct type pointed to by pNext |
| 82 | */ |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 83 | typedef enum VkLayerFunction_ { |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 84 | VK_LAYER_LINK_INFO = 0, |
Jon Ashburn | ed8f231 | 2016-03-31 10:52:22 -0600 | [diff] [blame] | 85 | VK_LOADER_DATA_CALLBACK = 1 |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 86 | } VkLayerFunction; |
| 87 | |
Courtney Goeltzenleuchter | 8286acc | 2016-01-08 11:40:27 -0700 | [diff] [blame] | 88 | typedef struct VkLayerInstanceLink_ { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 89 | struct VkLayerInstanceLink_ *pNext; |
Courtney Goeltzenleuchter | 8286acc | 2016-01-08 11:40:27 -0700 | [diff] [blame] | 90 | PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; |
Mark Young | 3938987 | 2017-01-19 21:10:49 -0700 | [diff] [blame] | 91 | PFN_GetPhysicalDeviceProcAddr pfnNextGetPhysicalDeviceProcAddr; |
Courtney Goeltzenleuchter | 8286acc | 2016-01-08 11:40:27 -0700 | [diff] [blame] | 92 | } VkLayerInstanceLink; |
| 93 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 94 | /* |
| 95 | * When creating the device chain the loader needs to pass |
| 96 | * down information about it's device structure needed at |
| 97 | * the end of the chain. Passing the data via the |
| 98 | * VkLayerDeviceInfo avoids issues with finding the |
| 99 | * exact instance being used. |
| 100 | */ |
| 101 | typedef struct VkLayerDeviceInfo_ { |
| 102 | void *device_info; |
| 103 | PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; |
| 104 | } VkLayerDeviceInfo; |
| 105 | |
Jon Ashburn | c3c5877 | 2016-03-29 11:16:01 -0600 | [diff] [blame] | 106 | typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance, |
| 107 | void *object); |
Jon Ashburn | ed8f231 | 2016-03-31 10:52:22 -0600 | [diff] [blame] | 108 | typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device, |
| 109 | void *object); |
Jon Ashburn | c3c5877 | 2016-03-29 11:16:01 -0600 | [diff] [blame] | 110 | |
Courtney Goeltzenleuchter | 8286acc | 2016-01-08 11:40:27 -0700 | [diff] [blame] | 111 | typedef struct { |
Vinjn Zhang | e589144 | 2016-04-06 15:38:24 +0800 | [diff] [blame] | 112 | VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 113 | const void *pNext; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 114 | VkLayerFunction function; |
| 115 | union { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 116 | VkLayerInstanceLink *pLayerInfo; |
Jon Ashburn | c3c5877 | 2016-03-29 11:16:01 -0600 | [diff] [blame] | 117 | PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 118 | } u; |
Courtney Goeltzenleuchter | 8286acc | 2016-01-08 11:40:27 -0700 | [diff] [blame] | 119 | } VkLayerInstanceCreateInfo; |
| 120 | |
| 121 | typedef struct VkLayerDeviceLink_ { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 122 | struct VkLayerDeviceLink_ *pNext; |
Courtney Goeltzenleuchter | 8286acc | 2016-01-08 11:40:27 -0700 | [diff] [blame] | 123 | PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; |
| 124 | PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr; |
| 125 | } VkLayerDeviceLink; |
| 126 | |
| 127 | typedef struct { |
Vinjn Zhang | e589144 | 2016-04-06 15:38:24 +0800 | [diff] [blame] | 128 | VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 129 | const void *pNext; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 130 | VkLayerFunction function; |
| 131 | union { |
Karl Schultz | 37419ed | 2016-02-02 12:32:50 -0700 | [diff] [blame] | 132 | VkLayerDeviceLink *pLayerInfo; |
Jon Ashburn | ed8f231 | 2016-03-31 10:52:22 -0600 | [diff] [blame] | 133 | PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData; |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 134 | } u; |
Courtney Goeltzenleuchter | 8286acc | 2016-01-08 11:40:27 -0700 | [diff] [blame] | 135 | } VkLayerDeviceCreateInfo; |
| 136 | |
Mark Young | 21aa6d6 | 2017-03-29 13:39:27 -0600 | [diff] [blame] | 137 | #ifdef __cplusplus |
| 138 | extern "C" { |
| 139 | #endif |
| 140 | |
| 141 | VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct); |
| 142 | |
Lenny Komow | 3cf3ac7 | 2017-12-19 16:38:37 -0700 | [diff] [blame] | 143 | typedef enum VkChainType { |
| 144 | VK_CHAIN_TYPE_UNKNOWN = 0, |
| 145 | VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES = 1, |
| 146 | VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES = 2, |
| 147 | } VkChainType; |
| 148 | |
| 149 | typedef struct VkChainHeader { |
| 150 | VkChainType type; |
| 151 | uint32_t version; |
| 152 | uint32_t size; |
| 153 | } VkChainHeader; |
| 154 | |
| 155 | typedef struct VkEnumerateInstanceExtensionPropertiesChain { |
| 156 | VkChainHeader header; |
| 157 | VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *, const char *, uint32_t *, |
| 158 | VkExtensionProperties *); |
| 159 | const struct VkEnumerateInstanceExtensionPropertiesChain *pNextLink; |
| 160 | |
| 161 | #if defined(__cplusplus) |
| 162 | inline VkResult CallDown(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const { |
| 163 | return pfnNextLayer(pNextLink, pLayerName, pPropertyCount, pProperties); |
| 164 | } |
| 165 | #endif |
| 166 | } VkEnumerateInstanceExtensionPropertiesChain; |
| 167 | |
| 168 | typedef struct VkEnumerateInstanceLayerPropertiesChain { |
| 169 | VkChainHeader header; |
| 170 | VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *, uint32_t *, VkLayerProperties *); |
| 171 | const struct VkEnumerateInstanceLayerPropertiesChain *pNextLink; |
| 172 | |
| 173 | #if defined(__cplusplus) |
| 174 | inline VkResult CallDown(uint32_t *pPropertyCount, VkLayerProperties *pProperties) const { |
| 175 | return pfnNextLayer(pNextLink, pPropertyCount, pProperties); |
| 176 | } |
| 177 | #endif |
| 178 | } VkEnumerateInstanceLayerPropertiesChain; |
| 179 | |
Mark Young | 21aa6d6 | 2017-03-29 13:39:27 -0600 | [diff] [blame] | 180 | #ifdef __cplusplus |
| 181 | } |
| 182 | #endif |