blob: f5dc823d1f0fbcd80b5be771ebf5d4363af4641d [file] [log] [blame]
Ian Elliott954fa342015-10-30 15:28:23 -06001/*
2 *
3 * Copyright (C) 2015 Valve Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Author: Ian Elliott <ian@lunarg.com>
Ian Elliottc2e9aee2015-11-19 11:58:08 -070024 * Author: Ian Elliott <ianelliott@google.com>
Ian Elliott954fa342015-10-30 15:28:23 -060025 */
26
27//#define _ISOC11_SOURCE /* for aligned_alloc() */
28#define _GNU_SOURCE
29#include <stdlib.h>
30#include <string.h>
31#include "vk_loader_platform.h"
32#include "loader.h"
33#include "wsi.h"
Ian Elliott2c05e222015-11-19 13:14:05 -070034#include <vulkan/vk_icd.h>
Ian Elliott954fa342015-10-30 15:28:23 -060035
36static const VkExtensionProperties wsi_surface_extension_info = {
37 .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
38 .specVersion = VK_KHR_SURFACE_REVISION,
39};
40
41#ifdef _WIN32
Ian Elliottc2e9aee2015-11-19 11:58:08 -070042#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060043static const VkExtensionProperties wsi_win32_surface_extension_info = {
44 .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
45 .specVersion = VK_KHR_WIN32_SURFACE_REVISION,
46};
Ian Elliottc2e9aee2015-11-19 11:58:08 -070047#endif/ VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060048#else // _WIN32
Ian Elliottaf7d6362015-10-30 17:45:05 -060049#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060050static const VkExtensionProperties wsi_mir_surface_extension_info = {
51 .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
52 .specVersion = VK_KHR_MIR_SURFACE_REVISION,
53};
Ian Elliottaf7d6362015-10-30 17:45:05 -060054#endif // VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060055
Ian Elliottaf7d6362015-10-30 17:45:05 -060056#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060057static const VkExtensionProperties wsi_wayland_surface_extension_info = {
58 .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
59 .specVersion = VK_KHR_WAYLAND_SURFACE_REVISION,
60};
Ian Elliottaf7d6362015-10-30 17:45:05 -060061#endif // VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060062
Ian Elliottaf7d6362015-10-30 17:45:05 -060063#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060064static const VkExtensionProperties wsi_xcb_surface_extension_info = {
65 .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
66 .specVersion = VK_KHR_XCB_SURFACE_REVISION,
67};
Ian Elliottaf7d6362015-10-30 17:45:05 -060068#endif // VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060069
Ian Elliottaf7d6362015-10-30 17:45:05 -060070#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060071static const VkExtensionProperties wsi_xlib_surface_extension_info = {
72 .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
73 .specVersion = VK_KHR_XLIB_SURFACE_REVISION,
74};
Ian Elliottaf7d6362015-10-30 17:45:05 -060075#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060076#endif // _WIN32
77
78void wsi_add_instance_extensions(
79 const struct loader_instance *inst,
80 struct loader_extension_list *ext_list)
81{
82 loader_add_to_ext_list(inst, ext_list, 1, &wsi_surface_extension_info);
83#ifdef _WIN32
Ian Elliottc2e9aee2015-11-19 11:58:08 -070084#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060085 loader_add_to_ext_list(inst, ext_list, 1, &wsi_win32_surface_extension_info);
Ian Elliottc2e9aee2015-11-19 11:58:08 -070086#endif/ VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060087#else // _WIN32
Ian Elliottaf7d6362015-10-30 17:45:05 -060088#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060089 loader_add_to_ext_list(inst, ext_list, 1, &wsi_mir_surface_extension_info);
Ian Elliottaf7d6362015-10-30 17:45:05 -060090#endif // VK_USE_PLATFORM_MIR_KHR
91#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060092 loader_add_to_ext_list(inst, ext_list, 1, &wsi_wayland_surface_extension_info);
Ian Elliottaf7d6362015-10-30 17:45:05 -060093#endif // VK_USE_PLATFORM_WAYLAND_KHR
94#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060095 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xcb_surface_extension_info);
Ian Elliottaf7d6362015-10-30 17:45:05 -060096#endif // VK_USE_PLATFORM_XCB_KHR
97#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060098 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xlib_surface_extension_info);
Ian Elliottaf7d6362015-10-30 17:45:05 -060099#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600100#endif // _WIN32
101}
102
103void wsi_create_instance(
104 struct loader_instance *ptr_instance,
105 const VkInstanceCreateInfo *pCreateInfo)
106{
Ian Elliottaf7d6362015-10-30 17:45:05 -0600107 ptr_instance->wsi_surface_enabled = false;
Ian Elliott954fa342015-10-30 15:28:23 -0600108#ifdef _WIN32
Ian Elliottdb4300a2015-11-23 10:17:23 -0700109 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliott954fa342015-10-30 15:28:23 -0600110#else // _WIN32
111 ptr_instance->wsi_mir_surface_enabled = false;
112 ptr_instance->wsi_wayland_surface_enabled = false;
113 ptr_instance->wsi_xcb_surface_enabled = false;
114 ptr_instance->wsi_xlib_surface_enabled = false;
115#endif // _WIN32
Ian Elliott954fa342015-10-30 15:28:23 -0600116
117 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
118 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
119 ptr_instance->wsi_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700120 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600121 }
122#ifdef _WIN32
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700123#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600124 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliottdb4300a2015-11-23 10:17:23 -0700125 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700126 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600127 }
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700128#endif/ VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600129#else // _WIN32
Ian Elliottaf7d6362015-10-30 17:45:05 -0600130#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600131 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
132 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700133 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600134 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600135#endif // VK_USE_PLATFORM_MIR_KHR
136#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600137 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
138 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700139 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600140 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600141#endif // VK_USE_PLATFORM_WAYLAND_KHR
142#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600143 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
144 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700145 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600146 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600147#endif // VK_USE_PLATFORM_XCB_KHR
148#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600149 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
150 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700151 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600152 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600153#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600154#endif // _WIN32
155 }
156}
157
158/*
Ian Elliott2c05e222015-11-19 13:14:05 -0700159 * Functions for the VK_KHR_surface extension:
160 */
161
162/*
163 * This is the trampoline entrypoint
164 * for DestroySurfaceKHR
Ian Elliott2c05e222015-11-19 13:14:05 -0700165 */
166LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(
167 VkInstance instance,
168 VkSurfaceKHR surface,
169 const VkAllocationCallbacks* pAllocator)
170{
Ian Elliottfb42cd72015-11-25 14:43:02 -0700171 const VkLayerInstanceDispatchTable *disp;
172 disp = loader_get_instance_dispatch(instance);
173 disp->DestroySurfaceKHR(instance, surface, pAllocator);
174}
175
176/*
177 * This is the instance chain terminator function
178 * for DestroySurfaceKHR
179 */
180VKAPI_ATTR void VKAPI_CALL loader_DestroySurfaceKHR(
181 VkInstance instance,
182 VkSurfaceKHR surface,
183 const VkAllocationCallbacks* pAllocator)
184{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700185 struct loader_instance *ptr_instance = loader_get_instance(instance);
186
187 loader_heap_free(ptr_instance, surface);
Ian Elliott2c05e222015-11-19 13:14:05 -0700188}
189
190/*
Ian Elliott954fa342015-10-30 15:28:23 -0600191 * This is the trampoline entrypoint
192 * for GetPhysicalDeviceSurfaceSupportKHR
193 */
Ian Elliott83e6aa92015-11-19 12:37:51 -0700194LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(
Ian Elliott954fa342015-10-30 15:28:23 -0600195 VkPhysicalDevice physicalDevice,
196 uint32_t queueFamilyIndex,
197 VkSurfaceKHR surface,
198 VkBool32* pSupported)
199{
200 const VkLayerInstanceDispatchTable *disp;
201 disp = loader_get_instance_dispatch(physicalDevice);
202 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
203 physicalDevice,
204 queueFamilyIndex,
205 surface,
206 pSupported);
207 return res;
208}
209
210/*
211 * This is the instance chain terminator function
212 * for GetPhysicalDeviceSurfaceSupportKHR
213 */
214VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceSupportKHR(
215 VkPhysicalDevice physicalDevice,
216 uint32_t queueFamilyIndex,
217 VkSurfaceKHR surface,
218 VkBool32* pSupported)
219{
220 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
221 struct loader_icd *icd = phys_dev->this_icd;
222
223 assert(pSupported && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
224 *pSupported = false;
225
226 assert(icd->GetPhysicalDeviceSurfaceSupportKHR && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
227
228 return icd->GetPhysicalDeviceSurfaceSupportKHR(phys_dev->phys_dev,
229 queueFamilyIndex,
230 surface,
231 pSupported);
232}
233
Ian Elliott486c5502015-11-19 16:05:09 -0700234/*
235 * This is the trampoline entrypoint
236 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
237 */
238LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
239 VkPhysicalDevice physicalDevice,
240 VkSurfaceKHR surface,
241 VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
242{
243 const VkLayerInstanceDispatchTable *disp;
244 disp = loader_get_instance_dispatch(physicalDevice);
245 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
246 physicalDevice,
247 surface,
248 pSurfaceCapabilities);
249 return res;
250}
251
252/*
253 * This is the instance chain terminator function
254 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
255 */
256VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceCapabilitiesKHR(
257 VkPhysicalDevice physicalDevice,
258 VkSurfaceKHR surface,
259 VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
260{
261 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
262 struct loader_icd *icd = phys_dev->this_icd;
263
264 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: Error, null pSurfaceCapabilities");
265
266 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
267
268 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev->phys_dev,
269 surface,
270 pSurfaceCapabilities);
271}
272
273/*
274 * This is the trampoline entrypoint
275 * for GetPhysicalDeviceSurfaceFormatsKHR
276 */
277LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(
278 VkPhysicalDevice physicalDevice,
279 VkSurfaceKHR surface,
280 uint32_t* pSurfaceFormatCount,
281 VkSurfaceFormatKHR* pSurfaceFormats)
282{
283 const VkLayerInstanceDispatchTable *disp;
284 disp = loader_get_instance_dispatch(physicalDevice);
285 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
286 physicalDevice,
287 surface,
288 pSurfaceFormatCount,
289 pSurfaceFormats);
290 return res;
291}
292
293/*
294 * This is the instance chain terminator function
295 * for GetPhysicalDeviceSurfaceFormatsKHR
296 */
297VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceFormatsKHR(
298 VkPhysicalDevice physicalDevice,
299 VkSurfaceKHR surface,
300 uint32_t* pSurfaceFormatCount,
301 VkSurfaceFormatKHR* pSurfaceFormats)
302{
303 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
304 struct loader_icd *icd = phys_dev->this_icd;
305
306 assert(pSurfaceFormatCount && "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
307
308 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR && "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
309
310 return icd->GetPhysicalDeviceSurfaceFormatsKHR(phys_dev->phys_dev,
311 surface,
312 pSurfaceFormatCount,
313 pSurfaceFormats);
314}
315
316/*
317 * This is the trampoline entrypoint
318 * for GetPhysicalDeviceSurfacePresentModesKHR
319 */
320LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(
321 VkPhysicalDevice physicalDevice,
322 VkSurfaceKHR surface,
323 uint32_t* pPresentModeCount,
324 VkPresentModeKHR* pPresentModes)
325{
326 const VkLayerInstanceDispatchTable *disp;
327 disp = loader_get_instance_dispatch(physicalDevice);
328 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
329 physicalDevice,
330 surface,
331 pPresentModeCount,
332 pPresentModes);
333 return res;
334}
335
336/*
337 * This is the instance chain terminator function
338 * for GetPhysicalDeviceSurfacePresentModesKHR
339 */
340VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfacePresentModesKHR(
341 VkPhysicalDevice physicalDevice,
342 VkSurfaceKHR surface,
343 uint32_t* pPresentModeCount,
344 VkPresentModeKHR* pPresentModes)
345{
346 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
347 struct loader_icd *icd = phys_dev->this_icd;
348
349 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: Error, null pPresentModeCount");
350
351 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
352
353 return icd->GetPhysicalDeviceSurfacePresentModesKHR(phys_dev->phys_dev,
354 surface,
355 pPresentModeCount,
356 pPresentModes);
357}
358
Ian Elliott2c05e222015-11-19 13:14:05 -0700359
Ian Elliott2c05e222015-11-19 13:14:05 -0700360/*
361 * Functions for the VK_KHR_swapchain extension:
362 */
363
Ian Elliott934d0d52015-11-19 16:39:21 -0700364/*
365 * This is the trampoline entrypoint
366 * for CreateSwapchainKHR
367 */
368LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
369 VkDevice device,
370 const VkSwapchainCreateInfoKHR* pCreateInfo,
371 const VkAllocationCallbacks* pAllocator,
372 VkSwapchainKHR* pSwapchain)
373{
374 const VkLayerDispatchTable *disp;
375 disp = loader_get_dispatch(device);
376 VkResult res = disp->CreateSwapchainKHR(
377 device,
378 pCreateInfo,
379 pAllocator,
380 pSwapchain);
381 return res;
382}
Ian Elliott2c05e222015-11-19 13:14:05 -0700383
Ian Elliott934d0d52015-11-19 16:39:21 -0700384/*
385 * This is the trampoline entrypoint
386 * for DestroySwapchainKHR
387 */
388LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(
389 VkDevice device,
390 VkSwapchainKHR swapchain,
391 const VkAllocationCallbacks* pAllocator)
392{
393 const VkLayerDispatchTable *disp;
394 disp = loader_get_dispatch(device);
395 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
396}
Ian Elliott2c05e222015-11-19 13:14:05 -0700397
Ian Elliott934d0d52015-11-19 16:39:21 -0700398/*
399 * This is the trampoline entrypoint
400 * for GetSwapchainImagesKHR
401 */
402LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
403 VkDevice device,
404 VkSwapchainKHR swapchain,
405 uint32_t* pSwapchainImageCount,
406 VkImage* pSwapchainImages)
407{
408 const VkLayerDispatchTable *disp;
409 disp = loader_get_dispatch(device);
410 VkResult res = disp->GetSwapchainImagesKHR(
411 device,
412 swapchain,
413 pSwapchainImageCount,
414 pSwapchainImages);
415 return res;
416}
417
418/*
419 * This is the trampoline entrypoint
420 * for AcquireNextImageKHR
421 */
422LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(
423 VkDevice device,
424 VkSwapchainKHR swapchain,
425 uint64_t timeout,
426 VkSemaphore semaphore,
427 VkFence fence,
428 uint32_t* pImageIndex)
429{
430 const VkLayerDispatchTable *disp;
431 disp = loader_get_dispatch(device);
432 VkResult res = disp->AcquireNextImageKHR(
433 device,
434 swapchain,
435 timeout,
436 semaphore,
437 fence,
438 pImageIndex);
439 return res;
440}
441
442/*
443 * This is the trampoline entrypoint
444 * for QueuePresentKHR
445 */
446LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(
447 VkQueue queue,
448 const VkPresentInfoKHR* pPresentInfo)
449{
450 const VkLayerDispatchTable *disp;
451 disp = loader_get_dispatch(queue);
452 VkResult res = disp->QueuePresentKHR(queue, pPresentInfo);
453 return res;
454}
Ian Elliott2c05e222015-11-19 13:14:05 -0700455
456
457#ifdef _WIN32
458
459#ifdef VK_USE_PLATFORM_WIN32_KHR
460
461/*
462 * Functions for the VK_KHR_win32_surface extension:
463 */
464
465/*
466 * This is the trampoline entrypoint
467 * for CreateWin32SurfaceKHR
468 */
469LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
470 VkInstance instance,
471 HINSTANCE hinstance,
472 HWND hwnd,
473 const VkAllocationCallbacks* pAllocator,
474 VkSurfaceKHR* pSurface)
475{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700476 const VkLayerInstanceDispatchTable *disp;
477 disp = loader_get_instance_dispatch(instance);
478 VkResult res;
479
480 res = disp->CreateWin32SurfaceKHR(instance, hinstance, hwnd, pAllocator, pSurface);
481 return res;
482}
483
484/*
485 * This is the instance chain terminator function
486 * for CreateWin32SurfaceKHR
487 */
488VKAPI_ATTR VkResult VKAPI_CALL loader_CreateWin32SurfaceKHR(
489 VkInstance instance,
490 HINSTANCE hinstance,
491 HWND hwnd,
492 const VkAllocationCallbacks* pAllocator,
493 VkSurfaceKHR* pSurface)
494{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700495 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700496 VkIcdSurfaceWin32 *pIcdSurface = NULL;
497
Ian Elliottdb4300a2015-11-23 10:17:23 -0700498 pIcdSurface = loader_heap_alloc(ptr_instance,
499 sizeof(VkIcdSurfaceWin32),
500 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700501 if (pIcdSurface == NULL) {
502 return VK_ERROR_OUT_OF_HOST_MEMORY;
503 }
504
505 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32;
506 pIcdSurface->hinstance = hinstance;
507 pIcdSurface->hwnd = hwnd;
508
509 *pSurface = (VkSurfaceKHR) pIcdSurface;
510
511 return VK_SUCCESS;
512}
Ian Elliott919fa302015-11-24 15:39:10 -0700513
514/*
515 * This is the trampoline entrypoint
516 * for GetPhysicalDeviceWin32PresentationSupportKHR
517 */
518LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
519 VkPhysicalDevice physicalDevice,
520 uint32_t queueFamilyIndex)
521{
522 const VkLayerInstanceDispatchTable *disp;
523 disp = loader_get_instance_dispatch(physicalDevice);
524 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
525 physicalDevice,
526 queueFamilyIndex);
527 return res;
528}
529
530
531/*
532 * This is the instance chain terminator function
533 * for GetPhysicalDeviceWin32PresentationSupportKHR
534 */
535VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceWin32PresentationSupportKHR(
536 VkPhysicalDevice physicalDevice,
537 uint32_t queueFamilyIndex)
538{
539 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
540 struct loader_icd *icd = phys_dev->this_icd;
541
Mark Lobodzinski65923652015-11-24 15:49:46 -0700542 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR && "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD pointer");
Ian Elliott919fa302015-11-24 15:39:10 -0700543
544 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
545 queueFamilyIndex);
546}
Ian Elliott2c05e222015-11-19 13:14:05 -0700547#endif/ VK_USE_PLATFORM_WIN32_KHR
548
549#else // _WIN32 (i.e. Linux)
550
551#ifdef VK_USE_PLATFORM_MIR_KHR
552
553/*
554 * Functions for the VK_KHR_mir_surface extension:
555 */
556
557/*
558 * This is the trampoline entrypoint
559 * for CreateMirSurfaceKHR
560 */
561LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
562 VkInstance instance,
563 MirConnection* connection,
564 MirSurface* mirSurface,
565 const VkAllocationCallbacks* pAllocator,
566 VkSurfaceKHR* pSurface)
567{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700568 const VkLayerInstanceDispatchTable *disp;
569 disp = loader_get_instance_dispatch(instance);
570 VkResult res;
571
572 res = disp->CreateMirSurfaceKHR(instance, connection, mirSurface, pAllocator, pSurface);
573 return res;
574}
575
576/*
577 * This is the instance chain terminator function
578 * for CreateMirSurfaceKHR
579 */
580VKAPI_ATTR VkResult VKAPI_CALL loader_CreateMirSurfaceKHR(
581 VkInstance instance,
582 Display* dpy,
583 Window window,
584 const VkAllocationCallbacks* pAllocator,
585 VkSurfaceKHR* pSurface)
586{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700587 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700588 VkIcdSurfaceMir *pIcdSurface = NULL;
589
Ian Elliottdb4300a2015-11-23 10:17:23 -0700590 pIcdSurface = loader_heap_alloc(ptr_instance,
591 sizeof(VkIcdSurfaceMir),
592 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700593 if (pIcdSurface == NULL) {
594 return VK_ERROR_OUT_OF_HOST_MEMORY;
595 }
596
597 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR;
598 pIcdSurface->connection = connection;
599 pIcdSurface->mirSurface = mirSurface;
600
601 *pSurface = (VkSurfaceKHR) pIcdSurface;
602
603 return VK_SUCCESS;
604}
Ian Elliott919fa302015-11-24 15:39:10 -0700605
606/*
607 * This is the trampoline entrypoint
608 * for GetPhysicalDeviceMirPresentationSupportKHR
609 */
610LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR(
611 VkPhysicalDevice physicalDevice,
612 uint32_t queueFamilyIndex,
613 MirConnection* connection)
614{
615 const VkLayerInstanceDispatchTable *disp;
616 disp = loader_get_instance_dispatch(physicalDevice);
617 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
618 physicalDevice,
619 queueFamilyIndex,
620 connection);
621 return res;
622}
623
624
625/*
626 * This is the instance chain terminator function
627 * for GetPhysicalDeviceMirPresentationSupportKHR
628 */
629VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceMirPresentationSupportKHR(
630 VkPhysicalDevice physicalDevice,
631 uint32_t queueFamilyIndex,
632 MirConnection* connection)
633{
634 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
635 struct loader_icd *icd = phys_dev->this_icd;
636
637 assert(icd->GetPhysicalDeviceMirPresentationSupportKHR && "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
638
639 return icd->GetPhysicalDeviceMirPresentationSupportKHR(phys_dev->phys_dev,
640 queueFamilyIndex,
641 connection);
642}
Ian Elliott2c05e222015-11-19 13:14:05 -0700643#endif // VK_USE_PLATFORM_MIR_KHR
644
645#ifdef VK_USE_PLATFORM_WAYLAND_KHR
646
647/*
648 * Functions for the VK_KHR_wayland_surface extension:
649 */
650
651/*
652 * This is the trampoline entrypoint
653 * for CreateWaylandSurfaceKHR
654 */
655LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(
656 VkInstance instance,
657 struct wl_display* display,
658 struct wl_surface* surface,
659 const VkAllocationCallbacks* pAllocator,
660 VkSurfaceKHR* pSurface)
661{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700662 const VkLayerInstanceDispatchTable *disp;
663 disp = loader_get_instance_dispatch(instance);
664 VkResult res;
665
666 res = disp->CreateWaylandSurfaceKHR(instance, display, surface, pAllocator, pSurface);
667 return res;
668}
669
670/*
671 * This is the instance chain terminator function
672 * for CreateXlibSurfaceKHR
673 */
674VKAPI_ATTR VkResult VKAPI_CALL loader_CreateWaylandSurfaceKHR(
675 VkInstance instance,
676 struct wl_display* display,
677 struct wl_surface* surface,
678 const VkAllocationCallbacks* pAllocator,
679 VkSurfaceKHR* pSurface)
680{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700681 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700682 VkIcdSurfaceWayland *pIcdSurface = NULL;
683
Ian Elliottdb4300a2015-11-23 10:17:23 -0700684 pIcdSurface = loader_heap_alloc(ptr_instance,
685 sizeof(VkIcdSurfaceWayland),
686 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700687 if (pIcdSurface == NULL) {
688 return VK_ERROR_OUT_OF_HOST_MEMORY;
689 }
690
691 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
692 pIcdSurface->display = display;
693 pIcdSurface->surface = surface;
694
695 *pSurface = (VkSurfaceKHR) pIcdSurface;
696
697 return VK_SUCCESS;
698}
Ian Elliott919fa302015-11-24 15:39:10 -0700699
700/*
701 * This is the trampoline entrypoint
702 * for GetPhysicalDeviceWaylandPresentationSupportKHR
703 */
704LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(
705 VkPhysicalDevice physicalDevice,
706 uint32_t queueFamilyIndex,
707 struct wl_display* display)
708{
709 const VkLayerInstanceDispatchTable *disp;
710 disp = loader_get_instance_dispatch(physicalDevice);
711 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
712 physicalDevice,
713 queueFamilyIndex,
714 display);
715 return res;
716}
717
718
719/*
720 * This is the instance chain terminator function
721 * for GetPhysicalDeviceWaylandPresentationSupportKHR
722 */
723VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceWaylandPresentationSupportKHR(
724 VkPhysicalDevice physicalDevice,
725 uint32_t queueFamilyIndex,
726 struct wl_display* display)
727{
728 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
729 struct loader_icd *icd = phys_dev->this_icd;
730
731 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR && "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD pointer");
732
733 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(phys_dev->phys_dev,
734 queueFamilyIndex,
735 display);
736}
Ian Elliott2c05e222015-11-19 13:14:05 -0700737#endif // VK_USE_PLATFORM_WAYLAND_KHR
738
739#ifdef VK_USE_PLATFORM_XCB_KHR
740
741/*
742 * Functions for the VK_KHR_xcb_surface extension:
743 */
744
745/*
746 * This is the trampoline entrypoint
747 * for CreateXcbSurfaceKHR
748 */
749LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
750 VkInstance instance,
751 xcb_connection_t* connection,
752 xcb_window_t window,
753 const VkAllocationCallbacks* pAllocator,
754 VkSurfaceKHR* pSurface)
755{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700756 const VkLayerInstanceDispatchTable *disp;
757 disp = loader_get_instance_dispatch(instance);
758 VkResult res;
759
760 res = disp->CreateXcbSurfaceKHR(instance, connection, window, pAllocator, pSurface);
761 return res;
762}
763
764/*
765 * This is the instance chain terminator function
766 * for CreateXcbSurfaceKHR
767 */
768VKAPI_ATTR VkResult VKAPI_CALL loader_CreateXcbSurfaceKHR(
769 VkInstance instance,
770 xcb_connection_t* connection,
771 xcb_window_t window,
772 const VkAllocationCallbacks* pAllocator,
773 VkSurfaceKHR* pSurface)
774{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700775 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700776 VkIcdSurfaceXcb *pIcdSurface = NULL;
777
Ian Elliottdb4300a2015-11-23 10:17:23 -0700778 pIcdSurface = loader_heap_alloc(ptr_instance,
779 sizeof(VkIcdSurfaceXcb),
780 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700781 if (pIcdSurface == NULL) {
782 return VK_ERROR_OUT_OF_HOST_MEMORY;
783 }
784
785 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB;
786 pIcdSurface->connection = connection;
787 pIcdSurface->window = window;
788
789 *pSurface = (VkSurfaceKHR) pIcdSurface;
790
791 return VK_SUCCESS;
792}
Ian Elliott919fa302015-11-24 15:39:10 -0700793
794/*
795 * This is the trampoline entrypoint
796 * for GetPhysicalDeviceXcbPresentationSupportKHR
797 */
798LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(
799 VkPhysicalDevice physicalDevice,
800 uint32_t queueFamilyIndex,
801 xcb_connection_t* connection,
802 xcb_visualid_t visual_id)
803{
804 const VkLayerInstanceDispatchTable *disp;
805 disp = loader_get_instance_dispatch(physicalDevice);
806 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
807 physicalDevice,
808 queueFamilyIndex,
809 connection,
810 visual_id);
811 return res;
812}
813
814
815/*
816 * This is the instance chain terminator function
817 * for GetPhysicalDeviceXcbPresentationSupportKHR
818 */
819VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceXcbPresentationSupportKHR(
820 VkPhysicalDevice physicalDevice,
821 uint32_t queueFamilyIndex,
822 xcb_connection_t* connection,
823 xcb_visualid_t visual_id)
824{
825 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
826 struct loader_icd *icd = phys_dev->this_icd;
827
828 assert(icd->GetPhysicalDeviceXcbPresentationSupportKHR && "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
829
830 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(phys_dev->phys_dev,
831 queueFamilyIndex,
832 connection,
833 visual_id);
834}
Ian Elliott2c05e222015-11-19 13:14:05 -0700835#endif // VK_USE_PLATFORM_XCB_KHR
836
837#ifdef VK_USE_PLATFORM_XLIB_KHR
838
839/*
840 * Functions for the VK_KHR_xlib_surface extension:
841 */
842
843/*
844 * This is the trampoline entrypoint
845 * for CreateXlibSurfaceKHR
846 */
847LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
848 VkInstance instance,
849 Display* dpy,
850 Window window,
851 const VkAllocationCallbacks* pAllocator,
852 VkSurfaceKHR* pSurface)
853{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700854 const VkLayerInstanceDispatchTable *disp;
855 disp = loader_get_instance_dispatch(instance);
856 VkResult res;
857
858 res = disp->CreateXlibSurfaceKHR(instance, dpy, window, pAllocator, pSurface);
859 return res;
860}
861
862/*
863 * This is the instance chain terminator function
864 * for CreateXlibSurfaceKHR
865 */
866VKAPI_ATTR VkResult VKAPI_CALL loader_CreateXlibSurfaceKHR(
867 VkInstance instance,
868 Display* dpy,
869 Window window,
870 const VkAllocationCallbacks* pAllocator,
871 VkSurfaceKHR* pSurface)
872{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700873 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700874 VkIcdSurfaceXlib *pIcdSurface = NULL;
875
Ian Elliottdb4300a2015-11-23 10:17:23 -0700876 pIcdSurface = loader_heap_alloc(ptr_instance,
877 sizeof(VkIcdSurfaceXlib),
878 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700879 if (pIcdSurface == NULL) {
880 return VK_ERROR_OUT_OF_HOST_MEMORY;
881 }
882
883 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
884 pIcdSurface->dpy = dpy;
885 pIcdSurface->window = window;
886
887 *pSurface = (VkSurfaceKHR) pIcdSurface;
888
889 return VK_SUCCESS;
890}
Ian Elliott919fa302015-11-24 15:39:10 -0700891
892/*
893 * This is the trampoline entrypoint
894 * for GetPhysicalDeviceXlibPresentationSupportKHR
895 */
896LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(
897 VkPhysicalDevice physicalDevice,
898 uint32_t queueFamilyIndex,
899 Display* dpy,
900 VisualID visualID)
901{
902 const VkLayerInstanceDispatchTable *disp;
903 disp = loader_get_instance_dispatch(physicalDevice);
904 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
905 physicalDevice,
906 queueFamilyIndex,
907 dpy,
908 visualID);
909 return res;
910}
911
912
913/*
914 * This is the instance chain terminator function
915 * for GetPhysicalDeviceXlibPresentationSupportKHR
916 */
917VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceXlibPresentationSupportKHR(
918 VkPhysicalDevice physicalDevice,
919 uint32_t queueFamilyIndex,
920 Display* dpy,
921 VisualID visualID)
922{
923 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
924 struct loader_icd *icd = phys_dev->this_icd;
925
926 assert(icd->GetPhysicalDeviceXlibPresentationSupportKHR && "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
927
928 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(phys_dev->phys_dev,
929 queueFamilyIndex,
930 dpy,
931 visualID);
932}
Ian Elliott2c05e222015-11-19 13:14:05 -0700933#endif // VK_USE_PLATFORM_XLIB_KHR
934
935#endif // _WIN32
936
937
Ian Elliott954fa342015-10-30 15:28:23 -0600938bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
939 const char* name, void **addr)
940{
941 *addr = NULL;
942
Ian Elliott934d0d52015-11-19 16:39:21 -0700943 /*
944 * Functions for the VK_KHR_surface extension:
945 */
Ian Elliott2c05e222015-11-19 13:14:05 -0700946 if (!strcmp("vkDestroySurfaceKHR", name)) {
947 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkDestroySurfaceKHR : NULL;
948 return true;
949 }
Ian Elliott954fa342015-10-30 15:28:23 -0600950 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Ian Elliott83e6aa92015-11-19 12:37:51 -0700951 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceSupportKHR : NULL;
Ian Elliott954fa342015-10-30 15:28:23 -0600952 return true;
953 }
Ian Elliott486c5502015-11-19 16:05:09 -0700954 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
955 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceCapabilitiesKHR : NULL;
956 return true;
957 }
958 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
959 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceFormatsKHR : NULL;
960 return true;
961 }
962 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
963 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfacePresentModesKHR : NULL;
964 return true;
965 }
Ian Elliott934d0d52015-11-19 16:39:21 -0700966
967 /*
968 * Functions for the VK_KHR_swapchain extension:
969 *
970 * Note: This is a device extension, and its functions are statically
971 * exported from the loader. Per Khronos decisions, the the loader's GIPA
972 * function will return the trampoline function for such device-extension
973 * functions, regardless of whether the extension has been enabled.
974 */
975 if (!strcmp("vkCreateSwapchainKHR", name)) {
976 *addr = (void *) vkCreateSwapchainKHR;
977 return true;
978 }
979 if (!strcmp("vkDestroySwapchainKHR", name)) {
980 *addr = (void *) vkDestroySwapchainKHR;
981 return true;
982 }
983 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
984 *addr = (void *) vkGetSwapchainImagesKHR;
985 return true;
986 }
987 if (!strcmp("vkAcquireNextImageKHR", name)) {
988 *addr = (void *) vkAcquireNextImageKHR;
989 return true;
990 }
991 if (!strcmp("vkQueuePresentKHR", name)) {
992 *addr = (void *) vkQueuePresentKHR;
993 return true;
994 }
995
Ian Elliott2c05e222015-11-19 13:14:05 -0700996#ifdef _WIN32
997#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -0700998 /*
999 * Functions for the VK_KHR_win32_surface extension:
1000 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001001 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
1002 *addr = ptr_instance->wsi_win32_surface_enabled ? (void *) vkCreateWin32SurfaceKHR : NULL;
1003 return true;
1004 }
Ian Elliott919fa302015-11-24 15:39:10 -07001005 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
1006 *addr = ptr_instance->wsi_win32_surface_enabled ? (void *) vkGetPhysicalDeviceWin32PresentationSupportKHR : NULL;
1007 return true;
1008 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001009#endif // VK_USE_PLATFORM_WIN32_KHR
1010#else // _WIN32 (i.e. Linux)
1011#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001012 /*
1013 * Functions for the VK_KHR_mir_surface extension:
1014 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001015 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
1016 *addr = ptr_instance->wsi_mir_surface_enabled ? (void *) vkCreateMirSurfaceKHR : NULL;
1017 return true;
1018 }
Ian Elliott919fa302015-11-24 15:39:10 -07001019 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
1020 *addr = ptr_instance->wsi_mir_surface_enabled ? (void *) vkGetPhysicalDeviceMirPresentationSupportKHR : NULL;
1021 return true;
Ian Elliott2c05e222015-11-19 13:14:05 -07001022#endif // VK_USE_PLATFORM_MIR_KHR
1023#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001024 /*
1025 * Functions for the VK_KHR_wayland_surface extension:
1026 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001027 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1028 *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *) vkCreateWaylandSurfaceKHR : NULL;
1029 return true;
1030 }
Ian Elliott919fa302015-11-24 15:39:10 -07001031 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1032 *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *) vkGetPhysicalDeviceWaylandPresentationSupportKHR : NULL;
1033 return true;
Ian Elliott2c05e222015-11-19 13:14:05 -07001034#endif // VK_USE_PLATFORM_WAYLAND_KHR
1035#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001036 /*
1037 * Functions for the VK_KHR_xcb_surface extension:
1038 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001039 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1040 *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *) vkCreateXcbSurfaceKHR : NULL;
1041 return true;
1042 }
Ian Elliott919fa302015-11-24 15:39:10 -07001043 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1044 *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *) vkGetPhysicalDeviceXcbPresentationSupportKHR : NULL;
1045 return true;
1046 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001047#endif // VK_USE_PLATFORM_XCB_KHR
1048#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001049 /*
1050 * Functions for the VK_KHR_xlib_surface extension:
1051 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001052 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1053 *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkCreateXlibSurfaceKHR : NULL;
1054 return true;
1055 }
Ian Elliott919fa302015-11-24 15:39:10 -07001056 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1057 *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkGetPhysicalDeviceXlibPresentationSupportKHR : NULL;
1058 return true;
Jon Ashburncc07f702015-11-30 08:23:10 -07001059 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001060#endif // VK_USE_PLATFORM_XLIB_KHR
1061#endif // _WIN32
1062
Ian Elliott954fa342015-10-30 15:28:23 -06001063 return false;
1064}