Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: src/gpu/gl/GrGLProgramDesc.h

Issue 509153002: Initial change to create GeometryProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef GrGLProgramDesc_DEFINED 8 #ifndef GrGLProgramDesc_DEFINED
9 #define GrGLProgramDesc_DEFINED 9 #define GrGLProgramDesc_DEFINED
10 10
(...skipping 30 matching lines...) Expand all
41 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset> (); } 41 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset> (); }
42 42
43 // Gets the a checksum of the key. Can be used as a hash value for a fast lo okup in a cache. 43 // Gets the a checksum of the key. Can be used as a hash value for a fast lo okup in a cache.
44 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff set>(); } 44 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff set>(); }
45 45
46 // For unit testing. 46 // For unit testing.
47 bool setRandom(SkRandom*, 47 bool setRandom(SkRandom*,
48 const GrGpuGL* gpu, 48 const GrGpuGL* gpu,
49 const GrRenderTarget* dummyDstRenderTarget, 49 const GrRenderTarget* dummyDstRenderTarget,
50 const GrTexture* dummyDstCopyTexture, 50 const GrTexture* dummyDstCopyTexture,
51 const GrEffectStage* geometryProcessor,
51 const GrEffectStage* stages[], 52 const GrEffectStage* stages[],
52 int numColorStages, 53 int numColorStages,
53 int numCoverageStages, 54 int numCoverageStages,
54 int currAttribIndex); 55 int currAttribIndex);
55 56
56 /** 57 /**
57 * Builds a program descriptor from a GrDrawState. Whether the primitive typ e is points, the 58 * Builds a program descriptor from a GrDrawState. Whether the primitive typ e is points, the
58 * output of GrDrawState::getBlendOpts, and the caps of the GrGpuGL are also inputs. It also 59 * output of GrDrawState::getBlendOpts, and the caps of the GrGpuGL are also inputs. It also
59 * outputs the color and coverage stages referenced by the generated descrip tor. This may 60 * outputs the color and coverage stages referenced by the generated descrip tor. This may
60 * not contain all stages from the draw state and coverage stages from the d rawState may 61 * not contain all stages from the draw state and coverage stages from the d rawState may
61 * be treated as color stages in the output. 62 * be treated as color stages in the output.
62 */ 63 */
63 static bool Build(const GrDrawState&, 64 static bool Build(const GrDrawState&,
64 GrGpu::DrawType drawType, 65 GrGpu::DrawType drawType,
65 GrDrawState::BlendOptFlags, 66 GrDrawState::BlendOptFlags,
66 GrBlendCoeff srcCoeff, 67 GrBlendCoeff srcCoeff,
67 GrBlendCoeff dstCoeff, 68 GrBlendCoeff dstCoeff,
68 const GrGpuGL* gpu, 69 const GrGpuGL* gpu,
69 const GrDeviceCoordTexture* dstCopy, 70 const GrDeviceCoordTexture* dstCopy,
71 const GrEffectStage** outGeometryProcessor,
70 SkTArray<const GrEffectStage*, true>* outColorStages, 72 SkTArray<const GrEffectStage*, true>* outColorStages,
71 SkTArray<const GrEffectStage*, true>* outCoverageStages, 73 SkTArray<const GrEffectStage*, true>* outCoverageStages,
72 GrGLProgramDesc* outDesc); 74 GrGLProgramDesc* outDesc);
73 75
76 bool hasGeometryProcessor() const { return this->getHeader().fHasGeometryPro cessor; }
77
74 int numColorEffects() const { 78 int numColorEffects() const {
75 return this->getHeader().fColorEffectCnt; 79 return this->getHeader().fColorEffectCnt;
76 } 80 }
77 81
78 int numCoverageEffects() const { 82 int numCoverageEffects() const {
79 return this->getHeader().fCoverageEffectCnt; 83 return this->getHeader().fCoverageEffectCnt;
80 } 84 }
81 85
82 int numTotalEffects() const { return this->numColorEffects() + this->numCove rageEffects(); } 86 int numTotalEffects() const { return this->numColorEffects() + this->numCove rageEffects(); }
83 87
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // production) 158 // production)
155 #if GR_GL_EXPERIMENTAL_GS 159 #if GR_GL_EXPERIMENTAL_GS
156 SkBool8 fExperimentalGS; 160 SkBool8 fExperimentalGS;
157 #endif 161 #endif
158 162
159 int8_t fPositionAttributeIndex; 163 int8_t fPositionAttributeIndex;
160 int8_t fLocalCoordAttributeIndex; 164 int8_t fLocalCoordAttributeIndex;
161 int8_t fColorAttributeIndex; 165 int8_t fColorAttributeIndex;
162 int8_t fCoverageAttributeIndex; 166 int8_t fCoverageAttributeIndex;
163 167
168 SkBool8 fHasGeometryProcessor;
164 int8_t fColorEffectCnt; 169 int8_t fColorEffectCnt;
165 int8_t fCoverageEffectCnt; 170 int8_t fCoverageEffectCnt;
166 }; 171 };
167 172
168 // The key, stored in fKey, is composed of five parts: 173 // The key, stored in fKey, is composed of five parts:
169 // 1. uint32_t for total key length. 174 // 1. uint32_t for total key length.
170 // 2. uint32_t for a checksum. 175 // 2. uint32_t for a checksum.
171 // 3. Header struct defined above. 176 // 3. Header struct defined above.
172 // 4. An array of offsets to effect keys and their sizes (see 5). uint16_t f or each 177 // 4. An array of offsets to effect keys and their sizes (see 5). uint16_t f or each
173 // offset and size. 178 // offset and size.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 bool* setTrueIfRequiresVertexShader); 211 bool* setTrueIfRequiresVertexShader);
207 212
208 void finalize(); 213 void finalize();
209 214
210 const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHead erOffset>(); } 215 const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHead erOffset>(); }
211 216
212 /** Used to provide effects' keys to their emitCode() function. */ 217 /** Used to provide effects' keys to their emitCode() function. */
213 class EffectKeyProvider { 218 class EffectKeyProvider {
214 public: 219 public:
215 enum EffectType { 220 enum EffectType {
221 kGeometryProcessor_EffectType,
216 kColor_EffectType, 222 kColor_EffectType,
217 kCoverage_EffectType, 223 kCoverage_EffectType,
218 }; 224 };
219 225
220 EffectKeyProvider(const GrGLProgramDesc* desc, EffectType type) : fDesc( desc) { 226 EffectKeyProvider(const GrGLProgramDesc* desc, EffectType type) : fDesc( desc) {
221 // Coverage effect key offsets begin immediately after those of the color effects. 227 switch (type) {
222 fBaseIndex = kColor_EffectType == type ? 0 : desc->numColorEffects() ; 228 case kGeometryProcessor_EffectType:
229 // there can be only one
230 fBaseIndex = 0;
231 break;
232 case kColor_EffectType:
233 fBaseIndex = desc->hasGeometryProcessor() ? 1 : 0;
234 break;
235 case kCoverage_EffectType:
236 fBaseIndex = desc->numColorEffects() + (desc->hasGeometryPro cessor() ? 1 : 0);
237 break;
238 }
223 } 239 }
224 240
225 GrEffectKey get(int index) const { 241 GrEffectKey get(int index) const {
226 const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t* >( 242 const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t* >(
227 fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset); 243 fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset);
228 // We store two uint16_ts per effect, one for the offset to the effe ct's key and one for 244 // We store two uint16_ts per effect, one for the offset to the effe ct's key and one for
229 // its length. Here we just need the offset. 245 // its length. Here we just need the offset.
230 uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0]; 246 uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0];
231 uint16_t length = offsetsAndLengths[2 * (fBaseIndex + index) + 1]; 247 uint16_t length = offsetsAndLengths[2 * (fBaseIndex + index) + 1];
232 // Currently effects must add to the key in units of uint32_t. 248 // Currently effects must add to the key in units of uint32_t.
(...skipping 21 matching lines...) Expand all
254 friend class GrGLProgram; 270 friend class GrGLProgram;
255 friend class GrGLProgramBuilder; 271 friend class GrGLProgramBuilder;
256 friend class GrGLFullProgramBuilder; 272 friend class GrGLFullProgramBuilder;
257 friend class GrGLFragmentOnlyProgramBuilder; 273 friend class GrGLFragmentOnlyProgramBuilder;
258 friend class GrGLVertexShaderBuilder; 274 friend class GrGLVertexShaderBuilder;
259 friend class GrGLFragmentShaderBuilder; 275 friend class GrGLFragmentShaderBuilder;
260 friend class GrGLGeometryShaderBuilder; 276 friend class GrGLGeometryShaderBuilder;
261 }; 277 };
262 278
263 #endif 279 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698