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" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 desc->fCoverageInput = kTransBlack_ColorInput; | 69 desc->fCoverageInput = kTransBlack_ColorInput; |
70 } else if (covIsSolidWhite) { | 70 } else if (covIsSolidWhite) { |
71 desc->fCoverageInput = kSolidWhite_ColorInput; | 71 desc->fCoverageInput = kSolidWhite_ColorInput; |
72 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresCoverageAttrib) { | 72 } else if (GR_GL_NO_CONSTANT_ATTRIBUTES && !requiresCoverageAttrib) { |
73 desc->fCoverageInput = kUniform_ColorInput; | 73 desc->fCoverageInput = kUniform_ColorInput; |
74 } else { | 74 } else { |
75 desc->fCoverageInput = kAttribute_ColorInput; | 75 desc->fCoverageInput = kAttribute_ColorInput; |
76 } | 76 } |
77 | 77 |
78 bool readsDst = false; | 78 bool readsDst = false; |
79 bool readFragPosition = false; | |
79 int lastEnabledStage = -1; | 80 int lastEnabledStage = -1; |
80 | 81 |
81 for (int s = 0; s < GrDrawState::kNumStages; ++s) { | 82 for (int s = 0; s < GrDrawState::kNumStages; ++s) { |
82 | 83 |
83 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove rage; | 84 bool skip = s < drawState.getFirstCoverageStage() ? skipColor : skipCove rage; |
84 if (!skip && drawState.isStageEnabled(s)) { | 85 if (!skip && drawState.isStageEnabled(s)) { |
85 lastEnabledStage = s; | 86 lastEnabledStage = s; |
86 const GrEffectRef& effect = *drawState.getStage(s).getEffect(); | 87 const GrEffectRef& effect = *drawState.getStage(s).getEffect(); |
87 const GrBackendEffectFactory& factory = effect->getFactory(); | 88 const GrBackendEffectFactory& factory = effect->getFactory(); |
88 GrDrawEffect drawEffect(drawState.getStage(s), requiresLocalCoordAtt rib); | 89 GrDrawEffect drawEffect(drawState.getStage(s), requiresLocalCoordAtt rib); |
89 desc->fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps() ); | 90 desc->fEffectKeys[s] = factory.glEffectKey(drawEffect, gpu->glCaps() ); |
90 if (effect->willReadDstColor()) { | 91 if (effect->willReadDstColor()) { |
91 readsDst = true; | 92 readsDst = true; |
92 } | 93 } |
94 if (effect->willReadFragmentPosition()) { | |
95 readFragPosition = true; | |
96 } | |
93 } else { | 97 } else { |
94 desc->fEffectKeys[s] = 0; | 98 desc->fEffectKeys[s] = 0; |
95 } | 99 } |
96 } | 100 } |
97 | 101 |
98 if (readsDst) { | 102 if (readsDst) { |
99 GrAssert(NULL != dstCopy || gpu->caps()->dstReadInShaderSupport()); | 103 GrAssert(NULL != dstCopy || gpu->caps()->dstReadInShaderSupport()); |
100 const GrTexture* dstCopyTexture = NULL; | 104 const GrTexture* dstCopyTexture = NULL; |
101 if (NULL != dstCopy) { | 105 if (NULL != dstCopy) { |
102 dstCopyTexture = dstCopy->texture(); | 106 dstCopyTexture = dstCopy->texture(); |
103 } | 107 } |
104 desc->fDstRead = GrGLShaderBuilder::KeyForDstRead(dstCopyTexture, gpu->g lCaps()); | 108 desc->fDstRead = GrGLShaderBuilder::KeyForDstRead(dstCopyTexture, gpu->g lCaps()); |
105 GrAssert(0 != desc->fDstRead); | 109 GrAssert(0 != desc->fDstRead); |
106 } else { | 110 } else { |
107 desc->fDstRead = 0; | 111 desc->fDstRead = 0; |
108 } | 112 } |
109 | 113 |
114 if (readFragPosition) { | |
115 desc->fFragPos = GrGLShaderBuilder::KeyForFragmentPosition(drawState.get RenderTarget(), | |
116 gpu->glCaps() ); | |
117 } else { | |
robertphillips
2013/05/10 13:53:58
Use 'kNoFragPosRead_FragPosKey' here?
bsalomon
2013/05/13 15:16:49
It's private. I think in the long run the desc sho
| |
118 desc->fFragPos = 0; | |
119 } | |
120 | |
110 desc->fCoverageOutput = kModulate_CoverageOutput; | 121 desc->fCoverageOutput = kModulate_CoverageOutput; |
111 | 122 |
112 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything | 123 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything |
113 // other than pass through values from the VS to the FS anyway). | 124 // other than pass through values from the VS to the FS anyway). |
114 #if GR_GL_EXPERIMENTAL_GS | 125 #if GR_GL_EXPERIMENTAL_GS |
115 #if 0 | 126 #if 0 |
116 desc->fExperimentalGS = gpu->caps().geometryShaderSupport(); | 127 desc->fExperimentalGS = gpu->caps().geometryShaderSupport(); |
117 #else | 128 #else |
118 desc->fExperimentalGS = false; | 129 desc->fExperimentalGS = false; |
119 #endif | 130 #endif |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 | 202 |
192 if (requiresCoverageAttrib) { | 203 if (requiresCoverageAttrib) { |
193 desc->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex() ; | 204 desc->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex() ; |
194 } else if (GrGLProgramDesc::kAttribute_ColorInput == desc->fCoverageInput) { | 205 } else if (GrGLProgramDesc::kAttribute_ColorInput == desc->fCoverageInput) { |
195 GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); | 206 GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt); |
196 desc->fCoverageAttributeIndex = availableAttributeIndex; | 207 desc->fCoverageAttributeIndex = availableAttributeIndex; |
197 } else { | 208 } else { |
198 desc->fCoverageAttributeIndex = -1; | 209 desc->fCoverageAttributeIndex = -1; |
199 } | 210 } |
200 } | 211 } |
OLD | NEW |