blob: c22459bbcaf69dc1249a1c9bc3de379ae072bbc0 [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
Ian Elliottc2e9aee2015-11-19 11:58:08 -070041#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060042static const VkExtensionProperties wsi_win32_surface_extension_info = {
43 .extensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
44 .specVersion = VK_KHR_WIN32_SURFACE_REVISION,
45};
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070046#endif // VK_USE_PLATFORM_WIN32_KHR
47
Ian Elliottaf7d6362015-10-30 17:45:05 -060048#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060049static const VkExtensionProperties wsi_mir_surface_extension_info = {
50 .extensionName = VK_KHR_MIR_SURFACE_EXTENSION_NAME,
51 .specVersion = VK_KHR_MIR_SURFACE_REVISION,
52};
Ian Elliottaf7d6362015-10-30 17:45:05 -060053#endif // VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060054
Ian Elliottaf7d6362015-10-30 17:45:05 -060055#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060056static const VkExtensionProperties wsi_wayland_surface_extension_info = {
57 .extensionName = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME,
58 .specVersion = VK_KHR_WAYLAND_SURFACE_REVISION,
59};
Ian Elliottaf7d6362015-10-30 17:45:05 -060060#endif // VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060061
Ian Elliottaf7d6362015-10-30 17:45:05 -060062#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060063static const VkExtensionProperties wsi_xcb_surface_extension_info = {
64 .extensionName = VK_KHR_XCB_SURFACE_EXTENSION_NAME,
65 .specVersion = VK_KHR_XCB_SURFACE_REVISION,
66};
Ian Elliottaf7d6362015-10-30 17:45:05 -060067#endif // VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060068
Ian Elliottaf7d6362015-10-30 17:45:05 -060069#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060070static const VkExtensionProperties wsi_xlib_surface_extension_info = {
71 .extensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
72 .specVersion = VK_KHR_XLIB_SURFACE_REVISION,
73};
Ian Elliottaf7d6362015-10-30 17:45:05 -060074#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070075
76#ifdef VK_USE_PLATFORM_ANDROID_KHR
77static const VkExtensionProperties wsi_android_surface_extension_info = {
78 .extensionName = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME,
79 .specVersion = VK_KHR_ANDROID_SURFACE_REVISION,
80};
81#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060082
83void wsi_add_instance_extensions(
84 const struct loader_instance *inst,
85 struct loader_extension_list *ext_list)
86{
87 loader_add_to_ext_list(inst, ext_list, 1, &wsi_surface_extension_info);
Ian Elliottc2e9aee2015-11-19 11:58:08 -070088#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060089 loader_add_to_ext_list(inst, ext_list, 1, &wsi_win32_surface_extension_info);
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -070090#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottaf7d6362015-10-30 17:45:05 -060091#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060092 loader_add_to_ext_list(inst, ext_list, 1, &wsi_mir_surface_extension_info);
Ian Elliottaf7d6362015-10-30 17:45:05 -060093#endif // VK_USE_PLATFORM_MIR_KHR
94#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060095 loader_add_to_ext_list(inst, ext_list, 1, &wsi_wayland_surface_extension_info);
Ian Elliottaf7d6362015-10-30 17:45:05 -060096#endif // VK_USE_PLATFORM_WAYLAND_KHR
97#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -060098 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xcb_surface_extension_info);
Ian Elliottaf7d6362015-10-30 17:45:05 -060099#endif // VK_USE_PLATFORM_XCB_KHR
100#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600101 loader_add_to_ext_list(inst, ext_list, 1, &wsi_xlib_surface_extension_info);
Ian Elliottaf7d6362015-10-30 17:45:05 -0600102#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700103#ifdef VK_USE_PLATFORM_ANDROID_KHR
104 loader_add_to_ext_list(inst, ext_list, 1, &wsi_android_surface_extension_info);
105#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600106}
107
108void wsi_create_instance(
109 struct loader_instance *ptr_instance,
110 const VkInstanceCreateInfo *pCreateInfo)
111{
Ian Elliottaf7d6362015-10-30 17:45:05 -0600112 ptr_instance->wsi_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700113
114#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliottdb4300a2015-11-23 10:17:23 -0700115 ptr_instance->wsi_win32_surface_enabled = true;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700116#endif // VK_USE_PLATFORM_WIN32_KHR
117#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600118 ptr_instance->wsi_mir_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700119#endif // VK_USE_PLATFORM_MIR_KHR
120#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600121 ptr_instance->wsi_wayland_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700122#endif // VK_USE_PLATFORM_WAYLAND_KHR
123#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600124 ptr_instance->wsi_xcb_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700125#endif // VK_USE_PLATFORM_XCB_KHR
126#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600127 ptr_instance->wsi_xlib_surface_enabled = false;
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700128#endif // VK_USE_PLATFORM_XLIB_KHR
129#ifdef VK_USE_PLATFORM_ANDROID_KHR
130 ptr_instance->wsi_android_surface_enabled = false;
131#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600132
133 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) {
134 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) {
135 ptr_instance->wsi_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700136 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600137 }
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700138#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600139 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) {
Ian Elliottdb4300a2015-11-23 10:17:23 -0700140 ptr_instance->wsi_win32_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700141 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600142 }
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700143#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliottaf7d6362015-10-30 17:45:05 -0600144#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600145 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) {
146 ptr_instance->wsi_mir_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700147 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600148 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600149#endif // VK_USE_PLATFORM_MIR_KHR
150#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600151 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) {
152 ptr_instance->wsi_wayland_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700153 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600154 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600155#endif // VK_USE_PLATFORM_WAYLAND_KHR
156#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600157 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) {
158 ptr_instance->wsi_xcb_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700159 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600160 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600161#endif // VK_USE_PLATFORM_XCB_KHR
162#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600163 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) {
164 ptr_instance->wsi_xlib_surface_enabled = true;
Ian Elliottc2e9aee2015-11-19 11:58:08 -0700165 continue;
Ian Elliott954fa342015-10-30 15:28:23 -0600166 }
Ian Elliottaf7d6362015-10-30 17:45:05 -0600167#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700168#ifdef VK_USE_PLATFORM_ANDROID_KHR
169 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) {
170 ptr_instance->wsi_android_surface_enabled = true;
171 continue;
172 }
173#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott954fa342015-10-30 15:28:23 -0600174 }
175}
176
177/*
Ian Elliott2c05e222015-11-19 13:14:05 -0700178 * Functions for the VK_KHR_surface extension:
179 */
180
181/*
182 * This is the trampoline entrypoint
183 * for DestroySurfaceKHR
Ian Elliott2c05e222015-11-19 13:14:05 -0700184 */
185LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(
186 VkInstance instance,
187 VkSurfaceKHR surface,
188 const VkAllocationCallbacks* pAllocator)
189{
Ian Elliottfb42cd72015-11-25 14:43:02 -0700190 const VkLayerInstanceDispatchTable *disp;
191 disp = loader_get_instance_dispatch(instance);
192 disp->DestroySurfaceKHR(instance, surface, pAllocator);
193}
194
195/*
196 * This is the instance chain terminator function
197 * for DestroySurfaceKHR
198 */
199VKAPI_ATTR void VKAPI_CALL loader_DestroySurfaceKHR(
200 VkInstance instance,
201 VkSurfaceKHR surface,
202 const VkAllocationCallbacks* pAllocator)
203{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700204 struct loader_instance *ptr_instance = loader_get_instance(instance);
205
206 loader_heap_free(ptr_instance, surface);
Ian Elliott2c05e222015-11-19 13:14:05 -0700207}
208
209/*
Ian Elliott954fa342015-10-30 15:28:23 -0600210 * This is the trampoline entrypoint
211 * for GetPhysicalDeviceSurfaceSupportKHR
212 */
Ian Elliott83e6aa92015-11-19 12:37:51 -0700213LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(
Ian Elliott954fa342015-10-30 15:28:23 -0600214 VkPhysicalDevice physicalDevice,
215 uint32_t queueFamilyIndex,
216 VkSurfaceKHR surface,
217 VkBool32* pSupported)
218{
219 const VkLayerInstanceDispatchTable *disp;
220 disp = loader_get_instance_dispatch(physicalDevice);
221 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
222 physicalDevice,
223 queueFamilyIndex,
224 surface,
225 pSupported);
226 return res;
227}
228
229/*
230 * This is the instance chain terminator function
231 * for GetPhysicalDeviceSurfaceSupportKHR
232 */
233VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceSupportKHR(
234 VkPhysicalDevice physicalDevice,
235 uint32_t queueFamilyIndex,
236 VkSurfaceKHR surface,
237 VkBool32* pSupported)
238{
239 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
240 struct loader_icd *icd = phys_dev->this_icd;
241
242 assert(pSupported && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
243 *pSupported = false;
244
245 assert(icd->GetPhysicalDeviceSurfaceSupportKHR && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
246
247 return icd->GetPhysicalDeviceSurfaceSupportKHR(phys_dev->phys_dev,
248 queueFamilyIndex,
249 surface,
250 pSupported);
251}
252
Ian Elliott486c5502015-11-19 16:05:09 -0700253/*
254 * This is the trampoline entrypoint
255 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
256 */
257LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
258 VkPhysicalDevice physicalDevice,
259 VkSurfaceKHR surface,
260 VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
261{
262 const VkLayerInstanceDispatchTable *disp;
263 disp = loader_get_instance_dispatch(physicalDevice);
264 VkResult res = disp->GetPhysicalDeviceSurfaceCapabilitiesKHR(
265 physicalDevice,
266 surface,
267 pSurfaceCapabilities);
268 return res;
269}
270
271/*
272 * This is the instance chain terminator function
273 * for GetPhysicalDeviceSurfaceCapabilitiesKHR
274 */
275VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceCapabilitiesKHR(
276 VkPhysicalDevice physicalDevice,
277 VkSurfaceKHR surface,
278 VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
279{
280 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
281 struct loader_icd *icd = phys_dev->this_icd;
282
283 assert(pSurfaceCapabilities && "GetPhysicalDeviceSurfaceCapabilitiesKHR: Error, null pSurfaceCapabilities");
284
285 assert(icd->GetPhysicalDeviceSurfaceCapabilitiesKHR && "loader: null GetPhysicalDeviceSurfaceCapabilitiesKHR ICD pointer");
286
287 return icd->GetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev->phys_dev,
288 surface,
289 pSurfaceCapabilities);
290}
291
292/*
293 * This is the trampoline entrypoint
294 * for GetPhysicalDeviceSurfaceFormatsKHR
295 */
296LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(
297 VkPhysicalDevice physicalDevice,
298 VkSurfaceKHR surface,
299 uint32_t* pSurfaceFormatCount,
300 VkSurfaceFormatKHR* pSurfaceFormats)
301{
302 const VkLayerInstanceDispatchTable *disp;
303 disp = loader_get_instance_dispatch(physicalDevice);
304 VkResult res = disp->GetPhysicalDeviceSurfaceFormatsKHR(
305 physicalDevice,
306 surface,
307 pSurfaceFormatCount,
308 pSurfaceFormats);
309 return res;
310}
311
312/*
313 * This is the instance chain terminator function
314 * for GetPhysicalDeviceSurfaceFormatsKHR
315 */
316VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfaceFormatsKHR(
317 VkPhysicalDevice physicalDevice,
318 VkSurfaceKHR surface,
319 uint32_t* pSurfaceFormatCount,
320 VkSurfaceFormatKHR* pSurfaceFormats)
321{
322 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
323 struct loader_icd *icd = phys_dev->this_icd;
324
325 assert(pSurfaceFormatCount && "GetPhysicalDeviceSurfaceFormatsKHR: Error, null pSurfaceFormatCount");
326
327 assert(icd->GetPhysicalDeviceSurfaceFormatsKHR && "loader: null GetPhysicalDeviceSurfaceFormatsKHR ICD pointer");
328
329 return icd->GetPhysicalDeviceSurfaceFormatsKHR(phys_dev->phys_dev,
330 surface,
331 pSurfaceFormatCount,
332 pSurfaceFormats);
333}
334
335/*
336 * This is the trampoline entrypoint
337 * for GetPhysicalDeviceSurfacePresentModesKHR
338 */
339LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(
340 VkPhysicalDevice physicalDevice,
341 VkSurfaceKHR surface,
342 uint32_t* pPresentModeCount,
343 VkPresentModeKHR* pPresentModes)
344{
345 const VkLayerInstanceDispatchTable *disp;
346 disp = loader_get_instance_dispatch(physicalDevice);
347 VkResult res = disp->GetPhysicalDeviceSurfacePresentModesKHR(
348 physicalDevice,
349 surface,
350 pPresentModeCount,
351 pPresentModes);
352 return res;
353}
354
355/*
356 * This is the instance chain terminator function
357 * for GetPhysicalDeviceSurfacePresentModesKHR
358 */
359VKAPI_ATTR VkResult VKAPI_CALL loader_GetPhysicalDeviceSurfacePresentModesKHR(
360 VkPhysicalDevice physicalDevice,
361 VkSurfaceKHR surface,
362 uint32_t* pPresentModeCount,
363 VkPresentModeKHR* pPresentModes)
364{
365 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
366 struct loader_icd *icd = phys_dev->this_icd;
367
368 assert(pPresentModeCount && "GetPhysicalDeviceSurfacePresentModesKHR: Error, null pPresentModeCount");
369
370 assert(icd->GetPhysicalDeviceSurfacePresentModesKHR && "loader: null GetPhysicalDeviceSurfacePresentModesKHR ICD pointer");
371
372 return icd->GetPhysicalDeviceSurfacePresentModesKHR(phys_dev->phys_dev,
373 surface,
374 pPresentModeCount,
375 pPresentModes);
376}
377
Ian Elliott2c05e222015-11-19 13:14:05 -0700378
Ian Elliott2c05e222015-11-19 13:14:05 -0700379/*
380 * Functions for the VK_KHR_swapchain extension:
381 */
382
Ian Elliott934d0d52015-11-19 16:39:21 -0700383/*
384 * This is the trampoline entrypoint
385 * for CreateSwapchainKHR
386 */
387LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
388 VkDevice device,
389 const VkSwapchainCreateInfoKHR* pCreateInfo,
390 const VkAllocationCallbacks* pAllocator,
391 VkSwapchainKHR* pSwapchain)
392{
393 const VkLayerDispatchTable *disp;
394 disp = loader_get_dispatch(device);
395 VkResult res = disp->CreateSwapchainKHR(
396 device,
397 pCreateInfo,
398 pAllocator,
399 pSwapchain);
400 return res;
401}
Ian Elliott2c05e222015-11-19 13:14:05 -0700402
Ian Elliott934d0d52015-11-19 16:39:21 -0700403/*
404 * This is the trampoline entrypoint
405 * for DestroySwapchainKHR
406 */
407LOADER_EXPORT VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(
408 VkDevice device,
409 VkSwapchainKHR swapchain,
410 const VkAllocationCallbacks* pAllocator)
411{
412 const VkLayerDispatchTable *disp;
413 disp = loader_get_dispatch(device);
414 disp->DestroySwapchainKHR(device, swapchain, pAllocator);
415}
Ian Elliott2c05e222015-11-19 13:14:05 -0700416
Ian Elliott934d0d52015-11-19 16:39:21 -0700417/*
418 * This is the trampoline entrypoint
419 * for GetSwapchainImagesKHR
420 */
421LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
422 VkDevice device,
423 VkSwapchainKHR swapchain,
424 uint32_t* pSwapchainImageCount,
425 VkImage* pSwapchainImages)
426{
427 const VkLayerDispatchTable *disp;
428 disp = loader_get_dispatch(device);
429 VkResult res = disp->GetSwapchainImagesKHR(
430 device,
431 swapchain,
432 pSwapchainImageCount,
433 pSwapchainImages);
434 return res;
435}
436
437/*
438 * This is the trampoline entrypoint
439 * for AcquireNextImageKHR
440 */
441LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(
442 VkDevice device,
443 VkSwapchainKHR swapchain,
444 uint64_t timeout,
445 VkSemaphore semaphore,
446 VkFence fence,
447 uint32_t* pImageIndex)
448{
449 const VkLayerDispatchTable *disp;
450 disp = loader_get_dispatch(device);
451 VkResult res = disp->AcquireNextImageKHR(
452 device,
453 swapchain,
454 timeout,
455 semaphore,
456 fence,
457 pImageIndex);
458 return res;
459}
460
461/*
462 * This is the trampoline entrypoint
463 * for QueuePresentKHR
464 */
465LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(
466 VkQueue queue,
467 const VkPresentInfoKHR* pPresentInfo)
468{
469 const VkLayerDispatchTable *disp;
470 disp = loader_get_dispatch(queue);
471 VkResult res = disp->QueuePresentKHR(queue, pPresentInfo);
472 return res;
473}
Ian Elliott2c05e222015-11-19 13:14:05 -0700474
475
Ian Elliott2c05e222015-11-19 13:14:05 -0700476#ifdef VK_USE_PLATFORM_WIN32_KHR
477
478/*
479 * Functions for the VK_KHR_win32_surface extension:
480 */
481
482/*
483 * This is the trampoline entrypoint
484 * for CreateWin32SurfaceKHR
485 */
486LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
487 VkInstance instance,
488 HINSTANCE hinstance,
489 HWND hwnd,
490 const VkAllocationCallbacks* pAllocator,
491 VkSurfaceKHR* pSurface)
492{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700493 const VkLayerInstanceDispatchTable *disp;
494 disp = loader_get_instance_dispatch(instance);
495 VkResult res;
496
497 res = disp->CreateWin32SurfaceKHR(instance, hinstance, hwnd, pAllocator, pSurface);
498 return res;
499}
500
501/*
502 * This is the instance chain terminator function
503 * for CreateWin32SurfaceKHR
504 */
505VKAPI_ATTR VkResult VKAPI_CALL loader_CreateWin32SurfaceKHR(
506 VkInstance instance,
507 HINSTANCE hinstance,
508 HWND hwnd,
509 const VkAllocationCallbacks* pAllocator,
510 VkSurfaceKHR* pSurface)
511{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700512 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700513 VkIcdSurfaceWin32 *pIcdSurface = NULL;
514
Ian Elliottdb4300a2015-11-23 10:17:23 -0700515 pIcdSurface = loader_heap_alloc(ptr_instance,
516 sizeof(VkIcdSurfaceWin32),
517 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700518 if (pIcdSurface == NULL) {
519 return VK_ERROR_OUT_OF_HOST_MEMORY;
520 }
521
522 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WIN32;
523 pIcdSurface->hinstance = hinstance;
524 pIcdSurface->hwnd = hwnd;
525
526 *pSurface = (VkSurfaceKHR) pIcdSurface;
527
528 return VK_SUCCESS;
529}
Ian Elliott919fa302015-11-24 15:39:10 -0700530
531/*
532 * This is the trampoline entrypoint
533 * for GetPhysicalDeviceWin32PresentationSupportKHR
534 */
535LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
536 VkPhysicalDevice physicalDevice,
537 uint32_t queueFamilyIndex)
538{
539 const VkLayerInstanceDispatchTable *disp;
540 disp = loader_get_instance_dispatch(physicalDevice);
541 VkBool32 res = disp->GetPhysicalDeviceWin32PresentationSupportKHR(
542 physicalDevice,
543 queueFamilyIndex);
544 return res;
545}
546
547
548/*
549 * This is the instance chain terminator function
550 * for GetPhysicalDeviceWin32PresentationSupportKHR
551 */
552VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceWin32PresentationSupportKHR(
553 VkPhysicalDevice physicalDevice,
554 uint32_t queueFamilyIndex)
555{
556 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
557 struct loader_icd *icd = phys_dev->this_icd;
558
Mark Lobodzinski65923652015-11-24 15:49:46 -0700559 assert(icd->GetPhysicalDeviceWin32PresentationSupportKHR && "loader: null GetPhysicalDeviceWin32PresentationSupportKHR ICD pointer");
Ian Elliott919fa302015-11-24 15:39:10 -0700560
561 return icd->GetPhysicalDeviceWin32PresentationSupportKHR(phys_dev->phys_dev,
562 queueFamilyIndex);
563}
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700564#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -0700565
566#ifdef VK_USE_PLATFORM_MIR_KHR
567
568/*
569 * Functions for the VK_KHR_mir_surface extension:
570 */
571
572/*
573 * This is the trampoline entrypoint
574 * for CreateMirSurfaceKHR
575 */
576LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
577 VkInstance instance,
578 MirConnection* connection,
579 MirSurface* mirSurface,
580 const VkAllocationCallbacks* pAllocator,
581 VkSurfaceKHR* pSurface)
582{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700583 const VkLayerInstanceDispatchTable *disp;
584 disp = loader_get_instance_dispatch(instance);
585 VkResult res;
586
587 res = disp->CreateMirSurfaceKHR(instance, connection, mirSurface, pAllocator, pSurface);
588 return res;
589}
590
591/*
592 * This is the instance chain terminator function
593 * for CreateMirSurfaceKHR
594 */
595VKAPI_ATTR VkResult VKAPI_CALL loader_CreateMirSurfaceKHR(
596 VkInstance instance,
597 Display* dpy,
598 Window window,
599 const VkAllocationCallbacks* pAllocator,
600 VkSurfaceKHR* pSurface)
601{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700602 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700603 VkIcdSurfaceMir *pIcdSurface = NULL;
604
Ian Elliottdb4300a2015-11-23 10:17:23 -0700605 pIcdSurface = loader_heap_alloc(ptr_instance,
606 sizeof(VkIcdSurfaceMir),
607 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700608 if (pIcdSurface == NULL) {
609 return VK_ERROR_OUT_OF_HOST_MEMORY;
610 }
611
612 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_MIR;
613 pIcdSurface->connection = connection;
614 pIcdSurface->mirSurface = mirSurface;
615
616 *pSurface = (VkSurfaceKHR) pIcdSurface;
617
618 return VK_SUCCESS;
619}
Ian Elliott919fa302015-11-24 15:39:10 -0700620
621/*
622 * This is the trampoline entrypoint
623 * for GetPhysicalDeviceMirPresentationSupportKHR
624 */
625LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR(
626 VkPhysicalDevice physicalDevice,
627 uint32_t queueFamilyIndex,
628 MirConnection* connection)
629{
630 const VkLayerInstanceDispatchTable *disp;
631 disp = loader_get_instance_dispatch(physicalDevice);
632 VkBool32 res = disp->GetPhysicalDeviceMirPresentationSupportKHR(
633 physicalDevice,
634 queueFamilyIndex,
635 connection);
636 return res;
637}
638
639
640/*
641 * This is the instance chain terminator function
642 * for GetPhysicalDeviceMirPresentationSupportKHR
643 */
644VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceMirPresentationSupportKHR(
645 VkPhysicalDevice physicalDevice,
646 uint32_t queueFamilyIndex,
647 MirConnection* connection)
648{
649 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
650 struct loader_icd *icd = phys_dev->this_icd;
651
652 assert(icd->GetPhysicalDeviceMirPresentationSupportKHR && "loader: null GetPhysicalDeviceMirPresentationSupportKHR ICD pointer");
653
654 return icd->GetPhysicalDeviceMirPresentationSupportKHR(phys_dev->phys_dev,
655 queueFamilyIndex,
656 connection);
657}
Ian Elliott2c05e222015-11-19 13:14:05 -0700658#endif // VK_USE_PLATFORM_MIR_KHR
659
660#ifdef VK_USE_PLATFORM_WAYLAND_KHR
661
662/*
663 * Functions for the VK_KHR_wayland_surface extension:
664 */
665
666/*
667 * This is the trampoline entrypoint
668 * for CreateWaylandSurfaceKHR
669 */
670LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(
671 VkInstance instance,
672 struct wl_display* display,
673 struct wl_surface* surface,
674 const VkAllocationCallbacks* pAllocator,
675 VkSurfaceKHR* pSurface)
676{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700677 const VkLayerInstanceDispatchTable *disp;
678 disp = loader_get_instance_dispatch(instance);
679 VkResult res;
680
681 res = disp->CreateWaylandSurfaceKHR(instance, display, surface, pAllocator, pSurface);
682 return res;
683}
684
685/*
686 * This is the instance chain terminator function
687 * for CreateXlibSurfaceKHR
688 */
689VKAPI_ATTR VkResult VKAPI_CALL loader_CreateWaylandSurfaceKHR(
690 VkInstance instance,
691 struct wl_display* display,
692 struct wl_surface* surface,
693 const VkAllocationCallbacks* pAllocator,
694 VkSurfaceKHR* pSurface)
695{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700696 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700697 VkIcdSurfaceWayland *pIcdSurface = NULL;
698
Ian Elliottdb4300a2015-11-23 10:17:23 -0700699 pIcdSurface = loader_heap_alloc(ptr_instance,
700 sizeof(VkIcdSurfaceWayland),
701 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700702 if (pIcdSurface == NULL) {
703 return VK_ERROR_OUT_OF_HOST_MEMORY;
704 }
705
706 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_WAYLAND;
707 pIcdSurface->display = display;
708 pIcdSurface->surface = surface;
709
710 *pSurface = (VkSurfaceKHR) pIcdSurface;
711
712 return VK_SUCCESS;
713}
Ian Elliott919fa302015-11-24 15:39:10 -0700714
715/*
716 * This is the trampoline entrypoint
717 * for GetPhysicalDeviceWaylandPresentationSupportKHR
718 */
719LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(
720 VkPhysicalDevice physicalDevice,
721 uint32_t queueFamilyIndex,
722 struct wl_display* display)
723{
724 const VkLayerInstanceDispatchTable *disp;
725 disp = loader_get_instance_dispatch(physicalDevice);
726 VkBool32 res = disp->GetPhysicalDeviceWaylandPresentationSupportKHR(
727 physicalDevice,
728 queueFamilyIndex,
729 display);
730 return res;
731}
732
733
734/*
735 * This is the instance chain terminator function
736 * for GetPhysicalDeviceWaylandPresentationSupportKHR
737 */
738VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceWaylandPresentationSupportKHR(
739 VkPhysicalDevice physicalDevice,
740 uint32_t queueFamilyIndex,
741 struct wl_display* display)
742{
743 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
744 struct loader_icd *icd = phys_dev->this_icd;
745
746 assert(icd->GetPhysicalDeviceWaylandPresentationSupportKHR && "loader: null GetPhysicalDeviceWaylandPresentationSupportKHR ICD pointer");
747
748 return icd->GetPhysicalDeviceWaylandPresentationSupportKHR(phys_dev->phys_dev,
749 queueFamilyIndex,
750 display);
751}
Ian Elliott2c05e222015-11-19 13:14:05 -0700752#endif // VK_USE_PLATFORM_WAYLAND_KHR
753
754#ifdef VK_USE_PLATFORM_XCB_KHR
755
756/*
757 * Functions for the VK_KHR_xcb_surface extension:
758 */
759
760/*
761 * This is the trampoline entrypoint
762 * for CreateXcbSurfaceKHR
763 */
764LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
765 VkInstance instance,
766 xcb_connection_t* connection,
767 xcb_window_t window,
768 const VkAllocationCallbacks* pAllocator,
769 VkSurfaceKHR* pSurface)
770{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700771 const VkLayerInstanceDispatchTable *disp;
772 disp = loader_get_instance_dispatch(instance);
773 VkResult res;
774
775 res = disp->CreateXcbSurfaceKHR(instance, connection, window, pAllocator, pSurface);
776 return res;
777}
778
779/*
780 * This is the instance chain terminator function
781 * for CreateXcbSurfaceKHR
782 */
783VKAPI_ATTR VkResult VKAPI_CALL loader_CreateXcbSurfaceKHR(
784 VkInstance instance,
785 xcb_connection_t* connection,
786 xcb_window_t window,
787 const VkAllocationCallbacks* pAllocator,
788 VkSurfaceKHR* pSurface)
789{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700790 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700791 VkIcdSurfaceXcb *pIcdSurface = NULL;
792
Ian Elliottdb4300a2015-11-23 10:17:23 -0700793 pIcdSurface = loader_heap_alloc(ptr_instance,
794 sizeof(VkIcdSurfaceXcb),
795 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700796 if (pIcdSurface == NULL) {
797 return VK_ERROR_OUT_OF_HOST_MEMORY;
798 }
799
800 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XCB;
801 pIcdSurface->connection = connection;
802 pIcdSurface->window = window;
803
804 *pSurface = (VkSurfaceKHR) pIcdSurface;
805
806 return VK_SUCCESS;
807}
Ian Elliott919fa302015-11-24 15:39:10 -0700808
809/*
810 * This is the trampoline entrypoint
811 * for GetPhysicalDeviceXcbPresentationSupportKHR
812 */
813LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(
814 VkPhysicalDevice physicalDevice,
815 uint32_t queueFamilyIndex,
816 xcb_connection_t* connection,
817 xcb_visualid_t visual_id)
818{
819 const VkLayerInstanceDispatchTable *disp;
820 disp = loader_get_instance_dispatch(physicalDevice);
821 VkBool32 res = disp->GetPhysicalDeviceXcbPresentationSupportKHR(
822 physicalDevice,
823 queueFamilyIndex,
824 connection,
825 visual_id);
826 return res;
827}
828
829
830/*
831 * This is the instance chain terminator function
832 * for GetPhysicalDeviceXcbPresentationSupportKHR
833 */
834VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceXcbPresentationSupportKHR(
835 VkPhysicalDevice physicalDevice,
836 uint32_t queueFamilyIndex,
837 xcb_connection_t* connection,
838 xcb_visualid_t visual_id)
839{
840 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
841 struct loader_icd *icd = phys_dev->this_icd;
842
843 assert(icd->GetPhysicalDeviceXcbPresentationSupportKHR && "loader: null GetPhysicalDeviceXcbPresentationSupportKHR ICD pointer");
844
845 return icd->GetPhysicalDeviceXcbPresentationSupportKHR(phys_dev->phys_dev,
846 queueFamilyIndex,
847 connection,
848 visual_id);
849}
Ian Elliott2c05e222015-11-19 13:14:05 -0700850#endif // VK_USE_PLATFORM_XCB_KHR
851
852#ifdef VK_USE_PLATFORM_XLIB_KHR
853
854/*
855 * Functions for the VK_KHR_xlib_surface extension:
856 */
857
858/*
859 * This is the trampoline entrypoint
860 * for CreateXlibSurfaceKHR
861 */
862LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
863 VkInstance instance,
864 Display* dpy,
865 Window window,
866 const VkAllocationCallbacks* pAllocator,
867 VkSurfaceKHR* pSurface)
868{
Jon Ashburnf72a04b2015-11-25 17:55:49 -0700869 const VkLayerInstanceDispatchTable *disp;
870 disp = loader_get_instance_dispatch(instance);
871 VkResult res;
872
873 res = disp->CreateXlibSurfaceKHR(instance, dpy, window, pAllocator, pSurface);
874 return res;
875}
876
877/*
878 * This is the instance chain terminator function
879 * for CreateXlibSurfaceKHR
880 */
881VKAPI_ATTR VkResult VKAPI_CALL loader_CreateXlibSurfaceKHR(
882 VkInstance instance,
883 Display* dpy,
884 Window window,
885 const VkAllocationCallbacks* pAllocator,
886 VkSurfaceKHR* pSurface)
887{
Ian Elliottdb4300a2015-11-23 10:17:23 -0700888 struct loader_instance *ptr_instance = loader_get_instance(instance);
Ian Elliott2c05e222015-11-19 13:14:05 -0700889 VkIcdSurfaceXlib *pIcdSurface = NULL;
890
Ian Elliottdb4300a2015-11-23 10:17:23 -0700891 pIcdSurface = loader_heap_alloc(ptr_instance,
892 sizeof(VkIcdSurfaceXlib),
893 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
Ian Elliott2c05e222015-11-19 13:14:05 -0700894 if (pIcdSurface == NULL) {
895 return VK_ERROR_OUT_OF_HOST_MEMORY;
896 }
897
898 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_XLIB;
899 pIcdSurface->dpy = dpy;
900 pIcdSurface->window = window;
901
902 *pSurface = (VkSurfaceKHR) pIcdSurface;
903
904 return VK_SUCCESS;
905}
Ian Elliott919fa302015-11-24 15:39:10 -0700906
907/*
908 * This is the trampoline entrypoint
909 * for GetPhysicalDeviceXlibPresentationSupportKHR
910 */
911LOADER_EXPORT VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(
912 VkPhysicalDevice physicalDevice,
913 uint32_t queueFamilyIndex,
914 Display* dpy,
915 VisualID visualID)
916{
917 const VkLayerInstanceDispatchTable *disp;
918 disp = loader_get_instance_dispatch(physicalDevice);
919 VkBool32 res = disp->GetPhysicalDeviceXlibPresentationSupportKHR(
920 physicalDevice,
921 queueFamilyIndex,
922 dpy,
923 visualID);
924 return res;
925}
926
927
928/*
929 * This is the instance chain terminator function
930 * for GetPhysicalDeviceXlibPresentationSupportKHR
931 */
932VKAPI_ATTR VkBool32 VKAPI_CALL loader_GetPhysicalDeviceXlibPresentationSupportKHR(
933 VkPhysicalDevice physicalDevice,
934 uint32_t queueFamilyIndex,
935 Display* dpy,
936 VisualID visualID)
937{
938 struct loader_physical_device *phys_dev = (struct loader_physical_device *) physicalDevice;
939 struct loader_icd *icd = phys_dev->this_icd;
940
941 assert(icd->GetPhysicalDeviceXlibPresentationSupportKHR && "loader: null GetPhysicalDeviceXlibPresentationSupportKHR ICD pointer");
942
943 return icd->GetPhysicalDeviceXlibPresentationSupportKHR(phys_dev->phys_dev,
944 queueFamilyIndex,
945 dpy,
946 visualID);
947}
Ian Elliott2c05e222015-11-19 13:14:05 -0700948#endif // VK_USE_PLATFORM_XLIB_KHR
949
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700950#ifdef VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -0700951
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -0700952/*
953 * Functions for the VK_KHR_android_surface extension:
954 */
955
956/*
957 * This is the trampoline entrypoint
958 * for CreateAndroidSurfaceKHR
959 */
960LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
961 VkInstance instance,
962 ANativeWindow* window,
963 const VkAllocationCallbacks* pAllocator,
964 VkSurfaceKHR* pSurface)
965{
966 const VkLayerInstanceDispatchTable *disp;
967 disp = loader_get_instance_dispatch(instance);
968 VkResult res;
969
970 res = disp->CreateAndroidSurfaceKHR(instance, window, pAllocator, pSurface);
971 return res;
972}
973
974/*
975 * This is the instance chain terminator function
976 * for CreateAndroidSurfaceKHR
977 */
978VKAPI_ATTR VkResult VKAPI_CALL loader_CreateAndroidSurfaceKHR(
979 VkInstance instance,
980 Window window,
981 const VkAllocationCallbacks* pAllocator,
982 VkSurfaceKHR* pSurface)
983{
984 struct loader_instance *ptr_instance = loader_get_instance(instance);
985 VkIcdSurfaceAndroid *pIcdSurface = NULL;
986
987 pIcdSurface = loader_heap_alloc(ptr_instance,
988 sizeof(VkIcdSurfaceAndroid),
989 VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
990 if (pIcdSurface == NULL) {
991 return VK_ERROR_OUT_OF_HOST_MEMORY;
992 }
993
994 pIcdSurface->base.platform = VK_ICD_WSI_PLATFORM_ANDROID;
995 pIcdSurface->dpy = dpy;
996 pIcdSurface->window = window;
997
998 *pSurface = (VkSurfaceKHR) pIcdSurface;
999
1000 return VK_SUCCESS;
1001}
1002
1003#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001004
Ian Elliott954fa342015-10-30 15:28:23 -06001005bool wsi_swapchain_instance_gpa(struct loader_instance *ptr_instance,
1006 const char* name, void **addr)
1007{
1008 *addr = NULL;
1009
Ian Elliott934d0d52015-11-19 16:39:21 -07001010 /*
1011 * Functions for the VK_KHR_surface extension:
1012 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001013 if (!strcmp("vkDestroySurfaceKHR", name)) {
1014 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkDestroySurfaceKHR : NULL;
1015 return true;
1016 }
Ian Elliott954fa342015-10-30 15:28:23 -06001017 if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) {
Ian Elliott83e6aa92015-11-19 12:37:51 -07001018 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceSupportKHR : NULL;
Ian Elliott954fa342015-10-30 15:28:23 -06001019 return true;
1020 }
Ian Elliott486c5502015-11-19 16:05:09 -07001021 if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) {
1022 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceCapabilitiesKHR : NULL;
1023 return true;
1024 }
1025 if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) {
1026 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfaceFormatsKHR : NULL;
1027 return true;
1028 }
1029 if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) {
1030 *addr = ptr_instance->wsi_surface_enabled ? (void *) vkGetPhysicalDeviceSurfacePresentModesKHR : NULL;
1031 return true;
1032 }
Ian Elliott934d0d52015-11-19 16:39:21 -07001033
1034 /*
1035 * Functions for the VK_KHR_swapchain extension:
1036 *
1037 * Note: This is a device extension, and its functions are statically
1038 * exported from the loader. Per Khronos decisions, the the loader's GIPA
1039 * function will return the trampoline function for such device-extension
1040 * functions, regardless of whether the extension has been enabled.
1041 */
1042 if (!strcmp("vkCreateSwapchainKHR", name)) {
1043 *addr = (void *) vkCreateSwapchainKHR;
1044 return true;
1045 }
1046 if (!strcmp("vkDestroySwapchainKHR", name)) {
1047 *addr = (void *) vkDestroySwapchainKHR;
1048 return true;
1049 }
1050 if (!strcmp("vkGetSwapchainImagesKHR", name)) {
1051 *addr = (void *) vkGetSwapchainImagesKHR;
1052 return true;
1053 }
1054 if (!strcmp("vkAcquireNextImageKHR", name)) {
1055 *addr = (void *) vkAcquireNextImageKHR;
1056 return true;
1057 }
1058 if (!strcmp("vkQueuePresentKHR", name)) {
1059 *addr = (void *) vkQueuePresentKHR;
1060 return true;
1061 }
1062
Ian Elliott2c05e222015-11-19 13:14:05 -07001063#ifdef VK_USE_PLATFORM_WIN32_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001064 /*
1065 * Functions for the VK_KHR_win32_surface extension:
1066 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001067 if (!strcmp("vkCreateWin32SurfaceKHR", name)) {
1068 *addr = ptr_instance->wsi_win32_surface_enabled ? (void *) vkCreateWin32SurfaceKHR : NULL;
1069 return true;
1070 }
Ian Elliott919fa302015-11-24 15:39:10 -07001071 if (!strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) {
1072 *addr = ptr_instance->wsi_win32_surface_enabled ? (void *) vkGetPhysicalDeviceWin32PresentationSupportKHR : NULL;
1073 return true;
1074 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001075#endif // VK_USE_PLATFORM_WIN32_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001076#ifdef VK_USE_PLATFORM_MIR_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001077 /*
1078 * Functions for the VK_KHR_mir_surface extension:
1079 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001080 if (!strcmp("vkCreateMirSurfaceKHR", name)) {
1081 *addr = ptr_instance->wsi_mir_surface_enabled ? (void *) vkCreateMirSurfaceKHR : NULL;
1082 return true;
1083 }
Ian Elliott919fa302015-11-24 15:39:10 -07001084 if (!strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) {
1085 *addr = ptr_instance->wsi_mir_surface_enabled ? (void *) vkGetPhysicalDeviceMirPresentationSupportKHR : NULL;
1086 return true;
Ian Elliott2c05e222015-11-19 13:14:05 -07001087#endif // VK_USE_PLATFORM_MIR_KHR
1088#ifdef VK_USE_PLATFORM_WAYLAND_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001089 /*
1090 * Functions for the VK_KHR_wayland_surface extension:
1091 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001092 if (!strcmp("vkCreateWaylandSurfaceKHR", name)) {
1093 *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *) vkCreateWaylandSurfaceKHR : NULL;
1094 return true;
1095 }
Ian Elliott919fa302015-11-24 15:39:10 -07001096 if (!strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) {
1097 *addr = ptr_instance->wsi_wayland_surface_enabled ? (void *) vkGetPhysicalDeviceWaylandPresentationSupportKHR : NULL;
1098 return true;
Ian Elliott2c05e222015-11-19 13:14:05 -07001099#endif // VK_USE_PLATFORM_WAYLAND_KHR
1100#ifdef VK_USE_PLATFORM_XCB_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001101 /*
1102 * Functions for the VK_KHR_xcb_surface extension:
1103 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001104 if (!strcmp("vkCreateXcbSurfaceKHR", name)) {
1105 *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *) vkCreateXcbSurfaceKHR : NULL;
1106 return true;
1107 }
Ian Elliott919fa302015-11-24 15:39:10 -07001108 if (!strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) {
1109 *addr = ptr_instance->wsi_xcb_surface_enabled ? (void *) vkGetPhysicalDeviceXcbPresentationSupportKHR : NULL;
1110 return true;
1111 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001112#endif // VK_USE_PLATFORM_XCB_KHR
1113#ifdef VK_USE_PLATFORM_XLIB_KHR
Ian Elliott934d0d52015-11-19 16:39:21 -07001114 /*
1115 * Functions for the VK_KHR_xlib_surface extension:
1116 */
Ian Elliott2c05e222015-11-19 13:14:05 -07001117 if (!strcmp("vkCreateXlibSurfaceKHR", name)) {
1118 *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkCreateXlibSurfaceKHR : NULL;
1119 return true;
1120 }
Ian Elliott919fa302015-11-24 15:39:10 -07001121 if (!strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) {
1122 *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkGetPhysicalDeviceXlibPresentationSupportKHR : NULL;
1123 return true;
Jon Ashburncc07f702015-11-30 08:23:10 -07001124 }
Ian Elliott2c05e222015-11-19 13:14:05 -07001125#endif // VK_USE_PLATFORM_XLIB_KHR
Mark Lobodzinskia8a5f852015-12-10 16:25:21 -07001126#ifdef VK_USE_PLATFORM_ANDROID_KHR
1127 /*
1128 * Functions for the VK_KHR_android_surface extension:
1129 */
1130 if (!strcmp("vkCreateAndroidSurfaceKHR", name)) {
1131 *addr = ptr_instance->wsi_xlib_surface_enabled ? (void *) vkCreateAndroidSurfaceKHR : NULL;
1132 return true;
1133 }
1134#endif // VK_USE_PLATFORM_ANDROID_KHR
Ian Elliott2c05e222015-11-19 13:14:05 -07001135
Ian Elliott954fa342015-10-30 15:28:23 -06001136 return false;
1137}