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