xref: /aosp_15_r20/external/deqp/external/openglcts/modules/common/glcSingleConfigTestPackage.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2016 Google Inc.
6  * Copyright (c) 2016-2019 The Khronos Group Inc.
7  * Copyright (c) 2019 NVIDIA Corporation.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */ /*!
22  * \file
23  * \brief OpenGL/OpenGL ES Test Package that only gets run in a single config
24  */ /*-------------------------------------------------------------------*/
25 
26 #include "glcSingleConfigTestPackage.hpp"
27 #include "gluStateReset.hpp"
28 #include "glwEnums.hpp"
29 #include "glwFunctions.hpp"
30 #include "tcuTestLog.hpp"
31 #include "tcuWaiverUtil.hpp"
32 
33 #include "glcSubgroupsTests.hpp"
34 #include "gl4cEnhancedLayoutsTests.hpp"
35 #include "../gles31/es31cArrayOfArraysTests.hpp"
36 
37 namespace glcts
38 {
39 
40 class TestCaseWrapper : public tcu::TestCaseExecutor
41 {
42 public:
43     TestCaseWrapper(deqp::TestPackage &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
44     ~TestCaseWrapper(void);
45 
46     void init(tcu::TestCase *testCase, const std::string &path);
47     void deinit(tcu::TestCase *testCase);
48     tcu::TestNode::IterateResult iterate(tcu::TestCase *testCase);
49 
50 private:
51     deqp::TestPackage &m_testPackage;
52     de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
53 };
54 
TestCaseWrapper(deqp::TestPackage & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)55 TestCaseWrapper::TestCaseWrapper(deqp::TestPackage &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
56     : m_testPackage(package)
57     , m_waiverMechanism(waiverMechanism)
58 {
59 }
60 
~TestCaseWrapper(void)61 TestCaseWrapper::~TestCaseWrapper(void)
62 {
63 }
64 
init(tcu::TestCase * testCase,const std::string & path)65 void TestCaseWrapper::init(tcu::TestCase *testCase, const std::string &path)
66 {
67     if (m_waiverMechanism->isOnWaiverList(path))
68         throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
69 
70     testCase->init();
71 }
72 
deinit(tcu::TestCase * testCase)73 void TestCaseWrapper::deinit(tcu::TestCase *testCase)
74 {
75     testCase->deinit();
76 
77     glu::resetState(m_testPackage.getContext().getRenderContext(), m_testPackage.getContext().getContextInfo());
78 }
79 
iterate(tcu::TestCase * testCase)80 tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase *testCase)
81 {
82     tcu::TestContext &testCtx     = m_testPackage.getContext().getTestContext();
83     glu::RenderContext &renderCtx = m_testPackage.getContext().getRenderContext();
84     tcu::TestCase::IterateResult result;
85 
86     // Clear to surrender-blue
87     {
88         const glw::Functions &gl = renderCtx.getFunctions();
89         gl.clearColor(0.0f, 0.0f, 0.0f, 1.f);
90         gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
91     }
92 
93     result = testCase->iterate();
94 
95     // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
96     try
97     {
98         renderCtx.postIterate();
99         return result;
100     }
101     catch (const tcu::ResourceError &)
102     {
103         testCtx.getLog().endCase(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
104         testCtx.setTerminateAfter(true);
105         return tcu::TestNode::STOP;
106     }
107     catch (const std::exception &)
108     {
109         testCtx.getLog().endCase(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
110         return tcu::TestNode::STOP;
111     }
112 }
113 
SingleConfigGL43TestPackage(tcu::TestContext & testCtx,const char * packageName,const char * description,glu::ContextType renderContextType)114 SingleConfigGL43TestPackage::SingleConfigGL43TestPackage(tcu::TestContext &testCtx, const char *packageName,
115                                                          const char *description, glu::ContextType renderContextType)
116     : deqp::TestPackage(testCtx, packageName, description, renderContextType, "gl_cts/data/")
117 {
118 }
119 
~SingleConfigGL43TestPackage(void)120 SingleConfigGL43TestPackage::~SingleConfigGL43TestPackage(void)
121 {
122 }
123 
init(void)124 void SingleConfigGL43TestPackage::init(void)
125 {
126     // Call init() in parent - this creates context.
127     deqp::TestPackage::init();
128 
129     try
130     {
131         // Add main test groups
132         addChild(new glcts::ArrayOfArraysTestGroupGL(getContext()));
133     }
134     catch (...)
135     {
136         // Destroy context.
137         deqp::TestPackage::deinit();
138         throw;
139     }
140 }
141 
createExecutor(void) const142 tcu::TestCaseExecutor *SingleConfigGL43TestPackage::createExecutor(void) const
143 {
144     return new TestCaseWrapper(const_cast<SingleConfigGL43TestPackage &>(*this), m_waiverMechanism);
145 }
146 
SingleConfigGL44TestPackage(tcu::TestContext & testCtx,const char * packageName,const char * description,glu::ContextType renderContextType)147 SingleConfigGL44TestPackage::SingleConfigGL44TestPackage(tcu::TestContext &testCtx, const char *packageName,
148                                                          const char *description, glu::ContextType renderContextType)
149     : SingleConfigGL43TestPackage(testCtx, packageName, description, renderContextType)
150 {
151 }
152 
~SingleConfigGL44TestPackage(void)153 SingleConfigGL44TestPackage::~SingleConfigGL44TestPackage(void)
154 {
155 }
156 
init(void)157 void SingleConfigGL44TestPackage::init(void)
158 {
159     // Call init() in parent - this creates context.
160     SingleConfigGL43TestPackage::init();
161 
162     try
163     {
164         // Add main test groups
165         addChild(new gl4cts::EnhancedLayoutsTests(getContext()));
166     }
167     catch (...)
168     {
169         // Destroy context.
170         deqp::TestPackage::deinit();
171         throw;
172     }
173 }
174 
SingleConfigGL45TestPackage(tcu::TestContext & testCtx,const char * packageName,const char * description,glu::ContextType renderContextType)175 SingleConfigGL45TestPackage::SingleConfigGL45TestPackage(tcu::TestContext &testCtx, const char *packageName,
176                                                          const char *description, glu::ContextType renderContextType)
177     : SingleConfigGL44TestPackage(testCtx, packageName, description, renderContextType)
178 {
179 }
180 
~SingleConfigGL45TestPackage(void)181 SingleConfigGL45TestPackage::~SingleConfigGL45TestPackage(void)
182 {
183 }
184 
init(void)185 void SingleConfigGL45TestPackage::init(void)
186 {
187     // Call init() in parent - this creates context.
188     SingleConfigGL44TestPackage::init();
189 
190     try
191     {
192         // Add main test groups
193         addChild(new glc::subgroups::GlSubgroupTests(getContext()));
194     }
195     catch (...)
196     {
197         // Destroy context.
198         deqp::TestPackage::deinit();
199         throw;
200     }
201 }
202 
SingleConfigGL46TestPackage(tcu::TestContext & testCtx,const char * packageName,const char * description,glu::ContextType renderContextType)203 SingleConfigGL46TestPackage::SingleConfigGL46TestPackage(tcu::TestContext &testCtx, const char *packageName,
204                                                          const char *description, glu::ContextType renderContextType)
205     : SingleConfigGL45TestPackage(testCtx, packageName, description, renderContextType)
206 {
207 }
208 
~SingleConfigGL46TestPackage(void)209 SingleConfigGL46TestPackage::~SingleConfigGL46TestPackage(void)
210 {
211 }
212 
init(void)213 void SingleConfigGL46TestPackage::init(void)
214 {
215     // Call init() in parent - this creates context.
216     SingleConfigGL45TestPackage::init();
217 
218     try
219     {
220         // Add main test groups
221     }
222     catch (...)
223     {
224         // Destroy context.
225         deqp::TestPackage::deinit();
226         throw;
227     }
228 }
229 
SingleConfigES32TestPackage(tcu::TestContext & testCtx,const char * packageName,const char * description,glu::ContextType renderContextType)230 SingleConfigES32TestPackage::SingleConfigES32TestPackage(tcu::TestContext &testCtx, const char *packageName,
231                                                          const char *description, glu::ContextType renderContextType)
232     : deqp::TestPackage(testCtx, packageName, description, renderContextType, "gl_cts/data/")
233 {
234 }
235 
~SingleConfigES32TestPackage(void)236 SingleConfigES32TestPackage::~SingleConfigES32TestPackage(void)
237 {
238 }
239 
init(void)240 void SingleConfigES32TestPackage::init(void)
241 {
242     // Call init() in parent - this creates context.
243     deqp::TestPackage::init();
244 
245     try
246     {
247         // Add main test groups
248         addChild(new glc::subgroups::GlSubgroupTests(getContext()));
249     }
250     catch (...)
251     {
252         // Destroy context.
253         deqp::TestPackage::deinit();
254         throw;
255     }
256 }
257 
createExecutor(void) const258 tcu::TestCaseExecutor *SingleConfigES32TestPackage::createExecutor(void) const
259 {
260     return new TestCaseWrapper(const_cast<SingleConfigES32TestPackage &>(*this), m_waiverMechanism);
261 }
262 
263 } // namespace glcts
264