aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-03-02 08:49:19 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-02 15:28:02 +0000
commitbfafcba05a54e1bc9c3074353a155d61119d095c (patch)
tree1304d38dddb0253db2462028712db89aa5b21bbb /src/gpu
parentbb5af6b70086cca8cbaa17b6ecfd462be3ab0b9e (diff)
Determine whether any fp uses local coords in FragmentProcessorAnalysis rather than GrPipeline creation
Change-Id: I3b6253cd2b0081dfece51125082fd78f647e45e1 Reviewed-on: https://skia-review.googlesource.com/9133 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrPipeline.cpp7
-rw-r--r--src/gpu/GrProcOptInfo.cpp10
-rw-r--r--src/gpu/GrProcOptInfo.h13
-rw-r--r--src/gpu/GrProcessorSet.cpp6
-rw-r--r--src/gpu/GrProcessorSet.h2
5 files changed, 29 insertions, 9 deletions
diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp
index 0dcf20db74..60f80f8aa4 100644
--- a/src/gpu/GrPipeline.cpp
+++ b/src/gpu/GrPipeline.cpp
@@ -84,8 +84,6 @@ GrPipelineOptimizations GrPipeline::init(const InitArgs& args) {
colorFPsToEliminate = args.fProcessors->numColorFragmentProcessors();
}
- bool usesLocalCoords = false;
-
// Copy GrFragmentProcessors from GrPipelineBuilder to Pipeline, possibly removing some of the
// color fragment processors.
fNumColorProcessors = args.fProcessors->numColorFragmentProcessors() - colorFPsToEliminate;
@@ -100,17 +98,14 @@ GrPipelineOptimizations GrPipeline::init(const InitArgs& args) {
++i, ++currFPIdx) {
const GrFragmentProcessor* fp = args.fProcessors->colorFragmentProcessor(i);
fFragmentProcessors[currFPIdx].reset(fp);
- usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
}
for (int i = 0; i < args.fProcessors->numCoverageFragmentProcessors(); ++i, ++currFPIdx) {
const GrFragmentProcessor* fp = args.fProcessors->coverageFragmentProcessor(i);
fFragmentProcessors[currFPIdx].reset(fp);
- usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
}
if (const GrFragmentProcessor* fp = args.fAppliedClip->clipCoverageFragmentProcessor()) {
fFragmentProcessors[currFPIdx].reset(fp);
- usesLocalCoords = usesLocalCoords || fp->usesLocalCoords();
}
// Setup info we need to pass to GrPrimitiveProcessors that are used with this GrPipeline.
@@ -120,7 +115,7 @@ GrPipelineOptimizations GrPipeline::init(const InitArgs& args) {
optimizations.fFlags |= GrPipelineOptimizations::kUseOverrideColor_Flag;
optimizations.fOverrideColor = overrideColor;
}
- if (usesLocalCoords) {
+ if (args.fAnalysis->usesLocalCoords()) {
optimizations.fFlags |= GrPipelineOptimizations::kReadsLocalCoords_Flag;
}
if (SkToBool(optFlags & GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag)) {
diff --git a/src/gpu/GrProcOptInfo.cpp b/src/gpu/GrProcOptInfo.cpp
index 9eda9bbd12..902a7c77e4 100644
--- a/src/gpu/GrProcOptInfo.cpp
+++ b/src/gpu/GrProcOptInfo.cpp
@@ -12,7 +12,8 @@
void GrProcOptInfo::analyzeProcessors(const GrFragmentProcessor* const* processors, int cnt) {
for (int i = 0; i < cnt; ++i) {
bool knowCurrentOutput = fProcessorsVisitedWithKnownOutput == fTotalProcessorsVisited;
- if (!knowCurrentOutput && !fAllProcessorsCompatibleWithCoverageAsAlpha && !fIsOpaque) {
+ if (fUsesLocalCoords && !knowCurrentOutput &&
+ !fAllProcessorsCompatibleWithCoverageAsAlpha && !fIsOpaque) {
fTotalProcessorsVisited += cnt - i;
return;
}
@@ -21,12 +22,19 @@ void GrProcOptInfo::analyzeProcessors(const GrFragmentProcessor* const* processo
&fLastKnownOutputColor)) {
++fProcessorsVisitedWithKnownOutput;
fIsOpaque = fLastKnownOutputColor.isOpaque();
+ // We reset these since the caller is expected to not use the earlier fragment
+ // processors.
+ fAllProcessorsCompatibleWithCoverageAsAlpha = true;
+ fUsesLocalCoords = false;
} else if (fIsOpaque && !fp->preservesOpaqueInput()) {
fIsOpaque = false;
}
if (fAllProcessorsCompatibleWithCoverageAsAlpha && !fp->compatibleWithCoverageAsAlpha()) {
fAllProcessorsCompatibleWithCoverageAsAlpha = false;
}
+ if (fp->usesLocalCoords()) {
+ fUsesLocalCoords = true;
+ }
++fTotalProcessorsVisited;
}
}
diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h
index 304abae2b5..549fb7a60b 100644
--- a/src/gpu/GrProcOptInfo.h
+++ b/src/gpu/GrProcOptInfo.h
@@ -43,11 +43,23 @@ public:
void analyzeProcessors(const GrFragmentProcessor* const* processors, int cnt);
bool isOpaque() const { return fIsOpaque; }
+
+ /**
+ * Are all the fragment processors compatible with conflating coverage with color prior to the
+ * the first fragment processor. This result does not consider processors that should be
+ * eliminated as indicated by initialProcessorsToEliminate().
+ */
bool allProcessorsCompatibleWithCoverageAsAlpha() const {
return fAllProcessorsCompatibleWithCoverageAsAlpha;
}
/**
+ * Do any of the fragment processors require local coords. This result does not consider
+ * processors that should be eliminated as indicated by initialProcessorsToEliminate().
+ */
+ bool usesLocalCoords() const { return fUsesLocalCoords; }
+
+ /**
* If we detected that the result after the first N processors is a known color then we
* eliminate those N processors and replace the GrDrawOp's color input to the GrPipeline with
* the known output of the Nth processor, so that the Nth+1 fragment processor (or the XP if
@@ -84,6 +96,7 @@ private:
int fProcessorsVisitedWithKnownOutput = -1;
bool fIsOpaque = false;
bool fAllProcessorsCompatibleWithCoverageAsAlpha = true;
+ bool fUsesLocalCoords = false;
GrColor4f fLastKnownOutputColor;
};
diff --git a/src/gpu/GrProcessorSet.cpp b/src/gpu/GrProcessorSet.cpp
index 179456209f..c61fe8bc79 100644
--- a/src/gpu/GrProcessorSet.cpp
+++ b/src/gpu/GrProcessorSet.cpp
@@ -51,18 +51,20 @@ void GrProcessorSet::FragmentProcessorAnalysis::internalReset(const GrPipelineIn
fps += processors.fColorFragmentProcessorCnt;
int n = processors.numCoverageFragmentProcessors();
bool hasCoverageFP = n > 0;
- for (int i = 0; i < n && fCompatibleWithCoverageAsAlpha; ++i) {
+ fUsesLocalCoords = colorInfo.usesLocalCoords();
+ for (int i = 0; i < n; ++i) {
if (!fps[i]->compatibleWithCoverageAsAlpha()) {
fCompatibleWithCoverageAsAlpha = false;
// Other than tests that exercise atypical behavior we expect all coverage FPs to be
// compatible with the coverage-as-alpha optimization.
GrCapsDebugf(&caps, "Coverage FP is not compatible with coverage as alpha.\n");
- break;
}
+ fUsesLocalCoords |= fps[i]->usesLocalCoords();
}
if (clipFP) {
fCompatibleWithCoverageAsAlpha &= clipFP->compatibleWithCoverageAsAlpha();
+ fUsesLocalCoords |= clipFP->usesLocalCoords();
hasCoverageFP = true;
}
fInitialColorProcessorsToEliminate =
diff --git a/src/gpu/GrProcessorSet.h b/src/gpu/GrProcessorSet.h
index bd78dc927e..722bc048bd 100644
--- a/src/gpu/GrProcessorSet.h
+++ b/src/gpu/GrProcessorSet.h
@@ -71,6 +71,7 @@ public:
}
bool usesPLSDstRead() const { return fUsesPLSDstRead; }
+ bool usesLocalCoords() const { return fUsesLocalCoords; }
bool isCompatibleWithCoverageAsAlpha() const { return fCompatibleWithCoverageAsAlpha; }
bool isOutputColorOpaque() const {
return ColorType::kOpaque == fColorType || ColorType::kOpaqueConstant == fColorType;
@@ -96,6 +97,7 @@ public:
bool fUsesPLSDstRead = false;
bool fCompatibleWithCoverageAsAlpha = true;
+ bool fUsesLocalCoords = false;
CoverageType fCoverageType = CoverageType::kNone;
ColorType fColorType = ColorType::kUnknown;
int fInitialColorProcessorsToEliminate = 0;