Truncate random coordinates in late fragment tests
authorSteve Hill <hills@broadcom.com>
Fri, 11 Jan 2019 10:12:46 +0000 (10:12 +0000)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 17 Jan 2019 08:43:47 +0000 (03:43 -0500)
The late-fragment tests generate random triangles.  Unfortunately,
the reference rasteriser does not respect the sub-pixel precision
of the physical device (it assumes 8 bits) which means that on
some platforms the reference rasterisation does not agree with
implementation.

This patch rounds the random coordinates to the reported
sub-pixel precision.  It was decided that in the short term this
was a less invasive change than modifying the reference rasteriser.

Affects: dEQP-VK.renderpass*.subpass_dependencies.late_fragment_tests.*

Components: Vulkan

VK-GL-CTS issue: 1549

Change-Id: I50f20284d9d2cb22e73564d6f71c0a3342547b68

external/vulkancts/modules/vulkan/renderpass/vktRenderPassSubpassDependencyTests.cpp

index 0e7be4a..26265dc 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "rrRenderer.hpp"
 #include "deRandom.hpp"
+#include "deMath.h"
 
 using namespace vk;
 
@@ -1406,6 +1407,14 @@ tcu::TestStatus SubpassDependencyTestInstance::iterate (void)
        }
 }
 
+static float truncateCoord(int dim, int subPixelBits, float f)
+{
+       const float scale = (float)(dim << subPixelBits);
+       const float coord = deFloatFloor(f * scale) / scale;
+
+       return coord;
+}
+
 template<typename RenderpassSubpass>
 tcu::TestStatus SubpassDependencyTestInstance::iterateInternal (void)
 {
@@ -1453,10 +1462,12 @@ tcu::TestStatus SubpassDependencyTestInstance::iterateInternal (void)
 
                for (int vertexNdx = 0; vertexNdx < 3; vertexNdx++)
                {
-                       vertexData.push_back(Vec4(2.0f * ((((float) rand.getFloat()) / (float) 1.0f)) + -1.0f,  // x-coordinate
-                                                                         2.0f * ((((float) rand.getFloat()) / (float) 1.0f)) + -1.0f,  // y-coordinate
-                                                                         primitiveDepth,                                                                                               // z-coordinate (depth)
-                                                                         1.0f));                                                                                                               // w-coordinate
+                       const int subPixelBits = m_context.getDeviceProperties().limits.subPixelPrecisionBits;
+
+                       float x = 2.0f * truncateCoord(m_width,  subPixelBits, rand.getFloat()) - 1.0f;
+                       float y = 2.0f * truncateCoord(m_height, subPixelBits, rand.getFloat()) - 1.0f;
+
+                       vertexData.push_back(Vec4(x, y, primitiveDepth, 1.0f));
                }
        }