Caelum
0.6.4
|
An optimized reference to a gpu shared parameter. More...
#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. More... | |
void | unbind () |
Unbind ParamRef. More... | |
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 |
Set the value. More... | |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, Ogre::Real val) const |
Set the value. More... | |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, const Ogre::Vector3 &val) const |
Set the value. More... | |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, const Ogre::Vector4 &val) const |
Set the value. More... | |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, const Ogre::ColourValue &val) const |
Set the value. More... | |
void | set (const Ogre::GpuProgramParametersSharedPtr ¶ms, const Ogre::Matrix4 &val) const |
Set the value. More... | |
Protected Member Functions | |
template<typename ArgumentT > | |
void | doSet (const Ogre::GpuProgramParametersSharedPtr ¶ms, ArgumentT arg) const |
Set the value. More... | |
template<typename ArgumentT > | |
void | doSet (const Ogre::GpuProgramParametersSharedPtr ¶ms, ArgumentT arg, size_t count) const |
An optimized reference to a gpu shared parameter.
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.
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. |
If throwIfNotFound is false (the default) missing parameters are ignored and the param ref will remand unbound. Calling set will then have no effect.
void Caelum::FastGpuParamRef::unbind | ( | ) |
Unbind ParamRef.
If CAELUM_DEBUG_PARAM_REF is 1 this will also release the hold on GpuProgramParametersSharedPtr.
|
inlineprotected |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null |
arg | Argument to set. |
Will check params pointer matches the bound pointer if #CAELUM_DEBUG_PARAM_REF. Otherwise a mismatched params pointer can result in memory corruption.
|
inline |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null |
arg | Argument to set. |
Will check params pointer matches the bound pointer if #CAELUM_DEBUG_PARAM_REF. Otherwise a mismatched params pointer can result in memory corruption.
|
inline |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null |
arg | Argument to set. |
Will check params pointer matches the bound pointer if #CAELUM_DEBUG_PARAM_REF. Otherwise a mismatched params pointer can result in memory corruption.
|
inline |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null |
arg | Argument to set. |
Will check params pointer matches the bound pointer if #CAELUM_DEBUG_PARAM_REF. Otherwise a mismatched params pointer can result in memory corruption.
|
inline |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null |
arg | Argument to set. |
Will check params pointer matches the bound pointer if #CAELUM_DEBUG_PARAM_REF. Otherwise a mismatched params pointer can result in memory corruption.
|
inline |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null |
arg | Argument to set. |
Will check params pointer matches the bound pointer if #CAELUM_DEBUG_PARAM_REF. Otherwise a mismatched params pointer can result in memory corruption.
|
inline |
Set the value.
No effect if !this->isBound()
params | Parameter pointer. Can't be null |
arg | Argument to set. |
Will check params pointer matches the bound pointer if #CAELUM_DEBUG_PARAM_REF. Otherwise a mismatched params pointer can result in memory corruption.