Jon Ashburn | 79113cc | 2014-12-01 14:22:40 -0700 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Jon Ashburn | 79113cc | 2014-12-01 14:22:40 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | */ |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 24 | #include <string.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <assert.h> |
| 27 | #include <unordered_map> |
Ian Elliott | 2d4ab1e | 2015-01-13 17:52:38 -0700 | [diff] [blame] | 28 | #include "loader_platform.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 29 | #include "vk_dispatch_table_helper.h" |
| 30 | #include "vkLayer.h" |
Ian Elliott | 655cad7 | 2015-02-12 17:08:34 -0700 | [diff] [blame] | 31 | // The following is #included again to catch certain OS-specific functions |
| 32 | // being used: |
| 33 | #include "loader_platform.h" |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 34 | |
Jon Ashburn | bacb0f5 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 35 | static std::unordered_map<void *, VkLayerDispatchTable *> tableMap; |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 36 | static std::unordered_map<void *, VkLayerInstanceDispatchTable *> tableInstanceMap; |
| 37 | |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 38 | /* Various dispatchable objects will use the same underlying dispatch table if they |
| 39 | * are created from that "parent" object. Thus use pointer to dispatch table |
| 40 | * as the key to these table maps. |
| 41 | * Instance -> PhysicalDevice |
| 42 | * Device -> CmdBuffer or Queue |
| 43 | * If use the object themselves as key to map then implies Create entrypoints have to be intercepted |
| 44 | * and a new key inserted into map */ |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 45 | static VkLayerInstanceDispatchTable * initLayerInstanceTable(const VkBaseLayerObject *instancew) |
| 46 | { |
| 47 | VkLayerInstanceDispatchTable *pTable; |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 48 | assert(instancew); |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 49 | VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instancew->baseObject; |
| 50 | |
| 51 | std::unordered_map<void *, VkLayerInstanceDispatchTable *>::const_iterator it = tableInstanceMap.find((void *) *ppDisp); |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 52 | if (it == tableInstanceMap.end()) |
| 53 | { |
| 54 | pTable = new VkLayerInstanceDispatchTable; |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 55 | tableInstanceMap[(void *) *ppDisp] = pTable; |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 56 | } else |
| 57 | { |
| 58 | return it->second; |
| 59 | } |
| 60 | |
| 61 | layer_init_instance_dispatch_table(pTable, (PFN_vkGetInstanceProcAddr) instancew->pGPA, (VkInstance) instancew->nextObject); |
| 62 | |
| 63 | return pTable; |
| 64 | } |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 65 | |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 66 | static VkLayerDispatchTable * initLayerTable(const VkBaseLayerObject *devw) |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 67 | { |
Jon Ashburn | bacb0f5 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 68 | VkLayerDispatchTable *pTable; |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 69 | assert(devw); |
| 70 | VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) (devw->baseObject); |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 71 | |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 72 | std::unordered_map<void *, VkLayerDispatchTable *>::const_iterator it = tableMap.find((void *) *ppDisp); |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 73 | if (it == tableMap.end()) |
| 74 | { |
Jon Ashburn | bacb0f5 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 75 | pTable = new VkLayerDispatchTable; |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 76 | tableMap[(void *) *ppDisp] = pTable; |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 77 | } else |
| 78 | { |
| 79 | return it->second; |
| 80 | } |
Chia-I Wu | aa4121f | 2015-01-04 23:11:43 +0800 | [diff] [blame] | 81 | |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 82 | layer_initialize_dispatch_table(pTable, (PFN_vkGetDeviceProcAddr) devw->pGPA, (VkDevice) devw->nextObject); |
Chia-I Wu | aa4121f | 2015-01-04 23:11:43 +0800 | [diff] [blame] | 83 | |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 84 | return pTable; |
| 85 | } |
| 86 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 87 | VK_LAYER_EXPORT VkResult VKAPI vkLayerExtension1(VkDevice device) |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 88 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 89 | printf("In vkLayerExtension1() call w/ device: %p\n", (void*)device); |
| 90 | printf("vkLayerExtension1 returning SUCCESS\n"); |
| 91 | return VK_SUCCESS; |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 92 | } |
| 93 | |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 94 | struct extProps { |
| 95 | uint32_t version; |
| 96 | const char * const name; |
| 97 | }; |
| 98 | #define BASIC_LAYER_EXT_ARRAY_SIZE 2 |
| 99 | static const struct extProps basicExts[BASIC_LAYER_EXT_ARRAY_SIZE] = { |
| 100 | // TODO what is the version? |
| 101 | 0x10, "Basic", |
| 102 | 0x10, "vkLayerExtension1" |
| 103 | }; |
| 104 | |
| 105 | VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo( |
| 106 | VkExtensionInfoType infoType, |
| 107 | uint32_t extensionIndex, |
| 108 | size_t* pDataSize, |
| 109 | void* pData) |
| 110 | { |
Jon Ashburn | 9fd4cc4 | 2015-04-10 14:33:07 -0600 | [diff] [blame] | 111 | /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */ |
| 112 | VkExtensionProperties *ext_props; |
| 113 | uint32_t *count; |
| 114 | |
| 115 | if (pDataSize == NULL) |
| 116 | return VK_ERROR_INVALID_POINTER; |
| 117 | |
| 118 | switch (infoType) { |
| 119 | case VK_EXTENSION_INFO_TYPE_COUNT: |
| 120 | *pDataSize = sizeof(uint32_t); |
| 121 | if (pData == NULL) |
| 122 | return VK_SUCCESS; |
| 123 | count = (uint32_t *) pData; |
| 124 | *count = BASIC_LAYER_EXT_ARRAY_SIZE; |
| 125 | break; |
| 126 | case VK_EXTENSION_INFO_TYPE_PROPERTIES: |
| 127 | *pDataSize = sizeof(VkExtensionProperties); |
| 128 | if (pData == NULL) |
| 129 | return VK_SUCCESS; |
| 130 | if (extensionIndex >= BASIC_LAYER_EXT_ARRAY_SIZE) |
| 131 | return VK_ERROR_INVALID_VALUE; |
| 132 | ext_props = (VkExtensionProperties *) pData; |
| 133 | ext_props->version = basicExts[extensionIndex].version; |
| 134 | strncpy(ext_props->extName, basicExts[extensionIndex].name, |
| 135 | VK_MAX_EXTENSION_NAME); |
| 136 | ext_props->extName[VK_MAX_EXTENSION_NAME - 1] = '\0'; |
| 137 | break; |
| 138 | default: |
| 139 | return VK_ERROR_INVALID_VALUE; |
| 140 | }; |
| 141 | |
| 142 | return VK_SUCCESS; |
| 143 | } |
| 144 | |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 145 | VK_LAYER_EXPORT VkResult VKAPI vkEnumeratePhysicalDevices( |
| 146 | VkInstance instance, |
| 147 | uint32_t* pPhysicalDeviceCount, |
| 148 | VkPhysicalDevice* pPhysicalDevices) |
| 149 | { |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 150 | VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) instance; |
| 151 | VkLayerInstanceDispatchTable *pInstTable = tableInstanceMap[*ppDisp]; |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 152 | printf("At start of wrapped vkEnumeratePhysicalDevices() call w/ inst: %p\n", (void*)instance); |
| 153 | VkResult result = pInstTable->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 154 | printf("Completed wrapped vkEnumeratePhysicalDevices() call w/ count %u\n", *pPhysicalDeviceCount); |
| 155 | return result; |
| 156 | } |
| 157 | |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 158 | VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice) |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 159 | { |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 160 | VkLayerInstanceDispatchTable **ppDisp = (VkLayerInstanceDispatchTable **) gpu; |
| 161 | VkLayerInstanceDispatchTable* pInstTable = tableInstanceMap[*ppDisp]; |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 162 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 163 | printf("At start of wrapped vkCreateDevice() call w/ gpu: %p\n", (void*)gpu); |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 164 | VkResult result = pInstTable->CreateDevice(gpu, pCreateInfo, pDevice); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 165 | printf("Completed wrapped vkCreateDevice() call w/ pDevice, Device %p: %p\n", (void*)pDevice, (void *) *pDevice); |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 166 | return result; |
| 167 | } |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 168 | |
Jon Ashburn | 9a8a2e2 | 2015-05-19 16:34:53 -0600 | [diff] [blame^] | 169 | /* hook DestroyDevice to remove tableMap entry */ |
| 170 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device) |
| 171 | { |
| 172 | VkLayerDispatchTable *pDisp = *(VkLayerDispatchTable **) device; |
| 173 | VkLayerDispatchTable *pTable = tableMap[pDisp]; |
| 174 | VkResult res = pTable->DestroyDevice(device); |
| 175 | tableMap.erase(pDisp); |
| 176 | return res; |
| 177 | } |
| 178 | |
| 179 | /* hook DestroyInstance to remove tableInstanceMap entry */ |
| 180 | VK_LAYER_EXPORT VkResult VKAPI vkDestroyInstance(VkInstance instance) |
| 181 | { |
| 182 | VkLayerInstanceDispatchTable *pDisp = *(VkLayerInstanceDispatchTable **) instance; |
| 183 | VkLayerInstanceDispatchTable *pTable = tableInstanceMap[pDisp]; |
| 184 | VkResult res = pTable->DestroyInstance(instance); |
| 185 | tableInstanceMap.erase(pDisp); |
| 186 | return res; |
| 187 | } |
| 188 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 189 | VK_LAYER_EXPORT VkResult VKAPI vkGetFormatInfo(VkDevice device, VkFormat format, VkFormatInfoType infoType, size_t* pDataSize, void* pData) |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 190 | { |
Jon Ashburn | fe7ff9c | 2015-05-15 16:40:25 -0600 | [diff] [blame] | 191 | VkLayerDispatchTable **ppDisp = (VkLayerDispatchTable **) device; |
| 192 | VkLayerDispatchTable* pTable = tableMap[*ppDisp]; |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 193 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 194 | printf("At start of wrapped vkGetFormatInfo() call w/ device: %p\n", (void*)device); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 195 | VkResult result = pTable->GetFormatInfo(device, format, infoType, pDataSize, pData); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 196 | printf("Completed wrapped vkGetFormatInfo() call w/ device: %p\n", (void*)device); |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 197 | return result; |
| 198 | } |
| 199 | |
Courtney Goeltzenleuchter | d9dc0c7 | 2015-04-20 11:04:54 -0600 | [diff] [blame] | 200 | VK_LAYER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalDevice gpu, size_t maxStringSize, size_t* pLayerCount, char* const* pOutLayers, void* pReserved) |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 201 | { |
| 202 | if (gpu != NULL) |
| 203 | { |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 204 | VkLayerInstanceDispatchTable* pTable = initLayerInstanceTable((const VkBaseLayerObject *) gpu); |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 205 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 206 | printf("At start of wrapped vkEnumerateLayers() call w/ gpu: %p\n", gpu); |
Courtney Goeltzenleuchter | d9dc0c7 | 2015-04-20 11:04:54 -0600 | [diff] [blame] | 207 | VkResult result = pTable->EnumerateLayers(gpu, maxStringSize, pLayerCount, pOutLayers, pReserved); |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 208 | return result; |
| 209 | } else |
| 210 | { |
Courtney Goeltzenleuchter | d9dc0c7 | 2015-04-20 11:04:54 -0600 | [diff] [blame] | 211 | if (pLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL || pReserved == NULL) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 212 | return VK_ERROR_INVALID_POINTER; |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 213 | |
| 214 | // Example of a layer that is only compatible with Intel's GPUs |
Jon Ashburn | bacb0f5 | 2015-04-06 10:58:22 -0600 | [diff] [blame] | 215 | VkBaseLayerObject* gpuw = (VkBaseLayerObject*) pReserved; |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 216 | PFN_vkGetPhysicalDeviceInfo fpGetGpuInfo; |
| 217 | VkPhysicalDeviceProperties gpuProps; |
| 218 | size_t dataSize = sizeof(VkPhysicalDeviceProperties); |
| 219 | fpGetGpuInfo = (PFN_vkGetPhysicalDeviceInfo) gpuw->pGPA((VkPhysicalDevice) gpuw->nextObject, "vkGetPhysicalDeviceInfo"); |
| 220 | fpGetGpuInfo((VkPhysicalDevice) gpuw->nextObject, VK_PHYSICAL_DEVICE_INFO_TYPE_PROPERTIES, &dataSize, &gpuProps); |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 221 | if (gpuProps.vendorId == 0x8086) |
| 222 | { |
Courtney Goeltzenleuchter | d9dc0c7 | 2015-04-20 11:04:54 -0600 | [diff] [blame] | 223 | *pLayerCount = 1; |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 224 | strncpy((char *) pOutLayers[0], "Basic", maxStringSize); |
| 225 | } else |
| 226 | { |
Courtney Goeltzenleuchter | d9dc0c7 | 2015-04-20 11:04:54 -0600 | [diff] [blame] | 227 | *pLayerCount = 0; |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 228 | } |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 229 | return VK_SUCCESS; |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 230 | } |
| 231 | } |
| 232 | |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 233 | VK_LAYER_EXPORT void * VKAPI vkGetDeviceProcAddr(VkDevice device, const char* pName) |
Jon Ashburn | 79113cc | 2014-12-01 14:22:40 -0700 | [diff] [blame] | 234 | { |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 235 | if (device == NULL) |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 236 | return NULL; |
Chia-I Wu | b665d94 | 2015-01-05 09:41:27 +0800 | [diff] [blame] | 237 | |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 238 | initLayerTable((const VkBaseLayerObject *) device); |
Chia-I Wu | b665d94 | 2015-01-05 09:41:27 +0800 | [diff] [blame] | 239 | |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 240 | if (!strcmp("vkGetDeviceProcAddr", pName)) |
| 241 | return (void *) vkGetDeviceProcAddr; |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 242 | if (!strcmp("vkGetFormatInfo", pName)) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 243 | return (void *) vkGetFormatInfo; |
Jon Ashburn | 9a8a2e2 | 2015-05-19 16:34:53 -0600 | [diff] [blame^] | 244 | if (!strcmp("vkDestroyDevice", pName)) |
| 245 | return (void *) vkDestroyDevice; |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 246 | if (!strcmp("vkLayerExtension1", pName)) |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 247 | return (void *) vkLayerExtension1; |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 248 | else { |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 249 | VkBaseLayerObject* devw = (VkBaseLayerObject *) device; |
| 250 | if (devw->pGPA == NULL) |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 251 | return NULL; |
Jon Ashburn | 8d1b0b5 | 2015-05-18 13:20:15 -0600 | [diff] [blame] | 252 | return devw->pGPA((VkObject) devw->nextObject, pName); |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | |
| 256 | VK_LAYER_EXPORT void * VKAPI vkGetInstanceProcAddr(VkInstance instance, const char* pName) |
| 257 | { |
| 258 | if (instance == NULL) |
| 259 | return NULL; |
| 260 | |
Jon Ashburn | 8c5cbcf | 2015-05-07 10:27:37 -0600 | [diff] [blame] | 261 | initLayerInstanceTable((const VkBaseLayerObject *) instance); |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 262 | |
| 263 | if (!strcmp("vkGetInstanceProcAddr", pName)) |
| 264 | return (void *) vkGetInstanceProcAddr; |
Jon Ashburn | 9a8a2e2 | 2015-05-19 16:34:53 -0600 | [diff] [blame^] | 265 | if (!strcmp("vkDestroyInstance", pName)) |
| 266 | return (void *) vkDestroyInstance; |
Jon Ashburn | 95a77ba | 2015-05-15 15:09:35 -0600 | [diff] [blame] | 267 | if (!strcmp("vkEnumeratePhysicalDevices", pName)) |
| 268 | return (void*) vkEnumeratePhysicalDevices; |
| 269 | if (!strcmp("vkGetGlobalExtensionInfo", pName)) |
Jon Ashburn | f6b33db | 2015-05-05 14:22:52 -0600 | [diff] [blame] | 270 | return (void*) vkGetGlobalExtensionInfo; |
| 271 | if (!strcmp("vkCreateDevice", pName)) |
| 272 | return (void *) vkCreateDevice; |
| 273 | if (!strcmp("vkEnumerateLayers", pName)) |
| 274 | return (void *) vkEnumerateLayers; |
| 275 | else { |
| 276 | VkBaseLayerObject* instancew = (VkBaseLayerObject *) instance; |
| 277 | if (instancew->pGPA == NULL) |
| 278 | return NULL; |
| 279 | return instancew->pGPA((VkObject) instancew->nextObject, pName); |
Jon Ashburn | 1fec424 | 2014-11-26 11:10:26 -0700 | [diff] [blame] | 280 | } |
| 281 | } |