Cogs.Core
|
Material property buffers contain properties for a material, such as color, reflectiveness or other values, packed into a buffer for easy data management in the renderer. More...
#include <MaterialPropertyBuffer.h>
Public Member Functions | |
COGSCORE_DLL_API MaterialPropertyDescriptor | addProperty (size_t propertyAlignment, size_t propertySize, const uint8_t *data) |
Add the value pointed to by data, with the given propertySize, to the buffer. | |
COGSCORE_DLL_API void | finalize (Context *context) |
MaterialPropertyDescriptor | addProperty (const bool &data) |
MaterialPropertyDescriptor | addProperty (const float &data) |
MaterialPropertyDescriptor | addProperty (const int &data) |
MaterialPropertyDescriptor | addProperty (const glm::ivec2 &data) |
MaterialPropertyDescriptor | addProperty (const glm::ivec3 &data) |
MaterialPropertyDescriptor | addProperty (const glm::ivec4 &data) |
MaterialPropertyDescriptor | addProperty (const glm::vec2 &data) |
MaterialPropertyDescriptor | addProperty (const glm::vec3 &data) |
MaterialPropertyDescriptor | addProperty (const glm::vec4 &data) |
MaterialPropertyDescriptor | addProperty (const glm::mat4 &data) |
MaterialPropertyDescriptor | addProperty (const uint32_t &data) |
MaterialPropertyDescriptor | addProperty (const glm::uvec2 &data) |
MaterialPropertyDescriptor | addProperty (const glm::uvec3 &data) |
MaterialPropertyDescriptor | addProperty (const glm::uvec4 &data) |
COGSCORE_DLL_API void | setValue (size_t offset, size_t propertySize, const uint8_t *data) |
Set the property value for the property located at offset to that pointed to by data. | |
void | setValue (const MaterialPropertyDescriptor &descriptor, const uint8_t *data) |
template<typename T > | |
void | setValue (size_t offset, const T &value) |
Set the property value for the property located at offset to the value given. | |
template<typename T > | |
const T & | getValue (size_t offset) const |
Get the property value of type T located at offset. | |
template<> | |
void | setValue (size_t offset, const bool &boolValue) |
template<> | |
const bool & | getValue (size_t offset) const |
Public Attributes | |
std::vector< uint8_t > | content |
Default content for property buffer instances created from this buffer. | |
ConstantBufferKey | index |
Index of the buffer in the set of buffers owned by the same Material. | |
PropertyName | name |
Name used to refer to the buffer in shaders. | |
size_t | size = 0 |
Total size of the buffer in bytes. | |
bool | isPerInstance = true |
If the buffer is updated per instance. | |
size_t | generation = 1 |
Generation counter. | |
Material property buffers contain properties for a material, such as color, reflectiveness or other values, packed into a buffer for easy data management in the renderer.
When constructing a property buffer manually for use with an Effect, take care ensuring the layout of the buffer matches that of the corresponding constant/uniform layout declared in the shaders used by the effect.
Only simple structures supported by GPU shaders can be stored as properties, such as integers, floats, vec2s and vec4 structures. Using vec3 or other three-component structures is discouraged as these will always be padded in the structure layout anyways.
Material property buffers are never directly used by the Renderer, which will always read buffer contents from MaterialPropertyBufferInstance objects.
Definition at line 41 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 61 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 67 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 77 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 82 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 87 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 107 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 117 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 122 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 127 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 92 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 97 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 102 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 72 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 112 of file MaterialPropertyBuffer.h.
Cogs::Core::MaterialPropertyDescriptor Cogs::Core::MaterialPropertyBuffer::addProperty | ( | size_t | propertyAlignment, |
size_t | propertySize, | ||
const uint8_t * | data | ||
) |
Add the value pointed to by data, with the given propertySize, to the buffer.
The buffer will expand its storage to at least fit the contents of data, but may be larger due to padding constraints enforced by constant buffers.
propertySize | Size of the data type in bytes. |
data | Data value to set the initialized buffer storage to. |
Definition at line 22 of file MaterialPropertyBuffer.cpp.
void Cogs::Core::MaterialPropertyBuffer::finalize | ( | Context * | context | ) |
Definition at line 39 of file MaterialPropertyBuffer.cpp.
|
inline |
Get the property value of type T located at offset.
offset | Offset in bytes from the start of the buffer. |
Type | of the property value. |
Definition at line 172 of file MaterialPropertyBuffer.h.
References content.
|
inline |
Definition at line 205 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 142 of file MaterialPropertyBuffer.h.
|
inline |
Definition at line 198 of file MaterialPropertyBuffer.h.
|
inline |
Set the property value for the property located at offset to the value given.
offset | Offset in bytes from the start of the buffer to the location of the first byte of the property value. |
value | Property value to copy to the buffer. |
T | Type of the property value. |
Definition at line 157 of file MaterialPropertyBuffer.h.
References setValue().
void Cogs::Core::MaterialPropertyBuffer::setValue | ( | size_t | offset, |
size_t | propertySize, | ||
const uint8_t * | data | ||
) |
Set the property value for the property located at offset to that pointed to by data.
offset | Offset in bytes from the start of the buffer to the location of the first byte of the property value. |
propertySize | Size of the property in bytes, the number of bytes to copy from data. |
data | Pointer to a property value to copy from. |
Definition at line 11 of file MaterialPropertyBuffer.cpp.
References content, and generation.
Referenced by setValue().
std::vector<uint8_t> Cogs::Core::MaterialPropertyBuffer::content |
Default content for property buffer instances created from this buffer.
Definition at line 178 of file MaterialPropertyBuffer.h.
Referenced by getValue(), and setValue().
size_t Cogs::Core::MaterialPropertyBuffer::generation = 1 |
Generation counter.
Definition at line 193 of file MaterialPropertyBuffer.h.
Referenced by setValue().
ConstantBufferKey Cogs::Core::MaterialPropertyBuffer::index |
Index of the buffer in the set of buffers owned by the same Material.
Definition at line 181 of file MaterialPropertyBuffer.h.
bool Cogs::Core::MaterialPropertyBuffer::isPerInstance = true |
If the buffer is updated per instance.
Definition at line 190 of file MaterialPropertyBuffer.h.
PropertyName Cogs::Core::MaterialPropertyBuffer::name |
Name used to refer to the buffer in shaders.
Definition at line 184 of file MaterialPropertyBuffer.h.
size_t Cogs::Core::MaterialPropertyBuffer::size = 0 |
Total size of the buffer in bytes.
Definition at line 187 of file MaterialPropertyBuffer.h.