Make ANGLE perf decisions be runtime rather than compile time

R=robertphillips@google.com

Review URL: https://codereview.chromium.org/1268953002
This commit is contained in:
bsalomon 2015-07-31 11:20:16 -07:00 committed by Commit bot
parent 7eb0945af2
commit 88c7b988ba
7 changed files with 34 additions and 31 deletions

View File

@ -65,15 +65,6 @@
* The GrGLInterface field fCallback specifies the function ptr and there is an
* additional field fCallbackData of type intptr_t for client data.
*
* GR_GL_RGBA_8888_PIXEL_OPS_SLOW: Set this to 1 if it is known that performing
* glReadPixels / glTex(Sub)Image with format=GL_RGBA, type=GL_UNISIGNED_BYTE is
* significantly slower than format=GL_BGRA, type=GL_UNISIGNED_BYTE.
*
* GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL: Set this to 1 if calling
* glReadPixels to read the entire framebuffer is faster than calling it with
* the same sized rectangle but with a framebuffer bound that is larger than
* the rectangle read.
*
* GR_GL_CHECK_ALLOC_WITH_GET_ERROR: If set to 1 this will then glTexImage,
* glBufferData, glRenderbufferStorage, etc will be checked for errors. This
* amounts to ensuring the error is GL_NO_ERROR, calling the allocating
@ -128,14 +119,6 @@
#define GR_GL_PER_GL_FUNC_CALLBACK 0
#endif
#if !defined(GR_GL_RGBA_8888_PIXEL_OPS_SLOW)
#define GR_GL_RGBA_8888_PIXEL_OPS_SLOW 0
#endif
#if !defined(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL)
#define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 0
#endif
#if !defined(GR_GL_CHECK_ALLOC_WITH_GET_ERROR)
#define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 1
#endif

View File

@ -11,17 +11,6 @@
// glGetError() forces a sync with gpu process on chrome
#define GR_GL_CHECK_ERROR_START 0
#if defined(SK_BUILD_FOR_WIN32)
// For RGBA teximage/readpixels ANGLE will sw-convert to/from BGRA.
#define GR_GL_RGBA_8888_PIXEL_OPS_SLOW 1
// ANGLE can go faster if the entire fbo is read rather than a subrect
#define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 1
#else
#define GR_GL_RGBA_8888_PIXEL_OPS_SLOW 0
#define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 0
#endif
// cmd buffer allocates memory and memsets it to zero when it sees glBufferData
// with NULL.
#define GR_GL_USE_BUFFER_DATA_NULL_HINT 0

View File

@ -50,6 +50,8 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fFullClearIsFree = false;
fBindFragDataLocationSupport = false;
fSRGBWriteControl = false;
fRGBA8888PixelsOpsAreSlow = false;
fPartialFBOReadIsSlow = false;
fReadPixelsSupportedCache.reset();
@ -304,6 +306,17 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
}
}
#ifdef SK_BUILD_FOR_WIN
// We're assuming that on Windows Chromium we're using ANGLE.
bool isANGLE = kANGLE_GrGLDriver == ctxInfo.driver() ||
kChromium_GrGLDriver == ctxInfo.driver();
// Angle has slow read/write pixel paths for 32bit RGBA (but fast for BGRA).
fRGBA8888PixelsOpsAreSlow = isANGLE;
// On DX9 ANGLE reading a partial FBO is slow. TODO: Check whether this is still true and
// check DX11 ANGLE.
fPartialFBOReadIsSlow = isANGLE;
#endif
/**************************************************************************
* GrShaderCaps fields
**************************************************************************/
@ -1132,6 +1145,8 @@ SkString GrGLCaps::dump() const {
(fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO"));
r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO"));
r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow? "YES" : "NO"));
r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow? "YES" : "NO"));
return r;
}

View File

@ -281,6 +281,9 @@ public:
LATCAlias latcAlias() const { return fLATCAlias; }
bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
private:
@ -380,6 +383,8 @@ private:
bool fFullClearIsFree : 1;
bool fBindFragDataLocationSupport : 1;
bool fSRGBWriteControl : 1;
bool fRGBA8888PixelsOpsAreSlow : 1;
bool fPartialFBOReadIsSlow : 1;
struct ReadPixelsSupportedFormat {
GrGLenum fFormat;

View File

@ -542,7 +542,8 @@ bool GrGLGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height,
ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
tempDrawInfo->fTempSurfaceDesc.fConfig = dstSurface->config();
tempDrawInfo->fSwapRAndB = true;
} else if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == srcConfig) {
} else if (this->glCaps().rgba8888PixelsOpsAreSlow() &&
kRGBA_8888_GrPixelConfig == srcConfig) {
ElevateDrawPreference(drawPreference, kGpuPrefersDraw_DrawPreference);
tempDrawInfo->fTempSurfaceDesc.fConfig = dstSurface->config();
tempDrawInfo->fSwapRAndB = true;
@ -1761,7 +1762,7 @@ bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height,
tempDrawInfo->fTempSurfaceDesc.fHeight = height;
tempDrawInfo->fTempSurfaceDesc.fSampleCnt = 0;
tempDrawInfo->fTempSurfaceDesc.fOrigin = kTopLeft_GrSurfaceOrigin; // no CPU y-flip for TL.
tempDrawInfo->fUseExactScratch = SkToBool(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL) &&
tempDrawInfo->fUseExactScratch = this->glCaps().partialFBOReadIsSlow() &&
width >= this->caps()->minTextureSize() &&
height >= this->caps()->minTextureSize();
@ -1770,7 +1771,7 @@ bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height,
GrPixelConfig srcConfig = srcSurface->config();
tempDrawInfo->fTempSurfaceDesc.fConfig = readConfig;
if (GR_GL_RGBA_8888_PIXEL_OPS_SLOW && kRGBA_8888_GrPixelConfig == readConfig) {
if (this->glCaps().rgba8888PixelsOpsAreSlow() && kRGBA_8888_GrPixelConfig == readConfig) {
tempDrawInfo->fTempSurfaceDesc.fConfig = kBGRA_8888_GrPixelConfig;
tempDrawInfo->fSwapRAndB = true;
ElevateDrawPreference(drawPreference, kGpuPrefersDraw_DrawPreference);

View File

@ -147,6 +147,15 @@ void GrGLGetDriverInfo(GrGLStandard standard,
*outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor);
return;
}
if (0 == strncmp("ANGLE", rendererString, 5)) {
*outDriver = kANGLE_GrGLDriver;
n = sscanf(versionString, "OpenGL ES %d.%d (ANGLE %d.%d", &major, &minor, &driverMajor,
&driverMinor);
if (4 == n) {
*outVersion = GR_GL_DRIVER_VER(driverMajor, driverMinor);
}
return;
}
}
if (kIntel_GrGLVendor == vendor) {

View File

@ -59,6 +59,7 @@ enum GrGLDriver {
kChromium_GrGLDriver,
kNVIDIA_GrGLDriver,
kIntel_GrGLDriver,
kANGLE_GrGLDriver,
kUnknown_GrGLDriver
};