Bugfix: Use PointSize in draw tests
authorMaciej Jesionowski <maciej.jesionowski@mobica.com>
Mon, 28 Nov 2016 15:12:23 +0000 (16:12 +0100)
committerPyry Haulos <phaulos@google.com>
Fri, 2 Dec 2016 19:00:49 +0000 (14:00 -0500)
Tests that rasterize points have to write to PointSize variable.
Also fix nonCoherentAtomSize errors from validation.

Affected tests:
- dEQP-VK.draw.basic_draw.draw.point_list.*
- dEQP-VK.draw.basic_draw.draw_indexed.point_list.*
- dEQP-VK.draw.basic_draw.draw_indirect.point_list.*
- dEQP-VK.draw.basic_draw.draw_indexed_indirect.point_list.*
- dEQP-VK.draw.instanced.draw_vk_primitive_topology_point_list
- dEQP-VK.draw.instanced.draw_indexed_vk_primitive_topology_point_list
- dEQP-VK.draw.instanced.draw_indirect_vk_primitive_topology_point_list
- dEQP-VK.draw.instanced.draw_indexed_indirect_vk_primitive_topology_point_list

Fixes #536

Change-Id: Ief9df51887babfc3765b0d11c6431765f322c634

external/vulkancts/modules/vulkan/draw/vktBasicDrawTests.cpp
external/vulkancts/modules/vulkan/draw/vktDrawInstancedTests.cpp

index a966011..db93794 100644 (file)
@@ -249,6 +249,21 @@ public:
        }
 };
 
+inline bool imageCompare (tcu::TestLog& log, const tcu::ConstPixelBufferAccess& reference, const tcu::ConstPixelBufferAccess& result, const vk::VkPrimitiveTopology topology)
+{
+       if (topology == vk::VK_PRIMITIVE_TOPOLOGY_POINT_LIST)
+       {
+               return tcu::intThresholdPositionDeviationCompare(
+                       log, "Result", "Image comparison result", reference, result,
+                       tcu::UVec4(4u),                                 // color threshold
+                       tcu::IVec3(1, 1, 0),                    // position deviation tolerance
+                       true,                                                   // don't check the pixels at the boundary
+                       tcu::COMPARE_LOG_RESULT);
+       }
+       else
+               return tcu::fuzzyCompare(log, "Result", "Image comparison result", reference, result, 0.05f, tcu::COMPARE_LOG_RESULT);
+}
+
 class DrawTestInstanceBase : public TestInstance
 {
 public:
@@ -391,7 +406,7 @@ void DrawTestInstanceBase::initialize (const DrawParamsBase& data)
                                                           device,
                                                           m_vertexBuffer->getBoundMemory().getMemory(),
                                                           m_vertexBuffer->getBoundMemory().getOffset(),
-                                                          dataSize);
+                                                          VK_WHOLE_SIZE);
 
        const CmdPoolCreateInfo cmdPoolCreateInfo(queueFamilyIndex);
        m_cmdPool = vk::createCommandPool(m_vk, device, &cmdPoolCreateInfo);
@@ -584,11 +599,13 @@ void DrawTestCase<T>::initShaderSources (void)
                                << "layout(location = 0) out vec4 out_color;\n"
 
                                << "out gl_PerVertex {\n"
-                               << "    vec4 gl_Position;\n"
+                               << "    vec4  gl_Position;\n"
+                               << "    float gl_PointSize;\n"
                                << "};\n"
                                << "void main() {\n"
-                               << "    gl_Position = in_position;\n"
-                               << "    out_color = in_color;\n"
+                               << "    gl_PointSize = 1.0;\n"
+                               << "    gl_Position  = in_position;\n"
+                               << "    out_color    = in_color;\n"
                                << "}\n";
 
        m_vertShaderSource = vertShader.str();
@@ -599,7 +616,7 @@ void DrawTestCase<T>::initShaderSources (void)
                                << "layout(location = 0) out vec4 out_color;\n"
                                << "void main()\n"
                                << "{\n"
-                               << "    out_color = in_color;\n"
+                               << "    out_color = in_color;\n"
                                << "}\n";
 
        m_fragShaderSource = fragShader.str();
@@ -684,12 +701,9 @@ tcu::TestStatus DrawTestInstance<DrawParams>::iterate (void)
 
        qpTestResult res = QP_TEST_RESULT_PASS;
 
-       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
-                                                  refImage.getAccess(),
-                                                  renderedFrame, 0.05f,
-                                                  tcu::COMPARE_LOG_RESULT)) {
+       if (!imageCompare(log, refImage.getAccess(), renderedFrame, m_data.topology))
                res = QP_TEST_RESULT_FAIL;
-       }
+
        return tcu::TestStatus(res, qpGetTestResultName(res));
 }
 
@@ -814,12 +828,9 @@ tcu::TestStatus DrawTestInstance<DrawIndexedParams>::iterate (void)
 
        qpTestResult res = QP_TEST_RESULT_PASS;
 
-       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
-                                                  refImage.getAccess(),
-                                                  renderedFrame, 0.05f,
-                                                  tcu::COMPARE_LOG_RESULT)) {
+       if (!imageCompare(log, refImage.getAccess(), renderedFrame, m_data.topology))
                res = QP_TEST_RESULT_FAIL;
-       }
+
        return tcu::TestStatus(res, qpGetTestResultName(res));
 }
 
@@ -961,12 +972,9 @@ tcu::TestStatus DrawTestInstance<DrawIndirectParams>::iterate (void)
 
        qpTestResult res = QP_TEST_RESULT_PASS;
 
-       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
-                                                  refImage.getAccess(),
-                                                  renderedFrame, 0.05f,
-                                                  tcu::COMPARE_LOG_RESULT)) {
+       if (!imageCompare(log, refImage.getAccess(), renderedFrame, m_data.topology))
                res = QP_TEST_RESULT_FAIL;
-       }
+
        return tcu::TestStatus(res, qpGetTestResultName(res));
 }
 
@@ -1152,12 +1160,9 @@ tcu::TestStatus DrawTestInstance<DrawIndexedIndirectParams>::iterate (void)
 
        qpTestResult res = QP_TEST_RESULT_PASS;
 
-       if (!tcu::fuzzyCompare(log, "Result", "Image comparison result",
-                                                  refImage.getAccess(),
-                                                  renderedFrame, 0.05f,
-                                                  tcu::COMPARE_LOG_RESULT)) {
+       if (!imageCompare(log, refImage.getAccess(), renderedFrame, m_data.topology))
                res = QP_TEST_RESULT_FAIL;
-       }
+
        return tcu::TestStatus(res, qpGetTestResultName(res));
 }
 
index 6a15506..a1a28af 100644 (file)
@@ -136,7 +136,7 @@ de::SharedPtr<Buffer> createAndUploadBuffer(const std::vector<T> data, const vk:
        vk::flushMappedMemoryRange(vk, context.getDevice(),
                                                           vertexBuffer->getBoundMemory().getMemory(),
                                                           vertexBuffer->getBoundMemory().getOffset(),
-                                                          dataSize);
+                                                          VK_WHOLE_SIZE);
        return vertexBuffer;
 }
 
@@ -254,11 +254,13 @@ public:
                                "} params;\n"
                                "layout(location = 0) out vec4 out_color;\n"
                                "out gl_PerVertex {\n"
-                               "    vec4 gl_Position;\n"
+                               "    vec4  gl_Position;\n"
+                               "    float gl_PointSize;\n"
                                "};\n"
                                "void main() {\n"
-                               "       gl_Position = in_position + vec4(float(gl_InstanceIndex - params.firstInstance) * 2.0 / params.instanceCount, 0.0, 0.0, 0.0);\n"
-                               "       out_color = in_color + vec4(float(gl_InstanceIndex) / params.instanceCount, 0.0, 0.0, 1.0) + in_color_2;\n"
+                               "    gl_PointSize = 1.0;\n"
+                               "    gl_Position  = in_position + vec4(float(gl_InstanceIndex - params.firstInstance) * 2.0 / params.instanceCount, 0.0, 0.0, 0.0);\n"
+                               "    out_color    = in_color + vec4(float(gl_InstanceIndex) / params.instanceCount, 0.0, 0.0, 1.0) + in_color_2;\n"
                                "}\n";
 
                m_fragmentShader = "#version 430\n"
@@ -266,7 +268,7 @@ public:
                                "layout(location = 0) out vec4 out_color;\n"
                                "void main()\n"
                                "{\n"
-                               "  out_color = in_color;\n"
+                               "    out_color = in_color;\n"
                                "}\n";
        }
 
@@ -630,8 +632,24 @@ tcu::TestStatus InstancedDrawInstance::iterate()
 
                        std::ostringstream resultDesc;
                        resultDesc << "Image comparison result. Instance count: " << instanceCount << " first instance index: " << firstInstance;
-                       if (!tcu::fuzzyCompare(log, "Result", resultDesc.str().c_str(), refImage.getAccess(), renderedFrame, 0.05f, tcu::COMPARE_LOG_RESULT))
-                               res = QP_TEST_RESULT_FAIL;
+
+                       if (m_params.topology == vk::VK_PRIMITIVE_TOPOLOGY_POINT_LIST)
+                       {
+                               const bool ok = tcu::intThresholdPositionDeviationCompare(
+                                       log, "Result", resultDesc.str().c_str(), refImage.getAccess(), renderedFrame,
+                                       tcu::UVec4(4u),                                 // color threshold
+                                       tcu::IVec3(1, 1, 0),                    // position deviation tolerance
+                                       true,                                                   // don't check the pixels at the boundary
+                                       tcu::COMPARE_LOG_RESULT);
+
+                               if (!ok)
+                                       res = QP_TEST_RESULT_FAIL;
+                       }
+                       else
+                       {
+                               if (!tcu::fuzzyCompare(log, "Result", resultDesc.str().c_str(), refImage.getAccess(), renderedFrame, 0.05f, tcu::COMPARE_LOG_RESULT))
+                                       res = QP_TEST_RESULT_FAIL;
+                       }
                }
        }
        return tcu::TestStatus(res, qpGetTestResultName(res));