Clear atlas textures at creation in Chrome
authorBrian Salomon <bsalomon@google.com>
Wed, 24 May 2017 14:07:30 +0000 (10:07 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 24 May 2017 16:04:45 +0000 (16:04 +0000)
Bug: chromium:656320
Change-Id: Ia65274aa733f199be188579821e745920493aefc
Reviewed-on: https://skia-review.googlesource.com/17824
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>

include/gpu/GrCaps.h
src/gpu/GrCaps.cpp
src/gpu/GrDrawOpAtlas.cpp
src/gpu/gl/GrGLCaps.cpp

index 4dc7767..e6034c5 100644 (file)
@@ -176,6 +176,8 @@ public:
     /** True in environments that will issue errors if memory uploaded to buffers
         is not initialized (even if not read by draw calls). */
     bool mustClearUploadedBufferData() const { return fMustClearUploadedBufferData; }
+    /** True when there is a performance cost to using an atlas that has not been cleared. */
+    bool mustClearAtlases() const { return fMustClearAtlases; }
 
     bool wireframeMode() const { return fWireframeMode; }
 
@@ -219,6 +221,7 @@ protected:
     bool fPreferClientSideDynamicBuffers             : 1;
     bool fFullClearIsFree                            : 1;
     bool fMustClearUploadedBufferData                : 1;
+    bool fMustClearAtlases                           : 1;
 
     // Driver workaround
     bool fUseDrawInsteadOfClear                      : 1;
index 5c04d19..e12af68 100644 (file)
@@ -47,6 +47,7 @@ GrCaps::GrCaps(const GrContextOptions& options) {
     fPreferClientSideDynamicBuffers = false;
     fFullClearIsFree = false;
     fMustClearUploadedBufferData = false;
+    fMustClearAtlases = false;
     fSampleShadingSupport = false;
     fFenceSyncSupport = false;
     fCrossContextTextureSupport = false;
index be8258a..235bc87 100644 (file)
@@ -24,6 +24,10 @@ std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrContext* ctx, GrPixelConfig
     desc.fHeight = height;
     desc.fConfig = config;
 
+    if (ctx->caps()->mustClearAtlases()) {
+        desc.fFlags |= kPerformInitialClear_GrSurfaceFlag;
+    }
+
     // We don't want to flush the context so we claim we're in the middle of flushing so as to
     // guarantee we do not recieve a texture with pending IO
     // TODO: Determine how to avoid having to do this. (https://bug.skia.org/4156)
index 8c43303..9fb8db4 100644 (file)
@@ -495,6 +495,7 @@ void GrGLCaps::init(const GrContextOptions& contextOptions,
 
     if (kChromium_GrGLDriver == ctxInfo.driver()) {
         fMustClearUploadedBufferData = true;
+        fMustClearAtlases = true;
     }
 
     if (kGL_GrGLStandard == standard) {