Use packed enum for DrawElementsType.
The packing and unpacking take a few extra instructions. But it
completely obviates the need for any switches in the validation code.
Speed is slightly faster or the similar depending on the back-end.
Also add gl_angle_ext.xml to GL entry point generator inputs. This was
missing and would cause the code generation to miss certain changes.
Bug: angleproject:2985
Change-Id: I1ea41a71db71135000166ead8305ec42d22ff7b3
Reviewed-on: https://chromium-review.googlesource.com/c/1351729
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 3561600..cddee6c 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -633,7 +633,7 @@
bool ValidateDrawElementsInstancedBase(Context *context,
PrimitiveMode mode,
GLsizei count,
- GLenum type,
+ DrawElementsType type,
const GLvoid *indices,
GLsizei primcount)
{
@@ -2959,23 +2959,19 @@
return ValidateDrawInstancedANGLE(context);
}
-bool ValidateDrawElementsBase(Context *context, PrimitiveMode mode, GLenum type)
+bool ValidateDrawElementsBase(Context *context, PrimitiveMode mode, DrawElementsType type)
{
- switch (type)
+ if (!context->getStateCache().isValidDrawElementsType(type))
{
- case GL_UNSIGNED_BYTE:
- case GL_UNSIGNED_SHORT:
- break;
- case GL_UNSIGNED_INT:
- if (context->getClientMajorVersion() < 3 && !context->getExtensions().elementIndexUint)
- {
- context->validationError(GL_INVALID_ENUM, kTypeNotUnsignedShortByte);
- return false;
- }
- break;
- default:
+ if (type == DrawElementsType::UnsignedInt)
+ {
context->validationError(GL_INVALID_ENUM, kTypeNotUnsignedShortByte);
return false;
+ }
+
+ ASSERT(type == DrawElementsType::InvalidEnum);
+ context->validationError(GL_INVALID_ENUM, kEnumNotSupported);
+ return false;
}
const State &state = context->getGLState();
@@ -3012,7 +3008,7 @@
bool ValidateDrawElementsCommon(Context *context,
PrimitiveMode mode,
GLsizei count,
- GLenum type,
+ DrawElementsType type,
const void *indices,
GLsizei primcount)
{
@@ -3029,7 +3025,7 @@
const VertexArray *vao = state.getVertexArray();
Buffer *elementArrayBuffer = vao->getElementArrayBuffer();
- GLuint typeBytes = GetTypeInfo(type).bytes;
+ GLuint typeBytes = GetDrawElementsTypeSize(type);
ASSERT(isPow2(typeBytes) && typeBytes > 0);
if (context->getExtensions().webglCompatibility)
@@ -3165,7 +3161,7 @@
bool ValidateDrawElementsInstancedCommon(Context *context,
PrimitiveMode mode,
GLsizei count,
- GLenum type,
+ DrawElementsType type,
const void *indices,
GLsizei primcount)
{
@@ -3175,7 +3171,7 @@
bool ValidateDrawElementsInstancedANGLE(Context *context,
PrimitiveMode mode,
GLsizei count,
- GLenum type,
+ DrawElementsType type,
const void *indices,
GLsizei primcount)
{