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

Side by Side Diff: src/gpu/GrOptDrawState.cpp

Issue 699023003: remove separate color from coverage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 6 years, 1 month 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
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/gl/GrGLProgramDesc.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 2014 Google Inc. 2 * Copyright 2014 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 "GrOptDrawState.h" 8 #include "GrOptDrawState.h"
9 9
10 #include "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
(...skipping 26 matching lines...) Expand all
37 37
38 memcpy(descInfo.fFixedFunctionVertexAttribIndices, 38 memcpy(descInfo.fFixedFunctionVertexAttribIndices,
39 drawState.getFixedFunctionVertexAttribIndices(), 39 drawState.getFixedFunctionVertexAttribIndices(),
40 sizeof(descInfo.fFixedFunctionVertexAttribIndices)); 40 sizeof(descInfo.fFixedFunctionVertexAttribIndices));
41 41
42 descInfo.fInputColorIsUsed = true; 42 descInfo.fInputColorIsUsed = true;
43 descInfo.fInputCoverageIsUsed = true; 43 descInfo.fInputCoverageIsUsed = true;
44 44
45 int firstColorStageIdx = 0; 45 int firstColorStageIdx = 0;
46 int firstCoverageStageIdx = 0; 46 int firstCoverageStageIdx = 0;
47 bool separateCoverageFromColor;
48 47
49 uint8_t fixedFunctionVAToRemove = 0; 48 uint8_t fixedFunctionVAToRemove = 0;
50 49
51 this->computeEffectiveColorStages(drawState, &descInfo, &firstColorStageIdx, 50 this->computeEffectiveColorStages(drawState, &descInfo, &firstColorStageIdx,
52 &fixedFunctionVAToRemove); 51 &fixedFunctionVAToRemove);
53 this->computeEffectiveCoverageStages(drawState, &descInfo, &firstCoverageSta geIdx); 52 this->computeEffectiveCoverageStages(drawState, &descInfo, &firstCoverageSta geIdx);
54 this->adjustFromBlendOpts(drawState, &descInfo, &firstColorStageIdx, &firstC overageStageIdx, 53 this->adjustFromBlendOpts(drawState, &descInfo, &firstColorStageIdx, &firstC overageStageIdx,
55 &fixedFunctionVAToRemove); 54 &fixedFunctionVAToRemove);
56 // Should not be setting any more FFVA to be removed at this point 55 // Should not be setting any more FFVA to be removed at this point
57 if (0 != fixedFunctionVAToRemove) { 56 if (0 != fixedFunctionVAToRemove) {
58 this->removeFixedFunctionVertexAttribs(fixedFunctionVAToRemove, &descInf o); 57 this->removeFixedFunctionVertexAttribs(fixedFunctionVAToRemove, &descInf o);
59 } 58 }
60 this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, &d escInfo); 59 this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, &d escInfo);
61 this->setOutputStateInfo(drawState, *gpu->caps(), firstCoverageStageIdx, &de scInfo,
62 &separateCoverageFromColor);
63 60
64 // Copy GeometryProcesssor from DS or ODS 61 // Copy GeometryProcesssor from DS or ODS
65 if (drawState.hasGeometryProcessor()) { 62 if (drawState.hasGeometryProcessor()) {
66 fGeometryProcessor.initAndRef(drawState.fGeometryProcessor); 63 fGeometryProcessor.initAndRef(drawState.fGeometryProcessor);
67 } else if (!GrGpu::IsPathRenderingDrawType(drawType)) { 64 } else if (!GrGpu::IsPathRenderingDrawType(drawType)) {
68 // Install default GP, this will be ignored if we are rendering with fra gment shader only 65 // Install default GP, this will be ignored if we are rendering with fra gment shader only
69 // TODO(joshualitt) rendering code should do this 66 // TODO(joshualitt) rendering code should do this
70 fGeometryProcessor.reset(GrDefaultGeoProcFactory::Create()); 67 fGeometryProcessor.reset(GrDefaultGeoProcFactory::Create());
71 } else { 68 } else {
72 fGeometryProcessor.reset(NULL); 69 fGeometryProcessor.reset(NULL);
73 } 70 }
74 71
75 // Copy Color Stages from DS to ODS 72 // Copy Color Stages from DS to ODS
76 if (firstColorStageIdx < drawState.numColorStages()) { 73 if (firstColorStageIdx < drawState.numColorStages()) {
77 fFragmentStages.reset(&drawState.getColorStage(firstColorStageIdx), 74 fFragmentStages.reset(&drawState.getColorStage(firstColorStageIdx),
78 drawState.numColorStages() - firstColorStageIdx); 75 drawState.numColorStages() - firstColorStageIdx);
79 } else { 76 } else {
80 fFragmentStages.reset(); 77 fFragmentStages.reset();
81 } 78 }
82 79
83 fNumColorStages = fFragmentStages.count(); 80 fNumColorStages = fFragmentStages.count();
84 81
85 // Copy Coverage Stages from DS to ODS 82 // Copy Coverage Stages from DS to ODS
86 if (firstCoverageStageIdx < drawState.numCoverageStages()) { 83 if (firstCoverageStageIdx < drawState.numCoverageStages()) {
87 fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverag eStageIdx, 84 fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverag eStageIdx,
88 &drawState.getCoverageStage(firstCoverageSta geIdx)); 85 &drawState.getCoverageStage(firstCoverageSta geIdx));
89 if (!separateCoverageFromColor) {
90 fNumColorStages = fFragmentStages.count();
91 }
92 } 86 }
93 87
88 this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo);
89
94 // now create a key 90 // now create a key
95 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc); 91 gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc);
96 }; 92 };
97 93
98 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState, 94 GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState,
99 GrGpu* gpu, 95 GrGpu* gpu,
100 const GrDeviceCoordTexture* dstCopy, 96 const GrDeviceCoordTexture* dstCopy,
101 GrGpu::DrawType drawType) { 97 GrGpu::DrawType drawType) {
102 const GrDrawTargetCaps& caps = *gpu->caps(); 98 const GrDrawTargetCaps& caps = *gpu->caps();
103 if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCa chedCapsID) { 99 if (NULL == drawState.fCachedOptState || caps.getUniqueID() != drawState.fCa chedCapsID) {
(...skipping 25 matching lines...) Expand all
129 SkASSERT(GrOptDrawState(drawState, blendFlags, srcCoeff, dstCoeff, gpu, dstCopy, 125 SkASSERT(GrOptDrawState(drawState, blendFlags, srcCoeff, dstCoeff, gpu, dstCopy,
130 drawType) == *drawState.fCachedOptState); 126 drawType) == *drawState.fCachedOptState);
131 #endif 127 #endif
132 } 128 }
133 drawState.fCachedOptState->ref(); 129 drawState.fCachedOptState->ref();
134 return drawState.fCachedOptState; 130 return drawState.fCachedOptState;
135 } 131 }
136 132
137 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds, 133 void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
138 const GrDrawTargetCaps& caps, 134 const GrDrawTargetCaps& caps,
139 int firstCoverageStageIdx, 135 GrProgramDesc::DescInfo* descInfo) {
140 GrProgramDesc::DescInfo* descInfo,
141 bool* separateCoverageFromColor) {
142 // Set this default and then possibly change our mind if there is coverage. 136 // Set this default and then possibly change our mind if there is coverage.
143 descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType; 137 descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType;
144 descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType; 138 descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType;
145 139
146 // If we do have coverage determine whether it matters. 140 // If we do have coverage determine whether it matters. Dual source blendin g is expensive so
147 *separateCoverageFromColor = this->hasGeometryProcessor(); 141 // we don't do it if we are doing coverage drawing. If we aren't then We al ways do dual source
148 if (!this->isCoverageDrawing() && 142 // blending if we have any effective coverage stages OR the geometry process or doesn't emits
149 (ds.numCoverageStages() - firstCoverageStageIdx > 0 || 143 // solid coverage.
150 ds.hasGeometryProcessor() || 144 // TODO move the gp logic into the GP base class
151 descInfo->hasCoverageVertexAttribute())) { 145 if (!this->isCoverageDrawing() && (this->numCoverageStages() || !ds.hasSolid Coverage())) {
bsalomon 2014/11/10 20:13:41 Do we need this->numCoverageStages()? Seems like
joshualitt 2014/11/10 20:17:16 We could actually JUST do that test, but its a bit
152
153 if (caps.dualSourceBlendingSupport()) { 146 if (caps.dualSourceBlendingSupport()) {
154 if (kZero_GrBlendCoeff == fDstBlend) { 147 if (kZero_GrBlendCoeff == fDstBlend) {
155 // write the coverage value to second color 148 // write the coverage value to second color
156 descInfo->fSecondaryOutputType = GrProgramDesc::kCoverage_Second aryOutputType; 149 descInfo->fSecondaryOutputType = GrProgramDesc::kCoverage_Second aryOutputType;
157 *separateCoverageFromColor = true;
158 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; 150 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
159 } else if (kSA_GrBlendCoeff == fDstBlend) { 151 } else if (kSA_GrBlendCoeff == fDstBlend) {
160 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. 152 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
161 descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISA_Sec ondaryOutputType; 153 descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISA_Sec ondaryOutputType;
162 *separateCoverageFromColor = true;
163 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; 154 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
164 } else if (kSC_GrBlendCoeff == fDstBlend) { 155 } else if (kSC_GrBlendCoeff == fDstBlend) {
165 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered. 156 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
166 descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISC_Sec ondaryOutputType; 157 descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISC_Sec ondaryOutputType;
167 *separateCoverageFromColor = true;
168 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; 158 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
169 } 159 }
170 } else if (descInfo->fReadsDst && 160 } else if (descInfo->fReadsDst &&
171 kOne_GrBlendCoeff == fSrcBlend && 161 kOne_GrBlendCoeff == fSrcBlend &&
172 kZero_GrBlendCoeff == fDstBlend) { 162 kZero_GrBlendCoeff == fDstBlend) {
173 descInfo->fPrimaryOutputType = GrProgramDesc::kCombineWithDst_Primar yOutputType; 163 descInfo->fPrimaryOutputType = GrProgramDesc::kCombineWithDst_Primar yOutputType;
174 *separateCoverageFromColor = true;
175 } 164 }
176 } 165 }
177 } 166 }
178 167
179 void GrOptDrawState::adjustFromBlendOpts(const GrDrawState& ds, 168 void GrOptDrawState::adjustFromBlendOpts(const GrDrawState& ds,
180 GrProgramDesc::DescInfo* descInfo, 169 GrProgramDesc::DescInfo* descInfo,
181 int* firstColorStageIdx, 170 int* firstColorStageIdx,
182 int* firstCoverageStageIdx, 171 int* firstCoverageStageIdx,
183 uint8_t* fixedFunctionVAToRemove) { 172 uint8_t* fixedFunctionVAToRemove) {
184 switch (fBlendOptFlags) { 173 switch (fBlendOptFlags) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1; 376 bool explicitLocalCoords = this->fDesc.header().fLocalCoordAttributeIndex != -1;
388 for (int i = 0; i < this->numFragmentStages(); i++) { 377 for (int i = 0; i < this->numFragmentStages(); i++) {
389 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i), 378 if (!GrFragmentStage::AreCompatible(this->getFragmentStage(i), that.getF ragmentStage(i),
390 explicitLocalCoords)) { 379 explicitLocalCoords)) {
391 return false; 380 return false;
392 } 381 }
393 } 382 }
394 return true; 383 return true;
395 } 384 }
396 385
OLDNEW
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698