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

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

Issue 628633003: gl programs rewrite (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: build fix Created 6 years, 2 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
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "GrGLProcessor.h" 11 #include "GrGLProcessor.h"
12 #include "GrDrawState.h" 12 #include "GrDrawState.h"
13 #include "GrGpu.h" 13 #include "GrGpu.h"
14 #include "GrOptDrawState.h" 14 #include "GrOptDrawState.h"
15 15
16 class GrGpuGL; 16 class GrGpuGL;
17 17
18 #ifdef SK_DEBUG
19 // Optionally compile the experimental GS code. Set to SK_DEBUG so that debug build bots will
20 // execute the code.
21 #define GR_GL_EXPERIMENTAL_GS 1
22 #else
23 #define GR_GL_EXPERIMENTAL_GS 0
24 #endif
25
26
27 /** This class describes a program to generate. It also serves as a program cach e key. Very little 18 /** This class describes a program to generate. It also serves as a program cach e key. Very little
28 of this is GL-specific. The GL-specific parts could be factored out into a s ubclass. */ 19 of this is GL-specific. The GL-specific parts could be factored out into a s ubclass. */
29 class GrGLProgramDesc { 20 class GrGLProgramDesc {
30 public: 21 public:
31 GrGLProgramDesc() {} 22 GrGLProgramDesc() {}
32 GrGLProgramDesc(const GrGLProgramDesc& desc) { *this = desc; } 23 GrGLProgramDesc(const GrGLProgramDesc& desc) { *this = desc; }
33 24
34 // Returns this as a uint32_t array to be used as a key in the program cache . 25 // Returns this as a uint32_t array to be used as a key in the program cache .
35 const uint32_t* asKey() const { 26 const uint32_t* asKey() const {
36 return reinterpret_cast<const uint32_t*>(fKey.begin()); 27 return reinterpret_cast<const uint32_t*>(fKey.begin());
37 } 28 }
38 29
39 // Gets the number of bytes in asKey(). It will be a 4-byte aligned value. W hen comparing two 30 // Gets the number of bytes in asKey(). It will be a 4-byte aligned value. W hen comparing two
40 // keys the size of either key can be used with memcmp() since the lengths t hemselves begin the 31 // keys the size of either key can be used with memcmp() since the lengths t hemselves begin the
41 // keys and thus the memcmp will exit early if the keys are of different len gths. 32 // keys and thus the memcmp will exit early if the keys are of different len gths.
42 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset> (); } 33 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset> (); }
43 34
44 // Gets the a checksum of the key. Can be used as a hash value for a fast lo okup in a cache. 35 // Gets the a checksum of the key. Can be used as a hash value for a fast lo okup in a cache.
45 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff set>(); } 36 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff set>(); }
46 37
47 // For unit testing.
48 bool setRandom(SkRandom*,
49 GrGpuGL*,
50 const GrRenderTarget* dummyDstRenderTarget,
51 const GrTexture* dummyDstCopyTexture,
52 const GrGeometryStage* geometryProcessor,
53 const GrFragmentStage* stages[],
54 int numColorStages,
55 int numCoverageStages,
56 int currAttribIndex,
57 GrGpu::DrawType);
58
59 /** 38 /**
60 * Builds a program descriptor from a GrOptDrawState. Whether the primitive type is points, and 39 * Builds a program descriptor from a GrOptDrawState. Whether the primitive type is points, and
61 * 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
62 * 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
63 * color stages in the output. 42 * color stages in the output.
64 */ 43 */
65 static bool Build(const GrOptDrawState&, 44 static bool Build(const GrOptDrawState&,
66 GrGpu::DrawType, 45 GrGpu::DrawType,
67 GrBlendCoeff srcCoeff, 46 GrBlendCoeff srcCoeff,
68 GrBlendCoeff dstCoeff, 47 GrBlendCoeff dstCoeff,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 101
123 SkBool8 fUseFragShaderOnly; 102 SkBool8 fUseFragShaderOnly;
124 SkBool8 fEmitsPointSize; 103 SkBool8 fEmitsPointSize;
125 104
126 ColorInput fColorInput : 8; 105 ColorInput fColorInput : 8;
127 ColorInput fCoverageInput : 8; 106 ColorInput fCoverageInput : 8;
128 107
129 GrOptDrawState::PrimaryOutputType fPrimaryOutputType : 8; 108 GrOptDrawState::PrimaryOutputType fPrimaryOutputType : 8;
130 GrOptDrawState::SecondaryOutputType fSecondaryOutputType : 8; 109 GrOptDrawState::SecondaryOutputType fSecondaryOutputType : 8;
131 110
132
133 // To enable experimental geometry shader code (not for use in
134 // production)
135 #if GR_GL_EXPERIMENTAL_GS
136 SkBool8 fExperimentalGS;
137 #endif
138
139 int8_t fPositionAttributeIndex; 111 int8_t fPositionAttributeIndex;
140 int8_t fLocalCoordAttributeIndex; 112 int8_t fLocalCoordAttributeIndex;
141 int8_t fColorAttributeIndex; 113 int8_t fColorAttributeIndex;
142 int8_t fCoverageAttributeIndex; 114 int8_t fCoverageAttributeIndex;
143 115
144 SkBool8 fHasGeometryProcessor; 116 SkBool8 fHasGeometryProcessor;
145 int8_t fColorEffectCnt; 117 int8_t fColorEffectCnt;
146 int8_t fCoverageEffectCnt; 118 int8_t fCoverageEffectCnt;
147 }; 119 };
148 120
(...skipping 20 matching lines...) Expand all
169 template<typename T, size_t OFFSET> T* atOffset() { 141 template<typename T, size_t OFFSET> T* atOffset() {
170 return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + O FFSET); 142 return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + O FFSET);
171 } 143 }
172 144
173 template<typename T, size_t OFFSET> const T* atOffset() const { 145 template<typename T, size_t OFFSET> const T* atOffset() const {
174 return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin( )) + OFFSET); 146 return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin( )) + OFFSET);
175 } 147 }
176 148
177 KeyHeader* header() { return this->atOffset<KeyHeader, kHeaderOffset>(); } 149 KeyHeader* header() { return this->atOffset<KeyHeader, kHeaderOffset>(); }
178 150
179 // Shared code between setRandom() and Build(). 151 // a helper class to handle getting an individual processor's key
180 static bool GetProcessorKey(const GrProcessorStage& stage, 152 template <class ProcessorKeyBuilder>
181 const GrGLCaps& caps, 153 static bool BuildStagedProcessorKey(const typename ProcessorKeyBuilder::Stag edProcessor& stage,
182 bool useExplicitLocalCoords,
183 GrProcessorKeyBuilder* b,
184 uint16_t* effectKeySize);
185
186 static bool GetGeometryProcessorKey(const GrGeometryStage& stage,
187 const GrGLCaps& caps, 154 const GrGLCaps& caps,
188 bool useExplicitLocalCoords, 155 bool requiresLocalCoordAttrib,
189 GrProcessorKeyBuilder* b, 156 GrGLProgramDesc* desc,
190 uint16_t* effectKeySize); 157 int* offsetAndSizeIndex);
191 void finalize(); 158 void finalize();
192 159
193 const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHead erOffset>(); } 160 const KeyHeader& getHeader() const { return *this->atOffset<KeyHeader, kHead erOffset>(); }
194 161
195 /** Used to provide effects' keys to their emitCode() function. */ 162 /** Used to provide effects' keys to their emitCode() function. */
196 class EffectKeyProvider { 163 class EffectKeyProvider {
197 public: 164 public:
198 enum EffectType { 165 enum EffectType {
199 kGeometryProcessor_EffectType, 166 kGeometryProcessor_EffectType,
200 kColor_EffectType, 167 kColor_EffectType,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // visible to GrGLProcessors. Then make public accessors as necessary and re move friends. 214 // visible to GrGLProcessors. Then make public accessors as necessary and re move friends.
248 friend class GrGLProgram; 215 friend class GrGLProgram;
249 friend class GrGLProgramBuilder; 216 friend class GrGLProgramBuilder;
250 friend class GrGLLegacyNvprProgramBuilder; 217 friend class GrGLLegacyNvprProgramBuilder;
251 friend class GrGLVertexBuilder; 218 friend class GrGLVertexBuilder;
252 friend class GrGLFragmentShaderBuilder; 219 friend class GrGLFragmentShaderBuilder;
253 friend class GrGLGeometryBuilder; 220 friend class GrGLGeometryBuilder;
254 }; 221 };
255 222
256 #endif 223 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698