#include <ConstantsData.h>
Public Member Functions | |
ConstantsData (const ConstantsLayout *layout) | |
AZ_DEFAULT_COPY_MOVE (ConstantsData) | |
bool | SetConstantRaw (ShaderInputConstantIndex inputIndex, const void *bytes, size_t byteCount) |
Assigns constant data for the given constant shader input index. | |
bool | SetConstantRaw (ShaderInputConstantIndex inputIndex, const void *bytes, size_t byteOffset, size_t byteCount) |
template<typename T > | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const T &value) |
Assigns a value of type T to the constant shader input. | |
bool | SetConstantMatrixRows (ShaderInputConstantIndex inputIndex, const Matrix3x3 &value, uint32_t rowCount) |
Assigns a specified number of rows from a Matrix. | |
bool | SetConstantMatrixRows (ShaderInputConstantIndex inputIndex, const Matrix3x4 &value, uint32_t rowCount) |
bool | SetConstantMatrixRows (ShaderInputConstantIndex inputIndex, const Matrix4x4 &value, uint32_t rowCount) |
template<typename T > | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const T &value, uint32_t arrayIndex) |
Assigns a value of type T to the constant shader input, at an array offset. | |
template<typename T > | |
bool | SetConstantArray (ShaderInputConstantIndex inputIndex, AZStd::span< const T > values) |
Assigns an array of type T to the constant shader input. | |
bool | SetConstantData (const void *bytes, size_t byteCount) |
Assigns constant data as a whole. | |
bool | SetConstantData (const void *bytes, size_t byteOffset, size_t byteCount) |
template<typename T > | |
AZStd::span< const T > | GetConstantArray (ShaderInputConstantIndex inputIndex) const |
template<typename T > | |
T | GetConstant (ShaderInputConstantIndex inputIndex) const |
template<typename T > | |
T | GetConstant (ShaderInputConstantIndex inputIndex, uint32_t arrayIndex) const |
AZStd::span< const uint8_t > | GetConstantRaw (ShaderInputConstantIndex inputIndex) const |
Returns constant data for the given shader input index as a span of bytes. | |
AZStd::span< const uint8_t > | GetConstantData () const |
Returns the opaque constant data populated by calls to SetConstant and SetConstantData. | |
const ConstantsLayout * | GetLayout () const |
Returns the constants layout. | |
bool | ConstantIsEqual (const ConstantsData &other, ShaderInputConstantIndex inputIndex) const |
Returns whether other constant data and this have the same value at the specified shader input index. | |
AZStd::vector< ShaderInputConstantIndex > | GetIndicesOfDifferingConstants (const ConstantsData &other) const |
template<> | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const bool &value) |
template<> | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const Matrix3x3 &value) |
template<> | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const Matrix3x4 &value) |
template<> | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const Matrix4x4 &value) |
template<> | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const Vector2 &value) |
template<> | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const Vector3 &value) |
template<> | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const Vector4 &value) |
template<> | |
bool | SetConstant (ShaderInputConstantIndex inputIndex, const Color &value) |
template<> | |
bool | SetConstantArray (ShaderInputConstantIndex inputIndex, AZStd::span< const bool > values) |
template<> | |
bool | GetConstant (ShaderInputConstantIndex inputIndex) const |
template<> | |
Matrix3x3 | GetConstant (ShaderInputConstantIndex inputIndex) const |
template<> | |
Matrix3x4 | GetConstant (ShaderInputConstantIndex inputIndex) const |
template<> | |
Matrix4x4 | GetConstant (ShaderInputConstantIndex inputIndex) const |
template<> | |
Vector2 | GetConstant (ShaderInputConstantIndex inputIndex) const |
template<> | |
Vector3 | GetConstant (ShaderInputConstantIndex inputIndex) const |
template<> | |
Vector4 | GetConstant (ShaderInputConstantIndex inputIndex) const |
template<> | |
Color | GetConstant (ShaderInputConstantIndex inputIndex) const |
The intent of this class is to provide fast and thin access to the underlying constant data (inline or from an SRG), with basic validation to protect the user. As a secondary objective, it provides type-specific convenience operations as long as they don't violate the primary "fast" and "thin" objectives. To clarify, thin means we don't make assumptions about the data or how the user wants to operate on the data, and the convenience operations boil down to thin wrappers for single calls to SetConstantRaw and GetConstantRaw. So these convenience functions are provided in situations that are "low-hanging-fruit".
T AZ::RHI::ConstantsData::GetConstant | ( | ShaderInputConstantIndex | inputIndex | ) | const |
Returns the constant data as type 'T' returned by value. The size of the constant region must match the size of T exactly. Otherwise, an empty instance is returned.
T AZ::RHI::ConstantsData::GetConstant | ( | ShaderInputConstantIndex | inputIndex, |
uint32_t | arrayIndex | ||
) | const |
Treats the constant input as an array of type T, returning the element by value at the specified array index. The size of the constant region must equally partition into an array of type T. Otherwise, an empty instance is returned.
AZStd::span< const T > AZ::RHI::ConstantsData::GetConstantArray | ( | ShaderInputConstantIndex | inputIndex | ) | const |
Returns constant data for the given shader input index as a template type. The stride of T must match the size of the constant input region. The number of elements in the returned array is the number of evenly divisible elements. If the strides do not match, an empty array is returned.
AZStd::vector< ShaderInputConstantIndex > AZ::RHI::ConstantsData::GetIndicesOfDifferingConstants | ( | const ConstantsData & | other | ) | const |
Performs a diff between this and input constant data and returns a list of all the shader input indices for which the constants are not the same between the two. If one of the two has more constants than the other, these additional constants will be added to the end of the returned list.