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