OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrGLShaderVar_DEFINED | 8 #ifndef GrGLShaderVar_DEFINED |
9 #define GrGLShaderVar_DEFINED | 9 #define GrGLShaderVar_DEFINED |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 /** | 23 /** |
24 * Early versions of GLSL have Varying and Attribute; those are later | 24 * Early versions of GLSL have Varying and Attribute; those are later |
25 * deprecated, but we still need to know whether a Varying variable | 25 * deprecated, but we still need to know whether a Varying variable |
26 * should be treated as In or Out. | 26 * should be treated as In or Out. |
27 */ | 27 */ |
28 enum TypeModifier { | 28 enum TypeModifier { |
29 kNone_TypeModifier, | 29 kNone_TypeModifier, |
30 kOut_TypeModifier, | 30 kOut_TypeModifier, |
31 kIn_TypeModifier, | 31 kIn_TypeModifier, |
| 32 kInOut_TypeModifier, |
32 kUniform_TypeModifier, | 33 kUniform_TypeModifier, |
33 kAttribute_TypeModifier | 34 kAttribute_TypeModifier, |
| 35 kVaryingIn_TypeModifier, |
| 36 kVaryingOut_TypeModifier |
34 }; | 37 }; |
35 | 38 |
36 enum Precision { | 39 enum Precision { |
37 kLow_Precision, // lowp | 40 kLow_Precision, // lowp |
38 kMedium_Precision, // mediump | 41 kMedium_Precision, // mediump |
39 kHigh_Precision, // highp | 42 kHigh_Precision, // highp |
40 kDefault_Precision, // Default for the current context. We make | 43 kDefault_Precision, // Default for the current context. We make |
41 // fragment shaders default to mediump on ES2 | 44 // fragment shaders default to mediump on ES2 |
42 // because highp support is not guaranteed (and | 45 // because highp support is not guaranteed (and |
43 // we haven't been motivated to test for it). | 46 // we haven't been motivated to test for it). |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 this->getName().c_str(), | 299 this->getName().c_str(), |
297 indexName, | 300 indexName, |
298 fUseUniformFloatArrays ? "" : ".x"); | 301 fUseUniformFloatArrays ? "" : ".x"); |
299 } | 302 } |
300 | 303 |
301 private: | 304 private: |
302 static const char* TypeModifierString(TypeModifier t, GrGLSLGeneration gen)
{ | 305 static const char* TypeModifierString(TypeModifier t, GrGLSLGeneration gen)
{ |
303 switch (t) { | 306 switch (t) { |
304 case kNone_TypeModifier: | 307 case kNone_TypeModifier: |
305 return ""; | 308 return ""; |
| 309 case kIn_TypeModifier: |
| 310 return "in"; |
| 311 case kInOut_TypeModifier: |
| 312 return "inout"; |
306 case kOut_TypeModifier: | 313 case kOut_TypeModifier: |
307 return k110_GrGLSLGeneration == gen ? "varying" : "out"; | 314 return "out"; |
308 case kIn_TypeModifier: | |
309 return k110_GrGLSLGeneration == gen ? "varying" : "in"; | |
310 case kUniform_TypeModifier: | 315 case kUniform_TypeModifier: |
311 return "uniform"; | 316 return "uniform"; |
312 case kAttribute_TypeModifier: | 317 case kAttribute_TypeModifier: |
313 return k110_GrGLSLGeneration == gen ? "attribute" : "in"; | 318 return k110_GrGLSLGeneration == gen ? "attribute" : "in"; |
| 319 case kVaryingIn_TypeModifier: |
| 320 return k110_GrGLSLGeneration == gen ? "varying" : "in"; |
| 321 case kVaryingOut_TypeModifier: |
| 322 return k110_GrGLSLGeneration == gen ? "varying" : "out"; |
314 default: | 323 default: |
315 GrCrash("Unknown shader variable type modifier."); | 324 GrCrash("Unknown shader variable type modifier."); |
316 return ""; // suppress warning | 325 return ""; // suppress warning |
317 } | 326 } |
318 } | 327 } |
319 | 328 |
320 static const char* PrecisionString(Precision p, GrGLBinding binding) { | 329 static const char* PrecisionString(Precision p, GrGLBinding binding) { |
321 // Desktop GLSL has added precision qualifiers but they don't do anythin
g. | 330 // Desktop GLSL has added precision qualifiers but they don't do anythin
g. |
322 if (kES2_GrGLBinding == binding) { | 331 if (kES2_GrGLBinding == binding) { |
323 switch (p) { | 332 switch (p) { |
(...skipping 17 matching lines...) Expand all Loading... |
341 SkString fName; | 350 SkString fName; |
342 int fCount; | 351 int fCount; |
343 Precision fPrecision; | 352 Precision fPrecision; |
344 Origin fOrigin; | 353 Origin fOrigin; |
345 /// Work around driver bugs on some hardware that don't correctly | 354 /// Work around driver bugs on some hardware that don't correctly |
346 /// support uniform float [] | 355 /// support uniform float [] |
347 bool fUseUniformFloatArrays; | 356 bool fUseUniformFloatArrays; |
348 }; | 357 }; |
349 | 358 |
350 #endif | 359 #endif |
OLD | NEW |