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/Context.cpp b/src/libANGLE/Context.cpp
index 132563a..150301f 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -2242,7 +2242,10 @@
instanceCount);
}
-void Context::drawElements(PrimitiveMode mode, GLsizei count, GLenum type, const void *indices)
+void Context::drawElements(PrimitiveMode mode,
+ GLsizei count,
+ DrawElementsType type,
+ const void *indices)
{
// No-op if count draws no primitives for given mode
if (noopDraw(mode, count))
@@ -2256,7 +2259,7 @@
void Context::drawElementsInstanced(PrimitiveMode mode,
GLsizei count,
- GLenum type,
+ DrawElementsType type,
const void *indices,
GLsizei instances)
{
@@ -2275,7 +2278,7 @@
GLuint start,
GLuint end,
GLsizei count,
- GLenum type,
+ DrawElementsType type,
const void *indices)
{
// No-op if count draws no primitives for given mode
@@ -2295,7 +2298,7 @@
ANGLE_CONTEXT_TRY(mImplementation->drawArraysIndirect(this, mode, indirect));
}
-void Context::drawElementsIndirect(PrimitiveMode mode, GLenum type, const void *indirect)
+void Context::drawElementsIndirect(PrimitiveMode mode, DrawElementsType type, const void *indirect)
{
ANGLE_CONTEXT_TRY(prepareForDraw(mode));
ANGLE_CONTEXT_TRY(mImplementation->drawElementsIndirect(this, mode, type, indirect));
@@ -5461,7 +5464,7 @@
void Context::multiDrawElements(PrimitiveMode mode,
const GLsizei *counts,
- GLenum type,
+ DrawElementsType type,
const GLvoid *const *indices,
GLsizei drawcount)
{
@@ -5497,7 +5500,7 @@
void Context::multiDrawElementsInstanced(PrimitiveMode mode,
const GLsizei *counts,
- GLenum type,
+ DrawElementsType type,
const GLvoid *const *indices,
const GLsizei *instanceCounts,
GLsizei drawcount)
@@ -8186,6 +8189,7 @@
{
updateValidDrawModes(context);
updateValidBindTextureTypes(context);
+ updateValidDrawElementsTypes(context);
}
void StateCache::updateActiveAttribsMask(Context *context)
@@ -8403,4 +8407,16 @@
{TextureType::CubeMap, true},
}};
}
+
+void StateCache::updateValidDrawElementsTypes(Context *context)
+{
+ bool supportsUint =
+ (context->getClientMajorVersion() >= 3 || context->getExtensions().elementIndexUint);
+
+ mCachedValidDrawElementsTypes = {{
+ {DrawElementsType::UnsignedByte, true},
+ {DrawElementsType::UnsignedShort, true},
+ {DrawElementsType::UnsignedInt, supportsUint},
+ }};
+}
} // namespace gl