Fix issues in Vulkan PointCoord test
authorPyry Haulos <phaulos@google.com>
Wed, 1 Feb 2017 23:24:52 +0000 (15:24 -0800)
committerPyry Haulos <phaulos@google.com>
Fri, 3 Feb 2017 21:50:23 +0000 (13:50 -0800)
 * Fixed PointCoord calculation to follow spec.

 * Made random point size generation code more robust. Existing code
resulted in rnd.getInt() being called with invalid range.

Changed: dEQP-VK.glsl.builtin_var.simple.pointcoord
Components: Vulkan
VK-GL-CTS issue: 68

Change-Id: I34f0c2c2ec5c8d759f22e81a1683c21572887c58

external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp
external/vulkancts/mustpass/1.0.2/src/excluded-tests.txt
external/vulkancts/mustpass/1.0.2/vk-default.txt

index 4f89e18ba0b065605160a28073d5159aea149a78..3a6d8cc6c6a0fade96ddfcab63e71eb9623f1a0d 100644 (file)
@@ -439,15 +439,21 @@ TestStatus BuiltinGlPointCoordCaseInstance::iterate (void)
        Surface                                 resImage                (width, height);
        Surface                                 refImage                (width, height);
        bool                                    compareOk               = false;
-       VkPhysicalDeviceLimits  limits                  = m_context.getDeviceProperties().limits;
 
        // Compute coordinates.
        {
+               const VkPhysicalDeviceLimits&   limits                                  = m_context.getDeviceProperties().limits;
+               const float                                             minPointSize                    = limits.pointSizeRange[0];
+               const float                                             maxPointSize                    = limits.pointSizeRange[1];
+               const int                                               pointSizeDeltaMultiples = de::max(1, deCeilFloatToInt32((maxPointSize - minPointSize) / limits.pointSizeGranularity));
+
+               TCU_CHECK(minPointSize <= maxPointSize);
+
                for (vector<Vec3>::iterator coord = coords.begin(); coord != coords.end(); ++coord)
                {
                        coord->x() = rnd.getFloat(-0.9f, 0.9f);
                        coord->y() = rnd.getFloat(-0.9f, 0.9f);
-                       coord->z() = limits.pointSizeRange[0] + float(rnd.getInt(0, int((limits.pointSizeRange[1] - limits.pointSizeRange[0]) / limits.pointSizeGranularity))) * limits.pointSizeGranularity;
+                       coord->z() = de::min(maxPointSize, minPointSize + float(rnd.getInt(0, pointSizeDeltaMultiples)) * limits.pointSizeGranularity);
                }
        }
 
@@ -458,12 +464,16 @@ TestStatus BuiltinGlPointCoordCaseInstance::iterate (void)
 
        // Draw reference
        clear(refImage.getAccess(), m_clearColor);
+
        for (vector<Vec3>::const_iterator pointIter = coords.begin(); pointIter != coords.end(); ++pointIter)
        {
-               const int       x0              = deRoundFloatToInt32(float(width) *(pointIter->x()*0.5f + 0.5f) - pointIter->z()*0.5f);
-               const int       y0              = deRoundFloatToInt32(float(height)*(pointIter->y()*0.5f + 0.5f) - pointIter->z()*0.5f);
-               const int       x1              = deRoundFloatToInt32(float(width) *(pointIter->x()*0.5f + 0.5f) + pointIter->z()*0.5f);
-               const int       y1              = deRoundFloatToInt32(float(height)*(pointIter->y()*0.5f + 0.5f) + pointIter->z()*0.5f);
+               const float     centerX = float(width) *(pointIter->x()*0.5f + 0.5f);
+               const float     centerY = float(height)*(pointIter->y()*0.5f + 0.5f);
+               const float     size    = pointIter->z();
+               const int       x0              = deRoundFloatToInt32(centerX - size*0.5f);
+               const int       y0              = deRoundFloatToInt32(centerY - size*0.5f);
+               const int       x1              = deRoundFloatToInt32(centerX + size*0.5f);
+               const int       y1              = deRoundFloatToInt32(centerY + size*0.5f);
                const int       w               = x1-x0;
                const int       h               = y1-y0;
 
@@ -471,11 +481,13 @@ TestStatus BuiltinGlPointCoordCaseInstance::iterate (void)
                {
                        for (int xo = 0; xo < w; xo++)
                        {
-                               const float             xf              = (float(xo)+0.5f) / float(w);
-                               const float             yf              = (float(yo)+0.5f) / float(h);
-                               const Vec4              color   (xf, yf, 0.0f, 1.0f);
                                const int               dx              = x0+xo;
                                const int               dy              = y0+yo;
+                               const float             fragX   = float(dx) + 0.5f;
+                               const float             fragY   = float(dy) + 0.5f;
+                               const float             s               = 0.5f + (fragX - centerX) / size;
+                               const float             t               = 0.5f + (fragY - centerY) / size;
+                               const Vec4              color   (s, t, 0.0f, 1.0f);
 
                                if (de::inBounds(dx, 0, refImage.getWidth()) && de::inBounds(dy, 0, refImage.getHeight()))
                                        refImage.setPixel(dx, dy, RGBA(color));
index 84c1c9b0025bfb98577b73e5ab1e64058df9ca9e..ea8d52f91a3b5ffd8492dc168bfd8bd437a92ddd 100644 (file)
@@ -293,6 +293,3 @@ dEQP-VK.texture.explicit_lod.*
 
 # Exclude tests which are not on the Android CTS mustpass list
 dEQP-VK.texture.mipmap.2d.projected.*
-
-# Vulkan CTS issue 582
-dEQP-VK.glsl.builtin_var.simple.pointcoord
index 6eb7cb5bfd8d60986a4c03703d6c0322ad3d0377..68eaf54893d1069705d976fc29bcebae0d1658c2 100644 (file)
@@ -106037,6 +106037,7 @@ dEQP-VK.glsl.texture_gather.offsets.min_required_offset.2d_array.depth32f.base_l
 dEQP-VK.glsl.builtin_var.simple.frontfacing
 dEQP-VK.glsl.builtin_var.simple.fragcoord_xyz
 dEQP-VK.glsl.builtin_var.simple.fragcoord_w
+dEQP-VK.glsl.builtin_var.simple.pointcoord
 dEQP-VK.glsl.builtin_var.input_variations.input_none
 dEQP-VK.glsl.builtin_var.input_variations.input_builtin
 dEQP-VK.glsl.builtin_var.input_variations.input_varying