blob: 65c52d4125d37d71db8ea25f09d695e4ee020425 [file] [log] [blame]
Jon Ashburnd55a3942015-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 Goeltzenleuchterf579fa62015-06-10 17:39:03 -060026#include "wsi_lunarg.h"
Jon Ashburnd55a3942015-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 Barbour59a47322015-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 Ashburnb0fbe912015-05-06 10:15:07 -060056 if (!strcmp(name, "GetInstanceProcAddr"))
57 return (void*) vkGetInstanceProcAddr;
Jon Ashburn8d1b0b52015-05-18 13:20:15 -060058 if (!strcmp(name, "GetDeviceProcAddr"))
59 return (void*) vkGetDeviceProcAddr;
Jon Ashburnd55a3942015-05-06 09:02:10 -060060 if (!strcmp(name, "CreateDevice"))
61 return (void*) vkCreateDevice;
62 if (!strcmp(name, "DestroyDevice"))
63 return (void*) vkDestroyDevice;
Tony Barbour59a47322015-06-24 16:06:58 -060064 if (!strcmp(name, "GetGlobalExtensionProperties"))
65 return (void*) vkGetGlobalExtensionProperties;
Tony Barbour59a47322015-06-24 16:06:58 -060066 if (!strcmp(name, "GetPhysicalDeviceExtensionProperties"))
67 return (void*) vkGetPhysicalDeviceExtensionProperties;
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060068 if (!strcmp(name, "GetGlobalLayerProperties"))
69 return (void*) vkGetGlobalLayerProperties;
70 if (!strcmp(name, "GetPhysicalDeviceLayerProperties"))
71 return (void*) vkGetPhysicalDeviceLayerProperties;
Jon Ashburnd55a3942015-05-06 09:02:10 -060072 if (!strcmp(name, "GetDeviceQueue"))
73 return (void*) vkGetDeviceQueue;
74 if (!strcmp(name, "QueueSubmit"))
75 return (void*) vkQueueSubmit;
76 if (!strcmp(name, "QueueWaitIdle"))
77 return (void*) vkQueueWaitIdle;
78 if (!strcmp(name, "DeviceWaitIdle"))
79 return (void*) vkDeviceWaitIdle;
80 if (!strcmp(name, "AllocMemory"))
81 return (void*) vkAllocMemory;
82 if (!strcmp(name, "FreeMemory"))
83 return (void*) vkFreeMemory;
Jon Ashburnd55a3942015-05-06 09:02:10 -060084 if (!strcmp(name, "MapMemory"))
85 return (void*) vkMapMemory;
86 if (!strcmp(name, "UnmapMemory"))
87 return (void*) vkUnmapMemory;
88 if (!strcmp(name, "FlushMappedMemoryRanges"))
89 return (void*) vkFlushMappedMemoryRanges;
90 if (!strcmp(name, "InvalidateMappedMemoryRanges"))
91 return (void*) vkInvalidateMappedMemoryRanges;
Jon Ashburnd55a3942015-05-06 09:02:10 -060092 if (!strcmp(name, "DestroyObject"))
93 return (void*) vkDestroyObject;
Tony Barbour59a47322015-06-24 16:06:58 -060094 if (!strcmp(name, "GetObjectMemoryRequirements"))
95 return (void*) vkGetObjectMemoryRequirements;
Mark Lobodzinski942b1722015-05-11 17:21:15 -050096 if (!strcmp(name, "BindObjectMemory"))
97 return (void*) vkBindObjectMemory;
98 if (!strcmp(name, "QueueBindSparseBufferMemory"))
99 return (void*) vkQueueBindSparseBufferMemory;
100 if (!strcmp(name, "QueueBindSparseImageMemory"))
101 return (void*) vkQueueBindSparseImageMemory;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600102 if (!strcmp(name, "CreateFence"))
103 return (void*) vkCreateFence;
104 if (!strcmp(name, "ResetFences"))
105 return (void*) vkResetFences;
106 if (!strcmp(name, "GetFenceStatus"))
107 return (void*) vkGetFenceStatus;
108 if (!strcmp(name, "WaitForFences"))
109 return (void*) vkWaitForFences;
110 if (!strcmp(name, "CreateSemaphore"))
111 return (void*) vkCreateSemaphore;
112 if (!strcmp(name, "QueueSignalSemaphore"))
113 return (void*) vkQueueSignalSemaphore;
114 if (!strcmp(name, "QueueWaitSemaphore"))
115 return (void*) vkQueueWaitSemaphore;
116 if (!strcmp(name, "CreateEvent"))
117 return (void*) vkCreateEvent;
118 if (!strcmp(name, "GetEventStatus"))
119 return (void*) vkGetEventStatus;
120 if (!strcmp(name, "SetEvent"))
121 return (void*) vkSetEvent;
122 if (!strcmp(name, "ResetEvent"))
123 return (void*) vkResetEvent;
124 if (!strcmp(name, "CreateQueryPool"))
125 return (void*) vkCreateQueryPool;
126 if (!strcmp(name, "GetQueryPoolResults"))
127 return (void*) vkGetQueryPoolResults;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600128 if (!strcmp(name, "CreateBuffer"))
129 return (void*) vkCreateBuffer;
130 if (!strcmp(name, "CreateBufferView"))
131 return (void*) vkCreateBufferView;
132 if (!strcmp(name, "CreateImage"))
133 return (void*) vkCreateImage;
Tony Barbour59a47322015-06-24 16:06:58 -0600134 if (!strcmp(name, "GetImageSubresourceLayout"))
135 return (void*) vkGetImageSubresourceLayout;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600136 if (!strcmp(name, "CreateImageView"))
137 return (void*) vkCreateImageView;
138 if (!strcmp(name, "CreateColorAttachmentView"))
139 return (void*) vkCreateColorAttachmentView;
140 if (!strcmp(name, "CreateDepthStencilView"))
141 return (void*) vkCreateDepthStencilView;
Courtney Goeltzenleuchter2d2cb682015-06-24 18:24:19 -0600142 if (!strcmp(name, "CreateShaderModule"))
143 return (void*) vkCreateShaderModule;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600144 if (!strcmp(name, "CreateShader"))
145 return (void*) vkCreateShader;
146 if (!strcmp(name, "CreateGraphicsPipeline"))
147 return (void*) vkCreateGraphicsPipeline;
148 if (!strcmp(name, "CreateGraphicsPipelineDerivative"))
149 return (void*) vkCreateGraphicsPipelineDerivative;
150 if (!strcmp(name, "CreateComputePipeline"))
151 return (void*) vkCreateComputePipeline;
152 if (!strcmp(name, "StorePipeline"))
153 return (void*) vkStorePipeline;
154 if (!strcmp(name, "LoadPipeline"))
155 return (void*) vkLoadPipeline;
156 if (!strcmp(name, "LoadPipelineDerivative"))
157 return (void*) vkLoadPipelineDerivative;
158 if (!strcmp(name, "CreatePipelineLayout"))
159 return (void*) vkCreatePipelineLayout;
160 if (!strcmp(name, "CreateSampler"))
161 return (void*) vkCreateSampler;
162 if (!strcmp(name, "CreateDescriptorSetLayout"))
163 return (void*) vkCreateDescriptorSetLayout;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600164 if (!strcmp(name, "CreateDescriptorPool"))
165 return (void*) vkCreateDescriptorPool;
166 if (!strcmp(name, "ResetDescriptorPool"))
167 return (void*) vkResetDescriptorPool;
168 if (!strcmp(name, "AllocDescriptorSets"))
169 return (void*) vkAllocDescriptorSets;
Chia-I Wu9d00ed72015-05-25 16:27:55 +0800170 if (!strcmp(name, "UpdateDescriptorSets"))
171 return (void*) vkUpdateDescriptorSets;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600172 if (!strcmp(name, "CreateDynamicViewportState"))
173 return (void*) vkCreateDynamicViewportState;
174 if (!strcmp(name, "CreateDynamicRasterState"))
175 return (void*) vkCreateDynamicRasterState;
176 if (!strcmp(name, "CreateDynamicColorBlendState"))
177 return (void*) vkCreateDynamicColorBlendState;
178 if (!strcmp(name, "CreateDynamicDepthStencilState"))
179 return (void*) vkCreateDynamicDepthStencilState;
180 if (!strcmp(name, "CreateCommandBuffer"))
181 return (void*) vkCreateCommandBuffer;
182 if (!strcmp(name, "BeginCommandBuffer"))
183 return (void*) vkBeginCommandBuffer;
184 if (!strcmp(name, "EndCommandBuffer"))
185 return (void*) vkEndCommandBuffer;
186 if (!strcmp(name, "ResetCommandBuffer"))
187 return (void*) vkResetCommandBuffer;
188 if (!strcmp(name, "CmdBindPipeline"))
189 return (void*) vkCmdBindPipeline;
190 if (!strcmp(name, "CmdBindDynamicStateObject"))
191 return (void*) vkCmdBindDynamicStateObject;
192 if (!strcmp(name, "CmdBindDescriptorSets"))
193 return (void*) vkCmdBindDescriptorSets;
194 if (!strcmp(name, "CmdBindVertexBuffers"))
195 return (void*) vkCmdBindVertexBuffers;
196 if (!strcmp(name, "CmdBindIndexBuffer"))
197 return (void*) vkCmdBindIndexBuffer;
198 if (!strcmp(name, "CmdDraw"))
199 return (void*) vkCmdDraw;
200 if (!strcmp(name, "CmdDrawIndexed"))
201 return (void*) vkCmdDrawIndexed;
202 if (!strcmp(name, "CmdDrawIndirect"))
203 return (void*) vkCmdDrawIndirect;
204 if (!strcmp(name, "CmdDrawIndexedIndirect"))
205 return (void*) vkCmdDrawIndexedIndirect;
206 if (!strcmp(name, "CmdDispatch"))
207 return (void*) vkCmdDispatch;
208 if (!strcmp(name, "CmdDispatchIndirect"))
209 return (void*) vkCmdDispatchIndirect;
210 if (!strcmp(name, "CmdCopyBuffer"))
211 return (void*) vkCmdCopyBuffer;
212 if (!strcmp(name, "CmdCopyImage"))
213 return (void*) vkCmdCopyImage;
214 if (!strcmp(name, "CmdBlitImage"))
215 return (void*) vkCmdBlitImage;
216 if (!strcmp(name, "CmdCopyBufferToImage"))
217 return (void*) vkCmdCopyBufferToImage;
218 if (!strcmp(name, "CmdCopyImageToBuffer"))
219 return (void*) vkCmdCopyImageToBuffer;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600220 if (!strcmp(name, "CmdUpdateBuffer"))
221 return (void*) vkCmdUpdateBuffer;
222 if (!strcmp(name, "CmdFillBuffer"))
223 return (void*) vkCmdFillBuffer;
224 if (!strcmp(name, "CmdClearColorImage"))
225 return (void*) vkCmdClearColorImage;
Chris Forbesd9be82b2015-06-22 17:21:59 +1200226 if (!strcmp(name, "CmdClearDepthStencilImage"))
227 return (void*) vkCmdClearDepthStencilImage;
228 if (!strcmp(name, "CmdClearColorAttachment"))
229 return (void*) vkCmdClearColorAttachment;
230 if (!strcmp(name, "CmdClearDepthStencilAttachment"))
231 return (void*) vkCmdClearDepthStencilAttachment;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600232 if (!strcmp(name, "CmdResolveImage"))
233 return (void*) vkCmdResolveImage;
234 if (!strcmp(name, "CmdSetEvent"))
235 return (void*) vkCmdSetEvent;
236 if (!strcmp(name, "CmdResetEvent"))
237 return (void*) vkCmdResetEvent;
238 if (!strcmp(name, "CmdWaitEvents"))
239 return (void*) vkCmdWaitEvents;
240 if (!strcmp(name, "CmdPipelineBarrier"))
241 return (void*) vkCmdPipelineBarrier;
242 if (!strcmp(name, "CmdBeginQuery"))
243 return (void*) vkCmdBeginQuery;
244 if (!strcmp(name, "CmdEndQuery"))
245 return (void*) vkCmdEndQuery;
246 if (!strcmp(name, "CmdResetQueryPool"))
247 return (void*) vkCmdResetQueryPool;
248 if (!strcmp(name, "CmdWriteTimestamp"))
249 return (void*) vkCmdWriteTimestamp;
250 if (!strcmp(name, "CmdCopyQueryPoolResults"))
251 return (void*) vkCmdCopyQueryPoolResults;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600252 if (!strcmp(name, "CreateFramebuffer"))
253 return (void*) vkCreateFramebuffer;
254 if (!strcmp(name, "CreateRenderPass"))
255 return (void*) vkCreateRenderPass;
256 if (!strcmp(name, "CmdBeginRenderPass"))
257 return (void*) vkCmdBeginRenderPass;
258 if (!strcmp(name, "CmdEndRenderPass"))
259 return (void*) vkCmdEndRenderPass;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600260
261 return NULL;
262}
263
264/* These functions require special handling by the loader.
265* They are not just generic trampoline code entrypoints.
266* Thus GPA must return loader entrypoint for these instead of first function
267* in the chain. */
268static inline void *loader_non_passthrough_gpa(const char *name)
269{
270 if (!name || name[0] != 'v' || name[1] != 'k')
271 return NULL;
272
273 name += 2;
274 if (!strcmp(name, "CreateInstance"))
275 return (void*) vkCreateInstance;
276 if (!strcmp(name, "DestroyInstance"))
277 return (void*) vkDestroyInstance;
278 if (!strcmp(name, "EnumeratePhysicalDevices"))
279 return (void*) vkEnumeratePhysicalDevices;
Chris Forbesbc0bb772015-06-21 22:55:02 +1200280 if (!strcmp(name, "GetPhysicalDeviceFeatures"))
281 return (void*) vkGetPhysicalDeviceFeatures;
282 if (!strcmp(name, "GetPhysicalDeviceFormatInfo"))
283 return (void*) vkGetPhysicalDeviceFormatInfo;
284 if (!strcmp(name, "GetPhysicalDeviceLimits"))
285 return (void*) vkGetPhysicalDeviceLimits;
Tony Barbour59a47322015-06-24 16:06:58 -0600286 if (!strcmp(name, "GetPhysicalDevicePerformance"))
287 return (void*) vkGetPhysicalDevicePerformance;
288 if (!strcmp(name, "GetPhysicalDeviceQueueCount"))
289 return (void*) vkGetPhysicalDeviceQueueCount;
290 if (!strcmp(name, "GetPhysicalDeviceQueueProperties"))
291 return (void*) vkGetPhysicalDeviceQueueProperties;
292 if (!strcmp(name, "GetPhysicalDeviceMemoryProperties"))
293 return (void*) vkGetPhysicalDeviceMemoryProperties;
294 if (!strcmp(name, "GetPhysicalDeviceProperties"))
295 return (void*) vkGetPhysicalDeviceProperties;
Jon Ashburnb0fbe912015-05-06 10:15:07 -0600296 if (!strcmp(name, "GetInstanceProcAddr"))
297 return (void*) vkGetInstanceProcAddr;
Jon Ashburn8d1b0b52015-05-18 13:20:15 -0600298 if (!strcmp(name, "GetDeviceProcAddr"))
299 return (void*) vkGetDeviceProcAddr;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600300 if (!strcmp(name, "CreateDevice"))
301 return (void*) vkCreateDevice;
Tony Barbour59a47322015-06-24 16:06:58 -0600302 if (!strcmp(name, "GetPhysicalDeviceExtensionProperties"))
303 return (void*) vkGetPhysicalDeviceExtensionProperties;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600304 if (!strcmp(name, "GetDeviceQueue"))
305 return (void*) vkGetDeviceQueue;
306 if (!strcmp(name, "CreateCommandBuffer"))
307 return (void*) vkCreateCommandBuffer;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600308 if (!strcmp(name, "CreateSwapChainWSI"))
309 return (void*) wsi_lunarg_CreateSwapChainWSI;
Jon Ashburnd55a3942015-05-06 09:02:10 -0600310
311 return NULL;
312}