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 "GrGLFragmentProcessor.h" | 9 #include "GrGLFragmentProcessor.h" |
10 #include "GrProcessor.h" | 10 #include "GrProcessor.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 fp.getGLProcessorKey(*caps.glslCaps(), b); | 104 fp.getGLProcessorKey(*caps.glslCaps(), b); |
105 | 105 |
106 //**** use glslCaps here? | 106 //**** use glslCaps here? |
107 return get_meta_key(fp, caps, primProc.getTransformKey(fp.coordTransforms(), | 107 return get_meta_key(fp, caps, primProc.getTransformKey(fp.coordTransforms(), |
108 fp.numTransformsExclC
hildren()), b); | 108 fp.numTransformsExclC
hildren()), b); |
109 } | 109 } |
110 | 110 |
111 bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc, | 111 bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc, |
112 const GrPrimitiveProcessor& primProc, | 112 const GrPrimitiveProcessor& primProc, |
113 const GrPipeline& pipeline, | 113 const GrPipeline& pipeline, |
114 const GrGLGpu* gpu, | 114 const GrGLGpu* gpu) { |
115 const GrBatchTracker& batchTracker) { | |
116 // The descriptor is used as a cache key. Thus when a field of the | 115 // The descriptor is used as a cache key. Thus when a field of the |
117 // descriptor will not affect program generation (because of the attribute | 116 // descriptor will not affect program generation (because of the attribute |
118 // bindings in use or other descriptor field settings) it should be set | 117 // bindings in use or other descriptor field settings) it should be set |
119 // to a canonical value to avoid duplicate programs with different keys. | 118 // to a canonical value to avoid duplicate programs with different keys. |
120 | 119 |
121 GrGLProgramDesc* glDesc = (GrGLProgramDesc*) desc; | 120 GrGLProgramDesc* glDesc = (GrGLProgramDesc*) desc; |
122 | 121 |
123 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); | 122 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); |
124 // Make room for everything up to the effect keys. | 123 // Make room for everything up to the effect keys. |
125 glDesc->key().reset(); | 124 glDesc->key().reset(); |
126 glDesc->key().push_back_n(kProcessorKeysOffset); | 125 glDesc->key().push_back_n(kProcessorKeysOffset); |
127 | 126 |
128 GrProcessorKeyBuilder b(&glDesc->key()); | 127 GrProcessorKeyBuilder b(&glDesc->key()); |
129 | 128 |
130 primProc.getGLProcessorKey(batchTracker, *gpu->glCaps().glslCaps(), &b); | 129 primProc.getGLProcessorKey(*gpu->glCaps().glslCaps(), &b); |
131 //**** use glslCaps here? | 130 //**** use glslCaps here? |
132 if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) { | 131 if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) { |
133 glDesc->key().reset(); | 132 glDesc->key().reset(); |
134 return false; | 133 return false; |
135 } | 134 } |
136 | 135 |
137 for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) { | 136 for (int i = 0; i < pipeline.numFragmentProcessors(); ++i) { |
138 const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i); | 137 const GrFragmentProcessor& fp = pipeline.getFragmentProcessor(i); |
139 if (!get_frag_proc_and_meta_keys(primProc, fp, gpu->glCaps(), &b)) { | 138 if (!get_frag_proc_and_meta_keys(primProc, fp, gpu->glCaps(), &b)) { |
140 glDesc->key().reset(); | 139 glDesc->key().reset(); |
(...skipping 23 matching lines...) Expand all Loading... |
164 gpu->glCaps())
; | 163 gpu->glCaps())
; |
165 } else { | 164 } else { |
166 header->fFragPosKey = 0; | 165 header->fFragPosKey = 0; |
167 } | 166 } |
168 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); | 167 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); |
169 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); | 168 header->fColorEffectCnt = pipeline.numColorFragmentProcessors(); |
170 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); | 169 header->fCoverageEffectCnt = pipeline.numCoverageFragmentProcessors(); |
171 glDesc->finalize(); | 170 glDesc->finalize(); |
172 return true; | 171 return true; |
173 } | 172 } |
OLD | NEW |