Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: src/gpu/gl/GrGLProgram.cpp

Issue 154623002: Stop discarding in frag shader when coverage is zero and stencil writes are enabled (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: save all the files Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLProgram.h" 8 #include "GrGLProgram.h"
9 9
10 #include "GrAllocator.h" 10 #include "GrAllocator.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 /////////////////////////////////////////////////////////////////////////// 113 ///////////////////////////////////////////////////////////////////////////
114 // compute the partial coverage 114 // compute the partial coverage
115 GrGLSLExpr4 inCoverage = builder->getInputCoverage(); 115 GrGLSLExpr4 inCoverage = builder->getInputCoverage();
116 116
117 fCoverageEffects.reset( 117 fCoverageEffects.reset(
118 builder->createAndEmitEffects(coverageStages, 118 builder->createAndEmitEffects(coverageStages,
119 fDesc.getEffectKeys() + fDesc.numColorEffe cts(), 119 fDesc.getEffectKeys() + fDesc.numColorEffe cts(),
120 fDesc.numCoverageEffects(), 120 fDesc.numCoverageEffects(),
121 &inCoverage)); 121 &inCoverage));
122 122
123 // discard if coverage is zero
124 if (header.fDiscardIfZeroCoverage && !inCoverage.isOnes()) {
125 if (inCoverage.isZeros()) {
126 // This is unfortunate.
127 builder->fsCodeAppend("\tdiscard;\n");
128 } else {
129 builder->fsCodeAppendf("\tif (all(lessThanEqual(%s, vec4(0.0)))) {\n \t\tdiscard;\n\t}\n",
130 inCoverage.c_str());
131 }
132 }
133
134 if (GrGLProgramDesc::CoverageOutputUsesSecondaryOutput(header.fCoverageOutpu t)) { 123 if (GrGLProgramDesc::CoverageOutputUsesSecondaryOutput(header.fCoverageOutpu t)) {
135 const char* secondaryOutputName = builder->enableSecondaryOutput(); 124 const char* secondaryOutputName = builder->enableSecondaryOutput();
136 125
137 // default coeff to ones for kCoverage_DualSrcOutput 126 // default coeff to ones for kCoverage_DualSrcOutput
138 GrGLSLExpr4 coeff(1); 127 GrGLSLExpr4 coeff(1);
139 if (GrGLProgramDesc::kSecondaryCoverageISA_CoverageOutput == header.fCov erageOutput) { 128 if (GrGLProgramDesc::kSecondaryCoverageISA_CoverageOutput == header.fCov erageOutput) {
140 // Get (1-A) into coeff 129 // Get (1-A) into coeff
141 coeff = GrGLSLExpr4::VectorCast(GrGLSLExpr1(1) - inColor.a()); 130 coeff = GrGLSLExpr4::VectorCast(GrGLSLExpr1(1) - inColor.a());
142 } else if (GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput == head er.fCoverageOutput) { 131 } else if (GrGLProgramDesc::kSecondaryCoverageISC_CoverageOutput == head er.fCoverageOutput) {
143 // Get (1-RGBA) into coeff 132 // Get (1-RGBA) into coeff
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 336
348 fMatrixState.fViewMatrix = drawState.getViewMatrix(); 337 fMatrixState.fViewMatrix = drawState.getViewMatrix();
349 fMatrixState.fRenderTargetSize = size; 338 fMatrixState.fRenderTargetSize = size;
350 fMatrixState.fRenderTargetOrigin = rt->origin(); 339 fMatrixState.fRenderTargetOrigin = rt->origin();
351 340
352 GrGLfloat viewMatrix[3 * 3]; 341 GrGLfloat viewMatrix[3 * 3];
353 fMatrixState.getGLMatrix<3>(viewMatrix); 342 fMatrixState.getGLMatrix<3>(viewMatrix);
354 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, viewMatrix); 343 fUniformManager.setMatrix3f(fUniformHandles.fViewMatrixUni, viewMatrix);
355 } 344 }
356 } 345 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698