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 Extensions Test Package.
23 */ /*-------------------------------------------------------------------*/
24
25 #include "esextcTestPackage.hpp"
26
27 #include "draw_elements_base_vertex/esextcDrawElementsBaseVertexTests.hpp"
28 #include "geometry_shader/esextcGeometryShaderTests.hpp"
29 #include "gpu_shader5/esextcGPUShader5Tests.hpp"
30 #include "tessellation_shader/esextcTessellationShaderTests.hpp"
31 #include "texture_border_clamp/esextcTextureBorderClampTests.hpp"
32 #include "texture_buffer/esextcTextureBufferTests.hpp"
33 #include "texture_cube_map_array/esextcTextureCubeMapArrayTests.hpp"
34 #include "texture_shadow_lod/esextcTextureShadowLodFunctionsTest.hpp"
35 #include "disjoint_timer_query/esextcDisjointTimerQueryTests.hpp"
36 #include "glcViewportArrayTests.hpp"
37 #include "gluStateReset.hpp"
38 #include "tcuTestLog.hpp"
39 #include "tcuWaiverUtil.hpp"
40
41 namespace esextcts
42 {
43
44 class TestCaseWrapper : public tcu::TestCaseExecutor
45 {
46 public:
47 TestCaseWrapper(ESEXTTestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
48 ~TestCaseWrapper(void);
49
50 void init(tcu::TestCase* testCase, const std::string& path);
51 void deinit(tcu::TestCase* testCase);
52 tcu::TestNode::IterateResult iterate(tcu::TestCase* testCase);
53
54 private:
55 ESEXTTestPackage& m_testPackage;
56 de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
57 };
58
TestCaseWrapper(ESEXTTestPackage & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)59 TestCaseWrapper::TestCaseWrapper(ESEXTTestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
60 : m_testPackage(package), m_waiverMechanism(waiverMechanism)
61 {
62 }
63
~TestCaseWrapper(void)64 TestCaseWrapper::~TestCaseWrapper(void)
65 {
66 }
67
init(tcu::TestCase * testCase,const std::string & path)68 void TestCaseWrapper::init(tcu::TestCase* testCase, const std::string& path)
69 {
70 if (m_waiverMechanism->isOnWaiverList(path))
71 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
72
73 glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
74
75 testCase->init();
76 }
77
deinit(tcu::TestCase * testCase)78 void TestCaseWrapper::deinit(tcu::TestCase* testCase)
79 {
80 testCase->deinit();
81
82 glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
83 }
84
iterate(tcu::TestCase * testCase)85 tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase* testCase)
86 {
87 tcu::TestContext& testCtx = m_testPackage.getContext().getTestContext();
88 glu::RenderContext& renderCtx = m_testPackage.getContext().getRenderContext();
89 tcu::TestCase::IterateResult result;
90
91 result = testCase->iterate();
92
93 // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
94 try
95 {
96 renderCtx.postIterate();
97 return result;
98 }
99 catch (const tcu::ResourceError&)
100 {
101 testCtx.getLog().endCase(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
102 testCtx.setTerminateAfter(true);
103 return tcu::TestNode::STOP;
104 }
105 catch (const std::exception&)
106 {
107 testCtx.getLog().endCase(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
108 return tcu::TestNode::STOP;
109 }
110 }
111
ESEXTTestPackage(tcu::TestContext & testCtx,const char * packageName)112 ESEXTTestPackage::ESEXTTestPackage(tcu::TestContext& testCtx, const char* packageName)
113 : TestPackage(testCtx, packageName, "OpenGL ES Extensions Conformance Tests",
114 glu::ContextType(glu::ApiType::es(3, 1)), "gl_cts/data/")
115 {
116 }
117
~ESEXTTestPackage(void)118 ESEXTTestPackage::~ESEXTTestPackage(void)
119 {
120 }
121
init(void)122 void ESEXTTestPackage::init(void)
123 {
124 // Call init() in parent - this creates context.
125 TestPackage::init();
126
127 try
128 {
129 const glu::ContextType& context_type = getContext().getRenderContext().getType();
130 glcts::ExtParameters extParams(glu::GLSL_VERSION_310_ES, glcts::EXTENSIONTYPE_EXT);
131 if (glu::contextSupports(context_type, glu::ApiType::es(3, 2)))
132 {
133 extParams.glslVersion = glu::GLSL_VERSION_320_ES;
134 extParams.extType = glcts::EXTENSIONTYPE_NONE;
135 }
136
137 addChild(new glcts::GeometryShaderTests(getContext(), extParams));
138 addChild(new glcts::GPUShader5Tests(getContext(), extParams));
139 addChild(new glcts::TessellationShaderTests(getContext(), extParams));
140 addChild(new glcts::TextureCubeMapArrayTests(getContext(), extParams));
141 addChild(new glcts::TextureBorderClampTests(getContext(), extParams));
142 addChild(new glcts::TextureBufferTests(getContext(), extParams));
143 addChild(new glcts::DrawElementsBaseVertexTests(getContext(), extParams));
144 glcts::ExtParameters viewportParams(glu::GLSL_VERSION_310_ES, glcts::EXTENSIONTYPE_OES);
145 addChild(new glcts::ViewportArrayTests(getContext(), viewportParams));
146 addChild(new deqp::Functional::TextureShadowLodTest(getContext()));
147 glcts::ExtParameters viewportParams2(glu::GLSL_VERSION_100_ES, glcts::EXTENSIONTYPE_OES);
148 addChild(new glcts::DisjointTimerQueryTests(getContext(), viewportParams2));
149 }
150 catch (...)
151 {
152 // Destroy context.
153 TestPackage::deinit();
154 throw;
155 }
156 }
157
createExecutor(void) const158 tcu::TestCaseExecutor* ESEXTTestPackage::createExecutor(void) const
159 {
160 return new TestCaseWrapper(const_cast<ESEXTTestPackage&>(*this), m_waiverMechanism);
161 }
162
163 } // esextcts
164