1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 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 State Query tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es3fIntegerStateQueryTests.hpp"
25 #include "es3fApiCase.hpp"
26 
27 #include "glsStateQueryUtil.hpp"
28 
29 #include "gluRenderContext.hpp"
30 #include "gluContextInfo.hpp"
31 #include "gluStrUtil.hpp"
32 
33 #include "tcuRenderTarget.hpp"
34 
35 #include "deRandom.hpp"
36 
37 #include "glwEnums.hpp"
38 
39 using namespace glw; // GLint and other GL types
40 using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
41 
42 #ifndef GL_SLUMINANCE_NV
43 #define	GL_SLUMINANCE_NV 0x8C46
44 #endif
45 #ifndef GL_SLUMINANCE_ALPHA_NV
46 #define	GL_SLUMINANCE_ALPHA_NV 0x8C44
47 #endif
48 #ifndef GL_BGR_NV
49 #define GL_BGR_NV 0x80E0
50 #endif
51 
52 namespace deqp
53 {
54 namespace gles3
55 {
56 namespace Functional
57 {
58 namespace IntegerStateQueryVerifiers
59 {
60 
61 // StateVerifier
62 
63 class StateVerifier : protected glu::CallLogWrapper
64 {
65 public:
66 						StateVerifier						(const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix);
67 	virtual				~StateVerifier						(); // make GCC happy
68 
69 	const char*			getTestNamePostfix					(void) const;
70 
71 	virtual void		verifyInteger						(tcu::TestContext& testCtx, GLenum name, GLint reference)																																		= DE_NULL;
72 	virtual void		verifyInteger4						(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)																				= DE_NULL;
73 	virtual void		verifyInteger4Mask					(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)			= DE_NULL;
74 	virtual void		verifyIntegerGreaterOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference)																																		= DE_NULL;
75 	virtual void		verifyUnsignedIntegerGreaterOrEqual	(tcu::TestContext& testCtx, GLenum name, GLuint reference)																																		= DE_NULL;
76 	virtual void		verifyIntegerLessOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference)																																		= DE_NULL;
77 	virtual void		verifyIntegerGreaterOrEqual2		(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)																													= DE_NULL;
78 	virtual void		verifyIntegerAnyOf					(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)																											= DE_NULL;
79 	virtual void		verifyStencilMaskInitial			(tcu::TestContext& testCtx, GLenum name, int stencilBits)																																		= DE_NULL;
80 
81 private:
82 	const char*	const	m_testNamePostfix;
83 };
84 
StateVerifier(const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix)85 StateVerifier::StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix)
86 	: glu::CallLogWrapper	(gl, log)
87 	, m_testNamePostfix		(testNamePostfix)
88 {
89 	enableLogging(true);
90 }
91 
~StateVerifier()92 StateVerifier::~StateVerifier ()
93 {
94 }
95 
getTestNamePostfix(void) const96 const char* StateVerifier::getTestNamePostfix (void) const
97 {
98 	return m_testNamePostfix;
99 }
100 
101 // GetBooleanVerifier
102 
103 class GetBooleanVerifier : public StateVerifier
104 {
105 public:
106 			GetBooleanVerifier			(const glw::Functions& gl, tcu::TestLog& log);
107 	void	verifyInteger						(tcu::TestContext& testCtx, GLenum name, GLint reference);
108 	void	verifyInteger4						(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
109 	void	verifyInteger4Mask					(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
110 	void	verifyIntegerGreaterOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
111 	void	verifyUnsignedIntegerGreaterOrEqual	(tcu::TestContext& testCtx, GLenum name, GLuint reference);
112 	void	verifyIntegerLessOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
113 	void	verifyIntegerGreaterOrEqual2		(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
114 	void	verifyIntegerAnyOf					(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
115 	void	verifyStencilMaskInitial			(tcu::TestContext& testCtx, GLenum name, int stencilBits);
116 };
117 
GetBooleanVerifier(const glw::Functions& gl, tcu::TestLog& log)118 GetBooleanVerifier::GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log)
119 	: StateVerifier(gl, log, "_getboolean")
120 {
121 }
122 
verifyInteger(tcu::TestContext& testCtx, GLenum name, GLint reference)123 void GetBooleanVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
124 {
125 	using tcu::TestLog;
126 
127 	StateQueryMemoryWriteGuard<GLboolean> state;
128 	glGetBooleanv(name, &state);
129 
130 	if (!state.verifyValidity(testCtx))
131 		return;
132 
133 	const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE;
134 
135 	if (state != expectedGLState)
136 	{
137 		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (expectedGLState==GL_TRUE ? "GL_TRUE" : "GL_FALSE") << "; got " << (state == GL_TRUE ? "GL_TRUE" : (state == GL_FALSE ? "GL_FALSE" : "non-boolean")) << TestLog::EndMessage;
138 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
139 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
140 	}
141 }
142 
verifyInteger4(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)143 void GetBooleanVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
144 {
145 	verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
146 }
147 
verifyInteger4Mask(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)148 void GetBooleanVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
149 {
150 	using tcu::TestLog;
151 
152 	StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4;
153 	glGetBooleanv(name, boolVector4);
154 
155 	if (!boolVector4.verifyValidity(testCtx))
156 		return;
157 
158 	const GLboolean referenceAsGLBoolean[] =
159 	{
160 		reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
161 		reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
162 		reference2 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
163 		reference3 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
164 	};
165 
166 	if ((enableRef0 && (boolVector4[0] != referenceAsGLBoolean[0])) ||
167 		(enableRef1 && (boolVector4[1] != referenceAsGLBoolean[1])) ||
168 		(enableRef2 && (boolVector4[2] != referenceAsGLBoolean[2])) ||
169 		(enableRef3 && (boolVector4[3] != referenceAsGLBoolean[3])))
170 	{
171 		testCtx.getLog() << TestLog::Message << "// ERROR: expected "
172 			<< (enableRef0 ? (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
173 			<< (enableRef1 ? (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
174 			<< (enableRef2 ? (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
175 			<< (enableRef3 ? (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") : " - ") << TestLog::EndMessage;
176 
177 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
178 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
179 	}
180 }
181 
verifyIntegerGreaterOrEqual(tcu::TestContext& testCtx, GLenum name, GLint reference)182 void GetBooleanVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
183 {
184 	using tcu::TestLog;
185 
186 	StateQueryMemoryWriteGuard<GLboolean> state;
187 	glGetBooleanv(name, &state);
188 
189 	if (!state.verifyValidity(testCtx))
190 		return;
191 
192 	if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct)
193 		return;
194 
195 	if (state == GL_FALSE) // state is zero
196 	{
197 		if (reference > 0) // and reference is greater than zero?
198 		{
199 			testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
200 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
201 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
202 		}
203 	}
204 	else
205 	{
206 		testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
207 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
208 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
209 	}
210 }
211 
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext& testCtx, GLenum name, GLuint reference)212 void GetBooleanVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
213 {
214 	using tcu::TestLog;
215 
216 	StateQueryMemoryWriteGuard<GLboolean> state;
217 	glGetBooleanv(name, &state);
218 
219 	if (!state.verifyValidity(testCtx))
220 		return;
221 
222 	if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct)
223 		return;
224 
225 	if (state == GL_FALSE) // state is zero
226 	{
227 		if (reference > 0) // and reference is greater than zero?
228 		{
229 			testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
230 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
231 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
232 		}
233 	}
234 	else
235 	{
236 		testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
237 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
238 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
239 	}
240 }
241 
verifyIntegerLessOrEqual(tcu::TestContext& testCtx, GLenum name, GLint reference)242 void GetBooleanVerifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
243 {
244 	using tcu::TestLog;
245 
246 	StateQueryMemoryWriteGuard<GLboolean> state;
247 	glGetBooleanv(name, &state);
248 
249 	if (!state.verifyValidity(testCtx))
250 		return;
251 
252 	if (state == GL_TRUE) // state is non-zero, could be less than reference (correct)
253 		return;
254 
255 	if (state == GL_FALSE) // state is zero
256 	{
257 		if (reference < 0) // and reference is less than zero?
258 		{
259 			testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
260 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
261 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
262 		}
263 	}
264 	else
265 	{
266 		testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
267 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
268 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
269 	}
270 }
271 
verifyIntegerGreaterOrEqual2(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)272 void GetBooleanVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
273 {
274 	using tcu::TestLog;
275 
276 	StateQueryMemoryWriteGuard<GLboolean[2]> boolVector;
277 	glGetBooleanv(name, boolVector);
278 
279 	if (!boolVector.verifyValidity(testCtx))
280 		return;
281 
282 	const GLboolean referenceAsGLBoolean[2] =
283 	{
284 		reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
285 		reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE
286 	};
287 
288 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceAsGLBoolean); ++ndx)
289 	{
290 		if (boolVector[ndx] == GL_TRUE) // state is non-zero, could be greater than any integer
291 		{
292 			continue;
293 		}
294 		else if (boolVector[ndx] == GL_FALSE) // state is zero
295 		{
296 			if (referenceAsGLBoolean[ndx] > 0) // and reference is greater than zero?
297 			{
298 				testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
299 				if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
300 					testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
301 			}
302 		}
303 		else
304 		{
305 			testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
306 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
307 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
308 		}
309 	}
310 }
311 
verifyIntegerAnyOf(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)312 void GetBooleanVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
313 {
314 	using tcu::TestLog;
315 
316 	StateQueryMemoryWriteGuard<GLboolean> state;
317 	glGetBooleanv(name, &state);
318 
319 	if (!state.verifyValidity(testCtx))
320 		return;
321 
322 	for (size_t ndx = 0; ndx < referencesLength; ++ndx)
323 	{
324 		const GLboolean expectedGLState = references[ndx] ? GL_TRUE : GL_FALSE;
325 
326 		if (state == expectedGLState)
327 			return;
328 	}
329 
330 	testCtx.getLog() << TestLog::Message << "// ERROR: got " << (state==GL_TRUE ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
331 	if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
332 		testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
333 }
334 
verifyStencilMaskInitial(tcu::TestContext& testCtx, GLenum name, int stencilBits)335 void GetBooleanVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
336 {
337 	// if stencilBits == 0, the mask is allowed to be either GL_TRUE or GL_FALSE
338 	// otherwise it must be GL_TRUE
339 	using tcu::TestLog;
340 
341 	StateQueryMemoryWriteGuard<GLboolean> state;
342 	glGetBooleanv(name, &state);
343 
344 	if (!state.verifyValidity(testCtx))
345 		return;
346 
347 	if (stencilBits > 0 && state != GL_TRUE)
348 	{
349 		testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
350 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
351 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
352 	}
353 }
354 
355 //GetIntegerVerifier
356 
357 class GetIntegerVerifier : public StateVerifier
358 {
359 public:
360 			GetIntegerVerifier			(const glw::Functions& gl, tcu::TestLog& log);
361 	void	verifyInteger						(tcu::TestContext& testCtx, GLenum name, GLint reference);
362 	void	verifyInteger4						(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
363 	void	verifyInteger4Mask					(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
364 	void	verifyIntegerGreaterOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
365 	void	verifyUnsignedIntegerGreaterOrEqual	(tcu::TestContext& testCtx, GLenum name, GLuint reference);
366 	void	verifyIntegerLessOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
367 	void	verifyIntegerGreaterOrEqual2		(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
368 	void	verifyIntegerAnyOf					(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
369 	void	verifyStencilMaskInitial			(tcu::TestContext& testCtx, GLenum name, int stencilBits);
370 };
371 
GetIntegerVerifier(const glw::Functions& gl, tcu::TestLog& log)372 GetIntegerVerifier::GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log)
373 	: StateVerifier(gl, log, "_getinteger")
374 {
375 }
376 
verifyInteger(tcu::TestContext& testCtx, GLenum name, GLint reference)377 void GetIntegerVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
378 {
379 	using tcu::TestLog;
380 
381 	StateQueryMemoryWriteGuard<GLint> state;
382 	glGetIntegerv(name, &state);
383 
384 	if (!state.verifyValidity(testCtx))
385 		return;
386 
387 	if (state != reference)
388 	{
389 		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage;
390 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
391 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
392 	}
393 }
394 
verifyInteger4(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)395 void GetIntegerVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
396 {
397 	verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
398 }
399 
verifyInteger4Mask(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)400 void GetIntegerVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
401 {
402 	using tcu::TestLog;
403 
404 	StateQueryMemoryWriteGuard<GLint[4]> intVector4;
405 	glGetIntegerv(name, intVector4);
406 
407 	if (!intVector4.verifyValidity(testCtx))
408 		return;
409 
410 	if ((enableRef0 && (intVector4[0] != reference0)) ||
411 		(enableRef1 && (intVector4[1] != reference1)) ||
412 		(enableRef2 && (intVector4[2] != reference2)) ||
413 		(enableRef3 && (intVector4[3] != reference3)))
414 	{
415 		testCtx.getLog() << TestLog::Message << "// ERROR: expected "
416 			<< (enableRef0?"":"(") << reference0 << (enableRef0?"":")") << ", "
417 			<< (enableRef1?"":"(") << reference1 << (enableRef1?"":")") << ", "
418 			<< (enableRef2?"":"(") << reference2 << (enableRef2?"":")") << ", "
419 			<< (enableRef3?"":"(") << reference3 << (enableRef3?"":")")	<< TestLog::EndMessage;
420 
421 
422 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
423 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
424 	}
425 }
426 
verifyIntegerGreaterOrEqual(tcu::TestContext& testCtx, GLenum name, GLint reference)427 void GetIntegerVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
428 {
429 	using tcu::TestLog;
430 
431 	StateQueryMemoryWriteGuard<GLint> state;
432 	glGetIntegerv(name, &state);
433 
434 	if (!state.verifyValidity(testCtx))
435 		return;
436 
437 	if (state < reference)
438 	{
439 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << state << TestLog::EndMessage;
440 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
441 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
442 	}
443 }
444 
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext& testCtx, GLenum name, GLuint reference)445 void GetIntegerVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
446 {
447 	using tcu::TestLog;
448 
449 	StateQueryMemoryWriteGuard<GLint> state;
450 	glGetIntegerv(name, &state);
451 
452 	if (!state.verifyValidity(testCtx))
453 		return;
454 
455 	if (GLuint(state) < reference)
456 	{
457 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << GLuint(state) << TestLog::EndMessage;
458 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
459 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
460 	}
461 }
462 
verifyIntegerLessOrEqual(tcu::TestContext& testCtx, GLenum name, GLint reference)463 void GetIntegerVerifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
464 {
465 	using tcu::TestLog;
466 
467 	StateQueryMemoryWriteGuard<GLint> state;
468 	glGetIntegerv(name, &state);
469 
470 	if (!state.verifyValidity(testCtx))
471 		return;
472 
473 	if (state > reference)
474 	{
475 		testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << reference << "; got " << state << TestLog::EndMessage;
476 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
477 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
478 	}
479 }
480 
verifyIntegerGreaterOrEqual2(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)481 void GetIntegerVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
482 {
483 	using tcu::TestLog;
484 
485 	StateQueryMemoryWriteGuard<GLint[2]> intVector2;
486 	glGetIntegerv(name, intVector2);
487 
488 	if (!intVector2.verifyValidity(testCtx))
489 		return;
490 
491 	if (intVector2[0] < reference0 || intVector2[1] < reference1)
492 	{
493 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference0 << ", " << reference1 << "; got " << intVector2[0] << ", " << intVector2[0] << TestLog::EndMessage;
494 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
495 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
496 	}
497 }
498 
verifyIntegerAnyOf(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)499 void GetIntegerVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
500 {
501 	using tcu::TestLog;
502 
503 	StateQueryMemoryWriteGuard<GLint> state;
504 	glGetIntegerv(name, &state);
505 
506 	if (!state.verifyValidity(testCtx))
507 		return;
508 
509 	for (size_t ndx = 0; ndx < referencesLength; ++ndx)
510 	{
511 		const GLint expectedGLState = references[ndx];
512 
513 		if (state == expectedGLState)
514 			return;
515 	}
516 
517 	testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
518 	if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
519 		testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
520 }
521 
verifyStencilMaskInitial(tcu::TestContext& testCtx, GLenum name, int stencilBits)522 void GetIntegerVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
523 {
524 	using tcu::TestLog;
525 
526 	StateQueryMemoryWriteGuard<GLint> state;
527 	glGetIntegerv(name, &state);
528 
529 	if (!state.verifyValidity(testCtx))
530 		return;
531 
532 	const GLint reference = (1 << stencilBits) - 1;
533 
534 	if ((state & reference) != reference) // the least significant stencilBits bits should be on
535 	{
536 		testCtx.getLog() << TestLog::Message << "// ERROR: expected minimum mask of " << reference << "; got " << state << TestLog::EndMessage;
537 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
538 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value");
539 	}
540 }
541 
542 //GetInteger64Verifier
543 
544 class GetInteger64Verifier : public StateVerifier
545 {
546 public:
547 			GetInteger64Verifier			(const glw::Functions& gl, tcu::TestLog& log);
548 	void	verifyInteger						(tcu::TestContext& testCtx, GLenum name, GLint reference);
549 	void	verifyInteger4						(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
550 	void	verifyInteger4Mask					(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
551 	void	verifyIntegerGreaterOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
552 	void	verifyUnsignedIntegerGreaterOrEqual	(tcu::TestContext& testCtx, GLenum name, GLuint reference);
553 	void	verifyIntegerLessOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
554 	void	verifyIntegerGreaterOrEqual2		(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
555 	void	verifyIntegerAnyOf					(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
556 	void	verifyStencilMaskInitial			(tcu::TestContext& testCtx, GLenum name, int stencilBits);
557 };
558 
GetInteger64Verifier(const glw::Functions& gl, tcu::TestLog& log)559 GetInteger64Verifier::GetInteger64Verifier (const glw::Functions& gl, tcu::TestLog& log)
560 	: StateVerifier(gl, log, "_getinteger64")
561 {
562 }
563 
verifyInteger(tcu::TestContext& testCtx, GLenum name, GLint reference)564 void GetInteger64Verifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
565 {
566 	using tcu::TestLog;
567 
568 	StateQueryMemoryWriteGuard<GLint64> state;
569 	glGetInteger64v(name, &state);
570 
571 	if (!state.verifyValidity(testCtx))
572 		return;
573 
574 	if (state != GLint64(reference))
575 	{
576 		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage;
577 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
578 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
579 	}
580 }
581 
verifyInteger4(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)582 void GetInteger64Verifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
583 {
584 	verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
585 }
586 
verifyInteger4Mask(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)587 void GetInteger64Verifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
588 {
589 	using tcu::TestLog;
590 
591 	StateQueryMemoryWriteGuard<GLint64[4]> intVector4;
592 	glGetInteger64v(name, intVector4);
593 
594 	if (!intVector4.verifyValidity(testCtx))
595 		return;
596 
597 	if ((enableRef0 && (intVector4[0] != GLint64(reference0))) ||
598 		(enableRef1 && (intVector4[1] != GLint64(reference1))) ||
599 		(enableRef2 && (intVector4[2] != GLint64(reference2))) ||
600 		(enableRef3 && (intVector4[3] != GLint64(reference3))))
601 	{
602 		testCtx.getLog() << TestLog::Message << "// ERROR: expected "
603 			<< (enableRef0?"":"(") << reference0 << (enableRef0?"":")") << ", "
604 			<< (enableRef1?"":"(") << reference1 << (enableRef1?"":")") << ", "
605 			<< (enableRef2?"":"(") << reference2 << (enableRef2?"":")") << ", "
606 			<< (enableRef3?"":"(") << reference3 << (enableRef3?"":")")	<< TestLog::EndMessage;
607 
608 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
609 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
610 	}
611 }
612 
verifyIntegerGreaterOrEqual(tcu::TestContext& testCtx, GLenum name, GLint reference)613 void GetInteger64Verifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
614 {
615 	using tcu::TestLog;
616 
617 	StateQueryMemoryWriteGuard<GLint64> state;
618 	glGetInteger64v(name, &state);
619 
620 	if (!state.verifyValidity(testCtx))
621 		return;
622 
623 	if (state < GLint64(reference))
624 	{
625 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference) << "; got " << state << TestLog::EndMessage;
626 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
627 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
628 	}
629 }
630 
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext& testCtx, GLenum name, GLuint reference)631 void GetInteger64Verifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
632 {
633 	using tcu::TestLog;
634 
635 	StateQueryMemoryWriteGuard<GLint64> state;
636 	glGetInteger64v(name, &state);
637 
638 	if (!state.verifyValidity(testCtx))
639 		return;
640 
641 	if (GLuint(state) < GLint64(reference))
642 	{
643 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference) << "; got " << GLuint(state) << TestLog::EndMessage;
644 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
645 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
646 	}
647 }
648 
verifyIntegerLessOrEqual(tcu::TestContext& testCtx, GLenum name, GLint reference)649 void GetInteger64Verifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
650 {
651 	using tcu::TestLog;
652 
653 	StateQueryMemoryWriteGuard<GLint64> state;
654 	glGetInteger64v(name, &state);
655 
656 	if (!state.verifyValidity(testCtx))
657 		return;
658 
659 	if (state > GLint64(reference))
660 	{
661 		testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << GLint64(reference) << "; got " << state << TestLog::EndMessage;
662 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
663 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
664 	}
665 }
666 
verifyIntegerGreaterOrEqual2(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)667 void GetInteger64Verifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
668 {
669 	using tcu::TestLog;
670 
671 	StateQueryMemoryWriteGuard<GLint64[2]> intVector2;
672 	glGetInteger64v(name, intVector2);
673 
674 	if (!intVector2.verifyValidity(testCtx))
675 		return;
676 
677 	if (intVector2[0] < GLint64(reference0) || intVector2[1] < GLint64(reference1))
678 	{
679 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference0) << ", " << GLint64(reference1) << "; got " << intVector2[0] << ", " << intVector2[1] << TestLog::EndMessage;
680 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
681 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
682 	}
683 }
684 
verifyIntegerAnyOf(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)685 void GetInteger64Verifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
686 {
687 	using tcu::TestLog;
688 
689 	StateQueryMemoryWriteGuard<GLint64> state;
690 	glGetInteger64v(name, &state);
691 
692 	if (!state.verifyValidity(testCtx))
693 		return;
694 
695 	for (size_t ndx = 0; ndx < referencesLength; ++ndx)
696 	{
697 		const GLint64 expectedGLState = GLint64(references[ndx]);
698 
699 		if (state == expectedGLState)
700 			return;
701 	}
702 
703 	testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
704 	if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
705 		testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
706 }
707 
verifyStencilMaskInitial(tcu::TestContext& testCtx, GLenum name, int stencilBits)708 void GetInteger64Verifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
709 {
710 	using tcu::TestLog;
711 
712 	StateQueryMemoryWriteGuard<GLint64> state;
713 	glGetInteger64v(name, &state);
714 
715 	if (!state.verifyValidity(testCtx))
716 		return;
717 
718 	const GLint64 reference = (1ULL << stencilBits) - 1;
719 
720 	if ((state & reference) != reference) // the least significant stencilBits bits should be on
721 	{
722 		testCtx.getLog() << TestLog::Message << "// ERROR: expected mimimum mask of " << reference << "; got " << state << TestLog::EndMessage;
723 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
724 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value");
725 	}
726 }
727 
728 //GetFloatVerifier
729 
730 class GetFloatVerifier : public StateVerifier
731 {
732 public:
733 			GetFloatVerifier				(const glw::Functions& gl, tcu::TestLog& log);
734 	void	verifyInteger						(tcu::TestContext& testCtx, GLenum name, GLint reference);
735 	void	verifyInteger4						(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
736 	void	verifyInteger4Mask					(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
737 	void	verifyIntegerGreaterOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
738 	void	verifyUnsignedIntegerGreaterOrEqual	(tcu::TestContext& testCtx, GLenum name, GLuint reference);
739 	void	verifyIntegerLessOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
740 	void	verifyIntegerGreaterOrEqual2		(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
741 	void	verifyIntegerAnyOf					(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
742 	void	verifyStencilMaskInitial			(tcu::TestContext& testCtx, GLenum name, int stencilBits);
743 };
744 
GetFloatVerifier(const glw::Functions& gl, tcu::TestLog& log)745 GetFloatVerifier::GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log)
746 	: StateVerifier(gl, log, "_getfloat")
747 {
748 }
749 
verifyInteger(tcu::TestContext& testCtx, GLenum name, GLint reference)750 void GetFloatVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
751 {
752 	using tcu::TestLog;
753 
754 	const GLfloat referenceAsFloat = GLfloat(reference);
755 	DE_ASSERT(reference == GLint(referenceAsFloat)); // reference integer must have 1:1 mapping to float for this to work. Reference value is always such value in these tests
756 
757 	StateQueryMemoryWriteGuard<GLfloat> state;
758 	glGetFloatv(name, &state);
759 
760 	if (!state.verifyValidity(testCtx))
761 		return;
762 
763 	if (state != referenceAsFloat)
764 	{
765 		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsFloat << "; got " << state << TestLog::EndMessage;
766 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
767 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
768 	}
769 }
770 
verifyInteger4(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)771 void GetFloatVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
772 {
773 	verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
774 }
775 
verifyInteger4Mask(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)776 void GetFloatVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
777 {
778 	using tcu::TestLog;
779 
780 	StateQueryMemoryWriteGuard<GLfloat[4]> floatVector4;
781 	glGetFloatv(name, floatVector4);
782 
783 	if (!floatVector4.verifyValidity(testCtx))
784 		return;
785 
786 	if ((enableRef0 && (floatVector4[0] != GLfloat(reference0))) ||
787 		(enableRef1 && (floatVector4[1] != GLfloat(reference1))) ||
788 		(enableRef2 && (floatVector4[2] != GLfloat(reference2))) ||
789 		(enableRef3 && (floatVector4[3] != GLfloat(reference3))))
790 	{
791 		testCtx.getLog() << TestLog::Message << "// ERROR: expected "
792 			<< (enableRef0?"":"(") << GLfloat(reference0) << (enableRef0?"":")") << ", "
793 			<< (enableRef1?"":"(") << GLfloat(reference1) << (enableRef1?"":")") << ", "
794 			<< (enableRef2?"":"(") << GLfloat(reference2) << (enableRef2?"":")") << ", "
795 			<< (enableRef3?"":"(") << GLfloat(reference3) << (enableRef3?"":")") << TestLog::EndMessage;
796 
797 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
798 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
799 	}
800 }
801 
verifyIntegerGreaterOrEqual(tcu::TestContext& testCtx, GLenum name, GLint reference)802 void GetFloatVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
803 {
804 	using tcu::TestLog;
805 
806 	StateQueryMemoryWriteGuard<GLfloat> state;
807 	glGetFloatv(name, &state);
808 
809 	if (!state.verifyValidity(testCtx))
810 		return;
811 
812 	if (state < GLfloat(reference))
813 	{
814 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage;
815 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
816 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
817 	}
818 }
819 
verifyUnsignedIntegerGreaterOrEqual(tcu::TestContext& testCtx, GLenum name, GLuint reference)820 void GetFloatVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
821 {
822 	using tcu::TestLog;
823 
824 	StateQueryMemoryWriteGuard<GLfloat> state;
825 	glGetFloatv(name, &state);
826 
827 	if (!state.verifyValidity(testCtx))
828 		return;
829 
830 	if (state < GLfloat(reference))
831 	{
832 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage;
833 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
834 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
835 	}
836 }
837 
verifyIntegerLessOrEqual(tcu::TestContext& testCtx, GLenum name, GLint reference)838 void GetFloatVerifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
839 {
840 	using tcu::TestLog;
841 
842 	StateQueryMemoryWriteGuard<GLfloat> state;
843 	glGetFloatv(name, &state);
844 
845 	if (!state.verifyValidity(testCtx))
846 		return;
847 
848 	if (state > GLfloat(reference))
849 	{
850 		testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage;
851 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
852 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
853 	}
854 }
855 
verifyIntegerGreaterOrEqual2(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)856 void GetFloatVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
857 {
858 	using tcu::TestLog;
859 
860 	StateQueryMemoryWriteGuard<GLfloat[2]> floatVector2;
861 	glGetFloatv(name, floatVector2);
862 
863 	if (!floatVector2.verifyValidity(testCtx))
864 		return;
865 
866 	if (floatVector2[0] < GLfloat(reference0) || floatVector2[1] < GLfloat(reference1))
867 	{
868 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference0) << ", " << GLfloat(reference1) << "; got " << floatVector2[0] << ", " << floatVector2[1] << TestLog::EndMessage;
869 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
870 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
871 	}
872 }
873 
verifyIntegerAnyOf(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)874 void GetFloatVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
875 {
876 	using tcu::TestLog;
877 
878 	StateQueryMemoryWriteGuard<GLfloat> state;
879 	glGetFloatv(name, &state);
880 
881 	if (!state.verifyValidity(testCtx))
882 		return;
883 
884 	for (size_t ndx = 0; ndx < referencesLength; ++ndx)
885 	{
886 		const GLfloat expectedGLState = GLfloat(references[ndx]);
887 		DE_ASSERT(references[ndx] == GLint(expectedGLState)); // reference integer must have 1:1 mapping to float for this to work. Reference value is always such value in these tests
888 
889 		if (state == expectedGLState)
890 			return;
891 	}
892 
893 	testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
894 	if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
895 		testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
896 }
897 
verifyStencilMaskInitial(tcu::TestContext& testCtx, GLenum name, int stencilBits)898 void GetFloatVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
899 {
900 	// checking the mask bits with float doesn't make much sense because of conversion errors
901 	// just verify that the value is greater or equal to the minimum value
902 	const GLint reference = (1 << stencilBits) - 1;
903 	verifyIntegerGreaterOrEqual(testCtx, name, reference);
904 }
905 
906 } // IntegerStateQueryVerifiers
907 
908 namespace
909 {
910 
911 using namespace IntegerStateQueryVerifiers;
912 using namespace deqp::gls::StateQueryUtil;
913 
914 class ConstantMinimumValueTestCase : public ApiCase
915 {
916 public:
ConstantMinimumValueTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue)917 	ConstantMinimumValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue)
918 		: ApiCase		(context, name, description)
919 		, m_targetName	(targetName)
920 		, m_minValue	(minValue)
921 		, m_verifier	(verifier)
922 	{
923 	}
924 
test(void)925 	void test (void)
926 	{
927 		m_verifier->verifyUnsignedIntegerGreaterOrEqual(m_testCtx, m_targetName, m_minValue);
928 		expectError(GL_NO_ERROR);
929 	}
930 
931 private:
932 	GLenum			m_targetName;
933 	GLint			m_minValue;
934 	StateVerifier*	m_verifier;
935 };
936 
937 class ConstantMaximumValueTestCase : public ApiCase
938 {
939 public:
ConstantMaximumValueTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue)940 	ConstantMaximumValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue)
941 		: ApiCase		(context, name, description)
942 		, m_targetName	(targetName)
943 		, m_minValue	(minValue)
944 		, m_verifier	(verifier)
945 	{
946 	}
947 
test(void)948 	void test (void)
949 	{
950 		m_verifier->verifyIntegerLessOrEqual(m_testCtx, m_targetName, m_minValue);
951 		expectError(GL_NO_ERROR);
952 	}
953 
954 private:
955 	GLenum			m_targetName;
956 	GLint			m_minValue;
957 	StateVerifier*	m_verifier;
958 };
959 
960 class SampleBuffersTestCase : public ApiCase
961 {
962 public:
SampleBuffersTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)963 	SampleBuffersTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
964 		: ApiCase		(context, name, description)
965 		, m_verifier	(verifier)
966 	{
967 	}
968 
test(void)969 	void test (void)
970 	{
971 		const int expectedSampleBuffers = (m_context.getRenderTarget().getNumSamples() > 1) ? 1 : 0;
972 
973 		m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << ", expecting GL_SAMPLE_BUFFERS to be " << expectedSampleBuffers << tcu::TestLog::EndMessage;
974 
975 		m_verifier->verifyInteger(m_testCtx, GL_SAMPLE_BUFFERS, expectedSampleBuffers);
976 		expectError(GL_NO_ERROR);
977 	}
978 
979 private:
980 	StateVerifier*	m_verifier;
981 };
982 
983 class SamplesTestCase : public ApiCase
984 {
985 public:
SamplesTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)986 	SamplesTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
987 		: ApiCase		(context, name, description)
988 		, m_verifier	(verifier)
989 	{
990 	}
991 
test(void)992 	void test (void)
993 	{
994 		// MSAA?
995 		if (m_context.getRenderTarget().getNumSamples() > 1)
996 		{
997 			m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << tcu::TestLog::EndMessage;
998 
999 			m_verifier->verifyInteger(m_testCtx, GL_SAMPLES, m_context.getRenderTarget().getNumSamples());
1000 			expectError(GL_NO_ERROR);
1001 		}
1002 		else
1003 		{
1004 			const glw::GLint validSamples[] = {0, 1};
1005 
1006 			m_log << tcu::TestLog::Message << "Expecting GL_SAMPLES to be 0 or 1" << tcu::TestLog::EndMessage;
1007 
1008 			m_verifier->verifyIntegerAnyOf(m_testCtx, GL_SAMPLES, validSamples, DE_LENGTH_OF_ARRAY(validSamples));
1009 			expectError(GL_NO_ERROR);
1010 		}
1011 	}
1012 
1013 private:
1014 	StateVerifier*	m_verifier;
1015 };
1016 
1017 class HintTestCase : public ApiCase
1018 {
1019 public:
HintTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName)1020 	HintTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName)
1021 		: ApiCase		(context, name, description)
1022 		, m_targetName	(targetName)
1023 		, m_verifier	(verifier)
1024 	{
1025 	}
1026 
test(void)1027 	void test (void)
1028 	{
1029 		m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE);
1030 		expectError(GL_NO_ERROR);
1031 
1032 		glHint(m_targetName, GL_NICEST);
1033 		m_verifier->verifyInteger(m_testCtx, m_targetName, GL_NICEST);
1034 		expectError(GL_NO_ERROR);
1035 
1036 		glHint(m_targetName, GL_FASTEST);
1037 		m_verifier->verifyInteger(m_testCtx, m_targetName, GL_FASTEST);
1038 		expectError(GL_NO_ERROR);
1039 
1040 		glHint(m_targetName, GL_DONT_CARE);
1041 		m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE);
1042 		expectError(GL_NO_ERROR);
1043 	}
1044 
1045 private:
1046 	GLenum		m_targetName;
1047 	StateVerifier*	m_verifier;
1048 };
1049 
1050 class DepthFuncTestCase : public ApiCase
1051 {
1052 public:
DepthFuncTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)1053 	DepthFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1054 		: ApiCase		(context, name, description)
1055 		, m_verifier	(verifier)
1056 	{
1057 	}
1058 
test(void)1059 	void test (void)
1060 	{
1061 		m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, GL_LESS);
1062 		expectError(GL_NO_ERROR);
1063 
1064 		const GLenum depthFunctions[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GREATER, GL_GEQUAL, GL_NOTEQUAL};
1065 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthFunctions); ndx++)
1066 		{
1067 			glDepthFunc(depthFunctions[ndx]);
1068 			expectError(GL_NO_ERROR);
1069 
1070 			m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, depthFunctions[ndx]);
1071 			expectError(GL_NO_ERROR);
1072 		}
1073 	}
1074 
1075 private:
1076 	StateVerifier*	m_verifier;
1077 };
1078 
1079 class CullFaceTestCase : public ApiCase
1080 {
1081 public:
CullFaceTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)1082 	CullFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1083 		: ApiCase		(context, name, description)
1084 		, m_verifier	(verifier)
1085 	{
1086 	}
1087 
test(void)1088 	void test (void)
1089 	{
1090 		m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, GL_BACK);
1091 		expectError(GL_NO_ERROR);
1092 
1093 		const GLenum cullFaces[] = {GL_FRONT, GL_BACK, GL_FRONT_AND_BACK};
1094 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cullFaces); ndx++)
1095 		{
1096 			glCullFace(cullFaces[ndx]);
1097 			expectError(GL_NO_ERROR);
1098 
1099 			m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, cullFaces[ndx]);
1100 			expectError(GL_NO_ERROR);
1101 		}
1102 	}
1103 
1104 private:
1105 	StateVerifier*	m_verifier;
1106 };
1107 
1108 class FrontFaceTestCase : public ApiCase
1109 {
1110 public:
FrontFaceTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)1111 	FrontFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1112 		: ApiCase		(context, name, description)
1113 		, m_verifier	(verifier)
1114 	{
1115 	}
1116 
test(void)1117 	void test (void)
1118 	{
1119 		m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, GL_CCW);
1120 		expectError(GL_NO_ERROR);
1121 
1122 		const GLenum frontFaces[] = {GL_CW, GL_CCW};
1123 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(frontFaces); ndx++)
1124 		{
1125 			glFrontFace(frontFaces[ndx]);
1126 			expectError(GL_NO_ERROR);
1127 
1128 			m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, frontFaces[ndx]);
1129 			expectError(GL_NO_ERROR);
1130 		}
1131 	}
1132 
1133 private:
1134 	StateVerifier*	m_verifier;
1135 };
1136 
1137 class ViewPortTestCase : public ApiCase
1138 {
1139 public:
ViewPortTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)1140 	ViewPortTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1141 		: ApiCase		(context, name, description)
1142 		, m_verifier	(verifier)
1143 	{
1144 	}
1145 
test(void)1146 	void test (void)
1147 	{
1148 		de::Random rnd(0xabcdef);
1149 
1150 		GLint maxViewportDimensions[2] = {0};
1151 		GLfloat viewportBoundsRange[2] = {0.0f};
1152 		GLboolean hasViewportArray = false;
1153 		glGetIntegerv(GL_MAX_VIEWPORT_DIMS, maxViewportDimensions);
1154 		hasViewportArray = m_context.getContextInfo().isExtensionSupported("GL_OES_viewport_array") ||
1155 				   m_context.getContextInfo().isExtensionSupported("GL_NV_viewport_array") ||
1156 				   m_context.getContextInfo().isExtensionSupported("GL_ARB_viewport_array");
1157 		if (hasViewportArray)
1158 		{
1159 			glGetFloatv(GL_VIEWPORT_BOUNDS_RANGE, viewportBoundsRange);
1160 		}
1161 
1162 		// verify initial value of first two values
1163 		m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, 0, 0, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight());
1164 		expectError(GL_NO_ERROR);
1165 
1166 		const int numIterations = 120;
1167 		for (int i = 0; i < numIterations; ++i)
1168 		{
1169 			GLint x			= rnd.getInt(-64000, 64000);
1170 			GLint y			= rnd.getInt(-64000, 64000);
1171 			GLsizei width	= rnd.getInt(0, maxViewportDimensions[0]);
1172 			GLsizei height	= rnd.getInt(0, maxViewportDimensions[1]);
1173 
1174 			glViewport(x, y, width, height);
1175 
1176 			if (hasViewportArray)
1177 			{
1178 				m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT,
1179 										   de::clamp(x, deFloorFloatToInt32(viewportBoundsRange[0]), deFloorFloatToInt32(viewportBoundsRange[1])),
1180 										   de::clamp(y, deFloorFloatToInt32(viewportBoundsRange[0]), deFloorFloatToInt32(viewportBoundsRange[1])),
1181 										   width, height);
1182 			}
1183 			else
1184 			{
1185 				m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, x, y, width, height);
1186 			}
1187 
1188 			expectError(GL_NO_ERROR);
1189 		}
1190 	}
1191 
1192 private:
1193 	StateVerifier*	m_verifier;
1194 };
1195 
1196 class ScissorBoxTestCase : public ApiCase
1197 {
1198 public:
ScissorBoxTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)1199 	ScissorBoxTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1200 		: ApiCase		(context, name, description)
1201 		, m_verifier	(verifier)
1202 	{
1203 	}
1204 
test(void)1205 	void test (void)
1206 	{
1207 		de::Random rnd(0xabcdef);
1208 
1209 		// verify initial value of first two values
1210 		m_verifier->verifyInteger4Mask(m_testCtx, GL_SCISSOR_BOX, 0, true, 0, true, 0, false, 0, false);
1211 		expectError(GL_NO_ERROR);
1212 
1213 		const int numIterations = 120;
1214 		for (int i = 0; i < numIterations; ++i)
1215 		{
1216 			GLint left		= rnd.getInt(-64000, 64000);
1217 			GLint bottom	= rnd.getInt(-64000, 64000);
1218 			GLsizei width	= rnd.getInt(0, 64000);
1219 			GLsizei height	= rnd.getInt(0, 64000);
1220 
1221 			glScissor(left, bottom, width, height);
1222 			m_verifier->verifyInteger4(m_testCtx, GL_SCISSOR_BOX, left, bottom, width, height);
1223 			expectError(GL_NO_ERROR);
1224 		}
1225 	}
1226 private:
1227 	StateVerifier*	m_verifier;
1228 };
1229 
1230 class MaxViewportDimsTestCase : public ApiCase
1231 {
1232 public:
MaxViewportDimsTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)1233 	MaxViewportDimsTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1234 		: ApiCase		(context, name, description)
1235 		, m_verifier	(verifier)
1236 	{
1237 	}
1238 
test(void)1239 	void test (void)
1240 	{
1241 		m_verifier->verifyIntegerGreaterOrEqual2(m_testCtx, GL_MAX_VIEWPORT_DIMS, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight());
1242 		expectError(GL_NO_ERROR);
1243 	}
1244 private:
1245 	StateVerifier*	m_verifier;
1246 };
1247 
1248 class StencilRefTestCase : public ApiCase
1249 {
1250 public:
StencilRefTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)1251 	StencilRefTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
1252 		: ApiCase			(context, name, description)
1253 		, m_verifier		(verifier)
1254 		, m_testTargetName	(testTargetName)
1255 	{
1256 	}
1257 
test(void)1258 	void test (void)
1259 	{
1260 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0);
1261 		expectError(GL_NO_ERROR);
1262 
1263 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
1264 
1265 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1266 		{
1267 			const int ref = 1 << stencilBit;
1268 
1269 			glStencilFunc(GL_ALWAYS, ref, 0); // mask should not affect the REF
1270 			expectError(GL_NO_ERROR);
1271 
1272 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1273 			expectError(GL_NO_ERROR);
1274 
1275 			glStencilFunc(GL_ALWAYS, ref, ref);
1276 			expectError(GL_NO_ERROR);
1277 
1278 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1279 			expectError(GL_NO_ERROR);
1280 		}
1281 	}
1282 
1283 private:
1284 	StateVerifier*	m_verifier;
1285 	GLenum		m_testTargetName;
1286 };
1287 
1288 class StencilRefSeparateTestCase : public ApiCase
1289 {
1290 public:
StencilRefSeparateTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace)1291 	StencilRefSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace)
1292 		: ApiCase					(context, name, description)
1293 		, m_verifier				(verifier)
1294 		, m_testTargetName			(testTargetName)
1295 		, m_stencilFuncTargetFace	(stencilFuncTargetFace)
1296 	{
1297 	}
1298 
test(void)1299 	void test (void)
1300 	{
1301 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0);
1302 		expectError(GL_NO_ERROR);
1303 
1304 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
1305 
1306 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1307 		{
1308 			const int ref = 1 << stencilBit;
1309 
1310 			glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, 0);
1311 			expectError(GL_NO_ERROR);
1312 
1313 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1314 			expectError(GL_NO_ERROR);
1315 
1316 			glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, ref);
1317 			expectError(GL_NO_ERROR);
1318 
1319 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
1320 			expectError(GL_NO_ERROR);
1321 		}
1322 	}
1323 private:
1324 	StateVerifier*	m_verifier;
1325 	GLenum		m_testTargetName;
1326 	GLenum		m_stencilFuncTargetFace;
1327 };
1328 
1329 class StencilOpTestCase : public ApiCase
1330 {
1331 public:
StencilOpTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName)1332 	StencilOpTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName)
1333 		: ApiCase					(context, name, description)
1334 		, m_verifier				(verifier)
1335 		, m_stencilOpName			(stencilOpName)
1336 	{
1337 	}
1338 
test(void)1339 	void test (void)
1340 	{
1341 		m_verifier->verifyInteger(m_testCtx, m_stencilOpName, GL_KEEP);
1342 		expectError(GL_NO_ERROR);
1343 
1344 		const GLenum stencilOpValues[] = {GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP};
1345 
1346 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilOpValues); ++ndx)
1347 		{
1348 			SetStencilOp(stencilOpValues[ndx]);
1349 			expectError(GL_NO_ERROR);
1350 
1351 			m_verifier->verifyInteger(m_testCtx, m_stencilOpName, stencilOpValues[ndx]);
1352 			expectError(GL_NO_ERROR);
1353 		}
1354 	}
1355 
1356 protected:
SetStencilOp(GLenum stencilOpValue)1357 	virtual void SetStencilOp (GLenum stencilOpValue)
1358 	{
1359 		switch (m_stencilOpName)
1360 		{
1361 		case GL_STENCIL_FAIL:
1362 		case GL_STENCIL_BACK_FAIL:
1363 			glStencilOp(stencilOpValue, GL_KEEP, GL_KEEP);
1364 			break;
1365 
1366 		case GL_STENCIL_PASS_DEPTH_FAIL:
1367 		case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1368 			glStencilOp(GL_KEEP, stencilOpValue, GL_KEEP);
1369 			break;
1370 
1371 		case GL_STENCIL_PASS_DEPTH_PASS:
1372 		case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1373 			glStencilOp(GL_KEEP, GL_KEEP, stencilOpValue);
1374 			break;
1375 
1376 		default:
1377 			DE_ASSERT(false && "should not happen");
1378 			break;
1379 		}
1380 	}
1381 
1382 	StateVerifier*				m_verifier;
1383 	GLenum					m_stencilOpName;
1384 };
1385 
1386 
1387 class StencilOpSeparateTestCase : public StencilOpTestCase
1388 {
1389 public:
StencilOpSeparateTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName, GLenum stencilOpFace)1390 	StencilOpSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName, GLenum stencilOpFace)
1391 		: StencilOpTestCase		(context, verifier, name, description, stencilOpName)
1392 		, m_stencilOpFace		(stencilOpFace)
1393 	{
1394 	}
1395 
1396 private:
SetStencilOp(GLenum stencilOpValue)1397 	void SetStencilOp (GLenum stencilOpValue)
1398 	{
1399 		switch (m_stencilOpName)
1400 		{
1401 		case GL_STENCIL_FAIL:
1402 		case GL_STENCIL_BACK_FAIL:
1403 			glStencilOpSeparate(m_stencilOpFace, stencilOpValue, GL_KEEP, GL_KEEP);
1404 			break;
1405 
1406 		case GL_STENCIL_PASS_DEPTH_FAIL:
1407 		case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
1408 			glStencilOpSeparate(m_stencilOpFace, GL_KEEP, stencilOpValue, GL_KEEP);
1409 			break;
1410 
1411 		case GL_STENCIL_PASS_DEPTH_PASS:
1412 		case GL_STENCIL_BACK_PASS_DEPTH_PASS:
1413 			glStencilOpSeparate(m_stencilOpFace, GL_KEEP, GL_KEEP, stencilOpValue);
1414 			break;
1415 
1416 		default:
1417 			DE_ASSERT(false && "should not happen");
1418 			break;
1419 		}
1420 	}
1421 
1422 	GLenum		m_stencilOpFace;
1423 };
1424 
1425 class StencilFuncTestCase : public ApiCase
1426 {
1427 public:
StencilFuncTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)1428 	StencilFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
1429 		: ApiCase		(context, name, description)
1430 		, m_verifier	(verifier)
1431 	{
1432 	}
1433 
test(void)1434 	void test (void)
1435 	{
1436 		m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, GL_ALWAYS);
1437 		expectError(GL_NO_ERROR);
1438 
1439 		const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL};
1440 
1441 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx)
1442 		{
1443 			glStencilFunc(stencilfuncValues[ndx], 0, 0);
1444 			expectError(GL_NO_ERROR);
1445 
1446 			m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, stencilfuncValues[ndx]);
1447 			expectError(GL_NO_ERROR);
1448 
1449 			m_verifier->verifyInteger(m_testCtx, GL_STENCIL_BACK_FUNC, stencilfuncValues[ndx]);
1450 			expectError(GL_NO_ERROR);
1451 		}
1452 	}
1453 private:
1454 	StateVerifier*	m_verifier;
1455 };
1456 
1457 class StencilFuncSeparateTestCase : public ApiCase
1458 {
1459 public:
StencilFuncSeparateTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilFuncName, GLenum stencilFuncFace)1460 	StencilFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilFuncName, GLenum stencilFuncFace)
1461 		: ApiCase			(context, name, description)
1462 		, m_verifier		(verifier)
1463 		, m_stencilFuncName	(stencilFuncName)
1464 		, m_stencilFuncFace	(stencilFuncFace)
1465 	{
1466 	}
1467 
test(void)1468 	void test (void)
1469 	{
1470 		m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, GL_ALWAYS);
1471 		expectError(GL_NO_ERROR);
1472 
1473 		const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL};
1474 
1475 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx)
1476 		{
1477 			glStencilFuncSeparate(m_stencilFuncFace, stencilfuncValues[ndx], 0, 0);
1478 			expectError(GL_NO_ERROR);
1479 
1480 			m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, stencilfuncValues[ndx]);
1481 			expectError(GL_NO_ERROR);
1482 		}
1483 	}
1484 private:
1485 	StateVerifier*	m_verifier;
1486 	GLenum		m_stencilFuncName;
1487 	GLenum		m_stencilFuncFace;
1488 };
1489 
1490 class StencilMaskTestCase : public ApiCase
1491 {
1492 public:
StencilMaskTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)1493 	StencilMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
1494 		: ApiCase			(context, name, description)
1495 		, m_verifier		(verifier)
1496 		, m_testTargetName	(testTargetName)
1497 	{
1498 	}
1499 
test(void)1500 	void test (void)
1501 	{
1502 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
1503 
1504 		m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits);
1505 		expectError(GL_NO_ERROR);
1506 
1507 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1508 		{
1509 			const int mask = 1 << stencilBit;
1510 
1511 			glStencilFunc(GL_ALWAYS, 0, mask);
1512 			expectError(GL_NO_ERROR);
1513 
1514 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1515 			expectError(GL_NO_ERROR);
1516 		}
1517 	}
1518 private:
1519 	StateVerifier*	m_verifier;
1520 	GLenum		m_testTargetName;
1521 };
1522 
1523 class StencilMaskSeparateTestCase : public ApiCase
1524 {
1525 public:
StencilMaskSeparateTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace)1526 	StencilMaskSeparateTestCase	(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace)
1527 		: ApiCase					(context, name, description)
1528 		, m_verifier				(verifier)
1529 		, m_testTargetName			(testTargetName)
1530 		, m_stencilFuncTargetFace	(stencilFuncTargetFace)
1531 	{
1532 	}
1533 
test(void)1534 	void test (void)
1535 	{
1536 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
1537 
1538 		m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits);
1539 		expectError(GL_NO_ERROR);
1540 
1541 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1542 		{
1543 			const int mask = 1 << stencilBit;
1544 
1545 			glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, 0, mask);
1546 			expectError(GL_NO_ERROR);
1547 
1548 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1549 			expectError(GL_NO_ERROR);
1550 		}
1551 	}
1552 private:
1553 	StateVerifier*	m_verifier;
1554 	GLenum		m_testTargetName;
1555 	GLenum		m_stencilFuncTargetFace;
1556 };
1557 
1558 class StencilWriteMaskTestCase : public ApiCase
1559 {
1560 public:
StencilWriteMaskTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)1561 	StencilWriteMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
1562 		: ApiCase			(context, name, description)
1563 		, m_verifier		(verifier)
1564 		, m_testTargetName	(testTargetName)
1565 	{
1566 	}
1567 
test(void)1568 	void test (void)
1569 	{
1570 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
1571 
1572 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1573 		{
1574 			const int mask = 1 << stencilBit;
1575 
1576 			glStencilMask(mask);
1577 			expectError(GL_NO_ERROR);
1578 
1579 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1580 			expectError(GL_NO_ERROR);
1581 		}
1582 	}
1583 private:
1584 	StateVerifier*	m_verifier;
1585 	GLenum		m_testTargetName;
1586 };
1587 
1588 class StencilWriteMaskSeparateTestCase : public ApiCase
1589 {
1590 public:
StencilWriteMaskSeparateTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilTargetFace)1591 	StencilWriteMaskSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilTargetFace)
1592 		: ApiCase				(context, name, description)
1593 		, m_verifier			(verifier)
1594 		, m_testTargetName		(testTargetName)
1595 		, m_stencilTargetFace	(stencilTargetFace)
1596 	{
1597 	}
1598 
test(void)1599 	void test (void)
1600 	{
1601 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
1602 
1603 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
1604 		{
1605 			const int mask = 1 << stencilBit;
1606 
1607 			glStencilMaskSeparate(m_stencilTargetFace, mask);
1608 			expectError(GL_NO_ERROR);
1609 
1610 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
1611 			expectError(GL_NO_ERROR);
1612 		}
1613 	}
1614 private:
1615 	StateVerifier*	m_verifier;
1616 	GLenum		m_testTargetName;
1617 	GLenum		m_stencilTargetFace;
1618 };
1619 
1620 class PixelStoreTestCase : public ApiCase
1621 {
1622 public:
PixelStoreTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)1623 	PixelStoreTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1624 		: ApiCase			(context, name, description)
1625 		, m_verifier		(verifier)
1626 		, m_testTargetName	(testTargetName)
1627 		, m_initialValue	(initialValue)
1628 	{
1629 	}
1630 
test(void)1631 	void test (void)
1632 	{
1633 		de::Random rnd(0xabcdef);
1634 
1635 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
1636 		expectError(GL_NO_ERROR);
1637 
1638 		const int numIterations = 120;
1639 		for (int i = 0; i < numIterations; ++i)
1640 		{
1641 			const int referenceValue = rnd.getInt(0, 64000);
1642 
1643 			glPixelStorei(m_testTargetName, referenceValue);
1644 			expectError(GL_NO_ERROR);
1645 
1646 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1647 			expectError(GL_NO_ERROR);
1648 		}
1649 	}
1650 
1651 private:
1652 	StateVerifier*	m_verifier;
1653 	GLenum		m_testTargetName;
1654 	int			m_initialValue;
1655 };
1656 
1657 class PixelStoreAlignTestCase : public ApiCase
1658 {
1659 public:
PixelStoreAlignTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)1660 	PixelStoreAlignTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
1661 		: ApiCase			(context, name, description)
1662 		, m_verifier		(verifier)
1663 		, m_testTargetName	(testTargetName)
1664 	{
1665 	}
1666 
test(void)1667 	void test (void)
1668 	{
1669 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, 4);
1670 		expectError(GL_NO_ERROR);
1671 
1672 		const int alignments[] = {1, 2, 4, 8};
1673 
1674 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(alignments); ++ndx)
1675 		{
1676 			const int referenceValue = alignments[ndx];
1677 
1678 			glPixelStorei(m_testTargetName, referenceValue);
1679 			expectError(GL_NO_ERROR);
1680 
1681 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1682 			expectError(GL_NO_ERROR);
1683 		}
1684 	}
1685 
1686 private:
1687 	StateVerifier*	m_verifier;
1688 	GLenum		m_testTargetName;
1689 };
1690 
1691 class BlendFuncTestCase : public ApiCase
1692 {
1693 public:
BlendFuncTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)1694 	BlendFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1695 		: ApiCase			(context, name, description)
1696 		, m_verifier		(verifier)
1697 		, m_testTargetName	(testTargetName)
1698 		, m_initialValue	(initialValue)
1699 	{
1700 	}
1701 
test(void)1702 	void test (void)
1703 	{
1704 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
1705 		expectError(GL_NO_ERROR);
1706 
1707 		const GLenum blendFuncValues[] =
1708 		{
1709 			GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,
1710 			GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR,
1711 			GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA,
1712 			GL_SRC_ALPHA_SATURATE
1713 		};
1714 
1715 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx)
1716 		{
1717 			const GLenum referenceValue = blendFuncValues[ndx];
1718 
1719 			SetBlendFunc(referenceValue);
1720 			expectError(GL_NO_ERROR);
1721 
1722 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1723 			expectError(GL_NO_ERROR);
1724 		}
1725 	}
1726 protected:
SetBlendFunc(GLenum func)1727 	virtual void SetBlendFunc (GLenum func)
1728 	{
1729 		switch (m_testTargetName)
1730 		{
1731 		case GL_BLEND_SRC_RGB:
1732 		case GL_BLEND_SRC_ALPHA:
1733 			glBlendFunc(func, GL_ZERO);
1734 			break;
1735 
1736 		case GL_BLEND_DST_RGB:
1737 		case GL_BLEND_DST_ALPHA:
1738 			glBlendFunc(GL_ZERO, func);
1739 			break;
1740 
1741 		default:
1742 			DE_ASSERT(false && "should not happen");
1743 			break;
1744 		}
1745 	}
1746 
1747 	StateVerifier*		m_verifier;
1748 	GLenum			m_testTargetName;
1749 	int				m_initialValue;
1750 };
1751 
1752 class BlendFuncSeparateTestCase : public BlendFuncTestCase
1753 {
1754 public:
BlendFuncSeparateTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)1755 	BlendFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1756 		: BlendFuncTestCase	(context, verifier, name, description, testTargetName, initialValue)
1757 	{
1758 	}
1759 
SetBlendFunc(GLenum func)1760 	void SetBlendFunc (GLenum func)
1761 	{
1762 		switch (m_testTargetName)
1763 		{
1764 		case GL_BLEND_SRC_RGB:
1765 			glBlendFuncSeparate(func, GL_ZERO, GL_ZERO, GL_ZERO);
1766 			break;
1767 
1768 		case GL_BLEND_DST_RGB:
1769 			glBlendFuncSeparate(GL_ZERO, func, GL_ZERO, GL_ZERO);
1770 			break;
1771 
1772 		case GL_BLEND_SRC_ALPHA:
1773 			glBlendFuncSeparate(GL_ZERO, GL_ZERO, func, GL_ZERO);
1774 			break;
1775 
1776 		case GL_BLEND_DST_ALPHA:
1777 			glBlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, func);
1778 			break;
1779 
1780 		default:
1781 			DE_ASSERT(false && "should not happen");
1782 			break;
1783 		}
1784 	}
1785 };
1786 
1787 class BlendEquationTestCase : public ApiCase
1788 {
1789 public:
BlendEquationTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)1790 	BlendEquationTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1791 		: ApiCase			(context, name, description)
1792 		, m_verifier		(verifier)
1793 		, m_testTargetName	(testTargetName)
1794 		, m_initialValue	(initialValue)
1795 	{
1796 	}
1797 
test(void)1798 	void test (void)
1799 	{
1800 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
1801 		expectError(GL_NO_ERROR);
1802 
1803 		const GLenum blendFuncValues[] =
1804 		{
1805 			GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MIN, GL_MAX
1806 		};
1807 
1808 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx)
1809 		{
1810 			const GLenum referenceValue = blendFuncValues[ndx];
1811 
1812 			SetBlendEquation(referenceValue);
1813 			expectError(GL_NO_ERROR);
1814 
1815 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
1816 			expectError(GL_NO_ERROR);
1817 		}
1818 	}
1819 protected:
SetBlendEquation(GLenum equation)1820 	virtual void SetBlendEquation (GLenum equation)
1821 	{
1822 		glBlendEquation(equation);
1823 	}
1824 
1825 	StateVerifier*		m_verifier;
1826 	GLenum			m_testTargetName;
1827 	int				m_initialValue;
1828 };
1829 class BlendEquationSeparateTestCase : public BlendEquationTestCase
1830 {
1831 public:
BlendEquationSeparateTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)1832 	BlendEquationSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
1833 		: BlendEquationTestCase	(context, verifier, name, description, testTargetName, initialValue)
1834 	{
1835 	}
1836 
1837 protected:
SetBlendEquation(GLenum equation)1838 	void SetBlendEquation (GLenum equation)
1839 	{
1840 		switch (m_testTargetName)
1841 		{
1842 		case GL_BLEND_EQUATION_RGB:
1843 			glBlendEquationSeparate(equation, GL_FUNC_ADD);
1844 			break;
1845 
1846 		case GL_BLEND_EQUATION_ALPHA:
1847 			glBlendEquationSeparate(GL_FUNC_ADD, equation);
1848 			break;
1849 
1850 		default:
1851 			DE_ASSERT(false && "should not happen");
1852 			break;
1853 		}
1854 	}
1855 };
1856 
1857 class ImplementationArrayTestCase : public ApiCase
1858 {
1859 public:
ImplementationArrayTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum testTargetLengthTargetName, int minValue)1860 	ImplementationArrayTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum testTargetLengthTargetName, int minValue)
1861 		: ApiCase						(context, name, description)
1862 		, m_verifier					(verifier)
1863 		, m_testTargetName				(testTargetName)
1864 		, m_testTargetLengthTargetName	(testTargetLengthTargetName)
1865 		, m_minValue					(minValue)
1866 	{
1867 	}
1868 
test(void)1869 	void test (void)
1870 	{
1871 		m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, m_testTargetLengthTargetName, m_minValue);
1872 		expectError(GL_NO_ERROR);
1873 
1874 		GLint targetArrayLength = 0;
1875 		glGetIntegerv(m_testTargetLengthTargetName, &targetArrayLength);
1876 		expectError(GL_NO_ERROR);
1877 
1878 		if (targetArrayLength)
1879 		{
1880 			std::vector<GLint> queryResult;
1881 			queryResult.resize(targetArrayLength, 0);
1882 
1883 			glGetIntegerv(m_testTargetName, &queryResult[0]);
1884 			expectError(GL_NO_ERROR);
1885 		}
1886 	}
1887 
1888 private:
1889 	StateVerifier*		m_verifier;
1890 	GLenum			m_testTargetName;
1891 	GLenum			m_testTargetLengthTargetName;
1892 	int				m_minValue;
1893 };
1894 
1895 class BindingTest : public TestCase
1896 {
1897 public:
1898 						BindingTest	(Context&					context,
1899 									 const char*				name,
1900 									 const char*				desc,
1901 									 QueryType					type);
1902 
1903 	IterateResult		iterate		(void);
1904 
1905 	virtual void		test		(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const = 0;
1906 
1907 protected:
1908 	const QueryType		m_type;
1909 };
1910 
BindingTest(Context& context, const char* name, const char* desc, QueryType type)1911 BindingTest::BindingTest (Context&		context,
1912 						  const char*	name,
1913 						  const char*	desc,
1914 						  QueryType		type)
1915 	: TestCase	(context, name, desc)
1916 	, m_type	(type)
1917 {
1918 }
1919 
iterate(void)1920 BindingTest::IterateResult BindingTest::iterate (void)
1921 {
1922 	glu::CallLogWrapper		gl		(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
1923 	tcu::ResultCollector	result	(m_context.getTestContext().getLog(), " // ERROR: ");
1924 
1925 	gl.enableLogging(true);
1926 
1927 	test(gl, result);
1928 
1929 	result.setTestContextResult(m_testCtx);
1930 	return STOP;
1931 }
1932 
1933 class TransformFeedbackBindingTestCase : public BindingTest
1934 {
1935 public:
TransformFeedbackBindingTestCase(Context& context, QueryType type, const char* name)1936 	TransformFeedbackBindingTestCase (Context& context, QueryType type, const char* name)
1937 		: BindingTest(context, name, "GL_TRANSFORM_FEEDBACK_BINDING", type)
1938 	{
1939 	}
1940 
test(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const1941 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
1942 	{
1943 		static const char* transformFeedbackTestVertSource =
1944 			"#version 300 es\n"
1945 			"void main (void)\n"
1946 			"{\n"
1947 			"	gl_Position = vec4(0.0);\n"
1948 			"}\n\0";
1949 		static const char* transformFeedbackTestFragSource =
1950 			"#version 300 es\n"
1951 			"layout(location = 0) out mediump vec4 fragColor;"
1952 			"void main (void)\n"
1953 			"{\n"
1954 			"	fragColor = vec4(0.0);\n"
1955 			"}\n\0";
1956 
1957 		GLuint	shaderVert;
1958 		GLuint	shaderFrag;
1959 		GLuint	shaderProg;
1960 		GLuint	transformfeedback = 0;
1961 		GLuint	feedbackBufferId = 0;
1962 
1963 		{
1964 			const tcu::ScopedLogSection section(gl.getLog(), "Initial", "Initial");
1965 			verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, 0, m_type);
1966 		}
1967 
1968 		gl.glGenTransformFeedbacks(1, &transformfeedback);
1969 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenTransformFeedbacks");
1970 
1971 		{
1972 			const tcu::ScopedLogSection section(gl.getLog(), "VertexShader", "Vertex Shader");
1973 
1974 			GLint compileStatus = -1;
1975 
1976 			shaderVert = gl.glCreateShader(GL_VERTEX_SHADER);
1977 			gl.glShaderSource(shaderVert, 1, &transformFeedbackTestVertSource, DE_NULL);
1978 			gl.glCompileShader(shaderVert);
1979 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
1980 
1981 			gl.glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus);
1982 			if (compileStatus != GL_TRUE)
1983 				result.fail("expected GL_TRUE");
1984 		}
1985 		{
1986 			const tcu::ScopedLogSection section(gl.getLog(), "FragmentShader", "Fragment Shader");
1987 
1988 			GLint compileStatus = -1;
1989 
1990 			shaderFrag = gl.glCreateShader(GL_FRAGMENT_SHADER);
1991 			gl.glShaderSource(shaderFrag, 1, &transformFeedbackTestFragSource, DE_NULL);
1992 			gl.glCompileShader(shaderFrag);
1993 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
1994 
1995 			gl.glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus);
1996 			if (compileStatus != GL_TRUE)
1997 				result.fail("expected GL_TRUE");
1998 		}
1999 		{
2000 			const tcu::ScopedLogSection section(gl.getLog(), "Program", "Create and bind program");
2001 
2002 			const char*	transform_feedback_outputs	= "gl_Position";
2003 			GLint		linkStatus					= -1;
2004 
2005 			shaderProg = gl.glCreateProgram();
2006 			gl.glAttachShader(shaderProg, shaderVert);
2007 			gl.glAttachShader(shaderProg, shaderFrag);
2008 			gl.glTransformFeedbackVaryings(shaderProg, 1, &transform_feedback_outputs, GL_INTERLEAVED_ATTRIBS);
2009 			gl.glLinkProgram(shaderProg);
2010 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glLinkProgram");
2011 
2012 			gl.glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus);
2013 			if (linkStatus != GL_TRUE)
2014 				result.fail("expected GL_TRUE");
2015 		}
2016 
2017 		gl.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformfeedback);
2018 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTransformFeedback");
2019 
2020 		gl.glGenBuffers(1, &feedbackBufferId);
2021 		gl.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackBufferId);
2022 		gl.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_DYNAMIC_READ);
2023 		gl.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, feedbackBufferId);
2024 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind buffers");
2025 
2026 		gl.glUseProgram(shaderProg);
2027 
2028 		verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, transformfeedback, m_type);
2029 
2030 		gl.glUseProgram(0);
2031 		gl.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
2032 		gl.glDeleteTransformFeedbacks(1, &transformfeedback);
2033 
2034 		verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, 0, m_type);
2035 
2036 		gl.glDeleteBuffers(1, &feedbackBufferId);
2037 		gl.glDeleteShader(shaderVert);
2038 		gl.glDeleteShader(shaderFrag);
2039 		gl.glDeleteProgram(shaderProg);
2040 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteProgram");
2041 	}
2042 };
2043 
2044 class CurrentProgramBindingTestCase : public BindingTest
2045 {
2046 public:
CurrentProgramBindingTestCase(Context& context, QueryType type, const char* name, const char* description)2047 	CurrentProgramBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2048 		: BindingTest(context, name, description, type)
2049 	{
2050 	}
2051 
test(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const2052 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2053 	{
2054 		static const char* testVertSource =
2055 			"#version 300 es\n"
2056 			"void main (void)\n"
2057 			"{\n"
2058 			"	gl_Position = vec4(0.0);\n"
2059 			"}\n\0";
2060 		static const char* testFragSource =
2061 			"#version 300 es\n"
2062 			"layout(location = 0) out mediump vec4 fragColor;"
2063 			"void main (void)\n"
2064 			"{\n"
2065 			"	fragColor = vec4(0.0);\n"
2066 			"}\n\0";
2067 
2068 		GLuint	shaderVert;
2069 		GLuint	shaderFrag;
2070 		GLuint	shaderProg;
2071 
2072 		{
2073 			const tcu::ScopedLogSection section(gl.getLog(), "Initial", "Initial");
2074 
2075 			verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type);
2076 		}
2077 		{
2078 			const tcu::ScopedLogSection section(gl.getLog(), "VertexShader", "Vertex Shader");
2079 
2080 			GLint compileStatus = -1;
2081 
2082 			shaderVert = gl.glCreateShader(GL_VERTEX_SHADER);
2083 			gl.glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
2084 			gl.glCompileShader(shaderVert);
2085 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
2086 
2087 			gl.glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus);
2088 			if (compileStatus != GL_TRUE)
2089 				result.fail("expected GL_TRUE");
2090 		}
2091 		{
2092 			const tcu::ScopedLogSection section(gl.getLog(), "FragmentShader", "Fragment Shader");
2093 
2094 			GLint compileStatus = -1;
2095 
2096 			shaderFrag = gl.glCreateShader(GL_FRAGMENT_SHADER);
2097 			gl.glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
2098 			gl.glCompileShader(shaderFrag);
2099 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
2100 
2101 			gl.glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus);
2102 			if (compileStatus != GL_TRUE)
2103 				result.fail("expected GL_TRUE");
2104 		}
2105 		{
2106 			const tcu::ScopedLogSection section(gl.getLog(), "Program", "Create and bind program");
2107 
2108 			GLint linkStatus = -1;
2109 
2110 			shaderProg = gl.glCreateProgram();
2111 			gl.glAttachShader(shaderProg, shaderVert);
2112 			gl.glAttachShader(shaderProg, shaderFrag);
2113 			gl.glLinkProgram(shaderProg);
2114 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glLinkProgram");
2115 
2116 			gl.glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus);
2117 			if (linkStatus != GL_TRUE)
2118 				result.fail("expected GL_TRUE");
2119 
2120 			gl.glUseProgram(shaderProg);
2121 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram");
2122 
2123 			verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type);
2124 		}
2125 		{
2126 			const tcu::ScopedLogSection section(gl.getLog(), "Delete", "Delete program while in use");
2127 
2128 			gl.glDeleteShader(shaderVert);
2129 			gl.glDeleteShader(shaderFrag);
2130 			gl.glDeleteProgram(shaderProg);
2131 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteProgram");
2132 
2133 			verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type);
2134 		}
2135 		{
2136 			const tcu::ScopedLogSection section(gl.getLog(), "Unbind", "Unbind program");
2137 			gl.glUseProgram(0);
2138 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram");
2139 
2140 			verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type);
2141 		}
2142 	}
2143 };
2144 
2145 class VertexArrayBindingTestCase : public BindingTest
2146 {
2147 public:
VertexArrayBindingTestCase(Context& context, QueryType type, const char* name, const char* description)2148 	VertexArrayBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2149 		: BindingTest(context, name, description, type)
2150 	{
2151 	}
2152 
test(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const2153 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2154 	{
2155 		verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, 0, m_type);
2156 
2157 		GLuint vertexArrayObject = 0;
2158 		gl.glGenVertexArrays(1, &vertexArrayObject);
2159 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenVertexArrays");
2160 
2161 		gl.glBindVertexArray(vertexArrayObject);
2162 		verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, vertexArrayObject, m_type);
2163 
2164 		gl.glDeleteVertexArrays(1, &vertexArrayObject);
2165 		verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, 0, m_type);
2166 	}
2167 };
2168 
2169 class BufferBindingTestCase : public BindingTest
2170 {
2171 public:
BufferBindingTestCase(Context& context, QueryType type, const char* name, const char* description, GLenum bufferBindingName, GLenum bufferType)2172 	BufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description, GLenum bufferBindingName, GLenum bufferType)
2173 		: BindingTest			(context, name, description, type)
2174 		, m_bufferBindingName	(bufferBindingName)
2175 		, m_bufferType			(bufferType)
2176 	{
2177 	}
2178 
test(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const2179 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2180 	{
2181 		verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type);
2182 
2183 		GLuint bufferObject = 0;
2184 		gl.glGenBuffers(1, &bufferObject);
2185 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
2186 
2187 		gl.glBindBuffer(m_bufferType, bufferObject);
2188 		verifyStateInteger(result, gl, m_bufferBindingName, bufferObject, m_type);
2189 
2190 		gl.glDeleteBuffers(1, &bufferObject);
2191 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteBuffers");
2192 
2193 		verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type);
2194 	}
2195 
2196 private:
2197 	const GLenum	m_bufferBindingName;
2198 	const GLenum	m_bufferType;
2199 };
2200 
2201 class ElementArrayBufferBindingTestCase : public BindingTest
2202 {
2203 public:
ElementArrayBufferBindingTestCase(Context& context, QueryType type, const char* name)2204 	ElementArrayBufferBindingTestCase (Context& context, QueryType type, const char* name)
2205 		: BindingTest(context, name, "GL_ELEMENT_ARRAY_BUFFER_BINDING", type)
2206 	{
2207 	}
2208 
test(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const2209 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2210 	{
2211 		// Test with default VAO
2212 		{
2213 			const tcu::ScopedLogSection section(gl.getLog(), "DefaultVAO", "Test with default VAO");
2214 
2215 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2216 
2217 			GLuint bufferObject = 0;
2218 			gl.glGenBuffers(1, &bufferObject);
2219 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
2220 
2221 			gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObject);
2222 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, bufferObject, m_type);
2223 
2224 			gl.glDeleteBuffers(1, &bufferObject);
2225 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2226 		}
2227 
2228 		// Test with multiple VAOs
2229 		{
2230 			const tcu::ScopedLogSection section(gl.getLog(), "WithVAO", "Test with VAO");
2231 
2232 			GLuint vaos[2]		= {0};
2233 			GLuint buffers[2]	= {0};
2234 
2235 			gl.glGenVertexArrays(2, vaos);
2236 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenVertexArrays");
2237 
2238 			gl.glGenBuffers(2, buffers);
2239 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
2240 
2241 			// initial
2242 			gl.glBindVertexArray(vaos[0]);
2243 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2244 
2245 			// after setting
2246 			gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[0]);
2247 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[0], m_type);
2248 
2249 			// initial of vao 2
2250 			gl.glBindVertexArray(vaos[1]);
2251 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2252 
2253 			// after setting to 2
2254 			gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
2255 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[1], m_type);
2256 
2257 			// vao 1 still has buffer 1 bound?
2258 			gl.glBindVertexArray(vaos[0]);
2259 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[0], m_type);
2260 
2261 			// deleting clears from bound vaos ...
2262 			gl.glDeleteBuffers(2, buffers);
2263 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type);
2264 
2265 			// ... but does not from non-bound vaos?
2266 			gl.glBindVertexArray(vaos[1]);
2267 			verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[1], m_type);
2268 
2269 			gl.glDeleteVertexArrays(2, vaos);
2270 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteVertexArrays");
2271 		}
2272 	}
2273 };
2274 
2275 class StencilClearValueTestCase : public ApiCase
2276 {
2277 public:
StencilClearValueTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)2278 	StencilClearValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
2279 		: ApiCase		(context, name, description)
2280 		, m_verifier	(verifier)
2281 	{
2282 	}
2283 
test(void)2284 	void test (void)
2285 	{
2286 		m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, 0);
2287 		expectError(GL_NO_ERROR);
2288 
2289 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
2290 
2291 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
2292 		{
2293 			const int ref = 1 << stencilBit;
2294 
2295 			glClearStencil(ref); // mask should not affect the REF
2296 			expectError(GL_NO_ERROR);
2297 
2298 			m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, ref);
2299 			expectError(GL_NO_ERROR);
2300 		}
2301 	}
2302 
2303 private:
2304 	StateVerifier*	m_verifier;
2305 };
2306 
2307 class ActiveTextureTestCase : public ApiCase
2308 {
2309 public:
ActiveTextureTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)2310 	ActiveTextureTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
2311 		: ApiCase		(context, name, description)
2312 		, m_verifier	(verifier)
2313 	{
2314 	}
2315 
test(void)2316 	void test (void)
2317 	{
2318 		m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0);
2319 		expectError(GL_NO_ERROR);
2320 
2321 		GLint textureUnits = 0;
2322 		glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &textureUnits);
2323 		expectError(GL_NO_ERROR);
2324 
2325 		for (int ndx = 0; ndx < textureUnits; ++ndx)
2326 		{
2327 			glActiveTexture(GL_TEXTURE0 + ndx);
2328 			expectError(GL_NO_ERROR);
2329 
2330 			m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0 + ndx);
2331 			expectError(GL_NO_ERROR);
2332 		}
2333 	}
2334 
2335 private:
2336 	StateVerifier*		m_verifier;
2337 };
2338 
2339 class RenderbufferBindingTestCase : public BindingTest
2340 {
2341 public:
RenderbufferBindingTestCase(Context& context, QueryType type, const char* name, const char* description)2342 	RenderbufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2343 		: BindingTest(context, name, description, type)
2344 	{
2345 	}
2346 
test(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const2347 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2348 	{
2349 		verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type);
2350 
2351 		GLuint renderBuffer = 0;
2352 		gl.glGenRenderbuffers(1, &renderBuffer);
2353 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenRenderbuffers");
2354 
2355 		gl.glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
2356 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindRenderbuffer");
2357 
2358 		verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, renderBuffer, m_type);
2359 
2360 		gl.glDeleteRenderbuffers(1, &renderBuffer);
2361 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteRenderbuffers");
2362 
2363 		verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type);
2364 	}
2365 };
2366 
2367 class SamplerObjectBindingTestCase : public BindingTest
2368 {
2369 public:
SamplerObjectBindingTestCase(Context& context, QueryType type, const char* name, const char* description)2370 	SamplerObjectBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2371 		: BindingTest(context, name, description, type)
2372 	{
2373 	}
2374 
test(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const2375 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2376 	{
2377 		verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type);
2378 
2379 		{
2380 			const tcu::ScopedLogSection section(gl.getLog(), "SingleUnit", "Single unit");
2381 
2382 			GLuint sampler = 0;
2383 			gl.glGenSamplers(1, &sampler);
2384 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenSamplers");
2385 
2386 			gl.glBindSampler(0, sampler);
2387 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindSampler");
2388 
2389 			verifyStateInteger(result, gl, GL_SAMPLER_BINDING, sampler, m_type);
2390 
2391 			gl.glDeleteSamplers(1, &sampler);
2392 			verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type);
2393 		}
2394 
2395 		{
2396 			const tcu::ScopedLogSection section(gl.getLog(), "MultipleUnits", "Multiple units");
2397 
2398 			GLuint samplerA = 0;
2399 			GLuint samplerB = 0;
2400 			gl.glGenSamplers(1, &samplerA);
2401 			gl.glGenSamplers(1, &samplerB);
2402 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenSamplers");
2403 
2404 			gl.glBindSampler(1, samplerA);
2405 			gl.glBindSampler(2, samplerB);
2406 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindSampler");
2407 
2408 			verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type);
2409 
2410 			gl.glActiveTexture(GL_TEXTURE1);
2411 			verifyStateInteger(result, gl, GL_SAMPLER_BINDING, samplerA, m_type);
2412 
2413 			gl.glActiveTexture(GL_TEXTURE2);
2414 			verifyStateInteger(result, gl, GL_SAMPLER_BINDING, samplerB, m_type);
2415 
2416 			gl.glDeleteSamplers(1, &samplerB);
2417 			gl.glDeleteSamplers(1, &samplerA);
2418 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteSamplers");
2419 		}
2420 	}
2421 };
2422 
2423 class TextureBindingTestCase : public BindingTest
2424 {
2425 public:
TextureBindingTestCase(Context& context, QueryType type, const char* name, const char* description, GLenum testBindingName, GLenum textureType)2426 	TextureBindingTestCase (Context& context, QueryType type, const char* name, const char* description, GLenum testBindingName, GLenum textureType)
2427 		: BindingTest			(context, name, description, type)
2428 		, m_testBindingName		(testBindingName)
2429 		, m_textureType			(textureType)
2430 	{
2431 	}
2432 
test(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const2433 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2434 	{
2435 		verifyStateInteger(result, gl, m_testBindingName, 0, m_type);
2436 
2437 		GLuint texture = 0;
2438 		gl.glGenTextures(1, &texture);
2439 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenTextures");
2440 
2441 		gl.glBindTexture(m_textureType, texture);
2442 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
2443 
2444 		verifyStateInteger(result, gl, m_testBindingName, texture, m_type);
2445 
2446 		gl.glDeleteTextures(1, &texture);
2447 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
2448 
2449 		verifyStateInteger(result, gl, m_testBindingName, 0, m_type);
2450 	}
2451 private:
2452 	const GLenum	m_testBindingName;
2453 	const GLenum	m_textureType;
2454 };
2455 
2456 class FrameBufferBindingTestCase : public BindingTest
2457 {
2458 public:
FrameBufferBindingTestCase(Context& context, QueryType type, const char* name, const char* description)2459 	FrameBufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
2460 		: BindingTest(context, name, description, type)
2461 	{
2462 	}
2463 
test(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const2464 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
2465 	{
2466 		verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING,	0, m_type);
2467 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING,		0, m_type);
2468 		verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING,	0, m_type);
2469 
2470 		GLuint framebufferId = 0;
2471 		gl.glGenFramebuffers(1, &framebufferId);
2472 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenFramebuffers");
2473 
2474 		gl.glBindFramebuffer(GL_FRAMEBUFFER, framebufferId);
2475 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_FRAMEBUFFER");
2476 
2477 		verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING,	framebufferId, m_type);
2478 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING,		framebufferId, m_type);
2479 		verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING,	framebufferId, m_type);
2480 
2481 		gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
2482 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "unbind GL_FRAMEBUFFER");
2483 
2484 		verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING,	0, m_type);
2485 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING,		0, m_type);
2486 		verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING,	0, m_type);
2487 
2488 		gl.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferId);
2489 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_READ_FRAMEBUFFER");
2490 
2491 		verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING,	0,				m_type);
2492 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING,		0,				m_type);
2493 		verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING,	framebufferId,	m_type);
2494 
2495 		gl.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferId);
2496 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_DRAW_FRAMEBUFFER");
2497 
2498 		verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING,	framebufferId, m_type);
2499 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING,		framebufferId, m_type);
2500 		verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING,	framebufferId, m_type);
2501 
2502 		gl.glDeleteFramebuffers(1, &framebufferId);
2503 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteFramebuffers");
2504 
2505 		verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING,	0, m_type);
2506 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING,		0, m_type);
2507 		verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING,	0, m_type);
2508 	}
2509 };
2510 
2511 class ImplementationColorReadTestCase : public ApiCase
2512 {
2513 public:
ImplementationColorReadTestCase(Context& context, StateVerifier* verifier, const char* name, const char* description)2514 	ImplementationColorReadTestCase	(Context& context, StateVerifier* verifier, const char* name, const char* description)
2515 		: ApiCase		(context, name, description)
2516 		, m_verifier	(verifier)
2517 	{
2518 	}
2519 
test(void)2520 	void test (void)
2521 	{
2522 		const GLint defaultColorTypes[] =
2523 		{
2524 			GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT,
2525 			GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_UNSIGNED_SHORT_5_6_5,
2526 			GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1,
2527 			GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10F_11F_11F_REV
2528 		};
2529 		const GLint defaultColorFormats[] =
2530 		{
2531 			GL_RGBA, GL_RGBA_INTEGER, GL_RGB, GL_RGB_INTEGER,
2532 			GL_RG, GL_RG_INTEGER, GL_RED, GL_RED_INTEGER
2533 		};
2534 
2535 		std::vector<GLint> validColorTypes;
2536 		std::vector<GLint> validColorFormats;
2537 
2538 		// Defined by the spec
2539 
2540 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorTypes); ++ndx)
2541 			validColorTypes.push_back(defaultColorTypes[ndx]);
2542 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorFormats); ++ndx)
2543 			validColorFormats.push_back(defaultColorFormats[ndx]);
2544 
2545 		// Extensions
2546 
2547 		if (m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_format_BGRA8888") ||
2548 			m_context.getContextInfo().isExtensionSupported("GL_APPLE_texture_format_BGRA8888"))
2549 			validColorFormats.push_back(GL_BGRA);
2550 
2551 		if (m_context.getContextInfo().isExtensionSupported("GL_EXT_read_format_bgra"))
2552 		{
2553 			validColorFormats.push_back(GL_BGRA);
2554 			validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV);
2555 			validColorTypes.push_back(GL_UNSIGNED_SHORT_1_5_5_5_REV);
2556 		}
2557 
2558 		if (m_context.getContextInfo().isExtensionSupported("GL_IMG_read_format"))
2559 		{
2560 			validColorFormats.push_back(GL_BGRA);
2561 			validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV);
2562 		}
2563 
2564 		if (m_context.getContextInfo().isExtensionSupported("GL_NV_sRGB_formats"))
2565 		{
2566 			validColorFormats.push_back(GL_SLUMINANCE_NV);
2567 			validColorFormats.push_back(GL_SLUMINANCE_ALPHA_NV);
2568 		}
2569 
2570 		if (m_context.getContextInfo().isExtensionSupported("GL_NV_bgr"))
2571 		{
2572 			validColorFormats.push_back(GL_BGR_NV);
2573 		}
2574 
2575 		m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_TYPE,	&validColorTypes[0],	validColorTypes.size());
2576 		m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_FORMAT,	&validColorFormats[0],	validColorFormats.size());
2577 		expectError(GL_NO_ERROR);
2578 	}
2579 
2580 private:
2581 	StateVerifier*	m_verifier;
2582 };
2583 
2584 class ReadBufferCase : public ApiCase
2585 {
2586 public:
ReadBufferCase(Context& context, StateVerifier* verifier, const char* name, const char* description)2587 	ReadBufferCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
2588 		: ApiCase		(context, name, description)
2589 		, m_verifier	(verifier)
2590 	{
2591 	}
2592 
test(void)2593 	void test (void)
2594 	{
2595 		const bool isGlCore45 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5));
2596 		const GLenum colorAttachment = isGlCore45 ? GL_FRONT : GL_BACK;
2597 		const GLint validInitialValues[] = {(GLint)colorAttachment, GL_BACK, GL_NONE};
2598 		m_verifier->verifyIntegerAnyOf(m_testCtx, GL_READ_BUFFER, validInitialValues, DE_LENGTH_OF_ARRAY(validInitialValues));
2599 		expectError(GL_NO_ERROR);
2600 
2601 		glReadBuffer(GL_NONE);
2602 		m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_NONE);
2603 		expectError(GL_NO_ERROR);
2604 
2605 		glReadBuffer(colorAttachment);
2606 		m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, colorAttachment);
2607 		expectError(GL_NO_ERROR);
2608 
2609 		// test GL_READ_BUFFER with framebuffers
2610 
2611 		GLuint framebufferId = 0;
2612 		glGenFramebuffers(1, &framebufferId);
2613 		expectError(GL_NO_ERROR);
2614 
2615 		GLuint renderbuffer_id = 0;
2616 		glGenRenderbuffers(1, &renderbuffer_id);
2617 		expectError(GL_NO_ERROR);
2618 
2619 		glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_id);
2620 		expectError(GL_NO_ERROR);
2621 
2622 		glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128);
2623 		expectError(GL_NO_ERROR);
2624 
2625 		glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferId);
2626 		expectError(GL_NO_ERROR);
2627 
2628 		glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer_id);
2629 		expectError(GL_NO_ERROR);
2630 
2631 		m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_COLOR_ATTACHMENT0);
2632 
2633 		glDeleteFramebuffers(1, &framebufferId);
2634 		glDeleteRenderbuffers(1, &renderbuffer_id);
2635 		expectError(GL_NO_ERROR);
2636 
2637 		m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, colorAttachment);
2638 		expectError(GL_NO_ERROR);
2639 	}
2640 private:
2641 	StateVerifier*	m_verifier;
2642 };
2643 
2644 class DrawBufferCase : public ApiCase
2645 {
2646 public:
DrawBufferCase(Context& context, StateVerifier* verifier, const char* name, const char* description)2647 	DrawBufferCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
2648 		: ApiCase		(context, name, description)
2649 		, m_verifier	(verifier)
2650 	{
2651 	}
2652 
test(void)2653 	void test (void)
2654 	{
2655 		const GLint validInitialValues[] = {GL_FRONT, GL_BACK, GL_NONE};
2656 		m_verifier->verifyIntegerAnyOf(m_testCtx, GL_DRAW_BUFFER0, validInitialValues, DE_LENGTH_OF_ARRAY(validInitialValues));
2657 		expectError(GL_NO_ERROR);
2658 
2659 		GLenum bufs = GL_NONE;
2660 		glDrawBuffers(1, &bufs);
2661 		m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_NONE);
2662 		expectError(GL_NO_ERROR);
2663 
2664 		bufs = GL_BACK;
2665 		glDrawBuffers(1, &bufs);
2666 		const GLint validDraw0Values[] = {GL_FRONT_LEFT, GL_BACK};
2667 		m_verifier->verifyIntegerAnyOf(m_testCtx, GL_DRAW_BUFFER0, validDraw0Values, DE_LENGTH_OF_ARRAY(validDraw0Values));
2668 		expectError(GL_NO_ERROR);
2669 
2670 		// test GL_DRAW_BUFFER with framebuffers
2671 
2672 		GLuint framebufferId = 0;
2673 		glGenFramebuffers(1, &framebufferId);
2674 		expectError(GL_NO_ERROR);
2675 
2676 		GLuint renderbuffer_ids[2] = {0};
2677 		glGenRenderbuffers(2, renderbuffer_ids);
2678 		expectError(GL_NO_ERROR);
2679 
2680 		glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_ids[0]);
2681 		expectError(GL_NO_ERROR);
2682 		glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128);
2683 		expectError(GL_NO_ERROR);
2684 
2685 		glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_ids[1]);
2686 		expectError(GL_NO_ERROR);
2687 		glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128);
2688 		expectError(GL_NO_ERROR);
2689 
2690 		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferId);
2691 		expectError(GL_NO_ERROR);
2692 
2693 		glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer_ids[0]);
2694 		expectError(GL_NO_ERROR);
2695 		glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, renderbuffer_ids[1]);
2696 		expectError(GL_NO_ERROR);
2697 
2698 		// only the initial state the draw buffer for fragment color zero is defined
2699 		m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_COLOR_ATTACHMENT0);
2700 
2701 		GLenum bufTargets[2] = {GL_NONE, GL_COLOR_ATTACHMENT1};
2702 		glDrawBuffers(2, bufTargets);
2703 		m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_NONE);
2704 		m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER1, GL_COLOR_ATTACHMENT1);
2705 
2706 		glDeleteFramebuffers(1, &framebufferId);
2707 		glDeleteRenderbuffers(2, renderbuffer_ids);
2708 		expectError(GL_NO_ERROR);
2709 
2710 		m_verifier->verifyIntegerAnyOf(m_testCtx, GL_DRAW_BUFFER0, validDraw0Values, DE_LENGTH_OF_ARRAY(validDraw0Values));
2711 		expectError(GL_NO_ERROR);
2712 	}
2713 private:
2714 	StateVerifier*	m_verifier;
2715 };
2716 
getQueryTypeSuffix(QueryType type)2717 static const char* getQueryTypeSuffix (QueryType type)
2718 {
2719 	switch (type)
2720 	{
2721 		case QUERY_BOOLEAN:		return "_getboolean";
2722 		case QUERY_INTEGER:		return "_getinteger";
2723 		case QUERY_INTEGER64:	return "_getinteger64";
2724 		case QUERY_FLOAT:		return "_getfloat";
2725 		default:
2726 			DE_ASSERT(DE_FALSE);
2727 			return DE_NULL;
2728 	}
2729 }
2730 
2731 #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK)													\
2732 	do {																							\
2733 		for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++)	\
2734 		{																							\
2735 			StateVerifier* verifier = (VERIFIERS)[_verifierNdx];									\
2736 			CODE_BLOCK;																				\
2737 		}																							\
2738 	} while (0)
2739 
2740 #define FOR_EACH_QUERYTYPE(QUERYTYPES, CODE_BLOCK)														\
2741 	do {																								\
2742 		for (int _queryTypeNdx = 0; _queryTypeNdx < DE_LENGTH_OF_ARRAY(QUERYTYPES); _queryTypeNdx++)	\
2743 		{																								\
2744 			const QueryType queryType = (QUERYTYPES)[_queryTypeNdx];									\
2745 			CODE_BLOCK;																					\
2746 		}																								\
2747 	} while (0)
2748 
2749 } // anonymous
2750 
IntegerStateQueryTests(Context& context)2751 IntegerStateQueryTests::IntegerStateQueryTests (Context& context)
2752 	: TestCaseGroup			(context, "integers", "Integer Values")
2753 	, m_verifierBoolean		(DE_NULL)
2754 	, m_verifierInteger		(DE_NULL)
2755 	, m_verifierInteger64	(DE_NULL)
2756 	, m_verifierFloat		(DE_NULL)
2757 {
2758 }
2759 
~IntegerStateQueryTests(void)2760 IntegerStateQueryTests::~IntegerStateQueryTests (void)
2761 {
2762 	deinit();
2763 }
2764 
init(void)2765 void IntegerStateQueryTests::init (void)
2766 {
2767 	static const QueryType queryTypes[] =
2768 	{
2769 		QUERY_BOOLEAN,
2770 		QUERY_INTEGER,
2771 		QUERY_INTEGER64,
2772 		QUERY_FLOAT,
2773 	};
2774 
2775 	DE_ASSERT(m_verifierBoolean == DE_NULL);
2776 	DE_ASSERT(m_verifierInteger == DE_NULL);
2777 	DE_ASSERT(m_verifierInteger64 == DE_NULL);
2778 	DE_ASSERT(m_verifierFloat == DE_NULL);
2779 
2780 	m_verifierBoolean		= new GetBooleanVerifier	(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2781 	m_verifierInteger		= new GetIntegerVerifier	(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2782 	m_verifierInteger64		= new GetInteger64Verifier	(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2783 	m_verifierFloat			= new GetFloatVerifier		(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
2784 
2785 	const struct LimitedStateInteger
2786 	{
2787 		const char*		name;
2788 		const char*		description;
2789 		GLenum			targetName;
2790 		GLint			value;
2791 		bool			skipForGl;
2792 	} implementationMinLimits[] =
2793 	{
2794 		{ "subpixel_bits",									"SUBPIXEL_BITS has minimum value of 4",										GL_SUBPIXEL_BITS,									4	,	false},
2795 		{ "max_3d_texture_size",							"MAX_3D_TEXTURE_SIZE has minimum value of 256",								GL_MAX_3D_TEXTURE_SIZE,								256	,	false	},
2796 		{ "max_texture_size",								"MAX_TEXTURE_SIZE has minimum value of 2048",								GL_MAX_TEXTURE_SIZE,								2048	,	false	},
2797 		{ "max_array_texture_layers",						"MAX_ARRAY_TEXTURE_LAYERS has minimum value of 256",						GL_MAX_ARRAY_TEXTURE_LAYERS,						256	,	false	},
2798 		{ "max_cube_map_texture_size",						"MAX_CUBE_MAP_TEXTURE_SIZE has minimum value of 2048",						GL_MAX_CUBE_MAP_TEXTURE_SIZE,						2048	,	false	},
2799 		{ "max_renderbuffer_size",							"MAX_RENDERBUFFER_SIZE has minimum value of 2048",							GL_MAX_RENDERBUFFER_SIZE,							2048	,	false	},
2800 		{ "max_draw_buffers",								"MAX_DRAW_BUFFERS has minimum value of 4",									GL_MAX_DRAW_BUFFERS,								4	,	false	},
2801 		{ "max_color_attachments",							"MAX_COLOR_ATTACHMENTS has minimum value of 4",								GL_MAX_COLOR_ATTACHMENTS,							4	,	false	},
2802 		{ "max_elements_indices",							"MAX_ELEMENTS_INDICES has minimum value of 0",								GL_MAX_ELEMENTS_INDICES,							0	,	false	},
2803 		{ "max_elements_vertices",							"MAX_ELEMENTS_VERTICES has minimum value of 0",								GL_MAX_ELEMENTS_VERTICES,							0	,	false	},
2804 		{ "num_extensions",									"NUM_EXTENSIONS has minimum value of 0",									GL_NUM_EXTENSIONS,									0	,	false	},
2805 		{ "major_version",									"MAJOR_VERSION has minimum value of 3",										GL_MAJOR_VERSION,									3	,	false	},
2806 		{ "minor_version",									"MINOR_VERSION has minimum value of 0",										GL_MINOR_VERSION,									0	,	false	},
2807 		{ "max_vertex_attribs",								"MAX_VERTEX_ATTRIBS has minimum value of 16",								GL_MAX_VERTEX_ATTRIBS,								16	,	false	},
2808 		{ "max_vertex_uniform_components",					"MAX_VERTEX_UNIFORM_COMPONENTS has minimum value of 1024",					GL_MAX_VERTEX_UNIFORM_COMPONENTS,					1024	,	false	},
2809 		{ "max_vertex_uniform_vectors",						"MAX_VERTEX_UNIFORM_VECTORS has minimum value of 256",						GL_MAX_VERTEX_UNIFORM_VECTORS,						256	,	false	},
2810 		{ "max_vertex_uniform_blocks",						"MAX_VERTEX_UNIFORM_BLOCKS has minimum value of 12",						GL_MAX_VERTEX_UNIFORM_BLOCKS,						12	,	false	},
2811 		{ "max_vertex_output_components",					"MAX_VERTEX_OUTPUT_COMPONENTS has minimum value of 64",						GL_MAX_VERTEX_OUTPUT_COMPONENTS,					64	,	false	},
2812 		{ "max_vertex_texture_image_units",					"MAX_VERTEX_TEXTURE_IMAGE_UNITS has minimum value of 16",					GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,					16	,	false	},
2813 		{ "max_fragment_uniform_components",				"MAX_FRAGMENT_UNIFORM_COMPONENTS has minimum value of 896",					GL_MAX_FRAGMENT_UNIFORM_COMPONENTS,					896	,	false	},
2814 		{ "max_fragment_uniform_vectors",					"MAX_FRAGMENT_UNIFORM_VECTORS has minimum value of 224",					GL_MAX_FRAGMENT_UNIFORM_VECTORS,					224	,	false	},
2815 		{ "max_fragment_uniform_blocks",					"MAX_FRAGMENT_UNIFORM_BLOCKS has minimum value of 12",						GL_MAX_FRAGMENT_UNIFORM_BLOCKS,						12	,	false	},
2816 		{ "max_fragment_input_components",					"MAX_FRAGMENT_INPUT_COMPONENTS has minimum value of 60",					GL_MAX_FRAGMENT_INPUT_COMPONENTS,					60	,	false	},
2817 		{ "max_texture_image_units",						"MAX_TEXTURE_IMAGE_UNITS has minimum value of 16",							GL_MAX_TEXTURE_IMAGE_UNITS,							16	,	false	},
2818 		{ "max_program_texel_offset",						"MAX_PROGRAM_TEXEL_OFFSET has minimum value of 7",							GL_MAX_PROGRAM_TEXEL_OFFSET,						7	,	false	},
2819 		{ "max_uniform_buffer_bindings",					"MAX_UNIFORM_BUFFER_BINDINGS has minimum value of 24",						GL_MAX_UNIFORM_BUFFER_BINDINGS,						24	,	false	},
2820 		{ "max_combined_uniform_blocks",					"MAX_COMBINED_UNIFORM_BLOCKS has minimum value of 24",						GL_MAX_COMBINED_UNIFORM_BLOCKS,						24	,	false	},
2821 		{ "max_varying_components",							"MAX_VARYING_COMPONENTS has minimum value of 60",							GL_MAX_VARYING_COMPONENTS,							60	,	false	},
2822 		{ "max_varying_vectors",							"MAX_VARYING_VECTORS has minimum value of 15",								GL_MAX_VARYING_VECTORS,								15	,	false	},
2823 		{ "max_combined_texture_image_units",				"MAX_COMBINED_TEXTURE_IMAGE_UNITS has minimum value of 32",					GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,				32	,	false	},
2824 		{ "max_transform_feedback_interleaved_components",	"MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS has minimum value of 64",	GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS,	64	,	false	},
2825 		{ "max_transform_feedback_separate_attribs",		"MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS has minimum value of 4",			GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,			4	,	false	},
2826 		{ "max_transform_feedback_separate_components",		"MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS has minimum value of 4",		GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS,		4	,	false	},
2827 		{ "max_samples",									"MAX_SAMPLES has minimum value of 4",										GL_MAX_SAMPLES,										4	,	false	},
2828 		{ "red_bits",										"RED_BITS has minimum value of 0",											GL_RED_BITS,										0,	true	},
2829 		{ "green_bits",										"GREEN_BITS has minimum value of 0",										GL_GREEN_BITS,										0,	true	},
2830 		{ "blue_bits",										"BLUE_BITS has minimum value of 0",											GL_BLUE_BITS,										0,	true	},
2831 		{ "alpha_bits",										"ALPHA_BITS has minimum value of 0",										GL_ALPHA_BITS,										0,	true	},
2832 		{ "depth_bits",										"DEPTH_BITS has minimum value of 0",										GL_DEPTH_BITS,										0,	true	},
2833 		{ "stencil_bits",									"STENCIL_BITS has minimum value of 0",										GL_STENCIL_BITS,									0,	true	},
2834 	};
2835 	const LimitedStateInteger implementationMaxLimits[] =
2836 	{
2837 		{ "min_program_texel_offset",						"MIN_PROGRAM_TEXEL_OFFSET has maximum value of -8",							GL_MIN_PROGRAM_TEXEL_OFFSET,						-8	,	false	},
2838 		{ "uniform_buffer_offset_alignment",				"UNIFORM_BUFFER_OFFSET_ALIGNMENT has minimum value of 1",					GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,					256	,	false	},
2839 	};
2840 
2841 	// \note implementation defined limits have their own tests so just check the conversions to boolean, int64 and float
2842 	StateVerifier* implementationLimitVerifiers[] = {m_verifierBoolean, m_verifierInteger64, m_verifierFloat};
2843 
2844 	const bool isGlCore45 = glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5));
2845 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMinLimits); testNdx++)
2846 	{
2847 		if (implementationMinLimits[testNdx].skipForGl && isGlCore45)
2848 			continue;
2849 		FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new ConstantMinimumValueTestCase(m_context, verifier, (std::string(implementationMinLimits[testNdx].name) + verifier->getTestNamePostfix()).c_str(), implementationMinLimits[testNdx].description, implementationMinLimits[testNdx].targetName, implementationMinLimits[testNdx].value)));
2850 	}
2851 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMaxLimits); testNdx++)
2852 		FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new ConstantMaximumValueTestCase(m_context, verifier, (std::string(implementationMaxLimits[testNdx].name) + verifier->getTestNamePostfix()).c_str(), implementationMaxLimits[testNdx].description, implementationMaxLimits[testNdx].targetName, implementationMaxLimits[testNdx].value)));
2853 
2854 	StateVerifier* normalVerifiers[] = {m_verifierBoolean, m_verifierInteger, m_verifierInteger64, m_verifierFloat};
2855 
2856 	FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new SampleBuffersTestCase		(m_context,	 verifier, (std::string("sample_buffers")						+ verifier->getTestNamePostfix()).c_str(),		"SAMPLE_BUFFERS")));
2857 
2858 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new SamplesTestCase				(m_context,	 verifier, (std::string("samples")								+ verifier->getTestNamePostfix()).c_str(),		"SAMPLES")));
2859 	if (!isGlCore45)
2860 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new HintTestCase				(m_context,	 verifier, (std::string("generate_mipmap_hint")					+ verifier->getTestNamePostfix()).c_str(),		"GENERATE_MIPMAP_HINT",				GL_GENERATE_MIPMAP_HINT)));
2861 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new HintTestCase				(m_context,	 verifier, (std::string("fragment_shader_derivative_hint")		+ verifier->getTestNamePostfix()).c_str(),		"FRAGMENT_SHADER_DERIVATIVE_HINT",	GL_FRAGMENT_SHADER_DERIVATIVE_HINT)));
2862 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new DepthFuncTestCase			(m_context,	 verifier, (std::string("depth_func")							+ verifier->getTestNamePostfix()).c_str(),		"DEPTH_FUNC")));
2863 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new CullFaceTestCase			(m_context,	 verifier, (std::string("cull_face_mode")						+ verifier->getTestNamePostfix()).c_str(),		"CULL_FACE_MODE")));
2864 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new FrontFaceTestCase			(m_context,	 verifier, (std::string("front_face_mode")						+ verifier->getTestNamePostfix()).c_str(),		"FRONT_FACE")));
2865 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ViewPortTestCase			(m_context,	 verifier, (std::string("viewport")								+ verifier->getTestNamePostfix()).c_str(),		"VIEWPORT")));
2866 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ScissorBoxTestCase			(m_context,	 verifier, (std::string("scissor_box")							+ verifier->getTestNamePostfix()).c_str(),		"SCISSOR_BOX")));
2867 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new MaxViewportDimsTestCase		(m_context,	 verifier, (std::string("max_viewport_dims")					+ verifier->getTestNamePostfix()).c_str(),		"MAX_VIEWPORT_DIMS")));
2868 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefTestCase			(m_context,	 verifier, (std::string("stencil_ref")							+ verifier->getTestNamePostfix()).c_str(),		"STENCIL_REF",						GL_STENCIL_REF)));
2869 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefTestCase			(m_context,	 verifier, (std::string("stencil_back_ref")						+ verifier->getTestNamePostfix()).c_str(),		"STENCIL_BACK_REF",					GL_STENCIL_BACK_REF)));
2870 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase	(m_context,	 verifier, (std::string("stencil_ref_separate")					+ verifier->getTestNamePostfix()).c_str(),		"STENCIL_REF (separate)",			GL_STENCIL_REF,			GL_FRONT)));
2871 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase	(m_context,	 verifier, (std::string("stencil_ref_separate_both")			+ verifier->getTestNamePostfix()).c_str(),		"STENCIL_REF (separate)",			GL_STENCIL_REF,			GL_FRONT_AND_BACK)));
2872 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase	(m_context,	 verifier, (std::string("stencil_back_ref_separate")			+ verifier->getTestNamePostfix()).c_str(),		"STENCIL_BACK_REF (separate)",		GL_STENCIL_BACK_REF,	GL_BACK)));
2873 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase	(m_context,	 verifier, (std::string("stencil_back_ref_separate_both")		+ verifier->getTestNamePostfix()).c_str(),		"STENCIL_BACK_REF (separate)",		GL_STENCIL_BACK_REF,	GL_FRONT_AND_BACK)));
2874 
2875 	const struct NamedStencilOp
2876 	{
2877 		const char*		name;
2878 
2879 		const char*		frontDescription;
2880 		GLenum			frontTarget;
2881 		const char*		backDescription;
2882 		GLenum			backTarget;
2883 	} stencilOps[] =
2884 	{
2885 		{ "fail",		"STENCIL_FAIL",				GL_STENCIL_FAIL,			"STENCIL_BACK_FAIL",			GL_STENCIL_BACK_FAIL			},
2886 		{ "depth_fail",	"STENCIL_PASS_DEPTH_FAIL",	GL_STENCIL_PASS_DEPTH_FAIL,	"STENCIL_BACK_PASS_DEPTH_FAIL",	GL_STENCIL_BACK_PASS_DEPTH_FAIL	},
2887 		{ "depth_pass",	"STENCIL_PASS_DEPTH_PASS",	GL_STENCIL_PASS_DEPTH_PASS,	"STENCIL_BACK_PASS_DEPTH_PASS",	GL_STENCIL_BACK_PASS_DEPTH_PASS	}
2888 	};
2889 
2890 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(stencilOps); testNdx++)
2891 	{
2892 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpTestCase			(m_context, verifier, (std::string("stencil_")		+ stencilOps[testNdx].name + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].frontDescription,	stencilOps[testNdx].frontTarget)));
2893 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpTestCase			(m_context, verifier, (std::string("stencil_back_")	+ stencilOps[testNdx].name + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].backDescription,	stencilOps[testNdx].backTarget)));
2894 
2895 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase	(m_context, verifier, (std::string("stencil_")		+ stencilOps[testNdx].name + "_separate_both"	+ verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].frontDescription,	stencilOps[testNdx].frontTarget,	GL_FRONT_AND_BACK)));
2896 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase	(m_context, verifier, (std::string("stencil_back_")	+ stencilOps[testNdx].name + "_separate_both"	+ verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].backDescription,		stencilOps[testNdx].backTarget,		GL_FRONT_AND_BACK)));
2897 
2898 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase	(m_context, verifier, (std::string("stencil_")		+ stencilOps[testNdx].name + "_separate"		+ verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].frontDescription,	stencilOps[testNdx].frontTarget,	GL_FRONT)));
2899 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase	(m_context, verifier, (std::string("stencil_back_")	+ stencilOps[testNdx].name + "_separate"		+ verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].backDescription,		stencilOps[testNdx].backTarget,		GL_BACK)));
2900 	}
2901 
2902 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncTestCase					(m_context, verifier,	(std::string("stencil_func")								+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_FUNC")));
2903 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase			(m_context, verifier,	(std::string("stencil_func_separate")						+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_FUNC (separate)",				GL_STENCIL_FUNC,				GL_FRONT)));
2904 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase			(m_context, verifier,	(std::string("stencil_func_separate_both")					+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_FUNC (separate)",				GL_STENCIL_FUNC,				GL_FRONT_AND_BACK)));
2905 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase			(m_context, verifier,	(std::string("stencil_back_func_separate")					+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_FUNC (separate)",				GL_STENCIL_BACK_FUNC,			GL_BACK)));
2906 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase			(m_context, verifier,	(std::string("stencil_back_func_separate_both")				+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_FUNC (separate)",				GL_STENCIL_BACK_FUNC,			GL_FRONT_AND_BACK)));
2907 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskTestCase					(m_context, verifier,	(std::string("stencil_value_mask")							+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_VALUE_MASK",					GL_STENCIL_VALUE_MASK)));
2908 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskTestCase					(m_context, verifier,	(std::string("stencil_back_value_mask")						+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_BACK_VALUE_MASK",				GL_STENCIL_BACK_VALUE_MASK)));
2909 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase			(m_context, verifier,	(std::string("stencil_value_mask_separate")					+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_VALUE_MASK (separate)",		GL_STENCIL_VALUE_MASK,			GL_FRONT)));
2910 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase			(m_context, verifier,	(std::string("stencil_value_mask_separate_both")			+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_VALUE_MASK (separate)",		GL_STENCIL_VALUE_MASK,			GL_FRONT_AND_BACK)));
2911 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase			(m_context, verifier,	(std::string("stencil_back_value_mask_separate")			+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_BACK_VALUE_MASK (separate)",	GL_STENCIL_BACK_VALUE_MASK,		GL_BACK)));
2912 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase			(m_context, verifier,	(std::string("stencil_back_value_mask_separate_both")		+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_BACK_VALUE_MASK (separate)",	GL_STENCIL_BACK_VALUE_MASK,		GL_FRONT_AND_BACK)));
2913 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskTestCase			(m_context, verifier,	(std::string("stencil_writemask")							+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_WRITEMASK",					GL_STENCIL_WRITEMASK)));
2914 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskTestCase			(m_context, verifier,	(std::string("stencil_back_writemask")						+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_BACK_WRITEMASK",				GL_STENCIL_BACK_WRITEMASK)));
2915 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase	(m_context, verifier,	(std::string("stencil_writemask_separate")					+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_WRITEMASK (separate)",			GL_STENCIL_WRITEMASK,			GL_FRONT)));
2916 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase	(m_context, verifier,	(std::string("stencil_writemask_separate_both")				+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_WRITEMASK (separate)",			GL_STENCIL_WRITEMASK,			GL_FRONT_AND_BACK)));
2917 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase	(m_context, verifier,	(std::string("stencil_back_writemask_separate")				+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_BACK_WRITEMASK (separate)",	GL_STENCIL_BACK_WRITEMASK,		GL_BACK)));
2918 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase	(m_context, verifier,	(std::string("stencil_back_writemask_separate_both")		+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_BACK_WRITEMASK (separate)",	GL_STENCIL_BACK_WRITEMASK,		GL_FRONT_AND_BACK)));
2919 
2920 	const struct PixelStoreState
2921 	{
2922 		const char*	name;
2923 		const char*	description;
2924 		GLenum		target;
2925 		int			initialValue;
2926 	} pixelStoreStates[] =
2927 	{
2928 		{ "unpack_image_height","UNPACK_IMAGE_HEIGHT",	GL_UNPACK_IMAGE_HEIGHT,	0 },
2929 		{ "unpack_skip_images",	"UNPACK_SKIP_IMAGES",	GL_UNPACK_SKIP_IMAGES,	0 },
2930 		{ "unpack_row_length",	"UNPACK_ROW_LENGTH",	GL_UNPACK_ROW_LENGTH,	0 },
2931 		{ "unpack_skip_rows",	"UNPACK_SKIP_ROWS",		GL_UNPACK_SKIP_ROWS,	0 },
2932 		{ "unpack_skip_pixels",	"UNPACK_SKIP_PIXELS",	GL_UNPACK_SKIP_PIXELS,	0 },
2933 		{ "pack_row_length",	"PACK_ROW_LENGTH",		GL_PACK_ROW_LENGTH,		0 },
2934 		{ "pack_skip_rows",		"PACK_SKIP_ROWS",		GL_PACK_SKIP_ROWS,		0 },
2935 		{ "pack_skip_pixels",	"PACK_SKIP_PIXELS",		GL_PACK_SKIP_PIXELS,	0 }
2936 	};
2937 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(pixelStoreStates); testNdx++)
2938 	{
2939 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreTestCase(m_context, verifier, (std::string(pixelStoreStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(), pixelStoreStates[testNdx].description, pixelStoreStates[testNdx].target, pixelStoreStates[testNdx].initialValue)));
2940 	}
2941 
2942 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("unpack_alignment")	+ verifier->getTestNamePostfix()).c_str(),	"UNPACK_ALIGNMENT",	GL_UNPACK_ALIGNMENT)));
2943 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("pack_alignment")		+ verifier->getTestNamePostfix()).c_str(),	"PACK_ALIGNMENT",	GL_PACK_ALIGNMENT)));
2944 
2945 	const struct BlendColorState
2946 	{
2947 		const char*	name;
2948 		const char*	description;
2949 		GLenum		target;
2950 		int			initialValue;
2951 	} blendColorStates[] =
2952 	{
2953 		{ "blend_src_rgb",		"BLEND_SRC_RGB",	GL_BLEND_SRC_RGB,		GL_ONE	},
2954 		{ "blend_src_alpha",	"BLEND_SRC_ALPHA",	GL_BLEND_SRC_ALPHA,		GL_ONE	},
2955 		{ "blend_dst_rgb",		"BLEND_DST_RGB",	GL_BLEND_DST_RGB,		GL_ZERO	},
2956 		{ "blend_dst_alpha",	"BLEND_DST_ALPHA",	GL_BLEND_DST_ALPHA,		GL_ZERO	}
2957 	};
2958 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendColorStates); testNdx++)
2959 	{
2960 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendFuncTestCase			(m_context, verifier, (std::string(blendColorStates[testNdx].name)					+ verifier->getTestNamePostfix()).c_str(),	blendColorStates[testNdx].description,	blendColorStates[testNdx].target,	blendColorStates[testNdx].initialValue)));
2961 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendFuncSeparateTestCase	(m_context, verifier, (std::string(blendColorStates[testNdx].name) + "_separate"	+ verifier->getTestNamePostfix()).c_str(),	blendColorStates[testNdx].description,	blendColorStates[testNdx].target,	blendColorStates[testNdx].initialValue)));
2962 	}
2963 
2964 	const struct BlendEquationState
2965 	{
2966 		const char*	name;
2967 		const char*	description;
2968 		GLenum		target;
2969 		int			initialValue;
2970 	} blendEquationStates[] =
2971 	{
2972 		{ "blend_equation_rgb",		"BLEND_EQUATION_RGB",	GL_BLEND_EQUATION_RGB,		GL_FUNC_ADD	},
2973 		{ "blend_equation_alpha",	"BLEND_EQUATION_ALPHA",	GL_BLEND_EQUATION_ALPHA,	GL_FUNC_ADD	}
2974 	};
2975 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendEquationStates); testNdx++)
2976 	{
2977 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendEquationTestCase			(m_context, verifier, (std::string(blendEquationStates[testNdx].name) +				+ verifier->getTestNamePostfix()).c_str(),		blendEquationStates[testNdx].description,	blendEquationStates[testNdx].target,	blendEquationStates[testNdx].initialValue)));
2978 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendEquationSeparateTestCase	(m_context, verifier, (std::string(blendEquationStates[testNdx].name) + "_separate"	+ verifier->getTestNamePostfix()).c_str(),		blendEquationStates[testNdx].description,	blendEquationStates[testNdx].target,	blendEquationStates[testNdx].initialValue)));
2979 	}
2980 
2981 	const struct ImplementationArrayReturningState
2982 	{
2983 		const char*	name;
2984 		const char*	description;
2985 		GLenum		target;
2986 		GLenum		targetLengthTarget;
2987 		int			minLength;
2988 	} implementationArrayReturningStates[] =
2989 	{
2990 		{ "compressed_texture_formats",		"COMPRESSED_TEXTURE_FORMATS",	GL_COMPRESSED_TEXTURE_FORMATS,	GL_NUM_COMPRESSED_TEXTURE_FORMATS,	10	},
2991 		{ "program_binary_formats",			"PROGRAM_BINARY_FORMATS",		GL_PROGRAM_BINARY_FORMATS,		GL_NUM_PROGRAM_BINARY_FORMATS,		0	},
2992 		{ "shader_binary_formats",			"SHADER_BINARY_FORMATS",		GL_SHADER_BINARY_FORMATS,		GL_NUM_SHADER_BINARY_FORMATS,		0	}
2993 	};
2994 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationArrayReturningStates); testNdx++)
2995 	{
2996 		FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationArrayTestCase(m_context, verifier, (std::string(implementationArrayReturningStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(), implementationArrayReturningStates[testNdx].description,	implementationArrayReturningStates[testNdx].target,	implementationArrayReturningStates[testNdx].targetLengthTarget,	implementationArrayReturningStates[testNdx].minLength)));
2997 	}
2998 
2999 	const struct BufferBindingState
3000 	{
3001 		const char*	name;
3002 		const char*	description;
3003 		GLenum		target;
3004 		GLenum		type;
3005 	} bufferBindingStates[] =
3006 	{
3007 		{ "array_buffer_binding",				"ARRAY_BUFFER_BINDING",					GL_ARRAY_BUFFER_BINDING,				GL_ARRAY_BUFFER				},
3008 		{ "uniform_buffer_binding",				"UNIFORM_BUFFER_BINDING",				GL_UNIFORM_BUFFER_BINDING,				GL_UNIFORM_BUFFER			},
3009 		{ "pixel_pack_buffer_binding",			"PIXEL_PACK_BUFFER_BINDING",			GL_PIXEL_PACK_BUFFER_BINDING,			GL_PIXEL_PACK_BUFFER		},
3010 		{ "pixel_unpack_buffer_binding",		"PIXEL_UNPACK_BUFFER_BINDING",			GL_PIXEL_UNPACK_BUFFER_BINDING,			GL_PIXEL_UNPACK_BUFFER		},
3011 		{ "transform_feedback_buffer_binding",	"TRANSFORM_FEEDBACK_BUFFER_BINDING",	GL_TRANSFORM_FEEDBACK_BUFFER_BINDING,	GL_TRANSFORM_FEEDBACK_BUFFER},
3012 		{ "copy_read_buffer_binding",			"COPY_READ_BUFFER_BINDING",				GL_COPY_READ_BUFFER_BINDING,			GL_COPY_READ_BUFFER			},
3013 		{ "copy_write_buffer_binding",			"COPY_WRITE_BUFFER_BINDING",			GL_COPY_WRITE_BUFFER_BINDING,			GL_COPY_WRITE_BUFFER		}
3014 	};
3015 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(bufferBindingStates); testNdx++)
3016 	{
3017 		FOR_EACH_QUERYTYPE(queryTypes, addChild(new BufferBindingTestCase(m_context, queryType, (std::string(bufferBindingStates[testNdx].name) + getQueryTypeSuffix(queryType)).c_str(), bufferBindingStates[testNdx].description, bufferBindingStates[testNdx].target, bufferBindingStates[testNdx].type)));
3018 	}
3019 
3020 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new ElementArrayBufferBindingTestCase	(m_context, queryType, (std::string("element_array_buffer_binding")	+ getQueryTypeSuffix(queryType)).c_str())));
3021 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new TransformFeedbackBindingTestCase	(m_context, queryType, (std::string("transform_feedback_binding")	+ getQueryTypeSuffix(queryType)).c_str())));
3022 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new CurrentProgramBindingTestCase		(m_context, queryType, (std::string("current_program_binding")		+ getQueryTypeSuffix(queryType)).c_str(),	"CURRENT_PROGRAM")));
3023 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new VertexArrayBindingTestCase			(m_context, queryType, (std::string("vertex_array_binding")			+ getQueryTypeSuffix(queryType)).c_str(),	"VERTEX_ARRAY_BINDING")));
3024 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilClearValueTestCase			(m_context, verifier, (std::string("stencil_clear_value")			+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_CLEAR_VALUE")));
3025 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ActiveTextureTestCase				(m_context, verifier, (std::string("active_texture")				+ verifier->getTestNamePostfix()).c_str(),	"ACTIVE_TEXTURE")));
3026 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new RenderbufferBindingTestCase			(m_context, queryType, (std::string("renderbuffer_binding")			+ getQueryTypeSuffix(queryType)).c_str(),	"RENDERBUFFER_BINDING")));
3027 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new SamplerObjectBindingTestCase		(m_context, queryType, (std::string("sampler_binding")				+ getQueryTypeSuffix(queryType)).c_str(),	"SAMPLER_BINDING")));
3028 
3029 	const struct TextureBinding
3030 	{
3031 		const char*	name;
3032 		const char*	description;
3033 		GLenum		target;
3034 		GLenum		type;
3035 	} textureBindings[] =
3036 	{
3037 		{ "texture_binding_2d",			"TEXTURE_BINDING_2D",		GL_TEXTURE_BINDING_2D,			GL_TEXTURE_2D		},
3038 		{ "texture_binding_3d",			"TEXTURE_BINDING_3D",		GL_TEXTURE_BINDING_3D,			GL_TEXTURE_3D		},
3039 		{ "texture_binding_2d_array",	"TEXTURE_BINDING_2D_ARRAY",	GL_TEXTURE_BINDING_2D_ARRAY,	GL_TEXTURE_2D_ARRAY	},
3040 		{ "texture_binding_cube_map",	"TEXTURE_BINDING_CUBE_MAP",	GL_TEXTURE_BINDING_CUBE_MAP,	GL_TEXTURE_CUBE_MAP	}
3041 	};
3042 
3043 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(textureBindings); testNdx++)
3044 	{
3045 		FOR_EACH_QUERYTYPE(queryTypes, addChild(new TextureBindingTestCase(m_context, queryType, (std::string(textureBindings[testNdx].name) + getQueryTypeSuffix(queryType)).c_str(), textureBindings[testNdx].description, textureBindings[testNdx].target, textureBindings[testNdx].type)));
3046 	}
3047 
3048 
3049 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new FrameBufferBindingTestCase		(m_context, queryType, (std::string("framebuffer_binding")			+ getQueryTypeSuffix(queryType)).c_str(),	"DRAW_FRAMEBUFFER_BINDING and READ_FRAMEBUFFER_BINDING")));
3050 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationColorReadTestCase	(m_context, verifier, (std::string("implementation_color_read")		+ verifier->getTestNamePostfix()).c_str(),	"IMPLEMENTATION_COLOR_READ_TYPE and IMPLEMENTATION_COLOR_READ_FORMAT")));
3051 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ReadBufferCase					(m_context, verifier, (std::string("read_buffer")					+ verifier->getTestNamePostfix()).c_str(),	"READ_BUFFER")));
3052 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new DrawBufferCase					(m_context, verifier, (std::string("draw_buffer")					+ verifier->getTestNamePostfix()).c_str(),	"DRAW_BUFFER")));
3053 }
3054 
deinit(void)3055 void IntegerStateQueryTests::deinit (void)
3056 {
3057 	if (m_verifierBoolean)
3058 	{
3059 		delete m_verifierBoolean;
3060 		m_verifierBoolean = DE_NULL;
3061 	}
3062 	if (m_verifierInteger)
3063 	{
3064 		delete m_verifierInteger;
3065 		m_verifierInteger = DE_NULL;
3066 	}
3067 	if (m_verifierInteger64)
3068 	{
3069 		delete m_verifierInteger64;
3070 		m_verifierInteger64 = DE_NULL;
3071 	}
3072 	if (m_verifierFloat)
3073 	{
3074 		delete m_verifierFloat;
3075 		m_verifierFloat = DE_NULL;
3076 	}
3077 
3078 	this->TestCaseGroup::deinit();
3079 }
3080 
3081 } // Functional
3082 } // gles3
3083 } // deqp
3084