Improve performance of UsedTexture debugging info in OpenGL driver

--HG--
branch : kaetemi-optimize
This commit is contained in:
kaetemi 2013-07-29 03:41:10 +02:00
parent e701596156
commit 1c3fbf0256
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 )
if (enable)
{
nlinfo ("3D: PERFORMANCE INFO: enableUsedTextureMemorySum has been set to true in CDriverGL");
_TextureUsed.reserve(512);
}
_SumTextureMemoryUsed=enable;
}
@ -1502,7 +1505,7 @@ uint32 CDriverGL::getUsedTextureMemory() const
uint32 memory=0;
// For each texture used
set<CTextureDrvInfosGL*>::const_iterator ite=_TextureUsed.begin();
std::vector<CTextureDrvInfosGL *>::const_iterator ite = _TextureUsed.begin();
while (ite!=_TextureUsed.end())
{
// Get the gl texture
@ -1510,6 +1513,7 @@ uint32 CDriverGL::getUsedTextureMemory() const
gltext= (*ite);
// Sum the memory used by this texture
if (gltext)
memory+=gltext->TextureMemory;
// Next texture

View file

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

View file

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