Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 1 | /* |
| 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 Lentine | 9268944 | 2015-09-09 12:39:13 -0700 | [diff] [blame] | 30 | //#define _ISOC11_SOURCE /* for aligned_alloc() */ |
| 31 | #define _GNU_SOURCE |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 32 | #include <stdlib.h> |
| 33 | #include <string.h> |
| 34 | #include "vk_loader_platform.h" |
| 35 | #include "loader.h" |
| 36 | #include "wsi_swapchain.h" |
| 37 | |
Jon Ashburn | c4748dc | 2015-08-04 11:14:18 -0600 | [diff] [blame] | 38 | static const VkExtensionProperties wsi_swapchain_extension_info = { |
Ian Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 39 | .extName = VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME, |
Ian Elliott | a4e1c90 | 2015-09-04 14:02:04 -0600 | [diff] [blame] | 40 | .specVersion = VK_EXT_KHR_SWAPCHAIN_REVISION, |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | void wsi_swapchain_add_instance_extensions( |
Jon Ashburn | e58f1a3 | 2015-08-28 13:38:21 -0600 | [diff] [blame] | 44 | const struct loader_instance *inst, |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 45 | struct loader_extension_list *ext_list) |
| 46 | { |
Jon Ashburn | e58f1a3 | 2015-08-28 13:38:21 -0600 | [diff] [blame] | 47 | loader_add_to_ext_list(inst, ext_list, 1, &wsi_swapchain_extension_info); |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | void 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 Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 57 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) { |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 58 | ptr_instance->wsi_swapchain_enabled = true; |
| 59 | return; |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /* |
| 65 | * This is the trampoline entrypoint |
Ian Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 66 | * for GetPhysicalDeviceSurfaceSupportKHR |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 67 | */ |
Ian Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 68 | VkResult wsi_swapchain_GetPhysicalDeviceSurfaceSupportKHR( |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 69 | VkPhysicalDevice physicalDevice, |
| 70 | uint32_t queueNodeIndex, |
Ian Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 71 | const VkSurfaceDescriptionKHR* pSurfaceDescription, |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 72 | 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 Elliott | 329da01 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 77 | // loader_platform_thread_lock_mutex(&loader_lock); |
Ian Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 78 | VkResult res = disp->GetPhysicalDeviceSurfaceSupportKHR( |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 79 | physicalDevice, |
| 80 | queueNodeIndex, |
| 81 | pSurfaceDescription, |
| 82 | pSupported); |
Ian Elliott | 329da01 | 2015-09-22 10:51:24 -0600 | [diff] [blame] | 83 | // loader_platform_thread_unlock_mutex(&loader_lock); |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 84 | return res; |
| 85 | } |
| 86 | |
| 87 | /* |
| 88 | * This is the instance chain terminator function |
Ian Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 89 | * for GetPhysicalDeviceSurfaceSupportKHR |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 90 | */ |
Ian Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 91 | VkResult VKAPI loader_GetPhysicalDeviceSurfaceSupportKHR( |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 92 | VkPhysicalDevice physicalDevice, |
| 93 | uint32_t queueNodeIndex, |
Ian Elliott | 338dedb | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 94 | const VkSurfaceDescriptionKHR* pSurfaceDescription, |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 95 | VkBool32* pSupported) |
| 96 | { |
| 97 | uint32_t gpu_index; |
| 98 | struct loader_icd *icd = loader_get_icd(physicalDevice, &gpu_index); |
Courtney Goeltzenleuchter | ac544f3 | 2015-09-14 18:01:17 -0600 | [diff] [blame] | 99 | |
| 100 | assert(pSupported && "GetPhysicalDeviceSurfaceSupportKHR: Error, null pSupported"); |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 101 | *pSupported = false; |
| 102 | |
Courtney Goeltzenleuchter | ac544f3 | 2015-09-14 18:01:17 -0600 | [diff] [blame] | 103 | assert(icd->GetPhysicalDeviceSurfaceSupportKHR && "loader: null GetPhysicalDeviceSurfaceSupportKHR ICD pointer"); |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 104 | |
Courtney Goeltzenleuchter | ac544f3 | 2015-09-14 18:01:17 -0600 | [diff] [blame] | 105 | return icd->GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, |
| 106 | queueNodeIndex, |
| 107 | pSurfaceDescription, |
| 108 | pSupported); |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | |
Ian Elliott | 1d73e66 | 2015-07-06 14:36:13 -0600 | [diff] [blame] | 112 | |