Don't perform analysis twice in InstancedRendering::Op
Change-Id: Ie0aeeb7bf63090b0c27a9b062cce0cdc561a1d7e Reviewed-on: https://skia-review.googlesource.com/10583 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
7ee385e1dc
commit
13071c5c7a
@ -58,6 +58,20 @@ public:
|
|||||||
return (kColorIsKnown_Flag & fFlags) ? fColor == that.fColor : true;
|
return (kColorIsKnown_Flag & fFlags) ? fColor == that.fColor : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The returned value reflects the common properties of the two inputs. */
|
||||||
|
static GrPipelineAnalysisColor Combine(const GrPipelineAnalysisColor& a,
|
||||||
|
const GrPipelineAnalysisColor& b) {
|
||||||
|
GrPipelineAnalysisColor result;
|
||||||
|
uint32_t commonFlags = a.fFlags & b.fFlags;
|
||||||
|
if ((kColorIsKnown_Flag & commonFlags) && a.fColor == b.fColor) {
|
||||||
|
result.fColor = a.fColor;
|
||||||
|
result.fFlags = a.fFlags;
|
||||||
|
} else if (kIsOpaque_Flag & commonFlags) {
|
||||||
|
result.fFlags = kIsOpaque_Flag;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Flags {
|
enum Flags {
|
||||||
kColorIsKnown_Flag = 0x1,
|
kColorIsKnown_Flag = 0x1,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "InstancedRendering.h"
|
#include "InstancedRendering.h"
|
||||||
|
#include "GrAppliedClip.h"
|
||||||
#include "GrCaps.h"
|
#include "GrCaps.h"
|
||||||
#include "GrOpFlushState.h"
|
#include "GrOpFlushState.h"
|
||||||
#include "GrPipeline.h"
|
#include "GrPipeline.h"
|
||||||
@ -122,8 +122,6 @@ std::unique_ptr<InstancedRendering::Op> InstancedRendering::recordShape(
|
|||||||
op->fInfo.setAAType(aaType);
|
op->fInfo.setAAType(aaType);
|
||||||
op->fInfo.fShapeTypes = GetShapeFlag(type);
|
op->fInfo.fShapeTypes = GetShapeFlag(type);
|
||||||
op->fInfo.fCannotDiscard = true;
|
op->fInfo.fCannotDiscard = true;
|
||||||
op->fDrawColorsAreOpaque = GrColorIsOpaque(color);
|
|
||||||
op->fDrawColorsAreSame = true;
|
|
||||||
Instance& instance = op->getSingleInstance();
|
Instance& instance = op->getSingleInstance();
|
||||||
instance.fInfo = (int)type << kShapeType_InfoBit;
|
instance.fInfo = (int)type << kShapeType_InfoBit;
|
||||||
|
|
||||||
@ -343,6 +341,8 @@ bool InstancedRendering::Op::xpRequiresDstTexture(const GrCaps& caps, const GrAp
|
|||||||
}
|
}
|
||||||
fProcessors.analyzeAndEliminateFragmentProcessors(&analysis, this->getSingleInstance().fColor,
|
fProcessors.analyzeAndEliminateFragmentProcessors(&analysis, this->getSingleInstance().fColor,
|
||||||
coverageInput, clip, caps);
|
coverageInput, clip, caps);
|
||||||
|
fAnalysisColor = analysis.outputColor();
|
||||||
|
|
||||||
Draw& draw = this->getSingleDraw(); // This will assert if we have > 1 command.
|
Draw& draw = this->getSingleDraw(); // This will assert if we have > 1 command.
|
||||||
SkASSERT(draw.fGeometry.isEmpty());
|
SkASSERT(draw.fGeometry.isEmpty());
|
||||||
SkASSERT(SkIsPow2(fInfo.fShapeTypes));
|
SkASSERT(SkIsPow2(fInfo.fShapeTypes));
|
||||||
@ -407,9 +407,7 @@ bool InstancedRendering::Op::onCombineIfPossible(GrOp* other, const GrCaps& caps
|
|||||||
this->joinBounds(*that);
|
this->joinBounds(*that);
|
||||||
fInfo = combinedInfo;
|
fInfo = combinedInfo;
|
||||||
fPixelLoad += that->fPixelLoad;
|
fPixelLoad += that->fPixelLoad;
|
||||||
fDrawColorsAreOpaque = fDrawColorsAreOpaque && that->fDrawColorsAreOpaque;
|
fAnalysisColor = GrPipelineAnalysisColor::Combine(fAnalysisColor, that->fAnalysisColor);
|
||||||
fDrawColorsAreSame = fDrawColorsAreSame && that->fDrawColorsAreSame &&
|
|
||||||
fHeadDraw->fInstance.fColor == that->fHeadDraw->fInstance.fColor;
|
|
||||||
// Adopt the other op's draws.
|
// Adopt the other op's draws.
|
||||||
fNumDraws += that->fNumDraws;
|
fNumDraws += that->fNumDraws;
|
||||||
fNumChangesInGeometry += that->fNumChangesInGeometry;
|
fNumChangesInGeometry += that->fNumChangesInGeometry;
|
||||||
@ -466,28 +464,20 @@ void InstancedRendering::Op::onExecute(GrOpFlushState* state) {
|
|||||||
|
|
||||||
state->gpu()->handleDirtyContext();
|
state->gpu()->handleDirtyContext();
|
||||||
|
|
||||||
// TODO: Don't reanalyze the processors.
|
|
||||||
GrProcessorSet::FragmentProcessorAnalysis analysis;
|
|
||||||
GrPipelineAnalysisCoverage coverageInput;
|
|
||||||
if (GrAAType::kCoverage == fInfo.aaType() ||
|
|
||||||
(GrAAType::kNone == fInfo.aaType() && !fInfo.isSimpleRects() && fInfo.fCannotDiscard)) {
|
|
||||||
coverageInput = GrPipelineAnalysisCoverage::kSingleChannel;
|
|
||||||
} else {
|
|
||||||
coverageInput = GrPipelineAnalysisCoverage::kNone;
|
|
||||||
}
|
|
||||||
GrPipelineAnalysisColor colorInput;
|
|
||||||
if (fDrawColorsAreSame) {
|
|
||||||
colorInput = fHeadDraw->fInstance.fColor;
|
|
||||||
} else if (fDrawColorsAreOpaque) {
|
|
||||||
colorInput = GrPipelineAnalysisColor::Opaque::kYes;
|
|
||||||
}
|
|
||||||
const GrAppliedClip* clip = state->drawOpArgs().fAppliedClip;
|
const GrAppliedClip* clip = state->drawOpArgs().fAppliedClip;
|
||||||
analysis.init(colorInput, coverageInput, fProcessors, clip, state->caps());
|
GrPipelineAnalysisCoverage coverage;
|
||||||
|
if (GrAAType::kCoverage == fInfo.aaType() ||
|
||||||
|
(clip && clip->clipCoverageFragmentProcessor()) ||
|
||||||
|
(GrAAType::kNone == fInfo.aaType() && !fInfo.isSimpleRects() && fInfo.fCannotDiscard)) {
|
||||||
|
coverage = GrPipelineAnalysisCoverage::kSingleChannel;
|
||||||
|
} else {
|
||||||
|
coverage = GrPipelineAnalysisCoverage::kNone;
|
||||||
|
}
|
||||||
|
|
||||||
GrPipeline pipeline;
|
GrPipeline pipeline;
|
||||||
GrPipeline::InitArgs args;
|
GrPipeline::InitArgs args;
|
||||||
args.fInputColor = analysis.outputColor();
|
args.fInputColor = fAnalysisColor;
|
||||||
args.fInputCoverage = analysis.outputCoverage();
|
args.fInputCoverage = coverage;
|
||||||
args.fAppliedClip = clip;
|
args.fAppliedClip = clip;
|
||||||
args.fCaps = &state->caps();
|
args.fCaps = &state->caps();
|
||||||
args.fProcessors = &fProcessors;
|
args.fProcessors = &fProcessors;
|
||||||
|
@ -151,10 +151,9 @@ protected:
|
|||||||
OpInfo fInfo;
|
OpInfo fInfo;
|
||||||
SkScalar fPixelLoad;
|
SkScalar fPixelLoad;
|
||||||
GrProcessorSet fProcessors;
|
GrProcessorSet fProcessors;
|
||||||
|
GrPipelineAnalysisColor fAnalysisColor;
|
||||||
SkSTArray<5, ParamsTexel, true> fParams;
|
SkSTArray<5, ParamsTexel, true> fParams;
|
||||||
bool fIsTracked : 1;
|
bool fIsTracked;
|
||||||
bool fDrawColorsAreOpaque : 1;
|
|
||||||
bool fDrawColorsAreSame : 1;
|
|
||||||
int fNumDraws;
|
int fNumDraws;
|
||||||
int fNumChangesInGeometry;
|
int fNumChangesInGeometry;
|
||||||
Draw* fHeadDraw;
|
Draw* fHeadDraw;
|
||||||
|
Loading…
Reference in New Issue
Block a user