Skip to content

Commit

Permalink
Merge pull request xbmc#1649 from FernetMenta/asic
Browse files Browse the repository at this point in the history
fix gfx freeze on AMD (Linux) - Asic hang

The special code for GL should probably be factored out else where. But it make sense to postpone deletion of textures that are queued for render in next flip to after the actual flip call.
  • Loading branch information
elupus committed Oct 21, 2012
2 parents f4ee220 + 1d7b1f1 commit 2b19840
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions xbmc/Application.cpp
Expand Up @@ -2314,8 +2314,6 @@ void CApplication::Render()

g_Windowing.EndRender();

g_TextureManager.FreeUnusedTextures();

// reset our info cache - we do this at the end of Render so that it is
// fresh for the next process(), or after a windowclose animation (where process()
// isn't called)
Expand Down Expand Up @@ -2350,6 +2348,8 @@ void CApplication::Render()
g_graphicsContext.Flip(dirtyRegions);
CTimeUtils::UpdateFrameTime(flip);

g_TextureManager.FreeUnusedTextures();

g_renderManager.UpdateResolution();
g_renderManager.ManageCaptures();

Expand Down
3 changes: 2 additions & 1 deletion xbmc/guilib/GUIFontTTFGL.cpp
Expand Up @@ -23,6 +23,7 @@
#include "GUIFontTTFGL.h"
#include "GUIFontManager.h"
#include "Texture.h"
#include "TextureManager.h"
#include "GraphicContext.h"
#include "gui3d.h"
#include "utils/log.h"
Expand Down Expand Up @@ -234,7 +235,7 @@ void CGUIFontTTFGL::DeleteHardwareTexture()
if (m_bTextureLoaded)
{
if (glIsTexture(m_nTexture))
glDeleteTextures(1, (GLuint*) &m_nTexture);
g_TextureManager.ReleaseHwTexture(m_nTexture);
m_bTextureLoaded = false;
}
}
Expand Down
13 changes: 13 additions & 0 deletions xbmc/guilib/TextureManager.cpp
Expand Up @@ -459,6 +459,19 @@ void CGUITextureManager::FreeUnusedTextures()
for (ivecTextures i = m_unusedTextures.begin(); i != m_unusedTextures.end(); ++i)
delete *i;
m_unusedTextures.clear();

#if defined(HAS_GL) || defined(HAS_GLES)
for (unsigned int i = 0; i < m_unusedHwTextures.size(); ++i)
{
glDeleteTextures(1, (GLuint*) &m_unusedHwTextures[i]);
}
#endif
m_unusedHwTextures.clear();
}

void CGUITextureManager::ReleaseHwTexture(unsigned int texture)
{
m_unusedHwTextures.push_back(texture);
}

void CGUITextureManager::Cleanup()
Expand Down
2 changes: 2 additions & 0 deletions xbmc/guilib/TextureManager.h
Expand Up @@ -123,9 +123,11 @@ class CGUITextureManager
void RemoveTexturePath(const CStdString &texturePath); ///< Remove a path from the paths to check when loading media

void FreeUnusedTextures(); ///< Free textures (called from app thread only)
void ReleaseHwTexture(unsigned int texture);
protected:
std::vector<CTextureMap*> m_vecTextures;
std::vector<CTextureMap*> m_unusedTextures;
std::vector<unsigned int> m_unusedHwTextures;
typedef std::vector<CTextureMap*>::iterator ivecTextures;
// we have 2 texture bundles (one for the base textures, one for the theme)
CTextureBundle m_TexBundle[2];
Expand Down

0 comments on commit 2b19840

Please sign in to comment.