xref: /aosp_15_r20/external/deqp/modules/gles31/functional/es31fAndroidExtensionPackES31ATests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.1 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 ANDROID_extension_pack_es31a tests
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es31fAndroidExtensionPackES31ATests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "glsStateQueryUtil.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "glsShaderLibrary.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "tcuTestLog.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "gluCallLogWrapper.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
31*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "deStringUtil.hpp"
34*35238bceSAndroid Build Coastguard Worker 
35*35238bceSAndroid Build Coastguard Worker namespace deqp
36*35238bceSAndroid Build Coastguard Worker {
37*35238bceSAndroid Build Coastguard Worker namespace gles31
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker namespace Functional
40*35238bceSAndroid Build Coastguard Worker {
41*35238bceSAndroid Build Coastguard Worker namespace
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker 
genExtensionTestName(const char * extensionName)44*35238bceSAndroid Build Coastguard Worker static std::string genExtensionTestName(const char *extensionName)
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker     DE_ASSERT(deStringBeginsWith(extensionName, "GL_"));
47*35238bceSAndroid Build Coastguard Worker     return de::toLower(std::string(extensionName + 3));
48*35238bceSAndroid Build Coastguard Worker }
49*35238bceSAndroid Build Coastguard Worker 
50*35238bceSAndroid Build Coastguard Worker class ExtensionPackTestCase : public TestCase
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker public:
53*35238bceSAndroid Build Coastguard Worker     ExtensionPackTestCase(Context &context, const char *name, const char *description);
54*35238bceSAndroid Build Coastguard Worker 
55*35238bceSAndroid Build Coastguard Worker protected:
56*35238bceSAndroid Build Coastguard Worker     void init(void);
57*35238bceSAndroid Build Coastguard Worker };
58*35238bceSAndroid Build Coastguard Worker 
ExtensionPackTestCase(Context & context,const char * name,const char * description)59*35238bceSAndroid Build Coastguard Worker ExtensionPackTestCase::ExtensionPackTestCase(Context &context, const char *name, const char *description)
60*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, description)
61*35238bceSAndroid Build Coastguard Worker {
62*35238bceSAndroid Build Coastguard Worker }
63*35238bceSAndroid Build Coastguard Worker 
init(void)64*35238bceSAndroid Build Coastguard Worker void ExtensionPackTestCase::init(void)
65*35238bceSAndroid Build Coastguard Worker {
66*35238bceSAndroid Build Coastguard Worker     if (!m_context.getContextInfo().isExtensionSupported("GL_ANDROID_extension_pack_es31a"))
67*35238bceSAndroid Build Coastguard Worker         throw tcu::NotSupportedError("Test requires GL_ANDROID_extension_pack_es31a extension");
68*35238bceSAndroid Build Coastguard Worker }
69*35238bceSAndroid Build Coastguard Worker 
70*35238bceSAndroid Build Coastguard Worker class ImplementationLimitCase : public ExtensionPackTestCase
71*35238bceSAndroid Build Coastguard Worker {
72*35238bceSAndroid Build Coastguard Worker public:
73*35238bceSAndroid Build Coastguard Worker     ImplementationLimitCase(Context &context, const char *name, const char *description, glw::GLenum target, int limit);
74*35238bceSAndroid Build Coastguard Worker 
75*35238bceSAndroid Build Coastguard Worker private:
76*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
77*35238bceSAndroid Build Coastguard Worker 
78*35238bceSAndroid Build Coastguard Worker     const glw::GLenum m_target;
79*35238bceSAndroid Build Coastguard Worker     const int m_limit;
80*35238bceSAndroid Build Coastguard Worker };
81*35238bceSAndroid Build Coastguard Worker 
ImplementationLimitCase(Context & context,const char * name,const char * description,glw::GLenum target,int limit)82*35238bceSAndroid Build Coastguard Worker ImplementationLimitCase::ImplementationLimitCase(Context &context, const char *name, const char *description,
83*35238bceSAndroid Build Coastguard Worker                                                  glw::GLenum target, int limit)
84*35238bceSAndroid Build Coastguard Worker     : ExtensionPackTestCase(context, name, description)
85*35238bceSAndroid Build Coastguard Worker     , m_target(target)
86*35238bceSAndroid Build Coastguard Worker     , m_limit(limit)
87*35238bceSAndroid Build Coastguard Worker {
88*35238bceSAndroid Build Coastguard Worker }
89*35238bceSAndroid Build Coastguard Worker 
iterate(void)90*35238bceSAndroid Build Coastguard Worker ImplementationLimitCase::IterateResult ImplementationLimitCase::iterate(void)
91*35238bceSAndroid Build Coastguard Worker {
92*35238bceSAndroid Build Coastguard Worker     using namespace gls::StateQueryUtil;
93*35238bceSAndroid Build Coastguard Worker 
94*35238bceSAndroid Build Coastguard Worker     glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
95*35238bceSAndroid Build Coastguard Worker     StateQueryMemoryWriteGuard<glw::GLint> result;
96*35238bceSAndroid Build Coastguard Worker 
97*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
98*35238bceSAndroid Build Coastguard Worker     m_testCtx.getLog() << tcu::TestLog::Message << "Querying " << glu::getGettableStateName(m_target)
99*35238bceSAndroid Build Coastguard Worker                        << ", expecting at least " << m_limit << tcu::TestLog::EndMessage;
100*35238bceSAndroid Build Coastguard Worker 
101*35238bceSAndroid Build Coastguard Worker     gl.enableLogging(true);
102*35238bceSAndroid Build Coastguard Worker     gl.glGetIntegerv(m_target, &result);
103*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.glGetError(), "implementation limit query failed");
104*35238bceSAndroid Build Coastguard Worker 
105*35238bceSAndroid Build Coastguard Worker     if (result.verifyValidity(m_testCtx) && result < m_limit)
106*35238bceSAndroid Build Coastguard Worker     {
107*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << tcu::TestLog::Message << "// ERROR: Got " << result << ", expected at least " << m_limit
108*35238bceSAndroid Build Coastguard Worker                            << tcu::TestLog::EndMessage;
109*35238bceSAndroid Build Coastguard Worker 
110*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Too low implementation limit");
111*35238bceSAndroid Build Coastguard Worker     }
112*35238bceSAndroid Build Coastguard Worker 
113*35238bceSAndroid Build Coastguard Worker     return STOP;
114*35238bceSAndroid Build Coastguard Worker }
115*35238bceSAndroid Build Coastguard Worker 
116*35238bceSAndroid Build Coastguard Worker class SubExtensionCase : public ExtensionPackTestCase
117*35238bceSAndroid Build Coastguard Worker {
118*35238bceSAndroid Build Coastguard Worker public:
119*35238bceSAndroid Build Coastguard Worker     SubExtensionCase(Context &context, const char *name, const char *description, const char *extension);
120*35238bceSAndroid Build Coastguard Worker 
121*35238bceSAndroid Build Coastguard Worker private:
122*35238bceSAndroid Build Coastguard Worker     IterateResult iterate(void);
123*35238bceSAndroid Build Coastguard Worker 
124*35238bceSAndroid Build Coastguard Worker     const std::string m_extension;
125*35238bceSAndroid Build Coastguard Worker };
126*35238bceSAndroid Build Coastguard Worker 
SubExtensionCase(Context & context,const char * name,const char * description,const char * extension)127*35238bceSAndroid Build Coastguard Worker SubExtensionCase::SubExtensionCase(Context &context, const char *name, const char *description, const char *extension)
128*35238bceSAndroid Build Coastguard Worker     : ExtensionPackTestCase(context, name, description)
129*35238bceSAndroid Build Coastguard Worker     , m_extension(extension)
130*35238bceSAndroid Build Coastguard Worker {
131*35238bceSAndroid Build Coastguard Worker }
132*35238bceSAndroid Build Coastguard Worker 
iterate(void)133*35238bceSAndroid Build Coastguard Worker SubExtensionCase::IterateResult SubExtensionCase::iterate(void)
134*35238bceSAndroid Build Coastguard Worker {
135*35238bceSAndroid Build Coastguard Worker     m_testCtx.getLog() << tcu::TestLog::Message << "Verifying that extension \"" << m_extension << "\" is supported."
136*35238bceSAndroid Build Coastguard Worker                        << tcu::TestLog::EndMessage;
137*35238bceSAndroid Build Coastguard Worker 
138*35238bceSAndroid Build Coastguard Worker     if (m_context.getContextInfo().isExtensionSupported(m_extension.c_str()))
139*35238bceSAndroid Build Coastguard Worker     {
140*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << tcu::TestLog::Message << "Extension is supported." << tcu::TestLog::EndMessage;
141*35238bceSAndroid Build Coastguard Worker 
142*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
143*35238bceSAndroid Build Coastguard Worker     }
144*35238bceSAndroid Build Coastguard Worker     else
145*35238bceSAndroid Build Coastguard Worker     {
146*35238bceSAndroid Build Coastguard Worker         m_testCtx.getLog() << tcu::TestLog::Message << "Error, extension is not supported." << tcu::TestLog::EndMessage;
147*35238bceSAndroid Build Coastguard Worker 
148*35238bceSAndroid Build Coastguard Worker         m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Required extension not supported");
149*35238bceSAndroid Build Coastguard Worker     }
150*35238bceSAndroid Build Coastguard Worker 
151*35238bceSAndroid Build Coastguard Worker     return STOP;
152*35238bceSAndroid Build Coastguard Worker }
153*35238bceSAndroid Build Coastguard Worker 
154*35238bceSAndroid Build Coastguard Worker } // namespace
155*35238bceSAndroid Build Coastguard Worker 
AndroidExtensionPackES31ATests(Context & context)156*35238bceSAndroid Build Coastguard Worker AndroidExtensionPackES31ATests::AndroidExtensionPackES31ATests(Context &context)
157*35238bceSAndroid Build Coastguard Worker     : TestCaseGroup(context, "android_extension_pack", "ANDROID_extension_pack_es31a extension tests")
158*35238bceSAndroid Build Coastguard Worker {
159*35238bceSAndroid Build Coastguard Worker }
160*35238bceSAndroid Build Coastguard Worker 
~AndroidExtensionPackES31ATests(void)161*35238bceSAndroid Build Coastguard Worker AndroidExtensionPackES31ATests::~AndroidExtensionPackES31ATests(void)
162*35238bceSAndroid Build Coastguard Worker {
163*35238bceSAndroid Build Coastguard Worker }
164*35238bceSAndroid Build Coastguard Worker 
init(void)165*35238bceSAndroid Build Coastguard Worker void AndroidExtensionPackES31ATests::init(void)
166*35238bceSAndroid Build Coastguard Worker {
167*35238bceSAndroid Build Coastguard Worker     // .limits
168*35238bceSAndroid Build Coastguard Worker     {
169*35238bceSAndroid Build Coastguard Worker         static const struct
170*35238bceSAndroid Build Coastguard Worker         {
171*35238bceSAndroid Build Coastguard Worker             const char *name;
172*35238bceSAndroid Build Coastguard Worker             glw::GLenum target;
173*35238bceSAndroid Build Coastguard Worker             int limit;
174*35238bceSAndroid Build Coastguard Worker         } limits[] = {
175*35238bceSAndroid Build Coastguard Worker             {"max_fragment_atomic_counter_buffers", GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, 1},
176*35238bceSAndroid Build Coastguard Worker             {"max_fragment_atomic_counters", GL_MAX_FRAGMENT_ATOMIC_COUNTERS, 8},
177*35238bceSAndroid Build Coastguard Worker             {"max_fragment_image_uniforms", GL_MAX_FRAGMENT_IMAGE_UNIFORMS, 4},
178*35238bceSAndroid Build Coastguard Worker             {"max_fragment_shader_storage_blocks", GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, 4},
179*35238bceSAndroid Build Coastguard Worker         };
180*35238bceSAndroid Build Coastguard Worker 
181*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "limits", "Implementation limits");
182*35238bceSAndroid Build Coastguard Worker         addChild(group);
183*35238bceSAndroid Build Coastguard Worker 
184*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(limits); ++ndx)
185*35238bceSAndroid Build Coastguard Worker             group->addChild(new ImplementationLimitCase(
186*35238bceSAndroid Build Coastguard Worker                 m_context, limits[ndx].name,
187*35238bceSAndroid Build Coastguard Worker                 (std::string() + "Check " + limits[ndx].name + " is at least " + de::toString(limits[ndx].limit))
188*35238bceSAndroid Build Coastguard Worker                     .c_str(),
189*35238bceSAndroid Build Coastguard Worker                 limits[ndx].target, limits[ndx].limit));
190*35238bceSAndroid Build Coastguard Worker     }
191*35238bceSAndroid Build Coastguard Worker 
192*35238bceSAndroid Build Coastguard Worker     // .extensions
193*35238bceSAndroid Build Coastguard Worker     {
194*35238bceSAndroid Build Coastguard Worker         static const char *const subExtensions[] = {
195*35238bceSAndroid Build Coastguard Worker             "GL_KHR_debug",
196*35238bceSAndroid Build Coastguard Worker             "GL_KHR_texture_compression_astc_ldr",
197*35238bceSAndroid Build Coastguard Worker             "GL_KHR_blend_equation_advanced",
198*35238bceSAndroid Build Coastguard Worker             "GL_OES_sample_shading",
199*35238bceSAndroid Build Coastguard Worker             "GL_OES_sample_variables",
200*35238bceSAndroid Build Coastguard Worker             "GL_OES_shader_image_atomic",
201*35238bceSAndroid Build Coastguard Worker             "GL_OES_shader_multisample_interpolation",
202*35238bceSAndroid Build Coastguard Worker             "GL_OES_texture_stencil8",
203*35238bceSAndroid Build Coastguard Worker             "GL_OES_texture_storage_multisample_2d_array",
204*35238bceSAndroid Build Coastguard Worker             "GL_EXT_copy_image",
205*35238bceSAndroid Build Coastguard Worker             "GL_EXT_draw_buffers_indexed",
206*35238bceSAndroid Build Coastguard Worker             "GL_EXT_geometry_shader",
207*35238bceSAndroid Build Coastguard Worker             "GL_EXT_gpu_shader5",
208*35238bceSAndroid Build Coastguard Worker             "GL_EXT_primitive_bounding_box",
209*35238bceSAndroid Build Coastguard Worker             "GL_EXT_shader_io_blocks",
210*35238bceSAndroid Build Coastguard Worker             "GL_EXT_tessellation_shader",
211*35238bceSAndroid Build Coastguard Worker             "GL_EXT_texture_border_clamp",
212*35238bceSAndroid Build Coastguard Worker             "GL_EXT_texture_buffer",
213*35238bceSAndroid Build Coastguard Worker             "GL_EXT_texture_cube_map_array",
214*35238bceSAndroid Build Coastguard Worker             "GL_EXT_texture_sRGB_decode",
215*35238bceSAndroid Build Coastguard Worker         };
216*35238bceSAndroid Build Coastguard Worker 
217*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "extensions", "Required extensions");
218*35238bceSAndroid Build Coastguard Worker         addChild(group);
219*35238bceSAndroid Build Coastguard Worker 
220*35238bceSAndroid Build Coastguard Worker         for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(subExtensions); ++ndx)
221*35238bceSAndroid Build Coastguard Worker         {
222*35238bceSAndroid Build Coastguard Worker             const std::string name = genExtensionTestName(subExtensions[ndx]);
223*35238bceSAndroid Build Coastguard Worker             const std::string description =
224*35238bceSAndroid Build Coastguard Worker                 "Check that extension " + name + " is supported if extension pack is supported";
225*35238bceSAndroid Build Coastguard Worker             group->addChild(new SubExtensionCase(m_context, name.c_str(), description.c_str(), subExtensions[ndx]));
226*35238bceSAndroid Build Coastguard Worker         }
227*35238bceSAndroid Build Coastguard Worker     }
228*35238bceSAndroid Build Coastguard Worker 
229*35238bceSAndroid Build Coastguard Worker     // .shaders
230*35238bceSAndroid Build Coastguard Worker     {
231*35238bceSAndroid Build Coastguard Worker         gls::ShaderLibrary shaderLibrary(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo());
232*35238bceSAndroid Build Coastguard Worker         tcu::TestCaseGroup *const group = new tcu::TestCaseGroup(m_testCtx, "shaders", "Shader tests");
233*35238bceSAndroid Build Coastguard Worker 
234*35238bceSAndroid Build Coastguard Worker         {
235*35238bceSAndroid Build Coastguard Worker             const std::vector<tcu::TestNode *> &children =
236*35238bceSAndroid Build Coastguard Worker                 shaderLibrary.loadShaderFile("shaders/es31/android_extension_pack.test");
237*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const groupES31 =
238*35238bceSAndroid Build Coastguard Worker                 new tcu::TestCaseGroup(m_testCtx, "es31", "GLSL ES 3.1 Shader tests", children);
239*35238bceSAndroid Build Coastguard Worker 
240*35238bceSAndroid Build Coastguard Worker             group->addChild(groupES31);
241*35238bceSAndroid Build Coastguard Worker         }
242*35238bceSAndroid Build Coastguard Worker 
243*35238bceSAndroid Build Coastguard Worker         {
244*35238bceSAndroid Build Coastguard Worker             const std::vector<tcu::TestNode *> &children =
245*35238bceSAndroid Build Coastguard Worker                 shaderLibrary.loadShaderFile("shaders/es32/android_extension_pack.test");
246*35238bceSAndroid Build Coastguard Worker             tcu::TestCaseGroup *const groupES32 =
247*35238bceSAndroid Build Coastguard Worker                 new tcu::TestCaseGroup(m_testCtx, "es32", "GLSL ES 3.2 Shader tests", children);
248*35238bceSAndroid Build Coastguard Worker 
249*35238bceSAndroid Build Coastguard Worker             group->addChild(groupES32);
250*35238bceSAndroid Build Coastguard Worker         }
251*35238bceSAndroid Build Coastguard Worker 
252*35238bceSAndroid Build Coastguard Worker         addChild(group);
253*35238bceSAndroid Build Coastguard Worker     }
254*35238bceSAndroid Build Coastguard Worker }
255*35238bceSAndroid Build Coastguard Worker 
256*35238bceSAndroid Build Coastguard Worker } // namespace Functional
257*35238bceSAndroid Build Coastguard Worker } // namespace gles31
258*35238bceSAndroid Build Coastguard Worker } // namespace deqp
259