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

42 lines
1 KiB
C++

#pragma once
#include "vk/core/sampler.hpp"
#include <vulkan/vulkan_core.h>
#include <unordered_map>
#include <cstdint>
namespace VK::Pool {
///
/// Pool of initialized samplers.
///
class SamplerPool {
public:
///
/// Create a sampler pool.
///
SamplerPool() noexcept = default;
///
/// Get or create a sampler.
///
/// @param device Vulkan device.
/// @param type Address mode
/// @param compare Compare operation
/// @param white Whether to use a white border color
/// @return Preallocated sampler
///
/// @throws VK::vulkan_error if sampler creation fails.
///
[[nodiscard]] const Core::Sampler& getOrCreate(
const Core::Device& device,
VkSamplerAddressMode type = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
VkCompareOp compare = VK_COMPARE_OP_NEVER,
bool white = false);
private:
std::unordered_map<uint64_t, Core::Sampler> samplers;
};
}