Add vulkan sampler cache

This commit is contained in:
Wunkolo 2023-08-20 23:35:52 -07:00
parent 14b1d7d8a8
commit 7a86595a1b
3 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1,28 @@
#pragma once
#include <optional>
#include <unordered_map>
#include "helpers.hpp"
#include "vk_api.hpp"
namespace Vulkan {
// Implements a simple pool of reusable sampler objects
class SamplerCache {
private:
const vk::Device device;
std::unordered_map<std::size_t, vk::UniqueSampler> samplerMap;
explicit SamplerCache(vk::Device device);
public:
~SamplerCache() = default;
SamplerCache(SamplerCache&&) = default;
const vk::Sampler& getSampler(const vk::SamplerCreateInfo& samplerInfo);
static std::optional<SamplerCache> create(vk::Device device);
};
} // namespace Vulkan