Chromium Code Reviews| Index: include/gpu/GrTypesPriv.h |
| diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h |
| index 491b23b37baf93148f692f6853a41c3e18445aba..90d25ae0a7dcd92add27a307130bd68d53f261e2 100644 |
| --- a/include/gpu/GrTypesPriv.h |
| +++ b/include/gpu/GrTypesPriv.h |
| @@ -26,8 +26,10 @@ enum GrSLType { |
| kMat44f_GrSLType, |
| kSampler2D_GrSLType, |
| kSamplerExternal_GrSLType, |
| + kBool_GrSLType, |
| + kInt_GrSLType, |
| - kLast_GrSLType = kSamplerExternal_GrSLType |
| + kLast_GrSLType = kInt_GrSLType |
| }; |
| static const int kGrSLTypeCount = kLast_GrSLType + 1; |
| @@ -64,7 +66,7 @@ static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1; |
| */ |
| static inline int GrSLTypeVectorCount(GrSLType type) { |
| SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); |
| - static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1 }; |
| + static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1, -1 }; |
| return kCounts[type]; |
| GR_STATIC_ASSERT(0 == kVoid_GrSLType); |
| @@ -76,6 +78,8 @@ static inline int GrSLTypeVectorCount(GrSLType type) { |
| GR_STATIC_ASSERT(6 == kMat44f_GrSLType); |
| GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); |
| GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); |
| + GR_STATIC_ASSERT(9 == kBool_GrSLType); |
| + GR_STATIC_ASSERT(10 == kInt_GrSLType); |
| GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount); |
| } |
| @@ -91,10 +95,10 @@ static inline GrSLType GrSLFloatVectorType(int count) { |
| GR_STATIC_ASSERT(kVec4f_GrSLType == 4); |
| } |
| -/** Is the shading language type floating point (or vector/matrix of fp)? */ |
| -static inline bool GrSLTypeIsFloatType(GrSLType type) { |
| +/** Is the shading language type numeric (including vectors/matrices)? */ |
| +static inline bool GrSLTypeIsNumeric(GrSLType type) { |
| SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount)); |
| - return type >= 1 && type <= 6; |
| + return (type >= 1 && type <= 6) || type == 10; |
|
bsalomon
2016/01/13 19:15:33
Maybe make the new enum contiguous with the existi
ethannicholas
2016/01/20 17:51:05
I'm not strongly opposed to that, but there are so
bsalomon
2016/01/20 18:27:30
It seemed more intuitive to me for the long term,
|
| GR_STATIC_ASSERT(0 == kVoid_GrSLType); |
| GR_STATIC_ASSERT(1 == kFloat_GrSLType); |
| @@ -105,7 +109,9 @@ static inline bool GrSLTypeIsFloatType(GrSLType type) { |
| GR_STATIC_ASSERT(6 == kMat44f_GrSLType); |
| GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); |
| GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); |
| - GR_STATIC_ASSERT(9 == kGrSLTypeCount); |
| + GR_STATIC_ASSERT(9 == kBool_GrSLType); |
| + GR_STATIC_ASSERT(10 == kInt_GrSLType); |
| + GR_STATIC_ASSERT(11 == kGrSLTypeCount); |
| } |
| ////////////////////////////////////////////////////////////////////////////// |
| @@ -122,8 +128,10 @@ enum GrVertexAttribType { |
| kVec4ub_GrVertexAttribType, // vector of 4 unsigned bytes, e.g. colors |
| kVec2s_GrVertexAttribType, // vector of 2 shorts, e.g. texture coordinates |
| + |
| + kInt_GrVertexAttribType, |
| - kLast_GrVertexAttribType = kVec2s_GrVertexAttribType |
| + kLast_GrVertexAttribType = kInt_GrVertexAttribType |
| }; |
| static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; |
| @@ -131,8 +139,7 @@ static const int kGrVertexAttribTypeCount = kLast_GrVertexAttribType + 1; |
| * Returns the vector size of the type. |
| */ |
| static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { |
| - SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); |
| - static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2 }; |
| + static const int kCounts[] = { 1, 2, 3, 4, 1, 4, 2, 1 }; |
| return kCounts[type]; |
| GR_STATIC_ASSERT(0 == kFloat_GrVertexAttribType); |
| @@ -142,6 +149,7 @@ static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { |
| GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); |
| + GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); |
| GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrVertexAttribTypeCount); |
| } |
| @@ -149,7 +157,6 @@ static inline int GrVertexAttribTypeVectorCount(GrVertexAttribType type) { |
| * Returns the size of the attrib type in bytes. |
| */ |
| static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { |
| - SkASSERT(type >= 0 && type < kGrVertexAttribTypeCount); |
| static const size_t kSizes[] = { |
| sizeof(float), // kFloat_GrVertexAttribType |
| 2*sizeof(float), // kVec2f_GrVertexAttribType |
| @@ -157,7 +164,8 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { |
| 4*sizeof(float), // kVec4f_GrVertexAttribType |
| 1*sizeof(char), // kUByte_GrVertexAttribType |
| 4*sizeof(char), // kVec4ub_GrVertexAttribType |
| - 2*sizeof(int16_t) // kVec2s_GrVertexAttribType |
| + 2*sizeof(int16_t), // kVec2s_GrVertexAttribType |
| + sizeof(int32_t) // kInt_GrVertexAttribType |
| }; |
| return kSizes[type]; |
| @@ -168,6 +176,7 @@ static inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) { |
| GR_STATIC_ASSERT(4 == kUByte_GrVertexAttribType); |
| GR_STATIC_ASSERT(5 == kVec4ub_GrVertexAttribType); |
| GR_STATIC_ASSERT(6 == kVec2s_GrVertexAttribType); |
| + GR_STATIC_ASSERT(7 == kInt_GrVertexAttribType); |
| GR_STATIC_ASSERT(SK_ARRAY_COUNT(kSizes) == kGrVertexAttribTypeCount); |
| } |
| @@ -190,6 +199,8 @@ static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) { |
| case kVec4ub_GrVertexAttribType: |
| case kVec4f_GrVertexAttribType: |
| return kVec4f_GrSLType; |
| + case kInt_GrVertexAttribType: |
| + return kInt_GrSLType; |
| } |
| } |