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