class MaterialParametersBase

Common functionality for MaterialParameters and render::MaterialParameters.

Public

Constructors

MaterialParametersBase

MaterialParametersBase(const Map<String, ShaderDataParameterInformation> &dataParams, const Map<String, ShaderObjectParameterInformation> &textureParams, const Map<String, ShaderObjectParameterInformation> &bufferParams, const Map<String, ShaderObjectParameterInformation> &samplerParams, u64 initialParamVersion)

Creates a new material params object and initializes enough room for parameters from the provided parameter data.

MaterialParametersBase

MaterialParametersBase() noexcept(false) = default

Constructor for serialization use only.

Methods

~MaterialParametersBase

virtual ~MaterialParametersBase() noexcept

GetColorGradientParam

const ColorGradientHDR &GetColorGradientParam(const String &name, u32 arrayIdx) const

Returns the color gradient assigned to a shader color parameter with the specified name at the specified array index.

If the parameter name, index or type is not valid a warning will be logged and output value will not be retrieved. If no gradient has been assigned to this parameter then an empty gradient is returned.

name
Name of the shader parameter.
arrayIdx
If the parameter is an array, index of the entry to access.

Returns: Color gradient assigned to the parameter.

SetColorGradientParam

void SetColorGradientParam(const String &name, u32 arrayIdx, const ColorGradientHDR &input)

Sets a color gradient to a shader color parameter with the specified name at the specified array index.

If the parameter name, index or type is not valid a warning will be logged and output value will not be set.

name
Name of the shader parameter.
arrayIdx
If the parameter is an array, index of the entry to access.
input
New value of the parameter.

GetParamIndex

u32 GetParamIndex(const String &name) const

Returns an index of the parameter with the specified name.

Index can be used in a call to getParamData(u32) to get the actual parameter data.

name
Name of the shader parameter.

Returns: Index of the parameter, or -1 if not found.

GetParamIndex

GetParamResult GetParamIndex(const String &name, ParamType type, GpuDataParameterType dataType, u32 arrayIdx, u32 &output) const

Returns an index of the parameter with the specified name.

Index can be used in a call to getParamData(u32) to get the actual parameter data.

name
Name of the shader parameter.
type
Type of the parameter retrieve. Error will be logged if actual type of the parameter doesn't match.
dataType
Only relevant if the parameter is a data type. Determines exact data type of the parameter to retrieve.
arrayIdx
Array index of the entry to retrieve.
output
Index of the requested parameter, only valid if success is returned.

Returns: Success or error state of the request.

GetParamData

GetParamResult GetParamData(const String &name, ParamType type, GpuDataParameterType dataType, u32 arrayIdx, const ParamData **output) const

Returns data about a parameter and reports an error if there is a type or size mismatch, or if the parameter does exist.

name
Name of the shader parameter.
type
Type of the parameter retrieve. Error will be logged if actual type of the parameter doesn't match.
dataType
Only relevant if the parameter is a data type. Determines exact data type of the parameter to retrieve.
arrayIdx
Array index of the entry to retrieve.
output
Object describing the parameter with an index to its data. If the parameter was not found this value is undefined. This value will still be valid if parameter was found but some other error was reported.

Returns: Success or error state of the request.

GetParamData

const ParamData *GetParamData(u32 index) const

Returns information about a parameter at the specified global index, as retrieved by getParamIndex().

GetParameterCount

u32 GetParameterCount() const

Returns the total number of parameters managed by this object.

ReportGetParamError

void ReportGetParamError(GetParamResult errorCode, const String &name, u32 arrayIdx) const

Logs an error that was reported by getParamData().

errorCode
Information about the error.
name
Name of the shader parameter for which the error occurred.
arrayIdx
Array index for which the error occurred.

GetColorGradientParam

const ColorGradientHDR &GetColorGradientParam(const ParamData &param, u32 arrayIdx) const

Equivalent to getColorGradientParam(const String & , u32) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

SetColorGradientParam

void SetColorGradientParam(const ParamData &param, u32 arrayIdx, const ColorGradientHDR &input)

Equivalent to setColorGradientParam(const String & , u32, const ColorGradient & ) except it uses the internal parameter reference directly, avoiding the name lookup.

Caller must guarantee the parameter reference is valid and belongs to this object.

GetData

u8 *GetData(u32 index) const

Returns pointer to the internal data buffer for a data parameter at the specified index.

GetParamVersion

u64 GetParamVersion() const

Returns a counter that gets incremented whenever a parameter gets updated.

Protected

Fields

mParamLookup

UnorderedMap<String, u32> mParamLookup

mParams

Vector<ParamData> mParams

mDataParameterMetaData

TInlineArray<DataParamInfo, 16> mDataParameterMetaData

mStructParameterMetaData

TInlineArray<StructParameterMetaData, 2> mStructParameterMetaData

mDataParamsBuffer

u8 * mDataParamsBuffer

mDataSize

u32 mDataSize

mTextureParameterCount

u32 mTextureParameterCount

mBufferParameterCount

u32 mBufferParameterCount

mSamplerParameterCount

u32 mSamplerParameterCount

mParamVersion

u64 mParamVersion

mAlloc

StaticAlloc<kStaticBufferSize> mAlloc