2024-11-28 06:36:17 +00:00
|
|
|
/*
|
|
|
|
|
* 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 image_compression_control.hpp
|
|
|
|
|
*
|
|
|
|
|
* @brief Contains the implementation for VK_EXT_image_compression_control extension.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <optional>
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
|
|
#include <util/custom_allocator.hpp>
|
|
|
|
|
#include <util/macros.hpp>
|
2025-11-20 13:55:45 +00:00
|
|
|
#include <util/wsi_extension.hpp>
|
2024-11-28 06:36:17 +00:00
|
|
|
|
2025-11-20 13:55:45 +00:00
|
|
|
#include "image_create_info_extension.hpp"
|
2024-11-28 06:36:17 +00:00
|
|
|
|
|
|
|
|
namespace wsi
|
|
|
|
|
{
|
|
|
|
|
using util::MAX_PLANES;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Image compresssion control extension class
|
|
|
|
|
*
|
|
|
|
|
* This class implements the image compression control features.
|
|
|
|
|
* Backends needing additional features will create its own local
|
|
|
|
|
* copy and inherit this class.
|
|
|
|
|
*/
|
2025-11-20 13:55:45 +00:00
|
|
|
class image_create_compression_control : public image_create_info_extension
|
2024-11-28 06:36:17 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
2025-11-20 13:55:45 +00:00
|
|
|
* @brief Constructor for the image_create_compression_control class.
|
2024-11-28 06:36:17 +00:00
|
|
|
*
|
|
|
|
|
* @param extension Reference to VkImageCompressionControlEXT structure.
|
|
|
|
|
*/
|
2025-11-20 13:55:45 +00:00
|
|
|
image_create_compression_control(const VkImageCompressionControlEXT &extension);
|
2024-11-28 06:36:17 +00:00
|
|
|
|
2025-11-20 13:55:45 +00:00
|
|
|
image_create_compression_control(const image_create_compression_control &extension);
|
2024-11-28 06:36:17 +00:00
|
|
|
|
2025-11-20 13:55:45 +00:00
|
|
|
image_create_compression_control &operator=(const image_create_compression_control &extension)
|
2024-11-28 06:36:17 +00:00
|
|
|
{
|
|
|
|
|
if (this == &extension)
|
|
|
|
|
{
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-20 13:55:45 +00:00
|
|
|
auto compression_control = image_create_compression_control(extension);
|
2024-11-28 06:36:17 +00:00
|
|
|
std::swap(m_compression_control, compression_control.m_compression_control);
|
|
|
|
|
for (uint32_t i = 0; i < compression_control.m_compression_control.compressionControlPlaneCount; i++)
|
|
|
|
|
{
|
|
|
|
|
m_compression_control.pFixedRateFlags[i] = compression_control.m_compression_control.pFixedRateFlags[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-20 13:55:45 +00:00
|
|
|
* @brief Create image_create_compression_control class if deemed necessary.
|
2024-11-28 06:36:17 +00:00
|
|
|
*
|
|
|
|
|
* @param device The Vulkan device
|
|
|
|
|
* @param swapchain_create_info Swapchain create info
|
2025-11-20 13:55:45 +00:00
|
|
|
* @return Valid image_create_compression_control if requested by application,
|
2024-11-28 06:36:17 +00:00
|
|
|
* otherwise - an empty optional.
|
|
|
|
|
*/
|
2025-11-20 13:55:45 +00:00
|
|
|
static std::optional<image_create_compression_control> create(VkDevice device,
|
|
|
|
|
const VkSwapchainCreateInfoKHR *swapchain_create_info);
|
2024-11-28 06:36:17 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief This API is used to get the compression control properties of an image.
|
|
|
|
|
*
|
|
|
|
|
* @return The image compression control properties.
|
|
|
|
|
*/
|
|
|
|
|
VkImageCompressionControlEXT get_compression_control_properties();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief This API is used to get the bitmask for image compression flags.
|
|
|
|
|
*
|
|
|
|
|
* @return The bitmask for image compression flags.
|
|
|
|
|
*/
|
|
|
|
|
VkImageCompressionFlagsEXT get_bitmask_for_image_compression_flags();
|
|
|
|
|
|
2025-11-20 13:55:45 +00:00
|
|
|
VkResult extend_image_create_info(VkImageCreateInfo *image_create_info) override;
|
|
|
|
|
|
2024-11-28 06:36:17 +00:00
|
|
|
private:
|
|
|
|
|
/**
|
|
|
|
|
* @brief Array to hold the pFixedRateFlags.
|
|
|
|
|
*/
|
|
|
|
|
VkImageCompressionFixedRateFlagsEXT m_array_fixed_rate_flags[MAX_PLANES];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Image compression control properties.
|
|
|
|
|
*/
|
|
|
|
|
VkImageCompressionControlEXT m_compression_control;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} /* namespace wsi */
|