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