diff options
author | 2016-05-11 05:21:56 -0700 | |
---|---|---|
committer | 2016-05-11 05:21:56 -0700 | |
commit | e19aecdd13d83b2235faf3e2601100a2fd980b7b (patch) | |
tree | 75f24881e08d8c287b53bc3d055c68b3406ae8bf /src/gpu/gl | |
parent | 3e11da7fa9b7ab26df6d6197c3f6a71d0826c97e (diff) |
Revert of Separate user and raw stencil settings (patchset #8 id:140001 of https://codereview.chromium.org/1962243002/ )
Reason for revert:
This seems to be breaking nanobench on the Windows bots with:
Caught exception 3221225477 EXCEPTION_ACCESS_VIOLATION
GrDrawTarget::stencilPath +c7
GrStencilAndCoverPathRenderer::onDrawPath +fd
GrDrawContext::internalDrawPath +509
GrDrawContext::drawPath +223
GrBlurUtils::drawPathWithMaskFilter +250
SkGpuDevice::drawPath +2ea
SkCanvas::onDrawPath +2e3
SkRecordDraw +2e6
SkBigPicture::playback +e5
SkCanvas::onDrawPicture +12c
SkCanvas::drawPicture +145
SkRecordDraw +2e6
SkBigPicture::playback +e5
SkCanvas::onDrawPicture +12c
SkCanvas::drawPicture +145
SkRecordDraw +261
SkBigPicture::playback +e5
SkCanvas::onDrawPicture +12c
SkCanvas::drawPicture +145
SkMultiPictureDraw::draw +bf
SKPBench::drawMPDPicture +1e0
SKPBench::onDraw +34
Benchmark::draw +32
time +92
setup_gpu_bench +6e
nanobench_main +77b
Original issue's description:
> Separate user and raw stencil settings
>
> Adds a new GrUserStencilSettings class that describes in abstract terms
> how a draw will use the stencil (e.g. kAlwaysIfInClip, kSetClipBit,
> etc.). GrPipelineBuilder now only defines the GrUserStencilSettings.
> When the GrPipeline is finalized, the user stencil settings are then
> translated into concrete GrStencilSettings.
>
> At this point, GrClipMaskManager only needs to tell the GrAppliedClip
> whether or not there is a stencil clip. It does not need to modify
> stencil settings and GrPipelineBuilder does not need
> AutoRestoreStencil.
>
> This is one step of the stencil overhaul. In the future it will also
> allow us to clean up the special case handling for nvpr and the
> stateful fClipMode member of GrClipMaskManager.
>
> BUG=skia:
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1962243002
>
> Committed: https://skia.googlesource.com/skia/+/12dbb3947e1aaf205b4fcf13b40e54e50650eb37
TBR=bsalomon@google.com,cdalton@nvidia.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review-Url: https://codereview.chromium.org/1969693003
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 74 | ||||
-rw-r--r-- | src/gpu/gl/GrGLPathRendering.cpp | 37 | ||||
-rw-r--r-- | src/gpu/gl/GrGLPathRendering.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.cpp | 43 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.h | 4 |
5 files changed, 84 insertions, 76 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 6b03df3e10..004a4a90a5 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -2874,38 +2874,40 @@ namespace { GrGLenum gr_to_gl_stencil_op(GrStencilOp op) { - static const GrGLenum gTable[kGrStencilOpCount] = { - GR_GL_KEEP, // kKeep - GR_GL_ZERO, // kZero - GR_GL_REPLACE, // kReplace - GR_GL_INVERT, // kInvert - GR_GL_INCR_WRAP, // kIncWrap - GR_GL_DECR_WRAP, // kDecWrap - GR_GL_INCR, // kIncClamp - GR_GL_DECR, // kDecClamp + static const GrGLenum gTable[] = { + GR_GL_KEEP, // kKeep_StencilOp + GR_GL_REPLACE, // kReplace_StencilOp + GR_GL_INCR_WRAP, // kIncWrap_StencilOp + GR_GL_INCR, // kIncClamp_StencilOp + GR_GL_DECR_WRAP, // kDecWrap_StencilOp + GR_GL_DECR, // kDecClamp_StencilOp + GR_GL_ZERO, // kZero_StencilOp + GR_GL_INVERT, // kInvert_StencilOp }; - GR_STATIC_ASSERT(0 == (int)GrStencilOp::kKeep); - GR_STATIC_ASSERT(1 == (int)GrStencilOp::kZero); - GR_STATIC_ASSERT(2 == (int)GrStencilOp::kReplace); - GR_STATIC_ASSERT(3 == (int)GrStencilOp::kInvert); - GR_STATIC_ASSERT(4 == (int)GrStencilOp::kIncWrap); - GR_STATIC_ASSERT(5 == (int)GrStencilOp::kDecWrap); - GR_STATIC_ASSERT(6 == (int)GrStencilOp::kIncClamp); - GR_STATIC_ASSERT(7 == (int)GrStencilOp::kDecClamp); - SkASSERT(op < (GrStencilOp)kGrStencilOpCount); - return gTable[(int)op]; + GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kStencilOpCnt); + GR_STATIC_ASSERT(0 == kKeep_StencilOp); + GR_STATIC_ASSERT(1 == kReplace_StencilOp); + GR_STATIC_ASSERT(2 == kIncWrap_StencilOp); + GR_STATIC_ASSERT(3 == kIncClamp_StencilOp); + GR_STATIC_ASSERT(4 == kDecWrap_StencilOp); + GR_STATIC_ASSERT(5 == kDecClamp_StencilOp); + GR_STATIC_ASSERT(6 == kZero_StencilOp); + GR_STATIC_ASSERT(7 == kInvert_StencilOp); + SkASSERT((unsigned) op < kStencilOpCnt); + return gTable[op]; } void set_gl_stencil(const GrGLInterface* gl, - const GrStencilSettings::Face& face, - GrGLenum glFace) { - GrGLenum glFunc = GrToGLStencilFunc(face.fTest); - GrGLenum glFailOp = gr_to_gl_stencil_op(face.fFailOp); - GrGLenum glPassOp = gr_to_gl_stencil_op(face.fPassOp); + const GrStencilSettings& settings, + GrGLenum glFace, + GrStencilSettings::Face grFace) { + GrGLenum glFunc = GrToGLStencilFunc(settings.func(grFace)); + GrGLenum glFailOp = gr_to_gl_stencil_op(settings.failOp(grFace)); + GrGLenum glPassOp = gr_to_gl_stencil_op(settings.passOp(grFace)); - GrGLint ref = face.fRef; - GrGLint mask = face.fTestMask; - GrGLint writeMask = face.fWriteMask; + GrGLint ref = settings.funcRef(grFace); + GrGLint mask = settings.funcMask(grFace); + GrGLint writeMask = settings.writeMask(grFace); if (GR_GL_FRONT_AND_BACK == glFace) { // we call the combined func just in case separate stencil is not @@ -2935,18 +2937,20 @@ void GrGLGpu::flushStencil(const GrStencilSettings& stencilSettings) { } } if (!stencilSettings.isDisabled()) { - if (stencilSettings.isTwoSided()) { - SkASSERT(this->caps()->twoSidedStencilSupport()); + if (this->caps()->twoSidedStencilSupport()) { set_gl_stencil(this->glInterface(), - stencilSettings.front(), - GR_GL_FRONT); + stencilSettings, + GR_GL_FRONT, + GrStencilSettings::kFront_Face); set_gl_stencil(this->glInterface(), - stencilSettings.back(), - GR_GL_BACK); + stencilSettings, + GR_GL_BACK, + GrStencilSettings::kBack_Face); } else { set_gl_stencil(this->glInterface(), - stencilSettings.front(), - GR_GL_FRONT_AND_BACK); + stencilSettings, + GR_GL_FRONT_AND_BACK, + GrStencilSettings::kFront_Face); } } fHWStencilSettings = stencilSettings; diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp index 66648d8479..5616f9d58a 100644 --- a/src/gpu/gl/GrGLPathRendering.cpp +++ b/src/gpu/gl/GrGLPathRendering.cpp @@ -70,9 +70,9 @@ static GrGLenum gr_stencil_op_to_gl_path_rendering_fill_mode(GrStencilOp op) { default: SkFAIL("Unexpected path fill."); /* fallthrough */; - case GrStencilOp::kIncClamp: + case kIncClamp_StencilOp: return GR_GL_COUNT_UP; - case GrStencilOp::kInvert: + case kInvert_StencilOp: return GR_GL_INVERT; } } @@ -133,9 +133,9 @@ void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath* this->flushPathStencilSettings(*args.fStencil); SkASSERT(!fHWPathStencilSettings.isTwoSided()); - GrGLenum fillMode = - gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.front().fPassOp); - GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; + GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode( + fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); + GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); if (glPath->shouldFill()) { GL_CALL(StencilFillPath(glPath->pathID(), fillMode, writeMask)); @@ -157,9 +157,9 @@ void GrGLPathRendering::onDrawPath(const GrPipeline& pipeline, this->flushPathStencilSettings(stencil); SkASSERT(!fHWPathStencilSettings.isTwoSided()); - GrGLenum fillMode = - gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.front().fPassOp); - GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; + GrGLenum fillMode = gr_stencil_op_to_gl_path_rendering_fill_mode( + fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); + GrGLint writeMask = fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); if (glPath->shouldStroke()) { if (glPath->shouldFill()) { @@ -191,8 +191,10 @@ void GrGLPathRendering::onDrawPaths(const GrPipeline& pipeline, const GrGLPathRange* glPathRange = static_cast<const GrGLPathRange*>(pathRange); GrGLenum fillMode = - gr_stencil_op_to_gl_path_rendering_fill_mode(fHWPathStencilSettings.front().fPassOp); - GrGLint writeMask = fHWPathStencilSettings.front().fWriteMask; + gr_stencil_op_to_gl_path_rendering_fill_mode( + fHWPathStencilSettings.passOp(GrStencilSettings::kFront_Face)); + GrGLint writeMask = + fHWPathStencilSettings.writeMask(GrStencilSettings::kFront_Face); if (glPathRange->shouldStroke()) { if (glPathRange->shouldFill()) { @@ -320,15 +322,16 @@ void GrGLPathRendering::flushPathStencilSettings(const GrStencilSettings& stenci SkASSERT(stencilSettings.isValid()); // Just the func, ref, and mask is set here. The op and write mask are params to the call // that draws the path to the SB (glStencilFillPath) - uint16_t ref = stencilSettings.front().fRef; - GrStencilTest test = stencilSettings.front().fTest; - uint16_t testMask = stencilSettings.front().fTestMask; + const GrStencilSettings::Face kFront_Face = GrStencilSettings::kFront_Face; + GrStencilFunc func = stencilSettings.func(kFront_Face); + uint16_t funcRef = stencilSettings.funcRef(kFront_Face); + uint16_t funcMask = stencilSettings.funcMask(kFront_Face); if (!fHWPathStencilSettings.isValid() || - ref != fHWPathStencilSettings.front().fRef || - test != fHWPathStencilSettings.front().fTest || - testMask != fHWPathStencilSettings.front().fTestMask) { - GL_CALL(PathStencilFunc(GrToGLStencilFunc(test), ref, testMask)); + func != fHWPathStencilSettings.func(kFront_Face) || + funcRef != fHWPathStencilSettings.funcRef(kFront_Face) || + funcMask != fHWPathStencilSettings.funcMask(kFront_Face)) { + GL_CALL(PathStencilFunc(GrToGLStencilFunc(func), funcRef, funcMask)); } fHWPathStencilSettings = stencilSettings; } diff --git a/src/gpu/gl/GrGLPathRendering.h b/src/gpu/gl/GrGLPathRendering.h index 40f72ccd7b..8fb699deb3 100644 --- a/src/gpu/gl/GrGLPathRendering.h +++ b/src/gpu/gl/GrGLPathRendering.h @@ -10,12 +10,12 @@ #include "SkRefCnt.h" #include "GrPathRendering.h" +#include "GrStencil.h" #include "gl/GrGLTypes.h" #include "glsl/GrGLSLUtil.h" class GrGLNameAllocator; class GrGLGpu; -class GrStencilSettings; class GrStyle; /** diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp index ecc587b714..46b58f1d76 100644 --- a/src/gpu/gl/GrGLUtil.cpp +++ b/src/gpu/gl/GrGLUtil.cpp @@ -334,26 +334,27 @@ GrGLRenderer GrGLGetRenderer(const GrGLInterface* gl) { return GrGLGetRendererFromString((const char*) v); } -GrGLenum GrToGLStencilFunc(GrStencilTest test) { - static const GrGLenum gTable[kGrStencilTestCount] = { - GR_GL_ALWAYS, // kAlways - GR_GL_NEVER, // kNever - GR_GL_GREATER, // kGreater - GR_GL_GEQUAL, // kGEqual - GR_GL_LESS, // kLess - GR_GL_LEQUAL, // kLEqual - GR_GL_EQUAL, // kEqual - GR_GL_NOTEQUAL, // kNotEqual +GrGLenum GrToGLStencilFunc(GrStencilFunc basicFunc) { + static const GrGLenum gTable[] = { + GR_GL_ALWAYS, // kAlways_StencilFunc + GR_GL_NEVER, // kNever_StencilFunc + GR_GL_GREATER, // kGreater_StencilFunc + GR_GL_GEQUAL, // kGEqual_StencilFunc + GR_GL_LESS, // kLess_StencilFunc + GR_GL_LEQUAL, // kLEqual_StencilFunc, + GR_GL_EQUAL, // kEqual_StencilFunc, + GR_GL_NOTEQUAL, // kNotEqual_StencilFunc, }; - GR_STATIC_ASSERT(0 == (int)GrStencilTest::kAlways); - GR_STATIC_ASSERT(1 == (int)GrStencilTest::kNever); - GR_STATIC_ASSERT(2 == (int)GrStencilTest::kGreater); - GR_STATIC_ASSERT(3 == (int)GrStencilTest::kGEqual); - GR_STATIC_ASSERT(4 == (int)GrStencilTest::kLess); - GR_STATIC_ASSERT(5 == (int)GrStencilTest::kLEqual); - GR_STATIC_ASSERT(6 == (int)GrStencilTest::kEqual); - GR_STATIC_ASSERT(7 == (int)GrStencilTest::kNotEqual); - SkASSERT(test < (GrStencilTest)kGrStencilTestCount); - - return gTable[(int)test]; + GR_STATIC_ASSERT(SK_ARRAY_COUNT(gTable) == kBasicStencilFuncCnt); + GR_STATIC_ASSERT(0 == kAlways_StencilFunc); + GR_STATIC_ASSERT(1 == kNever_StencilFunc); + GR_STATIC_ASSERT(2 == kGreater_StencilFunc); + GR_STATIC_ASSERT(3 == kGEqual_StencilFunc); + GR_STATIC_ASSERT(4 == kLess_StencilFunc); + GR_STATIC_ASSERT(5 == kLEqual_StencilFunc); + GR_STATIC_ASSERT(6 == kEqual_StencilFunc); + GR_STATIC_ASSERT(7 == kNotEqual_StencilFunc); + SkASSERT((unsigned) basicFunc < kBasicStencilFuncCnt); + + return gTable[basicFunc]; } diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h index 98f738b091..c30ee93689 100644 --- a/src/gpu/gl/GrGLUtil.h +++ b/src/gpu/gl/GrGLUtil.h @@ -10,7 +10,7 @@ #include "gl/GrGLInterface.h" #include "GrGLDefines.h" -#include "GrStencilSettings.h" +#include "GrStencil.h" class SkMatrix; @@ -205,7 +205,7 @@ void GrGLClearErr(const GrGLInterface* gl); // call glGetError without doing a redundant error check or logging. #define GR_GL_GET_ERROR(IFACE) (IFACE)->fFunctions.fGetError() -GrGLenum GrToGLStencilFunc(GrStencilTest test); +GrGLenum GrToGLStencilFunc(GrStencilFunc basicFunc); #endif |