From André Garneau, threading bug fixes - moving scoped statics out of scope to be global statics
This commit is contained in:
@@ -26,10 +26,10 @@
|
||||
|
||||
using namespace osg;
|
||||
|
||||
static buffered_object< ref_ptr<FBOExtensions> > s_extensions;
|
||||
|
||||
FBOExtensions* FBOExtensions::instance(unsigned contextID, bool createIfNotInitalized)
|
||||
{
|
||||
static buffered_object< ref_ptr<FBOExtensions> > s_extensions;
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new FBOExtensions(contextID);
|
||||
return s_extensions[contextID].get();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,18 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
typedef std::set<std::string> ExtensionSet;
|
||||
static osg::buffered_object<ExtensionSet> s_glExtensionSetList;
|
||||
static osg::buffered_object<std::string> s_glRendererList;
|
||||
static osg::buffered_value<int> s_glInitializedList;
|
||||
|
||||
static osg::buffered_object<ExtensionSet> s_gluExtensionSetList;
|
||||
static osg::buffered_object<std::string> s_gluRendererList;
|
||||
static osg::buffered_value<int> s_gluInitializedList;
|
||||
|
||||
static const char* envVar = getenv("OSG_GL_EXTENSION_DISABLE");
|
||||
static std::string s_GLExtensionDisableString(envVar?envVar:"Nothing defined");
|
||||
|
||||
float osg::getGLVersionNumber()
|
||||
{
|
||||
// needs to be extended to do proper things with subversions like 1.5.1, etc.
|
||||
@@ -38,18 +50,13 @@ float osg::getGLVersionNumber()
|
||||
|
||||
bool osg::isGLExtensionSupported(unsigned int contextID, const char *extension)
|
||||
{
|
||||
typedef std::set<std::string> ExtensionSet;
|
||||
static osg::buffered_object<ExtensionSet> s_extensionSetList;
|
||||
static osg::buffered_object<std::string> s_rendererList;
|
||||
static osg::buffered_value<int> s_initializedList;
|
||||
|
||||
ExtensionSet& extensionSet = s_extensionSetList[contextID];
|
||||
std::string& rendererString = s_rendererList[contextID];
|
||||
ExtensionSet& extensionSet = s_glExtensionSetList[contextID];
|
||||
std::string& rendererString = s_glRendererList[contextID];
|
||||
|
||||
// if not already set up, initialize all the per graphic context values.
|
||||
if (!s_initializedList[contextID])
|
||||
if (!s_glInitializedList[contextID])
|
||||
{
|
||||
s_initializedList[contextID] = 1;
|
||||
s_glInitializedList[contextID] = 1;
|
||||
|
||||
// set up the renderer
|
||||
const GLubyte* renderer = glGetString(GL_RENDERER);
|
||||
@@ -194,26 +201,19 @@ void osg::setGLExtensionDisableString(const std::string& disableString)
|
||||
|
||||
std::string& osg::getGLExtensionDisableString()
|
||||
{
|
||||
static const char* envVar = getenv("OSG_GL_EXTENSION_DISABLE");
|
||||
static std::string s_GLExtensionDisableString(envVar?envVar:"Nothing defined");
|
||||
return s_GLExtensionDisableString;
|
||||
}
|
||||
|
||||
|
||||
bool osg::isGLUExtensionSupported(unsigned int contextID, const char *extension)
|
||||
{
|
||||
typedef std::set<std::string> ExtensionSet;
|
||||
static osg::buffered_object<ExtensionSet> s_extensionSetList;
|
||||
static osg::buffered_object<std::string> s_rendererList;
|
||||
static osg::buffered_value<int> s_initializedList;
|
||||
|
||||
ExtensionSet& extensionSet = s_extensionSetList[contextID];
|
||||
std::string& rendererString = s_rendererList[contextID];
|
||||
ExtensionSet& extensionSet = s_gluExtensionSetList[contextID];
|
||||
std::string& rendererString = s_gluRendererList[contextID];
|
||||
|
||||
// if not already set up, initialize all the per graphic context values.
|
||||
if (!s_initializedList[contextID])
|
||||
if (!s_gluInitializedList[contextID])
|
||||
{
|
||||
s_initializedList[contextID] = 1;
|
||||
s_gluInitializedList[contextID] = 1;
|
||||
|
||||
// set up the renderer
|
||||
const GLubyte* renderer = glGetString(GL_RENDERER);
|
||||
|
||||
@@ -45,21 +45,6 @@ using namespace osg;
|
||||
|
||||
ApplicationUsageProxy Texture_e0(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAX_TEXTURE_SIZE","Set the maximum size of textures.");
|
||||
|
||||
unsigned int Texture::s_numberTextureReusedLastInLastFrame = 0;
|
||||
unsigned int Texture::s_numberNewTextureInLastFrame = 0;
|
||||
unsigned int Texture::s_numberDeletedTextureInLastFrame = 0;
|
||||
|
||||
unsigned int s_minimumNumberOfTextureObjectsToRetainInCache = 0;
|
||||
void Texture::setMinimumNumberOfTextureObjectsToRetainInCache(unsigned int minimum)
|
||||
{
|
||||
s_minimumNumberOfTextureObjectsToRetainInCache = minimum;
|
||||
}
|
||||
|
||||
unsigned int Texture::getMinimumNumberOfTextureObjectsToRetainInCache()
|
||||
{
|
||||
return s_minimumNumberOfTextureObjectsToRetainInCache;
|
||||
}
|
||||
|
||||
class TextureObjectManager : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
@@ -130,6 +115,27 @@ public:
|
||||
OpenThreads::Mutex _mutex;
|
||||
};
|
||||
|
||||
unsigned int Texture::s_numberTextureReusedLastInLastFrame = 0;
|
||||
unsigned int Texture::s_numberNewTextureInLastFrame = 0;
|
||||
unsigned int Texture::s_numberDeletedTextureInLastFrame = 0;
|
||||
|
||||
unsigned int s_minimumNumberOfTextureObjectsToRetainInCache = 0;
|
||||
|
||||
typedef buffered_value< ref_ptr<Texture::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
static ref_ptr<TextureObjectManager> s_textureObjectManager = new TextureObjectManager;
|
||||
|
||||
void Texture::setMinimumNumberOfTextureObjectsToRetainInCache(unsigned int minimum)
|
||||
{
|
||||
s_minimumNumberOfTextureObjectsToRetainInCache = minimum;
|
||||
}
|
||||
|
||||
unsigned int Texture::getMinimumNumberOfTextureObjectsToRetainInCache()
|
||||
{
|
||||
return s_minimumNumberOfTextureObjectsToRetainInCache;
|
||||
}
|
||||
|
||||
Texture::TextureObject* TextureObjectManager::generateTextureObject(unsigned int /*contextID*/,GLenum target)
|
||||
{
|
||||
GLuint id;
|
||||
@@ -290,7 +296,6 @@ void TextureObjectManager::flushTextureObjects(unsigned int contextID,double cur
|
||||
|
||||
static TextureObjectManager* getTextureObjectManager()
|
||||
{
|
||||
static ref_ptr<TextureObjectManager> s_textureObjectManager = new TextureObjectManager;
|
||||
return s_textureObjectManager.get();
|
||||
}
|
||||
|
||||
@@ -1322,9 +1327,6 @@ void Texture::releaseGLObjects(State* state) const
|
||||
}
|
||||
}
|
||||
|
||||
typedef buffered_value< ref_ptr<Texture::Extensions> > BufferedExtensions;
|
||||
static BufferedExtensions s_extensions;
|
||||
|
||||
Texture::Extensions* Texture::getExtensions(unsigned int contextID,bool createIfNotInitalized)
|
||||
{
|
||||
if (!s_extensions[contextID] && createIfNotInitalized) s_extensions[contextID] = new Extensions(contextID);
|
||||
|
||||
Reference in New Issue
Block a user