blob: 6da2fcc41ecca8eef58f917cf9df9145817d170a [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;
Tony Barbour426b9052015-06-24 16:06:58 -060040 if (!strcmp(name, "GetPhysicalDeviceProperties"))
41 return (void*) vkGetPhysicalDeviceProperties;
42 if (!strcmp(name, "GetPhysicalDevicePerformance"))
43 return (void*) vkGetPhysicalDevicePerformance;
44 if (!strcmp(name, "GetPhysicalDeviceQueueCount"))
45 return (void*) vkGetPhysicalDeviceQueueCount;
46 if (!strcmp(name, "GetPhysicalDeviceQueueProperties"))
47 return (void*) vkGetPhysicalDeviceQueueProperties;
48 if (!strcmp(name, "GetPhysicalDeviceMemoryProperties"))
49 return (void*) vkGetPhysicalDeviceMemoryProperties;
50 if (!strcmp(name, "GetPhysicalDeviceFeatures"))
51 return (void*) vkGetPhysicalDeviceFeatures;
52 if (!strcmp(name, "GetPhysicalDeviceFormatInfo"))
53 return (void*) vkGetPhysicalDeviceFormatInfo;
54 if (!strcmp(name, "GetPhysicalDeviceLimits"))
55 return (void*) vkGetPhysicalDeviceLimits;
Jon Ashburn53c16772015-05-06 10:15:07 -060056 if (!strcmp(name, "GetInstanceProcAddr"))
57 return (void*) vkGetInstanceProcAddr;
Jon Ashburn1245cec2015-05-18 13:20:15 -060058 if (!strcmp(name, "GetDeviceProcAddr"))
59 return (void*) vkGetDeviceProcAddr;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060060 if (!strcmp(name, "CreateDevice"))
61 return (void*) vkCreateDevice;
62 if (!strcmp(name, "DestroyDevice"))
63 return (void*) vkDestroyDevice;
Tony Barbour426b9052015-06-24 16:06:58 -060064 if (!strcmp(name, "GetGlobalExtensionProperties"))
65 return (void*) vkGetGlobalExtensionProperties;
Tony Barbour426b9052015-06-24 16:06:58 -060066 if (!strcmp(name, "GetPhysicalDeviceExtensionProperties"))
67 return (void*) vkGetPhysicalDeviceExtensionProperties;
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -060068 if (!strcmp(name, "GetGlobalLayerProperties"))
69 return (void*) vkGetGlobalLayerProperties;
70 if (!strcmp(name, "GetPhysicalDeviceLayerProperties"))
71 return (void*) vkGetPhysicalDeviceLayerProperties;
Mark Lobodzinski83d4e6a2015-07-03 15:58:09 -060072 if (!strcmp(name, "GetPhysicalDeviceSparseImageFormatProperties"))
73 return (void*) vkGetPhysicalDeviceSparseImageFormatProperties;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060074 if (!strcmp(name, "GetDeviceQueue"))
75 return (void*) vkGetDeviceQueue;
76 if (!strcmp(name, "QueueSubmit"))
77 return (void*) vkQueueSubmit;
78 if (!strcmp(name, "QueueWaitIdle"))
79 return (void*) vkQueueWaitIdle;
80 if (!strcmp(name, "DeviceWaitIdle"))
81 return (void*) vkDeviceWaitIdle;
82 if (!strcmp(name, "AllocMemory"))
83 return (void*) vkAllocMemory;
84 if (!strcmp(name, "FreeMemory"))
85 return (void*) vkFreeMemory;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060086 if (!strcmp(name, "MapMemory"))
87 return (void*) vkMapMemory;
88 if (!strcmp(name, "UnmapMemory"))
89 return (void*) vkUnmapMemory;
90 if (!strcmp(name, "FlushMappedMemoryRanges"))
91 return (void*) vkFlushMappedMemoryRanges;
92 if (!strcmp(name, "InvalidateMappedMemoryRanges"))
93 return (void*) vkInvalidateMappedMemoryRanges;
Jon Ashburn2139a3e2015-05-06 09:02:10 -060094 if (!strcmp(name, "DestroyObject"))
95 return (void*) vkDestroyObject;
Tony Barbour426b9052015-06-24 16:06:58 -060096 if (!strcmp(name, "GetObjectMemoryRequirements"))
97 return (void*) vkGetObjectMemoryRequirements;
Mark Lobodzinskifb9f5642015-05-11 17:21:15 -050098 if (!strcmp(name, "BindObjectMemory"))
99 return (void*) vkBindObjectMemory;
100 if (!strcmp(name, "QueueBindSparseBufferMemory"))
101 return (void*) vkQueueBindSparseBufferMemory;
102 if (!strcmp(name, "QueueBindSparseImageMemory"))
103 return (void*) vkQueueBindSparseImageMemory;
Mark Lobodzinski83d4e6a2015-07-03 15:58:09 -0600104 if (!strcmp(name, "QueueBindSparseImageOpaqueMemory"))
105 return (void*) vkQueueBindSparseImageOpaqueMemory;
106 if (!strcmp(name, "GetImageSparseMemoryRequirements"))
107 return (void*) vkGetImageSparseMemoryRequirements;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600108 if (!strcmp(name, "CreateFence"))
109 return (void*) vkCreateFence;
110 if (!strcmp(name, "ResetFences"))
111 return (void*) vkResetFences;
112 if (!strcmp(name, "GetFenceStatus"))
113 return (void*) vkGetFenceStatus;
114 if (!strcmp(name, "WaitForFences"))
115 return (void*) vkWaitForFences;
116 if (!strcmp(name, "CreateSemaphore"))
117 return (void*) vkCreateSemaphore;
118 if (!strcmp(name, "QueueSignalSemaphore"))
119 return (void*) vkQueueSignalSemaphore;
120 if (!strcmp(name, "QueueWaitSemaphore"))
121 return (void*) vkQueueWaitSemaphore;
122 if (!strcmp(name, "CreateEvent"))
123 return (void*) vkCreateEvent;
124 if (!strcmp(name, "GetEventStatus"))
125 return (void*) vkGetEventStatus;
126 if (!strcmp(name, "SetEvent"))
127 return (void*) vkSetEvent;
128 if (!strcmp(name, "ResetEvent"))
129 return (void*) vkResetEvent;
130 if (!strcmp(name, "CreateQueryPool"))
131 return (void*) vkCreateQueryPool;
132 if (!strcmp(name, "GetQueryPoolResults"))
133 return (void*) vkGetQueryPoolResults;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600134 if (!strcmp(name, "CreateBuffer"))
135 return (void*) vkCreateBuffer;
136 if (!strcmp(name, "CreateBufferView"))
137 return (void*) vkCreateBufferView;
138 if (!strcmp(name, "CreateImage"))
139 return (void*) vkCreateImage;
Tony Barbour426b9052015-06-24 16:06:58 -0600140 if (!strcmp(name, "GetImageSubresourceLayout"))
141 return (void*) vkGetImageSubresourceLayout;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600142 if (!strcmp(name, "CreateImageView"))
143 return (void*) vkCreateImageView;
Chia-I Wuc278df82015-07-07 11:50:03 +0800144 if (!strcmp(name, "CreateAttachmentView"))
145 return (void*) vkCreateAttachmentView;
Courtney Goeltzenleuchter0b29b0d2015-06-24 18:24:19 -0600146 if (!strcmp(name, "CreateShaderModule"))
147 return (void*) vkCreateShaderModule;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600148 if (!strcmp(name, "CreateShader"))
149 return (void*) vkCreateShader;
Jon Ashburn0d60d272015-07-09 15:02:25 -0600150 if (!strcmp(name, "CreatePipelineCache"))
151 return (void*) vkCreatePipelineCache;
152 if (!strcmp(name, "DestroyPipelineCache"))
153 return (void*) vkDestroyPipelineCache;
154 if (!strcmp(name, "GetPipelineCacheSize"))
155 return (void*) vkGetPipelineCacheSize;
156 if (!strcmp(name, "GetPipelineCacheData"))
157 return (void*) vkGetPipelineCacheData;
158 if (!strcmp(name, "MergePipelineCaches"))
159 return (void*) vkMergePipelineCaches;
160 if (!strcmp(name, "CreateGraphicsPipelines"))
161 return (void*) vkCreateGraphicsPipelines;
162 if (!strcmp(name, "CreateComputePipelines"))
163 return (void*) vkCreateComputePipelines;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600164 if (!strcmp(name, "CreatePipelineLayout"))
165 return (void*) vkCreatePipelineLayout;
166 if (!strcmp(name, "CreateSampler"))
167 return (void*) vkCreateSampler;
168 if (!strcmp(name, "CreateDescriptorSetLayout"))
169 return (void*) vkCreateDescriptorSetLayout;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600170 if (!strcmp(name, "CreateDescriptorPool"))
171 return (void*) vkCreateDescriptorPool;
172 if (!strcmp(name, "ResetDescriptorPool"))
173 return (void*) vkResetDescriptorPool;
174 if (!strcmp(name, "AllocDescriptorSets"))
175 return (void*) vkAllocDescriptorSets;
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800176 if (!strcmp(name, "UpdateDescriptorSets"))
177 return (void*) vkUpdateDescriptorSets;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600178 if (!strcmp(name, "CreateDynamicViewportState"))
179 return (void*) vkCreateDynamicViewportState;
180 if (!strcmp(name, "CreateDynamicRasterState"))
181 return (void*) vkCreateDynamicRasterState;
182 if (!strcmp(name, "CreateDynamicColorBlendState"))
183 return (void*) vkCreateDynamicColorBlendState;
184 if (!strcmp(name, "CreateDynamicDepthStencilState"))
185 return (void*) vkCreateDynamicDepthStencilState;
186 if (!strcmp(name, "CreateCommandBuffer"))
187 return (void*) vkCreateCommandBuffer;
188 if (!strcmp(name, "BeginCommandBuffer"))
189 return (void*) vkBeginCommandBuffer;
190 if (!strcmp(name, "EndCommandBuffer"))
191 return (void*) vkEndCommandBuffer;
192 if (!strcmp(name, "ResetCommandBuffer"))
193 return (void*) vkResetCommandBuffer;
194 if (!strcmp(name, "CmdBindPipeline"))
195 return (void*) vkCmdBindPipeline;
196 if (!strcmp(name, "CmdBindDynamicStateObject"))
197 return (void*) vkCmdBindDynamicStateObject;
198 if (!strcmp(name, "CmdBindDescriptorSets"))
199 return (void*) vkCmdBindDescriptorSets;
200 if (!strcmp(name, "CmdBindVertexBuffers"))
201 return (void*) vkCmdBindVertexBuffers;
202 if (!strcmp(name, "CmdBindIndexBuffer"))
203 return (void*) vkCmdBindIndexBuffer;
204 if (!strcmp(name, "CmdDraw"))
205 return (void*) vkCmdDraw;
206 if (!strcmp(name, "CmdDrawIndexed"))
207 return (void*) vkCmdDrawIndexed;
208 if (!strcmp(name, "CmdDrawIndirect"))
209 return (void*) vkCmdDrawIndirect;
210 if (!strcmp(name, "CmdDrawIndexedIndirect"))
211 return (void*) vkCmdDrawIndexedIndirect;
212 if (!strcmp(name, "CmdDispatch"))
213 return (void*) vkCmdDispatch;
214 if (!strcmp(name, "CmdDispatchIndirect"))
215 return (void*) vkCmdDispatchIndirect;
216 if (!strcmp(name, "CmdCopyBuffer"))
217 return (void*) vkCmdCopyBuffer;
218 if (!strcmp(name, "CmdCopyImage"))
219 return (void*) vkCmdCopyImage;
220 if (!strcmp(name, "CmdBlitImage"))
221 return (void*) vkCmdBlitImage;
222 if (!strcmp(name, "CmdCopyBufferToImage"))
223 return (void*) vkCmdCopyBufferToImage;
224 if (!strcmp(name, "CmdCopyImageToBuffer"))
225 return (void*) vkCmdCopyImageToBuffer;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600226 if (!strcmp(name, "CmdUpdateBuffer"))
227 return (void*) vkCmdUpdateBuffer;
228 if (!strcmp(name, "CmdFillBuffer"))
229 return (void*) vkCmdFillBuffer;
230 if (!strcmp(name, "CmdClearColorImage"))
231 return (void*) vkCmdClearColorImage;
Chris Forbes2951d7d2015-06-22 17:21:59 +1200232 if (!strcmp(name, "CmdClearDepthStencilImage"))
233 return (void*) vkCmdClearDepthStencilImage;
234 if (!strcmp(name, "CmdClearColorAttachment"))
235 return (void*) vkCmdClearColorAttachment;
236 if (!strcmp(name, "CmdClearDepthStencilAttachment"))
237 return (void*) vkCmdClearDepthStencilAttachment;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600238 if (!strcmp(name, "CmdResolveImage"))
239 return (void*) vkCmdResolveImage;
240 if (!strcmp(name, "CmdSetEvent"))
241 return (void*) vkCmdSetEvent;
242 if (!strcmp(name, "CmdResetEvent"))
243 return (void*) vkCmdResetEvent;
244 if (!strcmp(name, "CmdWaitEvents"))
245 return (void*) vkCmdWaitEvents;
246 if (!strcmp(name, "CmdPipelineBarrier"))
247 return (void*) vkCmdPipelineBarrier;
248 if (!strcmp(name, "CmdBeginQuery"))
249 return (void*) vkCmdBeginQuery;
250 if (!strcmp(name, "CmdEndQuery"))
251 return (void*) vkCmdEndQuery;
252 if (!strcmp(name, "CmdResetQueryPool"))
253 return (void*) vkCmdResetQueryPool;
254 if (!strcmp(name, "CmdWriteTimestamp"))
255 return (void*) vkCmdWriteTimestamp;
256 if (!strcmp(name, "CmdCopyQueryPoolResults"))
257 return (void*) vkCmdCopyQueryPoolResults;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600258 if (!strcmp(name, "CreateFramebuffer"))
259 return (void*) vkCreateFramebuffer;
260 if (!strcmp(name, "CreateRenderPass"))
261 return (void*) vkCreateRenderPass;
262 if (!strcmp(name, "CmdBeginRenderPass"))
263 return (void*) vkCmdBeginRenderPass;
Chia-I Wuc278df82015-07-07 11:50:03 +0800264 if (!strcmp(name, "CmdNextSubpass"))
265 return (void*) vkCmdNextSubpass;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600266 if (!strcmp(name, "CmdEndRenderPass"))
267 return (void*) vkCmdEndRenderPass;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600268
269 return NULL;
270}
271
272/* These functions require special handling by the loader.
273* They are not just generic trampoline code entrypoints.
274* Thus GPA must return loader entrypoint for these instead of first function
275* in the chain. */
276static inline void *loader_non_passthrough_gpa(const char *name)
277{
278 if (!name || name[0] != 'v' || name[1] != 'k')
279 return NULL;
280
281 name += 2;
282 if (!strcmp(name, "CreateInstance"))
283 return (void*) vkCreateInstance;
284 if (!strcmp(name, "DestroyInstance"))
285 return (void*) vkDestroyInstance;
286 if (!strcmp(name, "EnumeratePhysicalDevices"))
287 return (void*) vkEnumeratePhysicalDevices;
Chris Forbesd7576302015-06-21 22:55:02 +1200288 if (!strcmp(name, "GetPhysicalDeviceFeatures"))
289 return (void*) vkGetPhysicalDeviceFeatures;
290 if (!strcmp(name, "GetPhysicalDeviceFormatInfo"))
291 return (void*) vkGetPhysicalDeviceFormatInfo;
292 if (!strcmp(name, "GetPhysicalDeviceLimits"))
293 return (void*) vkGetPhysicalDeviceLimits;
Tony Barbour426b9052015-06-24 16:06:58 -0600294 if (!strcmp(name, "GetPhysicalDevicePerformance"))
295 return (void*) vkGetPhysicalDevicePerformance;
296 if (!strcmp(name, "GetPhysicalDeviceQueueCount"))
297 return (void*) vkGetPhysicalDeviceQueueCount;
298 if (!strcmp(name, "GetPhysicalDeviceQueueProperties"))
299 return (void*) vkGetPhysicalDeviceQueueProperties;
300 if (!strcmp(name, "GetPhysicalDeviceMemoryProperties"))
301 return (void*) vkGetPhysicalDeviceMemoryProperties;
302 if (!strcmp(name, "GetPhysicalDeviceProperties"))
303 return (void*) vkGetPhysicalDeviceProperties;
Mark Lobodzinski83d4e6a2015-07-03 15:58:09 -0600304 if (!strcmp(name, "GetPhysicalDeviceSparseImageFormatProperties"))
305 return (void*) vkGetPhysicalDeviceSparseImageFormatProperties;
Jon Ashburn53c16772015-05-06 10:15:07 -0600306 if (!strcmp(name, "GetInstanceProcAddr"))
307 return (void*) vkGetInstanceProcAddr;
Jon Ashburn1245cec2015-05-18 13:20:15 -0600308 if (!strcmp(name, "GetDeviceProcAddr"))
309 return (void*) vkGetDeviceProcAddr;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600310 if (!strcmp(name, "CreateDevice"))
311 return (void*) vkCreateDevice;
Tony Barbour426b9052015-06-24 16:06:58 -0600312 if (!strcmp(name, "GetPhysicalDeviceExtensionProperties"))
313 return (void*) vkGetPhysicalDeviceExtensionProperties;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600314 if (!strcmp(name, "GetDeviceQueue"))
315 return (void*) vkGetDeviceQueue;
316 if (!strcmp(name, "CreateCommandBuffer"))
317 return (void*) vkCreateCommandBuffer;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600318 if (!strcmp(name, "CreateSwapChainWSI"))
319 return (void*) wsi_lunarg_CreateSwapChainWSI;
Jon Ashburn2139a3e2015-05-06 09:02:10 -0600320
321 return NULL;
322}