From Michael Platings, To address performance bottleneck that occurs when using large number of uniforms introduced a name to uniqued ID scheme for Uniforms so comparisons can be done on a uint rather than a string.

This commit is contained in:
Robert Osfield
2010-11-25 12:30:38 +00:00
parent 4b4e02e45b
commit cdfbb7a753
5 changed files with 48 additions and 14 deletions

View File

@@ -268,6 +268,9 @@ class OSG_EXPORT Uniform : public Object
/** Return the internal data array type corresponding to a GLSL type */
static GLenum getInternalArrayType( Type t );
/** Return the number that the name maps to uniquely */
static unsigned int getNameID(const std::string& name);
/** convenient scalar (non-array) constructors w/ assignment */
explicit Uniform( const char* name, float f );
explicit Uniform( const char* name, int i );
@@ -472,6 +475,8 @@ class OSG_EXPORT Uniform : public Object
inline void setModifiedCount(unsigned int mc) { _modifiedCount = mc; }
inline unsigned int getModifiedCount() const { return _modifiedCount; }
/** Get the number that the Uniform's name maps to uniquely */
unsigned int getNameID() const;
void apply(const GL2Extensions* ext, GLint location) const;
@@ -493,6 +498,8 @@ class OSG_EXPORT Uniform : public Object
Type _type;
unsigned int _numElements;
unsigned int _nameID;
// The internal data for osg::Uniforms are stored as an array of
// getInternalArrayType() of length getInternalArrayNumElements().