Re-land unit test for clear bug (w/ AMD work-arounds)
Bug: 768134
Change-Id: I76e5e3ff5719b0d2f9c74d49dfa9e187e4da7c1f
Reviewed-on: https://skia-review.googlesource.com/60562
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-on: https://skia-review.googlesource.com/61221
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index eb2d2c3..05bb121 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -569,6 +569,12 @@
fUseDrawToClearColor = true;
}
+ // A lot of GPUs have trouble with full screen clears (skbug.com/7195)
+ if (kAMDRadeonHD7xxx_GrGLRenderer == ctxInfo.renderer() ||
+ kAMDRadeonR9M4xx_GrGLRenderer == ctxInfo.renderer()) {
+ fUseDrawToClearColor = true;
+ }
+
#ifdef SK_BUILD_FOR_MAC
// crbug.com/768134 - On MacBook Pros, the Intel Iris Pro doesn't always perform
// full screen clears
diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp
index 055bc56..a0ea477 100644
--- a/src/gpu/gl/GrGLUtil.cpp
+++ b/src/gpu/gl/GrGLUtil.cpp
@@ -350,6 +350,25 @@
return kIntel6xxx_GrGLRenderer;
}
}
+
+ // The AMD string can have a somewhat arbitrary preamble (see skbug.com/7195)
+ if (const char* amdString = strstr(rendererString, "Radeon")) {
+ char amdGeneration, amdTier, amdRevision;
+ n = sscanf(amdString, "Radeon (TM) R9 M%c%c%c",
+ &amdGeneration, &amdTier, &amdRevision);
+ if (3 == n) {
+ if ('4' == amdGeneration) {
+ return kAMDRadeonR9M4xx_GrGLRenderer;
+ }
+ }
+
+ char amd0, amd1, amd2;
+ n = sscanf(amdString, "Radeon HD 7%c%c%c Series", &amd0, &amd1, &amd2);
+ if (3 == n) {
+ return kAMDRadeonHD7xxx_GrGLRenderer;
+ }
+ }
+
if (0 == strcmp("Mesa Offscreen", rendererString)) {
return kOSMesa_GrGLRenderer;
}
diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h
index f1b339f..04aa5bc 100644
--- a/src/gpu/gl/GrGLUtil.h
+++ b/src/gpu/gl/GrGLUtil.h
@@ -62,6 +62,10 @@
/** T-6xx, T-7xx, or T-8xx */
kMaliT_GrGLRenderer,
kANGLE_GrGLRenderer,
+
+ kAMDRadeonHD7xxx_GrGLRenderer, // AMD Radeon HD 7000 Series
+ kAMDRadeonR9M4xx_GrGLRenderer, // AMD Radeon R9 M400 Series
+
kOther_GrGLRenderer
};
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index c1c39dc..fca0318 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -11,6 +11,9 @@
#include "GrContext.h"
#include "GrRenderTargetContext.h"
+#include "SkCanvas.h"
+#include "SkSurface.h"
+
static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t expectedValue,
uint32_t* actualValue, int* failX, int* failY) {
int w = rect.width();
@@ -212,8 +215,6 @@
}
}
-#if 0
-
void fullscreen_clear_with_layer_test(skiatest::Reporter* reporter, GrContext* context) {
const SkImageInfo ii = SkImageInfo::Make(400, 77, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
@@ -280,5 +281,3 @@
}
#endif
-
-#endif