Merge with kaetemi-optimize

This commit is contained in:
kaetemi 2013-07-29 03:41:31 +02:00
commit 1d6e047edd
3 changed files with 20 additions and 5 deletions

View file

@ -1488,7 +1488,10 @@ void CDriverGL::enableUsedTextureMemorySum (bool enable)
H_AUTO_OGL(CDriverGL_enableUsedTextureMemorySum ) H_AUTO_OGL(CDriverGL_enableUsedTextureMemorySum )
if (enable) if (enable)
{
nlinfo ("3D: PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverGL"); nlinfo ("3D: PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverGL");
_TextureUsed.reserve(512);
}
_SumTextureMemoryUsed=enable; _SumTextureMemoryUsed=enable;
} }
@ -1502,7 +1505,7 @@ uint32 CDriverGL::getUsedTextureMemory() const
uint32 memory=0; uint32 memory=0;
// For each texture used // For each texture used
set<CTextureDrvInfosGL*>::const_iterator ite=_TextureUsed.begin(); std::vector<CTextureDrvInfosGL *>::const_iterator ite = _TextureUsed.begin();
while (ite!=_TextureUsed.end()) while (ite!=_TextureUsed.end())
{ {
// Get the gl texture // Get the gl texture
@ -1510,7 +1513,8 @@ uint32 CDriverGL::getUsedTextureMemory() const
gltext= (*ite); gltext= (*ite);
// Sum the memory used by this texture // Sum the memory used by this texture
memory+=gltext->TextureMemory; if (gltext)
memory+=gltext->TextureMemory;
// Next texture // Next texture
ite++; ite++;

View file

@ -196,6 +196,8 @@ public:
bool initFrameBufferObject(ITexture * tex); bool initFrameBufferObject(ITexture * tex);
bool activeFrameBufferObject(ITexture * tex); bool activeFrameBufferObject(ITexture * tex);
std::vector<CTextureDrvInfosGL *>::size_type TextureUsedIdx;
}; };
@ -1273,7 +1275,7 @@ private:
uint32 _NbSetupMaterialCall; uint32 _NbSetupMaterialCall;
uint32 _NbSetupModelMatrixCall; uint32 _NbSetupModelMatrixCall;
bool _SumTextureMemoryUsed; bool _SumTextureMemoryUsed;
std::set<CTextureDrvInfosGL*> _TextureUsed; std::vector<CTextureDrvInfosGL *> _TextureUsed;
uint computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const; uint computeMipMapMemoryUsage(uint w, uint h, GLint glfmt) const;
// VBHard Lock Profiling // VBHard Lock Profiling

View file

@ -79,6 +79,8 @@ CTextureDrvInfosGL::CTextureDrvInfosGL(IDriver *drv, ItTexDrvInfoPtrMap it, CDri
InitFBO = false; InitFBO = false;
AttachDepthStencil = true; AttachDepthStencil = true;
UsePackedDepthStencil = drvGl->supportPackedDepthStencil(); UsePackedDepthStencil = drvGl->supportPackedDepthStencil();
TextureUsedIdx = 0;
} }
// *************************************************************************** // ***************************************************************************
CTextureDrvInfosGL::~CTextureDrvInfosGL() CTextureDrvInfosGL::~CTextureDrvInfosGL()
@ -91,7 +93,10 @@ CTextureDrvInfosGL::~CTextureDrvInfosGL()
_Driver->_AllocatedTextureMemory-= TextureMemory; _Driver->_AllocatedTextureMemory-= TextureMemory;
// release in TextureUsed. // release in TextureUsed.
_Driver->_TextureUsed.erase (this); if (TextureUsedIdx < _Driver->_TextureUsed.size() && _Driver->_TextureUsed[TextureUsedIdx] == this)
{
_Driver->_TextureUsed[TextureUsedIdx] = NULL;
}
if(InitFBO) if(InitFBO)
{ {
@ -1492,7 +1497,11 @@ bool CDriverGL::activateTexture(uint stage, ITexture *tex)
if (_SumTextureMemoryUsed) if (_SumTextureMemoryUsed)
{ {
// Insert the pointer of this texture // Insert the pointer of this texture
_TextureUsed.insert (gltext); if (gltext->TextureUsedIdx >= _TextureUsed.size() || _TextureUsed[gltext->TextureUsedIdx] != gltext)
{
gltext->TextureUsedIdx = _TextureUsed.size();
_TextureUsed.push_back(gltext);
}
} }
if(tex->isTextureCube()) if(tex->isTextureCube())