Merge with kaetemi-optimize

hg/feature/sound
kaetemi 11 years ago
commit 1d6e047edd

@ -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,6 +1513,7 @@ uint32 CDriverGL::getUsedTextureMemory() const
gltext= (*ite); gltext= (*ite);
// Sum the memory used by this texture // Sum the memory used by this texture
if (gltext)
memory+=gltext->TextureMemory; memory+=gltext->TextureMemory;
// Next texture // Next texture

@ -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

@ -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())

Loading…
Cancel
Save