Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::Lumina::Pipeline::Constant Class Reference

Encapsulates a shader resource (UBO, SSBO, or sampler) bound by a pipeline. More...

#include <spk_pipeline.hpp>

Collaboration diagram for spk::Lumina::Pipeline::Constant:
Collaboration graph

Public Types

enum class  Kind { None , UBO , SSBO , Sampler }
 Enumerates the supported constant types.

Public Member Functions

 Constant ()=default
 Default constructor for an empty constant.
 Constant (Constant &&)=default
 Move-constructs a constant, transferring ownership of the underlying resource.
Constantoperator= (Constant &&)=default
 Move-assigns from another constant instance.
 Constant (const Constant &)=delete
Constantoperator= (const Constant &)=delete
Kind kind () const noexcept
 Reports the currently configured resource type.
GLuint bindingPoint () const noexcept
 Binding slot used when the constant represents a buffer or sampler.
std::size_t size () const noexcept
 Size of the buffer-backed constant in bytes.
void setUBO (GLuint p_bindingPoint, std::size_t p_size, spk::OpenGL::BufferObject::Usage p_usage)
 Initializes the constant as a uniform buffer.
void setSSBO (GLuint p_bindingPoint, std::size_t p_size, spk::OpenGL::BufferObject::Usage p_usage)
 Initializes the constant as a shader storage buffer.
void setSampler (GLint p_uniformLocation, GLuint p_textureUnitIndex)
 Initializes the constant as a sampler bound to a texture unit.
void activate ()
 Activates the underlying resource on the GPU.
void deactivate ()
 Deactivates the underlying resource on the GPU.
spk::OpenGL::UBOubo ()
 Accesses the constant as a uniform buffer object.
const spk::OpenGL::UBOubo () const
 Accesses the constant as a uniform buffer object.
spk::OpenGL::SSBOssbo ()
 Accesses the constant as a shader storage buffer object.
const spk::OpenGL::SSBOssbo () const
 Accesses the constant as a shader storage buffer object.
spk::OpenGL::SamplerObjectsampler ()
 Accesses the constant as a sampler object.
const spk::OpenGL::SamplerObjectsampler () const
 Accesses the constant as a sampler object.
 operator spk::OpenGL::UBO & ()
 Implicitly converts the constant to its UBO representation.
 operator const spk::OpenGL::UBO & () const
 Implicitly converts the constant to its UBO representation.
 operator spk::OpenGL::SSBO & ()
 Implicitly converts the constant to its SSBO representation.
 operator const spk::OpenGL::SSBO & () const
 Implicitly converts the constant to its SSBO representation.
 operator spk::OpenGL::SamplerObject & ()
 Implicitly converts the constant to its sampler object.
 operator const spk::OpenGL::SamplerObject & () const
 Implicitly converts the constant to its sampler object.

Detailed Description

Encapsulates a shader resource (UBO, SSBO, or sampler) bound by a pipeline.

Member Function Documentation

◆ bindingPoint()

GLuint spk::Lumina::Pipeline::Constant::bindingPoint ( ) const
inlinenoexcept

Binding slot used when the constant represents a buffer or sampler.

Returns
OpenGL binding point index for buffers or the texture unit for samplers.

◆ kind()

Kind spk::Lumina::Pipeline::Constant::kind ( ) const
inlinenoexcept

Reports the currently configured resource type.

Returns
Enumeration describing the active resource kind.
Here is the caller graph for this function:

◆ operator const spk::OpenGL::SamplerObject &()

spk::Lumina::Pipeline::Constant::operator const spk::OpenGL::SamplerObject & ( ) const
inline

Implicitly converts the constant to its sampler object.

Returns
Read-only sampler reference.

◆ operator const spk::OpenGL::SSBO &()

spk::Lumina::Pipeline::Constant::operator const spk::OpenGL::SSBO & ( ) const
inline

Implicitly converts the constant to its SSBO representation.

Returns
Read-only SSBO reference.

◆ operator const spk::OpenGL::UBO &()

spk::Lumina::Pipeline::Constant::operator const spk::OpenGL::UBO & ( ) const
inline

Implicitly converts the constant to its UBO representation.

Returns
Read-only UBO reference.

◆ operator spk::OpenGL::SamplerObject &()

spk::Lumina::Pipeline::Constant::operator spk::OpenGL::SamplerObject & ( )
inline

Implicitly converts the constant to its sampler object.

Returns
Mutable sampler reference.

◆ operator spk::OpenGL::SSBO &()

spk::Lumina::Pipeline::Constant::operator spk::OpenGL::SSBO & ( )
inline

Implicitly converts the constant to its SSBO representation.

Returns
Mutable SSBO reference.

◆ operator spk::OpenGL::UBO &()

spk::Lumina::Pipeline::Constant::operator spk::OpenGL::UBO & ( )
inline

Implicitly converts the constant to its UBO representation.

Returns
Mutable UBO reference.

◆ operator=()

Constant & spk::Lumina::Pipeline::Constant::operator= ( Constant && )
default

Move-assigns from another constant instance.

Returns
Reference to this constant after transfer.
Here is the call graph for this function:

◆ sampler() [1/2]

spk::OpenGL::SamplerObject & spk::Lumina::Pipeline::Constant::sampler ( )
inline

Accesses the constant as a sampler object.

Returns
Mutable reference to the sampler.

◆ sampler() [2/2]

const spk::OpenGL::SamplerObject & spk::Lumina::Pipeline::Constant::sampler ( ) const
inline

Accesses the constant as a sampler object.

Returns
Read-only reference to the sampler.

◆ setSampler()

void spk::Lumina::Pipeline::Constant::setSampler ( GLint p_uniformLocation,
GLuint p_textureUnitIndex )
inline

Initializes the constant as a sampler bound to a texture unit.

Parameters
p_uniformLocationUniform location used in the shader, or -1 when using layout(binding).
p_textureUnitIndexIndex of the texture unit to bind.

◆ setSSBO()

void spk::Lumina::Pipeline::Constant::setSSBO ( GLuint p_bindingPoint,
std::size_t p_size,
spk::OpenGL::BufferObject::Usage p_usage )
inline

Initializes the constant as a shader storage buffer.

Parameters
p_bindingPointBinding point to use when activating the buffer.
p_sizeSize in bytes to allocate inside the SSBO.
p_usageOpenGL usage hint for the buffer data.

◆ setUBO()

void spk::Lumina::Pipeline::Constant::setUBO ( GLuint p_bindingPoint,
std::size_t p_size,
spk::OpenGL::BufferObject::Usage p_usage )
inline

Initializes the constant as a uniform buffer.

Parameters
p_bindingPointBinding point to use when activating the buffer.
p_sizeSize in bytes to allocate inside the UBO.
p_usageOpenGL usage hint for the buffer data.

◆ size()

std::size_t spk::Lumina::Pipeline::Constant::size ( ) const
inlinenoexcept

Size of the buffer-backed constant in bytes.

Returns
Allocated size when using UBO or SSBO, otherwise zero.
Here is the caller graph for this function:

◆ ssbo() [1/2]

spk::OpenGL::SSBO & spk::Lumina::Pipeline::Constant::ssbo ( )
inline

Accesses the constant as a shader storage buffer object.

Returns
Mutable reference to the internal SSBO.

◆ ssbo() [2/2]

const spk::OpenGL::SSBO & spk::Lumina::Pipeline::Constant::ssbo ( ) const
inline

Accesses the constant as a shader storage buffer object.

Returns
Read-only reference to the internal SSBO.

◆ ubo() [1/2]

spk::OpenGL::UBO & spk::Lumina::Pipeline::Constant::ubo ( )
inline

Accesses the constant as a uniform buffer object.

Returns
Mutable reference to the internal UBO.

◆ ubo() [2/2]

const spk::OpenGL::UBO & spk::Lumina::Pipeline::Constant::ubo ( ) const
inline

Accesses the constant as a uniform buffer object.

Returns
Read-only reference to the internal UBO.

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