const char* gStdAttribs[ Program::ATTRIB_TYPE_LAST ] =
{
"aPosition", // ATTRIB_POSITION
- "aNormal", // ATTRIB_NORMAL
"aTexCoord", // ATTRIB_TEXCOORD
- "aColor", // ATTRIB_COLOR
- "aBoneWeights", // ATTRIB_BONE_WEIGHTS
- "aBoneIndices" // ATTRIB_BONE_INDICES
};
const char* gStdUniforms[ Program::UNIFORM_TYPE_LAST ] =
return;
}
- // Not caching these as based on current analysis this is not called that often by our shaders
- LOG_GL( "Uniform2f(%d,%f,%f)\n", location, value0, value1 );
- CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform2f( location, value0, value1 ) );
+ // check if uniform location fits the cache
+ if( location >= MAX_UNIFORM_CACHE_SIZE )
+ {
+ // not cached, make the gl call
+ LOG_GL( "Uniform2f(%d,%f,%f)\n", location, value0, value1 );
+ CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform2f( location, value0, value1 ) );
+ }
+ else
+ {
+ // check if the same value has already been set, reset if it is different
+ if( ( fabsf(value0 - mUniformCacheFloat2[ location ][ 0 ]) >= Math::MACHINE_EPSILON_1 )||
+ ( fabsf(value1 - mUniformCacheFloat2[ location ][ 1 ]) >= Math::MACHINE_EPSILON_1 ) )
+ {
+ // make the gl call
+ LOG_GL( "Uniform2f(%d,%f,%f)\n", location, value0, value1 );
+ CHECK_GL( mGlAbstraction, mGlAbstraction.Uniform2f( location, value0, value1 ) );
+
+ // update cache
+ mUniformCacheFloat2[ location ][ 0 ] = value0;
+ mUniformCacheFloat2[ location ][ 1 ] = value1;
+ }
+ }
}
void Program::SetSizeUniform3f( GLint location, GLfloat value0, GLfloat value1, GLfloat value2 )
// GL initializes uniforms to 0
mUniformCacheInt[ i ] = 0;
mUniformCacheFloat[ i ] = 0.0f;
+ mUniformCacheFloat2[ i ][ 0 ] = 0.0f;
+ mUniformCacheFloat2[ i ][ 1 ] = 0.0f;
mUniformCacheFloat4[ i ][ 0 ] = 0.0f;
mUniformCacheFloat4[ i ][ 1 ] = 0.0f;
mUniformCacheFloat4[ i ][ 2 ] = 0.0f;
{
ATTRIB_UNKNOWN = -1,
ATTRIB_POSITION,
- ATTRIB_NORMAL,
ATTRIB_TEXCOORD,
- ATTRIB_COLOR,
- ATTRIB_BONE_WEIGHTS,
- ATTRIB_BONE_INDICES,
ATTRIB_TYPE_LAST
};
// uniform value caching
GLint mUniformCacheInt[ MAX_UNIFORM_CACHE_SIZE ]; ///< Value cache for uniforms of single int
GLfloat mUniformCacheFloat[ MAX_UNIFORM_CACHE_SIZE ]; ///< Value cache for uniforms of single float
- GLfloat mUniformCacheFloat4[ MAX_UNIFORM_CACHE_SIZE ][4]; ///< Value cache for uniforms of four float
+ GLfloat mUniformCacheFloat2[ MAX_UNIFORM_CACHE_SIZE ][2]; ///< Value cache for uniforms of two floats
+ GLfloat mUniformCacheFloat4[ MAX_UNIFORM_CACHE_SIZE ][4]; ///< Value cache for uniforms of four floats
Vector3 mSizeUniformCache; ///< Cache value for size uniform
bool mModifiesGeometry; ///< True if the program changes geometry