Fix subpixel precision for line geometry generation
authorPetros Bantolas <petros.bantolas@imgtec.com>
Wed, 18 Jul 2018 10:19:04 +0000 (11:19 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 31 Aug 2018 07:48:29 +0000 (03:48 -0400)
Line geometry generation for rasterization tests wasn't taking the HW
subPixelPrecisionBits limit into account. Modified the triangle creation
routines to round those coordinates down to the driver provided
precision.

Affects:

dEQP-VK.rasterization.*line*
dEQP-GLES*.functional.rasterization.*line*

Components: Framework

VK-GL-CTS issue: 1274

Change-Id: I54af2f9606372bead2a8c7238588374101f80e55

framework/common/tcuRasterizationVerifier.cpp

index dd8ff86..12de7e8 100644 (file)
@@ -936,15 +936,21 @@ bool verifyMultisampleLineGroupRasterization (const tcu::Surface& surface, const
                        (lineNormalizedDeviceSpace[1] + tcu::Vec2(1.0f, 1.0f)) * 0.5f * viewportSize,
                };
 
-               const tcu::Vec2 lineDir                 = tcu::normalize(lineScreenSpace[1] - lineScreenSpace[0]);
+               const tcu::Vec2 lineScreenSpaceRounded[2] =
+               {
+                       tcu::Vec2(deFloatRound(lineScreenSpace[0].x() * (float)(1 << args.subpixelBits)) / (float)(1 << args.subpixelBits), deFloatRound(lineScreenSpace[0].y() * (float)(1 << args.subpixelBits)) / (float)(1 << args.subpixelBits)),
+                       tcu::Vec2(deFloatRound(lineScreenSpace[1].x() * (float)(1 << args.subpixelBits)) / (float)(1 << args.subpixelBits), deFloatRound(lineScreenSpace[1].y() * (float)(1 << args.subpixelBits)) / (float)(1 << args.subpixelBits))
+               };
+
+               const tcu::Vec2 lineDir                 = tcu::normalize(lineScreenSpaceRounded[1] - lineScreenSpaceRounded[0]);
                const tcu::Vec2 lineNormalDir   = tcu::Vec2(lineDir.y(), -lineDir.x());
 
                const tcu::Vec2 lineQuadScreenSpace[4] =
                {
-                       lineScreenSpace[0] + lineNormalDir * halfLineWidth,
-                       lineScreenSpace[0] - lineNormalDir * halfLineWidth,
-                       lineScreenSpace[1] - lineNormalDir * halfLineWidth,
-                       lineScreenSpace[1] + lineNormalDir * halfLineWidth,
+                       lineScreenSpaceRounded[0] + lineNormalDir * halfLineWidth,
+                       lineScreenSpaceRounded[0] - lineNormalDir * halfLineWidth,
+                       lineScreenSpaceRounded[1] - lineNormalDir * halfLineWidth,
+                       lineScreenSpaceRounded[1] + lineNormalDir * halfLineWidth,
                };
                const tcu::Vec2 lineQuadNormalizedDeviceSpace[4] =
                {
@@ -989,15 +995,21 @@ bool verifyMultisampleLineGroupInterpolation (const tcu::Surface& surface, const
                        (lineNormalizedDeviceSpace[1] + tcu::Vec2(1.0f, 1.0f)) * 0.5f * viewportSize,
                };
 
-               const tcu::Vec2 lineDir                 = tcu::normalize(lineScreenSpace[1] - lineScreenSpace[0]);
+               const tcu::Vec2 lineScreenSpaceRounded[2] =
+               {
+                       tcu::Vec2(deFloatRound(lineScreenSpace[0].x() * (float)(1 << args.subpixelBits)) / (float)(1 << args.subpixelBits), deFloatRound(lineScreenSpace[0].y() * (float)(1 << args.subpixelBits)) / (float)(1 << args.subpixelBits)),
+                       tcu::Vec2(deFloatRound(lineScreenSpace[1].x() * (float)(1 << args.subpixelBits)) / (float)(1 << args.subpixelBits), deFloatRound(lineScreenSpace[1].y() * (float)(1 << args.subpixelBits)) / (float)(1 << args.subpixelBits))
+               };
+
+               const tcu::Vec2 lineDir                 = tcu::normalize(lineScreenSpaceRounded[1] - lineScreenSpaceRounded[0]);
                const tcu::Vec2 lineNormalDir   = tcu::Vec2(lineDir.y(), -lineDir.x());
 
                const tcu::Vec2 lineQuadScreenSpace[4] =
                {
-                       lineScreenSpace[0] + lineNormalDir * halfLineWidth,
-                       lineScreenSpace[0] - lineNormalDir * halfLineWidth,
-                       lineScreenSpace[1] - lineNormalDir * halfLineWidth,
-                       lineScreenSpace[1] + lineNormalDir * halfLineWidth,
+                       lineScreenSpaceRounded[0] + lineNormalDir * halfLineWidth,
+                       lineScreenSpaceRounded[0] - lineNormalDir * halfLineWidth,
+                       lineScreenSpaceRounded[1] - lineNormalDir * halfLineWidth,
+                       lineScreenSpaceRounded[1] + lineNormalDir * halfLineWidth,
                };
                const tcu::Vec2 lineQuadNormalizedDeviceSpace[4] =
                {