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

Side by Side Diff: include/gpu/GrTypesPriv.h

Issue 1669853002: Improve GLSL integer support (Closed) Base URL: https://skia.googlesource.com/skia.git@uploat_dratindirect
Patch Set: rebase Created 4 years, 10 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 | « include/gpu/GrCaps.h ('k') | include/gpu/gl/GrGLFunctions.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 GrTypesPriv_DEFINED 8 #ifndef GrTypesPriv_DEFINED
9 #define GrTypesPriv_DEFINED 9 #define GrTypesPriv_DEFINED
10 10
(...skipping 11 matching lines...) Expand all
22 kVec2f_GrSLType, 22 kVec2f_GrSLType,
23 kVec3f_GrSLType, 23 kVec3f_GrSLType,
24 kVec4f_GrSLType, 24 kVec4f_GrSLType,
25 kMat33f_GrSLType, 25 kMat33f_GrSLType,
26 kMat44f_GrSLType, 26 kMat44f_GrSLType,
27 kSampler2D_GrSLType, 27 kSampler2D_GrSLType,
28 kSamplerExternal_GrSLType, 28 kSamplerExternal_GrSLType,
29 kSampler2DRect_GrSLType, 29 kSampler2DRect_GrSLType,
30 kBool_GrSLType, 30 kBool_GrSLType,
31 kInt_GrSLType, 31 kInt_GrSLType,
32 kUint_GrSLType,
32 33
33 kLast_GrSLType = kInt_GrSLType 34 kLast_GrSLType = kUint_GrSLType
34 }; 35 };
35 static const int kGrSLTypeCount = kLast_GrSLType + 1; 36 static const int kGrSLTypeCount = kLast_GrSLType + 1;
36 37
37 enum GrShaderType { 38 enum GrShaderType {
38 kVertex_GrShaderType, 39 kVertex_GrShaderType,
39 kGeometry_GrShaderType, 40 kGeometry_GrShaderType,
40 kFragment_GrShaderType, 41 kFragment_GrShaderType,
41 42
42 kLastkFragment_GrShaderType = kFragment_GrShaderType 43 kLastkFragment_GrShaderType = kFragment_GrShaderType
43 }; 44 };
(...skipping 16 matching lines...) Expand all
60 kLast_GrSLPrecision = kHigh_GrSLPrecision 61 kLast_GrSLPrecision = kHigh_GrSLPrecision
61 }; 62 };
62 63
63 static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1; 64 static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1;
64 65
65 /** 66 /**
66 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample rs. 67 * Gets the vector size of the SLType. Returns -1 for void, matrices, and sample rs.
67 */ 68 */
68 static inline int GrSLTypeVectorCount(GrSLType type) { 69 static inline int GrSLTypeVectorCount(GrSLType type) {
69 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); 70 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
70 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1 }; 71 static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, 1, 1, 1 } ;
71 return kCounts[type]; 72 return kCounts[type];
72 73
73 GR_STATIC_ASSERT(0 == kVoid_GrSLType); 74 GR_STATIC_ASSERT(0 == kVoid_GrSLType);
74 GR_STATIC_ASSERT(1 == kFloat_GrSLType); 75 GR_STATIC_ASSERT(1 == kFloat_GrSLType);
75 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); 76 GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
76 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); 77 GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
77 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); 78 GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
78 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); 79 GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
79 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); 80 GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
80 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); 81 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
81 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); 82 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
82 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); 83 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
83 GR_STATIC_ASSERT(10 == kBool_GrSLType); 84 GR_STATIC_ASSERT(10 == kBool_GrSLType);
84 GR_STATIC_ASSERT(11 == kInt_GrSLType); 85 GR_STATIC_ASSERT(11 == kInt_GrSLType);
86 GR_STATIC_ASSERT(12 == kUint_GrSLType);
85 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount); 87 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount);
86 } 88 }
87 89
88 /** Return the type enum for a vector of floats of length n (1..4), 90 /** Return the type enum for a vector of floats of length n (1..4),
89 e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */ 91 e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */
90 static inline GrSLType GrSLFloatVectorType(int count) { 92 static inline GrSLType GrSLFloatVectorType(int count) {
91 SkASSERT(count > 0 && count <= 4); 93 SkASSERT(count > 0 && count <= 4);
92 return (GrSLType)(count); 94 return (GrSLType)(count);
93 95
94 GR_STATIC_ASSERT(kFloat_GrSLType == 1); 96 GR_STATIC_ASSERT(kFloat_GrSLType == 1);
(...skipping 12 matching lines...) Expand all
107 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); 109 GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
108 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); 110 GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
109 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); 111 GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
110 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); 112 GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
111 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); 113 GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
112 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); 114 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
113 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); 115 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
114 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); 116 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
115 GR_STATIC_ASSERT(10 == kBool_GrSLType); 117 GR_STATIC_ASSERT(10 == kBool_GrSLType);
116 GR_STATIC_ASSERT(11 == kInt_GrSLType); 118 GR_STATIC_ASSERT(11 == kInt_GrSLType);
117 GR_STATIC_ASSERT(12 == kGrSLTypeCount); 119 GR_STATIC_ASSERT(12 == kUint_GrSLType);
120 GR_STATIC_ASSERT(13 == kGrSLTypeCount);
118 } 121 }
119 122
120 /** Is the shading language type integral (including vectors/matrices)? */ 123 /** Is the shading language type integral (including vectors/matrices)? */
121 static inline bool GrSLTypeIsIntType(GrSLType type) { 124 static inline bool GrSLTypeIsIntType(GrSLType type) {
122 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); 125 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
123 return type == kInt_GrSLType; 126 return type >= kInt_GrSLType;
124 127
125 GR_STATIC_ASSERT(0 == kVoid_GrSLType); 128 GR_STATIC_ASSERT(0 == kVoid_GrSLType);
126 GR_STATIC_ASSERT(1 == kFloat_GrSLType); 129 GR_STATIC_ASSERT(1 == kFloat_GrSLType);
127 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); 130 GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
128 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); 131 GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
129 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); 132 GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
130 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); 133 GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
131 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); 134 GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
132 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); 135 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
133 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); 136 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
134 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); 137 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
135 GR_STATIC_ASSERT(10 == kBool_GrSLType); 138 GR_STATIC_ASSERT(10 == kBool_GrSLType);
136 GR_STATIC_ASSERT(11 == kInt_GrSLType); 139 GR_STATIC_ASSERT(11 == kInt_GrSLType);
137 GR_STATIC_ASSERT(12 == kGrSLTypeCount); 140 GR_STATIC_ASSERT(12 == kUint_GrSLType);
141 GR_STATIC_ASSERT(13 == kGrSLTypeCount);
138 } 142 }
139 143
140 /** Is the shading language type numeric (including vectors/matrices)? */ 144 /** Is the shading language type numeric (including vectors/matrices)? */
141 static inline bool GrSLTypeIsNumeric(GrSLType type) { 145 static inline bool GrSLTypeIsNumeric(GrSLType type) {
142 return GrSLTypeIsFloatType(type) || GrSLTypeIsIntType(type); 146 return GrSLTypeIsFloatType(type) || GrSLTypeIsIntType(type);
143 } 147 }
144 148
145 /** Returns the size in bytes for floating point GrSLTypes. For non floating poi nt type returns 0 */ 149 /** Returns the size in bytes for floating point GrSLTypes. For non floating poi nt type returns 0 */
146 static inline size_t GrSLTypeSize(GrSLType type) { 150 static inline size_t GrSLTypeSize(GrSLType type) {
147 SkASSERT(GrSLTypeIsFloatType(type)); 151 SkASSERT(GrSLTypeIsFloatType(type));
148 static const size_t kSizes[] = { 152 static const size_t kSizes[] = {
149 0, // kVoid_GrSLType 153 0, // kVoid_GrSLType
150 sizeof(float), // kFloat_GrSLType 154 sizeof(float), // kFloat_GrSLType
151 2 * sizeof(float), // kVec2f_GrSLType 155 2 * sizeof(float), // kVec2f_GrSLType
152 3 * sizeof(float), // kVec3f_GrSLType 156 3 * sizeof(float), // kVec3f_GrSLType
153 4 * sizeof(float), // kVec4f_GrSLType 157 4 * sizeof(float), // kVec4f_GrSLType
154 9 * sizeof(float), // kMat33f_GrSLType 158 9 * sizeof(float), // kMat33f_GrSLType
155 16 * sizeof(float), // kMat44f_GrSLType 159 16 * sizeof(float), // kMat44f_GrSLType
156 0, // kSampler2D_GrSLType 160 0, // kSampler2D_GrSLType
157 0, // kSamplerExternal_GrSLType 161 0, // kSamplerExternal_GrSLType
158 0, // kSampler2DRect_GrSLType 162 0, // kSampler2DRect_GrSLType
159 0, // kBool_GrSLType 163 0, // kBool_GrSLType
160 0, // kInt_GrSLType 164 0, // kInt_GrSLType
165 0, // kUint_GrSLType
161 }; 166 };
162 return kSizes[type]; 167 return kSizes[type];
163 168
164 GR_STATIC_ASSERT(0 == kVoid_GrSLType); 169 GR_STATIC_ASSERT(0 == kVoid_GrSLType);
165 GR_STATIC_ASSERT(1 == kFloat_GrSLType); 170 GR_STATIC_ASSERT(1 == kFloat_GrSLType);
166 GR_STATIC_ASSERT(2 == kVec2f_GrSLType); 171 GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
167 GR_STATIC_ASSERT(3 == kVec3f_GrSLType); 172 GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
168 GR_STATIC_ASSERT(4 == kVec4f_GrSLType); 173 GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
169 GR_STATIC_ASSERT(5 == kMat33f_GrSLType); 174 GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
170 GR_STATIC_ASSERT(6 == kMat44f_GrSLType); 175 GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
171 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); 176 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
172 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); 177 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
173 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); 178 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
174 GR_STATIC_ASSERT(10 == kBool_GrSLType); 179 GR_STATIC_ASSERT(10 == kBool_GrSLType);
175 GR_STATIC_ASSERT(11 == kInt_GrSLType); 180 GR_STATIC_ASSERT(11 == kInt_GrSLType);
176 GR_STATIC_ASSERT(12 == kGrSLTypeCount); 181 GR_STATIC_ASSERT(12 == kUint_GrSLType);
182 GR_STATIC_ASSERT(13 == kGrSLTypeCount);
177 } 183 }
178 184
179 static inline bool GrSLTypeIsSamplerType(GrSLType type) { 185 static inline bool GrSLTypeIsSamplerType(GrSLType type) {
180 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); 186 SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
181 return type >= 7 && type <= 9; 187 return type >= 7 && type <= 9;
182 188
183 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); 189 GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
184 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); 190 GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
185 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType); 191 GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
186 } 192 }
187 193
188 ////////////////////////////////////////////////////////////////////////////// 194 //////////////////////////////////////////////////////////////////////////////
189 195
190 /** 196 /**
191 * Types used to describe format of vertices in arrays. 197 * Types used to describe format of vertices in arrays.
192 */ 198 */
193 enum GrVertexAttribType { 199 enum GrVertexAttribType {
194 kFloat_GrVertexAttribType = 0, 200 kFloat_GrVertexAttribType = 0,
195 kVec2f_GrVertexAttribType, 201 kVec2f_GrVertexAttribType,
196 kVec3f_GrVertexAttribType, 202 kVec3f_GrVertexAttribType,
197 kVec4f_GrVertexAttribType, 203 kVec4f_GrVertexAttribType,
198 204
199 kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage 205 kUByte_GrVertexAttribType, // unsigned byte, e.g. coverage
200 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors 206 kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors
201 207
202 kVec2s_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates 208 kVec2s_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates
203 209
204 kInt_GrVertexAttribType, 210 kInt_GrVertexAttribType,
211 kUint_GrVertexAttribType,
205 212
206 kLast_GrVertexAttribType = kInt_GrVertexAttribType 213 kLast_GrVertexAttribType = kUint_GrVertexAttribType
207 }; 214 };
208 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; 215 static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1;
209 216
210 /** 217 /**
211 * Returns the vector size of the type. 218 * Returns the vector size of the type.
212 */ 219 */
213 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { 220 static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) {
214 static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2, 1 }; 221 SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount);
222 static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2, 1, 1 };
215 return kCounts[type]; 223 return kCounts[type];
216 224
217 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); 225 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
218 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); 226 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
219 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); 227 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
220 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); 228 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
221 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); 229 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
222 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); 230 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
223 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); 231 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
224 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); 232 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
233 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType);
225 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); 234 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount);
226 } 235 }
227 236
228 /** 237 /**
229 * Returns the size of the attrib type in bytes. 238 * Returns the size of the attrib type in bytes.
230 */ 239 */
231 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { 240 static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
232 static const size_t kSizes[] = { 241 static const size_t kSizes[] = {
233 sizeof(float), // kFloat_GrVertexAttribType 242 sizeof(float), // kFloat_GrVertexAttribType
234 2*sizeof(float), // kVec2f_GrVertexAttribType 243 2*sizeof(float), // kVec2f_GrVertexAttribType
235 3*sizeof(float), // kVec3f_GrVertexAttribType 244 3*sizeof(float), // kVec3f_GrVertexAttribType
236 4*sizeof(float), // kVec4f_GrVertexAttribType 245 4*sizeof(float), // kVec4f_GrVertexAttribType
237 1*sizeof(char), // kUByte_GrVertexAttribType 246 1*sizeof(char), // kUByte_GrVertexAttribType
238 4*sizeof(char), // kVec4ub_GrVertexAttribType 247 4*sizeof(char), // kVec4ub_GrVertexAttribType
239 2*sizeof(int16_t), // kVec2s_GrVertexAttribType 248 2*sizeof(int16_t), // kVec2s_GrVertexAttribType
240 sizeof(int32_t) // kInt_GrVertexAttribType 249 sizeof(int32_t), // kInt_GrVertexAttribType
250 sizeof(uint32_t) // kUint_GrVertexAttribType
241 }; 251 };
242 return kSizes[type]; 252 return kSizes[type];
243 253
244 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); 254 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
245 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType); 255 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
246 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType); 256 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
247 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType); 257 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
248 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); 258 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
249 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); 259 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
250 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); 260 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
251 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); 261 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
262 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType);
252 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); 263 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount);
253 } 264 }
254 265
255 /** 266 /**
267 * Is the attrib type integral?
268 */
269 static inline bool GrVertexAttribTypeIsIntType(GrVertexAttribType type) {
270 SkASSERT(type >= 0 && type < static_cast<GrVertexAttribType>(kGrVertexAttrib TypeCount));
271 return type >= kInt_GrVertexAttribType;
272
273 GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType);
274 GR_STATIC_ASSERT(1 == kVec2f_GrVertexAttribType);
275 GR_STATIC_ASSERT(2 == kVec3f_GrVertexAttribType);
276 GR_STATIC_ASSERT(3 == kVec4f_GrVertexAttribType);
277 GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType);
278 GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType);
279 GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType);
280 GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType);
281 GR_STATIC_ASSERT(8 == kUint_GrVertexAttribType);
282 GR_STATIC_ASSERT(9 == kGrVertexAttribTypeCount);
283 }
284
285 /**
256 * converts a GrVertexAttribType to a GrSLType 286 * converts a GrVertexAttribType to a GrSLType
257 */ 287 */
258 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { 288 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) {
259 switch (type) { 289 switch (type) {
260 default: 290 default:
261 SkFAIL("Unsupported type conversion"); 291 SkFAIL("Unsupported type conversion");
262 return kVoid_GrSLType; 292 return kVoid_GrSLType;
263 case kUByte_GrVertexAttribType: 293 case kUByte_GrVertexAttribType:
264 case kFloat_GrVertexAttribType: 294 case kFloat_GrVertexAttribType:
265 return kFloat_GrSLType; 295 return kFloat_GrSLType;
266 case kVec2s_GrVertexAttribType: 296 case kVec2s_GrVertexAttribType:
267 case kVec2f_GrVertexAttribType: 297 case kVec2f_GrVertexAttribType:
268 return kVec2f_GrSLType; 298 return kVec2f_GrSLType;
269 case kVec3f_GrVertexAttribType: 299 case kVec3f_GrVertexAttribType:
270 return kVec3f_GrSLType; 300 return kVec3f_GrSLType;
271 case kVec4ub_GrVertexAttribType: 301 case kVec4ub_GrVertexAttribType:
272 case kVec4f_GrVertexAttribType: 302 case kVec4f_GrVertexAttribType:
273 return kVec4f_GrSLType; 303 return kVec4f_GrSLType;
274 case kInt_GrVertexAttribType: 304 case kInt_GrVertexAttribType:
275 return kInt_GrSLType; 305 return kInt_GrSLType;
306 case kUint_GrVertexAttribType:
307 return kUint_GrSLType;
276 } 308 }
277 } 309 }
278 310
279 ////////////////////////////////////////////////////////////////////////////// 311 //////////////////////////////////////////////////////////////////////////////
280 312
281 /** 313 /**
282 * We have coverage effects that clip rendering to the edge of some geometric pri mitive. 314 * We have coverage effects that clip rendering to the edge of some geometric pri mitive.
283 * This enum specifies how that clipping is performed. Not all factories that tak e a 315 * This enum specifies how that clipping is performed. Not all factories that tak e a
284 * GrProcessorEdgeType will succeed with all values and it is up to the caller to check for 316 * GrProcessorEdgeType will succeed with all values and it is up to the caller to check for
285 * a NULL return. 317 * a NULL return.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Takes a pointer to a GrCaps, and will suppress prints if required 398 // Takes a pointer to a GrCaps, and will suppress prints if required
367 #define GrCapsDebugf(caps, ...) \ 399 #define GrCapsDebugf(caps, ...) \
368 if (!caps->suppressPrints()) { \ 400 if (!caps->suppressPrints()) { \
369 SkDebugf(__VA_ARGS__); \ 401 SkDebugf(__VA_ARGS__); \
370 } 402 }
371 #else 403 #else
372 #define GrCapsDebugf(caps, ...) 404 #define GrCapsDebugf(caps, ...)
373 #endif 405 #endif
374 406
375 #endif 407 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrCaps.h ('k') | include/gpu/gl/GrGLFunctions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698