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