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 #include "GrGLProgramDesc.h" | 7 #include "GrGLProgramDesc.h" |
8 | 8 |
9 #include "GrGLProcessor.h" | 9 #include "GrGLProcessor.h" |
10 #include "GrBackendProcessorFactory.h" | 10 #include "GrBackendProcessorFactory.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 * every effect using this function. It is also responsible for inserting the ef
fect's class ID | 116 * every effect using this function. It is also responsible for inserting the ef
fect's class ID |
117 * which must be different for every GrProcessor subclass. It can fail if an eff
ect uses too many | 117 * which must be different for every GrProcessor subclass. It can fail if an eff
ect uses too many |
118 * textures, transforms, etc, for the space allotted in the meta-key. NOTE, bot
h FPs and GPs share | 118 * textures, transforms, etc, for the space allotted in the meta-key. NOTE, bot
h FPs and GPs share |
119 * this function because it is hairy, though FPs do not have attribs, and GPs do
not have transforms | 119 * this function because it is hairy, though FPs do not have attribs, and GPs do
not have transforms |
120 */ | 120 */ |
121 static bool get_meta_key(const GrProcessor& proc, | 121 static bool get_meta_key(const GrProcessor& proc, |
122 const GrGLCaps& caps, | 122 const GrGLCaps& caps, |
123 uint32_t transformKey, | 123 uint32_t transformKey, |
124 uint32_t attribKey, | 124 uint32_t attribKey, |
125 GrProcessorKeyBuilder* b) { | 125 GrProcessorKeyBuilder* b) { |
| 126 const GrBackendProcessorFactory& factory = proc.getFactory(); |
| 127 factory.getGLProcessorKey(proc, caps, b); |
| 128 |
126 size_t processorKeySize = b->size(); | 129 size_t processorKeySize = b->size(); |
127 uint32_t textureKey = gen_texture_key(proc, caps); | 130 uint32_t textureKey = gen_texture_key(proc, caps); |
128 uint32_t classID = proc.getFactory().classID(); | 131 uint32_t classID = proc.getFactory().classID(); |
129 | 132 |
130 // Currently we allow 16 bits for each of the above portions of the meta-key
. Fail if they | 133 // Currently we allow 16 bits for each of the above portions of the meta-key
. Fail if they |
131 // don't fit. | 134 // don't fit. |
132 static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16); | 135 static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16); |
133 if ((textureKey | transformKey | classID) & kMetaKeyInvalidMask) { | 136 if ((textureKey | transformKey | classID) & kMetaKeyInvalidMask) { |
134 return false; | 137 return false; |
135 } | 138 } |
(...skipping 24 matching lines...) Expand all Loading... |
160 | 163 |
161 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); | 164 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); |
162 // Make room for everything up to the effect keys. | 165 // Make room for everything up to the effect keys. |
163 desc->fKey.reset(); | 166 desc->fKey.reset(); |
164 desc->fKey.push_back_n(kProcessorKeysOffset); | 167 desc->fKey.push_back_n(kProcessorKeysOffset); |
165 | 168 |
166 // We can only have one effect which touches the vertex shader | 169 // We can only have one effect which touches the vertex shader |
167 if (optState.hasGeometryProcessor()) { | 170 if (optState.hasGeometryProcessor()) { |
168 const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); | 171 const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); |
169 GrProcessorKeyBuilder b(&desc->fKey); | 172 GrProcessorKeyBuilder b(&desc->fKey); |
170 const GrBackendGeometryProcessorFactory& factory = gp.getFactory(); | |
171 factory.getGLProcessorKey(gp, optState.getBatchTracker(), gpu->glCaps(),
&b); | |
172 if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) { | 173 if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) { |
173 desc->fKey.reset(); | 174 desc->fKey.reset(); |
174 return false; | 175 return false; |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 for (int s = 0; s < optState.numFragmentStages(); ++s) { | 179 for (int s = 0; s < optState.numFragmentStages(); ++s) { |
179 const GrPendingFragmentStage& fps = optState.getFragmentStage(s); | 180 const GrPendingFragmentStage& fps = optState.getFragmentStage(s); |
180 const GrFragmentProcessor& fp = *fps.getProcessor(); | |
181 GrProcessorKeyBuilder b(&desc->fKey); | 181 GrProcessorKeyBuilder b(&desc->fKey); |
182 const GrBackendFragmentProcessorFactory& factory = fp.getFactory(); | |
183 factory.getGLProcessorKey(fp, gpu->glCaps(), &b); | |
184 if (!get_meta_key(*fps.getProcessor(), gpu->glCaps(), | 182 if (!get_meta_key(*fps.getProcessor(), gpu->glCaps(), |
185 gen_transform_key(fps, requiresLocalCoordAttrib), 0, &b
)) { | 183 gen_transform_key(fps, requiresLocalCoordAttrib), 0, &b
)) { |
186 desc->fKey.reset(); | 184 desc->fKey.reset(); |
187 return false; | 185 return false; |
188 } | 186 } |
189 } | 187 } |
190 | 188 |
191 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- | 189 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- |
192 // Because header is a pointer into the dynamic array, we can't push any new
data into the key | 190 // Because header is a pointer into the dynamic array, we can't push any new
data into the key |
193 // below here. | 191 // below here. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 251 } |
254 | 252 |
255 header->fPrimaryOutputType = descInfo.fPrimaryOutputType; | 253 header->fPrimaryOutputType = descInfo.fPrimaryOutputType; |
256 header->fSecondaryOutputType = descInfo.fSecondaryOutputType; | 254 header->fSecondaryOutputType = descInfo.fSecondaryOutputType; |
257 | 255 |
258 header->fColorEffectCnt = optState.numColorStages(); | 256 header->fColorEffectCnt = optState.numColorStages(); |
259 header->fCoverageEffectCnt = optState.numCoverageStages(); | 257 header->fCoverageEffectCnt = optState.numCoverageStages(); |
260 desc->finalize(); | 258 desc->finalize(); |
261 return true; | 259 return true; |
262 } | 260 } |
OLD | NEW |