Use smaller triangles in triangle_vertex.clip_three
authorPyry Haulos <phaulos@google.com>
Tue, 22 Mar 2016 18:36:35 +0000 (11:36 -0700)
committerPyry Haulos <phaulos@google.com>
Thu, 24 Mar 2016 16:56:44 +0000 (09:56 -0700)
A few tests in clipping.triangle_vertex.clip_three generate triangles
that extend over 2^22 units in NDC outside viewport (something real
content is never expected to contain). Clipping these is not something
older ES2-only GPUs are necessarily expected to do accurately and might
come with prohibitive performance cost. This change limits size of those
triangles to a more reasonable value.

Bug: 27533503
Change-Id: Ic571b9d79db2c40652e96f4fc6a567fcfa7dcee3

modules/gles2/functional/es2fClippingTests.cpp

index 71e74b0..176af9c 100644 (file)
@@ -1881,7 +1881,8 @@ PolyVertexClipTestGroup::PolyVertexClipTestGroup (Context& context)
 
 void PolyVertexClipTestGroup::init (void)
 {
-       const float far = 30000.0f;
+       const float far                                 = 30000.0f;
+       const float farForThreeVertex   = 20000.0f; // 3 vertex clipping tests use smaller triangles
        const tcu::IVec3 outside[] =
        {
                // outside one clipping plane
@@ -2023,9 +2024,9 @@ void PolyVertexClipTestGroup::init (void)
                const tcu::IVec3 r0             = outside[ndx1];
                const tcu::IVec3 r1             = outside[ndx2];
                const tcu::IVec3 r2             = outside[ndx3];
-               const tcu::Vec4 p0              = tcu::Vec4(r0.x() * far * w0, r0.y() * far * w0, r0.z() * far * w0, w0);
-               const tcu::Vec4 p1              = tcu::Vec4(r1.x() * far * w1, r1.y() * far * w1, r1.z() * far * w1, w1);
-               const tcu::Vec4 p2              = tcu::Vec4(r2.x() * far * w2, r2.y() * far * w2, r2.z() * far * w2, w2);
+               const tcu::Vec4 p0              = tcu::Vec4(r0.x() * farForThreeVertex * w0, r0.y() * farForThreeVertex * w0, r0.z() * farForThreeVertex * w0, w0);
+               const tcu::Vec4 p1              = tcu::Vec4(r1.x() * farForThreeVertex * w1, r1.y() * farForThreeVertex * w1, r1.z() * farForThreeVertex * w1, w1);
+               const tcu::Vec4 p2              = tcu::Vec4(r2.x() * farForThreeVertex * w2, r2.y() * farForThreeVertex * w2, r2.z() * farForThreeVertex * w2, w2);
 
                // ignore cases where polygon is along xz or yz planes
                if (pointsOnLine(r0.swizzle(0, 1), r1.swizzle(0, 1), r2.swizzle(0, 1)))