lsfg-vk/include/utils/utils.hpp
2025-07-05 18:14:39 +02:00

65 lines
2.3 KiB
C++

#ifndef UTILS_HPP
#define UTILS_HPP
#include <vulkan/vulkan_core.h>
#include <vector>
#include <utility>
namespace Utils {
///
/// Find a queue in the physical device that supports the given queue flags.
///
/// @param device The Vulkan device to use for queue retrieval.
/// @param physicalDevice The physical device to search in.
/// @param desc The device creation info, used to determine enabled queue families.
/// @param flags The queue flags to search for (e.g., VK_QUEUE_GRAPHICS_BIT).
/// @return Pair of queue family index and queue handle.
///
/// @throws LSFG::vulkan_error if no suitable queue is found.
///
std::pair<uint32_t, VkQueue> findQueue(VkDevice device, VkPhysicalDevice physicalDevice,
VkDeviceCreateInfo* desc, VkQueueFlags flags);
///
/// Ensure a list of extensions is present in the given array.
///
/// @param extensions The array of extensions to check.
/// @param requiredExtensions The list of required extensions to ensure are present.
///
std::vector<const char*> addExtensions(const char* const* extensions, size_t count,
const std::vector<const char*>& requiredExtensions);
///
/// Copy an image from source to destination in a command buffer.
///
/// @param buf The command buffer to record the copy operation into.
/// @param src The source image to copy from.
/// @param dst The destination image to copy to.
/// @param width The width of the image to copy.
/// @param height The height of the image to copy.
/// @param pre The pipeline stage to wait on.
/// @param post The pipeline stage to provide after the copy.
/// @param makeSrcPresentable If true, the source image will be made presentable after the copy.
/// @param makeDstPresentable If true, the destination image will be made presentable after the copy.
///
void copyImage(VkCommandBuffer buf,
VkImage src, VkImage dst,
uint32_t width, uint32_t height,
VkPipelineStageFlags pre, VkPipelineStageFlags post,
bool makeSrcPresentable, bool makeDstPresentable);
///
/// Store the current layer environment.
///
void storeLayerEnv();
///
/// Restore the layer environment to the previously stored value.
///
void restoreLayerEnv();
}
#endif // UTILS_HPP