MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Portal::Graphics::SamplerForge Class Reference

Creates and caches Vulkan samplers (Singleton) More...

#include <SamplerForge.hpp>

+ Collaboration diagram for MayaFlux::Portal::Graphics::SamplerForge:

Public Member Functions

void destroy_sampler (vk::Sampler sampler)
 Destroy a specific sampler.
 
vk::Sampler get_anisotropic (float max_anisotropy=16.0F)
 Get an anisotropic sampler (high quality)
 
vk::Sampler get_default_linear ()
 Get a default linear sampler.
 
vk::Sampler get_default_nearest ()
 Get a default nearest sampler.
 
vk::Sampler get_or_create (const SamplerConfig &config)
 Get or create a sampler with the given configuration.
 
size_t get_sampler_count () const
 Get number of cached samplers.
 
bool initialize (const std::shared_ptr< Core::VulkanBackend > &backend)
 Initialize with backend reference.
 
bool is_initialized () const
 Check if factory is initialized.
 
SamplerForge & operator= (const SamplerForge &)=delete
 
SamplerForge & operator= (SamplerForge &&)=delete
 
 SamplerForge (const SamplerForge &)=delete
 
 SamplerForge (SamplerForge &&)=delete
 
void shutdown ()
 Shutdown and cleanup all samplers.
 

Static Public Member Functions

static SamplerForge & instance ()
 
static FitPlan plan_fit (uint32_t src_width, uint32_t src_height, uint32_t dst_width, uint32_t dst_height, FitMode mode=FitMode::STRETCH, FilterMode filter=FilterMode::LINEAR)
 Work out how a source extent maps onto a destination extent.
 

Private Member Functions

vk::Sampler create_sampler (const SamplerConfig &config)
 
 SamplerForge ()=default
 
 ~SamplerForge ()
 

Static Private Member Functions

static size_t hash_config (const SamplerConfig &config)
 
static vk::SamplerAddressMode to_vk_address_mode (AddressMode mode)
 
static vk::BorderColor to_vk_border_color (BorderColor color)
 
static vk::Filter to_vk_filter (FilterMode mode)
 

Private Attributes

std::shared_ptr< Core::VulkanBackend > m_backend
 
std::unordered_map< size_t, vk::Sampler > m_sampler_cache
 

Static Private Attributes

static bool s_initialized = false
 

Detailed Description

Creates and caches Vulkan samplers (Singleton)

Samplers control how textures are filtered and addressed when sampled in shaders. This factory caches samplers based on configuration to avoid creating duplicates.

Lifecycle:

  • Initialize with backend reference
  • Create samplers via get_or_create()
  • Samplers are cached and reused
  • Cleanup destroys all samplers

Thread-safe after initialization.

Definition at line 46 of file SamplerForge.hpp.


The documentation for this class was generated from the following files: