Lysa  0.0
Lysa 3D Engine
Samplers Class Reference

Detailed Description

Manages a small, shared collection of GPU sampler objects.

  • Provide a fixed-size pool of samplers that materials/shaders can reuse.
  • Create and track descriptor layout and descriptor set for binding samplers.
  • Expose an update mechanism to (re)write descriptors when the set changes.

Classes

struct  SamplerInfo
 

Public Member Functions

uint32 addSampler (vireo::Filter minFilter, vireo::Filter maxFilter, vireo::AddressMode samplerAddressModeU, vireo::AddressMode samplerAddressModeV, float minLod=0.0f, float maxLod=vireo::Sampler::LOD_CLAMP_NONE, bool anisotropyEnable=true, vireo::MipMapMode mipMapMode=vireo::MipMapMode::LINEAR, vireo::CompareOp compareOp=vireo::CompareOp::NEVER)
 
bool isUpdateNeeded () const
 
void update ()
 
const auto & getDescriptorLayout () const
 
const auto & getDescriptorSet () const
 
 Samplers (const std::shared_ptr< vireo::Vireo > &vireo, size_t capacity)
 
 ~Samplers ()
 

Static Public Attributes

static constexpr uint32 SET {1}
 
static constexpr unique_id NEAREST_NEAREST_CLAMP_TO_BORDER = 0
 
static constexpr unique_id NEAREST_NEAREST_CLAMP_TO_EDGE = 1
 
static constexpr unique_id LINEAR_LINEAR_CLAMP_TO_EDGE = 2
 
static constexpr unique_id LINEAR_LINEAR_CLAMP_TO_EDGE_LOD_CLAMP_NONE = 3
 
static constexpr unique_id LINEAR_LINEAR_REPEAT = 4
 
static constexpr unique_id NEAREST_NEAREST_REPEAT = 5
 

Constructor & Destructor Documentation

Samplers ( const std::shared_ptr< vireo::Vireo > &  vireo,
size_t  capacity 
)

Creates a Samplers pool bound to the given backend.

~Samplers ( )

Member Function Documentation

uint32 addSampler ( vireo::Filter  minFilter,
vireo::Filter  maxFilter,
vireo::AddressMode  samplerAddressModeU,
vireo::AddressMode  samplerAddressModeV,
float  minLod = 0.0f,
float  maxLod = vireo::Sampler::LOD_CLAMP_NONE,
bool  anisotropyEnable = true,
vireo::MipMapMode  mipMapMode = vireo::MipMapMode::LINEAR,
vireo::CompareOp  compareOp = vireo::CompareOp::NEVER 
)

Adds a sampler to the pool, creating it if an equivalent one does not already exist, and returns its index for binding.

Parameters
minFilterMinification filter.
maxFilterMagnification filter.
samplerAddressModeUAddress mode for U (S) coordinate.
samplerAddressModeVAddress mode for V (T) coordinate.
minLodMinimum LOD to sample (default 0.0f).
maxLodMaximum LOD to sample; use Sampler::LOD_CLAMP_NONE to disable clamping.
anisotropyEnableEnable anisotropic filtering when available.
mipMapModeMip sampling mode (default LINEAR).
compareOpOptional compare op for depth/shadow lookups.
Returns
Index into the samplers set suitable for descriptor binding.
const auto& getDescriptorLayout ( ) const
inline

Returns the descriptor layout used for the samplers set.

const auto& getDescriptorSet ( ) const
inline

Returns the descriptor set that binds the samplers to shaders.

bool isUpdateNeeded ( ) const
inline

Returns true if the samplers descriptor set needs to be updated.

void update ( )

Writes pending sampler bindings to the descriptor set if needed.

Member Data Documentation

constexpr unique_id LINEAR_LINEAR_CLAMP_TO_EDGE = 2
staticconstexpr
constexpr unique_id LINEAR_LINEAR_CLAMP_TO_EDGE_LOD_CLAMP_NONE = 3
staticconstexpr
constexpr unique_id LINEAR_LINEAR_REPEAT = 4
staticconstexpr
constexpr unique_id NEAREST_NEAREST_CLAMP_TO_BORDER = 0
staticconstexpr
constexpr unique_id NEAREST_NEAREST_CLAMP_TO_EDGE = 1
staticconstexpr
constexpr unique_id NEAREST_NEAREST_REPEAT = 5
staticconstexpr
constexpr uint32 SET {1}
staticconstexpr

Descriptor set index used by pipelines to bind the samplers set.