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

Unified Diff: src/gpu/GrOptDrawState.cpp

Issue 545693004: Calculate stage stats in GrOptDrawState (Closed) Base URL: https://skia.googlesource.com/skia.git@connectOpt2
Patch Set: Nit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrOptDrawState.cpp
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 5f352966b8a3441d5faf603c6234788dc2e23db6..cb03d2d683005dfe063bbedf49cf0cd53b8e933a 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -44,6 +44,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
this->copyEffectiveColorStages(drawState);
this->copyEffectiveCoverageStages(drawState);
this->adjustFromBlendOpts();
+ this->getStageStats();
};
void GrOptDrawState::adjustFromBlendOpts() {
@@ -179,6 +180,41 @@ void GrOptDrawState::copyEffectiveCoverageStages(const GrDrawState& ds) {
}
}
+static void get_stage_stats(const GrEffectStage& stage, bool* readsDst, bool* readsFragPosition) {
+ if (stage.getEffect()->willReadDstColor()) {
+ *readsDst = true;
+ }
+ if (stage.getEffect()->willReadFragmentPosition()) {
+ *readsFragPosition = true;
+ }
+}
+void GrOptDrawState::getStageStats() {
+ // We will need a local coord attrib if there is one currently set on the optState and we are
+ // actually generating some effect code
+ fRequiresLocalCoordAttrib = this->hasLocalCoordAttribute() && this->numTotalStages() > 0;
+
+ // if 1 == fVACount then that VA must be position, otherwise it contains some attribute which
+ // will require a vertexShader
+ fRequiresVertexShader = fVACount > 1;
+
+ fReadsDst = false;
+ fReadsFragPosition = false;
+
+ for (int s = 0; s < this->numColorStages(); ++s) {
+ const GrEffectStage& stage = this->getColorStage(s);
+ get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
+ }
+ for (int s = 0; s < this->numCoverageStages(); ++s) {
+ const GrEffectStage& stage = this->getCoverageStage(s);
+ get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
+ }
+ if (this->hasGeometryProcessor()) {
+ const GrEffectStage& stage = *this->getGeometryProcessor();
+ get_stage_stats(stage, &fReadsDst, &fReadsFragPosition);
+ SkASSERT(fRequiresVertexShader);
+ }
+}
+
bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
return this->isEqual(that);
}
« no previous file with comments | « src/gpu/GrOptDrawState.h ('k') | src/gpu/gl/GrGLProgramDesc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698