MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ get_or_create()

vk::Sampler MayaFlux::Portal::Graphics::SamplerForge::get_or_create ( const SamplerConfig config)

Get or create a sampler with the given configuration.

Parameters
configSampler configuration
Returns
Vulkan sampler handle (cached)

Samplers are cached - identical configs return the same sampler. All samplers are destroyed on shutdown.

Definition at line 71 of file SamplerForge.cpp.

72{
73 if (!is_initialized()) {
75 "SamplerForge not initialized");
76 return nullptr;
77 }
78
79 size_t hash = hash_config(config);
80
81 auto it = m_sampler_cache.find(hash);
82 if (it != m_sampler_cache.end()) {
83 return it->second;
84 }
85
86 vk::Sampler sampler = create_sampler(config);
87 if (sampler) {
88 m_sampler_cache[hash] = sampler;
90 "Created and cached sampler (hash: {}, total: {})",
91 hash, m_sampler_cache.size());
92 }
93
94 return sampler;
95}
#define MF_ERROR(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
bool is_initialized() const
Check if factory is initialized.
std::unordered_map< size_t, vk::Sampler > m_sampler_cache
static size_t hash_config(const SamplerConfig &config)
vk::Sampler create_sampler(const SamplerConfig &config)
@ ImageProcessing
Image processing tasks (filters, transformations)
@ Portal
High-level user-facing API layer.

References create_sampler(), hash_config(), MayaFlux::Journal::ImageProcessing, is_initialized(), m_sampler_cache, MF_DEBUG, MF_ERROR, and MayaFlux::Journal::Portal.

Referenced by get_anisotropic(), get_default_linear(), and get_default_nearest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: