Home | History | Annotate | Download | only in functional
      1 /*-------------------------------------------------------------------------
      2  * drawElements Quality Program OpenGL ES 2.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 "es2fIntegerStateQueryTests.hpp"
     25 #include "es2fApiCase.hpp"
     26 
     27 #include "glsStateQueryUtil.hpp"
     28 
     29 #include "gluRenderContext.hpp"
     30 #include "gluContextInfo.hpp"
     31 #include "gluStrUtil.hpp"
     32 
     33 #include "tcuRenderTarget.hpp"
     34 
     35 #include "deRandom.hpp"
     36 
     37 #include "glwEnums.hpp"
     38 
     39 using namespace glw; // GLint and other GL types
     40 using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
     41 
     42 #ifndef GL_SLUMINANCE_NV
     43 #define	GL_SLUMINANCE_NV 0x8C46
     44 #endif
     45 #ifndef GL_SLUMINANCE_ALPHA_NV
     46 #define	GL_SLUMINANCE_ALPHA_NV 0x8C44
     47 #endif
     48 #ifndef GL_BGR_NV
     49 #define GL_BGR_NV 0x80E0
     50 #endif
     51 
     52 namespace deqp
     53 {
     54 namespace gles2
     55 {
     56 namespace Functional
     57 {
     58 namespace IntegerStateQueryVerifiers
     59 {
     60 
     61 // StateVerifier
     62 
     63 class StateVerifier : protected glu::CallLogWrapper
     64 {
     65 public:
     66 						StateVerifier						(const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix);
     67 	virtual				~StateVerifier						(); // make GCC happy
     68 
     69 	const char*			getTestNamePostfix					(void) const;
     70 
     71 	virtual void		verifyInteger						(tcu::TestContext& testCtx, GLenum name, GLint reference)																																= DE_NULL;
     72 	virtual void		verifyInteger4						(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)																		= DE_NULL;
     73 	virtual void		verifyInteger4Mask					(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)	= DE_NULL;
     74 	virtual void		verifyIntegerGreaterOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference)																																= DE_NULL;
     75 	virtual void		verifyUnsignedIntegerGreaterOrEqual	(tcu::TestContext& testCtx, GLenum name, GLuint reference)																																= DE_NULL;
     76 	virtual void		verifyIntegerGreaterOrEqual2		(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)																											= DE_NULL;
     77 	virtual void		verifyIntegerAnyOf					(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)																								= DE_NULL;
     78 	virtual void		verifyStencilMaskInitial			(tcu::TestContext& testCtx, GLenum name, int stencilBits)																																= DE_NULL;
     79 
     80 private:
     81 	const char*	const	m_testNamePostfix;
     82 };
     83 
     84 StateVerifier::StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix)
     85 	: glu::CallLogWrapper	(gl, log)
     86 	, m_testNamePostfix		(testNamePostfix)
     87 {
     88 	enableLogging(true);
     89 }
     90 
     91 StateVerifier::~StateVerifier ()
     92 {
     93 }
     94 
     95 const char* StateVerifier::getTestNamePostfix (void) const
     96 {
     97 	return m_testNamePostfix;
     98 }
     99 
    100 // GetBooleanVerifier
    101 
    102 class GetBooleanVerifier : public StateVerifier
    103 {
    104 public:
    105 			GetBooleanVerifier					(const glw::Functions& gl, tcu::TestLog& log);
    106 	void	verifyInteger						(tcu::TestContext& testCtx, GLenum name, GLint reference);
    107 	void	verifyInteger4						(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
    108 	void	verifyInteger4Mask					(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
    109 	void	verifyIntegerGreaterOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
    110 	void	verifyUnsignedIntegerGreaterOrEqual	(tcu::TestContext& testCtx, GLenum name, GLuint reference);
    111 	void	verifyIntegerGreaterOrEqual2		(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
    112 	void	verifyIntegerAnyOf					(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
    113 	void	verifyStencilMaskInitial			(tcu::TestContext& testCtx, GLenum name, int stencilBits);
    114 };
    115 
    116 GetBooleanVerifier::GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log)
    117 	: StateVerifier(gl, log, "_getboolean")
    118 {
    119 }
    120 
    121 void GetBooleanVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
    122 {
    123 	using tcu::TestLog;
    124 
    125 	StateQueryMemoryWriteGuard<GLboolean> state;
    126 	glGetBooleanv(name, &state);
    127 
    128 	if (!state.verifyValidity(testCtx))
    129 		return;
    130 
    131 	const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE;
    132 
    133 	if (state != expectedGLState)
    134 	{
    135 		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;
    136 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    137 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    138 	}
    139 }
    140 
    141 void GetBooleanVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
    142 {
    143 	verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
    144 }
    145 
    146 void GetBooleanVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
    147 {
    148 	using tcu::TestLog;
    149 
    150 	StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4;
    151 	glGetBooleanv(name, boolVector4);
    152 
    153 	if (!boolVector4.verifyValidity(testCtx))
    154 		return;
    155 
    156 	const GLboolean referenceAsGLBoolean[] =
    157 	{
    158 		reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
    159 		reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
    160 		reference2 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
    161 		reference3 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
    162 	};
    163 
    164 	if ((enableRef0 && (boolVector4[0] != referenceAsGLBoolean[0])) ||
    165 		(enableRef1 && (boolVector4[1] != referenceAsGLBoolean[1])) ||
    166 		(enableRef2 && (boolVector4[2] != referenceAsGLBoolean[2])) ||
    167 		(enableRef3 && (boolVector4[3] != referenceAsGLBoolean[3])))
    168 	{
    169 		testCtx.getLog() << TestLog::Message << "// ERROR: expected "
    170 			<< (enableRef0 ? (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
    171 			<< (enableRef1 ? (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
    172 			<< (enableRef2 ? (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", "
    173 			<< (enableRef3 ? (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") : " - ") << TestLog::EndMessage;
    174 
    175 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    176 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    177 	}
    178 }
    179 
    180 void GetBooleanVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
    181 {
    182 	using tcu::TestLog;
    183 
    184 	StateQueryMemoryWriteGuard<GLboolean> state;
    185 	glGetBooleanv(name, &state);
    186 
    187 	if (!state.verifyValidity(testCtx))
    188 		return;
    189 
    190 	if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct)
    191 		return;
    192 
    193 	if (state == GL_FALSE) // state is zero
    194 	{
    195 		if (reference > 0) // and reference is greater than zero?
    196 		{
    197 			testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
    198 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    199 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    200 		}
    201 	}
    202 	else
    203 	{
    204 		testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
    205 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    206 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    207 	}
    208 }
    209 
    210 void GetBooleanVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
    211 {
    212 	using tcu::TestLog;
    213 
    214 	StateQueryMemoryWriteGuard<GLboolean> state;
    215 	glGetBooleanv(name, &state);
    216 
    217 	if (!state.verifyValidity(testCtx))
    218 		return;
    219 
    220 	if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct)
    221 		return;
    222 
    223 	if (state == GL_FALSE) // state is zero
    224 	{
    225 		if (reference > 0) // and reference is greater than zero?
    226 		{
    227 			testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
    228 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    229 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    230 		}
    231 	}
    232 	else
    233 	{
    234 		testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
    235 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    236 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    237 	}
    238 }
    239 
    240 void GetBooleanVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
    241 {
    242 	using tcu::TestLog;
    243 
    244 	StateQueryMemoryWriteGuard<GLboolean[2]> boolVector;
    245 	glGetBooleanv(name, boolVector);
    246 
    247 	if (!boolVector.verifyValidity(testCtx))
    248 		return;
    249 
    250 	const GLboolean referenceAsGLBoolean[2] =
    251 	{
    252 		reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE,
    253 		reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE
    254 	};
    255 
    256 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceAsGLBoolean); ++ndx)
    257 	{
    258 		if (boolVector[ndx] == GL_TRUE) // state is non-zero, could be greater than any integer
    259 		{
    260 			continue;
    261 		}
    262 		else if (boolVector[ndx] == GL_FALSE) // state is zero
    263 		{
    264 			if (referenceAsGLBoolean[ndx] > 0) // and reference is greater than zero?
    265 			{
    266 				testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
    267 				if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    268 					testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    269 			}
    270 		}
    271 		else
    272 		{
    273 			testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage;
    274 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    275 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    276 		}
    277 	}
    278 }
    279 
    280 void GetBooleanVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
    281 {
    282 	using tcu::TestLog;
    283 
    284 	StateQueryMemoryWriteGuard<GLboolean> state;
    285 	glGetBooleanv(name, &state);
    286 
    287 	if (!state.verifyValidity(testCtx))
    288 		return;
    289 
    290 	for (size_t ndx = 0; ndx < referencesLength; ++ndx)
    291 	{
    292 		const GLboolean expectedGLState = references[ndx] ? GL_TRUE : GL_FALSE;
    293 
    294 		if (state == expectedGLState)
    295 			return;
    296 	}
    297 
    298 	testCtx.getLog() << TestLog::Message << "// ERROR: got " << (state==GL_TRUE ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
    299 	if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    300 		testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    301 }
    302 
    303 void GetBooleanVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
    304 {
    305 	// if stencilBits == 0, the mask is allowed to be either GL_TRUE or GL_FALSE
    306 	// otherwise it must be GL_TRUE
    307 	using tcu::TestLog;
    308 
    309 	StateQueryMemoryWriteGuard<GLboolean> state;
    310 	glGetBooleanv(name, &state);
    311 
    312 	if (!state.verifyValidity(testCtx))
    313 		return;
    314 
    315 	if (stencilBits > 0 && state != GL_TRUE)
    316 	{
    317 		testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage;
    318 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    319 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    320 	}
    321 }
    322 
    323 //GetIntegerVerifier
    324 
    325 class GetIntegerVerifier : public StateVerifier
    326 {
    327 public:
    328 			GetIntegerVerifier			(const glw::Functions& gl, tcu::TestLog& log);
    329 	void	verifyInteger						(tcu::TestContext& testCtx, GLenum name, GLint reference);
    330 	void	verifyInteger4						(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
    331 	void	verifyInteger4Mask					(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
    332 	void	verifyIntegerGreaterOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
    333 	void	verifyUnsignedIntegerGreaterOrEqual	(tcu::TestContext& testCtx, GLenum name, GLuint reference);
    334 	void	verifyIntegerGreaterOrEqual2		(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
    335 	void	verifyIntegerAnyOf					(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
    336 	void	verifyStencilMaskInitial			(tcu::TestContext& testCtx, GLenum name, int stencilBits);
    337 };
    338 
    339 GetIntegerVerifier::GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log)
    340 	: StateVerifier(gl, log, "_getinteger")
    341 {
    342 }
    343 
    344 void GetIntegerVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
    345 {
    346 	using tcu::TestLog;
    347 
    348 	StateQueryMemoryWriteGuard<GLint> state;
    349 	glGetIntegerv(name, &state);
    350 
    351 	if (!state.verifyValidity(testCtx))
    352 		return;
    353 
    354 	if (state != reference)
    355 	{
    356 		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage;
    357 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    358 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    359 	}
    360 }
    361 
    362 void GetIntegerVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
    363 {
    364 	verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
    365 }
    366 
    367 void GetIntegerVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
    368 {
    369 	using tcu::TestLog;
    370 
    371 	StateQueryMemoryWriteGuard<GLint[4]> intVector4;
    372 	glGetIntegerv(name, intVector4);
    373 
    374 	if (!intVector4.verifyValidity(testCtx))
    375 		return;
    376 
    377 	if ((enableRef0 && (intVector4[0] != reference0)) ||
    378 		(enableRef1 && (intVector4[1] != reference1)) ||
    379 		(enableRef2 && (intVector4[2] != reference2)) ||
    380 		(enableRef3 && (intVector4[3] != reference3)))
    381 	{
    382 		testCtx.getLog() << TestLog::Message << "// ERROR: expected "
    383 			<< (enableRef0?"":"(") << reference0 << (enableRef0?"":")") << ", "
    384 			<< (enableRef1?"":"(") << reference1 << (enableRef1?"":")") << ", "
    385 			<< (enableRef2?"":"(") << reference2 << (enableRef2?"":")") << ", "
    386 			<< (enableRef3?"":"(") << reference3 << (enableRef3?"":")")	<< TestLog::EndMessage;
    387 
    388 
    389 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    390 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    391 	}
    392 }
    393 
    394 void GetIntegerVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
    395 {
    396 	using tcu::TestLog;
    397 
    398 	StateQueryMemoryWriteGuard<GLint> state;
    399 	glGetIntegerv(name, &state);
    400 
    401 	if (!state.verifyValidity(testCtx))
    402 		return;
    403 
    404 	if (state < reference)
    405 	{
    406 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << state << TestLog::EndMessage;
    407 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    408 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    409 	}
    410 }
    411 
    412 void GetIntegerVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
    413 {
    414 	using tcu::TestLog;
    415 
    416 	StateQueryMemoryWriteGuard<GLint> state;
    417 	glGetIntegerv(name, &state);
    418 
    419 	if (!state.verifyValidity(testCtx))
    420 		return;
    421 
    422 	if (GLuint(state) < reference)
    423 	{
    424 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << GLuint(state) << TestLog::EndMessage;
    425 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    426 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    427 	}
    428 }
    429 
    430 void GetIntegerVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
    431 {
    432 	using tcu::TestLog;
    433 
    434 	StateQueryMemoryWriteGuard<GLint[2]> intVector2;
    435 	glGetIntegerv(name, intVector2);
    436 
    437 	if (!intVector2.verifyValidity(testCtx))
    438 		return;
    439 
    440 	if (intVector2[0] < reference0 || intVector2[1] < reference1)
    441 	{
    442 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference0 << ", " << reference1 << "; got " << intVector2[0] << ", " << intVector2[0] << TestLog::EndMessage;
    443 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    444 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    445 	}
    446 }
    447 
    448 void GetIntegerVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
    449 {
    450 	using tcu::TestLog;
    451 
    452 	StateQueryMemoryWriteGuard<GLint> state;
    453 	glGetIntegerv(name, &state);
    454 
    455 	if (!state.verifyValidity(testCtx))
    456 		return;
    457 
    458 	for (size_t ndx = 0; ndx < referencesLength; ++ndx)
    459 	{
    460 		const GLint expectedGLState = references[ndx];
    461 
    462 		if (state == expectedGLState)
    463 			return;
    464 	}
    465 
    466 	testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
    467 	if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    468 		testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    469 }
    470 
    471 void GetIntegerVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
    472 {
    473 	using tcu::TestLog;
    474 
    475 	StateQueryMemoryWriteGuard<GLint> state;
    476 	glGetIntegerv(name, &state);
    477 
    478 	if (!state.verifyValidity(testCtx))
    479 		return;
    480 
    481 	const GLint reference = (1 << stencilBits) - 1;
    482 
    483 	if ((state & reference) != reference) // the least significant stencilBits bits should be on
    484 	{
    485 		testCtx.getLog() << TestLog::Message << "// ERROR: expected minimum mask of " << reference << "; got " << state << TestLog::EndMessage;
    486 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    487 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value");
    488 	}
    489 }
    490 
    491 //GetFloatVerifier
    492 
    493 class GetFloatVerifier : public StateVerifier
    494 {
    495 public:
    496 			GetFloatVerifier					(const glw::Functions& gl, tcu::TestLog& log);
    497 	void	verifyInteger						(tcu::TestContext& testCtx, GLenum name, GLint reference);
    498 	void	verifyInteger4						(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3);
    499 	void	verifyInteger4Mask					(tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3);
    500 	void	verifyIntegerGreaterOrEqual			(tcu::TestContext& testCtx, GLenum name, GLint reference);
    501 	void	verifyUnsignedIntegerGreaterOrEqual	(tcu::TestContext& testCtx, GLenum name, GLuint reference);
    502 	void	verifyIntegerGreaterOrEqual2		(tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1);
    503 	void	verifyIntegerAnyOf					(tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength);
    504 	void	verifyStencilMaskInitial			(tcu::TestContext& testCtx, GLenum name, int stencilBits);
    505 };
    506 
    507 GetFloatVerifier::GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log)
    508 	: StateVerifier(gl, log, "_getfloat")
    509 {
    510 }
    511 
    512 void GetFloatVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference)
    513 {
    514 	using tcu::TestLog;
    515 
    516 	const GLfloat referenceAsFloat = GLfloat(reference);
    517 	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
    518 
    519 	StateQueryMemoryWriteGuard<GLfloat> state;
    520 	glGetFloatv(name, &state);
    521 
    522 	if (!state.verifyValidity(testCtx))
    523 		return;
    524 
    525 	if (state != referenceAsFloat)
    526 	{
    527 		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsFloat << "; got " << state << TestLog::EndMessage;
    528 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    529 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
    530 	}
    531 }
    532 
    533 void GetFloatVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3)
    534 {
    535 	verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true);
    536 }
    537 
    538 void GetFloatVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3)
    539 {
    540 	using tcu::TestLog;
    541 
    542 	StateQueryMemoryWriteGuard<GLfloat[4]> floatVector4;
    543 	glGetFloatv(name, floatVector4);
    544 
    545 	if (!floatVector4.verifyValidity(testCtx))
    546 		return;
    547 
    548 	if ((enableRef0 && (floatVector4[0] != GLfloat(reference0))) ||
    549 		(enableRef1 && (floatVector4[1] != GLfloat(reference1))) ||
    550 		(enableRef2 && (floatVector4[2] != GLfloat(reference2))) ||
    551 		(enableRef3 && (floatVector4[3] != GLfloat(reference3))))
    552 	{
    553 		testCtx.getLog() << TestLog::Message << "// ERROR: expected "
    554 			<< (enableRef0?"":"(") << GLfloat(reference0) << (enableRef0?"":")") << ", "
    555 			<< (enableRef1?"":"(") << GLfloat(reference1) << (enableRef1?"":")") << ", "
    556 			<< (enableRef2?"":"(") << GLfloat(reference2) << (enableRef2?"":")") << ", "
    557 			<< (enableRef3?"":"(") << GLfloat(reference3) << (enableRef3?"":")") << TestLog::EndMessage;
    558 
    559 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    560 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
    561 	}
    562 }
    563 
    564 void GetFloatVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference)
    565 {
    566 	using tcu::TestLog;
    567 
    568 	StateQueryMemoryWriteGuard<GLfloat> state;
    569 	glGetFloatv(name, &state);
    570 
    571 	if (!state.verifyValidity(testCtx))
    572 		return;
    573 
    574 	if (state < GLfloat(reference))
    575 	{
    576 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage;
    577 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    578 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
    579 	}
    580 }
    581 
    582 void GetFloatVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference)
    583 {
    584 	using tcu::TestLog;
    585 
    586 	StateQueryMemoryWriteGuard<GLfloat> state;
    587 	glGetFloatv(name, &state);
    588 
    589 	if (!state.verifyValidity(testCtx))
    590 		return;
    591 
    592 	if (GLuint(state) < GLfloat(reference))
    593 	{
    594 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << GLuint(state) << TestLog::EndMessage;
    595 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    596 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
    597 	}
    598 }
    599 
    600 void GetFloatVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1)
    601 {
    602 	using tcu::TestLog;
    603 
    604 	StateQueryMemoryWriteGuard<GLfloat[2]> floatVector2;
    605 	glGetFloatv(name, floatVector2);
    606 
    607 	if (!floatVector2.verifyValidity(testCtx))
    608 		return;
    609 
    610 	if (floatVector2[0] < GLfloat(reference0) || floatVector2[1] < GLfloat(reference1))
    611 	{
    612 		testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference0) << ", " << GLfloat(reference1) << "; got " << floatVector2[0] << ", " << floatVector2[1] << TestLog::EndMessage;
    613 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    614 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
    615 	}
    616 }
    617 
    618 void GetFloatVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength)
    619 {
    620 	using tcu::TestLog;
    621 
    622 	StateQueryMemoryWriteGuard<GLfloat> state;
    623 	glGetFloatv(name, &state);
    624 
    625 	if (!state.verifyValidity(testCtx))
    626 		return;
    627 
    628 	for (size_t ndx = 0; ndx < referencesLength; ++ndx)
    629 	{
    630 		const GLfloat expectedGLState = GLfloat(references[ndx]);
    631 		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
    632 
    633 		if (state == expectedGLState)
    634 			return;
    635 	}
    636 
    637 	testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage;
    638 	if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    639 		testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
    640 }
    641 
    642 void GetFloatVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits)
    643 {
    644 	// checking the mask bits with float doesn't make much sense because of conversion errors
    645 	// just verify that the value is greater or equal to the minimum value
    646 	const GLint reference = (1 << stencilBits) - 1;
    647 	verifyIntegerGreaterOrEqual(testCtx, name, reference);
    648 }
    649 
    650 } // IntegerStateQueryVerifiers
    651 
    652 namespace
    653 {
    654 
    655 using namespace IntegerStateQueryVerifiers;
    656 using namespace deqp::gls::StateQueryUtil;
    657 
    658 class ConstantMinimumValueTestCase : public ApiCase
    659 {
    660 public:
    661 	ConstantMinimumValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue)
    662 		: ApiCase		(context, name, description)
    663 		, m_targetName	(targetName)
    664 		, m_minValue	(minValue)
    665 		, m_verifier	(verifier)
    666 	{
    667 	}
    668 
    669 	void test (void)
    670 	{
    671 		m_verifier->verifyUnsignedIntegerGreaterOrEqual(m_testCtx, m_targetName, m_minValue);
    672 		expectError(GL_NO_ERROR);
    673 	}
    674 
    675 private:
    676 	GLenum			m_targetName;
    677 	GLint			m_minValue;
    678 	StateVerifier*	m_verifier;
    679 };
    680 
    681 class SampleBuffersTestCase : public ApiCase
    682 {
    683 public:
    684 	SampleBuffersTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    685 		: ApiCase		(context, name, description)
    686 		, m_verifier	(verifier)
    687 	{
    688 	}
    689 
    690 	void test (void)
    691 	{
    692 		const int expectedSampleBuffers = (m_context.getRenderTarget().getNumSamples() > 1) ? 1 : 0;
    693 
    694 		m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << ", expecting GL_SAMPLE_BUFFERS to be " << expectedSampleBuffers << tcu::TestLog::EndMessage;
    695 
    696 		m_verifier->verifyInteger(m_testCtx, GL_SAMPLE_BUFFERS, expectedSampleBuffers);
    697 		expectError(GL_NO_ERROR);
    698 	}
    699 
    700 private:
    701 	StateVerifier*	m_verifier;
    702 };
    703 
    704 class SamplesTestCase : public ApiCase
    705 {
    706 public:
    707 	SamplesTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    708 		: ApiCase		(context, name, description)
    709 		, m_verifier	(verifier)
    710 	{
    711 	}
    712 
    713 	void test (void)
    714 	{
    715 		// MSAA?
    716 		if (m_context.getRenderTarget().getNumSamples() > 1)
    717 		{
    718 			m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << tcu::TestLog::EndMessage;
    719 
    720 			m_verifier->verifyInteger(m_testCtx, GL_SAMPLES, m_context.getRenderTarget().getNumSamples());
    721 			expectError(GL_NO_ERROR);
    722 		}
    723 		else
    724 		{
    725 			const glw::GLint validSamples[] = {0, 1};
    726 
    727 			m_log << tcu::TestLog::Message << "Expecting GL_SAMPLES to be 0 or 1" << tcu::TestLog::EndMessage;
    728 
    729 			m_verifier->verifyIntegerAnyOf(m_testCtx, GL_SAMPLES, validSamples, DE_LENGTH_OF_ARRAY(validSamples));
    730 			expectError(GL_NO_ERROR);
    731 		}
    732 	}
    733 
    734 private:
    735 	StateVerifier*	m_verifier;
    736 };
    737 
    738 class HintTestCase : public ApiCase
    739 {
    740 public:
    741 	HintTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName)
    742 		: ApiCase		(context, name, description)
    743 		, m_targetName	(targetName)
    744 		, m_verifier	(verifier)
    745 	{
    746 	}
    747 
    748 	void test (void)
    749 	{
    750 		m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE);
    751 		expectError(GL_NO_ERROR);
    752 
    753 		glHint(m_targetName, GL_NICEST);
    754 		m_verifier->verifyInteger(m_testCtx, m_targetName, GL_NICEST);
    755 		expectError(GL_NO_ERROR);
    756 
    757 		glHint(m_targetName, GL_FASTEST);
    758 		m_verifier->verifyInteger(m_testCtx, m_targetName, GL_FASTEST);
    759 		expectError(GL_NO_ERROR);
    760 
    761 		glHint(m_targetName, GL_DONT_CARE);
    762 		m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE);
    763 		expectError(GL_NO_ERROR);
    764 	}
    765 
    766 private:
    767 	GLenum		m_targetName;
    768 	StateVerifier*	m_verifier;
    769 };
    770 
    771 class DepthFuncTestCase : public ApiCase
    772 {
    773 public:
    774 	DepthFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    775 		: ApiCase		(context, name, description)
    776 		, m_verifier	(verifier)
    777 	{
    778 	}
    779 
    780 	void test (void)
    781 	{
    782 		m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, GL_LESS);
    783 		expectError(GL_NO_ERROR);
    784 
    785 		const GLenum depthFunctions[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GREATER, GL_GEQUAL, GL_NOTEQUAL};
    786 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthFunctions); ndx++)
    787 		{
    788 			glDepthFunc(depthFunctions[ndx]);
    789 			expectError(GL_NO_ERROR);
    790 
    791 			m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, depthFunctions[ndx]);
    792 			expectError(GL_NO_ERROR);
    793 		}
    794 	}
    795 
    796 private:
    797 	StateVerifier*	m_verifier;
    798 };
    799 
    800 class CullFaceTestCase : public ApiCase
    801 {
    802 public:
    803 	CullFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    804 		: ApiCase		(context, name, description)
    805 		, m_verifier	(verifier)
    806 	{
    807 	}
    808 
    809 	void test (void)
    810 	{
    811 		m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, GL_BACK);
    812 		expectError(GL_NO_ERROR);
    813 
    814 		const GLenum cullFaces[] = {GL_FRONT, GL_BACK, GL_FRONT_AND_BACK};
    815 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cullFaces); ndx++)
    816 		{
    817 			glCullFace(cullFaces[ndx]);
    818 			expectError(GL_NO_ERROR);
    819 
    820 			m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, cullFaces[ndx]);
    821 			expectError(GL_NO_ERROR);
    822 		}
    823 	}
    824 
    825 private:
    826 	StateVerifier*	m_verifier;
    827 };
    828 
    829 class FrontFaceTestCase : public ApiCase
    830 {
    831 public:
    832 	FrontFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    833 		: ApiCase		(context, name, description)
    834 		, m_verifier	(verifier)
    835 	{
    836 	}
    837 
    838 	void test (void)
    839 	{
    840 		m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, GL_CCW);
    841 		expectError(GL_NO_ERROR);
    842 
    843 		const GLenum frontFaces[] = {GL_CW, GL_CCW};
    844 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(frontFaces); ndx++)
    845 		{
    846 			glFrontFace(frontFaces[ndx]);
    847 			expectError(GL_NO_ERROR);
    848 
    849 			m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, frontFaces[ndx]);
    850 			expectError(GL_NO_ERROR);
    851 		}
    852 	}
    853 
    854 private:
    855 	StateVerifier*	m_verifier;
    856 };
    857 
    858 class ViewPortTestCase : public ApiCase
    859 {
    860 public:
    861 	ViewPortTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    862 		: ApiCase		(context, name, description)
    863 		, m_verifier	(verifier)
    864 	{
    865 	}
    866 
    867 	void test (void)
    868 	{
    869 		de::Random rnd(0xabcdef);
    870 
    871 		GLint maxViewportDimensions[2] = {0};
    872 		glGetIntegerv(GL_MAX_VIEWPORT_DIMS, maxViewportDimensions);
    873 
    874 		// verify initial value of first two values
    875 		m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, 0, 0, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight());
    876 		expectError(GL_NO_ERROR);
    877 
    878 		const int numIterations = 120;
    879 		for (int i = 0; i < numIterations; ++i)
    880 		{
    881 			GLint x			= rnd.getInt(-64000, 64000);
    882 			GLint y			= rnd.getInt(-64000, 64000);
    883 			GLsizei width	= rnd.getInt(0, maxViewportDimensions[0]);
    884 			GLsizei height	= rnd.getInt(0, maxViewportDimensions[1]);
    885 
    886 			glViewport(x, y, width, height);
    887 			m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, x, y, width, height);
    888 			expectError(GL_NO_ERROR);
    889 		}
    890 	}
    891 
    892 private:
    893 	StateVerifier*	m_verifier;
    894 };
    895 
    896 class ScissorBoxTestCase : public ApiCase
    897 {
    898 public:
    899 	ScissorBoxTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    900 		: ApiCase		(context, name, description)
    901 		, m_verifier	(verifier)
    902 	{
    903 	}
    904 
    905 	void test (void)
    906 	{
    907 		de::Random rnd(0xabcdef);
    908 
    909 		// verify initial value
    910 		m_verifier->verifyInteger4(m_testCtx, GL_SCISSOR_BOX, 0, 0, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight());
    911 		expectError(GL_NO_ERROR);
    912 
    913 		const int numIterations = 120;
    914 		for (int i = 0; i < numIterations; ++i)
    915 		{
    916 			GLint left		= rnd.getInt(-64000, 64000);
    917 			GLint bottom	= rnd.getInt(-64000, 64000);
    918 			GLsizei width	= rnd.getInt(0, 64000);
    919 			GLsizei height	= rnd.getInt(0, 64000);
    920 
    921 			glScissor(left, bottom, width, height);
    922 			m_verifier->verifyInteger4(m_testCtx, GL_SCISSOR_BOX, left, bottom, width, height);
    923 			expectError(GL_NO_ERROR);
    924 		}
    925 	}
    926 private:
    927 	StateVerifier*	m_verifier;
    928 };
    929 
    930 class MaxViewportDimsTestCase : public ApiCase
    931 {
    932 public:
    933 	MaxViewportDimsTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    934 		: ApiCase		(context, name, description)
    935 		, m_verifier	(verifier)
    936 	{
    937 	}
    938 
    939 	void test (void)
    940 	{
    941 		m_verifier->verifyIntegerGreaterOrEqual2(m_testCtx, GL_MAX_VIEWPORT_DIMS, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight());
    942 		expectError(GL_NO_ERROR);
    943 	}
    944 private:
    945 	StateVerifier*	m_verifier;
    946 };
    947 
    948 class StencilRefTestCase : public ApiCase
    949 {
    950 public:
    951 	StencilRefTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
    952 		: ApiCase			(context, name, description)
    953 		, m_verifier		(verifier)
    954 		, m_testTargetName	(testTargetName)
    955 	{
    956 	}
    957 
    958 	void test (void)
    959 	{
    960 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0);
    961 		expectError(GL_NO_ERROR);
    962 
    963 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
    964 
    965 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
    966 		{
    967 			const int ref = 1 << stencilBit;
    968 
    969 			glStencilFunc(GL_ALWAYS, ref, 0); // mask should not affect the REF
    970 			expectError(GL_NO_ERROR);
    971 
    972 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
    973 			expectError(GL_NO_ERROR);
    974 
    975 			glStencilFunc(GL_ALWAYS, ref, ref);
    976 			expectError(GL_NO_ERROR);
    977 
    978 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
    979 			expectError(GL_NO_ERROR);
    980 		}
    981 	}
    982 
    983 private:
    984 	StateVerifier*	m_verifier;
    985 	GLenum		m_testTargetName;
    986 };
    987 
    988 class StencilRefSeparateTestCase : public ApiCase
    989 {
    990 public:
    991 	StencilRefSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace)
    992 		: ApiCase					(context, name, description)
    993 		, m_verifier				(verifier)
    994 		, m_testTargetName			(testTargetName)
    995 		, m_stencilFuncTargetFace	(stencilFuncTargetFace)
    996 	{
    997 	}
    998 
    999 	void test (void)
   1000 	{
   1001 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0);
   1002 		expectError(GL_NO_ERROR);
   1003 
   1004 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
   1005 
   1006 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
   1007 		{
   1008 			const int ref = 1 << stencilBit;
   1009 
   1010 			glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, 0);
   1011 			expectError(GL_NO_ERROR);
   1012 
   1013 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
   1014 			expectError(GL_NO_ERROR);
   1015 
   1016 			glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, ref);
   1017 			expectError(GL_NO_ERROR);
   1018 
   1019 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref);
   1020 			expectError(GL_NO_ERROR);
   1021 		}
   1022 	}
   1023 private:
   1024 	StateVerifier*	m_verifier;
   1025 	GLenum		m_testTargetName;
   1026 	GLenum		m_stencilFuncTargetFace;
   1027 };
   1028 
   1029 class StencilOpTestCase : public ApiCase
   1030 {
   1031 public:
   1032 	StencilOpTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName)
   1033 		: ApiCase					(context, name, description)
   1034 		, m_verifier				(verifier)
   1035 		, m_stencilOpName			(stencilOpName)
   1036 	{
   1037 	}
   1038 
   1039 	void test (void)
   1040 	{
   1041 		m_verifier->verifyInteger(m_testCtx, m_stencilOpName, GL_KEEP);
   1042 		expectError(GL_NO_ERROR);
   1043 
   1044 		const GLenum stencilOpValues[] = {GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP};
   1045 
   1046 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilOpValues); ++ndx)
   1047 		{
   1048 			SetStencilOp(stencilOpValues[ndx]);
   1049 			expectError(GL_NO_ERROR);
   1050 
   1051 			m_verifier->verifyInteger(m_testCtx, m_stencilOpName, stencilOpValues[ndx]);
   1052 			expectError(GL_NO_ERROR);
   1053 		}
   1054 	}
   1055 
   1056 protected:
   1057 	virtual void SetStencilOp (GLenum stencilOpValue)
   1058 	{
   1059 		switch (m_stencilOpName)
   1060 		{
   1061 		case GL_STENCIL_FAIL:
   1062 		case GL_STENCIL_BACK_FAIL:
   1063 			glStencilOp(stencilOpValue, GL_KEEP, GL_KEEP);
   1064 			break;
   1065 
   1066 		case GL_STENCIL_PASS_DEPTH_FAIL:
   1067 		case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
   1068 			glStencilOp(GL_KEEP, stencilOpValue, GL_KEEP);
   1069 			break;
   1070 
   1071 		case GL_STENCIL_PASS_DEPTH_PASS:
   1072 		case GL_STENCIL_BACK_PASS_DEPTH_PASS:
   1073 			glStencilOp(GL_KEEP, GL_KEEP, stencilOpValue);
   1074 			break;
   1075 
   1076 		default:
   1077 			DE_ASSERT(false && "should not happen");
   1078 			break;
   1079 		}
   1080 	}
   1081 
   1082 	StateVerifier*				m_verifier;
   1083 	GLenum					m_stencilOpName;
   1084 };
   1085 
   1086 class StencilOpSeparateTestCase : public StencilOpTestCase
   1087 {
   1088 public:
   1089 	StencilOpSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName, GLenum stencilOpFace)
   1090 		: StencilOpTestCase		(context, verifier, name, description, stencilOpName)
   1091 		, m_stencilOpFace		(stencilOpFace)
   1092 	{
   1093 	}
   1094 
   1095 private:
   1096 	void SetStencilOp (GLenum stencilOpValue)
   1097 	{
   1098 		switch (m_stencilOpName)
   1099 		{
   1100 		case GL_STENCIL_FAIL:
   1101 		case GL_STENCIL_BACK_FAIL:
   1102 			glStencilOpSeparate(m_stencilOpFace, stencilOpValue, GL_KEEP, GL_KEEP);
   1103 			break;
   1104 
   1105 		case GL_STENCIL_PASS_DEPTH_FAIL:
   1106 		case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
   1107 			glStencilOpSeparate(m_stencilOpFace, GL_KEEP, stencilOpValue, GL_KEEP);
   1108 			break;
   1109 
   1110 		case GL_STENCIL_PASS_DEPTH_PASS:
   1111 		case GL_STENCIL_BACK_PASS_DEPTH_PASS:
   1112 			glStencilOpSeparate(m_stencilOpFace, GL_KEEP, GL_KEEP, stencilOpValue);
   1113 			break;
   1114 
   1115 		default:
   1116 			DE_ASSERT(false && "should not happen");
   1117 			break;
   1118 		}
   1119 	}
   1120 
   1121 	GLenum		m_stencilOpFace;
   1122 };
   1123 
   1124 class StencilFuncTestCase : public ApiCase
   1125 {
   1126 public:
   1127 	StencilFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
   1128 		: ApiCase		(context, name, description)
   1129 		, m_verifier	(verifier)
   1130 	{
   1131 	}
   1132 
   1133 	void test (void)
   1134 	{
   1135 		m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, GL_ALWAYS);
   1136 		expectError(GL_NO_ERROR);
   1137 
   1138 		const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL};
   1139 
   1140 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx)
   1141 		{
   1142 			glStencilFunc(stencilfuncValues[ndx], 0, 0);
   1143 			expectError(GL_NO_ERROR);
   1144 
   1145 			m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, stencilfuncValues[ndx]);
   1146 			expectError(GL_NO_ERROR);
   1147 
   1148 			m_verifier->verifyInteger(m_testCtx, GL_STENCIL_BACK_FUNC, stencilfuncValues[ndx]);
   1149 			expectError(GL_NO_ERROR);
   1150 		}
   1151 	}
   1152 private:
   1153 	StateVerifier*	m_verifier;
   1154 };
   1155 
   1156 class StencilFuncSeparateTestCase : public ApiCase
   1157 {
   1158 public:
   1159 	StencilFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilFuncName, GLenum stencilFuncFace)
   1160 		: ApiCase			(context, name, description)
   1161 		, m_verifier		(verifier)
   1162 		, m_stencilFuncName	(stencilFuncName)
   1163 		, m_stencilFuncFace	(stencilFuncFace)
   1164 	{
   1165 	}
   1166 
   1167 	void test (void)
   1168 	{
   1169 		m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, GL_ALWAYS);
   1170 		expectError(GL_NO_ERROR);
   1171 
   1172 		const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL};
   1173 
   1174 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx)
   1175 		{
   1176 			glStencilFuncSeparate(m_stencilFuncFace, stencilfuncValues[ndx], 0, 0);
   1177 			expectError(GL_NO_ERROR);
   1178 
   1179 			m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, stencilfuncValues[ndx]);
   1180 			expectError(GL_NO_ERROR);
   1181 		}
   1182 	}
   1183 private:
   1184 	StateVerifier*	m_verifier;
   1185 	GLenum		m_stencilFuncName;
   1186 	GLenum		m_stencilFuncFace;
   1187 };
   1188 
   1189 class StencilMaskTestCase : public ApiCase
   1190 {
   1191 public:
   1192 	StencilMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
   1193 		: ApiCase			(context, name, description)
   1194 		, m_verifier		(verifier)
   1195 		, m_testTargetName	(testTargetName)
   1196 	{
   1197 	}
   1198 
   1199 	void test (void)
   1200 	{
   1201 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
   1202 
   1203 		m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits);
   1204 		expectError(GL_NO_ERROR);
   1205 
   1206 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
   1207 		{
   1208 			const int mask = 1 << stencilBit;
   1209 
   1210 			glStencilFunc(GL_ALWAYS, 0, mask);
   1211 			expectError(GL_NO_ERROR);
   1212 
   1213 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
   1214 			expectError(GL_NO_ERROR);
   1215 		}
   1216 	}
   1217 private:
   1218 	StateVerifier*	m_verifier;
   1219 	GLenum		m_testTargetName;
   1220 };
   1221 
   1222 class StencilMaskSeparateTestCase : public ApiCase
   1223 {
   1224 public:
   1225 	StencilMaskSeparateTestCase	(Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace)
   1226 		: ApiCase					(context, name, description)
   1227 		, m_verifier				(verifier)
   1228 		, m_testTargetName			(testTargetName)
   1229 		, m_stencilFuncTargetFace	(stencilFuncTargetFace)
   1230 	{
   1231 	}
   1232 
   1233 	void test (void)
   1234 	{
   1235 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
   1236 
   1237 		m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits);
   1238 		expectError(GL_NO_ERROR);
   1239 
   1240 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
   1241 		{
   1242 			const int mask = 1 << stencilBit;
   1243 
   1244 			glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, 0, mask);
   1245 			expectError(GL_NO_ERROR);
   1246 
   1247 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
   1248 			expectError(GL_NO_ERROR);
   1249 		}
   1250 	}
   1251 private:
   1252 	StateVerifier*	m_verifier;
   1253 	GLenum		m_testTargetName;
   1254 	GLenum		m_stencilFuncTargetFace;
   1255 };
   1256 
   1257 class StencilWriteMaskTestCase : public ApiCase
   1258 {
   1259 public:
   1260 	StencilWriteMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
   1261 		: ApiCase			(context, name, description)
   1262 		, m_verifier		(verifier)
   1263 		, m_testTargetName	(testTargetName)
   1264 	{
   1265 	}
   1266 
   1267 	void test (void)
   1268 	{
   1269 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
   1270 
   1271 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
   1272 		{
   1273 			const int mask = 1 << stencilBit;
   1274 
   1275 			glStencilMask(mask);
   1276 			expectError(GL_NO_ERROR);
   1277 
   1278 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
   1279 			expectError(GL_NO_ERROR);
   1280 		}
   1281 	}
   1282 private:
   1283 	StateVerifier*	m_verifier;
   1284 	GLenum		m_testTargetName;
   1285 };
   1286 
   1287 class StencilWriteMaskSeparateTestCase : public ApiCase
   1288 {
   1289 public:
   1290 	StencilWriteMaskSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilTargetFace)
   1291 		: ApiCase				(context, name, description)
   1292 		, m_verifier			(verifier)
   1293 		, m_testTargetName		(testTargetName)
   1294 		, m_stencilTargetFace	(stencilTargetFace)
   1295 	{
   1296 	}
   1297 
   1298 	void test (void)
   1299 	{
   1300 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
   1301 
   1302 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
   1303 		{
   1304 			const int mask = 1 << stencilBit;
   1305 
   1306 			glStencilMaskSeparate(m_stencilTargetFace, mask);
   1307 			expectError(GL_NO_ERROR);
   1308 
   1309 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask);
   1310 			expectError(GL_NO_ERROR);
   1311 		}
   1312 	}
   1313 private:
   1314 	StateVerifier*	m_verifier;
   1315 	GLenum		m_testTargetName;
   1316 	GLenum		m_stencilTargetFace;
   1317 };
   1318 
   1319 class PixelStoreAlignTestCase : public ApiCase
   1320 {
   1321 public:
   1322 	PixelStoreAlignTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName)
   1323 		: ApiCase			(context, name, description)
   1324 		, m_verifier		(verifier)
   1325 		, m_testTargetName	(testTargetName)
   1326 	{
   1327 	}
   1328 
   1329 	void test (void)
   1330 	{
   1331 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, 4);
   1332 		expectError(GL_NO_ERROR);
   1333 
   1334 		const int alignments[] = {1, 2, 4, 8};
   1335 
   1336 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(alignments); ++ndx)
   1337 		{
   1338 			const int referenceValue = alignments[ndx];
   1339 
   1340 			glPixelStorei(m_testTargetName, referenceValue);
   1341 			expectError(GL_NO_ERROR);
   1342 
   1343 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
   1344 			expectError(GL_NO_ERROR);
   1345 		}
   1346 	}
   1347 
   1348 private:
   1349 	StateVerifier*	m_verifier;
   1350 	GLenum		m_testTargetName;
   1351 };
   1352 
   1353 class BlendFuncTestCase : public ApiCase
   1354 {
   1355 public:
   1356 	BlendFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
   1357 		: ApiCase			(context, name, description)
   1358 		, m_verifier		(verifier)
   1359 		, m_testTargetName	(testTargetName)
   1360 		, m_initialValue	(initialValue)
   1361 	{
   1362 	}
   1363 
   1364 	void test (void)
   1365 	{
   1366 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
   1367 		expectError(GL_NO_ERROR);
   1368 
   1369 		const GLenum blendFuncValues[] =
   1370 		{
   1371 			GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,
   1372 			GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR,
   1373 			GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA,
   1374 			GL_SRC_ALPHA_SATURATE
   1375 		};
   1376 
   1377 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx)
   1378 		{
   1379 			const GLenum referenceValue = blendFuncValues[ndx];
   1380 
   1381 			//GL_SRC_ALPHA_SATURATE is ony allowed for srcRGB or srcA
   1382 			if (referenceValue == GL_SRC_ALPHA_SATURATE &&
   1383 				!(m_testTargetName == GL_BLEND_SRC_RGB || m_testTargetName == GL_BLEND_SRC_ALPHA))
   1384 				continue;
   1385 
   1386 			SetBlendFunc(referenceValue);
   1387 			expectError(GL_NO_ERROR);
   1388 
   1389 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
   1390 			expectError(GL_NO_ERROR);
   1391 		}
   1392 	}
   1393 protected:
   1394 	virtual void SetBlendFunc (GLenum func)
   1395 	{
   1396 		switch (m_testTargetName)
   1397 		{
   1398 		case GL_BLEND_SRC_RGB:
   1399 		case GL_BLEND_SRC_ALPHA:
   1400 			glBlendFunc(func, GL_ZERO);
   1401 			break;
   1402 
   1403 		case GL_BLEND_DST_RGB:
   1404 		case GL_BLEND_DST_ALPHA:
   1405 			glBlendFunc(GL_ZERO, func);
   1406 			break;
   1407 
   1408 		default:
   1409 			DE_ASSERT(false && "should not happen");
   1410 			break;
   1411 		}
   1412 	}
   1413 
   1414 	StateVerifier*		m_verifier;
   1415 	GLenum			m_testTargetName;
   1416 	int				m_initialValue;
   1417 };
   1418 
   1419 class BlendFuncSeparateTestCase : public BlendFuncTestCase
   1420 {
   1421 public:
   1422 	BlendFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
   1423 		: BlendFuncTestCase	(context, verifier, name, description, testTargetName, initialValue)
   1424 	{
   1425 	}
   1426 
   1427 	void SetBlendFunc (GLenum func)
   1428 	{
   1429 		switch (m_testTargetName)
   1430 		{
   1431 		case GL_BLEND_SRC_RGB:
   1432 			glBlendFuncSeparate(func, GL_ZERO, GL_ZERO, GL_ZERO);
   1433 			break;
   1434 
   1435 		case GL_BLEND_DST_RGB:
   1436 			glBlendFuncSeparate(GL_ZERO, func, GL_ZERO, GL_ZERO);
   1437 			break;
   1438 
   1439 		case GL_BLEND_SRC_ALPHA:
   1440 			glBlendFuncSeparate(GL_ZERO, GL_ZERO, func, GL_ZERO);
   1441 			break;
   1442 
   1443 		case GL_BLEND_DST_ALPHA:
   1444 			glBlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, func);
   1445 			break;
   1446 
   1447 		default:
   1448 			DE_ASSERT(false && "should not happen");
   1449 			break;
   1450 		}
   1451 	}
   1452 };
   1453 
   1454 class BlendEquationTestCase : public ApiCase
   1455 {
   1456 public:
   1457 	BlendEquationTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
   1458 		: ApiCase			(context, name, description)
   1459 		, m_verifier		(verifier)
   1460 		, m_testTargetName	(testTargetName)
   1461 		, m_initialValue	(initialValue)
   1462 	{
   1463 	}
   1464 
   1465 	void test (void)
   1466 	{
   1467 		m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue);
   1468 		expectError(GL_NO_ERROR);
   1469 
   1470 		const GLenum blendFuncValues[] =
   1471 		{
   1472 			GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT
   1473 		};
   1474 
   1475 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx)
   1476 		{
   1477 			const GLenum referenceValue = blendFuncValues[ndx];
   1478 
   1479 			SetBlendEquation(referenceValue);
   1480 			expectError(GL_NO_ERROR);
   1481 
   1482 			m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue);
   1483 			expectError(GL_NO_ERROR);
   1484 		}
   1485 	}
   1486 protected:
   1487 	virtual void SetBlendEquation (GLenum equation)
   1488 	{
   1489 		glBlendEquation(equation);
   1490 	}
   1491 
   1492 	StateVerifier*		m_verifier;
   1493 	GLenum			m_testTargetName;
   1494 	int				m_initialValue;
   1495 };
   1496 
   1497 class BlendEquationSeparateTestCase : public BlendEquationTestCase
   1498 {
   1499 public:
   1500 	BlendEquationSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue)
   1501 		: BlendEquationTestCase	(context, verifier, name, description, testTargetName, initialValue)
   1502 	{
   1503 	}
   1504 
   1505 protected:
   1506 	void SetBlendEquation (GLenum equation)
   1507 	{
   1508 		switch (m_testTargetName)
   1509 		{
   1510 		case GL_BLEND_EQUATION_RGB:
   1511 			glBlendEquationSeparate(equation, GL_FUNC_ADD);
   1512 			break;
   1513 
   1514 		case GL_BLEND_EQUATION_ALPHA:
   1515 			glBlendEquationSeparate(GL_FUNC_ADD, equation);
   1516 			break;
   1517 
   1518 		default:
   1519 			DE_ASSERT(false && "should not happen");
   1520 			break;
   1521 		}
   1522 	}
   1523 };
   1524 
   1525 class ImplementationArrayTestCase : public ApiCase
   1526 {
   1527 public:
   1528 	ImplementationArrayTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum testTargetLengthTargetName, int minValue)
   1529 		: ApiCase						(context, name, description)
   1530 		, m_verifier					(verifier)
   1531 		, m_testTargetName				(testTargetName)
   1532 		, m_testTargetLengthTargetName	(testTargetLengthTargetName)
   1533 		, m_minValue					(minValue)
   1534 	{
   1535 	}
   1536 
   1537 	void test (void)
   1538 	{
   1539 		m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, m_testTargetLengthTargetName, m_minValue);
   1540 		expectError(GL_NO_ERROR);
   1541 
   1542 		GLint targetArrayLength = 0;
   1543 		glGetIntegerv(m_testTargetLengthTargetName, &targetArrayLength);
   1544 		expectError(GL_NO_ERROR);
   1545 
   1546 		if (targetArrayLength)
   1547 		{
   1548 			std::vector<GLint> queryResult;
   1549 			queryResult.resize(targetArrayLength, 0);
   1550 
   1551 			glGetIntegerv(m_testTargetName, &queryResult[0]);
   1552 			expectError(GL_NO_ERROR);
   1553 		}
   1554 	}
   1555 
   1556 private:
   1557 	StateVerifier*		m_verifier;
   1558 	GLenum			m_testTargetName;
   1559 	GLenum			m_testTargetLengthTargetName;
   1560 	int				m_minValue;
   1561 };
   1562 
   1563 class BindingTest : public TestCase
   1564 {
   1565 public:
   1566 						BindingTest	(Context&					context,
   1567 									 const char*				name,
   1568 									 const char*				desc,
   1569 									 QueryType					type);
   1570 
   1571 	IterateResult		iterate		(void);
   1572 
   1573 	virtual void		test		(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const = 0;
   1574 
   1575 protected:
   1576 	const QueryType		m_type;
   1577 };
   1578 
   1579 BindingTest::BindingTest (Context&		context,
   1580 						  const char*	name,
   1581 						  const char*	desc,
   1582 						  QueryType		type)
   1583 	: TestCase	(context, name, desc)
   1584 	, m_type	(type)
   1585 {
   1586 }
   1587 
   1588 BindingTest::IterateResult BindingTest::iterate (void)
   1589 {
   1590 	glu::CallLogWrapper		gl		(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
   1591 	tcu::ResultCollector	result	(m_context.getTestContext().getLog(), " // ERROR: ");
   1592 
   1593 	gl.enableLogging(true);
   1594 
   1595 	test(gl, result);
   1596 
   1597 	result.setTestContextResult(m_testCtx);
   1598 	return STOP;
   1599 }
   1600 
   1601 class CurrentProgramBindingTestCase : public BindingTest
   1602 {
   1603 public:
   1604 	CurrentProgramBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
   1605 		: BindingTest(context, name, description, type)
   1606 	{
   1607 	}
   1608 
   1609 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1610 	{
   1611 		static const char* testVertSource =
   1612 			"void main (void)\n"
   1613 			"{\n"
   1614 			"	gl_Position = vec4(0.0);\n"
   1615 			"}\n";
   1616 		static const char* testFragSource =
   1617 			"void main (void)\n"
   1618 			"{\n"
   1619 			"	gl_FragColor = vec4(0.0);\n"
   1620 			"}\n";
   1621 
   1622 		GLuint	shaderVert;
   1623 		GLuint	shaderFrag;
   1624 		GLuint	shaderProg;
   1625 		GLint	compileStatus;
   1626 		GLint	linkStatus;
   1627 
   1628 		{
   1629 			const tcu::ScopedLogSection section(gl.getLog(), "Initial", "Initial");
   1630 
   1631 			verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type);
   1632 		}
   1633 		{
   1634 			const tcu::ScopedLogSection section(gl.getLog(), "VertexShader", "Vertex Shader");
   1635 
   1636 			shaderVert = gl.glCreateShader(GL_VERTEX_SHADER);
   1637 			gl.glShaderSource(shaderVert, 1, &testVertSource, DE_NULL);
   1638 			gl.glCompileShader(shaderVert);
   1639 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
   1640 
   1641 			gl.glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus);
   1642 			if (compileStatus != GL_TRUE)
   1643 				result.fail("expected GL_TRUE");
   1644 		}
   1645 		{
   1646 			const tcu::ScopedLogSection section(gl.getLog(), "FragmentShader", "Fragment Shader");
   1647 
   1648 			shaderFrag = gl.glCreateShader(GL_FRAGMENT_SHADER);
   1649 			gl.glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL);
   1650 			gl.glCompileShader(shaderFrag);
   1651 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader");
   1652 
   1653 			gl.glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus);
   1654 			if (compileStatus != GL_TRUE)
   1655 				result.fail("expected GL_TRUE");
   1656 		}
   1657 		{
   1658 			const tcu::ScopedLogSection section(gl.getLog(), "Program", "Create and bind program");
   1659 
   1660 			shaderProg = gl.glCreateProgram();
   1661 			gl.glAttachShader(shaderProg, shaderVert);
   1662 			gl.glAttachShader(shaderProg, shaderFrag);
   1663 			gl.glLinkProgram(shaderProg);
   1664 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glLinkProgram");
   1665 
   1666 			gl.glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus);
   1667 			if (linkStatus != GL_TRUE)
   1668 				result.fail("expected GL_TRUE");
   1669 
   1670 			gl.glUseProgram(shaderProg);
   1671 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram");
   1672 
   1673 			verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type);
   1674 		}
   1675 		{
   1676 			const tcu::ScopedLogSection section(gl.getLog(), "Delete", "Delete program while in use");
   1677 
   1678 			gl.glDeleteShader(shaderVert);
   1679 			gl.glDeleteShader(shaderFrag);
   1680 			gl.glDeleteProgram(shaderProg);
   1681 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteProgram");
   1682 
   1683 			verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type);
   1684 		}
   1685 		{
   1686 			const tcu::ScopedLogSection section(gl.getLog(), "Unbind", "Unbind program");
   1687 			gl.glUseProgram(0);
   1688 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram");
   1689 
   1690 			verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type);
   1691 		}
   1692 	}
   1693 };
   1694 
   1695 class BufferBindingTestCase : public BindingTest
   1696 {
   1697 public:
   1698 	BufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description, GLenum bufferBindingName, GLenum bufferType)
   1699 		: BindingTest			(context, name, description, type)
   1700 		, m_bufferBindingName	(bufferBindingName)
   1701 		, m_bufferType			(bufferType)
   1702 	{
   1703 	}
   1704 
   1705 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1706 	{
   1707 		verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type);
   1708 
   1709 		GLuint bufferObject = 0;
   1710 		gl.glGenBuffers(1, &bufferObject);
   1711 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers");
   1712 
   1713 		gl.glBindBuffer(m_bufferType, bufferObject);
   1714 		verifyStateInteger(result, gl, m_bufferBindingName, bufferObject, m_type);
   1715 
   1716 		gl.glDeleteBuffers(1, &bufferObject);
   1717 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteBuffers");
   1718 
   1719 		verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type);
   1720 	}
   1721 
   1722 private:
   1723 	const GLenum	m_bufferBindingName;
   1724 	const GLenum	m_bufferType;
   1725 };
   1726 
   1727 class StencilClearValueTestCase : public ApiCase
   1728 {
   1729 public:
   1730 	StencilClearValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
   1731 		: ApiCase		(context, name, description)
   1732 		, m_verifier	(verifier)
   1733 	{
   1734 	}
   1735 
   1736 	void test (void)
   1737 	{
   1738 		m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, 0);
   1739 		expectError(GL_NO_ERROR);
   1740 
   1741 		const int stencilBits = m_context.getRenderTarget().getStencilBits();
   1742 
   1743 		for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit)
   1744 		{
   1745 			const int ref = 1 << stencilBit;
   1746 
   1747 			glClearStencil(ref);
   1748 			expectError(GL_NO_ERROR);
   1749 
   1750 			m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, ref);
   1751 			expectError(GL_NO_ERROR);
   1752 		}
   1753 	}
   1754 
   1755 private:
   1756 	StateVerifier*	m_verifier;
   1757 };
   1758 
   1759 class ActiveTextureTestCase : public ApiCase
   1760 {
   1761 public:
   1762 	ActiveTextureTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
   1763 		: ApiCase		(context, name, description)
   1764 		, m_verifier	(verifier)
   1765 	{
   1766 	}
   1767 
   1768 	void test (void)
   1769 	{
   1770 		m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0);
   1771 		expectError(GL_NO_ERROR);
   1772 
   1773 		GLint textureUnits = 0;
   1774 		glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &textureUnits);
   1775 		expectError(GL_NO_ERROR);
   1776 
   1777 		for (int ndx = 0; ndx < textureUnits; ++ndx)
   1778 		{
   1779 			glActiveTexture(GL_TEXTURE0 + ndx);
   1780 			expectError(GL_NO_ERROR);
   1781 
   1782 			m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0 + ndx);
   1783 			expectError(GL_NO_ERROR);
   1784 		}
   1785 	}
   1786 
   1787 private:
   1788 	StateVerifier*		m_verifier;
   1789 };
   1790 
   1791 class RenderbufferBindingTestCase : public BindingTest
   1792 {
   1793 public:
   1794 	RenderbufferBindingTestCase	(Context& context, QueryType type, const char* name, const char* description)
   1795 		: BindingTest(context, name, description, type)
   1796 	{
   1797 	}
   1798 
   1799 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1800 	{
   1801 		verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type);
   1802 
   1803 		GLuint renderBuffer = 0;
   1804 		gl.glGenRenderbuffers(1, &renderBuffer);
   1805 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenRenderbuffers");
   1806 
   1807 		gl.glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
   1808 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindRenderbuffer");
   1809 
   1810 		verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, renderBuffer, m_type);
   1811 
   1812 		gl.glDeleteRenderbuffers(1, &renderBuffer);
   1813 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteRenderbuffers");
   1814 
   1815 		verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type);
   1816 	}
   1817 };
   1818 
   1819 class TextureBindingTestCase : public BindingTest
   1820 {
   1821 public:
   1822 	TextureBindingTestCase (Context& context, QueryType type, const char* name, const char* description, GLenum testBindingName, GLenum textureType)
   1823 		: BindingTest			(context, name, description, type)
   1824 		, m_testBindingName		(testBindingName)
   1825 		, m_textureType			(textureType)
   1826 	{
   1827 	}
   1828 
   1829 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1830 	{
   1831 		verifyStateInteger(result, gl, m_testBindingName, 0, m_type);
   1832 
   1833 		GLuint texture = 0;
   1834 		gl.glGenTextures(1, &texture);
   1835 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenTextures");
   1836 
   1837 		gl.glBindTexture(m_textureType, texture);
   1838 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
   1839 
   1840 		verifyStateInteger(result, gl, m_testBindingName, texture, m_type);
   1841 
   1842 		gl.glDeleteTextures(1, &texture);
   1843 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
   1844 
   1845 		verifyStateInteger(result, gl, m_testBindingName, 0, m_type);
   1846 	}
   1847 private:
   1848 	const GLenum	m_testBindingName;
   1849 	const GLenum	m_textureType;
   1850 };
   1851 
   1852 class FrameBufferBindingTestCase : public BindingTest
   1853 {
   1854 public:
   1855 	FrameBufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description)
   1856 		: BindingTest(context, name, description, type)
   1857 	{
   1858 	}
   1859 
   1860 	void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1861 	{
   1862 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
   1863 
   1864 		GLuint framebufferId = 0;
   1865 		gl.glGenFramebuffers(1, &framebufferId);
   1866 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenFramebuffers");
   1867 
   1868 		gl.glBindFramebuffer(GL_FRAMEBUFFER, framebufferId);
   1869 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindFramebuffer");
   1870 
   1871 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, framebufferId, m_type);
   1872 
   1873 		gl.glBindFramebuffer(GL_FRAMEBUFFER, 0);
   1874 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindFramebuffer");
   1875 
   1876 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
   1877 
   1878 		gl.glBindFramebuffer(GL_FRAMEBUFFER, framebufferId);
   1879 		gl.glDeleteFramebuffers(1, &framebufferId);
   1880 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteFramebuffers");
   1881 
   1882 		verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type);
   1883 	}
   1884 };
   1885 
   1886 class ImplementationColorReadTestCase : public ApiCase
   1887 {
   1888 public:
   1889 	ImplementationColorReadTestCase	(Context& context, StateVerifier* verifier, const char* name, const char* description)
   1890 		: ApiCase		(context, name, description)
   1891 		, m_verifier	(verifier)
   1892 	{
   1893 	}
   1894 
   1895 	void test (void)
   1896 	{
   1897 		const GLint defaultColorTypes[] =
   1898 		{
   1899 			GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_5_6_5
   1900 		};
   1901 		const GLint defaultColorFormats[] =
   1902 		{
   1903 			GL_RGBA, GL_RGB, GL_ALPHA
   1904 		};
   1905 
   1906 		std::vector<GLint> validColorTypes;
   1907 		std::vector<GLint> validColorFormats;
   1908 
   1909 		// Defined by the spec
   1910 
   1911 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorTypes); ++ndx)
   1912 			validColorTypes.push_back(defaultColorTypes[ndx]);
   1913 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorFormats); ++ndx)
   1914 			validColorFormats.push_back(defaultColorFormats[ndx]);
   1915 
   1916 		// Extensions
   1917 
   1918 		if (m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_format_BGRA8888") ||
   1919 			m_context.getContextInfo().isExtensionSupported("GL_APPLE_texture_format_BGRA8888"))
   1920 			validColorFormats.push_back(GL_BGRA);
   1921 
   1922 		if (m_context.getContextInfo().isExtensionSupported("GL_EXT_read_format_bgra"))
   1923 		{
   1924 			validColorFormats.push_back(GL_BGRA);
   1925 			validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV);
   1926 			validColorTypes.push_back(GL_UNSIGNED_SHORT_1_5_5_5_REV);
   1927 		}
   1928 
   1929 		if (m_context.getContextInfo().isExtensionSupported("GL_IMG_read_format"))
   1930 		{
   1931 			validColorFormats.push_back(GL_BGRA);
   1932 			validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV);
   1933 		}
   1934 
   1935 		if (m_context.getContextInfo().isExtensionSupported("GL_NV_sRGB_formats"))
   1936 		{
   1937 			validColorFormats.push_back(GL_SLUMINANCE_NV);
   1938 			validColorFormats.push_back(GL_SLUMINANCE_ALPHA_NV);
   1939 		}
   1940 
   1941 		if (m_context.getContextInfo().isExtensionSupported("GL_NV_bgr"))
   1942 		{
   1943 			validColorFormats.push_back(GL_BGR_NV);
   1944 		}
   1945 
   1946 		if (m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_rg"))
   1947 		{
   1948 			validColorFormats.push_back(GL_RED);
   1949 			validColorFormats.push_back(GL_RG);
   1950 		}
   1951 
   1952 		m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_TYPE,	&validColorTypes[0],	validColorTypes.size());
   1953 		m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_FORMAT,	&validColorFormats[0],	validColorFormats.size());
   1954 		expectError(GL_NO_ERROR);
   1955 	}
   1956 
   1957 private:
   1958 	StateVerifier*	m_verifier;
   1959 };
   1960 
   1961 class BufferComponentSizeCase : public ApiCase
   1962 {
   1963 public:
   1964 	BufferComponentSizeCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
   1965 		: ApiCase		(context, name, description)
   1966 		, m_verifier	(verifier)
   1967 	{
   1968 	}
   1969 
   1970 	void test (void)
   1971 	{
   1972 		m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_RED_BITS,		m_context.getRenderTarget().getPixelFormat().redBits);
   1973 		m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_BLUE_BITS,	m_context.getRenderTarget().getPixelFormat().blueBits);
   1974 		m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_GREEN_BITS,	m_context.getRenderTarget().getPixelFormat().greenBits);
   1975 		m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_ALPHA_BITS,	m_context.getRenderTarget().getPixelFormat().alphaBits);
   1976 		expectError(GL_NO_ERROR);
   1977 
   1978 		m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_DEPTH_BITS,	m_context.getRenderTarget().getDepthBits());
   1979 		m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_STENCIL_BITS,	m_context.getRenderTarget().getStencilBits());
   1980 		expectError(GL_NO_ERROR);
   1981 	}
   1982 private:
   1983 	StateVerifier*	m_verifier;
   1984 };
   1985 
   1986 static const char* getQueryTypeSuffix (QueryType type)
   1987 {
   1988 	switch (type)
   1989 	{
   1990 		case QUERY_BOOLEAN:	return "_getboolean";
   1991 		case QUERY_INTEGER:	return "_getinteger";
   1992 		case QUERY_FLOAT:	return "_getfloat";
   1993 		default:
   1994 			DE_ASSERT(DE_FALSE);
   1995 			return DE_NULL;
   1996 	}
   1997 }
   1998 
   1999 #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK)												\
   2000 	for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++)	\
   2001 	{																							\
   2002 		StateVerifier* verifier = VERIFIERS[_verifierNdx];										\
   2003 		CODE_BLOCK;																				\
   2004 	}
   2005 
   2006 #define FOR_EACH_QUERYTYPE(QUERYTYPES, CODE_BLOCK)													\
   2007 	for (int _queryTypeNdx = 0; _queryTypeNdx < DE_LENGTH_OF_ARRAY(QUERYTYPES); _queryTypeNdx++)	\
   2008 	{																								\
   2009 		const QueryType queryType = QUERYTYPES[_queryTypeNdx];										\
   2010 		CODE_BLOCK;																					\
   2011 	}
   2012 
   2013 } // anonymous
   2014 
   2015 IntegerStateQueryTests::IntegerStateQueryTests (Context& context)
   2016 	: TestCaseGroup			(context, "integers", "Integer Values")
   2017 	, m_verifierBoolean		(DE_NULL)
   2018 	, m_verifierInteger		(DE_NULL)
   2019 	, m_verifierFloat		(DE_NULL)
   2020 {
   2021 }
   2022 
   2023 IntegerStateQueryTests::~IntegerStateQueryTests (void)
   2024 {
   2025 	deinit();
   2026 }
   2027 
   2028 void IntegerStateQueryTests::init (void)
   2029 {
   2030 	static const QueryType queryTypes[] =
   2031 	{
   2032 		QUERY_BOOLEAN,
   2033 		QUERY_INTEGER,
   2034 		QUERY_FLOAT,
   2035 	};
   2036 
   2037 	DE_ASSERT(m_verifierBoolean == DE_NULL);
   2038 	DE_ASSERT(m_verifierInteger == DE_NULL);
   2039 	DE_ASSERT(m_verifierFloat == DE_NULL);
   2040 
   2041 	m_verifierBoolean		= new GetBooleanVerifier	(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
   2042 	m_verifierInteger		= new GetIntegerVerifier	(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
   2043 	m_verifierFloat			= new GetFloatVerifier		(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
   2044 
   2045 	const struct LimitedStateInteger
   2046 	{
   2047 		const char*		name;
   2048 		const char*		description;
   2049 		GLenum			targetName;
   2050 		GLint			value;
   2051 	} implementationMinLimits[] =
   2052 	{
   2053 		{ "subpixel_bits",						"SUBPIXEL_BITS has  a minimum value of 4",						GL_SUBPIXEL_BITS,						4	},
   2054 		{ "max_texture_size",					"MAX_TEXTURE_SIZE has  a minimum value of 64",					GL_MAX_TEXTURE_SIZE,					64	},
   2055 		{ "max_cube_map_texture_size",			"MAX_CUBE_MAP_TEXTURE_SIZE has  a minimum value of 16",			GL_MAX_CUBE_MAP_TEXTURE_SIZE,			16	},
   2056 		{ "max_vertex_attribs",					"MAX_VERTEX_ATTRIBS has  a minimum value of 8",					GL_MAX_VERTEX_ATTRIBS,					8	},
   2057 		{ "max_vertex_uniform_vectors",			"MAX_VERTEX_UNIFORM_VECTORS has  a minimum value of 128",		GL_MAX_VERTEX_UNIFORM_VECTORS,			128	},
   2058 		{ "max_varying_vectors",				"MAX_VARYING_VECTORS has  a minimum value of 8",				GL_MAX_VARYING_VECTORS,					8	},
   2059 		{ "max_combined_texture_image_units",	"MAX_COMBINED_TEXTURE_IMAGE_UNITS has  a minimum value of 8",	GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,	8	},
   2060 		{ "max_vertex_texture_image_units",		"MAX_VERTEX_TEXTURE_IMAGE_UNITS has  a minimum value of 0",		GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,		0	},
   2061 		{ "max_texture_image_units",			"MAX_TEXTURE_IMAGE_UNITS has  a minimum value of 8",			GL_MAX_TEXTURE_IMAGE_UNITS,				8	},
   2062 		{ "max_fragment_uniform_vectors",		"MAX_FRAGMENT_UNIFORM_VECTORS has  a minimum value of 16",		GL_MAX_FRAGMENT_UNIFORM_VECTORS,		16	},
   2063 		{ "max_renderbuffer_size",				"MAX_RENDERBUFFER_SIZE has  a minimum value of 1",				GL_MAX_RENDERBUFFER_SIZE,				1	},
   2064 	};
   2065 
   2066 	// \note implementation defined limits have their own tests so just check the conversions to boolean and float
   2067 	StateVerifier* implementationLimitVerifiers[]	= {m_verifierBoolean,						m_verifierFloat};
   2068 	StateVerifier* normalVerifiers[]				= {m_verifierBoolean,	m_verifierInteger,	m_verifierFloat};
   2069 
   2070 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMinLimits); testNdx++)
   2071 		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)));
   2072 
   2073 	FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new SampleBuffersTestCase		(m_context,	 verifier, (std::string("sample_buffers")						+ verifier->getTestNamePostfix()).c_str(),		"SAMPLE_BUFFERS")));
   2074 
   2075 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new SamplesTestCase				(m_context,	 verifier, (std::string("samples")								+ verifier->getTestNamePostfix()).c_str(),		"SAMPLES")));
   2076 	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)));
   2077 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new DepthFuncTestCase			(m_context,	 verifier, (std::string("depth_func")							+ verifier->getTestNamePostfix()).c_str(),		"DEPTH_FUNC")));
   2078 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new CullFaceTestCase			(m_context,	 verifier, (std::string("cull_face_mode")						+ verifier->getTestNamePostfix()).c_str(),		"CULL_FACE_MODE")));
   2079 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new FrontFaceTestCase			(m_context,	 verifier, (std::string("front_face_mode")						+ verifier->getTestNamePostfix()).c_str(),		"FRONT_FACE")));
   2080 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ViewPortTestCase			(m_context,	 verifier, (std::string("viewport")								+ verifier->getTestNamePostfix()).c_str(),		"VIEWPORT")));
   2081 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ScissorBoxTestCase			(m_context,	 verifier, (std::string("scissor_box")							+ verifier->getTestNamePostfix()).c_str(),		"SCISSOR_BOX")));
   2082 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new MaxViewportDimsTestCase		(m_context,	 verifier, (std::string("max_viewport_dims")					+ verifier->getTestNamePostfix()).c_str(),		"MAX_VIEWPORT_DIMS")));
   2083 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new BufferComponentSizeCase		(m_context,	 verifier, (std::string("buffer_component_size")				+ verifier->getTestNamePostfix()).c_str(),		"x BITS")));
   2084 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefTestCase			(m_context,	 verifier, (std::string("stencil_ref")							+ verifier->getTestNamePostfix()).c_str(),		"STENCIL_REF",						GL_STENCIL_REF)));
   2085 	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)));
   2086 	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)));
   2087 	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)));
   2088 	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)));
   2089 	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)));
   2090 
   2091 	const struct NamedStencilOp
   2092 	{
   2093 		const char*		name;
   2094 
   2095 		const char*		frontDescription;
   2096 		GLenum			frontTarget;
   2097 		const char*		backDescription;
   2098 		GLenum			backTarget;
   2099 	} stencilOps[] =
   2100 	{
   2101 		{ "fail",		"STENCIL_FAIL",				GL_STENCIL_FAIL,			"STENCIL_BACK_FAIL",			GL_STENCIL_BACK_FAIL			},
   2102 		{ "depth_fail",	"STENCIL_PASS_DEPTH_FAIL",	GL_STENCIL_PASS_DEPTH_FAIL,	"STENCIL_BACK_PASS_DEPTH_FAIL",	GL_STENCIL_BACK_PASS_DEPTH_FAIL	},
   2103 		{ "depth_pass",	"STENCIL_PASS_DEPTH_PASS",	GL_STENCIL_PASS_DEPTH_PASS,	"STENCIL_BACK_PASS_DEPTH_PASS",	GL_STENCIL_BACK_PASS_DEPTH_PASS	}
   2104 	};
   2105 
   2106 	for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(stencilOps); testNdx++)
   2107 	{
   2108 		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)));
   2109 		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)));
   2110 
   2111 		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)));
   2112 		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)));
   2113 
   2114 		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)));
   2115 		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)));
   2116 	}
   2117 
   2118 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncTestCase					(m_context, verifier,	(std::string("stencil_func")								+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_FUNC")));
   2119 	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)));
   2120 	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)));
   2121 	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)));
   2122 	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)));
   2123 	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)));
   2124 	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)));
   2125 	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)));
   2126 	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)));
   2127 	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)));
   2128 	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)));
   2129 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskTestCase			(m_context, verifier,	(std::string("stencil_writemask")							+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_WRITEMASK",					GL_STENCIL_WRITEMASK)));
   2130 	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)));
   2131 	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)));
   2132 	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)));
   2133 	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)));
   2134 	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)));
   2135 
   2136 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("unpack_alignment")	+ verifier->getTestNamePostfix()).c_str(),	"UNPACK_ALIGNMENT",	GL_UNPACK_ALIGNMENT)));
   2137 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("pack_alignment")		+ verifier->getTestNamePostfix()).c_str(),	"PACK_ALIGNMENT",	GL_PACK_ALIGNMENT)));
   2138 
   2139 	{
   2140 		const struct BlendColorState
   2141 		{
   2142 			const char*	name;
   2143 			const char*	description;
   2144 			GLenum		target;
   2145 			int			initialValue;
   2146 		} blendColorStates[] =
   2147 		{
   2148 			{ "blend_src_rgb",		"BLEND_SRC_RGB",	GL_BLEND_SRC_RGB,		GL_ONE	},
   2149 			{ "blend_src_alpha",	"BLEND_SRC_ALPHA",	GL_BLEND_SRC_ALPHA,		GL_ONE	},
   2150 			{ "blend_dst_rgb",		"BLEND_DST_RGB",	GL_BLEND_DST_RGB,		GL_ZERO	},
   2151 			{ "blend_dst_alpha",	"BLEND_DST_ALPHA",	GL_BLEND_DST_ALPHA,		GL_ZERO	}
   2152 		};
   2153 		for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendColorStates); testNdx++)
   2154 		{
   2155 			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)));
   2156 			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)));
   2157 		}
   2158 	}
   2159 
   2160 	{
   2161 		const struct BlendEquationState
   2162 		{
   2163 			const char*	name;
   2164 			const char*	description;
   2165 			GLenum		target;
   2166 			int			initialValue;
   2167 		} blendEquationStates[] =
   2168 		{
   2169 			{ "blend_equation_rgb",		"BLEND_EQUATION_RGB",	GL_BLEND_EQUATION_RGB,		GL_FUNC_ADD	},
   2170 			{ "blend_equation_alpha",	"BLEND_EQUATION_ALPHA",	GL_BLEND_EQUATION_ALPHA,	GL_FUNC_ADD	}
   2171 		};
   2172 		for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendEquationStates); testNdx++)
   2173 		{
   2174 			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)));
   2175 			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)));
   2176 		}
   2177 	}
   2178 
   2179 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationArrayTestCase			(m_context, verifier, (std::string("compressed_texture_formats")	+ verifier->getTestNamePostfix()).c_str(),	"COMPRESSED_TEXTURE_FORMATS",	GL_COMPRESSED_TEXTURE_FORMATS,		GL_NUM_COMPRESSED_TEXTURE_FORMATS,	0)));
   2180 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationArrayTestCase			(m_context, verifier, (std::string("shader_binary_formats")			+ verifier->getTestNamePostfix()).c_str(),	"SHADER_BINARY_FORMATS",		GL_SHADER_BINARY_FORMATS,			GL_NUM_SHADER_BINARY_FORMATS,		0)));
   2181 
   2182 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new BufferBindingTestCase				(m_context, queryType, (std::string("array_buffer_binding")			+ getQueryTypeSuffix(queryType)).c_str(),	"ARRAY_BUFFER_BINDING",			GL_ARRAY_BUFFER_BINDING,			GL_ARRAY_BUFFER)));
   2183 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new BufferBindingTestCase				(m_context, queryType, (std::string("element_array_buffer_binding")	+ getQueryTypeSuffix(queryType)).c_str(),	"ELEMENT_ARRAY_BUFFER_BINDING",	GL_ELEMENT_ARRAY_BUFFER_BINDING,	GL_ELEMENT_ARRAY_BUFFER)));
   2184 
   2185 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new CurrentProgramBindingTestCase		(m_context, queryType, (std::string("current_program_binding")		+ getQueryTypeSuffix(queryType)).c_str(),	"CURRENT_PROGRAM")));
   2186 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilClearValueTestCase			(m_context, verifier, (std::string("stencil_clear_value")			+ verifier->getTestNamePostfix()).c_str(),	"STENCIL_CLEAR_VALUE")));
   2187 	FOR_EACH_VERIFIER(normalVerifiers, addChild(new ActiveTextureTestCase				(m_context, verifier, (std::string("active_texture")				+ verifier->getTestNamePostfix()).c_str(),	"ACTIVE_TEXTURE")));
   2188 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new RenderbufferBindingTestCase			(m_context, queryType, (std::string("renderbuffer_binding")			+ getQueryTypeSuffix(queryType)).c_str(),	"RENDERBUFFER_BINDING")));
   2189 
   2190 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new TextureBindingTestCase				(m_context, queryType, (std::string("texture_binding_2d")			+ getQueryTypeSuffix(queryType)).c_str(),	"TEXTURE_BINDING_2D",			GL_TEXTURE_BINDING_2D,			GL_TEXTURE_2D)));
   2191 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new TextureBindingTestCase				(m_context, queryType, (std::string("texture_binding_cube_map")		+ getQueryTypeSuffix(queryType)).c_str(),	"TEXTURE_BINDING_CUBE_MAP",		GL_TEXTURE_BINDING_CUBE_MAP,	GL_TEXTURE_CUBE_MAP)));
   2192 
   2193 	FOR_EACH_QUERYTYPE(queryTypes,     addChild(new FrameBufferBindingTestCase			(m_context, queryType, (std::string("framebuffer_binding")			+ getQueryTypeSuffix(queryType)).c_str(),	"DRAW_FRAMEBUFFER_BINDING and READ_FRAMEBUFFER_BINDING")));
   2194 	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")));
   2195 }
   2196 
   2197 void IntegerStateQueryTests::deinit (void)
   2198 {
   2199 	if (m_verifierBoolean)
   2200 	{
   2201 		delete m_verifierBoolean;
   2202 		m_verifierBoolean = DE_NULL;
   2203 	}
   2204 	if (m_verifierInteger)
   2205 	{
   2206 		delete m_verifierInteger;
   2207 		m_verifierInteger = DE_NULL;
   2208 	}
   2209 	if (m_verifierFloat)
   2210 	{
   2211 		delete m_verifierFloat;
   2212 		m_verifierFloat = DE_NULL;
   2213 	}
   2214 
   2215 	this->TestCaseGroup::deinit();
   2216 }
   2217 
   2218 } // Functional
   2219 } // gles2
   2220 } // deqp
   2221