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 "es3cTestPackage.hpp"
26 #include "es3cCopyTexImageConversionsTests.hpp"
27 #include "es3cNumberParsingTests.hpp"
28 #include "glcAggressiveShaderOptimizationsTests.hpp"
29 #include "glcExposedExtensionsTests.hpp"
30 #include "glcFragDepthTests.hpp"
31 #include "glcGLSLVectorConstructorTests.hpp"
32 #include "glcInfoTests.hpp"
33 #include "glcInternalformatTests.hpp"
34 #include "glcPackedDepthStencilTests.hpp"
35 #include "glcPackedPixelsTests.hpp"
36 #include "glcParallelShaderCompileTests.hpp"
37 #include "glcShaderConstExprTests.hpp"
38 #include "glcShaderIndexingTests.hpp"
39 #include "glcShaderIntegerMixTests.hpp"
40 #include "glcShaderLibrary.hpp"
41 #include "glcShaderLoopTests.hpp"
42 #include "glcShaderMacroTests.hpp"
43 #include "glcShaderNegativeTests.hpp"
44 #include "glcShaderStructTests.hpp"
45 #include "glcTextureFilterAnisotropicTests.hpp"
46 #include "glcTextureRepeatModeTests.hpp"
47 #include "glcUniformBlockTests.hpp"
48 #include "glcNearestEdgeTests.hpp"
49 #include "glcFramebufferCompleteness.hpp"
50 #include "gluStateReset.hpp"
51 #include "glwEnums.hpp"
52 #include "glwFunctions.hpp"
53 #include "tcuTestLog.hpp"
54 #include "tcuWaiverUtil.hpp"
55
56 namespace es3cts
57 {
58
59 class TestCaseWrapper : public tcu::TestCaseExecutor
60 {
61 public:
62 TestCaseWrapper(ES30TestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
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 ES30TestPackage& m_testPackage;
71 de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
72 };
73
TestCaseWrapper(ES30TestPackage & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)74 TestCaseWrapper::TestCaseWrapper(ES30TestPackage& package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
75 : m_testPackage(package), m_waiverMechanism(waiverMechanism)
76 {
77 }
78
~TestCaseWrapper(void)79 TestCaseWrapper::~TestCaseWrapper(void)
80 {
81 }
82
init(tcu::TestCase * testCase,const std::string & path)83 void TestCaseWrapper::init(tcu::TestCase* testCase, const std::string& path)
84 {
85 if (m_waiverMechanism->isOnWaiverList(path))
86 throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
87
88 glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
89
90 testCase->init();
91 }
92
deinit(tcu::TestCase * testCase)93 void TestCaseWrapper::deinit(tcu::TestCase* testCase)
94 {
95 testCase->deinit();
96
97 glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
98 }
99
iterate(tcu::TestCase * testCase)100 tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase* testCase)
101 {
102 tcu::TestContext& testCtx = m_testPackage.getContext().getTestContext();
103 glu::RenderContext& renderCtx = m_testPackage.getContext().getRenderContext();
104 tcu::TestCase::IterateResult result;
105
106 // Clear to black
107 {
108 const glw::Functions& gl = renderCtx.getFunctions();
109 gl.clearColor(0.0f, 0.0f, 0.0f, 1.f);
110 gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
111 }
112
113 result = testCase->iterate();
114
115 // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
116 try
117 {
118 renderCtx.postIterate();
119 return result;
120 }
121 catch (const tcu::ResourceError&)
122 {
123 testCtx.getLog().endCase(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
124 testCtx.setTerminateAfter(true);
125 return tcu::TestNode::STOP;
126 }
127 catch (const std::exception&)
128 {
129 testCtx.getLog().endCase(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
130 return tcu::TestNode::STOP;
131 }
132 }
133
134 class ShaderTests : public deqp::TestCaseGroup
135 {
136 public:
ShaderTests(deqp::Context & context)137 ShaderTests(deqp::Context& context) : TestCaseGroup(context, "shaders", "Shading Language Tests")
138 {
139 }
140
init(void)141 void init(void)
142 {
143 addChild(new deqp::ShaderLibraryGroup(m_context, "declarations", "Declaration Tests", "declarations.test"));
144 addChild(new deqp::FragDepthTests(m_context, glu::GLSL_VERSION_300_ES));
145 addChild(new deqp::ShaderIndexingTests(m_context, glu::GLSL_VERSION_300_ES));
146 addChild(new deqp::ShaderLoopTests(m_context, glu::GLSL_VERSION_300_ES));
147 addChild(new deqp::ShaderLibraryGroup(m_context, "preprocessor", "Preprocessor Tests", "preprocessor.test"));
148 addChild(new deqp::ShaderLibraryGroup(m_context, "literal_parsing", "Literal Parsing Tests",
149 "literal_parsing.test"));
150 addChild(new deqp::ShaderLibraryGroup(m_context, "name_hiding", "Name Hiding Tests", "name_hiding.test"));
151 addChild(new deqp::ShaderStructTests(m_context, glu::GLSL_VERSION_300_ES));
152 addChild(new deqp::UniformBlockTests(m_context, glu::GLSL_VERSION_300_ES));
153 addChild(new deqp::GLSLVectorConstructorTests(m_context, glu::GLSL_VERSION_300_ES));
154 addChild(new deqp::ShaderIntegerMixTests(m_context, glu::GLSL_VERSION_300_ES));
155 addChild(new deqp::ShaderNegativeTests(m_context, glu::GLSL_VERSION_300_ES));
156 addChild(new glcts::AggressiveShaderOptimizationsTests(m_context));
157 }
158 };
159
ES30TestPackage(tcu::TestContext & testCtx,const char * packageName)160 ES30TestPackage::ES30TestPackage(tcu::TestContext& testCtx, const char* packageName)
161 : deqp::TestPackage(testCtx, packageName, "OpenGL ES 3 Conformance Tests", glu::ContextType(glu::ApiType::es(3, 0)),
162 "gl_cts/data/gles3/")
163 {
164 }
165
~ES30TestPackage(void)166 ES30TestPackage::~ES30TestPackage(void)
167 {
168 }
169
init(void)170 void ES30TestPackage::init(void)
171 {
172 // Call init() in parent - this creates context.
173 deqp::TestPackage::init();
174
175 try
176 {
177 addChild(new ShaderTests(getContext()));
178 addChild(new glcts::TextureFilterAnisotropicTests(getContext()));
179 addChild(new glcts::TextureRepeatModeTests(getContext()));
180 addChild(new glcts::ExposedExtensionsTests(getContext()));
181 tcu::TestCaseGroup* coreGroup = new tcu::TestCaseGroup(getTestContext(), "core", "core tests");
182 coreGroup->addChild(new glcts::ShaderConstExprTests(getContext()));
183 coreGroup->addChild(new glcts::ShaderMacroTests(getContext()));
184 coreGroup->addChild(new glcts::InternalformatTests(getContext()));
185 coreGroup->addChild(new glcts::NearestEdgeCases(getContext()));
186 addChild(coreGroup);
187 addChild(new glcts::ParallelShaderCompileTests(getContext()));
188 addChild(new glcts::PackedPixelsTests(getContext()));
189 addChild(new glcts::PackedDepthStencilTests(getContext()));
190 addChild(new glcts::FramebufferCompletenessTests(getContext()));
191 addChild(new es3cts::CopyTexImageConversionsTests(getContext()));
192 addChild(new es3cts::NumberParsingTests(getContext()));
193 }
194 catch (...)
195 {
196 // Destroy context.
197 deqp::TestPackage::deinit();
198 throw;
199 }
200 }
201
createExecutor(void) const202 tcu::TestCaseExecutor* ES30TestPackage::createExecutor(void) const
203 {
204 return new TestCaseWrapper(const_cast<ES30TestPackage&>(*this), m_waiverMechanism);
205 }
206
207 } // es3cts
208