Disabling calls to TexParameteri when the values do not exist on ES2.
authorcblume <cblume@chromium.org>
Tue, 1 Mar 2016 22:08:28 +0000 (14:08 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 1 Mar 2016 22:08:28 +0000 (14:08 -0800)
BUG=590804
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1750833003

Review URL: https://codereview.chromium.org/1750833003

src/gpu/gl/GrGLCaps.cpp
src/gpu/gl/GrGLCaps.h
src/gpu/gl/GrGLGpu.cpp

index 132e9b2..22aa13f 100644 (file)
@@ -52,6 +52,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
     fSRGBWriteControl = false;
     fRGBA8888PixelsOpsAreSlow = false;
     fPartialFBOReadIsSlow = false;
+    fMipMapLevelAndLodControlSupport = false;
 
     fBlitFramebufferSupport = kNone_BlitFramebufferSupport;
 
@@ -246,6 +247,14 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
         }
     }
 
+    if (kGL_GrGLStandard == standard) {
+        fMipMapLevelAndLodControlSupport = true;
+    } else if (kGLES_GrGLStandard == standard) {
+        if (version >= GR_GL_VER(3,0)) {
+            fMipMapLevelAndLodControlSupport = true;
+        }
+    }
+
 #ifdef SK_BUILD_FOR_WIN
     // We're assuming that on Windows Chromium we're using ANGLE.
     bool isANGLE = kANGLE_GrGLDriver == ctxInfo.driver() ||
index 724bab6..06deaaf 100644 (file)
@@ -342,6 +342,8 @@ public:
      */
     bool srgbWriteControl() const { return fSRGBWriteControl; }
 
+    bool mipMapLevelAndLodControlSupport() const { return fMipMapLevelAndLodControlSupport; }
+
     /**
      * Returns a string containing the caps info.
      */
@@ -418,6 +420,7 @@ private:
     bool fExternalTextureSupport : 1;
     bool fRectangleTextureSupport : 1;
     bool fTextureSwizzleSupport : 1;
+    bool fMipMapLevelAndLodControlSupport : 1;
 
     BlitFramebufferSupport fBlitFramebufferSupport;
 
index 2984133..dc50c14 100644 (file)
@@ -3344,14 +3344,17 @@ void GrGLGpu::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur
         GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MIN_FILTER, newTexParams.fMinFilter));
     }
     if (setAll || newTexParams.fMaxMipMapLevel != oldTexParams.fMaxMipMapLevel) {
-        if (newTexParams.fMaxMipMapLevel != 0) {
-            this->setTextureUnit(unitIdx);
-            GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MIN_LOD, 0));
-            GL_CALL(TexParameteri(target, GR_GL_TEXTURE_BASE_LEVEL, 0));
-            GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAX_LOD,
-                                  newTexParams.fMaxMipMapLevel));
-            GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAX_LEVEL,
-                                  newTexParams.fMaxMipMapLevel));
+        // These are not supported in ES2 contexts
+        if (this->glCaps().mipMapLevelAndLodControlSupport()) {
+            if (newTexParams.fMaxMipMapLevel != 0) {
+                this->setTextureUnit(unitIdx);
+                GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MIN_LOD, 0));
+                GL_CALL(TexParameteri(target, GR_GL_TEXTURE_BASE_LEVEL, 0));
+                GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAX_LOD,
+                                      newTexParams.fMaxMipMapLevel));
+                GL_CALL(TexParameteri(target, GR_GL_TEXTURE_MAX_LEVEL,
+                                      newTexParams.fMaxMipMapLevel));
+            }
         }
     }
     if (setAll || newTexParams.fWrapS != oldTexParams.fWrapS) {