blob: fd300554884a301b9a2665740be1e694b7ddc3fc [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>
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060026#include "wsi_lunarg.h"
Jon Ashburn2139a3e2015-05-06 09:02:10 -060027
28static inline void* globalGetProcAddr(const char *name)
29{
30 if (!name || name[0] != 'v' || name[1] != 'k')
31 return NULL;
32
33 name += 2;
34 if (!strcmp(name, "CreateInstance"))
35 return (void*) vkCreateInstance;
36 if (!strcmp(name, "DestroyInstance"))
37 return (void*) vkDestroyInstance;
38 if (!strcmp(name, "EnumeratePhysicalDevices"))
39 return (void*) vkEnumeratePhysicalDevices;
40 if (!strcmp(name, "GetPhysicalDeviceInfo"))
41 return (void*) vkGetPhysicalDeviceInfo;
Jon Ashburn53c16772015-05-06 10:15:07 -060042 if (!strcmp(name, "GetInstanceProcAddr"))
43 return (void*) vkGetInstanceProcAddr;
Jon Ashburn1245cec2015-05-18 13:20:15 -060044 if (!strcmp(name, "GetDeviceProcAddr"))
45 return (void*) vkGetDeviceProcAddr;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060046 if (!strcmp(name, "CreateDevice"))
47 return (void*) vkCreateDevice;
48 if (!strcmp(name, "DestroyDevice"))
49 return (void*) vkDestroyDevice;
50 if (!strcmp(name, "GetGlobalExtensionInfo"))
51 return (void*) vkGetGlobalExtensionInfo;
52 if (!strcmp(name, "GetPhysicalDeviceExtensionInfo"))
53 return (void*) vkGetPhysicalDeviceExtensionInfo;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060054 if (!strcmp(name, "GetDeviceQueue"))
55 return (void*) vkGetDeviceQueue;
56 if (!strcmp(name, "QueueSubmit"))
57 return (void*) vkQueueSubmit;
58 if (!strcmp(name, "QueueWaitIdle"))
59 return (void*) vkQueueWaitIdle;
60 if (!strcmp(name, "DeviceWaitIdle"))
61 return (void*) vkDeviceWaitIdle;
62 if (!strcmp(name, "AllocMemory"))
63 return (void*) vkAllocMemory;
64 if (!strcmp(name, "FreeMemory"))
65 return (void*) vkFreeMemory;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060066 if (!strcmp(name, "MapMemory"))
67 return (void*) vkMapMemory;
68 if (!strcmp(name, "UnmapMemory"))
69 return (void*) vkUnmapMemory;
70 if (!strcmp(name, "FlushMappedMemoryRanges"))
71 return (void*) vkFlushMappedMemoryRanges;
72 if (!strcmp(name, "InvalidateMappedMemoryRanges"))
73 return (void*) vkInvalidateMappedMemoryRanges;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060074 if (!strcmp(name, "DestroyObject"))
75 return (void*) vkDestroyObject;
76 if (!strcmp(name, "GetObjectInfo"))
77 return (void*) vkGetObjectInfo;
Mark Lobodzinskifb9f5642015-05-11 17:21:15 -050078 if (!strcmp(name, "BindObjectMemory"))
79 return (void*) vkBindObjectMemory;
80 if (!strcmp(name, "QueueBindSparseBufferMemory"))
81 return (void*) vkQueueBindSparseBufferMemory;
82 if (!strcmp(name, "QueueBindSparseImageMemory"))
83 return (void*) vkQueueBindSparseImageMemory;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060084 if (!strcmp(name, "CreateFence"))
85 return (void*) vkCreateFence;
86 if (!strcmp(name, "ResetFences"))
87 return (void*) vkResetFences;
88 if (!strcmp(name, "GetFenceStatus"))
89 return (void*) vkGetFenceStatus;
90 if (!strcmp(name, "WaitForFences"))
91 return (void*) vkWaitForFences;
92 if (!strcmp(name, "CreateSemaphore"))
93 return (void*) vkCreateSemaphore;
94 if (!strcmp(name, "QueueSignalSemaphore"))
95 return (void*) vkQueueSignalSemaphore;
96 if (!strcmp(name, "QueueWaitSemaphore"))
97 return (void*) vkQueueWaitSemaphore;
98 if (!strcmp(name, "CreateEvent"))
99 return (void*) vkCreateEvent;
100 if (!strcmp(name, "GetEventStatus"))
101 return (void*) vkGetEventStatus;
102 if (!strcmp(name, "SetEvent"))
103 return (void*) vkSetEvent;
104 if (!strcmp(name, "ResetEvent"))
105 return (void*) vkResetEvent;
106 if (!strcmp(name, "CreateQueryPool"))
107 return (void*) vkCreateQueryPool;
108 if (!strcmp(name, "GetQueryPoolResults"))
109 return (void*) vkGetQueryPoolResults;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600110 if (!strcmp(name, "CreateBuffer"))
111 return (void*) vkCreateBuffer;
112 if (!strcmp(name, "CreateBufferView"))
113 return (void*) vkCreateBufferView;
114 if (!strcmp(name, "CreateImage"))
115 return (void*) vkCreateImage;
116 if (!strcmp(name, "GetImageSubresourceInfo"))
117 return (void*) vkGetImageSubresourceInfo;
118 if (!strcmp(name, "CreateImageView"))
119 return (void*) vkCreateImageView;
120 if (!strcmp(name, "CreateColorAttachmentView"))
121 return (void*) vkCreateColorAttachmentView;
122 if (!strcmp(name, "CreateDepthStencilView"))
123 return (void*) vkCreateDepthStencilView;
124 if (!strcmp(name, "CreateShader"))
125 return (void*) vkCreateShader;
126 if (!strcmp(name, "CreateGraphicsPipeline"))
127 return (void*) vkCreateGraphicsPipeline;
128 if (!strcmp(name, "CreateGraphicsPipelineDerivative"))
129 return (void*) vkCreateGraphicsPipelineDerivative;
130 if (!strcmp(name, "CreateComputePipeline"))
131 return (void*) vkCreateComputePipeline;
132 if (!strcmp(name, "StorePipeline"))
133 return (void*) vkStorePipeline;
134 if (!strcmp(name, "LoadPipeline"))
135 return (void*) vkLoadPipeline;
136 if (!strcmp(name, "LoadPipelineDerivative"))
137 return (void*) vkLoadPipelineDerivative;
138 if (!strcmp(name, "CreatePipelineLayout"))
139 return (void*) vkCreatePipelineLayout;
140 if (!strcmp(name, "CreateSampler"))
141 return (void*) vkCreateSampler;
142 if (!strcmp(name, "CreateDescriptorSetLayout"))
143 return (void*) vkCreateDescriptorSetLayout;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600144 if (!strcmp(name, "CreateDescriptorPool"))
145 return (void*) vkCreateDescriptorPool;
146 if (!strcmp(name, "ResetDescriptorPool"))
147 return (void*) vkResetDescriptorPool;
148 if (!strcmp(name, "AllocDescriptorSets"))
149 return (void*) vkAllocDescriptorSets;
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800150 if (!strcmp(name, "UpdateDescriptorSets"))
151 return (void*) vkUpdateDescriptorSets;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600152 if (!strcmp(name, "CreateDynamicViewportState"))
153 return (void*) vkCreateDynamicViewportState;
154 if (!strcmp(name, "CreateDynamicRasterState"))
155 return (void*) vkCreateDynamicRasterState;
156 if (!strcmp(name, "CreateDynamicColorBlendState"))
157 return (void*) vkCreateDynamicColorBlendState;
158 if (!strcmp(name, "CreateDynamicDepthStencilState"))
159 return (void*) vkCreateDynamicDepthStencilState;
160 if (!strcmp(name, "CreateCommandBuffer"))
161 return (void*) vkCreateCommandBuffer;
162 if (!strcmp(name, "BeginCommandBuffer"))
163 return (void*) vkBeginCommandBuffer;
164 if (!strcmp(name, "EndCommandBuffer"))
165 return (void*) vkEndCommandBuffer;
166 if (!strcmp(name, "ResetCommandBuffer"))
167 return (void*) vkResetCommandBuffer;
168 if (!strcmp(name, "CmdBindPipeline"))
169 return (void*) vkCmdBindPipeline;
170 if (!strcmp(name, "CmdBindDynamicStateObject"))
171 return (void*) vkCmdBindDynamicStateObject;
172 if (!strcmp(name, "CmdBindDescriptorSets"))
173 return (void*) vkCmdBindDescriptorSets;
174 if (!strcmp(name, "CmdBindVertexBuffers"))
175 return (void*) vkCmdBindVertexBuffers;
176 if (!strcmp(name, "CmdBindIndexBuffer"))
177 return (void*) vkCmdBindIndexBuffer;
178 if (!strcmp(name, "CmdDraw"))
179 return (void*) vkCmdDraw;
180 if (!strcmp(name, "CmdDrawIndexed"))
181 return (void*) vkCmdDrawIndexed;
182 if (!strcmp(name, "CmdDrawIndirect"))
183 return (void*) vkCmdDrawIndirect;
184 if (!strcmp(name, "CmdDrawIndexedIndirect"))
185 return (void*) vkCmdDrawIndexedIndirect;
186 if (!strcmp(name, "CmdDispatch"))
187 return (void*) vkCmdDispatch;
188 if (!strcmp(name, "CmdDispatchIndirect"))
189 return (void*) vkCmdDispatchIndirect;
190 if (!strcmp(name, "CmdCopyBuffer"))
191 return (void*) vkCmdCopyBuffer;
192 if (!strcmp(name, "CmdCopyImage"))
193 return (void*) vkCmdCopyImage;
194 if (!strcmp(name, "CmdBlitImage"))
195 return (void*) vkCmdBlitImage;
196 if (!strcmp(name, "CmdCopyBufferToImage"))
197 return (void*) vkCmdCopyBufferToImage;
198 if (!strcmp(name, "CmdCopyImageToBuffer"))
199 return (void*) vkCmdCopyImageToBuffer;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600200 if (!strcmp(name, "CmdUpdateBuffer"))
201 return (void*) vkCmdUpdateBuffer;
202 if (!strcmp(name, "CmdFillBuffer"))
203 return (void*) vkCmdFillBuffer;
204 if (!strcmp(name, "CmdClearColorImage"))
205 return (void*) vkCmdClearColorImage;
206 if (!strcmp(name, "CmdClearDepthStencil"))
207 return (void*) vkCmdClearDepthStencil;
208 if (!strcmp(name, "CmdResolveImage"))
209 return (void*) vkCmdResolveImage;
210 if (!strcmp(name, "CmdSetEvent"))
211 return (void*) vkCmdSetEvent;
212 if (!strcmp(name, "CmdResetEvent"))
213 return (void*) vkCmdResetEvent;
214 if (!strcmp(name, "CmdWaitEvents"))
215 return (void*) vkCmdWaitEvents;
216 if (!strcmp(name, "CmdPipelineBarrier"))
217 return (void*) vkCmdPipelineBarrier;
218 if (!strcmp(name, "CmdBeginQuery"))
219 return (void*) vkCmdBeginQuery;
220 if (!strcmp(name, "CmdEndQuery"))
221 return (void*) vkCmdEndQuery;
222 if (!strcmp(name, "CmdResetQueryPool"))
223 return (void*) vkCmdResetQueryPool;
224 if (!strcmp(name, "CmdWriteTimestamp"))
225 return (void*) vkCmdWriteTimestamp;
226 if (!strcmp(name, "CmdCopyQueryPoolResults"))
227 return (void*) vkCmdCopyQueryPoolResults;
228 if (!strcmp(name, "CmdInitAtomicCounters"))
229 return (void*) vkCmdInitAtomicCounters;
230 if (!strcmp(name, "CmdLoadAtomicCounters"))
231 return (void*) vkCmdLoadAtomicCounters;
232 if (!strcmp(name, "CmdSaveAtomicCounters"))
233 return (void*) vkCmdSaveAtomicCounters;
234 if (!strcmp(name, "CreateFramebuffer"))
235 return (void*) vkCreateFramebuffer;
236 if (!strcmp(name, "CreateRenderPass"))
237 return (void*) vkCreateRenderPass;
238 if (!strcmp(name, "CmdBeginRenderPass"))
239 return (void*) vkCmdBeginRenderPass;
240 if (!strcmp(name, "CmdEndRenderPass"))
241 return (void*) vkCmdEndRenderPass;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600242
243 return NULL;
244}
245
246/* These functions require special handling by the loader.
247* They are not just generic trampoline code entrypoints.
248* Thus GPA must return loader entrypoint for these instead of first function
249* in the chain. */
250static inline void *loader_non_passthrough_gpa(const char *name)
251{
252 if (!name || name[0] != 'v' || name[1] != 'k')
253 return NULL;
254
255 name += 2;
256 if (!strcmp(name, "CreateInstance"))
257 return (void*) vkCreateInstance;
258 if (!strcmp(name, "DestroyInstance"))
259 return (void*) vkDestroyInstance;
260 if (!strcmp(name, "EnumeratePhysicalDevices"))
261 return (void*) vkEnumeratePhysicalDevices;
262 if (!strcmp(name, "GetPhysicalDeviceInfo"))
263 return (void*) vkGetPhysicalDeviceInfo;
Chris Forbesd7576302015-06-21 22:55:02 +1200264 if (!strcmp(name, "GetPhysicalDeviceFeatures"))
265 return (void*) vkGetPhysicalDeviceFeatures;
266 if (!strcmp(name, "GetPhysicalDeviceFormatInfo"))
267 return (void*) vkGetPhysicalDeviceFormatInfo;
268 if (!strcmp(name, "GetPhysicalDeviceLimits"))
269 return (void*) vkGetPhysicalDeviceLimits;
Jon Ashburn53c16772015-05-06 10:15:07 -0600270 if (!strcmp(name, "GetInstanceProcAddr"))
271 return (void*) vkGetInstanceProcAddr;
Jon Ashburn1245cec2015-05-18 13:20:15 -0600272 if (!strcmp(name, "GetDeviceProcAddr"))
273 return (void*) vkGetDeviceProcAddr;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600274 if (!strcmp(name, "CreateDevice"))
275 return (void*) vkCreateDevice;
276 if (!strcmp(name, "GetGlobalExtensionInfo"))
277 return (void*) vkGetGlobalExtensionInfo;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600278 if (!strcmp(name, "GetDeviceQueue"))
279 return (void*) vkGetDeviceQueue;
280 if (!strcmp(name, "CreateCommandBuffer"))
281 return (void*) vkCreateCommandBuffer;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600282 if (!strcmp(name, "CreateSwapChainWSI"))
283 return (void*) wsi_lunarg_CreateSwapChainWSI;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600284
285 return NULL;
286}