Add a cap for when dual sided stencil refs and masks must match

Change-Id: Ice00a00cd7185131578669e9c1ca865341f0ed0f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/283274
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/GrOpsRenderPass.cpp b/src/gpu/GrOpsRenderPass.cpp
index 060b9fc..66e346b 100644
--- a/src/gpu/GrOpsRenderPass.cpp
+++ b/src/gpu/GrOpsRenderPass.cpp
@@ -77,6 +77,15 @@
     if (programInfo.pipeline().isWireframe()) {
          SkASSERT(this->gpu()->caps()->wireframeSupport());
     }
+    if (this->gpu()->caps()->twoSidedStencilRefsAndMasksMustMatch() &&
+        programInfo.pipeline().isStencilEnabled()) {
+        const GrUserStencilSettings* stencil = programInfo.pipeline().getUserStencil();
+        if (stencil->isTwoSided(programInfo.pipeline().hasStencilClip())) {
+            SkASSERT(stencil->fCCWFace.fRef == stencil->fCWFace.fRef);
+            SkASSERT(stencil->fCCWFace.fTestMask == stencil->fCWFace.fTestMask);
+            SkASSERT(stencil->fCCWFace.fWriteMask == stencil->fCWFace.fWriteMask);
+        }
+    }
     if (GrPrimitiveType::kPatches == programInfo.primitiveType()) {
         SkASSERT(this->gpu()->caps()->shaderCaps()->tessellationSupport());
     }