21 #ifndef CAELUM__FAST_GPU_PARAM_REF_H 22 #define CAELUM__FAST_GPU_PARAM_REF_H 33 #define CAELUM_DEBUG_PARAM_REF OGRE_DEBUG_MODE 59 FastGpuParamRef(Ogre::GpuProgramParametersSharedPtr paramsPtr,
const Ogre::String& name);
72 Ogre::GpuProgramParametersSharedPtr paramsPtr,
73 const Ogre::String& name,
74 bool throwIfNotFound =
false);
84 inline bool isBound()
const {
return mPhysicalIndex != InvalidPhysicalIndex; }
98 template<
typename ArgumentT>
99 inline void doSet(
const Ogre::GpuProgramParametersSharedPtr& params, ArgumentT arg)
const {
100 #if CAELUM_DEBUG_PARAM_REF 101 assert(params.getPointer() == mParams.getPointer());
103 assert(!params.isNull());
104 if (mPhysicalIndex != InvalidPhysicalIndex) {
105 params->_writeRawConstant(mPhysicalIndex, arg);
109 template<
typename ArgumentT>
110 inline void doSet(
const Ogre::GpuProgramParametersSharedPtr& params, ArgumentT arg,
size_t count)
const {
111 #if CAELUM_DEBUG_PARAM_REF 112 assert(params.getPointer() == mParams.getPointer());
114 assert(!params.isNull());
115 if (mPhysicalIndex != InvalidPhysicalIndex) {
116 params->_writeRawConstant(mPhysicalIndex, arg, count);
122 inline void set(
const Ogre::GpuProgramParametersSharedPtr& params,
int val)
const { doSet<int>(params, val); }
124 inline void set(
const Ogre::GpuProgramParametersSharedPtr& params, Ogre::Real val)
const { doSet<Ogre::Real>(params, val); }
126 inline void set(
const Ogre::GpuProgramParametersSharedPtr& params,
const Ogre::Vector3& val)
const { doSet<const Ogre::Vector3&>(params, val); }
128 inline void set(
const Ogre::GpuProgramParametersSharedPtr& params,
const Ogre::Vector4& val)
const { doSet<const Ogre::Vector4&>(params, val); }
130 inline void set(
const Ogre::GpuProgramParametersSharedPtr& params,
const Ogre::ColourValue& val)
const { doSet<const Ogre::ColourValue&>(params, val); }
132 inline void set(
const Ogre::GpuProgramParametersSharedPtr& params,
const Ogre::Matrix4& val)
const { doSet<const Ogre::Matrix4*>(params, &val, 1); }
135 #if CAELUM_DEBUG_PARAM_REF 136 Ogre::GpuProgramParametersSharedPtr mParams;
138 static const size_t InvalidPhysicalIndex = 0xFFFFFFFF;
139 size_t mPhysicalIndex;
bool isBound() const
Return if this param ref is bound to an actual param.
FastGpuParamRef()
Default constructor. Starts as unbound.
An optimized reference to a gpu shared parameter.
size_t getPhysicalIndex() const
Return the physical index. Only valid if this->isBound().
void doSet(const Ogre::GpuProgramParametersSharedPtr ¶ms, ArgumentT arg) const
Set the value.