Pack VertexAttribType enum.
This improves performance slightly in vertex array format checks.
Instead of needing to switch on GLenum values we can use packed arrays
and tables to determine the values we need.
Does not significantly affect performance but will enable future work.
Bug: angleproject:3074
Change-Id: I6f4821a463e9b41fe3f8c8967eb3ed4c1d6b84be
Reviewed-on: https://chromium-review.googlesource.com/c/1393903
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp
index 1cbca8c..4d75f18 100644
--- a/src/libANGLE/formatutils.cpp
+++ b/src/libANGLE/formatutils.cpp
@@ -1344,14 +1344,14 @@
}
}
-angle::FormatID GetVertexFormatID(GLenum type,
+angle::FormatID GetVertexFormatID(VertexAttribType type,
GLboolean normalized,
GLuint components,
bool pureInteger)
{
switch (type)
{
- case GL_BYTE:
+ case VertexAttribType::Byte:
switch (components)
{
case 1:
@@ -1384,7 +1384,7 @@
return angle::FormatID::NONE;
#endif
}
- case GL_UNSIGNED_BYTE:
+ case VertexAttribType::UnsignedByte:
switch (components)
{
case 1:
@@ -1417,7 +1417,7 @@
return angle::FormatID::NONE;
#endif
}
- case GL_SHORT:
+ case VertexAttribType::Short:
switch (components)
{
case 1:
@@ -1450,7 +1450,7 @@
return angle::FormatID::NONE;
#endif
}
- case GL_UNSIGNED_SHORT:
+ case VertexAttribType::UnsignedShort:
switch (components)
{
case 1:
@@ -1483,7 +1483,7 @@
return angle::FormatID::NONE;
#endif
}
- case GL_INT:
+ case VertexAttribType::Int:
switch (components)
{
case 1:
@@ -1516,7 +1516,7 @@
return angle::FormatID::NONE;
#endif
}
- case GL_UNSIGNED_INT:
+ case VertexAttribType::UnsignedInt:
switch (components)
{
case 1:
@@ -1549,7 +1549,7 @@
return angle::FormatID::NONE;
#endif
}
- case GL_FLOAT:
+ case VertexAttribType::Float:
switch (components)
{
case 1:
@@ -1566,7 +1566,7 @@
return angle::FormatID::NONE;
#endif
}
- case GL_HALF_FLOAT:
+ case VertexAttribType::HalfFloat:
switch (components)
{
case 1:
@@ -1583,7 +1583,7 @@
return angle::FormatID::NONE;
#endif
}
- case GL_FIXED:
+ case VertexAttribType::Fixed:
switch (components)
{
case 1:
@@ -1600,13 +1600,13 @@
return angle::FormatID::NONE;
#endif
}
- case GL_INT_2_10_10_10_REV:
+ case VertexAttribType::Int2101010:
if (pureInteger)
return angle::FormatID::R10G10B10A2_SINT;
if (normalized)
return angle::FormatID::R10G10B10A2_SNORM;
return angle::FormatID::R10G10B10A2_SSCALED;
- case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case VertexAttribType::UnsignedInt2101010:
if (pureInteger)
return angle::FormatID::R10G10B10A2_UINT;
if (normalized)
@@ -1620,11 +1620,12 @@
}
}
-angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, GLenum currentValueType)
+angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribType currentValueType)
{
if (!attrib.enabled)
{
- return GetVertexFormatID(currentValueType, GL_FALSE, 4, (currentValueType != GL_FLOAT));
+ return GetVertexFormatID(currentValueType, GL_FALSE, 4,
+ (currentValueType != VertexAttribType::Float));
}
return GetVertexFormatID(attrib);
}