| 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 | |
| 129 size_t processorKeySize = b->size(); | 126 size_t processorKeySize = b->size(); |
| 130 uint32_t textureKey = gen_texture_key(proc, caps); | 127 uint32_t textureKey = gen_texture_key(proc, caps); |
| 131 uint32_t classID = proc.getFactory().classID(); | 128 uint32_t classID = proc.getFactory().classID(); |
| 132 | 129 |
| 133 // Currently we allow 16 bits for each of the above portions of the meta-key
. Fail if they | 130 // Currently we allow 16 bits for each of the above portions of the meta-key
. Fail if they |
| 134 // don't fit. | 131 // don't fit. |
| 135 static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16); | 132 static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16); |
| 136 if ((textureKey | transformKey | classID) & kMetaKeyInvalidMask) { | 133 if ((textureKey | transformKey | classID) & kMetaKeyInvalidMask) { |
| 137 return false; | 134 return false; |
| 138 } | 135 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 163 | 160 |
| 164 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); | 161 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); |
| 165 // Make room for everything up to the effect keys. | 162 // Make room for everything up to the effect keys. |
| 166 desc->fKey.reset(); | 163 desc->fKey.reset(); |
| 167 desc->fKey.push_back_n(kProcessorKeysOffset); | 164 desc->fKey.push_back_n(kProcessorKeysOffset); |
| 168 | 165 |
| 169 // We can only have one effect which touches the vertex shader | 166 // We can only have one effect which touches the vertex shader |
| 170 if (optState.hasGeometryProcessor()) { | 167 if (optState.hasGeometryProcessor()) { |
| 171 const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); | 168 const GrGeometryProcessor& gp = *optState.getGeometryProcessor(); |
| 172 GrProcessorKeyBuilder b(&desc->fKey); | 169 GrProcessorKeyBuilder b(&desc->fKey); |
| 170 const GrBackendGeometryProcessorFactory& factory = gp.getFactory(); |
| 171 factory.getGLProcessorKey(gp, optState.getBatchTracker(), gpu->glCaps(),
&b); |
| 173 if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) { | 172 if (!get_meta_key(gp, gpu->glCaps(), 0, gen_attrib_key(gp), &b)) { |
| 174 desc->fKey.reset(); | 173 desc->fKey.reset(); |
| 175 return false; | 174 return false; |
| 176 } | 175 } |
| 177 } | 176 } |
| 178 | 177 |
| 179 for (int s = 0; s < optState.numFragmentStages(); ++s) { | 178 for (int s = 0; s < optState.numFragmentStages(); ++s) { |
| 180 const GrPendingFragmentStage& fps = optState.getFragmentStage(s); | 179 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); |
| 182 if (!get_meta_key(*fps.getProcessor(), gpu->glCaps(), | 184 if (!get_meta_key(*fps.getProcessor(), gpu->glCaps(), |
| 183 gen_transform_key(fps, requiresLocalCoordAttrib), 0, &b
)) { | 185 gen_transform_key(fps, requiresLocalCoordAttrib), 0, &b
)) { |
| 184 desc->fKey.reset(); | 186 desc->fKey.reset(); |
| 185 return false; | 187 return false; |
| 186 } | 188 } |
| 187 } | 189 } |
| 188 | 190 |
| 189 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- | 191 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- |
| 190 // Because header is a pointer into the dynamic array, we can't push any new
data into the key | 192 // Because header is a pointer into the dynamic array, we can't push any new
data into the key |
| 191 // below here. | 193 // below here. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 253 } |
| 252 | 254 |
| 253 header->fPrimaryOutputType = descInfo.fPrimaryOutputType; | 255 header->fPrimaryOutputType = descInfo.fPrimaryOutputType; |
| 254 header->fSecondaryOutputType = descInfo.fSecondaryOutputType; | 256 header->fSecondaryOutputType = descInfo.fSecondaryOutputType; |
| 255 | 257 |
| 256 header->fColorEffectCnt = optState.numColorStages(); | 258 header->fColorEffectCnt = optState.numColorStages(); |
| 257 header->fCoverageEffectCnt = optState.numCoverageStages(); | 259 header->fCoverageEffectCnt = optState.numCoverageStages(); |
| 258 desc->finalize(); | 260 desc->finalize(); |
| 259 return true; | 261 return true; |
| 260 } | 262 } |
| OLD | NEW |