diff options
Diffstat (limited to 'include/gpu/GrTypesPriv.h')
-rw-r--r-- | include/gpu/GrTypesPriv.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h index 491b23b37b..6a9c44ff9f 100644 --- a/include/gpu/GrTypesPriv.h +++ b/include/gpu/GrTypesPriv.h @@ -107,6 +107,35 @@ static inline bool GrSLTypeIsFloatType(GrSLType type) { GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); GR_STATIC_ASSERT(9 == kGrSLTypeCount); } + +/** Returns the size in bytes for floating point GrSLTypes. For non floating point type returns 0 */ +static inline size_t GrSLTypeSize(GrSLType type) { + SkASSERT(GrSLTypeIsFloatType(type)); + static const size_t kSizes[] = { + 0, // kVoid_GrSLType + sizeof(float), // kFloat_GrSLType + 2 * sizeof(float), // kVec2f_GrSLType + 3 * sizeof(float), // kVec3f_GrSLType + 4 * sizeof(float), // kVec4f_GrSLType + 9 * sizeof(float), // kMat33f_GrSLType + 16 * sizeof(float), // kMat44f_GrSLType + 0, // kSampler2D_GrSLType + 0 // kSamplerExternal_GrSLType + }; + return kSizes[type]; + + GR_STATIC_ASSERT(0 == kVoid_GrSLType); + GR_STATIC_ASSERT(1 == kFloat_GrSLType); + GR_STATIC_ASSERT(2 == kVec2f_GrSLType); + GR_STATIC_ASSERT(3 == kVec3f_GrSLType); + GR_STATIC_ASSERT(4 == kVec4f_GrSLType); + GR_STATIC_ASSERT(5 == kMat33f_GrSLType); + GR_STATIC_ASSERT(6 == kMat44f_GrSLType); + GR_STATIC_ASSERT(7 == kSampler2D_GrSLType); + GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType); + GR_STATIC_ASSERT(9 == kGrSLTypeCount); +} + ////////////////////////////////////////////////////////////////////////////// /** |