Add a caps bit to enable/disable the new manual mip-mapper
authorbrianosman <brianosman@google.com>
Thu, 2 Jun 2016 15:59:34 +0000 (08:59 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 2 Jun 2016 15:59:34 +0000 (08:59 -0700)
Turn it off on Adreno3xx devices, because the small-render-target bug on
those devices leads to empty mipmaps for the smallest mips.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2026393004

Review-Url: https://codereview.chromium.org/2026393004

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

index 6aa94de..88ed455 100644 (file)
@@ -50,6 +50,7 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
     fPartialFBOReadIsSlow = false;
     fMipMapLevelAndLodControlSupport = false;
     fRGBAToBGRAReadbackConversionsAreSlow = false;
+    fDoManualMipmapping = false;
 
     fBlitFramebufferSupport = kNone_BlitFramebufferSupport;
 
@@ -543,6 +544,14 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
         fSampleShadingSupport = true;
     }
 
+    // Manual mip-mapping requires mip-level sampling control.
+    // Additionally, Adreno330 will produce empty mip-maps for the very smallest mips with
+    // our manual (draw-call) implementation.
+    if (fMipMapLevelAndLodControlSupport &&
+        kAdreno3xx_GrGLRenderer != ctxInfo.renderer()) {
+        fDoManualMipmapping = true;
+    }
+
     // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES compatibility have
     // already been detected.
     this->initConfigTable(ctxInfo, gli, glslCaps);
index 1602a0f..58bf98c 100644 (file)
@@ -333,6 +333,8 @@ public:
 
     bool mipMapLevelAndLodControlSupport() const { return fMipMapLevelAndLodControlSupport; }
 
+    bool doManualMipmapping() const { return fDoManualMipmapping; }
+
     /**
      * Returns a string containing the caps info.
      */
@@ -410,6 +412,7 @@ private:
     bool fTextureSwizzleSupport : 1;
     bool fMipMapLevelAndLodControlSupport : 1;
     bool fRGBAToBGRAReadbackConversionsAreSlow : 1;
+    bool fDoManualMipmapping : 1;
 
     BlitFramebufferSupport fBlitFramebufferSupport;
 
index 1744e25..fe32556 100644 (file)
@@ -4314,14 +4314,12 @@ bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst,
     return true;
 }
 
-bool gManualMipmaps = true;
-
 // Manual implementation of mipmap generation, to work around driver bugs w/sRGB.
 // Uses draw calls to do a series of downsample operations to successive mips.
 // If this returns false, then the calling code falls back to using glGenerateMipmap.
 bool GrGLGpu::generateMipmap(GrGLTexture* texture, bool gammaCorrect) {
-    // Global switch for manual mipmap generation:
-    if (!gManualMipmaps) {
+    // Our iterative downsample requires the ability to limit which level we're sampling:
+    if (!this->glCaps().doManualMipmapping()) {
         return false;
     }
 
@@ -4335,11 +4333,6 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, bool gammaCorrect) {
         return false;
     }
 
-    // Our iterative downsample requires the ability to limit which level we're sampling:
-    if (!this->glCaps().mipMapLevelAndLodControlSupport()) {
-        return false;
-    }
-
     // If we're mipping an sRGB texture, we need to ensure FB sRGB is correct:
     if (GrPixelConfigIsSRGB(texture->config())) {
         // If we have write-control, just set the state that we want: