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, const ColorClearGroupSpec* first, const ColorClearGroupSpec* last)
58 {
59 	for (const ColorClearGroupSpec* groupIter = first; groupIter != last; groupIter++)
60 	{
61 		tcu::TestCaseGroup* configGroup = new tcu::TestCaseGroup(eglTestCtx.getTestContext(), groupIter->name, groupIter->desc);
62 		group->addChild(configGroup);
63 
64 		vector<RenderFilterList>	filterLists;
65 		eglu::FilterList			baseFilters;
66 		baseFilters << groupIter->baseFilter;
67 		getDefaultRenderFilterLists(filterLists, baseFilters);
68 
69 		for (vector<RenderFilterList>::const_iterator listIter = filterLists.begin(); listIter != filterLists.end(); listIter++)
70 			configGroup->addChild(new ClearClass(eglTestCtx, listIter->getName(), "", groupIter->apiBits, listIter->getSurfaceTypeMask(), *listIter, groupIter->numContextsPerApi));
71 	}
72 }
73 
74 template <deUint32 Bits>
renderable(const eglu::CandidateConfig & c)75 static bool renderable (const eglu::CandidateConfig& c)
76 {
77 	return (c.renderableType() & Bits) == Bits;
78 }
79 
init(void)80 void ColorClearTests::init (void)
81 {
82 #define CASE(NAME, DESC, BITS, NUMCFG) { NAME, DESC, BITS, renderable<BITS>, NUMCFG }
83 
84 	static const ColorClearGroupSpec singleContextCases[] =
85 	{
86 		CASE("gles1",			"Color clears using GLES1",											EGL_OPENGL_ES_BIT,										1),
87 		CASE("gles2",			"Color clears using GLES2",											EGL_OPENGL_ES2_BIT,										1),
88 		CASE("gles3",			"Color clears using GLES3",											EGL_OPENGL_ES3_BIT,										1),
89 		CASE("vg",				"Color clears using OpenVG",										EGL_OPENVG_BIT,											1)
90 	};
91 
92 	static const ColorClearGroupSpec multiContextCases[] =
93 	{
94 		CASE("gles1",				"Color clears using multiple GLES1 contexts to shared surface",		EGL_OPENGL_ES_BIT,											3),
95 		CASE("gles2",				"Color clears using multiple GLES2 contexts to shared surface",		EGL_OPENGL_ES2_BIT,											3),
96 		CASE("gles3",				"Color clears using multiple GLES3 contexts to shared surface",		EGL_OPENGL_ES3_BIT,											3),
97 		CASE("vg",					"Color clears using multiple OpenVG contexts to shared surface",	EGL_OPENVG_BIT,												3),
98 		CASE("gles1_gles2",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT,						1),
99 		CASE("gles1_gles2_gles3",	"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT|EGL_OPENGL_ES3_BIT,	1),
100 		CASE("gles1_vg",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENVG_BIT,							1),
101 		CASE("gles2_vg",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES2_BIT|EGL_OPENVG_BIT,							1),
102 		CASE("gles3_vg",			"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES3_BIT|EGL_OPENVG_BIT,							1),
103 		CASE("gles1_gles2_vg",		"Color clears using multiple APIs to shared surface",				EGL_OPENGL_ES_BIT|EGL_OPENGL_ES2_BIT|EGL_OPENVG_BIT,		1)
104 	};
105 
106 #undef CASE
107 
108 	tcu::TestCaseGroup* singleContextGroup = new tcu::TestCaseGroup(m_testCtx, "single_context", "Single-context color clears");
109 	addChild(singleContextGroup);
110 	createColorClearGroups<SingleThreadColorClearCase>(m_eglTestCtx, singleContextGroup, &singleContextCases[0], &singleContextCases[DE_LENGTH_OF_ARRAY(singleContextCases)]);
111 
112 	tcu::TestCaseGroup* multiContextGroup = new tcu::TestCaseGroup(m_testCtx, "multi_context", "Multi-context color clears with shared surface");
113 	addChild(multiContextGroup);
114 	createColorClearGroups<SingleThreadColorClearCase>(m_eglTestCtx, multiContextGroup, &multiContextCases[0], &multiContextCases[DE_LENGTH_OF_ARRAY(multiContextCases)]);
115 
116 	tcu::TestCaseGroup* multiThreadGroup = new tcu::TestCaseGroup(m_testCtx, "multi_thread", "Multi-thread color clears with shared surface");
117 	addChild(multiThreadGroup);
118 	createColorClearGroups<MultiThreadColorClearCase>(m_eglTestCtx, multiThreadGroup, &multiContextCases[0], &multiContextCases[DE_LENGTH_OF_ARRAY(multiContextCases)]);
119 }
120 
121 } // egl
122 } // deqp
123