Chromium Code Reviews| Index: src/gpu/gl/GrGLProgramDesc.cpp |
| diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp |
| index b49cff97af739ed22d0b804475914c232d54757a..1d6f34b8ce5f24b89b23eb5f6c1f33246a38a69e 100644 |
| --- a/src/gpu/gl/GrGLProgramDesc.cpp |
| +++ b/src/gpu/gl/GrGLProgramDesc.cpp |
| @@ -14,25 +14,11 @@ |
| #include "SkChecksum.h" |
| -bool GrGLProgramDesc::GetEffectKeyAndUpdateStats(const GrEffectStage& stage, |
| - const GrGLCaps& caps, |
| - bool useExplicitLocalCoords, |
| - GrEffectKeyBuilder* b, |
| - uint16_t* effectKeySize, |
| - bool* setTrueIfReadsDst, |
| - bool* setTrueIfReadsPos, |
| - bool* setTrueIfRequiresVertexShader) { |
| +bool GrGLProgramDesc::GetEffectKey(const GrEffectStage& stage, const GrGLCaps& caps, |
| + bool useExplicitLocalCoords, GrEffectKeyBuilder* b, |
| + uint16_t* effectKeySize) { |
| const GrBackendEffectFactory& factory = stage.getEffect()->getFactory(); |
| const GrEffect& effect = *stage.getEffect(); |
| - if (effect.willReadDstColor()) { |
| - *setTrueIfReadsDst = true; |
| - } |
| - if (effect.willReadFragmentPosition()) { |
| - *setTrueIfReadsPos = true; |
| - } |
| - if (effect.requiresVertexShader()) { |
| - *setTrueIfRequiresVertexShader = true; |
| - } |
| factory.getGLEffectKey(effect, caps, b); |
| size_t size = b->size(); |
| if (size > SK_MaxU16) { |
| @@ -76,12 +62,6 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
| bool requiresLocalCoordAttrib = optState.numTotalStages() > 0 && |
| optState.hasLocalCoordAttribute(); |
| - bool readsDst = false; |
| - bool readFragPosition = false; |
| - |
| - // Provide option for shader programs without vertex shader only when drawing paths. |
| - bool requiresVertexShader = !GrGpu::IsPathRenderingDrawType(drawType); |
| - |
| int numStages = optState.numTotalStages(); |
| GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t)); |
| @@ -105,18 +85,14 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
| GrEffectKeyBuilder b(&desc->fKey); |
| uint16_t effectKeySize; |
| uint32_t effectOffset = desc->fKey.count(); |
| - effectKeySuccess |= GetEffectKeyAndUpdateStats( |
| - *optState.getGeometryProcessor(), gpu->glCaps(), |
| - requiresLocalCoordAttrib, &b, |
| - &effectKeySize, &readsDst, |
| - &readFragPosition, &requiresVertexShader); |
| + effectKeySuccess |= GetEffectKey(*optState.getGeometryProcessor(), gpu->glCaps(), |
| + requiresLocalCoordAttrib, &b, &effectKeySize); |
| effectKeySuccess |= (effectOffset <= SK_MaxU16); |
| offsetAndSize[0] = SkToU16(effectOffset); |
| offsetAndSize[1] = effectKeySize; |
| ++offsetAndSizeIndex; |
| *geometryProcessor = optState.getGeometryProcessor(); |
| - SkASSERT(requiresVertexShader); |
| header->fHasGeometryProcessor = true; |
| } |
| @@ -125,21 +101,16 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
| reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset + |
| offsetAndSizeIndex * 2 * sizeof(uint16_t)); |
| - bool effectRequiresVertexShader = false; |
| GrEffectKeyBuilder b(&desc->fKey); |
| uint16_t effectKeySize; |
| uint32_t effectOffset = desc->fKey.count(); |
| - effectKeySuccess |= GetEffectKeyAndUpdateStats( |
| - optState.getColorStage(s), gpu->glCaps(), |
| - requiresLocalCoordAttrib, &b, |
| - &effectKeySize, &readsDst, |
| - &readFragPosition, &effectRequiresVertexShader); |
| + effectKeySuccess |= GetEffectKey(optState.getColorStage(s), gpu->glCaps(), |
| + requiresLocalCoordAttrib, &b, &effectKeySize); |
| effectKeySuccess |= (effectOffset <= SK_MaxU16); |
| offsetAndSize[0] = SkToU16(effectOffset); |
| offsetAndSize[1] = effectKeySize; |
| ++offsetAndSizeIndex; |
| - SkASSERT(!effectRequiresVertexShader); |
| } |
| for (int s = 0; s < optState.numCoverageStages(); ++s) { |
| @@ -147,21 +118,16 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
| reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset + |
| offsetAndSizeIndex * 2 * sizeof(uint16_t)); |
| - bool effectRequiresVertexShader = false; |
| GrEffectKeyBuilder b(&desc->fKey); |
| uint16_t effectKeySize; |
| uint32_t effectOffset = desc->fKey.count(); |
| - effectKeySuccess |= GetEffectKeyAndUpdateStats( |
| - optState.getCoverageStage(s), gpu->glCaps(), |
| - requiresLocalCoordAttrib, &b, |
| - &effectKeySize, &readsDst, |
| - &readFragPosition, &effectRequiresVertexShader); |
| + effectKeySuccess |= GetEffectKey(optState.getCoverageStage(s), gpu->glCaps(), |
| + requiresLocalCoordAttrib, &b, &effectKeySize); |
| effectKeySuccess |= (effectOffset <= SK_MaxU16); |
| offsetAndSize[0] = SkToU16(effectOffset); |
| offsetAndSize[1] = effectKeySize; |
| ++offsetAndSizeIndex; |
| - SkASSERT(!effectRequiresVertexShader); |
| } |
| if (!effectKeySuccess) { |
| @@ -172,7 +138,14 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
| // Because header is a pointer into the dynamic array, we can't push any new data into the key |
| // below here. |
| - header->fRequiresVertexShader = requiresVertexShader || requiresLocalCoordAttrib; |
| + // We will only use vertex shader if we have a geometry processor and we should not have a |
|
bsalomon
2014/09/16 21:54:20
use->require ?
egdaniel
2014/09/17 15:00:14
Done.
|
| + // geometry processor if we are doing path rendering. |
| + // TODO: Once we have a default GeometryProcessor on all programs not using path rendering, |
| + // we can remove the !GrGpu::IsPathRenderingDrawType(drawType) in setting header |
| + SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType) || !optState.requiresVertexShader()); |
|
bsalomon
2014/09/16 21:54:20
can requriesLocalCoordAttrib be part of optState.r
egdaniel
2014/09/17 15:00:14
Moved the checking of requires local coord attrib
|
| + header->fRequiresVertexShader = optState.requiresVertexShader() || |
| + requiresLocalCoordAttrib || |
| + !GrGpu::IsPathRenderingDrawType(drawType); |
| header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; |
| // Currently the experimental GS will only work with triangle prims (and it doesn't do anything |
| @@ -206,7 +179,7 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
| header->fRequiresVertexShader = true; |
| } |
| - if (readsDst) { |
| + if (optState.readsDst()) { |
| SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); |
| const GrTexture* dstCopyTexture = NULL; |
| if (dstCopy) { |
| @@ -219,7 +192,7 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
| header->fDstReadKey = 0; |
| } |
| - if (readFragPosition) { |
| + if (optState.readsFragPosition()) { |
| header->fFragPosKey = GrGLFragmentShaderBuilder::KeyForFragmentPosition( |
| optState.getRenderTarget(), gpu->glCaps()); |
| } else { |
| @@ -277,7 +250,7 @@ bool GrGLProgramDesc::Build(const GrOptDrawState& optState, |
| header->fCoverageOutput = kSecondaryCoverageISC_CoverageOutput; |
| separateCoverageFromColor = true; |
| } |
| - } else if (readsDst && |
| + } else if (optState.readsDst() && |
| kOne_GrBlendCoeff == srcCoeff && |
| kZero_GrBlendCoeff == dstCoeff) { |
| header->fCoverageOutput = kCombineWithDst_CoverageOutput; |