Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1696)

Unified Diff: cc/quads/draw_polygon_unittest.cc

Issue 443903004: [CC]: Reduce required precision for TransformNormal test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/quads/draw_polygon_unittest.cc
diff --git a/cc/quads/draw_polygon_unittest.cc b/cc/quads/draw_polygon_unittest.cc
index 3b8caf3600fb2179fec05150756b1e48becd1fe8..27cfed43816b02bc64df851c03d4806bf6efe268 100644
--- a/cc/quads/draw_polygon_unittest.cc
+++ b/cc/quads/draw_polygon_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <limits>
#include <vector>
#include "cc/output/bsp_compare_result.h"
@@ -15,6 +16,9 @@ namespace {
#define CREATE_NEW_DRAW_POLYGON(name, points_vector, normal, polygon_id) \
DrawPolygon name(NULL, points_vector, normal, polygon_id)
+#define EXPECT_FLOAT_WITHIN_EPSILON_OF(a, b) \
+ EXPECT_TRUE(std::abs(a - b) < std::numeric_limits<float>::epsilon());
Sami 2014/08/06 17:09:24 I think in general the epsilon should be scaled up
+
#define EXPECT_POINT_EQ(point_a, point_b) \
EXPECT_FLOAT_EQ(point_a.x(), point_b.x()); \
EXPECT_FLOAT_EQ(point_a.y(), point_b.y()); \
@@ -173,9 +177,13 @@ TEST(DrawPolygonTransformTest, TransformNormal) {
// using the inverse tranpose matrix gives us the right result.
polygon_a.TransformToScreenSpace(transform);
- EXPECT_FLOAT_EQ(polygon_a.normal().x(), 0);
- EXPECT_FLOAT_EQ(polygon_a.normal().y(), 0);
- EXPECT_FLOAT_EQ(polygon_a.normal().z(), -1);
+ // Note: We use EXPECT_FLOAT_WITHIN_EPSILON instead of EXPECT_FLOAT_EQUAL here
+ // because some architectures (e.g., Arm64) employ a fused multiply-add
+ // instruction which causes rounding asymmetry and reduces precision.
+ // http://crbug.com/401117.
+ EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().x(), 0);
+ EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().y(), 0);
+ EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().z(), -1);
}
} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698