mirror of
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer.git
synced 2025-12-20 02:10:13 +01:00
This commit adds the initial sources for the vulkan-wsi-layer project: a Vulkan layer which implements some of the Vulkan window system integration extensions such as VK_KHR_swapchain. The layer is designed to be GPU vendor agnostic when used as part of the Vulkan ICD/loader architecture. The project currently implements support for VK_EXT_headless_surface and its dependencies. We hope to extend support for further platforms such as Wayland and direct-to-display rendering in the future. This initial commit collects contributions from different individuals employed by Arm. More information on the project (building instructions, how to contribute, etc.) can be found on the README.md file at the top of the project tree. Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
94 lines
2.9 KiB
C++
94 lines
2.9 KiB
C++
/*
|
|
* Copyright (c) 2017-2019 Arm Limited.
|
|
*
|
|
* 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 swapchain.hpp
|
|
*
|
|
* @brief Contains the class definition for a headless swapchain.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <vulkan/vk_icd.h>
|
|
#include <vulkan/vulkan.h>
|
|
#include <wsi/swapchain_base.hpp>
|
|
|
|
namespace wsi
|
|
{
|
|
namespace headless
|
|
{
|
|
|
|
/**
|
|
* @brief Headless swapchain class.
|
|
*
|
|
* This class is mostly empty, because all the swapchain stuff is handled by the swapchain class,
|
|
* which we inherit. This class only provides a way to create an image and page-flip ops.
|
|
*/
|
|
class swapchain : public wsi::swapchain_base
|
|
{
|
|
public:
|
|
explicit swapchain(layer::device_private_data &dev_data, const VkAllocationCallbacks *pAllocator);
|
|
|
|
~swapchain();
|
|
|
|
protected:
|
|
/**
|
|
* @brief Platform specific init
|
|
*/
|
|
VkResult init_platform(VkDevice device, const VkSwapchainCreateInfoKHR *pSwapchainCreateInfo)
|
|
{
|
|
return VK_SUCCESS;
|
|
};
|
|
|
|
/**
|
|
* @brief Creates a new swapchain image.
|
|
*
|
|
* @param image_create_info Data to be used to create the image.
|
|
*
|
|
* @param image Handle to the image.
|
|
*
|
|
* @return If image creation is successful returns VK_SUCCESS, otherwise
|
|
* will return VK_ERROR_OUT_OF_DEVICE_MEMORY or VK_ERROR_INITIALIZATION_FAILED
|
|
* depending on the error that occured.
|
|
*/
|
|
VkResult create_image(const VkImageCreateInfo &image_create_info, wsi::swapchain_image &image);
|
|
|
|
/**
|
|
* @brief Method to perform a present - just calls unpresent_image on headless
|
|
*
|
|
* @param pendingIndex Index of the pending image to be presented.
|
|
*
|
|
*/
|
|
void present_image(uint32_t pendingIndex);
|
|
|
|
/**
|
|
* @brief Method to release a swapchain image
|
|
*
|
|
* @param image Handle to the image about to be released.
|
|
*/
|
|
void destroy_image(wsi::swapchain_image &image);
|
|
};
|
|
|
|
} /* namespace headless */
|
|
} /* namespace wsi */
|