Added handling of resetting of the texture object format
This commit is contained in:
@@ -975,16 +975,12 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
|
||||
inline void setAllocated(bool allocated=true) { _allocated = allocated; }
|
||||
|
||||
inline void setAllocated(GLint numMipmapLevels,
|
||||
void setAllocated(GLint numMipmapLevels,
|
||||
GLenum internalFormat,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
GLsizei depth,
|
||||
GLint border)
|
||||
{
|
||||
_allocated=true;
|
||||
_profile.set(numMipmapLevels,internalFormat,width,height,depth,border);
|
||||
}
|
||||
GLint border);
|
||||
|
||||
inline bool isAllocated() const { return _allocated; }
|
||||
|
||||
@@ -1019,12 +1015,16 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
void moveToBack(TextureObject* to);
|
||||
void addToBack(TextureObject* to);
|
||||
void orphan(TextureObject* to);
|
||||
void remove(TextureObject* to);
|
||||
|
||||
unsigned int size() const { return _profile._size * _numOfTextureObjects; }
|
||||
|
||||
bool makeSpace(unsigned int& size);
|
||||
|
||||
bool checkConsistency() const;
|
||||
|
||||
TextureObjectManager* getParent() { return _parent; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~TextureObjectSet();
|
||||
@@ -1085,6 +1085,7 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
void flushDeletedTextureObjects(double currentTime, double& availableTime);
|
||||
void releaseTextureObject(TextureObject* to);
|
||||
|
||||
TextureObjectSet* getTextureObjectSet(const TextureProfile& profile);
|
||||
|
||||
void newFrame(osg::FrameStamp* fs);
|
||||
void resetStats();
|
||||
|
||||
@@ -76,6 +76,32 @@ void Texture::TextureObject::bind()
|
||||
if (_set) _set->moveToBack(this);
|
||||
}
|
||||
|
||||
void Texture::TextureObject::setAllocated(GLint numMipmapLevels,
|
||||
GLenum internalFormat,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
GLsizei depth,
|
||||
GLint border)
|
||||
{
|
||||
_allocated=true;
|
||||
if (!match(_profile._target,numMipmapLevels,internalFormat,width,height,depth,border))
|
||||
{
|
||||
_profile.set(numMipmapLevels,internalFormat,width,height,depth,border);
|
||||
|
||||
if (_set)
|
||||
{
|
||||
// remove self from original set
|
||||
_set->remove(this);
|
||||
|
||||
// get the new set for the new profile
|
||||
_set = _set->getParent()->getTextureObjectSet(_profile);
|
||||
|
||||
// register self with new set.
|
||||
_set->addToBack(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::TextureProfile::computeSize()
|
||||
{
|
||||
unsigned int numBitsPerTexel = 32;
|
||||
@@ -209,29 +235,7 @@ void Texture::TextureObjectSet::handlePendingOrphandedTextureObjects()
|
||||
|
||||
_orphanedTextureObjects.push_back(to);
|
||||
|
||||
if (to->_previous!=0)
|
||||
{
|
||||
(to->_previous)->_next = to->_next;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 'to' was head so assign _head to the next in list
|
||||
_head = to->_next;
|
||||
}
|
||||
|
||||
if (to->_next!=0)
|
||||
{
|
||||
(to->_next)->_previous = to->_previous;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 'to' was tail so assing tail to the previous in list
|
||||
_tail = to->_previous;
|
||||
}
|
||||
|
||||
// reset the 'to' list pointers as it's no longer in the active list.
|
||||
to->_next = 0;
|
||||
to->_previous = 0;
|
||||
remove(to);
|
||||
|
||||
#if 0
|
||||
osg::notify(osg::NOTICE)<<" HPOTO after _head = "<<_head<<std::endl;
|
||||
@@ -571,6 +575,34 @@ void Texture::TextureObjectSet::orphan(Texture::TextureObject* to)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::TextureObjectSet::remove(Texture::TextureObject* to)
|
||||
{
|
||||
if (to->_previous!=0)
|
||||
{
|
||||
(to->_previous)->_next = to->_next;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 'to' was head so assign _head to the next in list
|
||||
_head = to->_next;
|
||||
}
|
||||
|
||||
if (to->_next!=0)
|
||||
{
|
||||
(to->_next)->_previous = to->_previous;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 'to' was tail so assing tail to the previous in list
|
||||
_tail = to->_previous;
|
||||
}
|
||||
|
||||
// reset the 'to' list pointers as it's no longer in the active list.
|
||||
to->_next = 0;
|
||||
to->_previous = 0;
|
||||
}
|
||||
|
||||
|
||||
Texture::TextureObjectManager::TextureObjectManager(unsigned int contextID):
|
||||
_contextID(contextID),
|
||||
_numActiveTextureObjects(0),
|
||||
@@ -631,9 +663,15 @@ Texture::TextureObject* Texture::TextureObjectManager::generateTextureObject(con
|
||||
++getNumberGenerated();
|
||||
|
||||
Texture::TextureProfile profile(target,numMipmapLevels,internalFormat,width,height,depth,border);
|
||||
TextureObjectSet* tos = getTextureObjectSet(profile);
|
||||
return tos->takeOrGenerate(const_cast<Texture*>(texture));
|
||||
}
|
||||
|
||||
Texture::TextureObjectSet* Texture::TextureObjectManager::getTextureObjectSet(const TextureProfile& profile)
|
||||
{
|
||||
osg::ref_ptr<Texture::TextureObjectSet>& tos = _textureSetMap[profile];
|
||||
if (!tos) tos = new Texture::TextureObjectSet(this, profile);
|
||||
return tos->takeOrGenerate(const_cast<Texture*>(texture));
|
||||
return tos.get();
|
||||
}
|
||||
|
||||
void Texture::TextureObjectManager::handlePendingOrphandedTextureObjects()
|
||||
|
||||
@@ -885,6 +885,11 @@ BEGIN_OBJECT_REFLECTOR(osg::Texture::TextureObjectManager)
|
||||
__void__releaseTextureObject__TextureObject_P1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(osg::Texture::TextureObjectSet *, getTextureObjectSet, IN, const osg::Texture::TextureProfile &, profile,
|
||||
Properties::NON_VIRTUAL,
|
||||
__TextureObjectSet_P1__getTextureObjectSet__C5_TextureProfile_R1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(void, newFrame, IN, osg::FrameStamp *, fs,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__newFrame__osg_FrameStamp_P1,
|
||||
@@ -1033,6 +1038,11 @@ BEGIN_OBJECT_REFLECTOR(osg::Texture::TextureObjectSet)
|
||||
__void__orphan__TextureObject_P1,
|
||||
"",
|
||||
"");
|
||||
I_Method1(void, remove, IN, osg::Texture::TextureObject *, to,
|
||||
Properties::NON_VIRTUAL,
|
||||
__void__remove__TextureObject_P1,
|
||||
"",
|
||||
"");
|
||||
I_Method0(unsigned int, size,
|
||||
Properties::NON_VIRTUAL,
|
||||
__unsigned_int__size,
|
||||
@@ -1048,6 +1058,14 @@ BEGIN_OBJECT_REFLECTOR(osg::Texture::TextureObjectSet)
|
||||
__bool__checkConsistency,
|
||||
"",
|
||||
"");
|
||||
I_Method0(osg::Texture::TextureObjectManager *, getParent,
|
||||
Properties::NON_VIRTUAL,
|
||||
__TextureObjectManager_P1__getParent,
|
||||
"",
|
||||
"");
|
||||
I_SimpleProperty(osg::Texture::TextureObjectManager *, Parent,
|
||||
__TextureObjectManager_P1__getParent,
|
||||
0);
|
||||
END_REFLECTOR
|
||||
|
||||
BEGIN_VALUE_REFLECTOR(osg::Texture::TextureProfile)
|
||||
|
||||
Reference in New Issue
Block a user