Updated to DatabasePager support

This commit is contained in:
Robert Osfield
2004-09-21 21:33:52 +00:00
parent 0d884d66eb
commit 54b45ce3bc
21 changed files with 404 additions and 219 deletions

View File

@@ -26,13 +26,12 @@
#include <map>
#include <list>
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Mutex>
#endif
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Mutex>
using namespace osg;
unsigned int Drawable::s_numberDrawablesReusedLastInLastFrame = 0;
unsigned int Drawable::s_numberNewDrawablesInLastFrame = 0;
unsigned int Drawable::s_numberDeletedDrawablesInLastFrame = 0;
@@ -42,43 +41,72 @@ unsigned int Drawable::s_numberDeletedDrawablesInLastFrame = 0;
typedef std::list<GLuint> DisplayListList;
typedef std::map<GLuint,DisplayListList> DeletedDisplayListCache;
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
static OpenThreads::Mutex s_mutex_deletedDisplayListCache;
#endif
static OpenThreads::Mutex s_mutex_deletedDisplayListCache;
static DeletedDisplayListCache s_deletedDisplayListCache;
GLuint Drawable::generateDisplayList(unsigned int contextID, unsigned int sizeHint)
GLuint Drawable::generateDisplayList(unsigned int contextID, unsigned int /*sizeHint*/)
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedDisplayListCache);
#endif
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedDisplayListCache);
DisplayListList& dll = s_deletedDisplayListCache[contextID];
if (dll.empty()) return glGenLists( 1 );
if (dll.empty())
{
++s_numberNewDrawablesInLastFrame;
return glGenLists( 1 );
}
else
{
notify(NOTICE)<<"reusing display list "<<std::endl;
++s_numberDrawablesReusedLastInLastFrame;
// notify(NOTICE)<<"reusing display list "<<std::endl;
GLuint globj = dll.back();
dll.pop_back();
return globj;
}
}
void Drawable::deleteDisplayList(unsigned int contextID,GLuint globj, unsigned int sizeHint)
unsigned int s_minimumNumberOfDisplayListsToRetainInCache = 0;
void Drawable::setMinimumNumberOfDisplayListsToRetainInCache(unsigned int minimum)
{
s_minimumNumberOfDisplayListsToRetainInCache = minimum;
}
unsigned int Drawable::getMinimumNumberOfDisplayListsToRetainInCache()
{
return s_minimumNumberOfDisplayListsToRetainInCache;
}
void Drawable::deleteDisplayList(unsigned int contextID,GLuint globj, unsigned int /*sizeHint*/)
{
if (globj!=0)
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedDisplayListCache);
#endif
// insert the globj into the cache for the appropriate context.
s_deletedDisplayListCache[contextID].push_back(globj);
}
}
/** flush all the cached display list which need to be deleted
* in the OpenGL context related to contextID.*/
void Drawable::flushDeletedDisplayLists(unsigned int contextID,double /*currentTime*/, double& availableTime)
void Drawable::flushAllDeletedDisplayLists(unsigned int contextID)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedDisplayListCache);
DeletedDisplayListCache::iterator citr = s_deletedDisplayListCache.find(contextID);
if (citr!=s_deletedDisplayListCache.end())
{
DisplayListList& dll = citr->second;
for(DisplayListList::iterator ditr=dll.begin();
ditr!=dll.end();
++ditr)
{
glDeleteLists(*ditr,1);
}
dll.clear();
}
}
void Drawable::flushDeletedDisplayLists(unsigned int contextID, double& availableTime)
{
// if no time available don't try to flush objects.
if (availableTime<=0.0) return;
@@ -90,17 +118,15 @@ void Drawable::flushDeletedDisplayLists(unsigned int contextID,double /*currentT
unsigned int noDeleted = 0;
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedDisplayListCache);
#endif
DeletedDisplayListCache::iterator citr = s_deletedDisplayListCache.find(contextID);
if (citr!=s_deletedDisplayListCache.end())
{
DisplayListList& dll = citr->second;
for(DisplayListList::iterator ditr=dll.begin();
ditr!=dll.end() && elapsedTime<availableTime;
ditr!=dll.end() && elapsedTime<availableTime && dll.size()>s_minimumNumberOfDisplayListsToRetainInCache;
)
{
glDeleteLists(*ditr,1);
@@ -114,24 +140,20 @@ void Drawable::flushDeletedDisplayLists(unsigned int contextID,double /*currentT
}
elapsedTime = timer.delta_s(start_tick,timer.tick());
if (noDeleted) notify(NOTICE)<<"Number display lists deleted = "<<noDeleted<<" elapsed time"<<elapsedTime<<std::endl;
// if (noDeleted) notify(NOTICE)<<"Number display lists deleted = "<<noDeleted<<" elapsed time"<<elapsedTime<<std::endl;
availableTime -= elapsedTime;
}
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
static OpenThreads::Mutex s_mutex_deletedVertexBufferObjectCache;
#endif
static OpenThreads::Mutex s_mutex_deletedVertexBufferObjectCache;
static DeletedDisplayListCache s_deletedVertexBufferObjectCache;
void Drawable::deleteVertexBufferObject(unsigned int contextID,GLuint globj)
{
if (globj!=0)
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexBufferObjectCache);
#endif
// insert the globj into the cache for the appropriate context.
s_deletedVertexBufferObjectCache[contextID].push_back(globj);
@@ -151,9 +173,7 @@ void Drawable::flushDeletedVertexBufferObjects(unsigned int contextID,double /*c
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexBufferObjectCache);
#endif
DeletedDisplayListCache::iterator citr = s_deletedVertexBufferObjectCache.find(contextID);
if (citr!=s_deletedVertexBufferObjectCache.end())
@@ -267,11 +287,11 @@ void Drawable::compileGLObjects(State& state) const
// call the globj if already set otherwise comple and execute.
if( globj != 0 )
{
{
glDeleteLists( globj, 1 );
}
globj = glGenLists( 1 );
globj = generateDisplayList(contextID, getGLObjectSizeHint());
glNewList( globj, GL_COMPILE );
if (_drawCallback.valid())

View File

@@ -18,10 +18,8 @@
#include <list>
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Mutex>
#endif
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Mutex>
using namespace osg;
@@ -31,18 +29,14 @@ using namespace osg;
typedef std::list<GLuint> FragmentProgramObjectList;
typedef std::map<unsigned int,FragmentProgramObjectList> DeletedFragmentProgramObjectCache;
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
static OpenThreads::Mutex s_mutex_deletedFragmentProgramObjectCache;
#endif
static OpenThreads::Mutex s_mutex_deletedFragmentProgramObjectCache;
static DeletedFragmentProgramObjectCache s_deletedFragmentProgramObjectCache;
void FragmentProgram::deleteFragmentProgramObject(unsigned int contextID,GLuint handle)
{
if (handle!=0)
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedFragmentProgramObjectCache);
#endif
// insert the handle into the cache for the appropriate context.
s_deletedFragmentProgramObjectCache[contextID].push_back(handle);
@@ -60,9 +54,7 @@ void FragmentProgram::flushDeletedFragmentProgramObjects(unsigned int contextID,
double elapsedTime = 0.0;
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedFragmentProgramObjectCache);
#endif
DeletedFragmentProgramObjectCache::iterator citr = s_deletedFragmentProgramObjectCache.find(contextID);
if (citr!=s_deletedFragmentProgramObjectCache.end())

View File

@@ -18,6 +18,9 @@
#include <osg/GLU>
#include <osg/Timer>
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Mutex>
using namespace osg;
#ifndef GL_TEXTURE_WRAP_R
@@ -41,7 +44,80 @@ unsigned int Texture::s_numberTextureReusedLastInLastFrame = 0;
unsigned int Texture::s_numberNewTextureInLastFrame = 0;
unsigned int Texture::s_numberDeletedTextureInLastFrame = 0;
Texture::TextureObject* Texture::TextureObjectManager::generateTextureObject(unsigned int /*contextID*/,GLenum target)
unsigned int s_minimumNumberOfTextureObjectsToRetainInCache = 0;
void Texture::setMinimumNumberOfTextureObjectsToRetainInCache(unsigned int minimum)
{
s_minimumNumberOfTextureObjectsToRetainInCache = minimum;
}
unsigned int Texture::getMinimumNumberOfTextureObjectsToRetainInCache()
{
return s_minimumNumberOfTextureObjectsToRetainInCache;
}
class SG_EXPORT TextureObjectManager : public osg::Referenced
{
public:
TextureObjectManager():
_expiryDelay(0.0) {}
virtual Texture::TextureObject* generateTextureObject(unsigned int contextID,GLenum target);
virtual Texture::TextureObject* generateTextureObject(unsigned int contextID,
GLenum target,
GLint numMipmapLevels,
GLenum internalFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border);
virtual Texture::TextureObject* reuseTextureObject(unsigned int contextID,
GLenum target,
GLint numMipmapLevels,
GLenum internalFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border);
inline Texture::TextureObject* reuseOrGenerateTextureObject(unsigned int contextID,
GLenum target,
GLint numMipmapLevels,
GLenum internalFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border)
{
Texture::TextureObject* to = reuseTextureObject(contextID,target,numMipmapLevels,internalFormat,width,height,depth,border);
if (to) return to;
else return generateTextureObject(contextID,target,numMipmapLevels,internalFormat,width,height,depth,border);
}
void addTextureObjects(Texture::TextureObjectListMap& toblm);
void addTextureObjectsFrom(Texture& texture);
void flushAllTextureObjects(unsigned int contextID);
void flushTextureObjects(unsigned int contextID,double currentTime, double& availableTime);
void setExpiryDelay(double expiryDelay) { _expiryDelay = expiryDelay; }
double getExpiryDelay() const { return _expiryDelay; }
/** How long to keep unused texture objects before deletion. */
double _expiryDelay;
Texture::TextureObjectListMap _textureObjectListMap;
// mutex to keep access serialized.
OpenThreads::Mutex _mutex;
};
Texture::TextureObject* TextureObjectManager::generateTextureObject(unsigned int /*contextID*/,GLenum target)
{
GLuint id;
glGenTextures( 1L, &id );
@@ -51,7 +127,7 @@ Texture::TextureObject* Texture::TextureObjectManager::generateTextureObject(uns
static int s_number = 0;
Texture::TextureObject* Texture::TextureObjectManager::generateTextureObject(unsigned int /*contextID*/,
Texture::TextureObject* TextureObjectManager::generateTextureObject(unsigned int /*contextID*/,
GLenum target,
GLint numMipmapLevels,
GLenum internalFormat,
@@ -61,7 +137,7 @@ Texture::TextureObject* Texture::TextureObjectManager::generateTextureObject(uns
GLint border)
{
++s_number;
++s_numberNewTextureInLastFrame;
++Texture::s_numberNewTextureInLastFrame;
// notify(NOTICE)<<"creating new texture object "<<s_number<<std::endl;
// no useable texture object found so return 0
@@ -71,7 +147,7 @@ Texture::TextureObject* Texture::TextureObjectManager::generateTextureObject(uns
return new Texture::TextureObject(id,target,numMipmapLevels,internalFormat,width,height,depth,border);
}
Texture::TextureObject* Texture::TextureObjectManager::reuseTextureObject(unsigned int contextID,
Texture::TextureObject* TextureObjectManager::reuseTextureObject(unsigned int contextID,
GLenum target,
GLint numMipmapLevels,
GLenum internalFormat,
@@ -80,12 +156,10 @@ Texture::TextureObject* Texture::TextureObjectManager::reuseTextureObject(unsign
GLsizei depth,
GLint border)
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
#endif
TextureObjectList& tol = _textureObjectListMap[contextID];
for(TextureObjectList::iterator itr = tol.begin();
Texture::TextureObjectList& tol = _textureObjectListMap[contextID];
for(Texture::TextureObjectList::iterator itr = tol.begin();
itr != tol.end();
++itr)
{
@@ -97,7 +171,7 @@ Texture::TextureObject* Texture::TextureObjectManager::reuseTextureObject(unsign
// notify(NOTICE)<<"reusing texture object "<<std::endl;
++s_numberTextureReusedLastInLastFrame;
++Texture::s_numberTextureReusedLastInLastFrame;
return textureObject;
}
@@ -108,31 +182,46 @@ Texture::TextureObject* Texture::TextureObjectManager::reuseTextureObject(unsign
void Texture::TextureObjectManager::addTextureObjects(Texture::TextureObjectListMap& toblm)
void TextureObjectManager::addTextureObjects(Texture::TextureObjectListMap& toblm)
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
#endif
for(TextureObjectListMap::iterator itr = toblm.begin();
for(Texture::TextureObjectListMap::iterator itr = toblm.begin();
itr != toblm.end();
++itr)
{
TextureObjectList& tol = _textureObjectListMap[itr->first];
Texture::TextureObjectList& tol = _textureObjectListMap[itr->first];
tol.insert(tol.end(),itr->second.begin(),itr->second.end());
}
}
void Texture::TextureObjectManager::addTextureObjectsFrom(Texture& texture)
void TextureObjectManager::addTextureObjectsFrom(Texture& texture)
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
#endif
texture.takeTextureObjects(_textureObjectListMap);
}
void Texture::TextureObjectManager::flushTextureObjects(unsigned int contextID,double currentTime, double& availableTime)
void TextureObjectManager::flushAllTextureObjects(unsigned int contextID)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
Texture::TextureObjectListMap::iterator tmitr = _textureObjectListMap.find(contextID);
if (tmitr!=_textureObjectListMap.end())
{
Texture::TextureObjectList& tol = tmitr->second;
for(Texture::TextureObjectList::iterator itr=tol.begin();
itr!=tol.end();
++itr)
{
glDeleteTextures( 1L, &((*itr)->_id));
}
tol.clear();
}
}
void TextureObjectManager::flushTextureObjects(unsigned int contextID,double currentTime, double& availableTime)
{
// if no time available don't try to flush objects.
if (availableTime<=0.0) return;
@@ -146,17 +235,15 @@ void Texture::TextureObjectManager::flushTextureObjects(unsigned int contextID,d
unsigned int numTexturesDeleted = 0;
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
#endif
TextureObjectListMap::iterator tmitr = _textureObjectListMap.find(contextID);
Texture::TextureObjectListMap::iterator tmitr = _textureObjectListMap.find(contextID);
if (tmitr!=_textureObjectListMap.end())
{
TextureObjectList& tol = tmitr->second;
Texture::TextureObjectList& tol = tmitr->second;
// reset the time of any uninitialized objects.
TextureObjectList::iterator itr;
Texture::TextureObjectList::iterator itr;
for(itr=tol.begin();
itr!=tol.end();
++itr)
@@ -167,13 +254,13 @@ void Texture::TextureObjectManager::flushTextureObjects(unsigned int contextID,d
double expiryTime = currentTime-_expiryDelay;
for(itr=tol.begin();
itr!=tol.end() && elapsedTime<availableTime && numObjectsDeleted<maxNumObjectsToDelete;
itr!=tol.end() && elapsedTime<availableTime && tol.size()>s_minimumNumberOfTextureObjectsToRetainInCache && numObjectsDeleted<maxNumObjectsToDelete;
)
{
if ((*itr)->_timeStamp<expiryTime)
{
--s_number;
++s_numberDeletedTextureInLastFrame;
++Texture::s_numberDeletedTextureInLastFrame;
glDeleteTextures( 1L, &((*itr)->_id));
itr = tol.erase(itr);
@@ -195,20 +282,45 @@ void Texture::TextureObjectManager::flushTextureObjects(unsigned int contextID,d
availableTime -= elapsedTime;
}
static ref_ptr<Texture::TextureObjectManager> s_textureObjectManager;
void Texture::setTextureObjectManager(Texture::TextureObjectManager* tom)
static TextureObjectManager* getTextureObjectManager()
{
s_textureObjectManager = tom;
}
Texture::TextureObjectManager* Texture::getTextureObjectManager()
{
if (!s_textureObjectManager) s_textureObjectManager = new Texture::TextureObjectManager;
static ref_ptr<TextureObjectManager> s_textureObjectManager;
if (!s_textureObjectManager) s_textureObjectManager = new TextureObjectManager;
return s_textureObjectManager.get();
}
void Texture::flushTextureObjects(unsigned int contextID,double currentTime, double& availbleTime)
Texture::TextureObject* Texture::generateTextureObject(unsigned int contextID,GLenum target)
{
return getTextureObjectManager()->generateTextureObject(contextID,target);
}
Texture::TextureObject* Texture::generateTextureObject(unsigned int contextID,
GLenum target,
GLint numMipmapLevels,
GLenum internalFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border)
{
return getTextureObjectManager()->reuseOrGenerateTextureObject(contextID,
target,
numMipmapLevels,
internalFormat,
width,
height,
depth,
border);
}
void Texture::flushAllDeletedTextureObjects(unsigned int contextID)
{
getTextureObjectManager()->flushAllTextureObjects(contextID);
}
void Texture::flushDeletedTextureObjects(unsigned int contextID,double currentTime, double& availbleTime)
{
getTextureObjectManager()->flushTextureObjects(contextID, currentTime, availbleTime);
}
@@ -1097,9 +1209,7 @@ void Texture::releaseGLObjects(State* state) const
unsigned int contextID = state->getContextID();
if (_textureObjectBuffer[contextID].valid())
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(getTextureObjectManager()->_mutex);
#endif
getTextureObjectManager()->_textureObjectListMap[contextID].push_back(_textureObjectBuffer[contextID]);
_textureObjectBuffer[contextID] = 0;

View File

@@ -118,7 +118,7 @@ void Texture1D::apply(State& state) const
{
// we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object.
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_1D);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_1D);
textureObject->bind();
@@ -139,7 +139,7 @@ void Texture1D::apply(State& state) const
{
// we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object.
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_1D);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_1D);
textureObject->bind();
@@ -310,7 +310,7 @@ void Texture1D::copyTexImage1D(State& state, int x, int y, int width)
_min_filter = LINEAR;
_mag_filter = LINEAR;
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_1D);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_1D);
textureObject->bind();

View File

@@ -134,7 +134,7 @@ void Texture2D::apply(State& state) const
else if (_subloadCallback.valid())
{
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_2D);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_2D);
textureObject->bind();
@@ -161,7 +161,7 @@ void Texture2D::apply(State& state) const
computeRequiredTextureDimensions(state,*_image,_textureWidth, _textureHeight, _numMipmapLevels);
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->reuseOrGenerateTextureObject(
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(
contextID,GL_TEXTURE_2D,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0);
textureObject->bind();
@@ -251,7 +251,7 @@ void Texture2D::copyTexImage2D(State& state, int x, int y, int width, int height
_min_filter = LINEAR;
_mag_filter = LINEAR;
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_2D);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_2D);
textureObject->bind();

View File

@@ -135,7 +135,7 @@ void Texture3D::apply(State& state) const
else if (_subloadCallback.valid())
{
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_3D);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_3D);
textureObject->bind();
@@ -155,7 +155,7 @@ void Texture3D::apply(State& state) const
else if (_image.valid() && _image->data())
{
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_3D);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_3D);
textureObject->bind();

View File

@@ -234,7 +234,7 @@ void TextureCubeMap::apply(State& state) const
}
else if (_subloadCallback.valid())
{
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_CUBE_MAP);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_CUBE_MAP);
textureObject->bind();
@@ -258,7 +258,7 @@ void TextureCubeMap::apply(State& state) const
// compute the dimensions of the texture.
computeRequiredTextureDimensions(state,*_images[0],_textureWidth, _textureHeight, _numMipmapLevels);
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->reuseOrGenerateTextureObject(
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(
contextID,GL_TEXTURE_CUBE_MAP,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0);
textureObject->bind();

View File

@@ -154,7 +154,7 @@ void TextureRectangle::apply(State& state) const
else if (_subloadCallback.valid())
{
// we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object.
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_RECTANGLE);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_RECTANGLE);
textureObject->bind();
@@ -173,7 +173,7 @@ void TextureRectangle::apply(State& state) const
else if (_image.valid() && _image->data())
{
// we don't have a applyTexImage1D_subload yet so can't reuse.. so just generate a new texture object.
_textureObjectBuffer[contextID] = textureObject = getTextureObjectManager()->generateTextureObject(contextID,GL_TEXTURE_RECTANGLE);
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(contextID,GL_TEXTURE_RECTANGLE);
textureObject->bind();

View File

@@ -18,10 +18,8 @@
#include <list>
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Mutex>
#endif
#include <OpenThreads/ScopedLock>
#include <OpenThreads/Mutex>
using namespace osg;
@@ -31,18 +29,14 @@ using namespace osg;
typedef std::list<GLuint> VertexProgramObjectList;
typedef std::map<unsigned int,VertexProgramObjectList> DeletedVertexProgramObjectCache;
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
static OpenThreads::Mutex s_mutex_deletedVertexProgramObjectCache;
#endif
static OpenThreads::Mutex s_mutex_deletedVertexProgramObjectCache;
static DeletedVertexProgramObjectCache s_deletedVertexProgramObjectCache;
void VertexProgram::deleteVertexProgramObject(unsigned int contextID,GLuint handle)
{
if (handle!=0)
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexProgramObjectCache);
#endif
// insert the handle into the cache for the appropriate context.
s_deletedVertexProgramObjectCache[contextID].push_back(handle);
@@ -60,9 +54,7 @@ void VertexProgram::flushDeletedVertexProgramObjects(unsigned int contextID,doub
double elapsedTime = 0.0;
{
#ifdef THREAD_SAFE_GLOBJECT_DELETE_LISTS
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexProgramObjectCache);
#endif
DeletedVertexProgramObjectCache::iterator citr = s_deletedVertexProgramObjectCache.find(contextID);
if (citr!=s_deletedVertexProgramObjectCache.end())