Add new swizzle math operation tests am: 821035bbc9
[platform/upstream/VK-GL-CTS.git] / external / openglcts / modules / gles32 / es32cTestPackage.cpp
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2016 Google Inc.
6  * Copyright (c) 2016 The Khronos Group Inc.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */ /*!
21  * \file
22  * \brief OpenGL ES 3 Test Package.
23  */ /*-------------------------------------------------------------------*/
24
25 #include "es32cTestPackage.hpp"
26 #include "es32cRobustBufferAccessBehaviorTests.hpp"
27 #include "esextcTestPackage.hpp"
28 #include "glcFragDepthTests.hpp"
29 #include "glcInfoTests.hpp"
30 #include "glcShaderIndexingTests.hpp"
31 #include "glcShaderIntegerMixTests.hpp"
32 #include "glcShaderLibrary.hpp"
33 #include "glcShaderLoopTests.hpp"
34 #include "glcShaderNegativeTests.hpp"
35 #include "glcShaderStructTests.hpp"
36 #include "glcShaderSwitchTests.hpp"
37 #include "glcUniformBlockTests.hpp"
38 #include "gluStateReset.hpp"
39 #include "glwEnums.hpp"
40 #include "glwFunctions.hpp"
41 #include "tcuTestLog.hpp"
42
43 #include "../glesext/draw_buffers_indexed/esextcDrawBuffersIndexedTests.hpp"
44 #include "../glesext/geometry_shader/esextcGeometryShaderTests.hpp"
45 #include "../glesext/gpu_shader5/esextcGPUShader5Tests.hpp"
46 #include "../glesext/tessellation_shader/esextcTessellationShaderTests.hpp"
47 #include "../glesext/texture_border_clamp/esextcTextureBorderClampTests.hpp"
48 #include "../glesext/texture_buffer/esextcTextureBufferTests.hpp"
49 #include "../glesext/texture_cube_map_array/esextcTextureCubeMapArrayTests.hpp"
50
51 namespace es32cts
52 {
53
54 class TestCaseWrapper : public tcu::TestCaseExecutor
55 {
56 public:
57         TestCaseWrapper(ES32TestPackage& package);
58         ~TestCaseWrapper(void);
59
60         void init(tcu::TestCase* testCase, const std::string& path);
61         void deinit(tcu::TestCase* testCase);
62         tcu::TestNode::IterateResult iterate(tcu::TestCase* testCase);
63
64 private:
65         ES32TestPackage& m_testPackage;
66 };
67
68 TestCaseWrapper::TestCaseWrapper(ES32TestPackage& package) : m_testPackage(package)
69 {
70 }
71
72 TestCaseWrapper::~TestCaseWrapper(void)
73 {
74 }
75
76 void TestCaseWrapper::init(tcu::TestCase* testCase, const std::string&)
77 {
78         testCase->init();
79 }
80
81 void TestCaseWrapper::deinit(tcu::TestCase* testCase)
82 {
83         testCase->deinit();
84
85         glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
86 }
87
88 tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase* testCase)
89 {
90         tcu::TestContext&                        testCtx   = m_testPackage.getContext().getTestContext();
91         glu::RenderContext&                      renderCtx = m_testPackage.getContext().getRenderContext();
92         tcu::TestCase::IterateResult result;
93
94         // Clear to surrender-blue
95         {
96                 const glw::Functions& gl = renderCtx.getFunctions();
97                 gl.clearColor(0.0f, 0.0f, 0.0f, 1.f);
98                 gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
99         }
100
101         result = testCase->iterate();
102
103         // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
104         try
105         {
106                 renderCtx.postIterate();
107                 return result;
108         }
109         catch (const tcu::ResourceError&)
110         {
111                 testCtx.getLog().endCase(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
112                 testCtx.setTerminateAfter(true);
113                 return tcu::TestNode::STOP;
114         }
115         catch (const std::exception&)
116         {
117                 testCtx.getLog().endCase(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
118                 return tcu::TestNode::STOP;
119         }
120 }
121
122 ES32TestPackage::ES32TestPackage(tcu::TestContext& testCtx, const char* packageName)
123         : deqp::TestPackage(testCtx, packageName, "OpenGL ES 3.2 Conformance Tests",
124                                                 glu::ContextType(glu::ApiType::es(3, 2)), "gl_cts/data/gles32/")
125 {
126 }
127
128 ES32TestPackage::~ES32TestPackage(void)
129 {
130         deqp::TestPackage::deinit();
131 }
132
133 void ES32TestPackage::init(void)
134 {
135         // Call init() in parent - this creates context.
136         deqp::TestPackage::init();
137
138         try
139         {
140                 // Add main test groups
141                 addChild(new deqp::InfoTests(getContext()));
142
143                 tcu::TestCaseGroup* shadersGroup = new tcu::TestCaseGroup(getTestContext(), "shaders", "");
144                 shadersGroup->addChild(new deqp::ShaderIntegerMixTests(getContext(), glu::GLSL_VERSION_320_ES));
145                 shadersGroup->addChild(new deqp::ShaderNegativeTests(getContext(), glu::GLSL_VERSION_320_ES));
146                 addChild(shadersGroup);
147
148                 tcu::TestCaseGroup*  coreGroup = new tcu::TestCaseGroup(getTestContext(), "core", "");
149                 glcts::ExtParameters extParams(glu::GLSL_VERSION_320_ES, glcts::EXTENSIONTYPE_NONE);
150                 coreGroup->addChild(new glcts::GeometryShaderTests(getContext(), extParams));
151                 coreGroup->addChild(new glcts::GPUShader5Tests(getContext(), extParams));
152                 coreGroup->addChild(new glcts::TessellationShaderTests(getContext(), extParams));
153                 coreGroup->addChild(new glcts::TextureCubeMapArrayTests(getContext(), extParams));
154                 coreGroup->addChild(new glcts::TextureBorderClampTests(getContext(), extParams));
155                 coreGroup->addChild(new glcts::TextureBufferTests(getContext(), extParams));
156                 coreGroup->addChild(new glcts::DrawBuffersIndexedTests(getContext(), extParams));
157                 addChild(coreGroup);
158                 tcu::TestCaseGroup* robustGroup = new tcu::TestCaseGroup(getTestContext(), "robust", "");
159                 robustGroup->addChild(new es32cts::RobustBufferAccessBehaviorTests(getContext()));
160                 addChild(robustGroup);
161         }
162         catch (...)
163         {
164                 // Destroy context.
165                 deqp::TestPackage::deinit();
166                 throw;
167         }
168 }
169
170 tcu::TestCaseExecutor* ES32TestPackage::createExecutor(void) const
171 {
172         return new TestCaseWrapper(const_cast<ES32TestPackage&>(*this));
173 }
174
175 } // es32cts