aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-11-11 08:51:30 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-11 08:51:30 -0800
commit4dd99886420329fcacd72d87f2c46ff2555d0945 (patch)
treea9ca6881d454ad3ffa1b87b19beb374c8d118079
parent672550ddb6098ab39bb8b5c48d2dc08f00df4c6a (diff)
remove separate color from coverage
-rw-r--r--expectations/gm/ignored-tests.txt3
-rw-r--r--src/gpu/GrDrawState.cpp16
-rw-r--r--src/gpu/GrDrawState.h4
-rw-r--r--src/gpu/GrOptDrawState.cpp29
-rw-r--r--src/gpu/GrOptDrawState.h3
-rw-r--r--src/gpu/gl/GrGLProgramDesc.cpp22
6 files changed, 34 insertions, 43 deletions
diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt
index e524d331e4..f268a0f9c0 100644
--- a/expectations/gm/ignored-tests.txt
+++ b/expectations/gm/ignored-tests.txt
@@ -63,3 +63,6 @@ multipicturedraw_rrectclip_simple
multipicturedraw_rrectclip_tiled
multipicturedraw_sierpinski_simple
multipicturedraw_sierpinski_tiled
+
+#joshualitt
+hairmodes
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index c82c5adad1..1f9f6967c2 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -185,7 +185,7 @@ void GrDrawState::onReset(const SkMatrix* initialViewMatrix) {
}
bool GrDrawState::setIdentityViewMatrix() {
- if (this->numTotalStages()) {
+ if (this->numFragmentStages()) {
SkMatrix invVM;
if (!fViewMatrix.invert(&invVM)) {
// sad trombone sound
@@ -378,6 +378,10 @@ bool GrDrawState::hasSolidCoverage() const {
return true;
}
+ if (this->numCoverageStages() > 0) {
+ return false;
+ }
+
GrProcessor::InvariantOutput inout;
inout.fIsSingleComponent = true;
// Initialize to an unknown starting coverage if per-vertex coverage is specified.
@@ -388,15 +392,11 @@ bool GrDrawState::hasSolidCoverage() const {
inout.fValidFlags = kRGBA_GrColorComponentFlags;
}
- // Run through the coverage stages and see if the coverage will be all ones at the end.
+ // check the coverage output from the GP
if (this->hasGeometryProcessor()) {
fGeometryProcessor->computeInvariantOutput(&inout);
}
- for (int s = 0; s < this->numCoverageStages(); ++s) {
- const GrProcessor* processor = this->getCoverageStage(s).getProcessor();
- processor->computeInvariantOutput(&inout);
- }
return inout.isSolidWhite();
}
@@ -533,7 +533,7 @@ bool GrDrawState::AutoViewMatrixRestore::setIdentity(GrDrawState* drawState) {
}
fViewMatrix = drawState->getViewMatrix();
- if (0 == drawState->numTotalStages()) {
+ if (0 == drawState->numFragmentStages()) {
drawState->fViewMatrix.reset();
fDrawState = drawState;
fNumColorStages = 0;
@@ -554,7 +554,7 @@ bool GrDrawState::AutoViewMatrixRestore::setIdentity(GrDrawState* drawState) {
}
void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& coordChangeMatrix) {
- fSavedCoordChanges.reset(fDrawState->numTotalStages());
+ fSavedCoordChanges.reset(fDrawState->numFragmentStages());
int i = 0;
fNumColorStages = fDrawState->numColorStages();
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 15df975d73..baa92afd59 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -246,9 +246,9 @@ public:
int numColorStages() const { return fColorStages.count(); }
int numCoverageStages() const { return fCoverageStages.count(); }
+ int numFragmentStages() const { return this->numColorStages() + this->numCoverageStages(); }
int numTotalStages() const {
- return this->numColorStages() + this->numCoverageStages() +
- (this->hasGeometryProcessor() ? 1 : 0);
+ return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 : 0);
}
bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()); }
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index c764b432a1..79eef0c024 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -44,7 +44,6 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
int firstColorStageIdx = 0;
int firstCoverageStageIdx = 0;
- bool separateCoverageFromColor;
uint8_t fixedFunctionVAToRemove = 0;
@@ -58,8 +57,6 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
this->removeFixedFunctionVertexAttribs(fixedFunctionVAToRemove, &descInfo);
}
this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, &descInfo);
- this->setOutputStateInfo(drawState, *gpu->caps(), firstCoverageStageIdx, &descInfo,
- &separateCoverageFromColor);
// Copy GeometryProcesssor from DS or ODS
if (drawState.hasGeometryProcessor()) {
@@ -86,11 +83,10 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
if (firstCoverageStageIdx < drawState.numCoverageStages()) {
fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverageStageIdx,
&drawState.getCoverageStage(firstCoverageStageIdx));
- if (!separateCoverageFromColor) {
- fNumColorStages = fFragmentStages.count();
- }
}
+ this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo);
+
// now create a key
gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc);
};
@@ -120,42 +116,35 @@ GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState,
void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
const GrDrawTargetCaps& caps,
- int firstCoverageStageIdx,
- GrProgramDesc::DescInfo* descInfo,
- bool* separateCoverageFromColor) {
+ GrProgramDesc::DescInfo* descInfo) {
// Set this default and then possibly change our mind if there is coverage.
descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType;
descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType;
- // If we do have coverage determine whether it matters.
- *separateCoverageFromColor = this->hasGeometryProcessor();
- if (!this->isCoverageDrawing() &&
- (ds.numCoverageStages() - firstCoverageStageIdx > 0 ||
- ds.hasGeometryProcessor() ||
- descInfo->hasCoverageVertexAttribute())) {
-
+ // If we do have coverage determine whether it matters. Dual source blending is expensive so
+ // we don't do it if we are doing coverage drawing. If we aren't then We always do dual source
+ // blending if we have any effective coverage stages OR the geometry processor doesn't emits
+ // solid coverage.
+ // TODO move the gp logic into the GP base class
+ if (!this->isCoverageDrawing() && !ds.hasSolidCoverage()) {
if (caps.dualSourceBlendingSupport()) {
if (kZero_GrBlendCoeff == fDstBlend) {
// write the coverage value to second color
descInfo->fSecondaryOutputType = GrProgramDesc::kCoverage_SecondaryOutputType;
- *separateCoverageFromColor = true;
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
} else if (kSA_GrBlendCoeff == fDstBlend) {
// SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISA_SecondaryOutputType;
- *separateCoverageFromColor = true;
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
} else if (kSC_GrBlendCoeff == fDstBlend) {
// SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISC_SecondaryOutputType;
- *separateCoverageFromColor = true;
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
}
} else if (descInfo->fReadsDst &&
kOne_GrBlendCoeff == fSrcBlend &&
kZero_GrBlendCoeff == fDstBlend) {
descInfo->fPrimaryOutputType = GrProgramDesc::kCombineWithDst_PrimaryOutputType;
- *separateCoverageFromColor = true;
}
}
}
diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h
index 945cbfb759..cef32b6157 100644
--- a/src/gpu/GrOptDrawState.h
+++ b/src/gpu/GrOptDrawState.h
@@ -354,8 +354,7 @@ private:
* blend coeffs will represent those used by backend API.
*/
void setOutputStateInfo(const GrDrawState& ds, const GrDrawTargetCaps&,
- int firstCoverageStageIdx, GrProgramDesc::DescInfo*,
- bool* separateCoverageFromColor);
+ GrProgramDesc::DescInfo*);
bool isEqual(const GrOptDrawState& that) const;
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 4a182b36e6..836400e350 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -175,12 +175,12 @@ struct FragmentProcessorKeyBuilder {
template <class ProcessorKeyBuilder>
-bool
-GrGLProgramDescBuilder::BuildStagedProcessorKey(const typename ProcessorKeyBuilder::StagedProcessor& stage,
- const GrGLCaps& caps,
- bool requiresLocalCoordAttrib,
- GrProgramDesc* desc,
- int* offsetAndSizeIndex) {
+bool GrGLProgramDescBuilder::BuildStagedProcessorKey(
+ const typename ProcessorKeyBuilder::StagedProcessor& stage,
+ const GrGLCaps& caps,
+ bool requiresLocalCoordAttrib,
+ GrProgramDesc* desc,
+ int* offsetAndSizeIndex) {
GrProcessorKeyBuilder b(&desc->fKey);
uint16_t processorKeySize;
uint32_t processorOffset = desc->fKey.count();
@@ -201,11 +201,11 @@ GrGLProgramDescBuilder::BuildStagedProcessorKey(const typename ProcessorKeyBuild
}
bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState,
- const GrProgramDesc::DescInfo& descInfo,
- GrGpu::DrawType drawType,
- GrGpuGL* gpu,
- const GrDeviceCoordTexture* dstCopy,
- GrProgramDesc* desc) {
+ const GrProgramDesc::DescInfo& descInfo,
+ GrGpu::DrawType drawType,
+ GrGpuGL* gpu,
+ const GrDeviceCoordTexture* dstCopy,
+ GrProgramDesc* desc) {
bool inputColorIsUsed = descInfo.fInputColorIsUsed;
bool inputCoverageIsUsed = descInfo.fInputCoverageIsUsed;