blob: 5bdf284d859249d8b2c97fbcd2182bd1769c1858 [file] [log] [blame]
Ian Elliott1d73e662015-07-06 14:36:13 -06001/*
2 * Vulkan
3 *
4 * Copyright (C) 2015 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Jon Ashburn <jon@lunarg.com>
26 * Courtney Goeltzenleuchter <courtney@lunarg.com>
27 * Ian Elliott <ian@lunarg.com>
28 */
29
Michael Lentine92689442015-09-09 12:39:13 -070030//#define _ISOC11_SOURCE /* for aligned_alloc() */
31#define _GNU_SOURCE
Ian Elliott1d73e662015-07-06 14:36:13 -060032#include <stdlib.h>
33#include <string.h>
34#include "vk_loader_platform.h"
35#include "loader.h"
36#include "wsi_swapchain.h"
37
Jon Ashburnc4748dc2015-08-04 11:14:18 -060038static const VkExtensionProperties wsi_swapchain_extension_info = {
Ian Elliott338dedb2015-08-21 15:09:33 -060039 .extName = VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME,
Ian Elliotta4e1c902015-09-04 14:02:04 -060040 .specVersion = VK_EXT_KHR_SWAPCHAIN_REVISION,
Ian Elliott1d73e662015-07-06 14:36:13 -060041};
42
43void wsi_swapchain_add_instance_extensions(
Jon Ashburne58f1a32015-08-28 13:38:21 -060044 const struct loader_instance *inst,
Ian Elliott1d73e662015-07-06 14:36:13 -060045 struct loader_extension_list *ext_list)
46{
Jon Ashburne58f1a32015-08-28 13:38:21 -060047 loader_add_to_ext_list(inst, ext_list, 1, &wsi_swapchain_extension_info);
Ian Elliott1d73e662015-07-06 14:36:13 -060048}
49
50void wsi_swapchain_create_instance(
51 struct loader_instance *ptr_instance,
52 const VkInstanceCreateInfo *pCreateInfo)
53{
54 ptr_instance->wsi_swapchain_enabled = false;
55
56 for (uint32_t i = 0; i < pCreateInfo->extensionCount; i++) {
Ian Elliott338dedb2015-08-21 15:09:33 -060057 if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) {
Ian Elliott1d73e662015-07-06 14:36:13 -060058 ptr_instance->wsi_swapchain_enabled = true;
59 return;
60 }
61 }
62}
63
64/*
65 * This is the trampoline entrypoint
Ian Elliott338dedb2015-08-21 15:09:33 -060066 * for GetPhysicalDeviceSurfaceSupportKHR
Ian Elliott1d73e662015-07-06 14:36:13 -060067 */
Ian Elliott338dedb2015-08-21 15:09:33 -060068VkResult wsi_swapchain_GetPhysicalDeviceSurfaceSupportKHR(
Ian Elliott1d73e662015-07-06 14:36:13 -060069 VkPhysicalDevice physicalDevice,
70 uint32_t queueNodeIndex,
Ian Elliott338dedb2015-08-21 15:09:33 -060071 const VkSurfaceDescriptionKHR* pSurfaceDescription,
Ian Elliott1d73e662015-07-06 14:36:13 -060072 VkBool32* pSupported)
73{
74 const VkLayerInstanceDispatchTable *disp;
75// TBD/TODO: DO WE NEED TO DO LOCKING FOR THIS FUNCTION?
76 disp = loader_get_instance_dispatch(physicalDevice);
Ian Elliott329da012015-09-22 10:51:24 -060077// loader_platform_thread_lock_mutex(&loader_lock);
Ian Elliott338dedb2015-08-21 15:09:33 -060078 VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR(
Ian Elliott1d73e662015-07-06 14:36:13 -060079 physicalDevice,
80 queueNodeIndex,
81 pSurfaceDescription,
82 pSupported);
Ian Elliott329da012015-09-22 10:51:24 -060083// loader_platform_thread_unlock_mutex(&loader_lock);
Ian Elliott1d73e662015-07-06 14:36:13 -060084 return res;
85}
86
87/*
88 * This is the instance chain terminator function
Ian Elliott338dedb2015-08-21 15:09:33 -060089 * for GetPhysicalDeviceSurfaceSupportKHR
Ian Elliott1d73e662015-07-06 14:36:13 -060090 */
Ian Elliott338dedb2015-08-21 15:09:33 -060091VkResult VKAPI loader_GetPhysicalDeviceSurfaceSupportKHR(
Ian Elliott1d73e662015-07-06 14:36:13 -060092 VkPhysicalDevice physicalDevice,
93 uint32_t queueNodeIndex,
Ian Elliott338dedb2015-08-21 15:09:33 -060094 const VkSurfaceDescriptionKHR* pSurfaceDescription,
Ian Elliott1d73e662015-07-06 14:36:13 -060095 VkBool32* pSupported)
96{
97 uint32_t gpu_index;
98 struct loader_icd *icd = loader_get_icd(physicalDevice, &gpu_index);
Courtney Goeltzenleuchterac544f32015-09-14 18:01:17 -060099
100 assert(pSupported && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported");
Ian Elliott1d73e662015-07-06 14:36:13 -0600101 *pSupported = false;
102
Courtney Goeltzenleuchterac544f32015-09-14 18:01:17 -0600103 assert(icd->GetPhysicalDeviceSurfaceSupportKHR && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer");
Ian Elliott1d73e662015-07-06 14:36:13 -0600104
Courtney Goeltzenleuchterac544f32015-09-14 18:01:17 -0600105 return icd->GetPhysicalDeviceSurfaceSupportKHR(physicalDevice,
106 queueNodeIndex,
107 pSurfaceDescription,
108 pSupported);
Ian Elliott1d73e662015-07-06 14:36:13 -0600109}
110
111
Ian Elliott1d73e662015-07-06 14:36:13 -0600112