xref: /aosp_15_r20/external/deqp/modules/egl/teglColorClearTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program EGL 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 Color clear tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "teglColorClearTests.hpp"
25 #include "teglColorClearCase.hpp"
26 #include "eglwEnums.hpp"
27 
28 using std::string;
29 using std::vector;
30 
31 namespace deqp
32 {
33 namespace egl
34 {
35 
36 using namespace eglw;
37 
ColorClearTests(EglTestContext & eglTestCtx)38 ColorClearTests::ColorClearTests(EglTestContext &eglTestCtx)
39     : TestCaseGroup(eglTestCtx, "color_clears", "Color clears with different client APIs")
40 {
41 }
42 
~ColorClearTests(void)43 ColorClearTests::~ColorClearTests(void)
44 {
45 }
46 
47 struct ColorClearGroupSpec
48 {
49     const char *name;
50     const char *desc;
51     EGLint apiBits;
52     eglu::ConfigFilter baseFilter;
53     int numContextsPerApi;
54 };
55 
56 template <class ClearClass>
createColorClearGroups(EglTestContext & eglTestCtx,tcu::TestCaseGroup * group,const ColorClearGroupSpec * first,const ColorClearGroupSpec * last)57 static void createColorClearGroups(EglTestContext &eglTestCtx, tcu::TestCaseGroup *group,
58                                    const ColorClearGroupSpec *first, const ColorClearGroupSpec *last)
59 {
60     for (const ColorClearGroupSpec *groupIter = first; groupIter != last; groupIter++)
61     {
62         tcu::TestCaseGroup *configGroup =
63             new tcu::TestCaseGroup(eglTestCtx.getTestContext(), groupIter->name, groupIter->desc);
64         group->addChild(configGroup);
65 
66         vector<RenderFilterList> filterLists;
67         eglu::FilterList baseFilters;
68         baseFilters << groupIter->baseFilter;
69         getDefaultRenderFilterLists(filterLists, baseFilters);
70 
71         for (vector<RenderFilterList>::const_iterator listIter = filterLists.begin(); listIter != filterLists.end();
72              listIter++)
73             configGroup->addChild(new ClearClass(eglTestCtx, listIter->getName(), "", groupIter->apiBits,
74                                                  listIter->getSurfaceTypeMask(), *listIter,
75                                                  groupIter->numContextsPerApi));
76     }
77 }
78 
79 template <uint32_t Bits>
renderable(const eglu::CandidateConfig & c)80 static bool renderable(const eglu::CandidateConfig &c)
81 {
82     return (c.renderableType() & Bits) == Bits;
83 }
84 
init(void)85 void ColorClearTests::init(void)
86 {
87 #define CASE(NAME, DESC, BITS, NUMCFG)             \
88     {                                              \
89         NAME, DESC, BITS, renderable<BITS>, NUMCFG \
90     }
91 
92     static const ColorClearGroupSpec singleContextCases[] = {
93         CASE("gles1", "Color clears using GLES1", EGL_OPENGL_ES_BIT, 1),
94         CASE("gles2", "Color clears using GLES2", EGL_OPENGL_ES2_BIT, 1),
95         CASE("gles3", "Color clears using GLES3", EGL_OPENGL_ES3_BIT, 1),
96         CASE("vg", "Color clears using OpenVG", EGL_OPENVG_BIT, 1)};
97 
98     static const ColorClearGroupSpec multiContextCases[] = {
99         CASE("gles1", "Color clears using multiple GLES1 contexts to shared surface", EGL_OPENGL_ES_BIT, 3),
100         CASE("gles2", "Color clears using multiple GLES2 contexts to shared surface", EGL_OPENGL_ES2_BIT, 3),
101         CASE("gles3", "Color clears using multiple GLES3 contexts to shared surface", EGL_OPENGL_ES3_BIT, 3),
102         CASE("vg", "Color clears using multiple OpenVG contexts to shared surface", EGL_OPENVG_BIT, 3),
103         CASE("gles1_gles2", "Color clears using multiple APIs to shared surface",
104              EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT, 1),
105         CASE("gles1_gles2_gles3", "Color clears using multiple APIs to shared surface",
106              EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT, 1),
107         CASE("gles1_vg", "Color clears using multiple APIs to shared surface", EGL_OPENGL_ES_BIT | EGL_OPENVG_BIT, 1),
108         CASE("gles2_vg", "Color clears using multiple APIs to shared surface", EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT, 1),
109         CASE("gles3_vg", "Color clears using multiple APIs to shared surface", EGL_OPENGL_ES3_BIT | EGL_OPENVG_BIT, 1),
110         CASE("gles1_gles2_vg", "Color clears using multiple APIs to shared surface",
111              EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT | EGL_OPENVG_BIT, 1)};
112 
113 #undef CASE
114 
115     tcu::TestCaseGroup *singleContextGroup =
116         new tcu::TestCaseGroup(m_testCtx, "single_context", "Single-context color clears");
117     addChild(singleContextGroup);
118     createColorClearGroups<SingleThreadColorClearCase>(m_eglTestCtx, singleContextGroup, &singleContextCases[0],
119                                                        &singleContextCases[DE_LENGTH_OF_ARRAY(singleContextCases)]);
120 
121     tcu::TestCaseGroup *multiContextGroup =
122         new tcu::TestCaseGroup(m_testCtx, "multi_context", "Multi-context color clears with shared surface");
123     addChild(multiContextGroup);
124     createColorClearGroups<SingleThreadColorClearCase>(m_eglTestCtx, multiContextGroup, &multiContextCases[0],
125                                                        &multiContextCases[DE_LENGTH_OF_ARRAY(multiContextCases)]);
126 
127     tcu::TestCaseGroup *multiThreadGroup =
128         new tcu::TestCaseGroup(m_testCtx, "multi_thread", "Multi-thread color clears with shared surface");
129     addChild(multiThreadGroup);
130     createColorClearGroups<MultiThreadColorClearCase>(m_eglTestCtx, multiThreadGroup, &multiContextCases[0],
131                                                       &multiContextCases[DE_LENGTH_OF_ARRAY(multiContextCases)]);
132 }
133 
134 } // namespace egl
135 } // namespace deqp
136