Add GLSL support for texelFetch

Adds a cap and builder methods for texelFetch. This is required for
texel buffers. Also moves the texel buffer cap into the general shader
caps, and adds glTexBufferRange to the GL interface.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1869063005

Review URL: https://codereview.chromium.org/1869063005
diff --git a/src/gpu/glsl/GrGLSLShaderBuilder.cpp b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
index 91a0f9b..1031f84 100644
--- a/src/gpu/glsl/GrGLSLShaderBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLShaderBuilder.cpp
@@ -93,14 +93,7 @@
                      coordName);
     }
 
-    // This refers to any swizzling we may need to get from some backend internal format to the
-    // format used in GrPixelConfig. If this is implemented by the GrGpu object, then swizzle will
-    // be rgba. For shader prettiness we omit the swizzle rather than appending ".rgba".
-    const GrSwizzle& configSwizzle = glslCaps->configTextureSwizzle(sampler.config());
-
-    if (configSwizzle != GrSwizzle::RGBA()) {
-        out->appendf(".%s", configSwizzle.c_str());
-    }
+    this->appendTextureSwizzle(out, sampler.config());
 }
 
 void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLSampler& sampler,
@@ -118,6 +111,33 @@
     this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str());
 }
 
+void GrGLSLShaderBuilder::appendTexelFetch(SkString* out,
+                                           const GrGLSLSampler& sampler,
+                                           const char* coordExpr) const {
+    const GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler();
+    SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport());
+    SkASSERT(GrSLTypeIsSamplerType(
+             uniformHandler->getUniformVariable(sampler.fSamplerUniform).getType()));
+
+    out->appendf("texelFetch(%s, %s)",
+                 uniformHandler->getUniformCStr(sampler.fSamplerUniform),
+                 coordExpr);
+
+    this->appendTextureSwizzle(out, sampler.config());
+}
+
+void GrGLSLShaderBuilder::appendTexelFetch(const GrGLSLSampler& sampler, const char* coordExpr) {
+    this->appendTexelFetch(&this->code(), sampler, coordExpr);
+}
+
+void GrGLSLShaderBuilder::appendTextureSwizzle(SkString* out, GrPixelConfig config) const {
+    const GrSwizzle& configSwizzle = fProgramBuilder->glslCaps()->configTextureSwizzle(config);
+
+    if (configSwizzle != GrSwizzle::RGBA()) {
+        out->appendf(".%s", configSwizzle.c_str());
+    }
+}
+
 bool GrGLSLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionName) {
     if (featureBit & fFeaturesAddedMask) {
         return false;