Offset tris from fragments for triangle tests
authorReed Koser <rkoser@nvidia.com>
Mon, 3 Aug 2020 22:58:33 +0000 (15:58 -0700)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 27 Aug 2020 07:01:07 +0000 (03:01 -0400)
At some render resolutions, these tests can rely on the outcome of a
rasterizer tie-break. Since such behavior is left unspecified, we
offset the generated triangles slightly to ensure that they reliably
hit (or miss) the fragment locations we expect them to.

Affects:
KHR-GLES31.core.draw_indirect.basic-mode-drawArrays-triangle_strip_adjacency
KHR-GLES31.core.draw_indirect.basic-mode-drawArrays-triangles_adjacency
KHR-GLES31.core.draw_indirect.basic-mode-drawElements-triangle_strip_adjacency
KHR-GLES31.core.draw_indirect.basic-mode-drawElements-triangles_adjacency

Components: OpenGL ES

VK-GL-CTS issue: 2522

Change-Id: I63ab56dba99b5e6f6369aa4fd8b4538c9d01d874

external/openglcts/modules/gles31/es31cDrawIndirectTests.cpp

index 075236a..7adc4f7 100644 (file)
@@ -704,15 +704,20 @@ protected:
 
        void TrianglesAdjacencyGen(unsigned int drawSizeX, unsigned int drawSizeY, CColorArray& output)
        {
+               // Add a small amount (quarter pixel) of jitter to add to the rectangle sides to avoid
+               // triangle edges landing precisely on fragment centers.
+               float jigX = 0.5f / getWindowWidth();
+               float jigY = 0.5f / getWindowHeight();
+
                float sizeX = 1.0f / static_cast<float>(drawSizeX);
                float sizeY = 1.0f / static_cast<float>(drawSizeY);
 
                for (unsigned int i = 0; i < drawSizeX; ++i)
                {
-                       float offsetY = -0.5f + sizeY * static_cast<float>(i);
+                       float offsetY = -0.5f + jigY + sizeY * static_cast<float>(i);
                        for (unsigned int j = 0; j < drawSizeY; ++j)
                        {
-                               float offsetX = -0.5f + sizeX * static_cast<float>(j);
+                               float offsetX = -0.5f + jigX + sizeX * static_cast<float>(j);
 
                                output.push_back(tcu::Vec4(offsetX, offsetY, 0.0f, 1.0f));
                                output.push_back(tcu::Vec4(offsetX - sizeX, offsetY + sizeY, 0.0f, 1.0f));
@@ -733,15 +738,20 @@ protected:
 
        void TriangleStripAdjacencyGen(unsigned int drawSizeX, unsigned int drawSizeY, CColorArray& output)
        {
+               // Add a small amount (quarter pixel) of jitter to add to the rectangle sides to avoid
+               // triangle edges landing precisely on fragment centers.
+               float jigX = 0.5f / getWindowWidth();
+               float jigY = 0.5f / getWindowHeight();
+
                float sizeX = 1.0f / static_cast<float>(drawSizeX);
                float sizeY = 1.0f / static_cast<float>(drawSizeY);
 
                for (unsigned int i = 0; i < drawSizeX; ++i)
                {
-                       float offsetY = -0.5f + sizeY * static_cast<float>(i);
+                       float offsetY = -0.5f + jigY + sizeY * static_cast<float>(i);
                        for (unsigned int j = 0; j < drawSizeY; ++j)
                        {
-                               float offsetX = -0.5f + sizeX * static_cast<float>(j);
+                               float offsetX = -0.5f + jigX + sizeX * static_cast<float>(j);
 
                                output.push_back(tcu::Vec4(offsetX, offsetY, 0.0f, 1.0f));
                                output.push_back(tcu::Vec4(offsetX - sizeX, offsetY + sizeY, 0.0f, 1.0f));