Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RPI::ShaderOptionDescriptor Class Referencefinal

#include <ShaderOptionGroupLayout.h>

Public Member Functions

 AZ_TYPE_INFO (AZ::RPI::ShaderOptionDescriptor, "{07B9E2F7-5408-49E9-904D-CC1A9C33230E}")
 
 ShaderOptionDescriptor (const Name &name, const ShaderOptionType &optionType, uint32_t bitOffset, uint32_t order, const ShaderOptionValues &nameIndexList, const Name &defaultValue={})
 
 AZ_DEFAULT_COPY_MOVE (ShaderOptionDescriptor)
 
const Name & GetName () const
 
uint32_t GetBitOffset () const
 Returns the offset and count of bits comprising the local mask for the option.
 
uint32_t GetBitCount () const
 
uint32_t GetOrder () const
 Returns the order (rank) for this option. Lower order means higher priority.
 
ShaderVariantKey GetBitMask () const
 Returns the mask comprising bits specific to this option.
 
ShaderVariantKey GetBitMaskNot () const
 Returns the reverse mask for this option, used to unset the mask.
 
HashValue64 GetHash () const
 Returns a unique hash value describing this descriptor.
 
bool Set (ShaderOptionGroup &group, const Name &valueName) const
 
bool Set (ShaderOptionGroup &group, const ShaderOptionValue value) const
 Sets the corresponding option in the option group to the specified option value.
 
bool Set (ShaderVariantKey &key, const ShaderOptionValue value) const
 Sets the corresponding option in the variant key directly to the specified option value.
 
ShaderOptionValue Get (const ShaderOptionGroup &group) const
 Gets the option value for the corresponding option in the option group.
 
void Clear (ShaderOptionGroup &group) const
 Sets the corresponding option in the option group to an uninitialized state.
 
void SetDefaultValue (const Name &valueName)
 Sets the default value for this option by name.
 
const Name & GetDefaultValue () const
 Gets the default value for this option by name.
 
uint32_t GetValuesCount () const
 Gets the number of valid values for this option.
 
void SetType (ShaderOptionType optionType)
 Sets the type for the shader option (bool, enum, integer range, etc.).
 
const ShaderOptionType & GetType () const
 Gets the type for the shader option (bool, enum, integer range, etc.).
 
ShaderOptionValue GetMinValue () const
 Gets the minimal possible option value for the corresponding option .
 
ShaderOptionValue GetMaxValue () const
 Gets the maximum possible option value for the corresponding option.
 
ShaderOptionValue FindValue (const Name &valueName) const
 Finds a shader value index from a value name. Returns an empty handle if the value name was not found.
 
Name GetValueName (ShaderOptionValue value) const
 Gets the name for the option value.
 
Name GetValueName (uint32_t valueIndex) const
 Gets the name for the option value.
 
bool operator== (const ShaderOptionDescriptor &) const
 
bool operator!= (const ShaderOptionDescriptor &) const
 
uint32_t DecodeBits (ShaderVariantKey key) const
 

Static Public Member Functions

static void Reflect (ReflectContext *context)
 
static bool CompareOrder (const ShaderOptionDescriptor &first, const ShaderOptionDescriptor &second)
 True if the order of first option has higher priority than the second option.
 
static bool SameOrder (const ShaderOptionDescriptor &first, const ShaderOptionDescriptor &second)
 True if the order of this option has the same priority as the other option.
 

Detailed Description

Describes a shader option to the ShaderOptionGroupLayout class. Maps a shader option to a set of bits in a mask in order to facilitate packing values into a mask to form a ShaderKey.

Constructor & Destructor Documentation

◆ ShaderOptionDescriptor()

AZ::RPI::ShaderOptionDescriptor::ShaderOptionDescriptor ( const Name &  name,
const ShaderOptionType &  optionType,
uint32_t  bitOffset,
uint32_t  order,
const ShaderOptionValues &  nameIndexList,
const Name &  defaultValue = {} 
)

ShaderOptionDescriptor constructor. This is the preferred constructor for ShaderOptionDescriptor.

Parameters
namevariable name for this Option
optionTypeType hint for the option - bool, enum, integer range, etc.
bitOffsetBit offset must match the ShaderOptionGroupLayout where this Option will be added
orderThe order (rank) of the shader option. Must be unique within a group. Lower order is higher priority.
nameIndexListList of valid (valueName, value) pairs for this Option. See "Create*ShaderOptionValues" utility functions above.
defaultValueDefault value name, which must also be in the nameIndexList. In the cases where the list defines a range (IntegerRange for instance) defaultValue must be within the range instead. If omitted, the first entry in @nameIndexList will be used.

Member Function Documentation

◆ DecodeBits()

uint32_t AZ::RPI::ShaderOptionDescriptor::DecodeBits ( ShaderVariantKey  key) const

Decodes the value stored in the shader key associated with the bit region defined by the descriptor. The method will not test the bit mask, this responsibility lies with the caller.

◆ Set()

bool AZ::RPI::ShaderOptionDescriptor::Set ( ShaderOptionGroup group,
const Name &  valueName 
) const

Sets the corresponding option in the option group to the specified named option value. For performance reasons consider caching the index for valueName and calling void Set(ShaderOptionGroup& group, const ShaderOptionValue value) instead.


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