Implementated new dirty buffer mechansim for BufferObjects to make it more efficient
This commit is contained in:
@@ -108,7 +108,7 @@ class OSG_EXPORT Array : public Object
|
||||
virtual void trim() {}
|
||||
|
||||
/** Dirty the primitive, which increments the modified count, to force buffer objects to update. */
|
||||
inline void dirty() { ++_modifiedCount; }
|
||||
inline void dirty() { ++_modifiedCount; if (_vbo.valid()) _vbo->dirty(); }
|
||||
|
||||
/** Set the modified count value.*/
|
||||
inline void setModifiedCount(unsigned int value) { _modifiedCount=value; }
|
||||
|
||||
@@ -122,9 +122,18 @@ class OSG_EXPORT BufferObject : public Object
|
||||
extensions->glBindBuffer(_target,0);
|
||||
}
|
||||
|
||||
inline void dirty() { _compiledList.setAllElementsTo(0); }
|
||||
|
||||
bool isDirty(unsigned int contextID) const { return _compiledList[contextID]==0; }
|
||||
|
||||
virtual bool needsCompile(unsigned int contextID) const = 0;
|
||||
|
||||
virtual void compileBuffer(State& state) const = 0;
|
||||
inline void compileBuffer(unsigned int contextID, State& state) const
|
||||
{
|
||||
if (isDirty(contextID)) compileBufferImplementation(state);
|
||||
}
|
||||
|
||||
virtual void compileBufferImplementation(State& state) const = 0;
|
||||
|
||||
void releaseBuffer(State* state) const;
|
||||
|
||||
@@ -215,8 +224,10 @@ class OSG_EXPORT BufferObject : public Object
|
||||
virtual ~BufferObject();
|
||||
|
||||
typedef osg::buffered_value<GLuint> GLObjectList;
|
||||
typedef osg::buffered_value<unsigned int> CompiledList;
|
||||
|
||||
mutable GLObjectList _bufferObjectList;
|
||||
mutable CompiledList _compiledList;
|
||||
|
||||
GLenum _target;
|
||||
GLenum _usage;
|
||||
@@ -248,7 +259,7 @@ class OSG_EXPORT VertexBufferObject : public BufferObject
|
||||
|
||||
virtual bool needsCompile(unsigned int contextID) const;
|
||||
|
||||
virtual void compileBuffer(State& state) const;
|
||||
virtual void compileBufferImplementation(State& state) const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -282,7 +293,7 @@ class OSG_EXPORT ElementsBufferObject : public BufferObject
|
||||
|
||||
virtual bool needsCompile(unsigned int contextID) const;
|
||||
|
||||
virtual void compileBuffer(State& state) const;
|
||||
virtual void compileBufferImplementation(State& state) const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -314,7 +325,7 @@ class OSG_EXPORT PixelBufferObject : public BufferObject
|
||||
|
||||
virtual bool needsCompile(unsigned int contextID) const;
|
||||
|
||||
virtual void compileBuffer(State& state) const;
|
||||
virtual void compileBufferImplementation(State& state) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ class OSG_EXPORT Image : public Object
|
||||
void ensureValidSizeForTexturing(GLint maxTextureSize);
|
||||
|
||||
/** Dirty the image, which increments the modified count, to force osg::Texture to reload the image. */
|
||||
inline void dirty() { ++_modifiedCount; }
|
||||
inline void dirty() { ++_modifiedCount; if (_bufferObject.valid()) _bufferObject->dirty(); }
|
||||
|
||||
/** Set the modified count value. Used by osg::Texture when using texture subloading. */
|
||||
inline void setModifiedCount(unsigned int value) { _modifiedCount=value; }
|
||||
|
||||
@@ -241,7 +241,7 @@ class OSG_EXPORT PrimitiveSet : public Object
|
||||
virtual unsigned int getNumPrimitives() const;
|
||||
|
||||
/** Dirty the primitive, which increments the modified count, to force buffer objects to update. */
|
||||
inline void dirty() { ++_modifiedCount; }
|
||||
virtual void dirty() { ++_modifiedCount; }
|
||||
|
||||
/** Set the modified count value.*/
|
||||
inline void setModifiedCount(unsigned int value) { _modifiedCount=value; }
|
||||
@@ -423,6 +423,8 @@ class DrawElements : public PrimitiveSet
|
||||
virtual DrawElements* getDrawElements() { return this; }
|
||||
virtual const DrawElements* getDrawElements() const { return this; }
|
||||
|
||||
virtual void dirty() { ++_modifiedCount; if (_ebo.valid()) _ebo->dirty(); }
|
||||
|
||||
/** Set the ElementsBufferObject.*/
|
||||
inline void setElementsBufferObject(osg::ElementsBufferObject* ebo)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user