Various improvements to database paing.

This commit is contained in:
Robert Osfield
2004-09-21 17:26:08 +00:00
parent eea9ddccf5
commit 0d884d66eb
14 changed files with 330 additions and 77 deletions

View File

@@ -22,6 +22,7 @@
namespace osg {
class Vec2f;
class Vec3f;
class Vec4f;
@@ -115,6 +116,9 @@ class SG_EXPORT Drawable : public Object
{
public:
static unsigned int s_numberNewDrawablesInLastFrame;
static unsigned int s_numberDeletedDrawablesInLastFrame;
Drawable();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
@@ -230,7 +234,7 @@ class SG_EXPORT Drawable : public Object
inline bool getUseDisplayList() const { return _useDisplayList; }
/** When set to true, ignore the setUseDisplayList() settings, and hints to the drawImplementation
method to use OpenGL vertex buffer objects for rendering..*/
method to use OpenGL vertex buffer objects for rendering.*/
void setUseVertexBufferObjects(bool flag);
/** Return whether OpenGL vertex buffer objects should be used when supported by OpenGL driver.*/
@@ -241,6 +245,11 @@ class SG_EXPORT Drawable : public Object
void dirtyDisplayList();
/** Return the estimated size of GLObjects (display lists/vertex buffer objects) that are associated with this drawable.
* This size is used a hint for reuse of deleteed display lists/vertex buffer objects. */
virtual unsigned int getGLObjectSizeHint() const { return 0; }
/** draw OpenGL primitives.
* If the drawable has _useDisplayList set to true then use an OpenGL display
@@ -343,12 +352,13 @@ class SG_EXPORT Drawable : public Object
virtual void drawImplementation(State& state) const = 0;
static GLuint generateDisplayList(unsigned int contextID, unsigned int sizeHint = 0);
/** use deleteDisplayList instead of glDeleteList to allow
* OpenGL display list to be cached until they can be deleted
* by the OpenGL context in which they were created, specified
* by contextID.*/
static void deleteDisplayList(unsigned int contextID,GLuint globj);
static void deleteDisplayList(unsigned int contextID,GLuint globj, unsigned int sizeHint = 0);
/** flush all the cached display list which need to be deleted
* in the OpenGL context related to contextID.*/
@@ -754,7 +764,7 @@ inline void Drawable::draw(State& state) const
else if (_useDisplayList)
{
#ifdef USE_SEPARATE_COMPILE_AND_EXECUTE
globj = glGenLists( 1 );
globj = generateDisplayList(contextID, getGLObjectSizeHint()); // glGenLists( 1 );
glNewList( globj, GL_COMPILE );
if (_drawCallback.valid())
_drawCallback->drawImplementation(state,this);
@@ -764,7 +774,7 @@ inline void Drawable::draw(State& state) const
glCallList( globj);
#else
globj = glGenLists( 1 );
globj = generateDisplayList(contextID, getGLObjectSizeHint()); // glGenLists( 1 );
glNewList( globj, GL_COMPILE_AND_EXECUTE );
if (_drawCallback.valid())
_drawCallback->drawImplementation(state,this);

View File

@@ -330,6 +330,10 @@ class SG_EXPORT Geometry : public Drawable
const osg::Geometry* getInternalOptimizedGeometry() const { return _internalOptimizedGeometry.get(); }
/** Return the estimated size of GLObjects (display lists/vertex buffer objects) that are associated with this drawable.
* This size is used a hint for reuse of deleteed display lists/vertex buffer objects. */
virtual unsigned int getGLObjectSizeHint() const;
/** Draw Geometry directly ignoring an OpenGL display list which could be attached.
* This is the internal draw method which does the drawing itself,
* and is the method to override when deriving from Geometry for user-drawn objects.

View File

@@ -71,7 +71,7 @@ class SG_EXPORT Group : public Node
/** Replace specified Node with another Node.
* Equivalent to setChild(getChildIndex(orignChild),node)
* See docs for setChild for futher details on implementation.
*/
*/
virtual bool replaceChild( Node *origChild, Node* newChild );
/** Return the number of chilren nodes. */

View File

@@ -77,6 +77,15 @@ class SG_EXPORT PagedLOD : public LOD
unsigned int getNumTimeStamps() const { return _perRangeDataList.size(); }
/** Set the frame number of the last time that this PageLOD node was traversed.
* Note, this frame number is automatically set by the traverse() method for all traversals (update, cull etc.).
*/
inline void setFrameNumberOfLastTraversal(int frameNumber) { _frameNumberOfLastTraversal=frameNumber; }
/** Get the frame number of the last time that this PageLOD node was traversed.*/
inline int getFrameNumberOfLastTraversal() const { return _frameNumberOfLastTraversal; }
/** Set the number of children that the PagedLOD must keep around, even if they are older than their expiry time.*/
inline void setNumChildrenThatCannotBeExpired(unsigned int num) { _numChildrenThatCannotBeExpired = num; }
@@ -84,9 +93,12 @@ class SG_EXPORT PagedLOD : public LOD
unsigned int getNumChildrenThatCannotBeExpired() const { return _numChildrenThatCannotBeExpired; }
/** Remove the children from the PagedLOD which haven't been visited since specified expiry time.
The removed children are added to the removeChildren list passed into the method,
this allows the children to be deleted later at the caller's discretion.*/
virtual void removeExpiredChildren(double expiryTime,NodeList& removedChildren);
* The removed children are added to the removeChildren list passed into the method,
* this allows the children to be deleted later at the caller's discretion.
* Return true if children are removed, false otherwise. */
bool removeExpiredChildren(double expiryTime,NodeList& removedChildren);
protected :
@@ -100,8 +112,8 @@ class SG_EXPORT PagedLOD : public LOD
void expandPerRangeDataTo(unsigned int pos);
unsigned int _numChildrenThatCannotBeExpired;
int _frameNumberOfLastTraversal;
unsigned int _numChildrenThatCannotBeExpired;
PerRangeDataList _perRangeDataList;
};

View File

@@ -333,7 +333,7 @@ class SG_EXPORT DrawElementsUByte : public PrimitiveSet, public VectorUByte
typedef osg::buffered_value<GLuint> GLObjectList;
mutable GLObjectList _vboList;
virtual ~DrawElementsUByte() {}
virtual ~DrawElementsUByte();
};
@@ -381,7 +381,7 @@ class SG_EXPORT DrawElementsUShort : public PrimitiveSet, public VectorUShort
typedef osg::buffered_value<GLuint> GLObjectList;
mutable GLObjectList _vboList;
virtual ~DrawElementsUShort() {}
virtual ~DrawElementsUShort();
};
class SG_EXPORT DrawElementsUInt : public PrimitiveSet, public VectorUInt
@@ -425,10 +425,10 @@ class SG_EXPORT DrawElementsUInt : public PrimitiveSet, public VectorUInt
protected:
virtual ~DrawElementsUInt();
typedef osg::buffered_value<GLuint> GLObjectList;
mutable GLObjectList _vboList;
virtual ~DrawElementsUInt() {}
};
}

View File

@@ -162,6 +162,7 @@
namespace osg {
/** Texture pure virtual base class that encapsulates OpenGl texture
* functionality common to the various types of OSG textures.
*/
@@ -170,6 +171,10 @@ class SG_EXPORT Texture : public osg::StateAttribute
public :
static unsigned int s_numberTextureReusedLastInLastFrame;
static unsigned int s_numberNewTextureInLastFrame;
static unsigned int s_numberDeletedTextureInLastFrame;
Texture();
/** Copy constructor using CopyOp to manage deep vs shallow copy. */

View File

@@ -28,7 +28,7 @@
#include <osgDB/Export>
#include <map>
#include <set>
#include <list>
namespace osgDB {
@@ -211,7 +211,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
public:
typedef std::set< osg::ref_ptr<osg::PagedLOD> > PagedLODList;
typedef std::list< osg::ref_ptr<osg::PagedLOD> > PagedLODList;
typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetList;
typedef std::vector< osg::ref_ptr<osg::Drawable> > DrawableList;
@@ -288,7 +288,8 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
OpenThreads::Mutex _dataToMergeListMutex;
PagedLODList _pagedLODList;
PagedLODList _activePagedLODList;
PagedLODList _inactivePagedLODList;
double _expiryDelay;