lsfg-vk/framegen/include/vk/pool/buffer_pool.hpp
2025-09-28 23:24:51 +02:00

40 lines
1 KiB
C++

#pragma once
#include "vk/core/buffer.hpp"
#include <unordered_map>
#include <cstdint>
namespace VK::Pool {
///
/// Pool of initialized buffers.
///
class BufferPool {
public:
///
/// Create a buffer pool.
///
BufferPool() noexcept = default;
///
/// Get or create a buffer.
///
/// @param device Vulkan device.
/// @param flow Flow scale
/// @param hdr Whether HDR is enabled
/// @param timestamp Timestamp of the frame
/// @param firstIter Whether this is the first iteration
/// @param firstIterS Whether this is the first iteration for the second pass
/// @return Preallocated buffer
///
/// @throws VK::vulkan_error if buffer creation fails.
///
[[nodiscard]] const Core::Buffer& getOrCreate(
const Core::Device& device, float flow, bool hdr,
float timestamp, bool firstIter, bool firstIterS);
private:
std::unordered_map<uint64_t, Core::Buffer> buffers;
};
}