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

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: 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrOptDrawState.cpp
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 5f352966b8a3441d5faf603c6234788dc2e23db6..40a9509201e4b60a11bc9cdb5cf79bc508e1738e 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,44 @@ void GrOptDrawState::copyEffectiveCoverageStages(const GrDrawState& ds) {
}
}
+static void get_stage_stats(const GrEffectStage& stage, bool* readsDst,
+ bool* readsFragPosition, bool* requiresVertexShader) {
+ if (stage.getEffect()->willReadDstColor()) {
+ *readsDst = true;
+ }
+ if (stage.getEffect()->willReadFragmentPosition()) {
+ *readsFragPosition = true;
+ }
+ if (stage.getEffect()->requiresVertexShader()) {
+ *requiresVertexShader = true;
+ }
+}
+void GrOptDrawState::getStageStats() {
+ fReadsDst = false;
+ fReadsFragPosition = false;
+ fRequiresVertexShader = false;
+
+ for (int s = 0; s < this->numColorStages(); ++s) {
+ const GrEffectStage& stage = this->getColorStage(s);
+ get_stage_stats(stage, &fReadsDst, &fReadsFragPosition, &fRequiresVertexShader);
+ }
+ for (int s = 0; s < this->numCoverageStages(); ++s) {
+ const GrEffectStage& stage = this->getCoverageStage(s);
+ get_stage_stats(stage, &fReadsDst, &fReadsFragPosition, &fRequiresVertexShader);
+ }
+ // TODO: Once non Geom Processors can't be vertex effects we can remove this assert
+ SkASSERT(!fRequiresVertexShader);
+ if (this->hasGeometryProcessor()) {
+ const GrEffectStage& stage = *this->getGeometryProcessor();
+ get_stage_stats(stage, &fReadsDst, &fReadsFragPosition, &fRequiresVertexShader);
+ SkASSERT(fRequiresVertexShader);
+ }
+ // TODO: Once we have actually separate GP's from other effects we can just set
+ // fRequiresVertexShader to be hasGeometryProcessor (or actaully just drop the bool all
+ // together and just check for GP when needed.
+ SkASSERT(this->hasGeometryProcessor() == fRequiresVertexShader);
+}
+
bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
return this->isEqual(that);
}

Powered by Google App Engine
This is Rietveld 408576698