OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrGLProgramDesc.h" | 8 #include "GrGLProgramDesc.h" |
9 #include "GrBackendEffectFactory.h" | 9 #include "GrBackendEffectFactory.h" |
10 #include "GrDrawEffect.h" | 10 #include "GrDrawEffect.h" |
11 #include "GrEffect.h" | 11 #include "GrEffect.h" |
| 12 #include "GrGLShaderBuilder.h" |
12 #include "GrGpuGL.h" | 13 #include "GrGpuGL.h" |
13 | 14 |
14 void GrGLProgramDesc::Build(const GrDrawState& drawState, | 15 void GrGLProgramDesc::Build(const GrDrawState& drawState, |
15 bool isPoints, | 16 bool isPoints, |
16 GrDrawState::BlendOptFlags blendOpts, | 17 GrDrawState::BlendOptFlags blendOpts, |
17 GrBlendCoeff srcCoeff, | 18 GrBlendCoeff srcCoeff, |
18 GrBlendCoeff dstCoeff, | 19 GrBlendCoeff dstCoeff, |
19 const GrGpuGL* gpu, | 20 const GrGpuGL* gpu, |
| 21 const GrDeviceCoordTexture* dstCopy, |
20 GrGLProgramDesc* desc) { | 22 GrGLProgramDesc* desc) { |
21 | 23 |
22 // This should already have been caught | 24 // This should already have been caught |
23 GrAssert(!(GrDrawState::kSkipDraw_BlendOptFlag & blendOpts)); | 25 GrAssert(!(GrDrawState::kSkipDraw_BlendOptFlag & blendOpts)); |
24 | 26 |
25 bool skipCoverage = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_BlendO
ptFlag); | 27 bool skipCoverage = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_BlendO
ptFlag); |
26 | 28 |
27 bool skipColor = SkToBool(blendOpts & (GrDrawState::kEmitTransBlack_BlendOpt
Flag | | 29 bool skipColor = SkToBool(blendOpts & (GrDrawState::kEmitTransBlack_BlendOpt
Flag | |
28 GrDrawState::kEmitCoverage_BlendOptFl
ag)); | 30 GrDrawState::kEmitCoverage_BlendOptFl
ag)); |
29 | 31 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 if (skipCoverage) { | 75 if (skipCoverage) { |
74 desc->fCoverageInput = kTransBlack_ColorInput; | 76 desc->fCoverageInput = kTransBlack_ColorInput; |
75 } else if (covIsSolidWhite) { | 77 } else if (covIsSolidWhite) { |
76 desc->fCoverageInput = kSolidWhite_ColorInput; | 78 desc->fCoverageInput = kSolidWhite_ColorInput; |
77 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresAttributeCoverage) { | 79 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresAttributeCoverage) { |
78 desc->fCoverageInput = kUniform_ColorInput; | 80 desc->fCoverageInput = kUniform_ColorInput; |
79 } else { | 81 } else { |
80 desc->fCoverageInput = kAttribute_ColorInput; | 82 desc->fCoverageInput = kAttribute_ColorInput; |
81 } | 83 } |
82 | 84 |
| 85 bool readsDst = false; |
83 int lastEnabledStage = -1; | 86 int lastEnabledStage = -1; |
84 | 87 |
85 for (int s = 0; s < GrDrawState::kNumStages; ++s) { | 88 for (int s = 0; s < GrDrawState::kNumStages; ++s) { |
86 | 89 |
87 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove
rage; | 90 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove
rage; |
88 if (!skip && drawState.isStageEnabled(s)) { | 91 if (!skip && drawState.isStageEnabled(s)) { |
89 lastEnabledStage = s; | 92 lastEnabledStage = s; |
90 const GrEffectRef& effect = *drawState.getStage(s).getEffect(); | 93 const GrEffectRef& effect = *drawState.getStage(s).getEffect(); |
91 const GrBackendEffectFactory& factory = effect->getFactory(); | 94 const GrBackendEffectFactory& factory = effect->getFactory(); |
92 bool explicitLocalCoords = (drawState.getAttribBindings() & | 95 bool explicitLocalCoords = (drawState.getAttribBindings() & |
93 GrDrawState::kLocalCoords_AttribBindings
Bit); | 96 GrDrawState::kLocalCoords_AttribBindings
Bit); |
94 GrDrawEffect drawEffect(drawState.getStage(s), explicitLocalCoords); | 97 GrDrawEffect drawEffect(drawState.getStage(s), explicitLocalCoords); |
95 desc->fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps()
); | 98 desc->fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps()
); |
| 99 if (effect->willReadDst()) { |
| 100 readsDst = true; |
| 101 } |
96 } else { | 102 } else { |
97 desc->fEffectKeys[s] = 0; | 103 desc->fEffectKeys[s] = 0; |
98 } | 104 } |
99 } | 105 } |
100 | 106 |
| 107 if (readsDst) { |
| 108 GrAssert(NULL != dstCopy); |
| 109 desc->fDstRead = GrGLShaderBuilder::KeyForDstRead(dstCopy->texture(), gp
u->glCaps()); |
| 110 GrAssert(0 != desc->fDstRead); |
| 111 } else { |
| 112 desc->fDstRead = 0; |
| 113 } |
| 114 |
101 desc->fDualSrcOutput = kNone_DualSrcOutput; | 115 desc->fDualSrcOutput = kNone_DualSrcOutput; |
102 | 116 |
103 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything | 117 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything |
104 // other than pass through values from the VS to the FS anyway). | 118 // other than pass through values from the VS to the FS anyway). |
105 #if GR_GL_EXPERIMENTAL_GS | 119 #if GR_GL_EXPERIMENTAL_GS |
106 #if 0 | 120 #if 0 |
107 desc->fExperimentalGS = gpu->caps().geometryShaderSupport(); | 121 desc->fExperimentalGS = gpu->caps().geometryShaderSupport(); |
108 #else | 122 #else |
109 desc->fExperimentalGS = false; | 123 desc->fExperimentalGS = false; |
110 #endif | 124 #endif |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 if (requiresAttributeCoverage) { | 202 if (requiresAttributeCoverage) { |
189 GrAssert(desc->fCoverageAttributeIndex < GrDrawState::kVertexAttribCnt); | 203 GrAssert(desc->fCoverageAttributeIndex < GrDrawState::kVertexAttribCnt); |
190 GrAssert(GrGLAttribTypeToLayout(vertexAttribs[desc->fCoverageAttributeIn
dex].fType).fCount == 4); | 204 GrAssert(GrGLAttribTypeToLayout(vertexAttribs[desc->fCoverageAttributeIn
dex].fType).fCount == 4); |
191 } | 205 } |
192 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { | 206 if (desc->fAttribBindings & GrDrawState::kLocalCoords_AttribBindingsBit) { |
193 GrAssert(desc->fLocalCoordsAttributeIndex < GrDrawState::kVertexAttribCn
t); | 207 GrAssert(desc->fLocalCoordsAttributeIndex < GrDrawState::kVertexAttribCn
t); |
194 GrAssert(GrGLAttribTypeToLayout(vertexAttribs[desc->fLocalCoordsAttribut
eIndex].fType).fCount == 2); | 208 GrAssert(GrGLAttribTypeToLayout(vertexAttribs[desc->fLocalCoordsAttribut
eIndex].fType).fCount == 2); |
195 } | 209 } |
196 #endif | 210 #endif |
197 } | 211 } |
OLD | NEW |