aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ericrk <ericrk@chromium.org>2016-03-11 15:18:20 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-11 15:18:20 -0800
commitb4ecabd5a2c359f66a20207ffb02a77e624560c4 (patch)
tree3d4c7e87f527889a368d262c82f0747b3f2f9ef8
parentc04ce676d4516a8c64e29e1f60bb72cd2c6c0a59 (diff)
Fix BGRA/RGBA readback conversions on mac
Reading back from a BGRA framebuffer as RGBA or vis-versa is slow on mac. On my early 2013 MBP, we see a 40% regression when using the discrete GPU or a 13% regression on integrated. This change adds a workaround which causes Mac to use the existing Mesa path and prefer readback from the same format as the framebuffer. BUG=581311 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1786813002 Review URL: https://codereview.chromium.org/1786813002
-rw-r--r--src/gpu/gl/GrGLCaps.cpp13
-rw-r--r--src/gpu/gl/GrGLCaps.h4
-rw-r--r--src/gpu/gl/GrGLGpu.cpp2
3 files changed, 18 insertions, 1 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index dfcde60d45..40885359fb 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -51,6 +51,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
fRGBA8888PixelsOpsAreSlow = false;
fPartialFBOReadIsSlow = false;
fMipMapLevelAndLodControlSupport = false;
+ fRGBAToBGRAReadbackConversionsAreSlow = false;
fBlitFramebufferSupport = kNone_BlitFramebufferSupport;
@@ -253,6 +254,16 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
fPartialFBOReadIsSlow = isANGLE;
#endif
+ bool isMESA = kMesa_GrGLDriver == ctxInfo.driver();
+ bool isMAC = false;
+#ifdef SK_BUILD_FOR_MAC
+ isMAC = true;
+#endif
+
+ // Both mesa and mac have reduced performance if reading back an RGBA framebuffer as BGRA or
+ // vis-versa.
+ fRGBAToBGRAReadbackConversionsAreSlow = isMESA || isMAC;
+
/**************************************************************************
* GrShaderCaps fields
**************************************************************************/
@@ -1077,6 +1088,8 @@ SkString GrGLCaps::dump() const {
r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSupport ? "YES" : "NO"));
r.appendf("Rectangle texture support: %s\n", (fRectangleTextureSupport? "YES" : "NO"));
r.appendf("Texture swizzle support: %s\n", (fTextureSwizzleSupport ? "YES" : "NO"));
+ r.appendf("BGRA to RGBA readback conversions are slow: %s\n",
+ (fRGBAToBGRAReadbackConversionsAreSlow ? "YES" : "NO"));
r.append("Configs\n-------\n");
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index cf162914de..376610d8b0 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -345,6 +345,9 @@ public:
bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; }
bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; }
+ bool rgbaToBgraReadbackConversionsAreSlow() const {
+ return fRGBAToBGRAReadbackConversionsAreSlow;
+ }
const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
@@ -413,6 +416,7 @@ private:
bool fRectangleTextureSupport : 1;
bool fTextureSwizzleSupport : 1;
bool fMipMapLevelAndLodControlSupport : 1;
+ bool fRGBAToBGRAReadbackConversionsAreSlow : 1;
BlitFramebufferSupport fBlitFramebufferSupport;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 443c55c234..3e8f507b4a 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2560,7 +2560,7 @@ bool GrGLGpu::onGetReadPixelsInfo(GrSurface* srcSurface, int width, int height,
tempDrawInfo->fSwizzle = GrSwizzle::BGRA();
tempDrawInfo->fReadConfig = kBGRA_8888_GrPixelConfig;
ElevateDrawPreference(drawPreference, kGpuPrefersDraw_DrawPreference);
- } else if (kMesa_GrGLDriver == this->glContext().driver() &&
+ } else if (this->glCaps().rgbaToBgraReadbackConversionsAreSlow() &&
GrBytesPerPixel(readConfig) == 4 &&
GrPixelConfigSwapRAndB(readConfig) == srcConfig &&
this->readPixelsSupported(srcSurface, srcConfig)) {