diff options
author | 2014-11-17 07:45:53 -0800 | |
---|---|---|
committer | 2014-11-17 07:45:53 -0800 | |
commit | 912b3d24a0e214e46a211da40cc01fe30238386c (patch) | |
tree | 086c4aae3ec2085857811fb66fe164f0d579a705 /src | |
parent | 468b6b4eaf4b30384d34041ca66676b5762548ec (diff) |
Use DrawStates ProcOptInfo when creating the Optimized Draw State.
BUG=skia:
Review URL: https://codereview.chromium.org/726693002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrDrawState.h | 10 | ||||
-rw-r--r-- | src/gpu/GrOptDrawState.cpp | 77 |
2 files changed, 23 insertions, 64 deletions
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h index 454390cfbc..974aff4c2f 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -803,6 +803,16 @@ private: GrBlendCoeff* srcCoeff = NULL, GrBlendCoeff* dstCoeff = NULL) const; + const GrProcOptInfo& colorProcInfo() const { + this->calcColorInvariantOutput(); + return fColorProcInfo; + } + + const GrProcOptInfo& coverageProcInfo() const { + this->calcCoverageInvariantOutput(); + return fCoverageProcInfo; + } + /** * Determines whether src alpha is guaranteed to be one for all src pixels */ diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp index 24ba3a1879..4a258c2e17 100644 --- a/src/gpu/GrOptDrawState.cpp +++ b/src/gpu/GrOptDrawState.cpp @@ -21,8 +21,6 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType drawType) { fRenderTarget.set(SkSafeRef(drawState.getRenderTarget()), kWrite_GrIOType); - fColor = drawState.getColor(); - fCoverage = drawState.getCoverage(); fViewMatrix = drawState.getViewMatrix(); fBlendConstant = drawState.getBlendConstant(); fFlagBits = drawState.getFlagBits(); @@ -40,17 +38,22 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState, drawState.getFixedFunctionVertexAttribIndices(), sizeof(descInfo.fFixedFunctionVertexAttribIndices)); - descInfo.fInputColorIsUsed = true; - descInfo.fInputCoverageIsUsed = true; + uint8_t fixedFunctionVAToRemove = 0; - int firstColorStageIdx = 0; - int firstCoverageStageIdx = 0; + const GrProcOptInfo& colorPOI = drawState.colorProcInfo(); + int firstColorStageIdx = colorPOI.firstEffectiveStageIndex(); + descInfo.fInputColorIsUsed = colorPOI.inputColorIsUsed(); + fColor = colorPOI.inputColorToEffectiveStage(); + if (colorPOI.removeVertexAttrib()) { + fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding; + } - uint8_t fixedFunctionVAToRemove = 0; + // TODO: Once we can handle single or four channel input into coverage stages then we can use + // drawState's coverageProcInfo (like color above) to set this initial information. + int firstCoverageStageIdx = 0; + descInfo.fInputCoverageIsUsed = true; + fCoverage = drawState.getCoverage(); - this->computeEffectiveColorStages(drawState, &descInfo, &firstColorStageIdx, - &fixedFunctionVAToRemove); - this->computeEffectiveCoverageStages(drawState, &descInfo, &firstCoverageStageIdx); this->adjustFromBlendOpts(drawState, &descInfo, &firstColorStageIdx, &firstCoverageStageIdx, &fixedFunctionVAToRemove); // Should not be setting any more FFVA to be removed at this point @@ -218,60 +221,6 @@ void GrOptDrawState::removeFixedFunctionVertexAttribs(uint8_t removeVAFlag, fVAPtr = fOptVA.get(); } -void GrOptDrawState::computeEffectiveColorStages(const GrDrawState& ds, - GrProgramDesc::DescInfo* descInfo, - int* firstColorStageIdx, - uint8_t* fixedFunctionVAToRemove) { - // Set up color and flags for ConstantColorComponent checks - GrColor color; - GrColorComponentFlags flags; - if (!descInfo->hasColorVertexAttribute()) { - color = ds.getColor(); - flags = kRGBA_GrColorComponentFlags; - } else { - if (ds.vertexColorsAreOpaque()) { - color = 0xFF << GrColor_SHIFT_A; - flags = kA_GrColorComponentFlag; - } else { - flags = static_cast<GrColorComponentFlags>(0); - // not strictly necessary but we get false alarms from tools about uninit. - color = 0; - } - } - GrProcOptInfo poi; - if (ds.numColorStages() > 0) { - poi.calcWithInitialValues(&ds.getColorStage(0), ds.numColorStages(), color, flags, false); - *firstColorStageIdx = poi.firstEffectiveStageIndex(); - descInfo->fInputColorIsUsed = poi.inputColorIsUsed(); - fColor = poi.inputColorToEffectiveStage(); - if (poi.removeVertexAttrib()) { - *fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding; - } - } -} - -void GrOptDrawState::computeEffectiveCoverageStages(const GrDrawState& ds, - GrProgramDesc::DescInfo* descInfo, - int* firstCoverageStageIdx) { - // We do not try to optimize out constantColor coverage effects here. It is extremely rare - // to have a coverage effect that returns a constant value for all four channels. Thus we - // save having to make extra virtual calls by not checking for it. - - // Don't do any optimizations on coverage stages. It should not be the case where we do not use - // input coverage in an effect -#ifdef OptCoverageStages - GrInvariantOutput inout; - for (int i = 0; i < ds.numCoverageStages(); ++i) { - const GrFragmentProcessor* fp = ds.getCoverageStage(i).getProcessor(); - fp->computeInvariantOutput(&inout); - if (!inout.fWillUseInputColor) { - *firstCoverageStageIdx = i; - descInfo->fInputCoverageIsUsed = false; - } - } -#endif -} - static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool* readsFragPosition) { if (stage.getProcessor()->willReadDstColor()) { *readsDst = true; |