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

Side by Side Diff: src/gpu/gl/GrGLProgramDesc.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 | « src/gpu/gl/GrGLProgramDesc.h ('k') | tests/GLProgramsTest.cpp » ('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 2013 Google Inc. 2 * Copyright 2013 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 "GrGLProgramDesc.h" 8 #include "GrGLProgramDesc.h"
9 #include "GrBackendEffectFactory.h" 9 #include "GrBackendEffectFactory.h"
10 #include "GrDrawEffect.h" 10 #include "GrDrawEffect.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 header->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex (); 208 header->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex ();
209 } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fCoverageInput) { 209 } else if (GrGLProgramDesc::kAttribute_ColorInput == header->fCoverageInput) {
210 SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); 210 SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
211 header->fCoverageAttributeIndex = availableAttributeIndex; 211 header->fCoverageAttributeIndex = availableAttributeIndex;
212 } else { 212 } else {
213 header->fCoverageAttributeIndex = -1; 213 header->fCoverageAttributeIndex = -1;
214 } 214 }
215 215
216 // Here we deal with whether/how we handle color and coverage separately. 216 // Here we deal with whether/how we handle color and coverage separately.
217 217
218 // Set these defaults and then possibly change our mind if there is coverage . 218 // Set this default and then possibly change our mind if there is coverage.
219 header->fDiscardIfZeroCoverage = false;
220 header->fCoverageOutput = kModulate_CoverageOutput; 219 header->fCoverageOutput = kModulate_CoverageOutput;
221 220
222 // If we do have coverage determine whether it matters. 221 // If we do have coverage determine whether it matters.
223 bool separateCoverageFromColor = false; 222 bool separateCoverageFromColor = false;
224 if (!drawState.isCoverageDrawing() && !skipCoverage && 223 if (!drawState.isCoverageDrawing() && !skipCoverage &&
225 (drawState.numCoverageStages() > 0 || requiresCoverageAttrib)) { 224 (drawState.numCoverageStages() > 0 || requiresCoverageAttrib)) {
226 225
227 // If we're stenciling then we want to discard samples that have zero co verage
228 if (drawState.getStencil().doesWrite()) {
229 header->fDiscardIfZeroCoverage = true;
230 separateCoverageFromColor = true;
231 }
232
233 if (gpu->caps()->dualSourceBlendingSupport() && 226 if (gpu->caps()->dualSourceBlendingSupport() &&
234 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | 227 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag |
235 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) { 228 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) {
236 if (kZero_GrBlendCoeff == dstCoeff) { 229 if (kZero_GrBlendCoeff == dstCoeff) {
237 // write the coverage value to second color 230 // write the coverage value to second color
238 header->fCoverageOutput = kSecondaryCoverage_CoverageOutput; 231 header->fCoverageOutput = kSecondaryCoverage_CoverageOutput;
239 separateCoverageFromColor = true; 232 separateCoverageFromColor = true;
240 } else if (kSA_GrBlendCoeff == dstCoeff) { 233 } else if (kSA_GrBlendCoeff == dstCoeff) {
241 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. 234 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
242 header->fCoverageOutput = kSecondaryCoverageISA_CoverageOutput; 235 header->fCoverageOutput = kSecondaryCoverageISA_CoverageOutput;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 273
281 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { 274 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) {
282 fInitialized = other.fInitialized; 275 fInitialized = other.fInitialized;
283 if (fInitialized) { 276 if (fInitialized) {
284 size_t keyLength = other.keyLength(); 277 size_t keyLength = other.keyLength();
285 fKey.reset(keyLength); 278 fKey.reset(keyLength);
286 memcpy(fKey.get(), other.fKey.get(), keyLength); 279 memcpy(fKey.get(), other.fKey.get(), keyLength);
287 } 280 }
288 return *this; 281 return *this;
289 } 282 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgramDesc.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698