Clear and discard stencil buffers on tilers, take 2
Bug: skia:
Change-Id: I6a3bc7e50f8d4f211ed4afb2a614581b2778b27a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/245300
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrOpsTask.h b/src/gpu/GrOpsTask.h
index a8588ce..80e4ffd 100644
--- a/src/gpu/GrOpsTask.h
+++ b/src/gpu/GrOpsTask.h
@@ -117,8 +117,30 @@
void deleteOps();
- // Must only be called if native stencil buffer clearing is enabled
- void setStencilLoadOp(GrLoadOp op) { fStencilLoadOp = op; }
+ enum class StencilContent {
+ kDontCare,
+ kUserBitsCleared, // User bits: cleared
+ // Clip bit: don't care (Ganesh always pre-clears the clip bit.)
+ kPreserved
+ };
+
+ // Lets the caller specify what the content of the stencil buffer should be at the beginning
+ // of the render pass.
+ //
+ // When requesting kClear: Tilers will load the stencil buffer with a "clear" op; non-tilers
+ // will clear the stencil on first load, and then preserve it on subsequent loads. (Preserving
+ // works because renderTargetContexts are required to leave the user bits in a cleared state
+ // once finished.)
+ //
+ // NOTE: initialContent must not be kClear if caps.performStencilClearsAsDraws() is true.
+ void setInitialStencilContent(StencilContent initialContent) {
+ fInitialStencilContent = initialContent;
+ }
+
+ // If a renderTargetContext splits its opsTask, it uses this method to guarantee stencil values
+ // get preserved across its split tasks.
+ void setMustPreserveStencil() { fMustPreserveStencil = true; }
+
// Must only be called if native color buffer clearing is enabled.
void setColorLoadOp(GrLoadOp op, const SkPMColor4f& color);
// Sets the clear color to transparent black
@@ -247,7 +269,8 @@
GrLoadOp fColorLoadOp = GrLoadOp::kLoad;
SkPMColor4f fLoadClearColor = SK_PMColor4fTRANSPARENT;
- GrLoadOp fStencilLoadOp = GrLoadOp::kLoad;
+ StencilContent fInitialStencilContent = StencilContent::kDontCare;
+ bool fMustPreserveStencil = false;
uint32_t fLastClipStackGenID;
SkIRect fLastDevClipBounds;