blob: 775b29cf3cad37154efe4441d49c0122ecdf3ddb [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;
Jon Ashburn53c16772015-05-06 10:15:07 -060041 if (!strcmp(name, "GetInstanceProcAddr"))
42 return (void*) vkGetInstanceProcAddr;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060043 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;
93 if (!strcmp(name, "QueueBindObjectMemory"))
94 return (void*) vkQueueBindObjectMemory;
95 if (!strcmp(name, "QueueBindObjectMemoryRange"))
96 return (void*) vkQueueBindObjectMemoryRange;
97 if (!strcmp(name, "QueueBindImageMemoryRange"))
98 return (void*) vkQueueBindImageMemoryRange;
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;
161 if (!strcmp(name, "BeginDescriptorPoolUpdate"))
162 return (void*) vkBeginDescriptorPoolUpdate;
163 if (!strcmp(name, "EndDescriptorPoolUpdate"))
164 return (void*) vkEndDescriptorPoolUpdate;
165 if (!strcmp(name, "CreateDescriptorPool"))
166 return (void*) vkCreateDescriptorPool;
167 if (!strcmp(name, "ResetDescriptorPool"))
168 return (void*) vkResetDescriptorPool;
169 if (!strcmp(name, "AllocDescriptorSets"))
170 return (void*) vkAllocDescriptorSets;
171 if (!strcmp(name, "ClearDescriptorSets"))
172 return (void*) vkClearDescriptorSets;
173 if (!strcmp(name, "UpdateDescriptors"))
174 return (void*) vkUpdateDescriptors;
175 if (!strcmp(name, "CreateDynamicViewportState"))
176 return (void*) vkCreateDynamicViewportState;
177 if (!strcmp(name, "CreateDynamicRasterState"))
178 return (void*) vkCreateDynamicRasterState;
179 if (!strcmp(name, "CreateDynamicColorBlendState"))
180 return (void*) vkCreateDynamicColorBlendState;
181 if (!strcmp(name, "CreateDynamicDepthStencilState"))
182 return (void*) vkCreateDynamicDepthStencilState;
183 if (!strcmp(name, "CreateCommandBuffer"))
184 return (void*) vkCreateCommandBuffer;
185 if (!strcmp(name, "BeginCommandBuffer"))
186 return (void*) vkBeginCommandBuffer;
187 if (!strcmp(name, "EndCommandBuffer"))
188 return (void*) vkEndCommandBuffer;
189 if (!strcmp(name, "ResetCommandBuffer"))
190 return (void*) vkResetCommandBuffer;
191 if (!strcmp(name, "CmdBindPipeline"))
192 return (void*) vkCmdBindPipeline;
193 if (!strcmp(name, "CmdBindDynamicStateObject"))
194 return (void*) vkCmdBindDynamicStateObject;
195 if (!strcmp(name, "CmdBindDescriptorSets"))
196 return (void*) vkCmdBindDescriptorSets;
197 if (!strcmp(name, "CmdBindVertexBuffers"))
198 return (void*) vkCmdBindVertexBuffers;
199 if (!strcmp(name, "CmdBindIndexBuffer"))
200 return (void*) vkCmdBindIndexBuffer;
201 if (!strcmp(name, "CmdDraw"))
202 return (void*) vkCmdDraw;
203 if (!strcmp(name, "CmdDrawIndexed"))
204 return (void*) vkCmdDrawIndexed;
205 if (!strcmp(name, "CmdDrawIndirect"))
206 return (void*) vkCmdDrawIndirect;
207 if (!strcmp(name, "CmdDrawIndexedIndirect"))
208 return (void*) vkCmdDrawIndexedIndirect;
209 if (!strcmp(name, "CmdDispatch"))
210 return (void*) vkCmdDispatch;
211 if (!strcmp(name, "CmdDispatchIndirect"))
212 return (void*) vkCmdDispatchIndirect;
213 if (!strcmp(name, "CmdCopyBuffer"))
214 return (void*) vkCmdCopyBuffer;
215 if (!strcmp(name, "CmdCopyImage"))
216 return (void*) vkCmdCopyImage;
217 if (!strcmp(name, "CmdBlitImage"))
218 return (void*) vkCmdBlitImage;
219 if (!strcmp(name, "CmdCopyBufferToImage"))
220 return (void*) vkCmdCopyBufferToImage;
221 if (!strcmp(name, "CmdCopyImageToBuffer"))
222 return (void*) vkCmdCopyImageToBuffer;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600223 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;
Jon Ashburn53c16772015-05-06 10:15:07 -0600315 if (!strcmp(name, "GetInstanceProcAddr"))
316 return (void*) vkGetInstanceProcAddr;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600317 if (!strcmp(name, "GetProcAddr"))
318 return (void*) vkGetProcAddr;
319 if (!strcmp(name, "CreateDevice"))
320 return (void*) vkCreateDevice;
321 if (!strcmp(name, "GetGlobalExtensionInfo"))
322 return (void*) vkGetGlobalExtensionInfo;
323 if (!strcmp(name, "EnumerateLayers"))
324 return (void*) vkEnumerateLayers;
325 if (!strcmp(name, "GetDeviceQueue"))
326 return (void*) vkGetDeviceQueue;
327 if (!strcmp(name, "CreateCommandBuffer"))
328 return (void*) vkCreateCommandBuffer;
329 if (!strcmp(name, "DbgRegisterMsgCallback"))
330 return (void*) vkDbgRegisterMsgCallback;
331 if (!strcmp(name, "DbgUnregisterMsgCallback"))
332 return (void*) vkDbgUnregisterMsgCallback;
333 if (!strcmp(name, "DbgSetGlobalOption"))
334 return (void*) vkDbgSetGlobalOption;
335 if (!strcmp(name, "CreateSwapChainWSI"))
336 return (void*) vkCreateSwapChainWSI;
337
338 return NULL;
339}