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