Bug 942499 - Part 1: Move CanUploadSubTextures and WantsSmallTiles out of GLContext - r=BenWa

This commit is contained in:
Benoit Jacob 2013-12-03 13:44:38 -05:00
parent b56cec3f0a
commit 30d72ed7e8
6 changed files with 57 additions and 52 deletions

View File

@ -1145,32 +1145,6 @@ GLContext::InitExtensions()
#endif
}
// In both of these cases (for the Adreno at least) it is impossible
// to determine good or bad driver versions for POT texture uploads,
// so blacklist them all. Newer drivers use a different rendering
// string in the form "Adreno (TM) 200" and the drivers we've seen so
// far work fine with NPOT textures, so don't blacklist those until we
// have evidence of any problems with them.
bool
GLContext::CanUploadSubTextures()
{
if (!mWorkAroundDriverBugs)
return true;
// There are certain GPUs that we don't want to use glTexSubImage2D on
// because that function can be very slow and/or buggy
if (Renderer() == RendererAdreno200 || Renderer() == RendererAdreno205)
return false;
// On PowerVR glTexSubImage does a readback, so it will be slower
// than just doing a glTexImage2D() directly. i.e. 26ms vs 10ms
if (Renderer() == RendererSGX540 || Renderer() == RendererSGX530)
return false;
return true;
}
bool
GLContext::CanReadSRGBFromFBOTexture()
{
@ -1227,24 +1201,6 @@ GLContext::CanUploadNonPowerOfTwo()
Renderer() != RendererAdreno205);
}
bool
GLContext::WantsSmallTiles()
{
// We must use small tiles for good performance if we can't use
// glTexSubImage2D() for some reason.
if (!CanUploadSubTextures())
return true;
// We can't use small tiles on the SGX 540, because of races in texture upload.
if (mWorkAroundDriverBugs &&
Renderer() == RendererSGX540)
return false;
// Don't use small tiles otherwise. (If we implement incremental texture upload,
// then we will want to revisit this.)
return false;
}
// Common code for checking for both GL extensions and GLX extensions.
bool
GLContext::ListHasExtension(const GLubyte *extensions, const char *extension)

View File

@ -2473,7 +2473,6 @@ public:
MOZ_CRASH("Must be called against a GLContextEGL.");
}
bool CanUploadSubTextures();
bool CanReadSRGBFromFBOTexture();
static void PlatformStartup();
@ -2486,8 +2485,6 @@ protected:
public:
bool CanUploadNonPowerOfTwo();
bool WantsSmallTiles();
/**
* If this context wraps a double-buffered target, swap the back
* and front buffers. It should be assumed that after a swap, the

View File

@ -130,7 +130,7 @@ BasicTextureImage::BeginUpdate(nsIntRegion& aRegion)
NS_ASSERTION(!mUpdateSurface, "BeginUpdate() without EndUpdate()?");
// determine the region the client will need to repaint
if (mGLContext->CanUploadSubTextures()) {
if (CanUploadSubTextures(mGLContext)) {
GetUpdateRegion(aRegion);
} else {
aRegion = nsIntRect(nsIntPoint(0, 0), mSize);
@ -333,6 +333,24 @@ CreateBasicTextureImage(GLContext* aGL,
return CreateBasicTextureImage(aGL, ThebesIntSize(aSize), aContentType, aWrapMode, aFlags);
}
static bool
WantsSmallTiles(GLContext* gl)
{
// We must use small tiles for good performance if we can't use
// glTexSubImage2D() for some reason.
if (!CanUploadSubTextures(gl))
return true;
// We can't use small tiles on the SGX 540, because of races in texture upload.
if (gl->WorkAroundDriverBugs() &&
gl->Renderer() == GLContext::RendererSGX540)
return false;
// Don't use small tiles otherwise. (If we implement incremental texture upload,
// then we will want to revisit this.)
return false;
}
TiledTextureImage::TiledTextureImage(GLContext* aGL,
nsIntSize aSize,
TextureImage::ContentType aContentType,
@ -348,7 +366,7 @@ TiledTextureImage::TiledTextureImage(GLContext* aGL,
, mTextureState(Created)
, mImageFormat(aImageFormat)
{
if (!(aFlags & TextureImage::DisallowBigImage) && mGL->WantsSmallTiles()) {
if (!(aFlags & TextureImage::DisallowBigImage) && WantsSmallTiles(mGL)) {
mTileSize = 256;
} else {
mGL->fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, (GLint*) &mTileSize);
@ -392,7 +410,7 @@ TiledTextureImage::DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion,
if (tileRegion.IsEmpty())
continue;
if (mGL->CanUploadSubTextures()) {
if (CanUploadSubTextures(mGL)) {
tileRegion.MoveBy(-xPos, -yPos); // translate into tile local space
} else {
// If sub-textures are unsupported, expand to tile boundaries

View File

@ -92,6 +92,37 @@ CopyAndPadTextureData(const GLvoid* srcBuffer,
}
}
// In both of these cases (for the Adreno at least) it is impossible
// to determine good or bad driver versions for POT texture uploads,
// so blacklist them all. Newer drivers use a different rendering
// string in the form "Adreno (TM) 200" and the drivers we've seen so
// far work fine with NPOT textures, so don't blacklist those until we
// have evidence of any problems with them.
bool
CanUploadSubTextures(GLContext* gl)
{
if (!gl->WorkAroundDriverBugs())
return true;
// There are certain GPUs that we don't want to use glTexSubImage2D on
// because that function can be very slow and/or buggy
if (gl->Renderer() == GLContext::RendererAdreno200 ||
gl->Renderer() == GLContext::RendererAdreno205)
{
return false;
}
// On PowerVR glTexSubImage does a readback, so it will be slower
// than just doing a glTexImage2D() directly. i.e. 26ms vs 10ms
if (gl->Renderer() == GLContext::RendererSGX540 ||
gl->Renderer() == GLContext::RendererSGX530)
{
return false;
}
return true;
}
static void
TexSubImage2DWithUnpackSubimageGLES(GLContext* gl,
GLenum target, GLint level,
@ -446,7 +477,7 @@ UploadImageDataToTexture(GLContext* gl,
NS_ASSERTION(textureInited || (iterRect->x == 0 && iterRect->y == 0),
"Must be uploading to the origin when we don't have an existing texture");
if (textureInited && gl->CanUploadSubTextures()) {
if (textureInited && CanUploadSubTextures(gl)) {
TexSubImage2DHelper(gl,
aTextureTarget,
0,

View File

@ -95,6 +95,8 @@ UploadSurfaceToTexture(GLContext* gl,
GLenum aTextureUnit,
GLenum aTextureTarget);
bool CanUploadSubTextures(GLContext* gl);
}
}

View File

@ -10,6 +10,7 @@
#include "FPSCounter.h" // for FPSState, FPSCounter
#include "GLContextProvider.h" // for GLContextProvider
#include "GLContext.h" // for GLContext
#include "GLUploadHelpers.h"
#include "Layers.h" // for WriteSnapshotToDumpFile
#include "LayerScope.h" // for LayerScope
#include "gfx2DGlue.h" // for ThebesFilter
@ -1501,7 +1502,7 @@ CompositorOGL::CreateDataTextureSource(TextureFlags aFlags)
bool
CompositorOGL::SupportsPartialTextureUpdate()
{
return mGLContext->CanUploadSubTextures();
return CanUploadSubTextures(mGLContext);
}
int32_t