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

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

Issue 14233006: Perform coverage blend with the dst in the shader when using a dst-reading xfermode. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 97
98 if (readsDst) { 98 if (readsDst) {
99 GrAssert(NULL != dstCopy); 99 GrAssert(NULL != dstCopy);
100 desc->fDstRead = GrGLShaderBuilder::KeyForDstRead(dstCopy->texture(), gp u->glCaps()); 100 desc->fDstRead = GrGLShaderBuilder::KeyForDstRead(dstCopy->texture(), gp u->glCaps());
101 GrAssert(0 != desc->fDstRead); 101 GrAssert(0 != desc->fDstRead);
102 } else { 102 } else {
103 desc->fDstRead = 0; 103 desc->fDstRead = 0;
104 } 104 }
105 105
106 desc->fDualSrcOutput = kNone_DualSrcOutput; 106 desc->fCoverageOutput = kModulate_CoverageOutput;
107 107
108 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything 108 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything
109 // other than pass through values from the VS to the FS anyway). 109 // other than pass through values from the VS to the FS anyway).
110 #if GR_GL_EXPERIMENTAL_GS 110 #if GR_GL_EXPERIMENTAL_GS
111 #if 0 111 #if 0
112 desc->fExperimentalGS = gpu->caps().geometryShaderSupport(); 112 desc->fExperimentalGS = gpu->caps().geometryShaderSupport();
113 #else 113 #else
114 desc->fExperimentalGS = false; 114 desc->fExperimentalGS = false;
115 #endif 115 #endif
116 #endif 116 #endif
(...skipping 27 matching lines...) Expand all
144 if (drawState.getStencil().doesWrite()) { 144 if (drawState.getStencil().doesWrite()) {
145 desc->fDiscardIfZeroCoverage = true; 145 desc->fDiscardIfZeroCoverage = true;
146 desc->fFirstCoverageStage = firstCoverageStage; 146 desc->fFirstCoverageStage = firstCoverageStage;
147 } 147 }
148 148
149 if (gpu->caps()->dualSourceBlendingSupport() && 149 if (gpu->caps()->dualSourceBlendingSupport() &&
150 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | 150 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag |
151 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) { 151 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) {
152 if (kZero_GrBlendCoeff == dstCoeff) { 152 if (kZero_GrBlendCoeff == dstCoeff) {
153 // write the coverage value to second color 153 // write the coverage value to second color
154 desc->fDualSrcOutput = kCoverage_DualSrcOutput; 154 desc->fCoverageOutput = kSecondaryCoverage_CoverageOutput;
155 desc->fFirstCoverageStage = firstCoverageStage; 155 desc->fFirstCoverageStage = firstCoverageStage;
156 } else if (kSA_GrBlendCoeff == dstCoeff) { 156 } else if (kSA_GrBlendCoeff == dstCoeff) {
157 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. 157 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
158 desc->fDualSrcOutput = kCoverageISA_DualSrcOutput; 158 desc->fCoverageOutput = kSecondaryCoverageISA_CoverageOutput;
159 desc->fFirstCoverageStage = firstCoverageStage; 159 desc->fFirstCoverageStage = firstCoverageStage;
160 } else if (kSC_GrBlendCoeff == dstCoeff) { 160 } else if (kSC_GrBlendCoeff == dstCoeff) {
161 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. 161 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
162 desc->fDualSrcOutput = kCoverageISC_DualSrcOutput; 162 desc->fCoverageOutput = kSecondaryCoverageISC_CoverageOutput;
163 desc->fFirstCoverageStage = firstCoverageStage; 163 desc->fFirstCoverageStage = firstCoverageStage;
164 } 164 }
165 } else if (readsDst &&
166 kOne_GrBlendCoeff == drawState.getSrcBlendCoeff() &&
167 kZero_GrBlendCoeff == drawState.getDstBlendCoeff()) {
168 desc->fCoverageOutput = kCombineWithDst_CoverageOutput;
169 desc->fFirstCoverageStage = firstCoverageStage;
165 } 170 }
166 } 171 }
167 172
168 desc->fPositionAttributeIndex = drawState.positionAttributeIndex(); 173 desc->fPositionAttributeIndex = drawState.positionAttributeIndex();
169 desc->fLocalCoordAttributeIndex = drawState.localCoordAttributeIndex(); 174 desc->fLocalCoordAttributeIndex = drawState.localCoordAttributeIndex();
170 175
171 // For constant color and coverage we need an attribute with an index beyond those already set 176 // For constant color and coverage we need an attribute with an index beyond those already set
172 int availableAttributeIndex = drawState.getVertexAttribCount(); 177 int availableAttributeIndex = drawState.getVertexAttribCount();
173 if (requiresColorAttrib) { 178 if (requiresColorAttrib) {
174 desc->fColorAttributeIndex = drawState.colorVertexAttributeIndex(); 179 desc->fColorAttributeIndex = drawState.colorVertexAttributeIndex();
175 } else if (GrGLProgramDesc::kAttribute_ColorInput == desc->fColorInput) { 180 } else if (GrGLProgramDesc::kAttribute_ColorInput == desc->fColorInput) {
176 GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); 181 GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
177 desc->fColorAttributeIndex = availableAttributeIndex; 182 desc->fColorAttributeIndex = availableAttributeIndex;
178 availableAttributeIndex++; 183 availableAttributeIndex++;
179 } else { 184 } else {
180 desc->fColorAttributeIndex = -1; 185 desc->fColorAttributeIndex = -1;
181 } 186 }
182 187
183 if (requiresCoverageAttrib) { 188 if (requiresCoverageAttrib) {
184 desc->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex() ; 189 desc->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex() ;
185 } else if (GrGLProgramDesc::kAttribute_ColorInput == desc->fCoverageInput) { 190 } else if (GrGLProgramDesc::kAttribute_ColorInput == desc->fCoverageInput) {
186 GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); 191 GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
187 desc->fCoverageAttributeIndex = availableAttributeIndex; 192 desc->fCoverageAttributeIndex = availableAttributeIndex;
188 } else { 193 } else {
189 desc->fCoverageAttributeIndex = -1; 194 desc->fCoverageAttributeIndex = -1;
190 } 195 }
191 } 196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698