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/validationES.cpp b/src/libANGLE/validationES.cpp
index cb1876f..976241a 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -982,7 +982,7 @@
}
bool ValidateWebGLVertexAttribPointer(Context *context,
- GLenum type,
+ VertexAttribType type,
GLboolean normalized,
GLsizei stride,
const void *ptr,
@@ -4803,7 +4803,7 @@
bool ValidateVertexFormatBase(Context *context,
GLuint attribIndex,
GLint size,
- GLenum type,
+ VertexAttribType type,
GLboolean pureInteger)
{
const Caps &caps = context->getCaps();
@@ -4819,16 +4819,17 @@
return false;
}
+ // This validation could be improved using a table and better encapsulation.
switch (type)
{
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
+ case VertexAttribType::Byte:
+ case VertexAttribType::UnsignedByte:
+ case VertexAttribType::Short:
+ case VertexAttribType::UnsignedShort:
break;
- case GL_INT:
- case GL_UNSIGNED_INT:
+ case VertexAttribType::Int:
+ case VertexAttribType::UnsignedInt:
if (context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES30);
@@ -4836,8 +4837,8 @@
}
break;
- case GL_FIXED:
- case GL_FLOAT:
+ case VertexAttribType::Fixed:
+ case VertexAttribType::Float:
if (pureInteger)
{
context->validationError(GL_INVALID_ENUM, kInvalidTypePureInt);
@@ -4845,7 +4846,7 @@
}
break;
- case GL_HALF_FLOAT:
+ case VertexAttribType::HalfFloat:
if (context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES30);
@@ -4858,8 +4859,8 @@
}
break;
- case GL_INT_2_10_10_10_REV:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case VertexAttribType::Int2101010:
+ case VertexAttribType::UnsignedInt2101010:
if (context->getClientMajorVersion() < 3)
{
context->validationError(GL_INVALID_ENUM, kEnumRequiresGLES30);