Skip to main content

UniformValueBag Class Template

Typed uniform container keyed by compile-time uniform tags. More...

Declaration

template <typename TUniformScope> class helios::engine::rendering::shader::UniformValueBag<TUniformScope> { ... }

Public Constructors Index

template <typename TUniformScope>
UniformValueBag ()

Constructs a value bag and resets all stored values. More...

Public Member Functions Index

template <typename TUniformScope>
voidclearValues ()

Resets all stored uniform values to defaults. More...

template <typename TUniform>
boolhas () const noexcept

Checks whether a typed uniform value is marked as active. More...

template <typename TUniformScope>
boolhas (const UniformSemantics semantics) const noexcept

Checks whether a semantic slot is marked as active. More...

template <typename TUniform>
const TUniform::value_type &get ()

Returns the stored value for a typed uniform. More...

template <typename TUniform>
voidset (const typename TUniform::value_type &value)

Stores a value for a typed uniform and marks it active. More...

template <typename TUniformScope>
const helios::math::mat4f *mat4f (const UniformSemantics semantics) const noexcept

Returns a matrix pointer for a matrix semantic. More...

template <typename TUniformScope>
const helios::math::vec4f *vec4f (const UniformSemantics semantics) const noexcept

Returns a vector pointer for a vector semantic. More...

Private Member Attributes Index

template <typename TUniformScope>
helios::math::mat4fmodelMatrix
template <typename TUniformScope>
helios::math::mat4fprojectionMatrix
template <typename TUniformScope>
helios::math::mat4fviewMatrix
template <typename TUniformScope>
helios::math::vec4fmaterialBaseColor
template <typename TUniformScope>
helios::math::vec4ftextColor
template <typename TUniformScope>
inttextTexture
template <typename TUniformScope>
floatmaterialRoughness
template <typename TUniformScope>
floatdeltaTime
template <typename TUniformScope>
floattotalTime
template <typename TUniformScope>
std::bitset< std::to_underlying(UniformSemantics::size_)>active_

Description

Typed uniform container keyed by compile-time uniform tags.

Template Parameters
TUniformScope

Uniform lifetime scope tag (for example pass or draw).

Definition at line 29 of file UniformValueBag.ixx.

Public Constructors

UniformValueBag()

template <typename TUniformScope>
helios::engine::rendering::shader::UniformValueBag< TUniformScope >::UniformValueBag ()
inline

Constructs a value bag and resets all stored values.

Definition at line 50 of file UniformValueBag.ixx.

52 }

Reference helios::engine::rendering::shader::UniformValueBag< TUniformScope >::clearValues.

Public Member Functions

clearValues()

template <typename TUniformScope>
void helios::engine::rendering::shader::UniformValueBag< TUniformScope >::clearValues ()
inline

Resets all stored uniform values to defaults.

Definition at line 58 of file UniformValueBag.ixx.

58 void clearValues() {
59 modelMatrix = helios::math::mat4f();
60 projectionMatrix = helios::math::mat4f();
61 viewMatrix = helios::math::mat4f();
62 materialBaseColor = helios::math::vec4f();
63 textColor = helios::math::vec4f();
64
65 textTexture = 0;
66
67 materialRoughness = 0.0f;
68 deltaTime = 0.0f;
69 totalTime = 0.0f;
70 }

References helios::engine::rendering::shader::types::deltaTime and helios::engine::rendering::shader::types::totalTime.

Referenced by helios::engine::rendering::shader::UniformValueBag< TUniformScope >::UniformValueBag.

get()

template <typename TUniform>
const TUniform::value_type & helios::engine::rendering::shader::UniformValueBag< TUniformScope >::get ()
inline

Returns the stored value for a typed uniform.

Template Parameters
TUniform

Uniform tag type.

Returns

Const reference to the stored value.

Definition at line 97 of file UniformValueBag.ixx.

97 [[nodiscard]] const typename TUniform::value_type& get() {
98 if constexpr (std::same_as<TUniform, ModelMatrixUniform>) {
99 return modelMatrix;
100 } else if constexpr (std::same_as<TUniform, ViewMatrixUniform>) {
101 return viewMatrix;
102 } else if constexpr (std::same_as<TUniform, ProjectionMatrixUniform>) {
103 return projectionMatrix;
104 } else if constexpr (std::same_as<TUniform, MaterialBaseColorUniform>) {
105 return materialBaseColor;
106 } else {
107 assert(false && "Unsupported uniform type in UniformValueBag::value");
108 }
109
110
111 }

Reference helios::engine::rendering::registerComponents.

has()

template <typename TUniform>
bool helios::engine::rendering::shader::UniformValueBag< TUniformScope >::has ()
inline noexcept

Checks whether a typed uniform value is marked as active.

Template Parameters
TUniform

Uniform tag type providing semantics.

Returns

true if the semantic slot is active.

Definition at line 78 of file UniformValueBag.ixx.

79 return active_.test(std::to_underlying(TUniform::semantics));
80 }

Referenced by helios::engine::rendering::shader::UniformValueBag< TUniformScope >::mat4f and helios::engine::rendering::shader::UniformValueBag< TUniformScope >::vec4f.

has()

template <typename TUniformScope>
bool helios::engine::rendering::shader::UniformValueBag< TUniformScope >::has (const UniformSemantics semantics)
inline noexcept

Checks whether a semantic slot is marked as active.

Parameters
semantics

Semantic slot to query.

Returns

true if the semantic slot is active.

Definition at line 87 of file UniformValueBag.ixx.

87 [[nodiscard]] bool has(const UniformSemantics semantics) const noexcept {
88 return active_.test(std::to_underlying(semantics));
89 }

mat4f()

template <typename TUniformScope>
const helios::math::mat4f * helios::engine::rendering::shader::UniformValueBag< TUniformScope >::mat4f (const UniformSemantics semantics)
inline noexcept

Returns a matrix pointer for a matrix semantic.

Parameters
semantics

Semantic slot to query.

Returns

Pointer to mat4f or nullptr.

Definition at line 140 of file UniformValueBag.ixx.

140 [[nodiscard]] const helios::math::mat4f* mat4f(const UniformSemantics semantics) const noexcept {
141 if (!has(semantics)) {
142 return nullptr;
143 }
144
145 switch (semantics) {
146 case UniformSemantics::ModelMatrix:
147 return &modelMatrix;
148 case UniformSemantics::ViewMatrix:
149 return &viewMatrix;
150 case UniformSemantics::ProjectionMatrix:
151 return &projectionMatrix;
152 default:
153 assert(false && "Unsupported uniform type in UniformValueBag::value");
154 }
155 }

References helios::engine::rendering::shader::UniformValueBag< TUniformScope >::has and helios::engine::rendering::registerComponents.

set()

template <typename TUniform>
void helios::engine::rendering::shader::UniformValueBag< TUniformScope >::set (const typename TUniform::value_type & value)
inline

Stores a value for a typed uniform and marks it active.

Template Parameters
TUniform

Uniform tag type.

Parameters
value

Value to store.

Definition at line 119 of file UniformValueBag.ixx.

119 void set (const typename TUniform::value_type& value) {
120 if constexpr (std::same_as<TUniform, ModelMatrixUniform>) {
121 modelMatrix = value;
122 } else if constexpr (std::same_as<TUniform, ViewMatrixUniform>) {
123 viewMatrix = value;
124 } else if constexpr (std::same_as<TUniform, ProjectionMatrixUniform>) {
125 projectionMatrix = value;
126 } else if constexpr (std::same_as<TUniform, MaterialBaseColorUniform>) {
127 materialBaseColor = value;
128 } else {
129 assert(false && "Unsupported uniform type in UniformValueBag::value");
130 }
131
132 active_.set(std::to_underlying(TUniform::semantics));
133 }

Reference helios::engine::rendering::registerComponents.

vec4f()

template <typename TUniformScope>
const helios::math::vec4f * helios::engine::rendering::shader::UniformValueBag< TUniformScope >::vec4f (const UniformSemantics semantics)
inline noexcept

Returns a vector pointer for a vector semantic.

Parameters
semantics

Semantic slot to query.

Returns

Pointer to vec4f or nullptr.

Definition at line 162 of file UniformValueBag.ixx.

162 [[nodiscard]] const helios::math::vec4f* vec4f(const UniformSemantics semantics) const noexcept {
163 if (!has(semantics)) {
164 return nullptr;
165 }
166
167 switch (semantics) {
168 case UniformSemantics::MaterialBaseColor:
169 return &materialBaseColor;
170 case UniformSemantics::TextColor:
171 return &textColor;
172 default:
173 assert(false && "Unsupported uniform type in UniformValueBag::value");
174 }
175 }

References helios::engine::rendering::shader::UniformValueBag< TUniformScope >::has and helios::engine::rendering::registerComponents.

Private Member Attributes

active_

template <typename TUniformScope>
std::bitset<std::to_underlying(UniformSemantics::size_)> helios::engine::rendering::shader::UniformValueBag< TUniformScope >::active_

Definition at line 43 of file UniformValueBag.ixx.

43 std::bitset<std::to_underlying(UniformSemantics::size_)> active_;

deltaTime

template <typename TUniformScope>
float helios::engine::rendering::shader::UniformValueBag< TUniformScope >::deltaTime

Definition at line 40 of file UniformValueBag.ixx.

40 float deltaTime;

materialBaseColor

template <typename TUniformScope>
helios::math::vec4f helios::engine::rendering::shader::UniformValueBag< TUniformScope >::materialBaseColor

Definition at line 33 of file UniformValueBag.ixx.

33 helios::math::vec4f materialBaseColor;

materialRoughness

template <typename TUniformScope>
float helios::engine::rendering::shader::UniformValueBag< TUniformScope >::materialRoughness

Definition at line 39 of file UniformValueBag.ixx.

39 float materialRoughness;

modelMatrix

template <typename TUniformScope>
helios::math::mat4f helios::engine::rendering::shader::UniformValueBag< TUniformScope >::modelMatrix

Definition at line 30 of file UniformValueBag.ixx.

30 helios::math::mat4f modelMatrix;

projectionMatrix

template <typename TUniformScope>
helios::math::mat4f helios::engine::rendering::shader::UniformValueBag< TUniformScope >::projectionMatrix

Definition at line 31 of file UniformValueBag.ixx.

31 helios::math::mat4f projectionMatrix;

textColor

template <typename TUniformScope>
helios::math::vec4f helios::engine::rendering::shader::UniformValueBag< TUniformScope >::textColor

Definition at line 35 of file UniformValueBag.ixx.

35 helios::math::vec4f textColor;

textTexture

template <typename TUniformScope>
int helios::engine::rendering::shader::UniformValueBag< TUniformScope >::textTexture

Definition at line 37 of file UniformValueBag.ixx.

37 int textTexture;

totalTime

template <typename TUniformScope>
float helios::engine::rendering::shader::UniformValueBag< TUniformScope >::totalTime

Definition at line 41 of file UniformValueBag.ixx.

41 float totalTime;

viewMatrix

template <typename TUniformScope>
helios::math::mat4f helios::engine::rendering::shader::UniformValueBag< TUniformScope >::viewMatrix

Definition at line 32 of file UniformValueBag.ixx.

32 helios::math::mat4f viewMatrix;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.