mirror of
https://gitlab.freedesktop.org/mesa/vulkan-wsi-layer.git
synced 2025-12-20 05:40:10 +01:00
Decouples the swapchain images and their memory binder/allocator logic into separate classes. This allows us to reduce code duplication across different backends that use the same type of allocation logic and also allows us to make use of RAII to release the resources for swapchain images. The swapchain_base and other swapchain classes have been refactored to handle the new swapchain images. The patch makes the following adjustments: * Introduces a new swapchain_image class that holds all swapchain image resources * Introduces a swapchain image factory class that constructs swapchain images * Introduces a Vulkan image handle class that is responsible for constructing VkImage handles * Introduces a new interface that describes how swapchain backing memory is being allocated * As part of this backing memory interface, introduces device and external (wsialloc) backing memory classes * Introduces a new interface that holds swapchain image data like wl_buffers * Refactors lots of swapchain image parts out of the base swapchain class and moves it into the respective backends to simplify the swapchain classes.
92 lines
No EOL
2.9 KiB
C++
92 lines
No EOL
2.9 KiB
C++
/*
|
|
* Copyright (c) 2025 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 vulkan_image_handle_creator.hpp
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <vulkan/vulkan.h>
|
|
#include <util/custom_allocator.hpp>
|
|
#include <wsi/extensions/image_create_info_extension.hpp>
|
|
|
|
#include "swapchain_image.hpp"
|
|
|
|
namespace wsi
|
|
{
|
|
|
|
/**
|
|
* @brief This class is responsible for owning and extending a swapchain's image
|
|
* creation info and creating Vulkan image handles.
|
|
*/
|
|
class vulkan_image_handle_creator
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Construct a new vulkan image handle creator
|
|
*
|
|
* @param allocator Allocator
|
|
* @param swapchain_create_info Swapchain create info passed by application.
|
|
*/
|
|
vulkan_image_handle_creator(util::allocator allocator, const VkSwapchainCreateInfoKHR &swapchain_create_info);
|
|
|
|
/**
|
|
* @brief Create Vulkan swapchain image handle
|
|
*
|
|
* @param device_data Device data
|
|
* @param allocator Allocator
|
|
* @param out_image_handle If successful, Vulkan image handle
|
|
* @return Vulkan result code.
|
|
*/
|
|
VkResult create_image(layer::device_private_data &device_data, const util::allocator &allocator,
|
|
VkImage &out_image_handle);
|
|
|
|
/**
|
|
* @brief Extend create info with extension data.
|
|
*
|
|
* @param extension Swapchain image create info extension.
|
|
*
|
|
* @return VK_SUCCESS on success, an appropriate error code on failure.
|
|
*/
|
|
VkResult add_extension(util::unique_ptr<image_create_info_extension> extension);
|
|
|
|
VkImageCreateInfo get_image_create_info() const
|
|
{
|
|
return m_image_create_info;
|
|
}
|
|
|
|
private:
|
|
/**
|
|
* @brief Image create info used for all swapchain images.
|
|
*/
|
|
VkImageCreateInfo m_image_create_info;
|
|
|
|
/**
|
|
* @brief Swapchain image extensions needed for extending image create info.
|
|
*/
|
|
util::vector<util::unique_ptr<image_create_info_extension>> m_extensions;
|
|
};
|
|
|
|
} /* namespace wsi */ |