From 09563cec928da5052972b3dca7f022fca3a72d05 Mon Sep 17 00:00:00 2001 From: brianosman Date: Thu, 2 Jun 2016 08:59:34 -0700 Subject: [PATCH] Add a caps bit to enable/disable the new manual mip-mapper 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 | 9 +++++++++ src/gpu/gl/GrGLCaps.h | 3 +++ src/gpu/gl/GrGLGpu.cpp | 11 ++--------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 6aa94de..88ed455 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -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); diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 1602a0f..58bf98c 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -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; diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 1744e25..fe32556 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -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: -- 2.7.4