Bug 797120 - GLContext::CanUploadNonPowerOfTwo() should not call AddBoolVarCache() when off the main thread. r=bjacob

This commit is contained in:
Jeff Gilbert 2012-11-07 11:39:38 +13:00
parent f0004b2afd
commit d9a04350b5
3 changed files with 34 additions and 9 deletions

View File

@ -625,21 +625,34 @@ GLContext::CanUploadSubTextures()
return true;
}
bool GLContext::sPowerOfTwoForced = false;
bool GLContext::sPowerOfTwoPrefCached = false;
void
GLContext::PlatformStartup()
{
CacheCanUploadNPOT();
}
void
GLContext::CacheCanUploadNPOT()
{
MOZ_ASSERT(NS_IsMainThread(), "Can't cache prefs off the main thread.");
MOZ_ASSERT(!sPowerOfTwoPrefCached, "Must only call this function once!");
sPowerOfTwoPrefCached = true;
mozilla::Preferences::AddBoolVarCache(&sPowerOfTwoForced,
"gfx.textures.poweroftwo.force-enabled");
}
bool
GLContext::CanUploadNonPowerOfTwo()
{
MOZ_ASSERT(sPowerOfTwoPrefCached);
if (!mWorkAroundDriverBugs)
return true;
static bool sPowerOfTwoForced;
static bool sPowerOfTwoPrefCached = false;
if (!sPowerOfTwoPrefCached) {
sPowerOfTwoPrefCached = true;
mozilla::Preferences::AddBoolVarCache(&sPowerOfTwoForced,
"gfx.textures.poweroftwo.force-enabled");
}
// Some GPUs driver crash when uploading non power of two 565 textures.
return sPowerOfTwoForced ? false : (Renderer() != RendererAdreno200 &&
Renderer() != RendererAdreno205);

View File

@ -744,7 +744,17 @@ public:
}
bool CanUploadSubTextures();
static void PlatformStartup();
protected:
static bool sPowerOfTwoForced;
static bool sPowerOfTwoPrefCached;
static void CacheCanUploadNPOT();
public:
bool CanUploadNonPowerOfTwo();
bool WantsSmallTiles();
virtual bool HasLockSurface() { return false; }

View File

@ -340,6 +340,8 @@ gfxPlatform::Init()
gPlatform->mWorkAroundDriverBugs = Preferences::GetBool("gfx.work-around-driver-bugs", true);
mozilla::gl::GLContext::PlatformStartup();
#ifdef MOZ_WIDGET_ANDROID
// Texture pool init
mozilla::gl::TexturePoolOGL::Init();