Driver bug workaround: max_msaa_sample_count_4

Bug: chromium: 829614
Change-Id: I54054191815ace6159585dab7dd811ebdc863095
Reviewed-on: https://skia-review.googlesource.com/126983
Commit-Queue: Adrienne Walker <enne@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/include/gpu/GrDriverBugWorkaroundsAutogen.h b/include/gpu/GrDriverBugWorkaroundsAutogen.h
index 1b3c8f8..2fdcaa0 100644
--- a/include/gpu/GrDriverBugWorkaroundsAutogen.h
+++ b/include/gpu/GrDriverBugWorkaroundsAutogen.h
@@ -12,6 +12,8 @@
          disable_discard_framebuffer)     \
   GPU_OP(DISALLOW_LARGE_INSTANCED_DRAW,   \
          disallow_large_instanced_draw)   \
+  GPU_OP(MAX_MSAA_SAMPLE_COUNT_4,         \
+         max_msaa_sample_count_4)         \
   GPU_OP(MAX_TEXTURE_SIZE_LIMIT_4096,     \
          max_texture_size_limit_4096)     \
 // The End
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 727db6c..dc4fc31 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -2786,7 +2786,11 @@
 
     for (int i = 0; i < count; ++i) {
         if (fConfigTable[config].fColorSampleCounts[i] >= requestedCount) {
-            return fConfigTable[config].fColorSampleCounts[i];
+            int count = fConfigTable[config].fColorSampleCounts[i];
+            if (fDriverBugWorkarounds.max_msaa_sample_count_4) {
+                count = SkTMin(count, 4);
+            }
+            return count;
         }
     }
     return 0;
diff --git a/src/gpu/gpu_workaround_list.txt b/src/gpu/gpu_workaround_list.txt
index 8c399a2..aa1e1a2 100644
--- a/src/gpu/gpu_workaround_list.txt
+++ b/src/gpu/gpu_workaround_list.txt
@@ -1,4 +1,5 @@
 disable_blend_equation_advanced
 disable_discard_framebuffer
 disallow_large_instanced_draw
+max_msaa_sample_count_4
 max_texture_size_limit_4096