Add test for gl_FrontFacing
authorPeter Siket <ps.szeged@partner.samsung.com>
Tue, 28 Jun 2016 11:18:36 +0000 (13:18 +0200)
committerPyry Haulos <phaulos@google.com>
Thu, 7 Jul 2016 19:41:18 +0000 (12:41 -0700)
Fixes #412

external/vulkancts/modules/vulkan/shaderrender/CMakeLists.txt
external/vulkancts/modules/vulkan/shaderrender/vktShaderRender.cpp
external/vulkancts/modules/vulkan/shaderrender/vktShaderRender.hpp
external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.hpp [new file with mode: 0644]
external/vulkancts/modules/vulkan/vktTestPackage.cpp
external/vulkancts/mustpass/1.0.1/com.drawelements.deqp.vk.xml
external/vulkancts/mustpass/1.0.1/vk-default.txt

index d85c4a0..e15521a 100644 (file)
@@ -5,6 +5,8 @@ include_directories(
 set(DEQP_VK_SHADERRENDER_SRCS
        vktShaderRender.cpp
        vktShaderRender.hpp
+       vktShaderRenderBuiltinVarTests.cpp
+       vktShaderRenderBuiltinVarTests.hpp
        vktShaderRenderDerivateTests.cpp
        vktShaderRenderDerivateTests.hpp
        vktShaderRenderDiscardTests.cpp
index a6c9cbc..6c5eced 100644 (file)
@@ -532,6 +532,23 @@ TestInstance* ShaderRenderCase::createInstance (Context& context) const
 
 // ShaderRenderCaseInstance.
 
+ShaderRenderCaseInstance::ShaderRenderCaseInstance (Context& context)
+       : vkt::TestInstance             (context)
+       , m_memAlloc                    (context.getDefaultAllocator())
+       , m_clearColor                  (DEFAULT_CLEAR_COLOR)
+       , m_isVertexCase                (false)
+       , m_vertexShaderName    ("vert")
+       , m_fragmentShaderName  ("frag")
+       , m_renderSize                  (128, 128)
+       , m_colorFormat                 (VK_FORMAT_R8G8B8A8_UNORM)
+       , m_evaluator                   (DE_NULL)
+       , m_uniformSetup                (DE_NULL)
+       , m_attribFunc                  (DE_NULL)
+       , m_sampleCount                 (VK_SAMPLE_COUNT_1_BIT)
+{
+}
+
+
 ShaderRenderCaseInstance::ShaderRenderCaseInstance (Context&                                   context,
                                                                                                        const bool                                      isVertexCase,
                                                                                                        const ShaderEvaluator&          evaluator,
index 145a414..f84fc92 100644 (file)
@@ -419,6 +419,7 @@ enum BaseAttributeType
 class ShaderRenderCaseInstance : public vkt::TestInstance
 {
 public:
+                                                                                                               ShaderRenderCaseInstance        (Context&                                       context);
                                                                                                                ShaderRenderCaseInstance        (Context&                                       context,
                                                                                                                                                                        const bool                                      isVertexCase,
                                                                                                                                                                        const ShaderEvaluator&          evaluator,
@@ -474,7 +475,7 @@ protected:
        void                                                                                            setSampleCount                          (vk::VkSampleCountFlagBits sampleCount);
 
        bool                                                                                            isMultiSampling                         (void) const;
-       
+
        vk::Allocator&                                                                          m_memAlloc;
        const tcu::Vec4                                                                         m_clearColor;
        const bool                                                                                      m_isVertexCase;
diff --git a/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp b/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.cpp
new file mode 100644 (file)
index 0000000..79fd52f
--- /dev/null
@@ -0,0 +1,174 @@
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Shader builtin variable tests.
+ *//*--------------------------------------------------------------------*/
+
+#include "vktShaderRenderBuiltinVarTests.hpp"
+#include "vktShaderRender.hpp"
+#include "gluShaderUtil.hpp"
+#include "tcuImageCompare.hpp"
+#include "tcuStringTemplate.hpp"
+#include "tcuTextureUtil.hpp"
+
+using namespace std;
+using namespace tcu;
+using namespace vk;
+
+namespace vkt
+{
+namespace sr
+{
+
+namespace
+{
+
+class BuiltinGlFrontFacingCaseInstance : public ShaderRenderCaseInstance
+{
+public:
+                                       BuiltinGlFrontFacingCaseInstance        (Context& context);
+
+       TestStatus              iterate                                                         (void);
+       virtual void    setupDefaultInputs                                      (void);
+};
+
+BuiltinGlFrontFacingCaseInstance::BuiltinGlFrontFacingCaseInstance (Context& context)
+       : ShaderRenderCaseInstance      (context)
+{
+}
+
+TestStatus BuiltinGlFrontFacingCaseInstance::iterate (void)
+{
+       const UVec2             viewportSize    = getViewportSize();
+       const int               width                   = viewportSize.x();
+       const int               height                  = viewportSize.y();
+       const RGBA              threshold               (2, 2, 2, 2);
+       Surface                 resImage                (width, height);
+       Surface                 refImage                (width, height);
+       bool                    compareOk               = false;
+       const deUint16  indices[12]             =
+       {
+               0, 4, 1,
+               0, 5, 4,
+               1, 2, 3,
+               1, 3, 4
+       };
+
+       setup();
+       render(6, 4, indices);
+       copy(resImage.getAccess(), getResultImage().getAccess());
+
+       for (int y = 0; y < refImage.getHeight(); y++)
+       {
+               for (int x = 0; x < refImage.getWidth()/2; x++)
+                       refImage.setPixel(x, y, RGBA::green());
+
+               for (int x = refImage.getWidth()/2; x < refImage.getWidth(); x++)
+                       refImage.setPixel(x, y, RGBA::blue());
+       }
+
+       compareOk = pixelThresholdCompare(m_context.getTestContext().getLog(), "Result", "Image comparison result", refImage, resImage, threshold, COMPARE_LOG_RESULT);
+
+       if (compareOk)
+               return TestStatus::pass("Result image matches reference");
+       else
+               return TestStatus::fail("Image mismatch");
+}
+
+void BuiltinGlFrontFacingCaseInstance::setupDefaultInputs (void)
+{
+       const float vertices[] =
+       {
+               -1.0f, -1.0f, 0.0f, 1.0f,
+                0.0f, -1.0f, 0.0f, 1.0f,
+                1.0f, -1.0f, 0.0f, 1.0f,
+                1.0f,  1.0f, 0.0f, 1.0f,
+                0.0f,  1.0f, 0.0f, 1.0f,
+               -1.0f,  1.0f, 0.0f, 1.0f
+       };
+
+       addAttribute(0u, VK_FORMAT_R32G32B32A32_SFLOAT, (deUint32)sizeof(float) * 4, 6, vertices);
+}
+
+class BuiltinGlFrontFacingCase : public TestCase
+{
+public:
+                                                               BuiltinGlFrontFacingCase        (TestContext& testCtx, const string& name, const string& description);
+       virtual                                         ~BuiltinGlFrontFacingCase       (void);
+
+       void                                            initPrograms                            (SourceCollections& dst) const;
+       TestInstance*                           createInstance                          (Context& context) const;
+
+private:
+                                                               BuiltinGlFrontFacingCase        (const BuiltinGlFrontFacingCase&);      // not allowed!
+       BuiltinGlFrontFacingCase&       operator=                                       (const BuiltinGlFrontFacingCase&);      // not allowed!
+};
+
+BuiltinGlFrontFacingCase::BuiltinGlFrontFacingCase (TestContext& testCtx, const string& name, const string& description)
+       : TestCase(testCtx, name, description)
+{
+}
+
+BuiltinGlFrontFacingCase::~BuiltinGlFrontFacingCase (void)
+{
+}
+
+void BuiltinGlFrontFacingCase::initPrograms (SourceCollections& dst) const
+{
+       dst.glslSources.add("vert") << glu::VertexSource(
+               "#version 310 es\n"
+               "layout(location = 0) in highp vec4 a_position;\n"
+               "void main (void)\n"
+               "{\n"
+               "       gl_Position = a_position;\n"
+               "}\n");
+
+       dst.glslSources.add("frag") << glu::FragmentSource(
+               "#version 310 es\n"
+               "layout(location = 0) out lowp vec4 o_color;\n"
+               "void main (void)\n"
+               "{\n"
+               "       if (gl_FrontFacing)\n"
+               "               o_color = vec4(0.0, 1.0, 0.0, 1.0);\n"
+               "       else\n"
+               "               o_color = vec4(0.0, 0.0, 1.0, 1.0);\n"
+               "}\n");
+}
+
+TestInstance* BuiltinGlFrontFacingCase::createInstance (Context& context) const
+{
+       return new BuiltinGlFrontFacingCaseInstance(context);
+}
+
+} // anonymous
+
+TestCaseGroup* createBuiltinVarTests (TestContext& testCtx)
+{
+       de::MovePtr<TestCaseGroup> varyingGroup(new TestCaseGroup(testCtx, "builtin_var", "Shader builtin variable tests."));
+
+       varyingGroup->addChild(new BuiltinGlFrontFacingCase(testCtx, "gl_frontfacing", "gl_FrontFacing test"));
+
+       return varyingGroup.release();
+}
+
+} // sr
+} // vkt
diff --git a/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.hpp b/external/vulkancts/modules/vulkan/shaderrender/vktShaderRenderBuiltinVarTests.hpp
new file mode 100644 (file)
index 0000000..9be3670
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef _VKTSHADERRENDERBUILTINVARTESTS_HPP
+#define _VKTSHADERRENDERBUILTINVARTESTS_HPP
+/*------------------------------------------------------------------------
+ * Vulkan Conformance Tests
+ * ------------------------
+ *
+ * Copyright (c) 2015 The Khronos Group Inc.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *//*!
+ * \file
+ * \brief Shader builtin variable tests.
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+#include "tcuTestCase.hpp"
+
+namespace vkt
+{
+namespace sr
+{
+
+tcu::TestCaseGroup*    createBuiltinVarTests   (tcu::TestContext& testCtx);
+
+} // sr
+} // vkt
+
+#endif // _VKTSHADERRENDERBUILTINVARTESTS_HPP
index 8854a69..cb46ea1 100644 (file)
@@ -45,6 +45,7 @@
 #include "vktShaderLibrary.hpp"
 #include "vktRenderPassTests.hpp"
 #include "vktMemoryTests.hpp"
+#include "vktShaderRenderBuiltinVarTests.hpp"
 #include "vktShaderRenderDerivateTests.hpp"
 #include "vktShaderRenderDiscardTests.hpp"
 #include "vktShaderRenderIndexingTests.hpp"
@@ -344,6 +345,7 @@ void createGlslTests (tcu::TestCaseGroup* glslTests)
        glslTests->addChild(sr::createSwitchTests                       (testCtx));
        glslTests->addChild(sr::createTextureFunctionTests      (testCtx));
        glslTests->addChild(sr::createTextureGatherTests        (testCtx));
+       glslTests->addChild(sr::createBuiltinVarTests           (testCtx));
 
        // ShaderExecutor-based tests
        glslTests->addChild(shaderexecutor::createBuiltinTests                          (testCtx));
@@ -386,8 +388,8 @@ void TestPackage::init (void)
        addChild(wsi::createTests                               (m_testCtx));
        addChild(synchronization::createTests   (m_testCtx));
        addChild(sparse::createTests                    (m_testCtx));
-       addChild(tessellation::createTests      (m_testCtx));
-       addChild(rasterization::createTests (m_testCtx));
+       addChild(tessellation::createTests              (m_testCtx));
+       addChild(rasterization::createTests     (m_testCtx));
 }
 
 } // vkt
index d4731db..a2dd098 100644 (file)
                                        </TestSuite>
                                </TestSuite>
                        </TestSuite>
+                       <TestCase name="builtin_var">
+                               <Test name="gl_frontfacing">
+                                       <TestInstance/>
+                               </Test>
+                       </TestCase>
                        <TestSuite name="builtin">
                                <TestSuite name="function">
                                        <TestSuite name="common">
index 57fc25c..7f3505d 100644 (file)
@@ -76690,6 +76690,7 @@ dEQP-VK.glsl.texture_gather.offsets.min_required_offset.2d_array.depth32f.filter
 dEQP-VK.glsl.texture_gather.offsets.min_required_offset.2d_array.depth32f.filter_mode.min_linear_mipmap_linear_mag_linear
 dEQP-VK.glsl.texture_gather.offsets.min_required_offset.2d_array.depth32f.base_level.level_1
 dEQP-VK.glsl.texture_gather.offsets.min_required_offset.2d_array.depth32f.base_level.level_2
+dEQP-VK.glsl.builtin_var.gl_frontfacing
 dEQP-VK.glsl.builtin.function.common.abs.float_mediump_vertex
 dEQP-VK.glsl.builtin.function.common.abs.float_mediump_fragment
 dEQP-VK.glsl.builtin.function.common.abs.float_mediump_geometry