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
This commit is contained in:
commit-bot@chromium.org 2014-02-05 16:29:12 +00:00
parent 76f10a3bd9
commit 8a13588b6f
4 changed files with 1 additions and 24 deletions

View File

@ -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();

View File

@ -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))) {

View File

@ -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;

View File

@ -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;