From 8a13588b6f41ba892bcf6e8ceef6b449c4a5d83d Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Wed, 5 Feb 2014 16:29:12 +0000 Subject: [PATCH] Stop discarding in frag shader when coverage is zero and stencil writes are enabled This fixes the corruption in the NVPR images here: http://108.170.217.252:10117/builders/Test-Win8-ShuttleA-GTX660-x86-Debug/builds/251/steps/CompareGMs/logs/stdio caused by: https://skia.googlesource.com/skia.git/+/65ee5f424cb4dabd453268902c00086605d77c1d The stencil path step writes inside and outside the clip when the clip is implemented by a coverage effect. The path cover step then doesn't write outside of the clip because the FS discards. This leaves stencil values outside of the clip non-zero which messed up subsequent path or clip draws to those samples. R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/154623002 git-svn-id: http://skia.googlecode.com/svn/trunk@13320 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/gl/GrGLProgram.cpp | 11 ----------- src/gpu/gl/GrGLProgramDesc.cpp | 9 +-------- src/gpu/gl/GrGLProgramDesc.h | 3 --- tests/GLProgramsTest.cpp | 2 -- 4 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index cac38b4bdd..6e9878a919 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -120,17 +120,6 @@ bool GrGLProgram::genProgram(GrGLShaderBuilder* builder, fDesc.numCoverageEffects(), &inCoverage)); - // discard if coverage is zero - if (header.fDiscardIfZeroCoverage && !inCoverage.isOnes()) { - if (inCoverage.isZeros()) { - // This is unfortunate. - builder->fsCodeAppend("\tdiscard;\n"); - } else { - builder->fsCodeAppendf("\tif (all(lessThanEqual(%s, vec4(0.0)))) {\n\t\tdiscard;\n\t}\n", - inCoverage.c_str()); - } - } - if (GrGLProgramDesc::CoverageOutputUsesSecondaryOutput(header.fCoverageOutput)) { const char* secondaryOutputName = builder->enableSecondaryOutput(); diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp index 381461a03b..b6029fe4ee 100644 --- a/src/gpu/gl/GrGLProgramDesc.cpp +++ b/src/gpu/gl/GrGLProgramDesc.cpp @@ -215,8 +215,7 @@ void GrGLProgramDesc::Build(const GrDrawState& drawState, // Here we deal with whether/how we handle color and coverage separately. - // Set these defaults and then possibly change our mind if there is coverage. - header->fDiscardIfZeroCoverage = false; + // Set this default and then possibly change our mind if there is coverage. header->fCoverageOutput = kModulate_CoverageOutput; // If we do have coverage determine whether it matters. @@ -224,12 +223,6 @@ void GrGLProgramDesc::Build(const GrDrawState& drawState, if (!drawState.isCoverageDrawing() && !skipCoverage && (drawState.numCoverageStages() > 0 || requiresCoverageAttrib)) { - // If we're stenciling then we want to discard samples that have zero coverage - if (drawState.getStencil().doesWrite()) { - header->fDiscardIfZeroCoverage = true; - separateCoverageFromColor = true; - } - if (gpu->caps()->dualSourceBlendingSupport() && !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | GrDrawState::kCoverageAsAlpha_BlendOptFlag))) { diff --git a/src/gpu/gl/GrGLProgramDesc.h b/src/gpu/gl/GrGLProgramDesc.h index ec3f097906..9116fdf66f 100644 --- a/src/gpu/gl/GrGLProgramDesc.h +++ b/src/gpu/gl/GrGLProgramDesc.h @@ -151,9 +151,6 @@ private: // effects that read the fragment position. // Otherwise, 0. - // should the FS discard if the coverage is zero (to avoid stencil manipulation) - SkBool8 fDiscardIfZeroCoverage; - ColorInput fColorInput : 8; ColorInput fCoverageInput : 8; CoverageOutput fCoverageOutput : 8; diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index f3207352df..24312eed8d 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -65,8 +65,6 @@ void GrGLProgramDesc::setRandom(SkRandom* random, header->fExperimentalGS = gpu->caps()->geometryShaderSupport() && random->nextBool(); #endif - header->fDiscardIfZeroCoverage = random->nextBool(); - bool useLocalCoords = random->nextBool() && currAttribIndex < GrDrawState::kMaxVertexAttribCnt; header->fLocalCoordAttributeIndex = useLocalCoords ? currAttribIndex++ : -1;