• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Test config list case.
23  */ /*-------------------------------------------------------------------*/
24 
25 #include "glcConfigListCase.hpp"
26 #include "glcConfigList.hpp"
27 #include "tcuTestLog.hpp"
28 
29 namespace glcts
30 {
31 
32 using tcu::TestLog;
33 using std::vector;
34 
getConfigTypeName(ConfigType type)35 static const char* getConfigTypeName(ConfigType type)
36 {
37 	switch (type)
38 	{
39 	case CONFIGTYPE_DEFAULT:
40 		return "default";
41 	case CONFIGTYPE_EGL:
42 		return "EGL";
43 	case CONFIGTYPE_WGL:
44 		return "WGL";
45 	default:
46 		throw tcu::Exception("Unknown config type");
47 	}
48 }
49 
getExcludeReasonName(ExcludeReason reason)50 static const char* getExcludeReasonName(ExcludeReason reason)
51 {
52 	switch (reason)
53 	{
54 	case EXCLUDEREASON_NOT_COMPATIBLE:
55 		return "Not compatible";
56 	case EXCLUDEREASON_NOT_CONFORMANT:
57 		return "Not conformant";
58 	case EXCLUDEREASON_MSAA:
59 		return "Multisampled: Not testable";
60 	case EXCLUDEREASON_FLOAT:
61 		return "Float configs: Not testable";
62 	case EXCLUDEREASON_YUV:
63 		return "YUV: Not testable";
64 	default:
65 		throw tcu::Exception("Unknown exclude reason");
66 	}
67 }
68 
getSurfaceTypeName(tcu::SurfaceType type)69 static const char* getSurfaceTypeName(tcu::SurfaceType type)
70 {
71 	switch (type)
72 	{
73 	case tcu::SURFACETYPE_WINDOW:
74 		return "window";
75 	case tcu::SURFACETYPE_OFFSCREEN_NATIVE:
76 		return "pixmap";
77 	case tcu::SURFACETYPE_OFFSCREEN_GENERIC:
78 		return "pbuffer";
79 	default:
80 		throw tcu::Exception("Unknown surface type");
81 	}
82 }
83 
84 struct SurfaceBitsFmt
85 {
86 	deUint32 bits;
87 
SurfaceBitsFmtglcts::SurfaceBitsFmt88 	SurfaceBitsFmt(deUint32 bits_) : bits(bits_)
89 	{
90 	}
91 };
92 
operator <<(std::ostream & str,const SurfaceBitsFmt & bits)93 std::ostream& operator<<(std::ostream& str, const SurfaceBitsFmt& bits)
94 {
95 	static const tcu::SurfaceType s_types[] = { tcu::SURFACETYPE_WINDOW, tcu::SURFACETYPE_OFFSCREEN_NATIVE,
96 												tcu::SURFACETYPE_OFFSCREEN_GENERIC };
97 
98 	bool isFirst = true;
99 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(s_types); ndx++)
100 	{
101 		if (bits.bits & (1 << s_types[ndx]))
102 		{
103 			if (!isFirst)
104 				str << ", ";
105 			str << getSurfaceTypeName(s_types[ndx]);
106 			isFirst = false;
107 		}
108 	}
109 
110 	return str;
111 }
112 
ConfigListCase(tcu::TestContext & testCtx,const char * name,const char * description,glu::ApiType type)113 ConfigListCase::ConfigListCase(tcu::TestContext& testCtx, const char* name, const char* description, glu::ApiType type)
114 	: TestCase(testCtx, name, description), m_ctxType(type)
115 {
116 }
117 
~ConfigListCase(void)118 ConfigListCase::~ConfigListCase(void)
119 {
120 }
121 
iterate(void)122 ConfigListCase::IterateResult ConfigListCase::iterate(void)
123 {
124 	TestLog&   log = m_testCtx.getLog();
125 	ConfigList configs;
126 
127 	getDefaultConfigList(m_testCtx.getPlatform(), m_ctxType, configs);
128 
129 	// Valid configs.
130 	{
131 		tcu::ScopedLogSection configSection(log, "Configs", "Configs");
132 
133 		for (vector<Config>::const_iterator cfgIter = configs.configs.begin(); cfgIter != configs.configs.end();
134 			 cfgIter++)
135 			log << TestLog::Message << getConfigTypeName(cfgIter->type) << "(" << cfgIter->id
136 				<< "): " << SurfaceBitsFmt(cfgIter->surfaceTypes) << TestLog::EndMessage;
137 	}
138 
139 	// Excluded configs.
140 	{
141 		tcu::ScopedLogSection excludedSection(log, "ExcludedConfigs", "Excluded configs");
142 
143 		for (vector<ExcludedConfig>::const_iterator cfgIter = configs.excludedConfigs.begin();
144 			 cfgIter != configs.excludedConfigs.end(); cfgIter++)
145 			log << TestLog::Message << getConfigTypeName(cfgIter->type) << "(" << cfgIter->id
146 				<< "): " << getExcludeReasonName(cfgIter->reason) << TestLog::EndMessage;
147 	}
148 
149 	// Totals.
150 	int numValid		 = (int)configs.configs.size();
151 	int numNotCompatible = 0;
152 	int numNotConformant = 0;
153 
154 	for (vector<ExcludedConfig>::const_iterator cfgIter = configs.excludedConfigs.begin();
155 		 cfgIter != configs.excludedConfigs.end(); cfgIter++)
156 		(cfgIter->reason == EXCLUDEREASON_NOT_CONFORMANT ? numNotConformant : numNotCompatible) += 1;
157 
158 	log << TestLog::Message << numValid << " valid, " << numNotConformant << " non-conformant and " << numNotCompatible
159 		<< " non-compatible configs" << TestLog::EndMessage;
160 
161 	bool configCountOk = numValid >= numNotConformant;
162 	m_testCtx.setTestResult(configCountOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL,
163 							configCountOk ? "Pass" : "Too many non-conformant configs");
164 
165 	return STOP;
166 }
167 
168 } // glcts
169