72570afe30544b73f77ad05a1b48f77bee2fad9e
[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 "es32cCopyImageTests.hpp"
27 #include "esextcTestPackage.hpp"
28 #include "glcAggressiveShaderOptimizationsTests.hpp"
29 #include "glcFragDepthTests.hpp"
30 #include "glcInfoTests.hpp"
31 #include "glcInternalformatTests.hpp"
32 #include "glcSeparableProgramsTransformFeedbackTests.hpp"
33 #include "glcShaderConstExprTests.hpp"
34 #include "glcShaderIndexingTests.hpp"
35 #include "glcShaderIntegerMixTests.hpp"
36 #include "glcShaderLibrary.hpp"
37 #include "glcShaderLoopTests.hpp"
38 #include "glcShaderMacroTests.hpp"
39 #include "glcShaderNegativeTests.hpp"
40 #include "glcShaderStructTests.hpp"
41 #include "glcShaderSwitchTests.hpp"
42 #include "glcUniformBlockTests.hpp"
43 #include "gluStateReset.hpp"
44 #include "glwEnums.hpp"
45 #include "glwFunctions.hpp"
46 #include "tcuTestLog.hpp"
47
48 #include "../glesext/draw_buffers_indexed/esextcDrawBuffersIndexedTests.hpp"
49 #include "../glesext/geometry_shader/esextcGeometryShaderTests.hpp"
50 #include "../glesext/gpu_shader5/esextcGPUShader5Tests.hpp"
51 #include "../glesext/tessellation_shader/esextcTessellationShaderTests.hpp"
52 #include "../glesext/texture_border_clamp/esextcTextureBorderClampTests.hpp"
53 #include "../glesext/texture_buffer/esextcTextureBufferTests.hpp"
54 #include "../glesext/texture_cube_map_array/esextcTextureCubeMapArrayTests.hpp"
55
56 namespace es32cts
57 {
58
59 class TestCaseWrapper : public tcu::TestCaseExecutor
60 {
61 public:
62         TestCaseWrapper(ES32TestPackage& package);
63         ~TestCaseWrapper(void);
64
65         void init(tcu::TestCase* testCase, const std::string& path);
66         void deinit(tcu::TestCase* testCase);
67         tcu::TestNode::IterateResult iterate(tcu::TestCase* testCase);
68
69 private:
70         ES32TestPackage& m_testPackage;
71 };
72
73 TestCaseWrapper::TestCaseWrapper(ES32TestPackage& package) : m_testPackage(package)
74 {
75 }
76
77 TestCaseWrapper::~TestCaseWrapper(void)
78 {
79 }
80
81 void TestCaseWrapper::init(tcu::TestCase* testCase, const std::string&)
82 {
83         testCase->init();
84 }
85
86 void TestCaseWrapper::deinit(tcu::TestCase* testCase)
87 {
88         testCase->deinit();
89
90         glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
91 }
92
93 tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase* testCase)
94 {
95         tcu::TestContext&                        testCtx   = m_testPackage.getContext().getTestContext();
96         glu::RenderContext&                      renderCtx = m_testPackage.getContext().getRenderContext();
97         tcu::TestCase::IterateResult result;
98
99         // Clear to surrender-blue
100         {
101                 const glw::Functions& gl = renderCtx.getFunctions();
102                 gl.clearColor(0.0f, 0.0f, 0.0f, 1.f);
103                 gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
104         }
105
106         result = testCase->iterate();
107
108         // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
109         try
110         {
111                 renderCtx.postIterate();
112                 return result;
113         }
114         catch (const tcu::ResourceError&)
115         {
116                 testCtx.getLog().endCase(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
117                 testCtx.setTerminateAfter(true);
118                 return tcu::TestNode::STOP;
119         }
120         catch (const std::exception&)
121         {
122                 testCtx.getLog().endCase(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
123                 return tcu::TestNode::STOP;
124         }
125 }
126
127 ES32TestPackage::ES32TestPackage(tcu::TestContext& testCtx, const char* packageName)
128         : deqp::TestPackage(testCtx, packageName, "OpenGL ES 3.2 Conformance Tests",
129                                                 glu::ContextType(glu::ApiType::es(3, 2)), "gl_cts/data/gles32/")
130 {
131 }
132
133 ES32TestPackage::~ES32TestPackage(void)
134 {
135         deqp::TestPackage::deinit();
136 }
137
138 void ES32TestPackage::init(void)
139 {
140         // Call init() in parent - this creates context.
141         deqp::TestPackage::init();
142
143         try
144         {
145                 // Add main test groups
146                 addChild(new deqp::InfoTests(getContext()));
147
148                 tcu::TestCaseGroup* shadersGroup = new tcu::TestCaseGroup(getTestContext(), "shaders", "");
149                 shadersGroup->addChild(new deqp::ShaderIntegerMixTests(getContext(), glu::GLSL_VERSION_320_ES));
150                 shadersGroup->addChild(new deqp::ShaderNegativeTests(getContext(), glu::GLSL_VERSION_320_ES));
151                 shadersGroup->addChild(new glcts::AggressiveShaderOptimizationsTests(getContext()));
152                 addChild(shadersGroup);
153
154                 tcu::TestCaseGroup*  coreGroup = new tcu::TestCaseGroup(getTestContext(), "core", "");
155                 glcts::ExtParameters extParams(glu::GLSL_VERSION_320_ES, glcts::EXTENSIONTYPE_NONE);
156                 coreGroup->addChild(new glcts::GeometryShaderTests(getContext(), extParams));
157                 coreGroup->addChild(new glcts::GPUShader5Tests(getContext(), extParams));
158                 coreGroup->addChild(new glcts::TessellationShaderTests(getContext(), extParams));
159                 coreGroup->addChild(new glcts::TextureCubeMapArrayTests(getContext(), extParams));
160                 coreGroup->addChild(new glcts::TextureBorderClampTests(getContext(), extParams));
161                 coreGroup->addChild(new glcts::TextureBufferTests(getContext(), extParams));
162                 coreGroup->addChild(new glcts::DrawBuffersIndexedTests(getContext(), extParams));
163                 coreGroup->addChild(new glcts::ShaderConstExprTests(getContext()));
164                 coreGroup->addChild(new glcts::ShaderMacroTests(getContext()));
165                 coreGroup->addChild(new glcts::SeparableProgramsTransformFeedbackTests(getContext()));
166                 coreGroup->addChild(new glcts::CopyImageTests(getContext()));
167                 coreGroup->addChild(new glcts::InternalformatTests(getContext()));
168                 addChild(coreGroup);
169         }
170         catch (...)
171         {
172                 // Destroy context.
173                 deqp::TestPackage::deinit();
174                 throw;
175         }
176 }
177
178 tcu::TestCaseExecutor* ES32TestPackage::createExecutor(void) const
179 {
180         return new TestCaseWrapper(const_cast<ES32TestPackage&>(*this));
181 }
182
183 } // es32cts