#include <FastGpuParamRef.h>
Public Member Functions | |
FastGpuParamRef () | |
Default constructor. Starts as unbound. | |
FastGpuParamRef (Ogre::GpuProgramParametersSharedPtr paramsPtr, const Ogre::String &name) | |
Create and bind. | |
void | bind (Ogre::GpuProgramParametersSharedPtr paramsPtr, const Ogre::String &name, bool throwIfNotFound=false) |
Bind to a certain parameter. | |
void | unbind () |
Unbind ParamRef. | |
bool | isBound () const |
Return if this param ref is bound to an actual param. | |
size_t | getPhysicalIndex () const |
Return the physical index. Only valid if this->isBound(). | |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, int val) const |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, Ogre::Real val) const |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, const Ogre::Vector3 &val) const |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, const Ogre::Vector4 &val) const |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, const Ogre::ColourValue &val) const |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, const Ogre::Matrix4 &val) const |
Protected Member Functions | |
template<typename ArgumentT > | |
void | doSet (const Ogre::GpuProgramParametersSharedPtr ¶ms, ArgumentT arg) const |
Set the value. | |
template<typename ArgumentT > | |
void | doSet (const Ogre::GpuProgramParametersSharedPtr ¶ms, ArgumentT arg, size_t count) const |
Profiling shows that GpuProgramParameters::_findNamedConstantDefinition is not free.
This class avoids hash lookups when updating. It's uses no additional memory than if you were to implement the same thing manually.
You must also keep the matching Ogre::GpuProgramParametersSharedPtr and send it whenever you call FastGpuParamRef::set. This is required to save memory in release mode. Debug mode checks the pointer you pass to set is the same as the pointer you called bind on; but uses more memory.
Also; please note that fetching gpu params from a material every frame is not free either.
Definition at line 49 of file FastGpuParamRef.h.
void Caelum::FastGpuParamRef::bind | ( | Ogre::GpuProgramParametersSharedPtr | paramsPtr, | |
const Ogre::String & | name, | |||
bool | throwIfNotFound = false | |||
) |
Bind to a certain parameter.
paramsPtr | params to bind to. Can't be null; you must unbind explicitly. | |
name | The name of the parameter to bind. | |
throwIfNotFound | Argument to GpuProgramParameters::_findNamedConstantDefinition. |
Definition at line 33 of file FastGpuParamRef.cpp.
References isBound().
Referenced by FastGpuParamRef().
void Caelum::FastGpuParamRef::unbind | ( | ) |
Unbind ParamRef.
If CAELUM_DEBUG_PARAM_REF is 1 this will also release the hold on GpuProgramParametersSharedPtr.
Definition at line 52 of file FastGpuParamRef.cpp.
References isBound().
void Caelum::FastGpuParamRef::doSet | ( | const Ogre::GpuProgramParametersSharedPtr & | params, | |
ArgumentT | arg | |||
) | const [inline, protected] |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null | |
arg | Argument to set. |
Definition at line 99 of file FastGpuParamRef.h.
void Caelum::FastGpuParamRef::set | ( | const Ogre::GpuProgramParametersSharedPtr & | params, | |
int | val | |||
) | const [inline] |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null | |
arg | Argument to set. |
Definition at line 122 of file FastGpuParamRef.h.
void Caelum::FastGpuParamRef::set | ( | const Ogre::GpuProgramParametersSharedPtr & | params, | |
Ogre::Real | val | |||
) | const [inline] |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null | |
arg | Argument to set. |
Definition at line 124 of file FastGpuParamRef.h.
void Caelum::FastGpuParamRef::set | ( | const Ogre::GpuProgramParametersSharedPtr & | params, | |
const Ogre::Vector3 & | val | |||
) | const [inline] |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null | |
arg | Argument to set. |
Definition at line 126 of file FastGpuParamRef.h.
void Caelum::FastGpuParamRef::set | ( | const Ogre::GpuProgramParametersSharedPtr & | params, | |
const Ogre::Vector4 & | val | |||
) | const [inline] |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null | |
arg | Argument to set. |
Definition at line 128 of file FastGpuParamRef.h.
void Caelum::FastGpuParamRef::set | ( | const Ogre::GpuProgramParametersSharedPtr & | params, | |
const Ogre::ColourValue & | val | |||
) | const [inline] |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null | |
arg | Argument to set. |
Definition at line 130 of file FastGpuParamRef.h.
void Caelum::FastGpuParamRef::set | ( | const Ogre::GpuProgramParametersSharedPtr & | params, | |
const Ogre::Matrix4 & | val | |||
) | const [inline] |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null | |
arg | Argument to set. |
Definition at line 132 of file FastGpuParamRef.h.