2 * Copyright (c) 2016-2017, 2019, 2021 Arm Limited.
4 * SPDX-License-Identifier: MIT
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
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 THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 #include <wsi/wsi_factory.hpp>
27 #include "private_data.hpp"
28 #include "surface_api.hpp"
33 * @brief Implements vkGetPhysicalDeviceSurfaceCapabilitiesKHR Vulkan entrypoint.
35 VKAPI_ATTR VkResult wsi_layer_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice,
37 VkSurfaceCapabilitiesKHR *pSurfaceCapabilities)
39 auto &instance = layer::instance_private_data::get(physicalDevice);
40 if (instance.should_layer_handle_surface(physicalDevice, surface))
42 wsi::surface_properties *props = wsi::get_surface_properties(surface);
43 assert(props != nullptr);
44 return props->get_surface_capabilities(physicalDevice, surface, pSurfaceCapabilities);
47 /* If the layer cannot handle this surface, then necessarily the surface must have been created by the ICDs (or a
48 * layer below us.) So it is safe to assume that the ICDs (or layers below us) support VK_KHR_surface and therefore
49 * it is safe to can call down. This holds for other entrypoints below.
51 return instance.disp.GetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, pSurfaceCapabilities);
55 * @brief Implements vkGetPhysicalDeviceSurfaceFormatsKHR Vulkan entrypoint.
57 VKAPI_ATTR VkResult wsi_layer_vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice,
58 VkSurfaceKHR surface, uint32_t *pSurfaceFormatCount,
59 VkSurfaceFormatKHR *pSurfaceFormats)
61 auto &instance = layer::instance_private_data::get(physicalDevice);
62 if (instance.should_layer_handle_surface(physicalDevice, surface))
64 wsi::surface_properties *props = wsi::get_surface_properties(surface);
65 assert(props != nullptr);
66 return props->get_surface_formats(physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats);
69 return instance.disp.GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, pSurfaceFormatCount,
74 * @brief Implements vkGetPhysicalDeviceSurfacePresentModesKHR Vulkan entrypoint.
76 VKAPI_ATTR VkResult wsi_layer_vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice,
78 uint32_t *pPresentModeCount,
79 VkPresentModeKHR *pPresentModes)
81 auto &instance = layer::instance_private_data::get(physicalDevice);
82 if (instance.should_layer_handle_surface(physicalDevice, surface))
84 wsi::surface_properties *props = wsi::get_surface_properties(surface);
85 assert(props != nullptr);
86 return props->get_surface_present_modes(physicalDevice, surface, pPresentModeCount, pPresentModes);
89 return instance.disp.GetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, pPresentModeCount,
94 * @brief Implements vkGetPhysicalDeviceSurfaceSupportKHR Vulkan entrypoint.
96 VKAPI_ATTR VkResult wsi_layer_vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
97 uint32_t queueFamilyIndex, VkSurfaceKHR surface,
100 auto &instance = layer::instance_private_data::get(physicalDevice);
101 if (instance.should_layer_handle_surface(physicalDevice, surface))
103 *pSupported = VK_TRUE;
107 return instance.disp.GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, pSupported);