2 * Copyright (c) 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
27 * @brief Contains the factory methods for obtaining the specific surface and swapchain implementations.
33 #include "swapchain_base_tizen.hpp"
35 #include "swapchain_base.hpp"
37 #include "surface_properties.hpp"
38 #include "util/platform_set.hpp"
40 #include <unordered_map>
46 * @brief Obtains the surface properties for the specific surface type.
48 * @param surface The surface for which to get the properties.
50 * @return nullptr if surface type is unsupported.
52 surface_properties *get_surface_properties(VkSurfaceKHR surface);
55 * @brief Allocates a surface specific swapchain.
57 * @param surface The surface for which a swapchain is allocated.
58 * @param dev_data The device specific data.
59 * @param pAllocator The allocator from which to allocate any memory.
61 * @return nullptr on failure.
63 swapchain_base *allocate_surface_swapchain(VkSurfaceKHR surface, layer::device_private_data &dev_data,
64 const VkAllocationCallbacks *pAllocator);
67 * @brief Destroys a swapchain and frees memory. Used with @ref allocate_surface_swapchain.
69 * @param swapchain Pointer to the swapchain to destroy.
70 * @param pAllocator The allocator to use for freeing memory.
72 void destroy_surface_swapchain(swapchain_base *swapchain, const VkAllocationCallbacks *pAllocator);
75 * @brief Return which platforms the layer can handle for an instance constructed in the specified way.
77 * @details This function looks at the extensions specified in @p pCreateInfo and based on this returns a list of
78 * platforms that the layer can support. For example, if the @c pCreateInfo.ppEnabledExtensionNames contains the string
79 * "VK_EXT_headless_surface" then the returned platform set will contain @c VK_ICD_WSI_PLATFORM_HEADLESS.
81 * @param pCreateInfo Structure used when creating the instance in vkCreateInstance().
83 * @return A list of WS platforms supported by the layer.
85 util::wsi_platform_set find_enabled_layer_platforms(const VkInstanceCreateInfo *pCreateInfo);
88 * @brief Add extra extensions that the layer requires to support the specified list of enabled platforms.
90 * @details Check whether @p phys_dev has support for the extensions required by the layer in order to support the
91 * platforms it implements. The extensions that the layer requires to operate are added to @p extensions_to_enable.
93 * @param[in] phys_dev The physical device to check.
94 * @param[in] enabled_platforms All the platforms that the layer must enable for @p phys_dev.
95 * @param[in,out] extensions_to_enable All the extensions required by the layer are added to this list.
97 * @retval @c VK_SUCCESS if the operation was successful.
99 VkResult add_extensions_required_by_layer(VkPhysicalDevice phys_dev, const util::wsi_platform_set enabled_platforms,
100 util::extension_list &extensions_to_enable);
103 * @brief Return a function pointer for surface specific functions.
105 * @details This function iterates through the supported platforms and queries them for the
106 * implementation of the @p name function.
108 * @param name The name of the target function
110 * @return A pointer to the implementation of the @p name function or null pointer in case this
111 * function isn't implemented for any platform.
113 PFN_vkVoidFunction get_proc_addr(const char *name);