Prefer fullscreen clears on Qualcomm/GL
Adds Qualcomm to the set of GL devices on which we prefer fullscreen
clears.
Renames fullscreenClearIsFree in GrCaps to preferFullscreenClears.
Replaces 'bool canIgnoreClip' on GrRenderTargetContext::clear with an
enum.
Bug: skia:
Change-Id: I5b30298c4d0b092c398b9fea6060f3e2bea91e46
Reviewed-on: https://skia-review.googlesource.com/83060
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 198551a..2c83cc3 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -53,7 +53,7 @@
fInstanceAttribSupport = false;
fUsesMixedSamples = false;
fPreferClientSideDynamicBuffers = false;
- fFullClearIsFree = false;
+ fPreferFullscreenClears = false;
fMustClearUploadedBufferData = false;
fSampleShadingSupport = false;
fFenceSyncSupport = false;
@@ -150,7 +150,7 @@
writer->appendBool("Instance Attrib Support", fInstanceAttribSupport);
writer->appendBool("Uses Mixed Samples", fUsesMixedSamples);
writer->appendBool("Prefer client-side dynamic buffers", fPreferClientSideDynamicBuffers);
- writer->appendBool("Full screen clear is free", fFullClearIsFree);
+ writer->appendBool("Prefer fullscreen clears", fPreferFullscreenClears);
writer->appendBool("Must clear buffer memory", fMustClearUploadedBufferData);
writer->appendBool("Sample shading support", fSampleShadingSupport);
writer->appendBool("Fence sync support", fFenceSyncSupport);
diff --git a/src/gpu/GrReducedClip.cpp b/src/gpu/GrReducedClip.cpp
index 83079d3..85a19ed 100644
--- a/src/gpu/GrReducedClip.cpp
+++ b/src/gpu/GrReducedClip.cpp
@@ -746,7 +746,7 @@
// The scratch texture that we are drawing into can be substantially larger than the mask. Only
// clear the part that we care about.
GrColor initialCoverage = InitialState::kAllIn == this->initialState() ? -1 : 0;
- rtc->priv().clear(clip, initialCoverage, true);
+ rtc->priv().clear(clip, initialCoverage, GrRenderTargetContext::CanClearFullscreen::kYes);
// Set the matrix so that rendered clip elements are transformed to mask space from clip space.
SkMatrix translate;
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 03d49bc..70864a0 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -272,14 +272,15 @@
void GrRenderTargetContext::clear(const SkIRect* rect,
const GrColor color,
- bool canIgnoreRect) {
+ CanClearFullscreen canClearFullscreen) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "clear", fContext);
AutoCheckFlush acf(this->drawingManager());
- this->internalClear(rect ? GrFixedClip(*rect) : GrFixedClip::Disabled(), color, canIgnoreRect);
+ this->internalClear(rect ? GrFixedClip(*rect) : GrFixedClip::Disabled(), color,
+ canClearFullscreen);
}
void GrRenderTargetContextPriv::absClear(const SkIRect* clearRect, const GrColor color) {
@@ -319,7 +320,7 @@
void GrRenderTargetContextPriv::clear(const GrFixedClip& clip,
const GrColor color,
- bool canIgnoreClip) {
+ CanClearFullscreen canClearFullscreen) {
ASSERT_SINGLE_OWNER_PRIV
RETURN_IF_ABANDONED_PRIV
SkDEBUGCODE(fRenderTargetContext->validate();)
@@ -327,16 +328,17 @@
fRenderTargetContext->fContext);
AutoCheckFlush acf(fRenderTargetContext->drawingManager());
- fRenderTargetContext->internalClear(clip, color, canIgnoreClip);
+ fRenderTargetContext->internalClear(clip, color, canClearFullscreen);
}
void GrRenderTargetContext::internalClear(const GrFixedClip& clip,
const GrColor color,
- bool canIgnoreClip) {
+ CanClearFullscreen canClearFullscreen) {
bool isFull = false;
if (!clip.hasWindowRectangles()) {
isFull = !clip.scissorEnabled() ||
- (canIgnoreClip && fContext->caps()->fullClearIsFree()) ||
+ (CanClearFullscreen::kYes == canClearFullscreen &&
+ fContext->caps()->preferFullscreenClears()) ||
clip.scissorRect().contains(SkIRect::MakeWH(this->width(), this->height()));
}
@@ -519,7 +521,8 @@
// Will it blend?
GrColor clearColor;
if (paint.isConstantBlendedColor(&clearColor)) {
- this->clear(nullptr, clearColor, true);
+ this->clear(nullptr, clearColor,
+ GrRenderTargetContext::CanClearFullscreen::kYes);
return;
}
}
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 127063e..304e6bc 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -79,14 +79,19 @@
*/
void discard();
+ enum class CanClearFullscreen : bool {
+ kNo = false,
+ kYes = true
+ };
+
/**
* Clear the entire or rect of the render target, ignoring any clips.
* @param rect the rect to clear or the whole thing if rect is NULL.
* @param color the color to clear to.
- * @param canIgnoreRect allows partial clears to be converted to whole
- * clears on platforms for which that is cheap
+ * @param CanClearFullscreen allows partial clears to be converted to fullscreen clears on
+ * tiling platforms where that is an optimization.
*/
- void clear(const SkIRect* rect, GrColor color, bool canIgnoreRect);
+ void clear(const SkIRect* rect, GrColor color, CanClearFullscreen);
/**
* Draw everywhere (respecting the clip) with the paint.
@@ -409,7 +414,7 @@
friend void test_draw_op(GrRenderTargetContext*, std::unique_ptr<GrFragmentProcessor>,
sk_sp<GrTextureProxy>);
- void internalClear(const GrFixedClip&, const GrColor, bool canIgnoreClip);
+ void internalClear(const GrFixedClip&, const GrColor, CanClearFullscreen);
// Only consumes the GrPaint if successful.
bool drawFilledDRRect(const GrClip& clip,
diff --git a/src/gpu/GrRenderTargetContextPriv.h b/src/gpu/GrRenderTargetContextPriv.h
index 41fc725..52f5497 100644
--- a/src/gpu/GrRenderTargetContextPriv.h
+++ b/src/gpu/GrRenderTargetContextPriv.h
@@ -43,7 +43,9 @@
opList->fLastClipNumAnalyticFPs != numClipAnalyticFPs;
}
- void clear(const GrFixedClip&, const GrColor, bool canIgnoreClip);
+ using CanClearFullscreen = GrRenderTargetContext::CanClearFullscreen;
+
+ void clear(const GrFixedClip&, const GrColor, CanClearFullscreen);
void clearStencilClip(const GrFixedClip&, bool insideStencilMask);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 3e16558..3d5540d 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -232,7 +232,7 @@
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext.get());
SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
- fRenderTargetContext->clear(&rect, 0x0, true);
+ fRenderTargetContext->clear(&rect, 0x0, GrRenderTargetContext::CanClearFullscreen::kYes);
}
void SkGpuDevice::replaceRenderTargetContext(bool shouldRetainContent) {
diff --git a/src/gpu/ccpr/GrCCPRAtlas.cpp b/src/gpu/ccpr/GrCCPRAtlas.cpp
index 8978e31..497241d 100644
--- a/src/gpu/ccpr/GrCCPRAtlas.cpp
+++ b/src/gpu/ccpr/GrCCPRAtlas.cpp
@@ -116,7 +116,7 @@
}
SkIRect clearRect = SkIRect::MakeSize(fDrawBounds);
- rtc->clear(&clearRect, 0, true);
+ rtc->clear(&clearRect, 0, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->addDrawOp(GrNoClip(), std::move(atlasOp));
fTextureProxy = sk_ref_sp(rtc->asTextureProxy());
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 3a51eb0..efc6628 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -152,8 +152,10 @@
fInvalidateFBType = kDiscard_InvalidateFBType;
}
- if (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor()) {
- fFullClearIsFree = true;
+ if (kARM_GrGLVendor == ctxInfo.vendor() ||
+ kImagination_GrGLVendor == ctxInfo.vendor() ||
+ kQualcomm_GrGLVendor == ctxInfo.vendor() ) {
+ fPreferFullscreenClears = true;
}
if (kGL_GrGLStandard == standard) {