2019-11-21 15:23:59 +00:00
|
|
|
/*
|
2023-09-19 10:19:39 +01:00
|
|
|
* Copyright (c) 2019, 2021, 2023 Arm Limited.
|
2019-11-21 15:23:59 +00:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
* @brief Contains the factory methods for obtaining the specific surface and swapchain implementations.
|
|
|
|
|
*/
|
2020-06-24 09:36:21 +01:00
|
|
|
|
2019-11-21 15:23:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "swapchain_base.hpp"
|
|
|
|
|
#include "surface_properties.hpp"
|
2020-06-24 09:36:21 +01:00
|
|
|
#include "util/platform_set.hpp"
|
|
|
|
|
|
|
|
|
|
#include <unordered_map>
|
2019-11-21 15:23:59 +00:00
|
|
|
|
|
|
|
|
namespace wsi
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
2020-06-24 09:36:21 +01:00
|
|
|
* @brief Obtains the surface properties for the specific surface type.
|
2019-11-21 15:23:59 +00:00
|
|
|
*
|
2021-07-21 20:19:52 +01:00
|
|
|
* @param instance_data The instance specific data.
|
|
|
|
|
* @param surface The surface for which to get the properties.
|
2019-11-21 15:23:59 +00:00
|
|
|
*
|
|
|
|
|
* @return nullptr if surface type is unsupported.
|
|
|
|
|
*/
|
2021-07-21 20:19:52 +01:00
|
|
|
surface_properties *get_surface_properties(layer::instance_private_data &instance_data, VkSurfaceKHR surface);
|
2019-11-21 15:23:59 +00:00
|
|
|
|
|
|
|
|
/**
|
2020-06-24 09:36:21 +01:00
|
|
|
* @brief Allocates a surface specific swapchain.
|
2019-11-21 15:23:59 +00:00
|
|
|
*
|
|
|
|
|
* @param surface The surface for which a swapchain is allocated.
|
|
|
|
|
* @param dev_data The device specific data.
|
|
|
|
|
* @param pAllocator The allocator from which to allocate any memory.
|
|
|
|
|
*
|
|
|
|
|
* @return nullptr on failure.
|
|
|
|
|
*/
|
2021-07-21 20:19:52 +01:00
|
|
|
util::unique_ptr<swapchain_base> allocate_surface_swapchain(VkSurfaceKHR surface, layer::device_private_data &dev_data,
|
|
|
|
|
const VkAllocationCallbacks *pAllocator);
|
2019-11-21 15:23:59 +00:00
|
|
|
|
|
|
|
|
/**
|
2020-06-24 09:36:21 +01:00
|
|
|
* @brief Destroys a swapchain and frees memory. Used with @ref allocate_surface_swapchain.
|
2019-11-21 15:23:59 +00:00
|
|
|
*
|
|
|
|
|
* @param swapchain Pointer to the swapchain to destroy.
|
2021-05-27 13:53:07 +01:00
|
|
|
* @param dev_data The device specific data.
|
2019-11-21 15:23:59 +00:00
|
|
|
* @param pAllocator The allocator to use for freeing memory.
|
|
|
|
|
*/
|
2023-09-19 10:19:39 +01:00
|
|
|
void destroy_surface_swapchain(swapchain_base *swapchain, layer::device_private_data &dev_data,
|
|
|
|
|
const VkAllocationCallbacks *pAllocator);
|
2019-11-21 15:23:59 +00:00
|
|
|
|
2020-06-24 09:36:21 +01:00
|
|
|
/**
|
|
|
|
|
* @brief Return which platforms the layer can handle for an instance constructed in the specified way.
|
|
|
|
|
*
|
|
|
|
|
* @details This function looks at the extensions specified in @p pCreateInfo and based on this returns a list of
|
|
|
|
|
* platforms that the layer can support. For example, if the @c pCreateInfo.ppEnabledExtensionNames contains the string
|
|
|
|
|
* "VK_EXT_headless_surface" then the returned platform set will contain @c VK_ICD_WSI_PLATFORM_HEADLESS.
|
|
|
|
|
*
|
|
|
|
|
* @param pCreateInfo Structure used when creating the instance in vkCreateInstance().
|
|
|
|
|
*
|
|
|
|
|
* @return A list of WS platforms supported by the layer.
|
|
|
|
|
*/
|
|
|
|
|
util::wsi_platform_set find_enabled_layer_platforms(const VkInstanceCreateInfo *pCreateInfo);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add extra extensions that the layer requires to support the specified list of enabled platforms.
|
|
|
|
|
*
|
|
|
|
|
* @details Check whether @p phys_dev has support for the extensions required by the layer in order to support the
|
|
|
|
|
* platforms it implements. The extensions that the layer requires to operate are added to @p extensions_to_enable.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] phys_dev The physical device to check.
|
|
|
|
|
* @param[in] enabled_platforms All the platforms that the layer must enable for @p phys_dev.
|
|
|
|
|
* @param[in,out] extensions_to_enable All the extensions required by the layer are added to this list.
|
|
|
|
|
*
|
|
|
|
|
* @retval @c VK_SUCCESS if the operation was successful.
|
|
|
|
|
*/
|
2023-09-19 10:19:39 +01:00
|
|
|
VkResult add_device_extensions_required_by_layer(VkPhysicalDevice phys_dev,
|
|
|
|
|
const util::wsi_platform_set enabled_platforms,
|
|
|
|
|
util::extension_list &extensions_to_enable);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Add required instance extensions by the layer.
|
|
|
|
|
*
|
|
|
|
|
* @param[in] enabled_platforms All the enabled platforms for the current instance.
|
|
|
|
|
* @param[in,out] extensions_to_enable All the extensions required by the layer are added to this list.
|
|
|
|
|
*
|
|
|
|
|
* @retval @c VK_SUCCESS if the operation was successful.
|
|
|
|
|
*/
|
|
|
|
|
VkResult add_instance_extensions_required_by_layer(const util::wsi_platform_set enabled_platforms,
|
|
|
|
|
util::extension_list &extensions_to_enable);
|
2020-06-24 09:36:21 +01:00
|
|
|
|
2021-01-31 20:09:53 +00:00
|
|
|
/**
|
|
|
|
|
* @brief Return a function pointer for surface specific functions.
|
|
|
|
|
*
|
|
|
|
|
* @details This function iterates through the supported platforms and queries them for the
|
|
|
|
|
* implementation of the @p name function.
|
|
|
|
|
*
|
|
|
|
|
* @param name The name of the target function
|
2021-11-08 13:32:12 +00:00
|
|
|
* @param instance_data The instance specific data.
|
2021-01-31 20:09:53 +00:00
|
|
|
*
|
|
|
|
|
* @return A pointer to the implementation of the @p name function or null pointer in case this
|
|
|
|
|
* function isn't implemented for any platform.
|
|
|
|
|
*/
|
2021-11-08 13:32:12 +00:00
|
|
|
PFN_vkVoidFunction get_proc_addr(const char *name, const layer::instance_private_data &instance_data);
|
2021-01-31 20:09:53 +00:00
|
|
|
|
|
|
|
|
} // namespace wsi
|