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

Side by Side Diff: src/gpu/GrPrimitiveProcessor.h

Issue 1822343002: Make max number of vertex attributes be checked dynamically (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Address comment Created 4 years, 9 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/GrGpu.cpp ('k') | src/gpu/gl/GrGLCaps.h » ('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 GrPrimitiveProcessor_DEFINED 8 #ifndef GrPrimitiveProcessor_DEFINED
9 #define GrPrimitiveProcessor_DEFINED 9 #define GrPrimitiveProcessor_DEFINED
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 * GrPrimitiveProcessor defines an interface which all subclasses must implement . All 144 * GrPrimitiveProcessor defines an interface which all subclasses must implement . All
145 * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh co lor / coverage 145 * GrPrimitiveProcessors must proivide seed color and coverage for the Ganesh co lor / coverage
146 * pipelines, and they must provide some notion of equality 146 * pipelines, and they must provide some notion of equality
147 */ 147 */
148 class GrPrimitiveProcessor : public GrProcessor { 148 class GrPrimitiveProcessor : public GrProcessor {
149 public: 149 public:
150 // Only the GrGeometryProcessor subclass actually has a geo shader or vertex attributes, but 150 // Only the GrGeometryProcessor subclass actually has a geo shader or vertex attributes, but
151 // we put these calls on the base class to prevent having to cast 151 // we put these calls on the base class to prevent having to cast
152 virtual bool willUseGeoShader() const = 0; 152 virtual bool willUseGeoShader() const = 0;
153 153
154 /*
155 * This is a safeguard to prevent GrPrimitiveProcessor's from going beyond p latform specific
156 * attribute limits. This number can almost certainly be raised if required.
157 */
158 static const int kMaxVertexAttribs = 8;
159
160 struct Attribute { 154 struct Attribute {
161 Attribute() 155 Attribute()
162 : fName(nullptr) 156 : fName(nullptr)
163 , fType(kFloat_GrVertexAttribType) 157 , fType(kFloat_GrVertexAttribType)
164 , fOffset(0) {} 158 , fOffset(0) {}
165 Attribute(const char* name, GrVertexAttribType type, 159 Attribute(const char* name, GrVertexAttribType type,
166 GrSLPrecision precision = kDefault_GrSLPrecision) 160 GrSLPrecision precision = kDefault_GrSLPrecision)
167 : fName(name) 161 : fName(name)
168 , fType(type) 162 , fType(type)
169 , fOffset(SkAlign4(GrVertexAttribTypeSize(type))) 163 , fOffset(SkAlign4(GrVertexAttribTypeSize(type)))
170 , fPrecision(precision) {} 164 , fPrecision(precision) {}
171 const char* fName; 165 const char* fName;
172 GrVertexAttribType fType; 166 GrVertexAttribType fType;
173 size_t fOffset; 167 size_t fOffset;
174 GrSLPrecision fPrecision; 168 GrSLPrecision fPrecision;
175 }; 169 };
176 170
177 int numAttribs() const { return fNumAttribs; } 171 int numAttribs() const { return fAttribs.count(); }
178 const Attribute& getAttrib(int index) const { 172 const Attribute& getAttrib(int index) const { return fAttribs[index]; }
179 SkASSERT(index < fNumAttribs);
180 return fAttribs[index];
181 }
182 173
183 // Returns the vertex stride of the GP. A common use case is to request geo metry from a 174 // Returns the vertex stride of the GP. A common use case is to request geo metry from a
184 // drawtarget based off of the stride, and to populate this memory using an implicit array of 175 // drawtarget based off of the stride, and to populate this memory using an implicit array of
185 // structs. In this case, it is best to assert the vertexstride == sizeof(V ertexStruct). 176 // structs. In this case, it is best to assert the vertexstride == sizeof(V ertexStruct).
186 size_t getVertexStride() const { return fVertexStride; } 177 size_t getVertexStride() const { return fVertexStride; }
187 178
188 /** 179 /**
189 * Computes a transformKey from an array of coord transforms. Will only look at the first 180 * Computes a transformKey from an array of coord transforms. Will only look at the first
190 * <numCoords> transforms in the array. 181 * <numCoords> transforms in the array.
191 * 182 *
(...skipping 28 matching lines...) Expand all
220 virtual GrPixelLocalStorageState getPixelLocalStorageState() const { 211 virtual GrPixelLocalStorageState getPixelLocalStorageState() const {
221 return kDisabled_GrPixelLocalStorageState; 212 return kDisabled_GrPixelLocalStorageState;
222 } 213 }
223 214
224 /** 215 /**
225 * If non-null, overrides the dest color returned by GrGLSLFragmentShaderBui lder::dstColor(). 216 * If non-null, overrides the dest color returned by GrGLSLFragmentShaderBui lder::dstColor().
226 */ 217 */
227 virtual const char* getDestColorOverride() const { return nullptr; } 218 virtual const char* getDestColorOverride() const { return nullptr; }
228 219
229 protected: 220 protected:
230 GrPrimitiveProcessor() 221 GrPrimitiveProcessor() : fVertexStride(0) {}
231 : fNumAttribs(0)
232 , fVertexStride(0) {}
233 222
234 Attribute fAttribs[kMaxVertexAttribs]; 223 enum { kPreallocAttribCnt = 8 };
235 int fNumAttribs; 224 SkSTArray<kPreallocAttribCnt, Attribute> fAttribs;
236 size_t fVertexStride; 225 size_t fVertexStride;
237 226
238 private: 227 private:
239 void notifyRefCntIsZero() const final {}; 228 void notifyRefCntIsZero() const final {};
240 virtual bool hasExplicitLocalCoords() const = 0; 229 virtual bool hasExplicitLocalCoords() const = 0;
241 230
242 typedef GrProcessor INHERITED; 231 typedef GrProcessor INHERITED;
243 }; 232 };
244 233
245 #endif 234 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/gl/GrGLCaps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698