Revert "Remove IndexRange retrieving in validation"
This reverts commit 59d9da089580afac175ff5f1a932b987c9d194d6.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Remove IndexRange retrieving in validation
>
> This change can improve the performance of drawElements which uses
> the path without translation.
> Paste a set of mean data (repeated 30) for reference on Intel skylake
> Win10 desktop.
> DrawElementsPerfBenchmark.Run/d3d11:
> before after
> mean: 13644.4666667 -> mean: 13887.8333333
> DrawElementsPerfBenchmark.Run/d3d11_index_buffer_changed:
> before after
> mean: 45.8 -> mean: 46.3666666667
>
> BUG=755897, angleproject:1393
>
> Change-Id: I11f5db25445346958dfef52b1d23df5483cda32f
> Reviewed-on: https://chromium-review.googlesource.com/607413
> Reviewed-by: Geoff Lang <geofflang@chromium.org>
> Reviewed-by: Jamie Madill <jmadill@chromium.org>
> Commit-Queue: Jamie Madill <jmadill@chromium.org>
TBR=geofflang@chromium.org,jmadill@chromium.org,jiajia.qin@intel.com
Change-Id: I4b00af2c32af36aa978ac2fddcf7514134497cf3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 755897, angleproject:1393
Reviewed-on: https://chromium-review.googlesource.com/633296
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index a878aed..6b9b390 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -3171,13 +3171,34 @@
}
}
- // Here we use maxVertex = 0 and vertexCount = 1 to avoid retrieving IndexRange.
- if (!ValidateDrawAttribs(context, primcount, 0, 1))
+ // Use the parameter buffer to retrieve and cache the index range.
+ // TODO: offer fast path, with disabled index validation.
+ // TODO: also disable index checking on back-ends that are robust to out-of-range accesses.
+ const auto ¶ms = context->getParams<HasIndexRange>();
+ const auto &indexRangeOpt = params.getIndexRange();
+ if (!indexRangeOpt.valid())
+ {
+ // Unexpected error.
+ return false;
+ }
+
+ // If we use an index greater than our maximum supported index range, return an error.
+ // The ES3 spec does not specify behaviour here, it is undefined, but ANGLE should always
+ // return an error if possible here.
+ if (static_cast<GLuint64>(indexRangeOpt.value().end) >= context->getCaps().maxElementIndex)
+ {
+ ANGLE_VALIDATION_ERR(context, InvalidOperation(), ExceedsMaxElement);
+ return false;
+ }
+
+ if (!ValidateDrawAttribs(context, primcount, static_cast<GLint>(indexRangeOpt.value().end),
+ static_cast<GLint>(indexRangeOpt.value().vertexCount())))
{
return false;
}
- return true;
+ // No op if there are no real indices in the index data (all are primitive restart).
+ return (indexRangeOpt.value().vertexIndexCount > 0);
}
bool ValidateDrawElementsInstancedCommon(ValidationContext *context,