move program descriptor generation to flush
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/829e1b80b1020b17f2078020c990e079b70c077c
Review URL: https://codereview.chromium.org/777673003
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index d97809f..ac76e15 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -277,7 +277,7 @@
void GrGpu::draw(const GrOptDrawState& ds, const GrDrawTarget::DrawInfo& info) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(ds, PrimTypeToDrawType(info.primitiveType()))) {
+ if (!this->flushGraphicsState(ds)) {
return;
}
this->onDraw(ds, info);
@@ -288,7 +288,7 @@
const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(ds, kStencilPath_DrawType)) {
+ if (!this->flushGraphicsState(ds)) {
return;
}
@@ -301,7 +301,7 @@
const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(ds, kDrawPath_DrawType)) {
+ if (!this->flushGraphicsState(ds)) {
return;
}
@@ -318,7 +318,7 @@
const GrStencilSettings& stencilSettings) {
this->handleDirtyContext();
- if (!this->flushGraphicsState(ds, kDrawPaths_DrawType)) {
+ if (!this->flushGraphicsState(ds)) {
return;
}
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index d0bff30..c88e1c8 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -469,7 +469,7 @@
// deltas from previous state at draw time. This function does the
// backend-specific flush of the state.
// returns false if current state is unsupported.
- virtual bool flushGraphicsState(const GrOptDrawState&, DrawType) = 0;
+ virtual bool flushGraphicsState(const GrOptDrawState&) = 0;
// clears target's entire stencil buffer to 0
virtual void clearStencil(GrRenderTarget* target) = 0;
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 5533174..83b9701 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -394,7 +394,7 @@
// Updated every time we find a set state cmd to reflect the current state in the playback
// stream.
- const GrOptDrawState* currentOptState = NULL;
+ GrOptDrawState* currentOptState = NULL;
while (iter.next()) {
GrGpuTraceMarker newMarker("", -1);
@@ -409,6 +409,7 @@
if (kSetState_Cmd == strip_trace_bit(iter->fType)) {
SetState* ss = reinterpret_cast<SetState*>(iter.get());
currentOptState = &ss->fState;
+ currentOptState->finalize(this->getGpu());
} else {
iter->execute(this, currentOptState);
}
@@ -486,7 +487,8 @@
const GrClipMaskManager::ScissorState& scissor,
const GrDeviceCoordTexture* dstCopy) {
SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
- (ds, this->getGpu(), scissor, dstCopy, drawType));
+ (ds, *this->getGpu()->caps(), scissor, dstCopy,
+ drawType));
if (ss->fState.mustSkip()) {
fCmdBuffer.pop_back();
return false;
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index 532842a..01e560a 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -171,15 +171,15 @@
};
struct SetState : public Cmd {
- SetState(const GrDrawState& drawState, GrGpu* gpu, const ScissorState& scissor,
- const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType drawType)
+ SetState(const GrDrawState& drawState, const GrDrawTargetCaps& caps,
+ const ScissorState& scissor, const GrDeviceCoordTexture* dstCopy,
+ GrGpu::DrawType drawType)
: Cmd(kSetState_Cmd)
- , fState(drawState, gpu, scissor, dstCopy, drawType) {}
+ , fState(drawState, caps, scissor, dstCopy, drawType) {}
void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE;
- const GrOptDrawState fState;
- GrGpu::DrawType fDrawType;
+ GrOptDrawState fState;
};
typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 6f6f0af..b787596 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -13,11 +13,12 @@
#include "GrProcOptInfo.h"
GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
- GrGpu* gpu,
+ const GrDrawTargetCaps& caps,
const ScissorState& scissorState,
const GrDeviceCoordTexture* dstCopy,
- GrGpu::DrawType drawType) {
-
+ GrGpu::DrawType drawType)
+ : fFinalized(false) {
+ fDrawType = drawType;
GrBlendCoeff optSrcCoeff;
GrBlendCoeff optDstCoeff;
GrDrawState::BlendOpt blendOpt = drawState.getBlendOpt(false, &optSrcCoeff, &optDstCoeff);
@@ -52,8 +53,6 @@
fDstCopy = *dstCopy;
}
- GrProgramDesc::DescInfo descInfo;
-
fFlags = 0;
if (drawState.isHWAntialias()) {
fFlags |= kHWAA_Flag;
@@ -65,34 +64,33 @@
fFlags |= kDither_Flag;
}
- descInfo.fHasVertexColor = drawState.hasGeometryProcessor() &&
- drawState.getGeometryProcessor()->hasVertexColor();
+ fDescInfo.fHasVertexColor = drawState.hasGeometryProcessor() &&
+ drawState.getGeometryProcessor()->hasVertexColor();
- descInfo.fHasVertexCoverage = drawState.hasGeometryProcessor() &&
- drawState.getGeometryProcessor()->hasVertexCoverage();
+ fDescInfo.fHasVertexCoverage = drawState.hasGeometryProcessor() &&
+ drawState.getGeometryProcessor()->hasVertexCoverage();
bool hasLocalCoords = drawState.hasGeometryProcessor() &&
drawState.getGeometryProcessor()->hasLocalCoords();
const GrProcOptInfo& colorPOI = drawState.colorProcInfo();
int firstColorStageIdx = colorPOI.firstEffectiveStageIndex();
- descInfo.fInputColorIsUsed = colorPOI.inputColorIsUsed();
+ fDescInfo.fInputColorIsUsed = colorPOI.inputColorIsUsed();
fColor = colorPOI.inputColorToEffectiveStage();
if (colorPOI.removeVertexAttrib()) {
- descInfo.fHasVertexColor = false;
+ fDescInfo.fHasVertexColor = false;
}
// 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;
+ fDescInfo.fInputCoverageIsUsed = true;
fCoverage = drawState.getCoverage();
- this->adjustProgramForBlendOpt(drawState, blendOpt, &descInfo, &firstColorStageIdx,
+ this->adjustProgramForBlendOpt(drawState, blendOpt, &firstColorStageIdx,
&firstCoverageStageIdx);
- this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, hasLocalCoords,
- &descInfo);
+ this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, hasLocalCoords);
// Copy GeometryProcesssor from DS or ODS
SkASSERT(GrGpu::IsPathRenderingDrawType(drawType) ||
@@ -118,19 +116,15 @@
(drawState.fCoverageStages[i], hasLocalCoords));
}
- this->setOutputStateInfo(drawState, blendOpt, *gpu->caps(), &descInfo);
-
- // now create a key
- gpu->buildProgramDesc(*this, descInfo, drawType, &fDesc);
+ this->setOutputStateInfo(drawState, blendOpt, caps);
};
void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
GrDrawState::BlendOpt blendOpt,
- const GrDrawTargetCaps& caps,
- GrProgramDesc::DescInfo* descInfo) {
+ const GrDrawTargetCaps& caps) {
// Set this default and then possibly change our mind if there is coverage.
- descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType;
- descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType;
+ fDescInfo.fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType;
+ fDescInfo.fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType;
// Determine whether we should use dual source blending or shader code to keep coverage
// separate from color.
@@ -140,28 +134,27 @@
if (caps.dualSourceBlendingSupport()) {
if (kZero_GrBlendCoeff == fDstBlend) {
// write the coverage value to second color
- descInfo->fSecondaryOutputType = GrProgramDesc::kCoverage_SecondaryOutputType;
+ fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverage_SecondaryOutputType;
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;
+ fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISA_SecondaryOutputType;
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;
+ fDescInfo.fSecondaryOutputType = GrProgramDesc::kCoverageISC_SecondaryOutputType;
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
}
- } else if (descInfo->fReadsDst &&
+ } else if (fDescInfo.fReadsDst &&
kOne_GrBlendCoeff == fSrcBlend &&
kZero_GrBlendCoeff == fDstBlend) {
- descInfo->fPrimaryOutputType = GrProgramDesc::kCombineWithDst_PrimaryOutputType;
+ fDescInfo.fPrimaryOutputType = GrProgramDesc::kCombineWithDst_PrimaryOutputType;
}
}
}
void GrOptDrawState::adjustProgramForBlendOpt(const GrDrawState& ds,
GrDrawState::BlendOpt blendOpt,
- GrProgramDesc::DescInfo* descInfo,
int* firstColorStageIdx,
int* firstCoverageStageIdx) {
switch (blendOpt) {
@@ -171,19 +164,19 @@
break;
case GrDrawState::kEmitCoverage_BlendOpt:
fColor = 0xffffffff;
- descInfo->fInputColorIsUsed = true;
+ fDescInfo.fInputColorIsUsed = true;
*firstColorStageIdx = ds.numColorStages();
- descInfo->fHasVertexColor = false;
+ fDescInfo.fHasVertexColor = false;
break;
case GrDrawState::kEmitTransBlack_BlendOpt:
fColor = 0;
fCoverage = 0xff;
- descInfo->fInputColorIsUsed = true;
- descInfo->fInputCoverageIsUsed = true;
+ fDescInfo.fInputColorIsUsed = true;
+ fDescInfo.fInputCoverageIsUsed = true;
*firstColorStageIdx = ds.numColorStages();
*firstCoverageStageIdx = ds.numCoverageStages();
- descInfo->fHasVertexColor = false;
- descInfo->fHasVertexCoverage = false;
+ fDescInfo.fHasVertexColor = false;
+ fDescInfo.fHasVertexCoverage = false;
break;
}
}
@@ -198,46 +191,53 @@
}
void GrOptDrawState::getStageStats(const GrDrawState& ds, int firstColorStageIdx,
- int firstCoverageStageIdx, bool hasLocalCoords,
- GrProgramDesc::DescInfo* descInfo) {
+ int firstCoverageStageIdx, bool hasLocalCoords) {
// We will need a local coord attrib if there is one currently set on the optState and we are
// actually generating some effect code
- descInfo->fRequiresLocalCoordAttrib = hasLocalCoords &&
+ fDescInfo.fRequiresLocalCoordAttrib = hasLocalCoords &&
ds.numTotalStages() - firstColorStageIdx - firstCoverageStageIdx > 0;
- descInfo->fReadsDst = false;
- descInfo->fReadsFragPosition = false;
+ fDescInfo.fReadsDst = false;
+ fDescInfo.fReadsFragPosition = false;
for (int s = firstColorStageIdx; s < ds.numColorStages(); ++s) {
const GrFragmentStage& stage = ds.getColorStage(s);
- get_stage_stats(stage, &descInfo->fReadsDst, &descInfo->fReadsFragPosition);
+ get_stage_stats(stage, &fDescInfo.fReadsDst, &fDescInfo.fReadsFragPosition);
}
for (int s = firstCoverageStageIdx; s < ds.numCoverageStages(); ++s) {
const GrFragmentStage& stage = ds.getCoverageStage(s);
- get_stage_stats(stage, &descInfo->fReadsDst, &descInfo->fReadsFragPosition);
+ get_stage_stats(stage, &fDescInfo.fReadsDst, &fDescInfo.fReadsFragPosition);
}
if (ds.hasGeometryProcessor()) {
const GrGeometryProcessor& gp = *ds.getGeometryProcessor();
- descInfo->fReadsFragPosition = descInfo->fReadsFragPosition || gp.willReadFragmentPosition();
+ fDescInfo.fReadsFragPosition = fDescInfo.fReadsFragPosition || gp.willReadFragmentPosition();
}
}
+void GrOptDrawState::finalize(GrGpu* gpu) {
+ gpu->buildProgramDesc(*this, fDescInfo, fDrawType, &fDesc);
+ fFinalized = true;
+}
+
////////////////////////////////////////////////////////////////////////////////
bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
- if (this->fDesc != that.fDesc) {
+ if (fDescInfo != that.fDescInfo) {
return false;
}
- bool hasVertexColors = this->fDesc.header().fColorInput == GrProgramDesc::kAttribute_ColorInput;
- if (!hasVertexColors && this->fColor != that.fColor) {
+
+ if (!fDescInfo.fHasVertexColor && this->fColor != that.fColor) {
return false;
}
if (this->getRenderTarget() != that.getRenderTarget() ||
+ this->fFragmentStages.count() != that.fFragmentStages.count() ||
+ this->fNumColorStages != that.fNumColorStages ||
this->fScissorState != that.fScissorState ||
!this->fViewMatrix.cheapEqualTo(that.fViewMatrix) ||
this->fSrcBlend != that.fSrcBlend ||
this->fDstBlend != that.fDstBlend ||
+ this->fDrawType != that.fDrawType ||
this->fBlendConstant != that.fBlendConstant ||
this->fFlags != that.fFlags ||
this->fStencilSettings != that.fStencilSettings ||
@@ -246,9 +246,7 @@
return false;
}
- bool hasVertexCoverage =
- this->fDesc.header().fCoverageInput == GrProgramDesc::kAttribute_ColorInput;
- if (!hasVertexCoverage && this->fCoverage != that.fCoverage) {
+ if (!fDescInfo.fHasVertexCoverage && this->fCoverage != that.fCoverage) {
return false;
}
diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h
index ac7ec16..25a3a49 100644
--- a/src/gpu/GrOptDrawState.h
+++ b/src/gpu/GrOptDrawState.h
@@ -30,7 +30,7 @@
typedef GrClipMaskManager::ScissorState ScissorState;
- GrOptDrawState(const GrDrawState& drawState, GrGpu*, const ScissorState&,
+ GrOptDrawState(const GrDrawState& drawState, const GrDrawTargetCaps&, const ScissorState&,
const GrDeviceCoordTexture* dstCopy, GrGpu::DrawType);
bool operator== (const GrOptDrawState& that) const;
@@ -180,33 +180,20 @@
///////////////////////////////////////////////////////////////////////////
+ GrGpu::DrawType drawType() const { return fDrawType; }
+
const GrDeviceCoordTexture* getDstCopy() const { return fDstCopy.texture() ? &fDstCopy : NULL; }
- const GrProgramDesc& programDesc() const { return fDesc; }
+ // Finalize *MUST* be called before programDesc()
+ void finalize(GrGpu*);
+
+ const GrProgramDesc& programDesc() const { SkASSERT(fFinalized); return fDesc; }
private:
/**
- * Loops through all the color stage effects to check if the stage will ignore color input or
- * always output a constant color. In the ignore color input case we can ignore all previous
- * stages. In the constant color case, we can ignore all previous stages and
- * the current one and set the state color to the constant color.
- */
- void computeEffectiveColorStages(const GrDrawState& ds, GrProgramDesc::DescInfo*,
- int* firstColorStageIdx, uint8_t* fixFunctionVAToRemove);
-
- /**
- * Loops through all the coverage stage effects to check if the stage will ignore color input.
- * If a coverage stage will ignore input, then we can ignore all coverage stages before it. We
- * loop to determine the first effective coverage stage.
- */
- void computeEffectiveCoverageStages(const GrDrawState& ds, GrProgramDesc::DescInfo* descInfo,
- int* firstCoverageStageIdx);
-
- /**
* Alter the program desc and inputs (attribs and processors) based on the blend optimization.
*/
void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt,
- GrProgramDesc::DescInfo*,
int* firstColorStageIdx, int* firstCoverageStageIdx);
/**
@@ -214,15 +201,14 @@
* shaders they require.
*/
void getStageStats(const GrDrawState& ds, int firstColorStageIdx, int firstCoverageStageIdx,
- bool hasLocalCoords, GrProgramDesc::DescInfo*);
+ bool hasLocalCoords);
/**
* Calculates the primary and secondary output types of the shader. For certain output types
* the function may adjust the blend coefficients. After this function is called the src and dst
* blend coeffs will represent those used by backend API.
*/
- void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const GrDrawTargetCaps&,
- GrProgramDesc::DescInfo*);
+ void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const GrDrawTargetCaps&);
enum Flags {
kDither_Flag = 0x1,
@@ -249,6 +235,9 @@
ProgramGeometryProcessor fGeometryProcessor;
ProgramXferProcessor fXferProcessor;
FragmentStageArray fFragmentStages;
+ GrGpu::DrawType fDrawType;
+ GrProgramDesc::DescInfo fDescInfo;
+ bool fFinalized;
// This function is equivalent to the offset into fFragmentStages where coverage stages begin.
int fNumColorStages;
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index 655254f..ef7be23 100644
--- a/src/gpu/GrProgramDesc.h
+++ b/src/gpu/GrProgramDesc.h
@@ -103,8 +103,6 @@
// effects that read the fragment position.
// Otherwise, 0.
- SkBool8 fEmitsPointSize;
-
ColorInput fColorInput : 8;
ColorInput fCoverageInput : 8;
@@ -136,6 +134,19 @@
// A struct to communicate descriptor information to the program descriptor builder
struct DescInfo {
+ bool operator==(const DescInfo& that) const {
+ return fHasVertexColor == that.fHasVertexColor &&
+ fHasVertexCoverage == that.fHasVertexCoverage &&
+ fInputColorIsUsed == that.fInputColorIsUsed &&
+ fInputCoverageIsUsed == that.fInputCoverageIsUsed &&
+ fReadsDst == that.fReadsDst &&
+ fReadsFragPosition == that.fReadsFragPosition &&
+ fRequiresLocalCoordAttrib == that.fRequiresLocalCoordAttrib &&
+ fPrimaryOutputType == that.fPrimaryOutputType &&
+ fSecondaryOutputType == that.fSecondaryOutputType;
+
+ }
+ bool operator!=(const DescInfo& that) const { return !(*this == that); };
// TODO when GPs control uniform / attribute handling of color / coverage, then we can
// clean this up
bool fHasVertexColor;
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 48f72a7..7038c10 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -140,7 +140,7 @@
return false;
}
- bool flushGraphicsState(const GrOptDrawState&, DrawType) SK_OVERRIDE { return false; }
+ bool flushGraphicsState(const GrOptDrawState&) SK_OVERRIDE { return false; }
void clearStencil(GrRenderTarget* target) SK_OVERRIDE {}
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index 63cb9da..3b04edb 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -123,13 +123,13 @@
///////////////////////////////////////////////////////////////////////////////
-void GrGLProgram::setData(const GrOptDrawState& optState, GrGpu::DrawType drawType) {
+void GrGLProgram::setData(const GrOptDrawState& optState) {
GrColor color = optState.getColor();
uint8_t coverage = optState.getCoverage();
this->setColor(optState, color);
this->setCoverage(optState, coverage);
- this->setMatrixAndRenderTargetHeight(drawType, optState);
+ this->setMatrixAndRenderTargetHeight(optState);
const GrDeviceCoordTexture* dstCopy = optState.getDstCopy();
if (dstCopy) {
@@ -164,7 +164,7 @@
this->setFragmentData(optState);
// Some of GrGLProgram subclasses need to update state here
- this->didSetData(drawType);
+ this->didSetData(optState.drawType());
}
void GrGLProgram::setFragmentData(const GrOptDrawState& optState) {
@@ -241,8 +241,7 @@
}
}
-void GrGLProgram::setMatrixAndRenderTargetHeight(GrGpu::DrawType drawType,
- const GrOptDrawState& optState) {
+void GrGLProgram::setMatrixAndRenderTargetHeight(const GrOptDrawState& optState) {
// Load the RT height uniform if it is needed to y-flip gl_FragCoord.
if (fBuiltinUniformHandles.fRTHeightUni.isValid() &&
fMatrixState.fRenderTargetSize.fHeight != optState.getRenderTarget()->height()) {
@@ -251,11 +250,10 @@
}
// call subclasses to set the actual view matrix
- this->onSetMatrixAndRenderTargetHeight(drawType, optState);
+ this->onSetMatrixAndRenderTargetHeight(optState);
}
-void GrGLProgram::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawType,
- const GrOptDrawState& optState) {
+void GrGLProgram::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optState) {
const GrRenderTarget* rt = optState.getRenderTarget();
SkISize size;
size.set(rt->width(), rt->height());
@@ -289,9 +287,8 @@
: INHERITED(gpu, desc, builtinUniforms, programID, uniforms, NULL, fragmentProcessors) {
}
-void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(GrGpu::DrawType drawType,
- const GrOptDrawState& optState) {
- SkASSERT(GrGpu::IsPathRenderingDrawType(drawType));
+void GrGLNvprProgramBase::onSetMatrixAndRenderTargetHeight(const GrOptDrawState& optState) {
+ SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType()));
const GrRenderTarget* rt = optState.getRenderTarget();
SkISize size;
size.set(rt->width(), rt->height());
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index a273a03..36bf860 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -129,7 +129,7 @@
* GrGpuGL object to bind the textures required by the GrGLProcessors. The color and coverage
* stages come from GrGLProgramDesc::Build().
*/
- void setData(const GrOptDrawState&, GrGpu::DrawType);
+ void setData(const GrOptDrawState&);
protected:
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
@@ -167,8 +167,8 @@
virtual void didSetData(GrGpu::DrawType);
// Helper for setData() that sets the view matrix and loads the render target height uniform
- void setMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDrawState&);
- virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDrawState&);
+ void setMatrixAndRenderTargetHeight(const GrOptDrawState&);
+ virtual void onSetMatrixAndRenderTargetHeight(const GrOptDrawState&);
// these reflect the current values of uniforms (GL uniform values travel with program)
MatrixState fMatrixState;
@@ -206,7 +206,7 @@
GrGLuint programID,
const UniformInfoArray&,
GrGLInstalledFragProcs* fragmentProcessors);
- virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDrawState&);
+ virtual void onSetMatrixAndRenderTargetHeight(const GrOptDrawState&);
typedef GrGLProgram INHERITED;
};
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index 74f669f..f8dbbc2 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -196,8 +196,6 @@
header->fHasGeometryProcessor = optState.hasGeometryProcessor();
- header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType;
-
bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType);
if (gpu->caps()->pathRenderingSupport() && isPathRendering) {
header->fUseNvpr = true;
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index df35d2c..383427d 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1894,14 +1894,14 @@
}
}
-void GrGpuGL::flushAAState(const GrOptDrawState& optState, DrawType type) {
+void GrGpuGL::flushAAState(const GrOptDrawState& optState) {
// At least some ATI linux drivers will render GL_LINES incorrectly when MSAA state is enabled but
// the target is not multisampled. Single pixel wide lines are rendered thicker than 1 pixel wide.
#if 0
// Replace RT_HAS_MSAA with this definition once this driver bug is no longer a relevant concern
#define RT_HAS_MSAA rt->isMultisampled()
#else
- #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == type)
+ #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == optState.drawType())
#endif
const GrRenderTarget* rt = optState.getRenderTarget();
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index 4224ba6..8a60988 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -155,7 +155,7 @@
virtual void clearStencil(GrRenderTarget*) SK_OVERRIDE;
- virtual bool flushGraphicsState(const GrOptDrawState&, DrawType) SK_OVERRIDE;
+ virtual bool flushGraphicsState(const GrOptDrawState&) SK_OVERRIDE;
// GrDrawTarget overrides
virtual void didAddGpuTraceMarker() SK_OVERRIDE;
@@ -188,7 +188,7 @@
~ProgramCache();
void abandon();
- GrGLProgram* getProgram(const GrOptDrawState&, DrawType);
+ GrGLProgram* getProgram(const GrOptDrawState&);
private:
enum {
@@ -248,7 +248,7 @@
void flushRenderTarget(GrGLRenderTarget*, const SkIRect* bounds);
void flushStencil(const GrStencilSettings&, DrawType);
- void flushAAState(const GrOptDrawState&, DrawType);
+ void flushAAState(const GrOptDrawState&);
bool configToGLFormats(GrPixelConfig config,
bool getSizedInternal,
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index cb8810c..a808aa8 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -91,7 +91,7 @@
return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less);
}
-GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, DrawType type) {
+GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState) {
#ifdef PROGRAM_CACHE_STATS
++fTotalRequests;
#endif
@@ -126,7 +126,7 @@
#ifdef PROGRAM_CACHE_STATS
++fCacheMisses;
#endif
- GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, type, fGpu);
+ GrGLProgram* program = GrGLProgramBuilder::CreateProgram(optState, fGpu);
if (NULL == program) {
return NULL;
}
@@ -201,11 +201,11 @@
#define GL_CALL(X) GR_GL_CALL(this->glInterface(), X)
-bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, DrawType type) {
+bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState) {
// GrGpu::setupClipAndFlushState should have already checked this and bailed if not true.
SkASSERT(optState.getRenderTarget());
- if (kStencilPath_DrawType == type) {
+ if (kStencilPath_DrawType == optState.drawType()) {
const GrRenderTarget* rt = optState.getRenderTarget();
SkISize size;
size.set(rt->width(), rt->height());
@@ -216,7 +216,7 @@
GrBlendCoeff srcCoeff = optState.getSrcBlendCoeff();
GrBlendCoeff dstCoeff = optState.getDstBlendCoeff();
- fCurrentProgram.reset(fProgramCache->getProgram(optState, type));
+ fCurrentProgram.reset(fProgramCache->getProgram(optState));
if (NULL == fCurrentProgram.get()) {
SkDEBUGFAIL("Failed to create program!");
return false;
@@ -230,15 +230,15 @@
fHWProgramID = programID;
}
- this->flushBlend(optState, kDrawLines_DrawType == type, srcCoeff, dstCoeff);
+ this->flushBlend(optState, kDrawLines_DrawType == optState.drawType(), srcCoeff, dstCoeff);
- fCurrentProgram->setData(optState, type);
+ fCurrentProgram->setData(optState);
}
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(optState.getRenderTarget());
- this->flushStencil(optState.getStencil(), type);
+ this->flushStencil(optState.getStencil(), optState.drawType());
this->flushScissor(optState.getScissorState(), glRT->getViewport(), glRT->origin());
- this->flushAAState(optState, type);
+ this->flushAAState(optState);
// This must come after textures are flushed because a texture may need
// to be msaa-resolved (which will modify bound FBO state).
diff --git a/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp b/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp
index f35c9ba..ef8d1a2 100644
--- a/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLGeometryShaderBuilder.cpp
@@ -48,9 +48,7 @@
geomShaderSrc.append("void main() {\n");
geomShaderSrc.append("\tfor (int i = 0; i < 3; ++i) {\n"
"\t\tgl_Position = gl_in[i].gl_Position;\n");
- if (fProgramBuilder->desc().header().fEmitsPointSize) {
- geomShaderSrc.append("\t\tgl_PointSize = 1.0;\n");
- }
+ geomShaderSrc.append("\t\tgl_PointSize = 1.0;\n");
SkASSERT(fInputs.count() == fOutputs.count());
for (int i = 0; i < fInputs.count(); ++i) {
geomShaderSrc.appendf("\t\t%s = %s[i];\n",
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 64150a4..aa9e40c 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -28,13 +28,10 @@
const int GrGLProgramBuilder::kVarsPerBlock = 8;
-GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState,
- GrGpu::DrawType drawType,
- GrGpuGL* gpu) {
+GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, GrGpuGL* gpu) {
// create a builder. This will be handed off to effects so they can use it to add
// uniforms, varyings, textures, etc
SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState,
- drawType,
optState.hasGeometryProcessor(),
gpu));
@@ -73,7 +70,6 @@
GrGLProgramBuilder*
GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawState& optState,
- GrGpu::DrawType drawType,
bool hasGeometryProcessor,
GrGpuGL* gpu) {
const GrProgramDesc& desc = optState.programDesc();
@@ -234,9 +230,7 @@
fVS.setupUniformViewMatrix();
const GrProgramDesc::KeyHeader& header = this->header();
- if (header.fEmitsPointSize) {
- fVS.codeAppend("gl_PointSize = 1.0;");
- }
+ fVS.codeAppend("gl_PointSize = 1.0;");
// Setup position
// TODO it'd be possible to remove these from the vertexshader builder and have them
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 76f7ae9..973ae5e 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -186,7 +186,7 @@
* to be used.
* @return true if generation was successful.
*/
- static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGpu::DrawType, GrGpuGL*);
+ static GrGLProgram* CreateProgram(const GrOptDrawState&, GrGpuGL*);
virtual UniformHandle addUniform(uint32_t visibility,
GrSLType type,
@@ -246,7 +246,6 @@
typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&,
- GrGpu::DrawType,
bool hasGeometryProcessor,
GrGpuGL*);