xref: /aosp_15_r20/external/deqp/external/openglcts/modules/gl/gl3cTestPackages.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 3.x Test Packages.
23  */ /*-------------------------------------------------------------------*/
24 
25 #include "gl3cTestPackages.hpp"
26 #include "gl3cClipDistance.hpp"
27 #include "gl3cCommonBugsTests.hpp"
28 #include "gl3cCullDistanceTests.hpp"
29 #include "gl3cGLSLnoperspectiveTests.hpp"
30 #include "gl3cGPUShader5Tests.hpp"
31 #include "gl3cTextureSizePromotion.hpp"
32 #include "gl3cTextureSwizzleTests.hpp"
33 #include "gl3cTransformFeedbackOverflowQueryTests.hpp"
34 #include "gl3cTransformFeedbackTests.hpp"
35 #include "gl4cPipelineStatisticsQueryTests.hpp"
36 #include "glcPixelStorageModesTests.hpp"
37 #include "glcFragDepthTests.hpp"
38 #include "glcInfoTests.hpp"
39 #include "glcPackedDepthStencilTests.hpp"
40 #include "glcPackedPixelsTests.hpp"
41 #include "glcShaderFunctionTests.hpp"
42 #include "glcShaderIndexingTests.hpp"
43 #include "glcShaderIntegerMixTests.hpp"
44 #include "glcShaderLibrary.hpp"
45 #include "glcShaderLoopTests.hpp"
46 #include "glcShaderNegativeTests.hpp"
47 #include "glcShaderStructTests.hpp"
48 #include "glcTextureRepeatModeTests.hpp"
49 #include "glcUniformBlockTests.hpp"
50 #include "glcNearestEdgeTests.hpp"
51 #include "glcGLSLVectorConstructorTests.hpp"
52 #include "gluStateReset.hpp"
53 #include "qpTestLog.h"
54 #include "tcuTestLog.hpp"
55 #include "tcuCommandLine.hpp"
56 #include "tcuWaiverUtil.hpp"
57 
58 #include "../glesext/texture_shadow_lod/esextcTextureShadowLodFunctionsTest.hpp"
59 
60 namespace gl3cts
61 {
62 
TestCaseWrapper(deqp::TestPackage & package,de::SharedPtr<tcu::WaiverUtil> waiverMechanism)63 TestCaseWrapper::TestCaseWrapper(deqp::TestPackage &package, de::SharedPtr<tcu::WaiverUtil> waiverMechanism)
64     : m_testPackage(package)
65     , m_waiverMechanism(waiverMechanism)
66 {
67 }
68 
~TestCaseWrapper(void)69 TestCaseWrapper::~TestCaseWrapper(void)
70 {
71 }
72 
init(tcu::TestCase * testCase,const std::string & path)73 void TestCaseWrapper::init(tcu::TestCase *testCase, const std::string &path)
74 {
75     if (m_waiverMechanism->isOnWaiverList(path))
76         throw tcu::TestException("Waived test", QP_TEST_RESULT_WAIVER);
77 
78     testCase->init();
79 }
80 
deinit(tcu::TestCase * testCase)81 void TestCaseWrapper::deinit(tcu::TestCase *testCase)
82 {
83     testCase->deinit();
84 
85     deqp::Context &context = m_testPackage.getContext();
86     glu::resetState(context.getRenderContext(), context.getContextInfo());
87 }
88 
iterate(tcu::TestCase * testCase)89 tcu::TestNode::IterateResult TestCaseWrapper::iterate(tcu::TestCase *testCase)
90 {
91     tcu::TestContext &testCtx     = m_testPackage.getTestContext();
92     glu::RenderContext &renderCtx = m_testPackage.getContext().getRenderContext();
93 
94     // Clear to black
95     {
96         const glw::Functions &gl = renderCtx.getFunctions();
97         gl.clearColor(0.0, 0.0f, 0.0f, 1.0f);
98         gl.clear(GL_COLOR_BUFFER_BIT);
99     }
100 
101     const tcu::TestCase::IterateResult result = testCase->iterate();
102 
103     {
104         if (testCtx.getCommandLine().isTerminateOnDeviceLostEnabled())
105         {
106             const glw::Functions &gl = renderCtx.getFunctions();
107             auto res                 = gl.getGraphicsResetStatus();
108             if (res != GL_NO_ERROR)
109             {
110                 testCtx.setTestResult(QP_TEST_RESULT_DEVICE_LOST, "Device Lost");
111             }
112         }
113     }
114 
115     // Call implementation specific post-iterate routine (usually handles native events and swaps buffers)
116     try
117     {
118         deqp::Context &context = m_testPackage.getContext();
119         context.getRenderContext().postIterate();
120         return result;
121     }
122     catch (const tcu::ResourceError &)
123     {
124         throw tcu::ResourceError(std::string("Resource error in context post-iteration routine"));
125         testCtx.setTerminateAfter(true);
126         return tcu::TestNode::STOP;
127     }
128     catch (const std::exception &)
129     {
130         testCtx.getLog().endCase(QP_TEST_RESULT_FAIL, "Error in context post-iteration routine");
131         return tcu::TestNode::STOP;
132     }
133 }
134 
135 // GL30TestPackage
136 
137 class GL30ShaderTests : public glcts::TestCaseGroup
138 {
139 public:
GL30ShaderTests(deqp::Context & context)140     GL30ShaderTests(deqp::Context &context) : TestCaseGroup(context, "shaders30", "Shading Language Tests")
141     {
142     }
143 
init(void)144     void init(void)
145     {
146         addChild(
147             new deqp::ShaderLibraryGroup(m_context, "declarations", "Declaration Tests", "gl30/declarations.test"));
148         addChild(new deqp::GLSLVectorConstructorTests(m_context, glu::GLSL_VERSION_130));
149     }
150 };
151 
GL30TestPackage(tcu::TestContext & testCtx,const char * packageName,const char * description,glu::ContextType renderContextType)152 GL30TestPackage::GL30TestPackage(tcu::TestContext &testCtx, const char *packageName, const char *description,
153                                  glu::ContextType renderContextType)
154     : TestPackage(testCtx, packageName, packageName, renderContextType, "gl_cts/data/")
155 {
156     (void)description;
157 }
158 
~GL30TestPackage(void)159 GL30TestPackage::~GL30TestPackage(void)
160 {
161 }
162 
init(void)163 void GL30TestPackage::init(void)
164 {
165     // Call init() in parent - this creates context.
166     TestPackage::init();
167 
168     try
169     {
170         addChild(new deqp::InfoTests(getContext()));
171         addChild(new gl3cts::ClipDistance::Tests(getContext()));
172         addChild(new gl3cts::GLSLnoperspectiveTests(getContext()));
173         addChild(new gl3cts::TransformFeedback::Tests(getContext()));
174         addChild(new glcts::TextureRepeatModeTests(getContext()));
175         addChild(new GL30ShaderTests(getContext()));
176         addChild(new deqp::Functional::TextureShadowLodTest(getContext()));
177     }
178     catch (...)
179     {
180         // Destroy context.
181         TestPackage::deinit();
182         throw;
183     }
184 }
185 
createExecutor(void) const186 tcu::TestCaseExecutor *GL30TestPackage::createExecutor(void) const
187 {
188     return new TestCaseWrapper(const_cast<GL30TestPackage &>(*this), m_waiverMechanism);
189 }
190 
191 // GL31TestPackage
192 
GL31TestPackage(tcu::TestContext & testCtx,const char * packageName,const char * description,glu::ContextType renderContextType)193 GL31TestPackage::GL31TestPackage(tcu::TestContext &testCtx, const char *packageName, const char *description,
194                                  glu::ContextType renderContextType)
195     : GL30TestPackage(testCtx, packageName, packageName, renderContextType)
196 {
197     (void)description;
198 }
199 
~GL31TestPackage(void)200 GL31TestPackage::~GL31TestPackage(void)
201 {
202 }
203 
init(void)204 void GL31TestPackage::init(void)
205 {
206     // Call init() in parent - this creates context.
207     GL30TestPackage::init();
208 
209     try
210     {
211         addChild(new gl3cts::CommonBugsTests(getContext()));
212         addChild(new gl3cts::TextureSizePromotion::Tests(getContext()));
213     }
214     catch (...)
215     {
216         // Destroy context.
217         TestPackage::deinit();
218         throw;
219     }
220 }
221 
222 // GL32TestPackage
223 
GL32TestPackage(tcu::TestContext & testCtx,const char * packageName,const char * description,glu::ContextType renderContextType)224 GL32TestPackage::GL32TestPackage(tcu::TestContext &testCtx, const char *packageName, const char *description,
225                                  glu::ContextType renderContextType)
226     : GL31TestPackage(testCtx, packageName, packageName, renderContextType)
227 {
228     (void)description;
229 }
230 
~GL32TestPackage(void)231 GL32TestPackage::~GL32TestPackage(void)
232 {
233 }
234 
init(void)235 void GL32TestPackage::init(void)
236 {
237     // Call init() in parent - this creates context.
238     GL31TestPackage::init();
239 
240     try
241     {
242         addChild(new gl3cts::GPUShader5Tests(getContext()));
243         addChild(new gl3cts::TransformFeedbackOverflowQueryTests(
244             getContext(), gl3cts::TransformFeedbackOverflowQueryTests::API_GL_ARB_transform_feedback_overflow_query));
245         addChild(new glcts::PackedPixelsTests(getContext()));
246         addChild(new glcts::PackedDepthStencilTests(getContext()));
247     }
248     catch (...)
249     {
250         // Destroy context.
251         TestPackage::deinit();
252         throw;
253     }
254 }
255 
256 // OpenGL 3.3 test groups
257 
258 class GL33ShaderTests : public glcts::TestCaseGroup
259 {
260 public:
GL33ShaderTests(deqp::Context & context)261     GL33ShaderTests(deqp::Context &context) : TestCaseGroup(context, "shaders", "Shading Language Tests")
262     {
263     }
264 
init(void)265     void init(void)
266     {
267         addChild(new deqp::ShaderLibraryGroup(m_context, "arrays", "Array Tests", "gl33/arrays.test"));
268         addChild(
269             new deqp::ShaderLibraryGroup(m_context, "declarations", "Declaration Tests", "gl33/declarations.test"));
270         addChild(new deqp::FragDepthTests(m_context, glu::GLSL_VERSION_330));
271         addChild(new deqp::ShaderIndexingTests(m_context, glu::GLSL_VERSION_330));
272         addChild(new deqp::ShaderLoopTests(m_context, glu::GLSL_VERSION_330));
273         addChild(
274             new deqp::ShaderLibraryGroup(m_context, "preprocessor", "Preprocessor Tests", "gl33/preprocessor.test"));
275         addChild(new deqp::ShaderFunctionTests(m_context, glu::GLSL_VERSION_330));
276         addChild(new deqp::ShaderStructTests(m_context, glu::GLSL_VERSION_330));
277         addChild(new deqp::UniformBlockTests(m_context, glu::GLSL_VERSION_330));
278         addChild(new deqp::ShaderIntegerMixTests(m_context, glu::GLSL_VERSION_330));
279         addChild(new deqp::ShaderNegativeTests(m_context, glu::GLSL_VERSION_330));
280     }
281 };
282 
283 // GL33TestPackage
284 
GL33TestPackage(tcu::TestContext & testCtx,const char * packageName,const char * description,glu::ContextType renderContextType)285 GL33TestPackage::GL33TestPackage(tcu::TestContext &testCtx, const char *packageName, const char *description,
286                                  glu::ContextType renderContextType)
287     : GL32TestPackage(testCtx, packageName, packageName, renderContextType)
288 {
289     (void)description;
290 }
291 
~GL33TestPackage(void)292 GL33TestPackage::~GL33TestPackage(void)
293 {
294 }
295 
init(void)296 void GL33TestPackage::init(void)
297 {
298     // Call init() in parent - this creates context.
299     GL32TestPackage::init();
300 
301     try
302     {
303         addChild(new GL33ShaderTests(getContext()));
304         addChild(new glcts::PipelineStatisticsQueryTests(getContext()));
305         addChild(new glcts::CullDistance::Tests(getContext()));
306         addChild(new gl3cts::TextureSwizzleTests(getContext()));
307         addChild(new glcts::NearestEdgeCases(getContext()));
308         addChild(new glcts::PixelStorageModesTests(getContext(), glu::GLSL_VERSION_330));
309     }
310     catch (...)
311     {
312         // Destroy context.
313         TestPackage::deinit();
314         throw;
315     }
316 }
317 
318 } // namespace gl3cts
319