Don't unroll gaussian blur kernel loop on ES3+ capable devices

Doesn't reduce total number of shaders (yet).

Bug: skia:11844
Change-Id: Ie03749807e18760c9242732587516a59fed721a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/398796
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index 5b8e250..09ec9c3 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -64,10 +64,17 @@
     Var coord(kFloat2_Type, "coord", sk_SampleCoord());
     Declare(coord);
 
-    // Manually unroll loop because some drivers don't; yields 20-30% speedup.
-    for (int i = 0; i < width; i++) {
-        color += SampleChild(/*index=*/0, coord + offsets[i / 4][i & 3] * increment) *
-            kernel[i / 4][i & 0x3];
+    // This checks that bitwise integer operations and array indexing by non-consts are allowed.
+    if (args.fShaderCaps->generation() >= k130_GrGLSLGeneration) {
+        Var i(kInt_Type, "i", 0);
+        For(Declare(i), i < width, i++,
+            color += SampleChild(/*index=*/0, coord + offsets[i / 4][i & 3] * increment) *
+                     kernel[i / 4][i & 0x3]);
+    } else {
+        for (int i = 0; i < width; i++) {
+            color += SampleChild(/*index=*/0, coord + offsets[i / 4][i & 3] * increment) *
+                     kernel[i / 4][i & 0x3];
+        }
     }
 
     Return(color);