Use parameter cache to skip passing IndexRange.
For DrawElements et al., we can use a simple design to store
entry point parameters and compute index ranges lazily. This allows
us to compute the index range outside of the validation layer.
Fixing this will let us implement a few things, such as the no error
extension. It will also allow auto-generation of the entry points,
since we won't have to have special cases for certain entry
points. It will also help fix the syncState layering problem. Now the
cached parameter helper (which is owned by the Context) can make the
impl layer calls, instead of the validation layer calling the impl
directly.
We use a small array in Context to gather parameters in a generic
way without reallocation on call. We also check type safety by storing
a type info struct which can handle inheritance between type classes.
Optional variables for the cache determine when to re-compute values.
The intent with gatherParams is to call this in every entry point, and
have in most cases be a no-op. In some cases like for IndexRange, we
store some parameters for later use. The inheritance scheme enables
auto-generation of the entry points by keeping signatures similar.
BUG=angleproject:747
Change-Id: I871e99e1334cf6e61ef8da62fde3ced094903f8a
Reviewed-on: https://chromium-review.googlesource.com/474119
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index 7460d8d..1b1961f 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -1080,8 +1080,7 @@
GLuint end,
GLsizei count,
GLenum type,
- const GLvoid *indices,
- IndexRange *indexRange)
+ const GLvoid *indices)
{
if (context->getClientMajorVersion() < 3)
{
@@ -1095,12 +1094,21 @@
return false;
}
- if (!ValidateDrawElements(context, mode, count, type, indices, 0, indexRange))
+ if (!ValidateDrawElementsCommon(context, mode, count, type, indices, 0))
{
return false;
}
- if (indexRange->end > end || indexRange->start < start)
+ // Use the parameter buffer to retrieve and cache the index range.
+ const auto ¶ms = context->getParams<HasIndexRange>();
+ const auto &indexRangeOpt = params.getIndexRange();
+ if (!indexRangeOpt.valid())
+ {
+ // Unexpected error.
+ return false;
+ }
+
+ if (indexRangeOpt.value().end > end || indexRangeOpt.value().start < start)
{
// GL spec says that behavior in this case is undefined - generating an error is fine.
context->handleError(
@@ -2555,4 +2563,20 @@
return true;
}
+bool ValidateDrawElementsInstanced(ValidationContext *context,
+ GLenum mode,
+ GLsizei count,
+ GLenum type,
+ const GLvoid *indices,
+ GLsizei instanceCount)
+{
+ if (context->getClientMajorVersion() < 3)
+ {
+ context->handleError(Error(GL_INVALID_OPERATION, "Requires a GLES 3.0 or higher context."));
+ return false;
+ }
+
+ return ValidateDrawElementsInstancedCommon(context, mode, count, type, indices, instanceCount);
+}
+
} // namespace gl