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

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

Issue 545693004: Calculate stage stats in GrOptDrawState (Closed) Base URL: https://skia.googlesource.com/skia.git@connectOpt2
Patch Set: Update from recent gpu changes Created 6 years, 3 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
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 "GrDrawState.h" 10 #include "GrDrawState.h"
(...skipping 26 matching lines...) Expand all
37 37
38 if (drawState.hasGeometryProcessor()) { 38 if (drawState.hasGeometryProcessor()) {
39 fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*drawState.getGeomet ryProcessor()))); 39 fGeometryProcessor.reset(SkNEW_ARGS(GrEffectStage, (*drawState.getGeomet ryProcessor())));
40 } else { 40 } else {
41 fGeometryProcessor.reset(NULL); 41 fGeometryProcessor.reset(NULL);
42 } 42 }
43 43
44 this->copyEffectiveColorStages(drawState); 44 this->copyEffectiveColorStages(drawState);
45 this->copyEffectiveCoverageStages(drawState); 45 this->copyEffectiveCoverageStages(drawState);
46 this->adjustFromBlendOpts(); 46 this->adjustFromBlendOpts();
47 this->getStageStats();
47 }; 48 };
48 49
49 void GrOptDrawState::adjustFromBlendOpts() { 50 void GrOptDrawState::adjustFromBlendOpts() {
50 51
51 switch (fBlendOptFlags) { 52 switch (fBlendOptFlags) {
52 case kNone_BlendOpt: 53 case kNone_BlendOpt:
53 case kSkipDraw_BlendOptFlag: 54 case kSkipDraw_BlendOptFlag:
54 break; 55 break;
55 case kCoverageAsAlpha_BlendOptFlag: 56 case kCoverageAsAlpha_BlendOptFlag:
56 fFlagBits |= kCoverageDrawing_StateBit; 57 fFlagBits |= kCoverageDrawing_StateBit;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 173 }
173 #endif 174 #endif
174 if (ds.numCoverageStages() > 0) { 175 if (ds.numCoverageStages() > 0) {
175 fCoverageStages.reset(&ds.getCoverageStage(firstCoverageStage), 176 fCoverageStages.reset(&ds.getCoverageStage(firstCoverageStage),
176 ds.numCoverageStages() - firstCoverageStage); 177 ds.numCoverageStages() - firstCoverageStage);
177 } else { 178 } else {
178 fCoverageStages.reset(); 179 fCoverageStages.reset();
179 } 180 }
180 } 181 }
181 182
183 static void get_stage_stats(const GrEffectStage& stage, bool* readsDst,
184 bool* readsFragPosition, bool* requiresVertexShader) {
185 if (stage.getEffect()->willReadDstColor()) {
186 *readsDst = true;
187 }
188 if (stage.getEffect()->willReadFragmentPosition()) {
189 *readsFragPosition = true;
190 }
191 if (stage.getEffect()->requiresVertexShader()) {
192 *requiresVertexShader = true;
193 }
194 }
195 void GrOptDrawState::getStageStats() {
196 fReadsDst = false;
197 fReadsFragPosition = false;
198 fRequiresVertexShader = false;
199
200 for (int s = 0; s < this->numColorStages(); ++s) {
201 const GrEffectStage& stage = this->getColorStage(s);
202 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition, &fRequiresVertex Shader);
203 }
204 for (int s = 0; s < this->numCoverageStages(); ++s) {
205 const GrEffectStage& stage = this->getCoverageStage(s);
206 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition, &fRequiresVertex Shader);
207 }
208 // TODO: Once non Geom Processors can't be vertex effects we can remove this assert
209 SkASSERT(!fRequiresVertexShader);
210 if (this->hasGeometryProcessor()) {
211 const GrEffectStage& stage = *this->getGeometryProcessor();
212 get_stage_stats(stage, &fReadsDst, &fReadsFragPosition, &fRequiresVertex Shader);
213 SkASSERT(fRequiresVertexShader);
214 }
215 // TODO: Once we have actually separate GP's from other effects we can just set
216 // fRequiresVertexShader to be hasGeometryProcessor (or actaully just drop t he bool all
217 // together and just check for GP when needed.
218 SkASSERT(this->hasGeometryProcessor() == fRequiresVertexShader);
219 }
220
182 bool GrOptDrawState::operator== (const GrOptDrawState& that) const { 221 bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
183 return this->isEqual(that); 222 return this->isEqual(that);
184 } 223 }
185 224
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698