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 678953002: Default geometry processor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix dm bug Created 6 years, 1 month 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 29 matching lines...) Expand all
40 * the caps of the GrGpuGL are also inputs. It also outputs the color and co verage stages 40 * the caps of the GrGpuGL are also inputs. It also outputs the color and co verage stages
41 * referenced by the generated descriptor. Coverage stages from the drawStat e may be treated as 41 * referenced by the generated descriptor. Coverage stages from the drawStat e may be treated as
42 * color stages in the output. 42 * color stages in the output.
43 */ 43 */
44 static bool Build(const GrOptDrawState&, 44 static bool Build(const GrOptDrawState&,
45 GrGpu::DrawType, 45 GrGpu::DrawType,
46 GrGpuGL*, 46 GrGpuGL*,
47 const GrDeviceCoordTexture*, 47 const GrDeviceCoordTexture*,
48 GrGLProgramDesc*); 48 GrGLProgramDesc*);
49 49
50 bool hasGeometryProcessor() const {
51 return SkToBool(this->getHeader().fHasGeometryProcessor);
52 }
53
54 int numColorEffects() const { 50 int numColorEffects() const {
55 return this->getHeader().fColorEffectCnt; 51 return this->getHeader().fColorEffectCnt;
56 } 52 }
57 53
58 int numCoverageEffects() const { 54 int numCoverageEffects() const {
59 return this->getHeader().fCoverageEffectCnt; 55 return this->getHeader().fCoverageEffectCnt;
60 } 56 }
61 57
62 int numTotalEffects() const { return this->numColorEffects() + this->numCove rageEffects(); } 58 int numTotalEffects() const { return this->numColorEffects() + this->numCove rageEffects(); }
63 59
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 ColorInput fCoverageInput : 8; 97 ColorInput fCoverageInput : 8;
102 98
103 GrOptDrawState::PrimaryOutputType fPrimaryOutputType : 8; 99 GrOptDrawState::PrimaryOutputType fPrimaryOutputType : 8;
104 GrOptDrawState::SecondaryOutputType fSecondaryOutputType : 8; 100 GrOptDrawState::SecondaryOutputType fSecondaryOutputType : 8;
105 101
106 int8_t fPositionAttributeIndex; 102 int8_t fPositionAttributeIndex;
107 int8_t fLocalCoordAttributeIndex; 103 int8_t fLocalCoordAttributeIndex;
108 int8_t fColorAttributeIndex; 104 int8_t fColorAttributeIndex;
109 int8_t fCoverageAttributeIndex; 105 int8_t fCoverageAttributeIndex;
110 106
111 SkBool8 fHasGeometryProcessor;
112 int8_t fColorEffectCnt; 107 int8_t fColorEffectCnt;
113 int8_t fCoverageEffectCnt; 108 int8_t fCoverageEffectCnt;
114 }; 109 };
115 110
116 // The key, stored in fKey, is composed of five parts: 111 // The key, stored in fKey, is composed of five parts:
117 // 1. uint32_t for total key length. 112 // 1. uint32_t for total key length.
118 // 2. uint32_t for a checksum. 113 // 2. uint32_t for a checksum.
119 // 3. Header struct defined above. 114 // 3. Header struct defined above.
120 // 4. An array of offsets to effect keys and their sizes (see 5). uint16_t f or each 115 // 4. An array of offsets to effect keys and their sizes (see 5). uint16_t f or each
121 // offset and size. 116 // offset and size.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 }; 158 };
164 159
165 ProcKeyProvider(const GrGLProgramDesc* desc, ProcessorType type) 160 ProcKeyProvider(const GrGLProgramDesc* desc, ProcessorType type)
166 : fDesc(desc), fBaseIndex(0) { 161 : fDesc(desc), fBaseIndex(0) {
167 switch (type) { 162 switch (type) {
168 case kGeometry_ProcessorType: 163 case kGeometry_ProcessorType:
169 // there can be only one 164 // there can be only one
170 fBaseIndex = 0; 165 fBaseIndex = 0;
171 break; 166 break;
172 case kFragment_ProcessorType: 167 case kFragment_ProcessorType:
173 fBaseIndex = desc->hasGeometryProcessor() ? 1 : 0; 168 fBaseIndex = desc->getHeader().fUseFragShaderOnly ? 0 : 1;
174 break; 169 break;
175 } 170 }
176 } 171 }
177 172
178 GrProcessorKey get(int index) const { 173 GrProcessorKey get(int index) const {
179 const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t* >( 174 const uint16_t* offsetsAndLengths = reinterpret_cast<const uint16_t* >(
180 fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset); 175 fDesc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset);
181 // We store two uint16_ts per effect, one for the offset to the effe ct's key and one for 176 // We store two uint16_ts per effect, one for the offset to the effe ct's key and one for
182 // its length. Here we just need the offset. 177 // its length. Here we just need the offset.
183 uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0]; 178 uint16_t offset = offsetsAndLengths[2 * (fBaseIndex + index) + 0];
(...skipping 15 matching lines...) Expand all
199 kMaxPreallocEffects * sizeof(uint32_t) * kIntsPerEffect, 194 kMaxPreallocEffects * sizeof(uint32_t) * kIntsPerEffect,
200 }; 195 };
201 196
202 SkSTArray<kPreAllocSize, uint8_t, true> fKey; 197 SkSTArray<kPreAllocSize, uint8_t, true> fKey;
203 198
204 // GrGLProgram and GrGLShaderBuilder read the private fields to generate cod e. TODO: Split out 199 // GrGLProgram and GrGLShaderBuilder read the private fields to generate cod e. TODO: Split out
205 // part of GrGLShaderBuilder that is used by effects so that this header doe sn't need to be 200 // part of GrGLShaderBuilder that is used by effects so that this header doe sn't need to be
206 // visible to GrGLProcessors. Then make public accessors as necessary and re move friends. 201 // visible to GrGLProcessors. Then make public accessors as necessary and re move friends.
207 friend class GrGLProgram; 202 friend class GrGLProgram;
208 friend class GrGLProgramBuilder; 203 friend class GrGLProgramBuilder;
204 friend class GrGLNvprProgramBuilderBase;
209 friend class GrGLLegacyNvprProgramBuilder; 205 friend class GrGLLegacyNvprProgramBuilder;
210 friend class GrGLVertexBuilder; 206 friend class GrGLVertexBuilder;
211 friend class GrGLFragmentShaderBuilder; 207 friend class GrGLFragmentShaderBuilder;
212 friend class GrGLGeometryBuilder; 208 friend class GrGLGeometryBuilder;
213 }; 209 };
214 210
215 #endif 211 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698