xref: /aosp_15_r20/external/deqp/modules/gles3/tes3TestPackage.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.0 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief OpenGL ES 3.0 Test Package
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "tes3TestPackage.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "tes3InfoTests.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "es3fFunctionalTests.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "es3aAccuracyTests.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "es3sStressTests.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "es3pPerformanceTests.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "tcuWaiverUtil.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "tcuCommandLine.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "gluStateReset.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
37*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
38*35238bceSAndroid Build Coastguard Worker 
39*35238bceSAndroid Build Coastguard Worker namespace deqp
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker namespace gles3
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker 
44*35238bceSAndroid Build Coastguard Worker class TestCaseWrapper : public tcu::TestCaseExecutor
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker public:
47*35238bceSAndroid Build Coastguard Worker     TestCaseWrapper(TestPackage &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism);
48*35238bceSAndroid Build Coastguard Worker     ~TestCaseWrapper(void);
49*35238bceSAndroid Build Coastguard Worker 
50*35238bceSAndroid Build Coastguard Worker     void init(tcu::TestCase *testCase, const std::string &path);
51*35238bceSAndroid Build Coastguard Worker     void deinit(tcu::TestCase *testCase);
52*35238bceSAndroid Build Coastguard Worker     tcu::TestNode::IterateResult iterate(tcu::TestCase *testCase);
53*35238bceSAndroid Build Coastguard Worker 
54*35238bceSAndroid Build Coastguard Worker private:
55*35238bceSAndroid Build Coastguard Worker     TestPackage &m_testPackage;
56*35238bceSAndroid Build Coastguard Worker     de::SharedPtr<tcu::WaiverUtil> m_waiverMechanism;
57*35238bceSAndroid Build Coastguard Worker };
58*35238bceSAndroid Build Coastguard Worker 
TestCaseWrapper(TestPackage & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)59*35238bceSAndroid Build Coastguard Worker TestCaseWrapper::TestCaseWrapper(TestPackage &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
60*35238bceSAndroid Build Coastguard Worker     : m_testPackage(package)
61*35238bceSAndroid Build Coastguard Worker     , m_waiverMechanism(waiverMechanism)
62*35238bceSAndroid Build Coastguard Worker {
63*35238bceSAndroid Build Coastguard Worker }
64*35238bceSAndroid Build Coastguard Worker 
~TestCaseWrapper(void)65*35238bceSAndroid Build Coastguard Worker TestCaseWrapper::~TestCaseWrapper(void)
66*35238bceSAndroid Build Coastguard Worker {
67*35238bceSAndroid Build Coastguard Worker }
68*35238bceSAndroid Build Coastguard Worker 
init(tcu::TestCase * testCase,const std::string & path)69*35238bceSAndroid Build Coastguard Worker void TestCaseWrapper::init(tcu::TestCase *testCase, const std::string &path)
70*35238bceSAndroid Build Coastguard Worker {
71*35238bceSAndroid Build Coastguard Worker     if (m_waiverMechanism->isOnWaiverList(path))
72*35238bceSAndroid Build Coastguard Worker         throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
73*35238bceSAndroid Build Coastguard Worker 
74*35238bceSAndroid Build Coastguard Worker     testCase->init();
75*35238bceSAndroid Build Coastguard Worker }
76*35238bceSAndroid Build Coastguard Worker 
deinit(tcu::TestCase * testCase)77*35238bceSAndroid Build Coastguard Worker void TestCaseWrapper::deinit(tcu::TestCase *testCase)
78*35238bceSAndroid Build Coastguard Worker {
79*35238bceSAndroid Build Coastguard Worker     testCase->deinit();
80*35238bceSAndroid Build Coastguard Worker 
81*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(m_testPackage.getContext());
82*35238bceSAndroid Build Coastguard Worker     glu::resetState(m_testPackage.getContext()->getRenderContext(), m_testPackage.getContext()->getContextInfo());
83*35238bceSAndroid Build Coastguard Worker }
84*35238bceSAndroid Build Coastguard Worker 
iterate(tcu::TestCase * testCase)85*35238bceSAndroid Build Coastguard Worker tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase *testCase)
86*35238bceSAndroid Build Coastguard Worker {
87*35238bceSAndroid Build Coastguard Worker     tcu::TestContext &testCtx     = m_testPackage.getContext()->getTestContext();
88*35238bceSAndroid Build Coastguard Worker     glu::RenderContext &renderCtx = m_testPackage.getContext()->getRenderContext();
89*35238bceSAndroid Build Coastguard Worker     tcu::TestCase::IterateResult result;
90*35238bceSAndroid Build Coastguard Worker 
91*35238bceSAndroid Build Coastguard Worker     // Clear to surrender-blue
92*35238bceSAndroid Build Coastguard Worker     {
93*35238bceSAndroid Build Coastguard Worker         const glw::Functions &gl = renderCtx.getFunctions();
94*35238bceSAndroid Build Coastguard Worker         gl.clearColor(0.125f, 0.25f, 0.5f, 1.f);
95*35238bceSAndroid Build Coastguard Worker         gl.clear(GL_COLOR_BUFFER_BIT);
96*35238bceSAndroid Build Coastguard Worker     }
97*35238bceSAndroid Build Coastguard Worker 
98*35238bceSAndroid Build Coastguard Worker     result = testCase->iterate();
99*35238bceSAndroid Build Coastguard Worker 
100*35238bceSAndroid Build Coastguard Worker     // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
101*35238bceSAndroid Build Coastguard Worker     try
102*35238bceSAndroid Build Coastguard Worker     {
103*35238bceSAndroid Build Coastguard Worker         renderCtx.postIterate();
104*35238bceSAndroid Build Coastguard Worker         return result;
105*35238bceSAndroid Build Coastguard Worker     }
106*35238bceSAndroid Build Coastguard Worker     catch (const tcu::ResourceError &e)
107*35238bceSAndroid Build Coastguard Worker     {
108*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << e;
109*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_RESOURCE_ERROR, "Resource error in context post-iteration routine");
110*35238bceSAndroid Build Coastguard Worker         testCtx.setTerminateAfter(true);
111*35238bceSAndroid Build Coastguard Worker         return tcu::TestNode::STOP;
112*35238bceSAndroid Build Coastguard Worker     }
113*35238bceSAndroid Build Coastguard Worker     catch (const std::exception &e)
114*35238bceSAndroid Build Coastguard Worker     {
115*35238bceSAndroid Build Coastguard Worker         testCtx.getLog() << e;
116*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
117*35238bceSAndroid Build Coastguard Worker         return tcu::TestNode::STOP;
118*35238bceSAndroid Build Coastguard Worker     }
119*35238bceSAndroid Build Coastguard Worker }
120*35238bceSAndroid Build Coastguard Worker 
TestPackage(tcu::TestContext & testCtx)121*35238bceSAndroid Build Coastguard Worker TestPackage::TestPackage(tcu::TestContext &testCtx)
122*35238bceSAndroid Build Coastguard Worker     : tcu::TestPackage(testCtx, "dEQP-GLES3", "dEQP OpenGL ES 3.0 Tests")
123*35238bceSAndroid Build Coastguard Worker     , m_archive(testCtx.getRootArchive(), "gles3/")
124*35238bceSAndroid Build Coastguard Worker     , m_context(DE_NULL)
125*35238bceSAndroid Build Coastguard Worker     , m_waiverMechanism(new tcu::WaiverUtil)
126*35238bceSAndroid Build Coastguard Worker {
127*35238bceSAndroid Build Coastguard Worker }
128*35238bceSAndroid Build Coastguard Worker 
~TestPackage(void)129*35238bceSAndroid Build Coastguard Worker TestPackage::~TestPackage(void)
130*35238bceSAndroid Build Coastguard Worker {
131*35238bceSAndroid Build Coastguard Worker     // Destroy children first since destructors may access context.
132*35238bceSAndroid Build Coastguard Worker     TestNode::deinit();
133*35238bceSAndroid Build Coastguard Worker     delete m_context;
134*35238bceSAndroid Build Coastguard Worker }
135*35238bceSAndroid Build Coastguard Worker 
init(void)136*35238bceSAndroid Build Coastguard Worker void TestPackage::init(void)
137*35238bceSAndroid Build Coastguard Worker {
138*35238bceSAndroid Build Coastguard Worker     try
139*35238bceSAndroid Build Coastguard Worker     {
140*35238bceSAndroid Build Coastguard Worker         // Create context
141*35238bceSAndroid Build Coastguard Worker         m_context = new Context(m_testCtx);
142*35238bceSAndroid Build Coastguard Worker 
143*35238bceSAndroid Build Coastguard Worker         // Setup waiver mechanism
144*35238bceSAndroid Build Coastguard Worker         if (m_testCtx.getCommandLine().getRunMode() == tcu::RUNMODE_EXECUTE)
145*35238bceSAndroid Build Coastguard Worker         {
146*35238bceSAndroid Build Coastguard Worker             const glu::ContextInfo &contextInfo = m_context->getContextInfo();
147*35238bceSAndroid Build Coastguard Worker             std::string vendor                  = contextInfo.getString(GL_VENDOR);
148*35238bceSAndroid Build Coastguard Worker             std::string renderer                = contextInfo.getString(GL_RENDERER);
149*35238bceSAndroid Build Coastguard Worker             const tcu::CommandLine &commandLine = m_context->getTestContext().getCommandLine();
150*35238bceSAndroid Build Coastguard Worker             tcu::SessionInfo sessionInfo(vendor, renderer, commandLine.getInitialCmdLine());
151*35238bceSAndroid Build Coastguard Worker             m_waiverMechanism->setup(commandLine.getWaiverFileName(), m_name, vendor, renderer, sessionInfo);
152*35238bceSAndroid Build Coastguard Worker             m_context->getTestContext().getLog().writeSessionInfo(sessionInfo.get());
153*35238bceSAndroid Build Coastguard Worker         }
154*35238bceSAndroid Build Coastguard Worker 
155*35238bceSAndroid Build Coastguard Worker         // Add main test groups
156*35238bceSAndroid Build Coastguard Worker         addChild(new InfoTests(*m_context));
157*35238bceSAndroid Build Coastguard Worker         addChild(new Functional::FunctionalTests(*m_context));
158*35238bceSAndroid Build Coastguard Worker         addChild(new Accuracy::AccuracyTests(*m_context));
159*35238bceSAndroid Build Coastguard Worker         addChild(new Performance::PerformanceTests(*m_context));
160*35238bceSAndroid Build Coastguard Worker         addChild(new Stress::StressTests(*m_context));
161*35238bceSAndroid Build Coastguard Worker     }
162*35238bceSAndroid Build Coastguard Worker     catch (...)
163*35238bceSAndroid Build Coastguard Worker     {
164*35238bceSAndroid Build Coastguard Worker         delete m_context;
165*35238bceSAndroid Build Coastguard Worker         m_context = DE_NULL;
166*35238bceSAndroid Build Coastguard Worker 
167*35238bceSAndroid Build Coastguard Worker         throw;
168*35238bceSAndroid Build Coastguard Worker     }
169*35238bceSAndroid Build Coastguard Worker }
170*35238bceSAndroid Build Coastguard Worker 
deinit(void)171*35238bceSAndroid Build Coastguard Worker void TestPackage::deinit(void)
172*35238bceSAndroid Build Coastguard Worker {
173*35238bceSAndroid Build Coastguard Worker     TestNode::deinit();
174*35238bceSAndroid Build Coastguard Worker     delete m_context;
175*35238bceSAndroid Build Coastguard Worker     m_context = DE_NULL;
176*35238bceSAndroid Build Coastguard Worker }
177*35238bceSAndroid Build Coastguard Worker 
createExecutor(void) const178*35238bceSAndroid Build Coastguard Worker tcu::TestCaseExecutor *TestPackage::createExecutor(void) const
179*35238bceSAndroid Build Coastguard Worker {
180*35238bceSAndroid Build Coastguard Worker     return new TestCaseWrapper(const_cast<TestPackage &>(*this), m_waiverMechanism);
181*35238bceSAndroid Build Coastguard Worker }
182*35238bceSAndroid Build Coastguard Worker 
183*35238bceSAndroid Build Coastguard Worker } // namespace gles3
184*35238bceSAndroid Build Coastguard Worker } // namespace deqp
185