Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::gfx::Attribute Class Reference

#include "attribute.h"

Inheritance diagram for ion::gfx::Attribute:
Collaboration diagram for ion::gfx::Attribute:

Public Types

typedef AttributeValueType HolderType
 
typedef AttributeType ValueType
 
enum  Tag {
  kUniform,
  kAttribute
}
 This is only used to determine the type of a ShaderInputRegistry::Spec since Attributes and Uniforms share the space of names. More...
 

Public Member Functions

 Attribute ()
 The default constructor creates an invalid Attribute instance, which should never be used as is. More...
 
 ~Attribute ()
 
bool IsFixedPointNormalized () const
 Checks and sets whether integer values should be mapped to the range [-1,1] (for signed values) or [0,1] (for unsigned values) when they are accessed and converted to floating point. More...
 
void SetFixedPointNormalized (bool normalize)
 
bool operator== (const Attribute &other) const
 
bool operator!= (const Attribute &other) const
 Needed for Field::Set(). More...
 
unsigned int GetDivisor () const
 Sets/Gets the attribute divisor. More...
 
void SetDivisor (unsigned int divisor)
 
template<>
ION_API Attribute::ValueType GetTypeByValue ()
 Specialize for each supported type. More...
 
template<>
ION_API Attribute::ValueType GetTypeByValue ()
 
bool IsValid () const
 Returns true if this is a valid instance created by a ShaderInputRegistry. More...
 
const ShaderInputRegistryGetRegistry () const
 Returns the ShaderInputRegistry the shader input is defined in. More...
 
size_t GetIndexInRegistry () const
 Returns the index of the shader input within the registry. More...
 
size_t GetRegistryId () const
 Returns the id of the owning registry. More...
 
size_t GetArrayIndex () const
 Returns the array index of this input; by default this is 0. More...
 
ValueType GetType () const
 Returns the type of the shader input. More...
 
const TGetValue () const
 If this instance contains a value of type T, this returns a const reference to it. More...
 
const TGetValueAt (size_t i) const
 If this instance contains an array of values of type T with a length smaller than the passed index, this returns a const reference to the element at i. More...
 
size_t GetCount () const
 Returns the number of elements in the held type. More...
 
bool Is () const
 If this instance contains a value of type T, this returns true, otherwise it returns false. More...
 
bool IsArrayOf () const
 If this instance contains an array of values of type T, this returns true, otherwise it returns false. More...
 
bool SetValue (const T &value)
 If this instance contains a value of type T, this changes it to the new value. More...
 
bool SetValueAt (size_t i, const T &value)
 If this instance contains a array of values of type T with a length larger than i, this changes the element at i to the new value. More...
 
uint64 GetStamp () const
 Returns the stamp of the input. More...
 

Static Public Member Functions

static const char * GetShaderInputTypeName ()
 Returns a string containing "attribute". More...
 
static const char * GetValueTypeName (const ValueType type)
 Returns a string representing a attribute type. More...
 
template<typename T >
static ValueType GetTypeByValue ()
 Returns the type for a templated value type. More...
 
static Tag GetTag ()
 Returns the tag for this input type. More...
 

Protected Member Functions

void SetNewStamp ()
 Assigns a new stamp to this Input. More...
 
void Init (const ShaderInputRegistry &registry, size_t registry_id, size_t index_in_registry, size_t array_index, ValueType type, const T &value)
 Initializes the ShaderInput to a valid state. More...
 
void InitArray (const ShaderInputRegistry &registry, size_t registry_id, size_t index_in_registry, size_t array_index, ValueType type, const T *values, size_t count, const base::AllocatorPtr &allocator)
 Initializes the ShaderInput to a valid state. More...
 
const base::AllocatorPtrGetArrayAllocator () const
 Returns the allocator used to make array allocations. More...
 

Static Protected Member Functions

static uint64 GetNewStamp ()
 Returns atomically post-incremented stamp. More...
 

Detailed Description

Definition at line 55 of file attribute.h.

Member Typedef Documentation

Definition at line 53 of file shaderinput.h.

Member Enumeration Documentation

This is only used to determine the type of a ShaderInputRegistry::Spec since Attributes and Uniforms share the space of names.

Enumerator
kUniform 
kAttribute 

Definition at line 35 of file shaderinput.h.

Constructor & Destructor Documentation

ion::gfx::Attribute::Attribute ( )
inline

The default constructor creates an invalid Attribute instance, which should never be used as is.

IsValid() will return false for such an instance.

Definition at line 61 of file attribute.h.

ion::gfx::Attribute::~Attribute ( )
inline

Definition at line 65 of file attribute.h.

Member Function Documentation

const base::AllocatorPtr& ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetArrayAllocator ( ) const
inlineprotectedinherited

Returns the allocator used to make array allocations.

Definition at line 207 of file shaderinput.h.

size_t ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetArrayIndex ( ) const
inlineinherited

Returns the array index of this input; by default this is 0.

An array index is specified in the input name with square brackets, e.g., uMyArray[2] has an index of 2.

Definition at line 76 of file shaderinput.h.

size_t ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetCount ( ) const
inlineinherited

Returns the number of elements in the held type.

This is 0 if this holds only a scalar value.

Definition at line 99 of file shaderinput.h.

unsigned int ion::gfx::Attribute::GetDivisor ( ) const
inline

Sets/Gets the attribute divisor.

Definition at line 96 of file attribute.h.

size_t ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetIndexInRegistry ( ) const
inlineinherited

Returns the index of the shader input within the registry.

This should not be called on an invalid instance.

Definition at line 67 of file shaderinput.h.

Referenced by operator==().

uint64 ion::gfx::ShaderInputBase::GetNewStamp ( )
staticprotectedinherited

Returns atomically post-incremented stamp.

Definition at line 24 of file shaderinput.cc.

Referenced by ion::gfx::ShaderInput< UniformValueType, UniformType >::SetNewStamp().

const ShaderInputRegistry& ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetRegistry ( ) const
inlineinherited

Returns the ShaderInputRegistry the shader input is defined in.

This will crash if called on an invalid instance.

Definition at line 63 of file shaderinput.h.

Referenced by operator==().

size_t ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetRegistryId ( ) const
inlineinherited

Returns the id of the owning registry.

This value will not be useful if called on an invalid instance.

Definition at line 71 of file shaderinput.h.

const char * ion::gfx::Attribute::GetShaderInputTypeName ( )
static

Returns a string containing "attribute".

Definition at line 25 of file attribute.cc.

uint64 ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetStamp ( ) const
inlineinherited

Returns the stamp of the input.

The stamp is a global counter which is advanced any time a ShaderInput is modified. Two Uniforms with the same stamp are guaranteed to have the same values. Two Uniforms with different stamps may or may not have the same value.

Definition at line 145 of file shaderinput.h.

static Tag ion::gfx::Attribute::GetTag ( )
inlinestatic

Returns the tag for this input type.

Definition at line 78 of file attribute.h.

ValueType ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetType ( ) const
inlineinherited

Returns the type of the shader input.

This should not be called on an invalid instance.

Definition at line 80 of file shaderinput.h.

Referenced by operator==().

template<>
ION_API Attribute::ValueType ion::gfx::Attribute::GetTypeByValue ( )

Specialize for each supported type.

Definition at line 51 of file attribute.cc.

References ion::gfx::kFloatAttribute.

template<typename T >
Attribute::ValueType ion::gfx::Attribute::GetTypeByValue ( )
static

Returns the type for a templated value type.

This is instantiated for all supported types

Definition at line 44 of file attribute.cc.

References CHECK, and ion::gfx::kFloatAttribute.

template<>
ION_API Attribute::ValueType ion::gfx::Attribute::GetTypeByValue ( )

Definition at line 79 of file attribute.cc.

References ion::gfx::kBufferObjectElementAttribute.

const T& ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetValue ( ) const
inlineinherited

If this instance contains a value of type T, this returns a const reference to it.

Otherwise, it returns an InvalidReference. This should not be called on an invalid instance.

Definition at line 85 of file shaderinput.h.

const T& ion::gfx::ShaderInput< AttributeValueType , AttributeType >::GetValueAt ( size_t  i) const
inlineinherited

If this instance contains an array of values of type T with a length smaller than the passed index, this returns a const reference to the element at i.

Otherwise, it returns an InvalidReference. This should not be called on an invalid instance.

Definition at line 93 of file shaderinput.h.

void ion::gfx::ShaderInput< AttributeValueType , AttributeType >::Init ( const ShaderInputRegistry registry,
size_t  registry_id,
size_t  index_in_registry,
size_t  array_index,
ValueType  type,
const T value 
)
inlineprotectedinherited

Initializes the ShaderInput to a valid state.

This is passed the ShaderInputRegistry containing the shader input definition, its index within that registry, the type, and the initial value. The value is assumed to be consistent with the registered type. This function is private because only the ShaderInputRegistry class can create valid instances, enforcing type consistency.

Definition at line 170 of file shaderinput.h.

void ion::gfx::ShaderInput< AttributeValueType , AttributeType >::InitArray ( const ShaderInputRegistry registry,
size_t  registry_id,
size_t  index_in_registry,
size_t  array_index,
ValueType  type,
const T values,
size_t  count,
const base::AllocatorPtr allocator 
)
inlineprotectedinherited

Initializes the ShaderInput to a valid state.

This is passed the ShaderInputRegistry containing the shader input definition, its index within that registry, the type, and the initial set of values (or NULL to not set values). The value is assumed to be consistent with the registered type. This function is private because only the ShaderInputRegistry class can create valid instances, enforcing type consistency.

Definition at line 189 of file shaderinput.h.

bool ion::gfx::ShaderInput< AttributeValueType , AttributeType >::Is ( ) const
inlineinherited

If this instance contains a value of type T, this returns true, otherwise it returns false.

Definition at line 105 of file shaderinput.h.

bool ion::gfx::ShaderInput< AttributeValueType , AttributeType >::IsArrayOf ( ) const
inlineinherited

If this instance contains an array of values of type T, this returns true, otherwise it returns false.

Definition at line 111 of file shaderinput.h.

bool ion::gfx::Attribute::IsFixedPointNormalized ( ) const
inline

Checks and sets whether integer values should be mapped to the range [-1,1] (for signed values) or [0,1] (for unsigned values) when they are accessed and converted to floating point.

If this is false, values will be converted to floats directly without any normalization. Note that the normalization is performed by the graphics hardware on the fly. By default data is not normalized.

Definition at line 86 of file attribute.h.

bool ion::gfx::ShaderInput< AttributeValueType , AttributeType >::IsValid ( ) const
inlineinherited

Returns true if this is a valid instance created by a ShaderInputRegistry.

If this returns false, most of the other methods should not be called.

Definition at line 59 of file shaderinput.h.

bool ion::gfx::Attribute::operator!= ( const Attribute other) const
inline

Needed for Field::Set().

Definition at line 91 of file attribute.h.

void ion::gfx::Attribute::SetDivisor ( unsigned int  divisor)
inline

Definition at line 97 of file attribute.h.

Referenced by ion::gfxutils::BufferToAttributeBinder< T >::Apply().

void ion::gfx::Attribute::SetFixedPointNormalized ( bool  normalize)
inline

Definition at line 87 of file attribute.h.

Referenced by ion::gfxutils::BufferToAttributeBinder< T >::Apply().

void ion::gfx::ShaderInput< AttributeValueType , AttributeType >::SetNewStamp ( )
inlineprotectedinherited

Assigns a new stamp to this Input.

Definition at line 161 of file shaderinput.h.

bool ion::gfx::ShaderInput< AttributeValueType , AttributeType >::SetValue ( const T value)
inlineinherited

If this instance contains a value of type T, this changes it to the new value.

Otherwise, it does nothing but return false. This should not be called on an invalid instance.

Definition at line 118 of file shaderinput.h.

bool ion::gfx::ShaderInput< AttributeValueType , AttributeType >::SetValueAt ( size_t  i,
const T value 
)
inlineinherited

If this instance contains a array of values of type T with a length larger than i, this changes the element at i to the new value.

Otherwise, it does nothing but return false. This should not be called on an invalid instance.

Definition at line 131 of file shaderinput.h.


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