Micro-optimize math in IndexDataManager
Use bitwise operations instead of division, which is expensive on multiple CPU
architectures.
BUG=angleproject:956
TEST=angle_end2end_tests
Change-Id: I57ab540d447c03dae5a96bafb4975fc37e310261
Reviewed-on: https://chromium-review.googlesource.com/262181
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Nicolas Capens <capn@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp
index 544652c..51e6a5a 100644
--- a/src/libANGLE/formatutils.cpp
+++ b/src/libANGLE/formatutils.cpp
@@ -132,6 +132,7 @@
Type::Type()
: bytes(0),
+ bytesShift(0),
specialInterpretation(false)
{
}
@@ -140,6 +141,13 @@
{
Type info;
info.bytes = bytes;
+ GLuint i = 0;
+ while ((1u << i) < bytes)
+ {
+ ++i;
+ }
+ info.bytesShift = i;
+ ASSERT((1u << info.bytesShift) == bytes);
info.specialInterpretation = specialInterpretation;
return info;
}