blob: 7d3616c333701968687a31ba6b9a7672912322fb [file] [log] [blame]
Ian Elliott54cea232015-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 Elliottb1849742015-11-19 11:58:08 -070024 * Author: Ian Elliott <ianelliott@google.com>
Ian Elliott54cea232015-10-30 15:28:23 -060025 */
26
Ian Elliottb1849742015-11-19 11:58:08 -070027// FIXME/TODO: DEVELOP A BETTER APPROACH FOR SETTING THE DEFAULT VALUES FOR
28// THESE PLATFORM-SPECIFIC MACROS APPROPRIATELY:
29#ifdef _WIN32
30// The Win32 default is to support the WIN32 platform:
31#ifndef VK_USE_PLATFORM_WIN32_KHR
32#define VK_USE_PLATFORM_WIN32_KHR
33#endif
34#else // _WIN32 (i.e. Linux)
35// The Linux default is to support the XCB platform:
36#if (!defined(VK_USE_PLATFORM_MIR_KHR) && \
37 !defined(VK_USE_PLATFORM_WAYLAND_KHR) && \
38 !defined(VK_USE_PLATFORM_XCB_KHR) && \
39 !defined(VK_USE_PLATFORM_XLIB_KHR))
40#define VK_USE_PLATFORM_XCB_KHR
41#endif
42#endif // _WIN32
43
Ian Elliott54cea232015-10-30 15:28:23 -060044//#define _ISOC11_SOURCE /* for aligned_alloc() */
45#define _GNU_SOURCE
46#include <stdlib.h>
47#include <string.h>
48#include "vk_loader_platform.h"
49#include "loader.h"
50#include "wsi.h"
Ian Elliott7c352552015-11-19 13:14:05 -070051#include <vulkan/vk_icd.h>
Ian Elliott54cea232015-10-30 15:28:23 -060052
53static const VkExtensionProperties wsi_surface_extension_info = {
54 .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
55 .specVersion = VK_KHR_SURFACE_REVISION,
56};
57
58#ifdef _WIN32
Ian Elliottb1849742015-11-19 11:58:08 -070059#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060060static const VkExtensionProperties wsi_win32_surface_extension_info = {
61 .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
62 .specVersion = VK_KHR_WIN32_SURFACE_REVISION,
63};
Ian Elliottb1849742015-11-19 11:58:08 -070064#endif/ VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060065#else // _WIN32
Ian Elliott5fb891a2015-10-30 17:45:05 -060066#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060067static const VkExtensionProperties wsi_mir_surface_extension_info = {
68 .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
69 .specVersion = VK_KHR_MIR_SURFACE_REVISION,
70};
Ian Elliott5fb891a2015-10-30 17:45:05 -060071#endif // VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060072
Ian Elliott5fb891a2015-10-30 17:45:05 -060073#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060074static const VkExtensionProperties wsi_wayland_surface_extension_info = {
75 .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
76 .specVersion = VK_KHR_WAYLAND_SURFACE_REVISION,
77};
Ian Elliott5fb891a2015-10-30 17:45:05 -060078#endif // VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060079
Ian Elliott5fb891a2015-10-30 17:45:05 -060080#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060081static const VkExtensionProperties wsi_xcb_surface_extension_info = {
82 .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
83 .specVersion = VK_KHR_XCB_SURFACE_REVISION,
84};
Ian Elliott5fb891a2015-10-30 17:45:05 -060085#endif // VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060086
Ian Elliott5fb891a2015-10-30 17:45:05 -060087#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060088static const VkExtensionProperties wsi_xlib_surface_extension_info = {
89 .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
90 .specVersion = VK_KHR_XLIB_SURFACE_REVISION,
91};
Ian Elliott5fb891a2015-10-30 17:45:05 -060092#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -060093#endif // _WIN32
94
95void wsi_add_instance_extensions(
96 const struct loader_instance *inst,
97 struct loader_extension_list *ext_list)
98{
99 loader_add_to_ext_list(inst, ext_list, 1, &wsi_surface_extension_info);
100#ifdef _WIN32
Ian Elliottb1849742015-11-19 11:58:08 -0700101#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600102 loader_add_to_ext_list(inst, ext_list, 1, &wsi_win32_surface_extension_info);
Ian Elliottb1849742015-11-19 11:58:08 -0700103#endif/ VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600104#else // _WIN32
Ian Elliott5fb891a2015-10-30 17:45:05 -0600105#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600106 loader_add_to_ext_list(inst, ext_list, 1, &wsi_mir_surface_extension_info);
Ian Elliott5fb891a2015-10-30 17:45:05 -0600107#endif // VK_USE_PLATFORM_MIR_KHR
108#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600109 loader_add_to_ext_list(inst, ext_list, 1, &wsi_wayland_surface_extension_info);
Ian Elliott5fb891a2015-10-30 17:45:05 -0600110#endif // VK_USE_PLATFORM_WAYLAND_KHR
111#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600112 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xcb_surface_extension_info);
Ian Elliott5fb891a2015-10-30 17:45:05 -0600113#endif // VK_USE_PLATFORM_XCB_KHR
114#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600115 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xlib_surface_extension_info);
Ian Elliott5fb891a2015-10-30 17:45:05 -0600116#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600117#endif // _WIN32
118}
119
120void wsi_create_instance(
121 struct loader_instance *ptr_instance,
122 const VkInstanceCreateInfo *pCreateInfo)
123{
Ian Elliott5fb891a2015-10-30 17:45:05 -0600124 ptr_instance->wsi_surface_enabled = false;
Ian Elliott54cea232015-10-30 15:28:23 -0600125#ifdef _WIN32
Ian Elliott1693f592015-11-23 10:17:23 -0700126 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliott54cea232015-10-30 15:28:23 -0600127#else // _WIN32
128 ptr_instance->wsi_mir_surface_enabled = false;
129 ptr_instance->wsi_wayland_surface_enabled = false;
130 ptr_instance->wsi_xcb_surface_enabled = false;
131 ptr_instance->wsi_xlib_surface_enabled = false;
132#endif // _WIN32
Ian Elliott54cea232015-10-30 15:28:23 -0600133
134 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
135 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
136 ptr_instance->wsi_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700137 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600138 }
139#ifdef _WIN32
Ian Elliottb1849742015-11-19 11:58:08 -0700140#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600141 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliott1693f592015-11-23 10:17:23 -0700142 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700143 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600144 }
Ian Elliottb1849742015-11-19 11:58:08 -0700145#endif/ VK_USE_PLATFORM_WIN32_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600146#else // _WIN32
Ian Elliott5fb891a2015-10-30 17:45:05 -0600147#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600148 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
149 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700150 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600151 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600152#endif // VK_USE_PLATFORM_MIR_KHR
153#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600154 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
155 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700156 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600157 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600158#endif // VK_USE_PLATFORM_WAYLAND_KHR
159#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600160 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
161 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700162 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600163 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600164#endif // VK_USE_PLATFORM_XCB_KHR
165#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600166 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
167 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliottb1849742015-11-19 11:58:08 -0700168 continue;
Ian Elliott54cea232015-10-30 15:28:23 -0600169 }
Ian Elliott5fb891a2015-10-30 17:45:05 -0600170#endif // VK_USE_PLATFORM_XLIB_KHR
Ian Elliott54cea232015-10-30 15:28:23 -0600171#endif // _WIN32
172 }
173}
174
175/*
Ian Elliott7c352552015-11-19 13:14:05 -0700176 * Functions for the VK_KHR_surface extension:
177 */
178
179/*
180 * This is the trampoline entrypoint
181 * for DestroySurfaceKHR
182 *
183 * Note: There is no terminator for this function.
184 */
185LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(
186 VkInstance instance,
187 VkSurfaceKHR surface,
188 const VkAllocationCallbacks* pAllocator)
189{
Ian Elliott1693f592015-11-23 10:17:23 -0700190 struct loader_instance *ptr_instance = loader_get_instance(instance);
191
192 loader_heap_free(ptr_instance, surface);
Ian Elliott7c352552015-11-19 13:14:05 -0700193}
194
195/*
Ian Elliott54cea232015-10-30 15:28:23 -0600196 * This is the trampoline entrypoint
197 * for GetPhysicalDeviceSurfaceSupportKHR
198 */
Ian Elliottf3be00f2015-11-19 12:37:51 -0700199LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(
Ian Elliott54cea232015-10-30 15:28:23 -0600200 VkPhysicalDevice physicalDevice,
201 uint32_t queueFamilyIndex,
202 VkSurfaceKHR surface,
203 VkBool32* pSupported)
204{
205 const VkLayerInstanceDispatchTable *disp;
206 disp = loader_get_instance_dispatch(physicalDevice);
207 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
208 physicalDevice,
209 queueFamilyIndex,
210 surface,
211 pSupported);
212 return res;
213}
214
215/*
216 * This is the instance chain terminator function
217 * for GetPhysicalDeviceSurfaceSupportKHR
218 */
219VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceSupportKHR(
220 VkPhysicalDevice physicalDevice,
221 uint32_t queueFamilyIndex,
222 VkSurfaceKHR surface,
223 VkBool32* pSupported)
224{
225 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
226 struct loader_icd *icd = phys_dev->this_icd;
227
228 assert(pSupported && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
229 *pSupported = false;
230
231 assert(icd->GetPhysicalDeviceSurfaceSupportKHR && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
232
233 return icd->GetPhysicalDeviceSurfaceSupportKHR(phys_dev->phys_dev,
234 queueFamilyIndex,
235 surface,
236 pSupported);
237}
238
Ian Elliottea666b22015-11-19 16:05:09 -0700239/*
240 * This is the trampoline entrypoint
241 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
242 */
243LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
244 VkPhysicalDevice physicalDevice,
245 VkSurfaceKHR surface,
246 VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
247{
248 const VkLayerInstanceDispatchTable *disp;
249 disp = loader_get_instance_dispatch(physicalDevice);
250 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
251 physicalDevice,
252 surface,
253 pSurfaceCapabilities);
254 return res;
255}
256
257/*
258 * This is the instance chain terminator function
259 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
260 */
261VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceCapabilitiesKHR(
262 VkPhysicalDevice physicalDevice,
263 VkSurfaceKHR surface,
264 VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
265{
266 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
267 struct loader_icd *icd = phys_dev->this_icd;
268
269 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: Error, null pSurfaceCapabilities");
270
271 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
272
273 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev->phys_dev,
274 surface,
275 pSurfaceCapabilities);
276}
277
278/*
279 * This is the trampoline entrypoint
280 * for GetPhysicalDeviceSurfaceFormatsKHR
281 */
282LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(
283 VkPhysicalDevice physicalDevice,
284 VkSurfaceKHR surface,
285 uint32_t* pSurfaceFormatCount,
286 VkSurfaceFormatKHR* pSurfaceFormats)
287{
288 const VkLayerInstanceDispatchTable *disp;
289 disp = loader_get_instance_dispatch(physicalDevice);
290 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
291 physicalDevice,
292 surface,
293 pSurfaceFormatCount,
294 pSurfaceFormats);
295 return res;
296}
297
298/*
299 * This is the instance chain terminator function
300 * for GetPhysicalDeviceSurfaceFormatsKHR
301 */
302VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceFormatsKHR(
303 VkPhysicalDevice physicalDevice,
304 VkSurfaceKHR surface,
305 uint32_t* pSurfaceFormatCount,
306 VkSurfaceFormatKHR* pSurfaceFormats)
307{
308 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
309 struct loader_icd *icd = phys_dev->this_icd;
310
311 assert(pSurfaceFormatCount && "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
312
313 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR && "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
314
315 return icd->GetPhysicalDeviceSurfaceFormatsKHR(phys_dev->phys_dev,
316 surface,
317 pSurfaceFormatCount,
318 pSurfaceFormats);
319}
320
321/*
322 * This is the trampoline entrypoint
323 * for GetPhysicalDeviceSurfacePresentModesKHR
324 */
325LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(
326 VkPhysicalDevice physicalDevice,
327 VkSurfaceKHR surface,
328 uint32_t* pPresentModeCount,
329 VkPresentModeKHR* pPresentModes)
330{
331 const VkLayerInstanceDispatchTable *disp;
332 disp = loader_get_instance_dispatch(physicalDevice);
333 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
334 physicalDevice,
335 surface,
336 pPresentModeCount,
337 pPresentModes);
338 return res;
339}
340
341/*
342 * This is the instance chain terminator function
343 * for GetPhysicalDeviceSurfacePresentModesKHR
344 */
345VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfacePresentModesKHR(
346 VkPhysicalDevice physicalDevice,
347 VkSurfaceKHR surface,
348 uint32_t* pPresentModeCount,
349 VkPresentModeKHR* pPresentModes)
350{
351 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
352 struct loader_icd *icd = phys_dev->this_icd;
353
354 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: Error, null pPresentModeCount");
355
356 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
357
358 return icd->GetPhysicalDeviceSurfacePresentModesKHR(phys_dev->phys_dev,
359 surface,
360 pPresentModeCount,
361 pPresentModes);
362}
363
Ian Elliott7c352552015-11-19 13:14:05 -0700364
Ian Elliott7c352552015-11-19 13:14:05 -0700365/*
366 * Functions for the VK_KHR_swapchain extension:
367 */
368
Ian Elliott9b89a472015-11-19 16:39:21 -0700369/*
370 * This is the trampoline entrypoint
371 * for CreateSwapchainKHR
372 */
373LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
374 VkDevice device,
375 const VkSwapchainCreateInfoKHR* pCreateInfo,
376 const VkAllocationCallbacks* pAllocator,
377 VkSwapchainKHR* pSwapchain)
378{
379 const VkLayerDispatchTable *disp;
380 disp = loader_get_dispatch(device);
381 VkResult res = disp->CreateSwapchainKHR(
382 device,
383 pCreateInfo,
384 pAllocator,
385 pSwapchain);
386 return res;
387}
Ian Elliott7c352552015-11-19 13:14:05 -0700388
Ian Elliott9b89a472015-11-19 16:39:21 -0700389/*
390 * This is the trampoline entrypoint
391 * for DestroySwapchainKHR
392 */
393LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(
394 VkDevice device,
395 VkSwapchainKHR swapchain,
396 const VkAllocationCallbacks* pAllocator)
397{
398 const VkLayerDispatchTable *disp;
399 disp = loader_get_dispatch(device);
400 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
401}
Ian Elliott7c352552015-11-19 13:14:05 -0700402
Ian Elliott9b89a472015-11-19 16:39:21 -0700403/*
404 * This is the trampoline entrypoint
405 * for GetSwapchainImagesKHR
406 */
407LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
408 VkDevice device,
409 VkSwapchainKHR swapchain,
410 uint32_t* pSwapchainImageCount,
411 VkImage* pSwapchainImages)
412{
413 const VkLayerDispatchTable *disp;
414 disp = loader_get_dispatch(device);
415 VkResult res = disp->GetSwapchainImagesKHR(
416 device,
417 swapchain,
418 pSwapchainImageCount,
419 pSwapchainImages);
420 return res;
421}
422
423/*
424 * This is the trampoline entrypoint
425 * for AcquireNextImageKHR
426 */
427LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(
428 VkDevice device,
429 VkSwapchainKHR swapchain,
430 uint64_t timeout,
431 VkSemaphore semaphore,
432 VkFence fence,
433 uint32_t* pImageIndex)
434{
435 const VkLayerDispatchTable *disp;
436 disp = loader_get_dispatch(device);
437 VkResult res = disp->AcquireNextImageKHR(
438 device,
439 swapchain,
440 timeout,
441 semaphore,
442 fence,
443 pImageIndex);
444 return res;
445}
446
447/*
448 * This is the trampoline entrypoint
449 * for QueuePresentKHR
450 */
451LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(
452 VkQueue queue,
453 const VkPresentInfoKHR* pPresentInfo)
454{
455 const VkLayerDispatchTable *disp;
456 disp = loader_get_dispatch(queue);
457 VkResult res = disp->QueuePresentKHR(queue, pPresentInfo);
458 return res;
459}
Ian Elliott7c352552015-11-19 13:14:05 -0700460
461
462#ifdef _WIN32
463
464#ifdef VK_USE_PLATFORM_WIN32_KHR
465
466/*
467 * Functions for the VK_KHR_win32_surface extension:
468 */
469
470/*
471 * This is the trampoline entrypoint
472 * for CreateWin32SurfaceKHR
473 */
474LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
475 VkInstance instance,
476 HINSTANCE hinstance,
477 HWND hwnd,
478 const VkAllocationCallbacks* pAllocator,
479 VkSurfaceKHR* pSurface)
480{
Ian Elliott1693f592015-11-23 10:17:23 -0700481 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott7c352552015-11-19 13:14:05 -0700482 VkIcdSurfaceWin32 *pIcdSurface = NULL;
483
Ian Elliott1693f592015-11-23 10:17:23 -0700484 pIcdSurface = loader_heap_alloc(ptr_instance,
485 sizeof(VkIcdSurfaceWin32),
486 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700487 if (pIcdSurface == NULL) {
488 return VK_ERROR_OUT_OF_HOST_MEMORY;
489 }
490
491 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32;
492 pIcdSurface->hinstance = hinstance;
493 pIcdSurface->hwnd = hwnd;
494
495 *pSurface = (VkSurfaceKHR) pIcdSurface;
496
497 return VK_SUCCESS;
498}
Ian Elliotte851dd62015-11-24 15:39:10 -0700499
500/*
501 * This is the trampoline entrypoint
502 * for GetPhysicalDeviceWin32PresentationSupportKHR
503 */
504LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
505 VkPhysicalDevice physicalDevice,
506 uint32_t queueFamilyIndex)
507{
508 const VkLayerInstanceDispatchTable *disp;
509 disp = loader_get_instance_dispatch(physicalDevice);
510 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
511 physicalDevice,
512 queueFamilyIndex);
513 return res;
514}
515
516
517/*
518 * This is the instance chain terminator function
519 * for GetPhysicalDeviceWin32PresentationSupportKHR
520 */
521VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceWin32PresentationSupportKHR(
522 VkPhysicalDevice physicalDevice,
523 uint32_t queueFamilyIndex)
524{
525 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
526 struct loader_icd *icd = phys_dev->this_icd;
527
Mark Lobodzinski3b8c1492015-11-24 15:49:46 -0700528 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR && "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD pointer");
Ian Elliotte851dd62015-11-24 15:39:10 -0700529
530 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
531 queueFamilyIndex);
532}
Ian Elliott7c352552015-11-19 13:14:05 -0700533#endif/ VK_USE_PLATFORM_WIN32_KHR
534
535#else // _WIN32 (i.e. Linux)
536
537#ifdef VK_USE_PLATFORM_MIR_KHR
538
539/*
540 * Functions for the VK_KHR_mir_surface extension:
541 */
542
543/*
544 * This is the trampoline entrypoint
545 * for CreateMirSurfaceKHR
546 */
547LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
548 VkInstance instance,
549 MirConnection* connection,
550 MirSurface* mirSurface,
551 const VkAllocationCallbacks* pAllocator,
552 VkSurfaceKHR* pSurface)
553{
Ian Elliott1693f592015-11-23 10:17:23 -0700554 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott7c352552015-11-19 13:14:05 -0700555 VkIcdSurfaceMir *pIcdSurface = NULL;
556
Ian Elliott1693f592015-11-23 10:17:23 -0700557 pIcdSurface = loader_heap_alloc(ptr_instance,
558 sizeof(VkIcdSurfaceMir),
559 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700560 if (pIcdSurface == NULL) {
561 return VK_ERROR_OUT_OF_HOST_MEMORY;
562 }
563
564 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR;
565 pIcdSurface->connection = connection;
566 pIcdSurface->mirSurface = mirSurface;
567
568 *pSurface = (VkSurfaceKHR) pIcdSurface;
569
570 return VK_SUCCESS;
571}
Ian Elliotte851dd62015-11-24 15:39:10 -0700572
573/*
574 * This is the trampoline entrypoint
575 * for GetPhysicalDeviceMirPresentationSupportKHR
576 */
577LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR(
578 VkPhysicalDevice physicalDevice,
579 uint32_t queueFamilyIndex,
580 MirConnection* connection)
581{
582 const VkLayerInstanceDispatchTable *disp;
583 disp = loader_get_instance_dispatch(physicalDevice);
584 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
585 physicalDevice,
586 queueFamilyIndex,
587 connection);
588 return res;
589}
590
591
592/*
593 * This is the instance chain terminator function
594 * for GetPhysicalDeviceMirPresentationSupportKHR
595 */
596VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceMirPresentationSupportKHR(
597 VkPhysicalDevice physicalDevice,
598 uint32_t queueFamilyIndex,
599 MirConnection* connection)
600{
601 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
602 struct loader_icd *icd = phys_dev->this_icd;
603
604 assert(icd->GetPhysicalDeviceMirPresentationSupportKHR && "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
605
606 return icd->GetPhysicalDeviceMirPresentationSupportKHR(phys_dev->phys_dev,
607 queueFamilyIndex,
608 connection);
609}
Ian Elliott7c352552015-11-19 13:14:05 -0700610#endif // VK_USE_PLATFORM_MIR_KHR
611
612#ifdef VK_USE_PLATFORM_WAYLAND_KHR
613
614/*
615 * Functions for the VK_KHR_wayland_surface extension:
616 */
617
618/*
619 * This is the trampoline entrypoint
620 * for CreateWaylandSurfaceKHR
621 */
622LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(
623 VkInstance instance,
624 struct wl_display* display,
625 struct wl_surface* surface,
626 const VkAllocationCallbacks* pAllocator,
627 VkSurfaceKHR* pSurface)
628{
Ian Elliott1693f592015-11-23 10:17:23 -0700629 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott7c352552015-11-19 13:14:05 -0700630 VkIcdSurfaceWayland *pIcdSurface = NULL;
631
Ian Elliott1693f592015-11-23 10:17:23 -0700632 pIcdSurface = loader_heap_alloc(ptr_instance,
633 sizeof(VkIcdSurfaceWayland),
634 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700635 if (pIcdSurface == NULL) {
636 return VK_ERROR_OUT_OF_HOST_MEMORY;
637 }
638
639 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
640 pIcdSurface->display = display;
641 pIcdSurface->surface = surface;
642
643 *pSurface = (VkSurfaceKHR) pIcdSurface;
644
645 return VK_SUCCESS;
646}
Ian Elliotte851dd62015-11-24 15:39:10 -0700647
648/*
649 * This is the trampoline entrypoint
650 * for GetPhysicalDeviceWaylandPresentationSupportKHR
651 */
652LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(
653 VkPhysicalDevice physicalDevice,
654 uint32_t queueFamilyIndex,
655 struct wl_display* display)
656{
657 const VkLayerInstanceDispatchTable *disp;
658 disp = loader_get_instance_dispatch(physicalDevice);
659 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
660 physicalDevice,
661 queueFamilyIndex,
662 display);
663 return res;
664}
665
666
667/*
668 * This is the instance chain terminator function
669 * for GetPhysicalDeviceWaylandPresentationSupportKHR
670 */
671VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceWaylandPresentationSupportKHR(
672 VkPhysicalDevice physicalDevice,
673 uint32_t queueFamilyIndex,
674 struct wl_display* display)
675{
676 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
677 struct loader_icd *icd = phys_dev->this_icd;
678
679 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR && "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD pointer");
680
681 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(phys_dev->phys_dev,
682 queueFamilyIndex,
683 display);
684}
Ian Elliott7c352552015-11-19 13:14:05 -0700685#endif // VK_USE_PLATFORM_WAYLAND_KHR
686
687#ifdef VK_USE_PLATFORM_XCB_KHR
688
689/*
690 * Functions for the VK_KHR_xcb_surface extension:
691 */
692
693/*
694 * This is the trampoline entrypoint
695 * for CreateXcbSurfaceKHR
696 */
697LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
698 VkInstance instance,
699 xcb_connection_t* connection,
700 xcb_window_t window,
701 const VkAllocationCallbacks* pAllocator,
702 VkSurfaceKHR* pSurface)
703{
Ian Elliott1693f592015-11-23 10:17:23 -0700704 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott7c352552015-11-19 13:14:05 -0700705 VkIcdSurfaceXcb *pIcdSurface = NULL;
706
Ian Elliott1693f592015-11-23 10:17:23 -0700707 pIcdSurface = loader_heap_alloc(ptr_instance,
708 sizeof(VkIcdSurfaceXcb),
709 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700710 if (pIcdSurface == NULL) {
711 return VK_ERROR_OUT_OF_HOST_MEMORY;
712 }
713
714 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB;
715 pIcdSurface->connection = connection;
716 pIcdSurface->window = window;
717
718 *pSurface = (VkSurfaceKHR) pIcdSurface;
719
720 return VK_SUCCESS;
721}
Ian Elliotte851dd62015-11-24 15:39:10 -0700722
723/*
724 * This is the trampoline entrypoint
725 * for GetPhysicalDeviceXcbPresentationSupportKHR
726 */
727LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(
728 VkPhysicalDevice physicalDevice,
729 uint32_t queueFamilyIndex,
730 xcb_connection_t* connection,
731 xcb_visualid_t visual_id)
732{
733 const VkLayerInstanceDispatchTable *disp;
734 disp = loader_get_instance_dispatch(physicalDevice);
735 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
736 physicalDevice,
737 queueFamilyIndex,
738 connection,
739 visual_id);
740 return res;
741}
742
743
744/*
745 * This is the instance chain terminator function
746 * for GetPhysicalDeviceXcbPresentationSupportKHR
747 */
748VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceXcbPresentationSupportKHR(
749 VkPhysicalDevice physicalDevice,
750 uint32_t queueFamilyIndex,
751 xcb_connection_t* connection,
752 xcb_visualid_t visual_id)
753{
754 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
755 struct loader_icd *icd = phys_dev->this_icd;
756
757 assert(icd->GetPhysicalDeviceXcbPresentationSupportKHR && "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
758
759 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(phys_dev->phys_dev,
760 queueFamilyIndex,
761 connection,
762 visual_id);
763}
Ian Elliott7c352552015-11-19 13:14:05 -0700764#endif // VK_USE_PLATFORM_XCB_KHR
765
766#ifdef VK_USE_PLATFORM_XLIB_KHR
767
768/*
769 * Functions for the VK_KHR_xlib_surface extension:
770 */
771
772/*
773 * This is the trampoline entrypoint
774 * for CreateXlibSurfaceKHR
775 */
776LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
777 VkInstance instance,
778 Display* dpy,
779 Window window,
780 const VkAllocationCallbacks* pAllocator,
781 VkSurfaceKHR* pSurface)
782{
Ian Elliott1693f592015-11-23 10:17:23 -0700783 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott7c352552015-11-19 13:14:05 -0700784 VkIcdSurfaceXlib *pIcdSurface = NULL;
785
Ian Elliott1693f592015-11-23 10:17:23 -0700786 pIcdSurface = loader_heap_alloc(ptr_instance,
787 sizeof(VkIcdSurfaceXlib),
788 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott7c352552015-11-19 13:14:05 -0700789 if (pIcdSurface == NULL) {
790 return VK_ERROR_OUT_OF_HOST_MEMORY;
791 }
792
793 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
794 pIcdSurface->dpy = dpy;
795 pIcdSurface->window = window;
796
797 *pSurface = (VkSurfaceKHR) pIcdSurface;
798
799 return VK_SUCCESS;
800}
Ian Elliotte851dd62015-11-24 15:39:10 -0700801
802/*
803 * This is the trampoline entrypoint
804 * for GetPhysicalDeviceXlibPresentationSupportKHR
805 */
806LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(
807 VkPhysicalDevice physicalDevice,
808 uint32_t queueFamilyIndex,
809 Display* dpy,
810 VisualID visualID)
811{
812 const VkLayerInstanceDispatchTable *disp;
813 disp = loader_get_instance_dispatch(physicalDevice);
814 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
815 physicalDevice,
816 queueFamilyIndex,
817 dpy,
818 visualID);
819 return res;
820}
821
822
823/*
824 * This is the instance chain terminator function
825 * for GetPhysicalDeviceXlibPresentationSupportKHR
826 */
827VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceXlibPresentationSupportKHR(
828 VkPhysicalDevice physicalDevice,
829 uint32_t queueFamilyIndex,
830 Display* dpy,
831 VisualID visualID)
832{
833 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
834 struct loader_icd *icd = phys_dev->this_icd;
835
836 assert(icd->GetPhysicalDeviceXlibPresentationSupportKHR && "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
837
838 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(phys_dev->phys_dev,
839 queueFamilyIndex,
840 dpy,
841 visualID);
842}
Ian Elliott7c352552015-11-19 13:14:05 -0700843#endif // VK_USE_PLATFORM_XLIB_KHR
844
845#endif // _WIN32
846
847
Ian Elliott54cea232015-10-30 15:28:23 -0600848bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
849 const char* name, void **addr)
850{
851 *addr = NULL;
852
Ian Elliott9b89a472015-11-19 16:39:21 -0700853 /*
854 * Functions for the VK_KHR_surface extension:
855 */
Ian Elliott7c352552015-11-19 13:14:05 -0700856 if (!strcmp("vkDestroySurfaceKHR", name)) {
857 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkDestroySurfaceKHR : NULL;
858 return true;
859 }
Ian Elliott54cea232015-10-30 15:28:23 -0600860 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Ian Elliottf3be00f2015-11-19 12:37:51 -0700861 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceSupportKHR : NULL;
Ian Elliott54cea232015-10-30 15:28:23 -0600862 return true;
863 }
Ian Elliottea666b22015-11-19 16:05:09 -0700864 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
865 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceCapabilitiesKHR : NULL;
866 return true;
867 }
868 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
869 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceFormatsKHR : NULL;
870 return true;
871 }
872 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
873 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfacePresentModesKHR : NULL;
874 return true;
875 }
Ian Elliott9b89a472015-11-19 16:39:21 -0700876
877 /*
878 * Functions for the VK_KHR_swapchain extension:
879 *
880 * Note: This is a device extension, and its functions are statically
881 * exported from the loader. Per Khronos decisions, the the loader's GIPA
882 * function will return the trampoline function for such device-extension
883 * functions, regardless of whether the extension has been enabled.
884 */
885 if (!strcmp("vkCreateSwapchainKHR", name)) {
886 *addr = (void *) vkCreateSwapchainKHR;
887 return true;
888 }
889 if (!strcmp("vkDestroySwapchainKHR", name)) {
890 *addr = (void *) vkDestroySwapchainKHR;
891 return true;
892 }
893 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
894 *addr = (void *) vkGetSwapchainImagesKHR;
895 return true;
896 }
897 if (!strcmp("vkAcquireNextImageKHR", name)) {
898 *addr = (void *) vkAcquireNextImageKHR;
899 return true;
900 }
901 if (!strcmp("vkQueuePresentKHR", name)) {
902 *addr = (void *) vkQueuePresentKHR;
903 return true;
904 }
905
Ian Elliott7c352552015-11-19 13:14:05 -0700906#ifdef _WIN32
907#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott9b89a472015-11-19 16:39:21 -0700908 /*
909 * Functions for the VK_KHR_win32_surface extension:
910 */
Ian Elliott7c352552015-11-19 13:14:05 -0700911 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
912 *addr = ptr_instance->wsi_win32_surface_enabled ? (void *) vkCreateWin32SurfaceKHR : NULL;
913 return true;
914 }
Ian Elliotte851dd62015-11-24 15:39:10 -0700915 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
916 *addr = ptr_instance->wsi_win32_surface_enabled ? (void *) vkGetPhysicalDeviceWin32PresentationSupportKHR : NULL;
917 return true;
918 }
Ian Elliott7c352552015-11-19 13:14:05 -0700919#endif // VK_USE_PLATFORM_WIN32_KHR
920#else // _WIN32 (i.e. Linux)
921#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott9b89a472015-11-19 16:39:21 -0700922 /*
923 * Functions for the VK_KHR_mir_surface extension:
924 */
Ian Elliott7c352552015-11-19 13:14:05 -0700925 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
926 *addr = ptr_instance->wsi_mir_surface_enabled ? (void *) vkCreateMirSurfaceKHR : NULL;
927 return true;
928 }
Ian Elliotte851dd62015-11-24 15:39:10 -0700929 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
930 *addr = ptr_instance->wsi_mir_surface_enabled ? (void *) vkGetPhysicalDeviceMirPresentationSupportKHR : NULL;
931 return true;
Ian Elliott7c352552015-11-19 13:14:05 -0700932#endif // VK_USE_PLATFORM_MIR_KHR
933#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott9b89a472015-11-19 16:39:21 -0700934 /*
935 * Functions for the VK_KHR_wayland_surface extension:
936 */
Ian Elliott7c352552015-11-19 13:14:05 -0700937 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
938 *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *) vkCreateWaylandSurfaceKHR : NULL;
939 return true;
940 }
Ian Elliotte851dd62015-11-24 15:39:10 -0700941 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
942 *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *) vkGetPhysicalDeviceWaylandPresentationSupportKHR : NULL;
943 return true;
Ian Elliott7c352552015-11-19 13:14:05 -0700944#endif // VK_USE_PLATFORM_WAYLAND_KHR
945#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott9b89a472015-11-19 16:39:21 -0700946 /*
947 * Functions for the VK_KHR_xcb_surface extension:
948 */
Ian Elliott7c352552015-11-19 13:14:05 -0700949 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
950 *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *) vkCreateXcbSurfaceKHR : NULL;
951 return true;
952 }
Ian Elliotte851dd62015-11-24 15:39:10 -0700953 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
954 *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *) vkGetPhysicalDeviceXcbPresentationSupportKHR : NULL;
955 return true;
956 }
Ian Elliott7c352552015-11-19 13:14:05 -0700957#endif // VK_USE_PLATFORM_XCB_KHR
958#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott9b89a472015-11-19 16:39:21 -0700959 /*
960 * Functions for the VK_KHR_xlib_surface extension:
961 */
Ian Elliott7c352552015-11-19 13:14:05 -0700962 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
963 *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkCreateXlibSurfaceKHR : NULL;
964 return true;
965 }
Ian Elliotte851dd62015-11-24 15:39:10 -0700966 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
967 *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkGetPhysicalDeviceXlibPresentationSupportKHR : NULL;
968 return true;
Ian Elliott7c352552015-11-19 13:14:05 -0700969#endif // VK_USE_PLATFORM_XLIB_KHR
970#endif // _WIN32
971
Ian Elliott54cea232015-10-30 15:28:23 -0600972 return false;
973}