move program descriptor generation to flush
BUG=skia: Committed: https://skia.googlesource.com/skia/+/829e1b80b1020b17f2078020c990e079b70c077c Review URL: https://codereview.chromium.org/777673003
This commit is contained in:
parent
051e56df8f
commit
dafa4d09cb
@ -277,7 +277,7 @@ const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const {
|
||||
|
||||
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 @@ void GrGpu::stencilPath(const GrOptDrawState& ds,
|
||||
const GrStencilSettings& stencilSettings) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
if (!this->flushGraphicsState(ds, kStencilPath_DrawType)) {
|
||||
if (!this->flushGraphicsState(ds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -301,7 +301,7 @@ void GrGpu::drawPath(const GrOptDrawState& ds,
|
||||
const GrStencilSettings& stencilSettings) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
if (!this->flushGraphicsState(ds, kDrawPath_DrawType)) {
|
||||
if (!this->flushGraphicsState(ds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ void GrGpu::drawPaths(const GrOptDrawState& ds,
|
||||
const GrStencilSettings& stencilSettings) {
|
||||
this->handleDirtyContext();
|
||||
|
||||
if (!this->flushGraphicsState(ds, kDrawPaths_DrawType)) {
|
||||
if (!this->flushGraphicsState(ds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ private:
|
||||
// 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;
|
||||
|
@ -394,7 +394,7 @@ void GrInOrderDrawBuffer::onFlush() {
|
||||
|
||||
// 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 @@ void GrInOrderDrawBuffer::onFlush() {
|
||||
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 @@ bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
|
||||
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;
|
||||
|
@ -171,15 +171,15 @@ private:
|
||||
};
|
||||
|
||||
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.
|
||||
|
@ -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 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
||||
fDstCopy = *dstCopy;
|
||||
}
|
||||
|
||||
GrProgramDesc::DescInfo descInfo;
|
||||
|
||||
fFlags = 0;
|
||||
if (drawState.isHWAntialias()) {
|
||||
fFlags |= kHWAA_Flag;
|
||||
@ -65,34 +64,33 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
||||
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 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
|
||||
(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 @@ void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
|
||||
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 @@ void GrOptDrawState::adjustProgramForBlendOpt(const GrDrawState& ds,
|
||||
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 @@ static void get_stage_stats(const GrFragmentStage& stage, bool* readsDst, bool*
|
||||
}
|
||||
|
||||
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 @@ bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
|
||||
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 @@ public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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 @@ private:
|
||||
* 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 @@ private:
|
||||
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;
|
||||
|
@ -103,8 +103,6 @@ public:
|
||||
// effects that read the fragment position.
|
||||
// Otherwise, 0.
|
||||
|
||||
SkBool8 fEmitsPointSize;
|
||||
|
||||
ColorInput fColorInput : 8;
|
||||
ColorInput fCoverageInput : 8;
|
||||
|
||||
@ -136,6 +134,19 @@ public:
|
||||
|
||||
// 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;
|
||||
|
@ -140,7 +140,7 @@ private:
|
||||
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 {}
|
||||
|
||||
|
@ -123,13 +123,13 @@ void GrGLProgram::bindTextures(const GrGLInstalledProc* ip, const GrProcessor& p
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
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 @@ void GrGLProgram::setData(const GrOptDrawState& optState, GrGpu::DrawType drawTy
|
||||
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::setCoverage(const GrOptDrawState& optState, uint8_t coverage)
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ void GrGLProgram::setMatrixAndRenderTargetHeight(GrGpu::DrawType drawType,
|
||||
}
|
||||
|
||||
// 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 @@ GrGLNvprProgramBase::GrGLNvprProgramBase(GrGpuGL* gpu,
|
||||
: 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());
|
||||
|
@ -129,7 +129,7 @@ public:
|
||||
* 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 @@ protected:
|
||||
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 @@ protected:
|
||||
GrGLuint programID,
|
||||
const UniformInfoArray&,
|
||||
GrGLInstalledFragProcs* fragmentProcessors);
|
||||
virtual void onSetMatrixAndRenderTargetHeight(GrGpu::DrawType, const GrOptDrawState&);
|
||||
virtual void onSetMatrixAndRenderTargetHeight(const GrOptDrawState&);
|
||||
|
||||
typedef GrGLProgram INHERITED;
|
||||
};
|
||||
|
@ -196,8 +196,6 @@ bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState,
|
||||
|
||||
header->fHasGeometryProcessor = optState.hasGeometryProcessor();
|
||||
|
||||
header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType;
|
||||
|
||||
bool isPathRendering = GrGpu::IsPathRenderingDrawType(drawType);
|
||||
if (gpu->caps()->pathRenderingSupport() && isPathRendering) {
|
||||
header->fUseNvpr = true;
|
||||
|
@ -1894,14 +1894,14 @@ void GrGpuGL::flushStencil(const GrStencilSettings& stencilSettings, DrawType ty
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
@ -155,7 +155,7 @@ private:
|
||||
|
||||
|
||||
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 @@ private:
|
||||
~ProgramCache();
|
||||
|
||||
void abandon();
|
||||
GrGLProgram* getProgram(const GrOptDrawState&, DrawType);
|
||||
GrGLProgram* getProgram(const GrOptDrawState&);
|
||||
|
||||
private:
|
||||
enum {
|
||||
@ -248,7 +248,7 @@ private:
|
||||
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,
|
||||
|
@ -91,7 +91,7 @@ int GrGpuGL::ProgramCache::search(const GrProgramDesc& desc) const {
|
||||
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 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, D
|
||||
#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 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrOptDrawState& optState, D
|
||||
|
||||
#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 @@ bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, DrawType type)
|
||||
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 @@ bool GrGpuGL::flushGraphicsState(const GrOptDrawState& optState, DrawType type)
|
||||
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).
|
||||
|
@ -48,9 +48,7 @@ bool GrGLGeometryBuilder::compileAndAttachShaders(GrGLuint programId,
|
||||
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",
|
||||
|
@ -28,13 +28,10 @@ static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar:
|
||||
|
||||
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 @@ GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState,
|
||||
|
||||
GrGLProgramBuilder*
|
||||
GrGLProgramBuilder::CreateProgramBuilder(const GrOptDrawState& optState,
|
||||
GrGpu::DrawType drawType,
|
||||
bool hasGeometryProcessor,
|
||||
GrGpuGL* gpu) {
|
||||
const GrProgramDesc& desc = optState.programDesc();
|
||||
@ -234,9 +230,7 @@ void GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
|
||||
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
|
||||
|
@ -186,7 +186,7 @@ public:
|
||||
* 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 @@ protected:
|
||||
typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
|
||||
|
||||
static GrGLProgramBuilder* CreateProgramBuilder(const GrOptDrawState&,
|
||||
GrGpu::DrawType,
|
||||
bool hasGeometryProcessor,
|
||||
GrGpuGL*);
|
||||
|
||||
|
@ -384,11 +384,12 @@ bool GrDrawTarget::programUnitTest(int maxStages) {
|
||||
|
||||
// create optimized draw state, setup readDst texture if required, and build a descriptor
|
||||
// and program. ODS creation can fail, so we have to check
|
||||
GrOptDrawState ods(ds, gpu, scissor, &dstCopy, drawType);
|
||||
GrOptDrawState ods(ds, *gpu->caps(), scissor, &dstCopy, drawType);
|
||||
if (ods.mustSkip()) {
|
||||
continue;
|
||||
}
|
||||
SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(ods, drawType, gpu));
|
||||
ods.finalize(gpu);
|
||||
SkAutoTUnref<GrGLProgram> program(GrGLProgramBuilder::CreateProgram(ods, gpu));
|
||||
if (NULL == program.get()) {
|
||||
SkDebugf("Failed to create program!");
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user