Jon Ashburn | 2139a3e | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Vulkan |
| 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 | */ |
| 24 | |
| 25 | #include <string.h> |
| 26 | |
| 27 | static inline void* globalGetProcAddr(const char *name) |
| 28 | { |
| 29 | if (!name || name[0] != 'v' || name[1] != 'k') |
| 30 | return NULL; |
| 31 | |
| 32 | name += 2; |
| 33 | if (!strcmp(name, "CreateInstance")) |
| 34 | return (void*) vkCreateInstance; |
| 35 | if (!strcmp(name, "DestroyInstance")) |
| 36 | return (void*) vkDestroyInstance; |
| 37 | if (!strcmp(name, "EnumeratePhysicalDevices")) |
| 38 | return (void*) vkEnumeratePhysicalDevices; |
| 39 | if (!strcmp(name, "GetPhysicalDeviceInfo")) |
| 40 | return (void*) vkGetPhysicalDeviceInfo; |
Jon Ashburn | 53c1677 | 2015-05-06 10:15:07 -0600 | [diff] [blame] | 41 | if (!strcmp(name, "GetInstanceProcAddr")) |
| 42 | return (void*) vkGetInstanceProcAddr; |
Jon Ashburn | 2139a3e | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 43 | if (!strcmp(name, "GetProcAddr")) |
| 44 | return (void*) vkGetProcAddr; |
| 45 | if (!strcmp(name, "CreateDevice")) |
| 46 | return (void*) vkCreateDevice; |
| 47 | if (!strcmp(name, "DestroyDevice")) |
| 48 | return (void*) vkDestroyDevice; |
| 49 | if (!strcmp(name, "GetGlobalExtensionInfo")) |
| 50 | return (void*) vkGetGlobalExtensionInfo; |
| 51 | if (!strcmp(name, "GetPhysicalDeviceExtensionInfo")) |
| 52 | return (void*) vkGetPhysicalDeviceExtensionInfo; |
| 53 | if (!strcmp(name, "EnumerateLayers")) |
| 54 | return (void*) vkEnumerateLayers; |
| 55 | if (!strcmp(name, "GetDeviceQueue")) |
| 56 | return (void*) vkGetDeviceQueue; |
| 57 | if (!strcmp(name, "QueueSubmit")) |
| 58 | return (void*) vkQueueSubmit; |
| 59 | if (!strcmp(name, "QueueWaitIdle")) |
| 60 | return (void*) vkQueueWaitIdle; |
| 61 | if (!strcmp(name, "DeviceWaitIdle")) |
| 62 | return (void*) vkDeviceWaitIdle; |
| 63 | if (!strcmp(name, "AllocMemory")) |
| 64 | return (void*) vkAllocMemory; |
| 65 | if (!strcmp(name, "FreeMemory")) |
| 66 | return (void*) vkFreeMemory; |
| 67 | if (!strcmp(name, "SetMemoryPriority")) |
| 68 | return (void*) vkSetMemoryPriority; |
| 69 | if (!strcmp(name, "MapMemory")) |
| 70 | return (void*) vkMapMemory; |
| 71 | if (!strcmp(name, "UnmapMemory")) |
| 72 | return (void*) vkUnmapMemory; |
| 73 | if (!strcmp(name, "FlushMappedMemoryRanges")) |
| 74 | return (void*) vkFlushMappedMemoryRanges; |
| 75 | if (!strcmp(name, "InvalidateMappedMemoryRanges")) |
| 76 | return (void*) vkInvalidateMappedMemoryRanges; |
| 77 | if (!strcmp(name, "PinSystemMemory")) |
| 78 | return (void*) vkPinSystemMemory; |
| 79 | if (!strcmp(name, "GetMultiDeviceCompatibility")) |
| 80 | return (void*) vkGetMultiDeviceCompatibility; |
| 81 | if (!strcmp(name, "OpenSharedMemory")) |
| 82 | return (void*) vkOpenSharedMemory; |
| 83 | if (!strcmp(name, "OpenSharedSemaphore")) |
| 84 | return (void*) vkOpenSharedSemaphore; |
| 85 | if (!strcmp(name, "OpenPeerMemory")) |
| 86 | return (void*) vkOpenPeerMemory; |
| 87 | if (!strcmp(name, "OpenPeerImage")) |
| 88 | return (void*) vkOpenPeerImage; |
| 89 | if (!strcmp(name, "DestroyObject")) |
| 90 | return (void*) vkDestroyObject; |
| 91 | if (!strcmp(name, "GetObjectInfo")) |
| 92 | return (void*) vkGetObjectInfo; |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 93 | if (!strcmp(name, "BindObjectMemory")) |
| 94 | return (void*) vkBindObjectMemory; |
| 95 | if (!strcmp(name, "QueueBindSparseBufferMemory")) |
| 96 | return (void*) vkQueueBindSparseBufferMemory; |
| 97 | if (!strcmp(name, "QueueBindSparseImageMemory")) |
| 98 | return (void*) vkQueueBindSparseImageMemory; |
Jon Ashburn | 2139a3e | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 99 | if (!strcmp(name, "CreateFence")) |
| 100 | return (void*) vkCreateFence; |
| 101 | if (!strcmp(name, "ResetFences")) |
| 102 | return (void*) vkResetFences; |
| 103 | if (!strcmp(name, "GetFenceStatus")) |
| 104 | return (void*) vkGetFenceStatus; |
| 105 | if (!strcmp(name, "WaitForFences")) |
| 106 | return (void*) vkWaitForFences; |
| 107 | if (!strcmp(name, "CreateSemaphore")) |
| 108 | return (void*) vkCreateSemaphore; |
| 109 | if (!strcmp(name, "QueueSignalSemaphore")) |
| 110 | return (void*) vkQueueSignalSemaphore; |
| 111 | if (!strcmp(name, "QueueWaitSemaphore")) |
| 112 | return (void*) vkQueueWaitSemaphore; |
| 113 | if (!strcmp(name, "CreateEvent")) |
| 114 | return (void*) vkCreateEvent; |
| 115 | if (!strcmp(name, "GetEventStatus")) |
| 116 | return (void*) vkGetEventStatus; |
| 117 | if (!strcmp(name, "SetEvent")) |
| 118 | return (void*) vkSetEvent; |
| 119 | if (!strcmp(name, "ResetEvent")) |
| 120 | return (void*) vkResetEvent; |
| 121 | if (!strcmp(name, "CreateQueryPool")) |
| 122 | return (void*) vkCreateQueryPool; |
| 123 | if (!strcmp(name, "GetQueryPoolResults")) |
| 124 | return (void*) vkGetQueryPoolResults; |
| 125 | if (!strcmp(name, "GetFormatInfo")) |
| 126 | return (void*) vkGetFormatInfo; |
| 127 | if (!strcmp(name, "CreateBuffer")) |
| 128 | return (void*) vkCreateBuffer; |
| 129 | if (!strcmp(name, "CreateBufferView")) |
| 130 | return (void*) vkCreateBufferView; |
| 131 | if (!strcmp(name, "CreateImage")) |
| 132 | return (void*) vkCreateImage; |
| 133 | if (!strcmp(name, "GetImageSubresourceInfo")) |
| 134 | return (void*) vkGetImageSubresourceInfo; |
| 135 | if (!strcmp(name, "CreateImageView")) |
| 136 | return (void*) vkCreateImageView; |
| 137 | if (!strcmp(name, "CreateColorAttachmentView")) |
| 138 | return (void*) vkCreateColorAttachmentView; |
| 139 | if (!strcmp(name, "CreateDepthStencilView")) |
| 140 | return (void*) vkCreateDepthStencilView; |
| 141 | if (!strcmp(name, "CreateShader")) |
| 142 | return (void*) vkCreateShader; |
| 143 | if (!strcmp(name, "CreateGraphicsPipeline")) |
| 144 | return (void*) vkCreateGraphicsPipeline; |
| 145 | if (!strcmp(name, "CreateGraphicsPipelineDerivative")) |
| 146 | return (void*) vkCreateGraphicsPipelineDerivative; |
| 147 | if (!strcmp(name, "CreateComputePipeline")) |
| 148 | return (void*) vkCreateComputePipeline; |
| 149 | if (!strcmp(name, "StorePipeline")) |
| 150 | return (void*) vkStorePipeline; |
| 151 | if (!strcmp(name, "LoadPipeline")) |
| 152 | return (void*) vkLoadPipeline; |
| 153 | if (!strcmp(name, "LoadPipelineDerivative")) |
| 154 | return (void*) vkLoadPipelineDerivative; |
| 155 | if (!strcmp(name, "CreatePipelineLayout")) |
| 156 | return (void*) vkCreatePipelineLayout; |
| 157 | if (!strcmp(name, "CreateSampler")) |
| 158 | return (void*) vkCreateSampler; |
| 159 | if (!strcmp(name, "CreateDescriptorSetLayout")) |
| 160 | return (void*) vkCreateDescriptorSetLayout; |
Jon Ashburn | 2139a3e | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 161 | if (!strcmp(name, "CreateDescriptorPool")) |
| 162 | return (void*) vkCreateDescriptorPool; |
| 163 | if (!strcmp(name, "ResetDescriptorPool")) |
| 164 | return (void*) vkResetDescriptorPool; |
| 165 | if (!strcmp(name, "AllocDescriptorSets")) |
| 166 | return (void*) vkAllocDescriptorSets; |
| 167 | if (!strcmp(name, "ClearDescriptorSets")) |
| 168 | return (void*) vkClearDescriptorSets; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 169 | if (!strcmp(name, "UpdateDescriptorSets")) |
| 170 | return (void*) vkUpdateDescriptorSets; |
Jon Ashburn | 2139a3e | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 171 | if (!strcmp(name, "CreateDynamicViewportState")) |
| 172 | return (void*) vkCreateDynamicViewportState; |
| 173 | if (!strcmp(name, "CreateDynamicRasterState")) |
| 174 | return (void*) vkCreateDynamicRasterState; |
| 175 | if (!strcmp(name, "CreateDynamicColorBlendState")) |
| 176 | return (void*) vkCreateDynamicColorBlendState; |
| 177 | if (!strcmp(name, "CreateDynamicDepthStencilState")) |
| 178 | return (void*) vkCreateDynamicDepthStencilState; |
| 179 | if (!strcmp(name, "CreateCommandBuffer")) |
| 180 | return (void*) vkCreateCommandBuffer; |
| 181 | if (!strcmp(name, "BeginCommandBuffer")) |
| 182 | return (void*) vkBeginCommandBuffer; |
| 183 | if (!strcmp(name, "EndCommandBuffer")) |
| 184 | return (void*) vkEndCommandBuffer; |
| 185 | if (!strcmp(name, "ResetCommandBuffer")) |
| 186 | return (void*) vkResetCommandBuffer; |
| 187 | if (!strcmp(name, "CmdBindPipeline")) |
| 188 | return (void*) vkCmdBindPipeline; |
| 189 | if (!strcmp(name, "CmdBindDynamicStateObject")) |
| 190 | return (void*) vkCmdBindDynamicStateObject; |
| 191 | if (!strcmp(name, "CmdBindDescriptorSets")) |
| 192 | return (void*) vkCmdBindDescriptorSets; |
| 193 | if (!strcmp(name, "CmdBindVertexBuffers")) |
| 194 | return (void*) vkCmdBindVertexBuffers; |
| 195 | if (!strcmp(name, "CmdBindIndexBuffer")) |
| 196 | return (void*) vkCmdBindIndexBuffer; |
| 197 | if (!strcmp(name, "CmdDraw")) |
| 198 | return (void*) vkCmdDraw; |
| 199 | if (!strcmp(name, "CmdDrawIndexed")) |
| 200 | return (void*) vkCmdDrawIndexed; |
| 201 | if (!strcmp(name, "CmdDrawIndirect")) |
| 202 | return (void*) vkCmdDrawIndirect; |
| 203 | if (!strcmp(name, "CmdDrawIndexedIndirect")) |
| 204 | return (void*) vkCmdDrawIndexedIndirect; |
| 205 | if (!strcmp(name, "CmdDispatch")) |
| 206 | return (void*) vkCmdDispatch; |
| 207 | if (!strcmp(name, "CmdDispatchIndirect")) |
| 208 | return (void*) vkCmdDispatchIndirect; |
| 209 | if (!strcmp(name, "CmdCopyBuffer")) |
| 210 | return (void*) vkCmdCopyBuffer; |
| 211 | if (!strcmp(name, "CmdCopyImage")) |
| 212 | return (void*) vkCmdCopyImage; |
| 213 | if (!strcmp(name, "CmdBlitImage")) |
| 214 | return (void*) vkCmdBlitImage; |
| 215 | if (!strcmp(name, "CmdCopyBufferToImage")) |
| 216 | return (void*) vkCmdCopyBufferToImage; |
| 217 | if (!strcmp(name, "CmdCopyImageToBuffer")) |
| 218 | return (void*) vkCmdCopyImageToBuffer; |
Jon Ashburn | 2139a3e | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 219 | if (!strcmp(name, "CmdUpdateBuffer")) |
| 220 | return (void*) vkCmdUpdateBuffer; |
| 221 | if (!strcmp(name, "CmdFillBuffer")) |
| 222 | return (void*) vkCmdFillBuffer; |
| 223 | if (!strcmp(name, "CmdClearColorImage")) |
| 224 | return (void*) vkCmdClearColorImage; |
| 225 | if (!strcmp(name, "CmdClearDepthStencil")) |
| 226 | return (void*) vkCmdClearDepthStencil; |
| 227 | if (!strcmp(name, "CmdResolveImage")) |
| 228 | return (void*) vkCmdResolveImage; |
| 229 | if (!strcmp(name, "CmdSetEvent")) |
| 230 | return (void*) vkCmdSetEvent; |
| 231 | if (!strcmp(name, "CmdResetEvent")) |
| 232 | return (void*) vkCmdResetEvent; |
| 233 | if (!strcmp(name, "CmdWaitEvents")) |
| 234 | return (void*) vkCmdWaitEvents; |
| 235 | if (!strcmp(name, "CmdPipelineBarrier")) |
| 236 | return (void*) vkCmdPipelineBarrier; |
| 237 | if (!strcmp(name, "CmdBeginQuery")) |
| 238 | return (void*) vkCmdBeginQuery; |
| 239 | if (!strcmp(name, "CmdEndQuery")) |
| 240 | return (void*) vkCmdEndQuery; |
| 241 | if (!strcmp(name, "CmdResetQueryPool")) |
| 242 | return (void*) vkCmdResetQueryPool; |
| 243 | if (!strcmp(name, "CmdWriteTimestamp")) |
| 244 | return (void*) vkCmdWriteTimestamp; |
| 245 | if (!strcmp(name, "CmdCopyQueryPoolResults")) |
| 246 | return (void*) vkCmdCopyQueryPoolResults; |
| 247 | if (!strcmp(name, "CmdInitAtomicCounters")) |
| 248 | return (void*) vkCmdInitAtomicCounters; |
| 249 | if (!strcmp(name, "CmdLoadAtomicCounters")) |
| 250 | return (void*) vkCmdLoadAtomicCounters; |
| 251 | if (!strcmp(name, "CmdSaveAtomicCounters")) |
| 252 | return (void*) vkCmdSaveAtomicCounters; |
| 253 | if (!strcmp(name, "CreateFramebuffer")) |
| 254 | return (void*) vkCreateFramebuffer; |
| 255 | if (!strcmp(name, "CreateRenderPass")) |
| 256 | return (void*) vkCreateRenderPass; |
| 257 | if (!strcmp(name, "CmdBeginRenderPass")) |
| 258 | return (void*) vkCmdBeginRenderPass; |
| 259 | if (!strcmp(name, "CmdEndRenderPass")) |
| 260 | return (void*) vkCmdEndRenderPass; |
| 261 | if (!strcmp(name, "DbgSetValidationLevel")) |
| 262 | return (void*) vkDbgSetValidationLevel; |
| 263 | if (!strcmp(name, "DbgRegisterMsgCallback")) |
| 264 | return (void*) vkDbgRegisterMsgCallback; |
| 265 | if (!strcmp(name, "DbgUnregisterMsgCallback")) |
| 266 | return (void*) vkDbgUnregisterMsgCallback; |
| 267 | if (!strcmp(name, "DbgSetMessageFilter")) |
| 268 | return (void*) vkDbgSetMessageFilter; |
| 269 | if (!strcmp(name, "DbgSetObjectTag")) |
| 270 | return (void*) vkDbgSetObjectTag; |
| 271 | if (!strcmp(name, "DbgSetGlobalOption")) |
| 272 | return (void*) vkDbgSetGlobalOption; |
| 273 | if (!strcmp(name, "DbgSetDeviceOption")) |
| 274 | return (void*) vkDbgSetDeviceOption; |
| 275 | if (!strcmp(name, "CmdDbgMarkerBegin")) |
| 276 | return (void*) vkCmdDbgMarkerBegin; |
| 277 | if (!strcmp(name, "CmdDbgMarkerEnd")) |
| 278 | return (void*) vkCmdDbgMarkerEnd; |
| 279 | if (!strcmp(name, "GetDisplayInfoWSI")) |
| 280 | return (void*) vkGetDisplayInfoWSI; |
| 281 | if (!strcmp(name, "CreateSwapChainWSI")) |
| 282 | return (void*) vkCreateSwapChainWSI; |
| 283 | if (!strcmp(name, "DestroySwapChainWSI")) |
| 284 | return (void*) vkDestroySwapChainWSI; |
| 285 | if (!strcmp(name, "GetSwapChainInfoWSI")) |
| 286 | return (void*) vkGetSwapChainInfoWSI; |
| 287 | if (!strcmp(name, "QueuePresentWSI")) |
| 288 | return (void*) vkQueuePresentWSI; |
| 289 | |
| 290 | return NULL; |
| 291 | } |
| 292 | |
| 293 | /* These functions require special handling by the loader. |
| 294 | * They are not just generic trampoline code entrypoints. |
| 295 | * Thus GPA must return loader entrypoint for these instead of first function |
| 296 | * in the chain. */ |
| 297 | static inline void *loader_non_passthrough_gpa(const char *name) |
| 298 | { |
| 299 | if (!name || name[0] != 'v' || name[1] != 'k') |
| 300 | return NULL; |
| 301 | |
| 302 | name += 2; |
| 303 | if (!strcmp(name, "CreateInstance")) |
| 304 | return (void*) vkCreateInstance; |
| 305 | if (!strcmp(name, "DestroyInstance")) |
| 306 | return (void*) vkDestroyInstance; |
| 307 | if (!strcmp(name, "EnumeratePhysicalDevices")) |
| 308 | return (void*) vkEnumeratePhysicalDevices; |
| 309 | if (!strcmp(name, "GetPhysicalDeviceInfo")) |
| 310 | return (void*) vkGetPhysicalDeviceInfo; |
Jon Ashburn | 53c1677 | 2015-05-06 10:15:07 -0600 | [diff] [blame] | 311 | if (!strcmp(name, "GetInstanceProcAddr")) |
| 312 | return (void*) vkGetInstanceProcAddr; |
Jon Ashburn | 2139a3e | 2015-05-06 09:02:10 -0600 | [diff] [blame] | 313 | if (!strcmp(name, "GetProcAddr")) |
| 314 | return (void*) vkGetProcAddr; |
| 315 | if (!strcmp(name, "CreateDevice")) |
| 316 | return (void*) vkCreateDevice; |
| 317 | if (!strcmp(name, "GetGlobalExtensionInfo")) |
| 318 | return (void*) vkGetGlobalExtensionInfo; |
| 319 | if (!strcmp(name, "EnumerateLayers")) |
| 320 | return (void*) vkEnumerateLayers; |
| 321 | if (!strcmp(name, "GetDeviceQueue")) |
| 322 | return (void*) vkGetDeviceQueue; |
| 323 | if (!strcmp(name, "CreateCommandBuffer")) |
| 324 | return (void*) vkCreateCommandBuffer; |
| 325 | if (!strcmp(name, "DbgRegisterMsgCallback")) |
| 326 | return (void*) vkDbgRegisterMsgCallback; |
| 327 | if (!strcmp(name, "DbgUnregisterMsgCallback")) |
| 328 | return (void*) vkDbgUnregisterMsgCallback; |
| 329 | if (!strcmp(name, "DbgSetGlobalOption")) |
| 330 | return (void*) vkDbgSetGlobalOption; |
| 331 | if (!strcmp(name, "CreateSwapChainWSI")) |
| 332 | return (void*) vkCreateSwapChainWSI; |
| 333 | |
| 334 | return NULL; |
| 335 | } |