Initialize unfilled textures based on GrCaps
This is especially relevant on WebGL, where there
can be a large performance hit to dealing with
uninitialized textures.
Change-Id: Ic8469ec833464a88fe846c72fc02a9af5d43d0d5
Bug: skia:8378
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206396
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 7638bf1..c02818a 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -7,6 +7,7 @@
#include "GrSWMaskHelper.h"
+#include "GrCaps.h"
#include "GrProxyProvider.h"
#include "GrRecordingContext.h"
#include "GrRecordingContextPriv.h"
@@ -115,15 +116,9 @@
surfaceFlags |= GrInternalSurfaceFlags::kNoPendingIO;
}
auto clearFlag = kNone_GrSurfaceFlags;
- // In a WASM build on Firefox, we see warnings like
- // WebGL warning: texSubImage2D: This operation requires zeroing texture data. This is slow.
- // WebGL warning: texSubImage2D: Texture has not been initialized prior to a partial upload,
- // forcing the browser to clear it. This may be slow.
- // Setting the initial clear seems to make those warnings go away and offers a substantial
- // boost in performance in Firefox. Chrome sees a more modest increase.
-#if IS_WEBGL==1
- clearFlag = kPerformInitialClear_GrSurfaceFlag;
-#endif
+ if (context->priv().caps()->shouldInitializeTextures() && fit == SkBackingFit::kApprox) {
+ clearFlag = kPerformInitialClear_GrSurfaceFlag;
+ }
return context->priv().proxyProvider()->createTextureProxy(
std::move(img), clearFlag, 1, SkBudgeted::kYes, fit, surfaceFlags);
}