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 Float State Query tests.
     22  *//*--------------------------------------------------------------------*/
     23 
     24 #include "es2fFloatStateQueryTests.hpp"
     25 #include "glsStateQueryUtil.hpp"
     26 #include "es2fApiCase.hpp"
     27 #include "gluRenderContext.hpp"
     28 #include "tcuRenderTarget.hpp"
     29 #include "tcuFormatUtil.hpp"
     30 #include "deRandom.hpp"
     31 #include "deMath.h"
     32 #include "glwEnums.hpp"
     33 
     34 #include <limits>
     35 
     36 using namespace glw; // GLint and other GL types
     37 using namespace deqp::gls;
     38 using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
     39 
     40 namespace deqp
     41 {
     42 namespace gles2
     43 {
     44 namespace Functional
     45 {
     46 namespace FloatStateQueryVerifiers
     47 {
     48 namespace
     49 {
     50 
     51 const int FLOAT_EXPANSION_E = 0x3FFF;
     52 
     53 GLint64 expandGLFloatToInteger (GLfloat f)
     54 {
     55 	const GLuint64 referenceValue = (GLint64)((f * double(0xFFFFFFFFULL) - 1) / 2);
     56 	return referenceValue;
     57 }
     58 
     59 GLint clampToGLint (GLint64 val)
     60 {
     61 	return (GLint)de::clamp<GLint64>(val, std::numeric_limits<GLint>::min(), std::numeric_limits<GLint>::max());
     62 }
     63 
     64 } // anonymous
     65 
     66 // StateVerifier
     67 
     68 class StateVerifier : protected glu::CallLogWrapper
     69 {
     70 public:
     71 						StateVerifier					(const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix);
     72 	virtual				~StateVerifier					(); // make GCC happy
     73 
     74 	const char*			getTestNamePostfix				(void) const;
     75 
     76 	virtual void		verifyFloat						(tcu::TestContext& testCtx, GLenum name, GLfloat reference)																																		= DE_NULL;
     77 
     78 	// "Expanded" == Float to int conversion converts from [-1.0 to 1.0] -> [MIN_INT MAX_INT]
     79 	virtual void		verifyFloatExpanded				(tcu::TestContext& testCtx, GLenum name, GLfloat reference)																																		= DE_NULL;
     80 	virtual void		verifyFloat2Expanded			(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1)																												= DE_NULL;
     81 	virtual void		verifyFloat4Color				(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1, GLfloat reference2, GLfloat reference3)																		= DE_NULL;
     82 
     83 	// verify that the given range is completely whitin the GL state range
     84 	virtual void		verifyFloatRange				(tcu::TestContext& testCtx, GLenum name, GLfloat min, GLfloat max)																																= DE_NULL;
     85 
     86 private:
     87 	const char*	const	m_testNamePostfix;
     88 };
     89 
     90 StateVerifier::StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix)
     91 	: glu::CallLogWrapper	(gl, log)
     92 	, m_testNamePostfix		(testNamePostfix)
     93 {
     94 	enableLogging(true);
     95 }
     96 
     97 StateVerifier::~StateVerifier ()
     98 {
     99 }
    100 
    101 const char* StateVerifier::getTestNamePostfix (void) const
    102 {
    103 	return m_testNamePostfix;
    104 }
    105 
    106 // GetBooleanVerifier
    107 
    108 class GetBooleanVerifier : public StateVerifier
    109 {
    110 public:
    111 			GetBooleanVerifier				(const glw::Functions& gl, tcu::TestLog& log);
    112 	void	verifyFloat						(tcu::TestContext& testCtx, GLenum name, GLfloat reference);
    113 	void	verifyFloatExpanded				(tcu::TestContext& testCtx, GLenum name, GLfloat reference);
    114 	void	verifyFloat2Expanded			(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1);
    115 	void	verifyFloat4Color				(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1, GLfloat reference2, GLfloat reference3);
    116 	void	verifyFloatRange				(tcu::TestContext& testCtx, GLenum name, GLfloat min, GLfloat max);
    117 };
    118 
    119 GetBooleanVerifier::GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log)
    120 	: StateVerifier(gl, log, "_getboolean")
    121 {
    122 }
    123 
    124 void GetBooleanVerifier::verifyFloat (tcu::TestContext& testCtx, GLenum name, GLfloat reference)
    125 {
    126 	using tcu::TestLog;
    127 
    128 	StateQueryMemoryWriteGuard<GLboolean> state;
    129 	glGetBooleanv(name, &state);
    130 
    131 	if (!state.verifyValidity(testCtx))
    132 		return;
    133 
    134 	const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE;
    135 
    136 	if (state != expectedGLState)
    137 	{
    138 		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;
    139 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    140 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    141 	}
    142 }
    143 
    144 void GetBooleanVerifier::verifyFloatExpanded (tcu::TestContext& testCtx, GLenum name, GLfloat reference)
    145 {
    146 	DE_ASSERT(de::inRange(reference, -1.0f, 1.0f));
    147 	verifyFloat(testCtx, name, reference);
    148 }
    149 
    150 void GetBooleanVerifier::verifyFloat2Expanded (tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1)
    151 {
    152 	DE_ASSERT(de::inRange(reference0, -1.0f, 1.0f));
    153 	DE_ASSERT(de::inRange(reference1, -1.0f, 1.0f));
    154 
    155 	using tcu::TestLog;
    156 
    157 	const GLboolean referenceAsGLBoolean[] =
    158 	{
    159 		reference0 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
    160 		reference1 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
    161 	};
    162 
    163 	StateQueryMemoryWriteGuard<GLboolean[2]> boolVector2;
    164 	glGetBooleanv(name, boolVector2);
    165 
    166 	if (!boolVector2.verifyValidity(testCtx))
    167 		return;
    168 
    169 	if (boolVector2[0] != referenceAsGLBoolean[0] ||
    170 		boolVector2[1] != referenceAsGLBoolean[1])
    171 	{
    172 		testCtx.getLog() << TestLog::Message << "// ERROR: expected "
    173 			<< (boolVector2[0] ? "GL_TRUE" : "GL_FALSE") << " "
    174 			<< (boolVector2[1] ? "GL_TRUE" : "GL_FALSE") << " "
    175 			<< TestLog::EndMessage;
    176 
    177 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    178 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    179 	}
    180 }
    181 
    182 void GetBooleanVerifier::verifyFloat4Color (tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1, GLfloat reference2, GLfloat reference3)
    183 {
    184 	using tcu::TestLog;
    185 
    186 	const GLboolean referenceAsGLBoolean[] =
    187 	{
    188 		reference0 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
    189 		reference1 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
    190 		reference2 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
    191 		reference3 ? GLboolean(GL_TRUE) : GLboolean(GL_FALSE),
    192 	};
    193 
    194 	StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4;
    195 	glGetBooleanv(name, boolVector4);
    196 
    197 	if (!boolVector4.verifyValidity(testCtx))
    198 		return;
    199 
    200 	if (boolVector4[0] != referenceAsGLBoolean[0] ||
    201 		boolVector4[1] != referenceAsGLBoolean[1] ||
    202 		boolVector4[2] != referenceAsGLBoolean[2] ||
    203 		boolVector4[3] != referenceAsGLBoolean[3])
    204 	{
    205 		testCtx.getLog() << TestLog::Message << "// ERROR: expected "
    206 			<< (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") << " "
    207 			<< (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") << " "
    208 			<< (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") << " "
    209 			<< (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
    210 
    211 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    212 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value");
    213 	}
    214 }
    215 
    216 void GetBooleanVerifier::verifyFloatRange (tcu::TestContext& testCtx, GLenum name, GLfloat min, GLfloat max)
    217 {
    218 	using tcu::TestLog;
    219 
    220 	StateQueryMemoryWriteGuard<GLboolean[2]> range;
    221 	glGetBooleanv(name, range);
    222 
    223 	if (!range.verifyValidity(testCtx))
    224 		return;
    225 
    226 	if (range[0] == GL_FALSE)
    227 	{
    228 		if (max < 0 || min < 0)
    229 		{
    230 			testCtx.getLog() << TestLog::Message << "// ERROR: range [" << min << ", " << max << "] is not in range [" << (range[0] == GL_TRUE ? "GL_TRUE" : (range[0] == GL_FALSE ? "GL_FALSE" : "non-boolean")) << ", " << (range[1] == GL_TRUE ? "GL_TRUE" : (range[1] == GL_FALSE ? "GL_FALSE" : "non-boolean")) << "]"  << TestLog::EndMessage;
    231 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    232 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean range");
    233 			return;
    234 		}
    235 	}
    236 	if (range[1] == GL_FALSE)
    237 	{
    238 		if (max > 0 || min > 0)
    239 		{
    240 			testCtx.getLog() << TestLog::Message << "// ERROR: range [" << min << ", " << max << "] is not in range [" << (range[0] == GL_TRUE ? "GL_TRUE" : (range[0] == GL_FALSE ? "GL_FALSE" : "non-boolean")) << ", " << (range[1] == GL_TRUE ? "GL_TRUE" : (range[1] == GL_FALSE ? "GL_FALSE" : "non-boolean")) << "]"  << TestLog::EndMessage;
    241 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    242 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean range");
    243 			return;
    244 		}
    245 	}
    246 }
    247 
    248 //GetIntegerVerifier
    249 
    250 class GetIntegerVerifier : public StateVerifier
    251 {
    252 public:
    253 			GetIntegerVerifier		(const glw::Functions& gl, tcu::TestLog& log);
    254 	void	verifyFloat						(tcu::TestContext& testCtx, GLenum name, GLfloat reference);
    255 	void	verifyFloatExpanded				(tcu::TestContext& testCtx, GLenum name, GLfloat reference);
    256 	void	verifyFloat2Expanded			(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1);
    257 	void	verifyFloat4Color				(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1, GLfloat reference2, GLfloat reference3);
    258 	void	verifyFloatRange				(tcu::TestContext& testCtx, GLenum name, GLfloat min, GLfloat max);
    259 };
    260 
    261 GetIntegerVerifier::GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log)
    262 	: StateVerifier(gl, log, "_getinteger")
    263 {
    264 }
    265 
    266 void GetIntegerVerifier::verifyFloat (tcu::TestContext& testCtx, GLenum name, GLfloat reference)
    267 {
    268 	using tcu::TestLog;
    269 
    270 	const GLint expectedGLStateMax = StateQueryUtil::roundGLfloatToNearestIntegerHalfUp<GLint>(reference);
    271 	const GLint expectedGLStateMin = StateQueryUtil::roundGLfloatToNearestIntegerHalfDown<GLint>(reference);
    272 
    273 	StateQueryMemoryWriteGuard<GLint> state;
    274 	glGetIntegerv(name, &state);
    275 
    276 	if (!state.verifyValidity(testCtx))
    277 		return;
    278 
    279 	if (state < expectedGLStateMin || state > expectedGLStateMax)
    280 	{
    281 		testCtx.getLog() << TestLog::Message << "// ERROR: expected rounding to the nearest integer, valid range [" << expectedGLStateMin << "," << expectedGLStateMax << "]; got " << state << TestLog::EndMessage;
    282 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    283 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    284 	}
    285 }
    286 
    287 void GetIntegerVerifier::verifyFloatExpanded (tcu::TestContext& testCtx, GLenum name, GLfloat reference)
    288 {
    289 	DE_ASSERT(de::inRange(reference, -1.0f, 1.0f));
    290 
    291 	using tcu::TestLog;
    292 	using tcu::toHex;
    293 
    294 	const GLint expectedGLStateMax = clampToGLint(expandGLFloatToInteger(reference) + FLOAT_EXPANSION_E);
    295 	const GLint expectedGLStateMin = clampToGLint(expandGLFloatToInteger(reference) - FLOAT_EXPANSION_E);
    296 
    297 	StateQueryMemoryWriteGuard<GLint> state;
    298 	glGetIntegerv(name, &state);
    299 
    300 	if (!state.verifyValidity(testCtx))
    301 		return;
    302 
    303 	if (state < expectedGLStateMin || state > expectedGLStateMax)
    304 	{
    305 		testCtx.getLog() << TestLog::Message << "// ERROR: expected in range [" << toHex(expectedGLStateMin) << "," << toHex(expectedGLStateMax) << "]; got " << toHex((GLint)state) << TestLog::EndMessage;
    306 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    307 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    308 	}
    309 }
    310 
    311 void GetIntegerVerifier::verifyFloat2Expanded (tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1)
    312 {
    313 	DE_ASSERT(de::inRange(reference0, -1.0f, 1.0f));
    314 	DE_ASSERT(de::inRange(reference1, -1.0f, 1.0f));
    315 
    316 	using tcu::TestLog;
    317 	using tcu::toHex;
    318 
    319 	const GLint referenceAsGLintMin[] =
    320 	{
    321 		clampToGLint(expandGLFloatToInteger(reference0) - FLOAT_EXPANSION_E),
    322 		clampToGLint(expandGLFloatToInteger(reference1) - FLOAT_EXPANSION_E)
    323 	};
    324 	const GLint referenceAsGLintMax[] =
    325 	{
    326 		clampToGLint(expandGLFloatToInteger(reference0) + FLOAT_EXPANSION_E),
    327 		clampToGLint(expandGLFloatToInteger(reference1) + FLOAT_EXPANSION_E)
    328 	};
    329 
    330 	StateQueryMemoryWriteGuard<GLint[2]> floatVector2;
    331 	glGetIntegerv(name, floatVector2);
    332 
    333 	if (!floatVector2.verifyValidity(testCtx))
    334 		return;
    335 
    336 	if (floatVector2[0] < referenceAsGLintMin[0] || floatVector2[0] > referenceAsGLintMax[0] ||
    337 		floatVector2[1] < referenceAsGLintMin[1] || floatVector2[1] > referenceAsGLintMax[1])
    338 	{
    339 		testCtx.getLog() << TestLog::Message
    340 			<< "// ERROR: expected in ranges "
    341 			<< "[" << toHex(referenceAsGLintMin[0]) << " " << toHex(referenceAsGLintMax[0]) << "], "
    342 			<< "[" << toHex(referenceAsGLintMin[1]) << " " << toHex(referenceAsGLintMax[1]) << "]"
    343 			<< "; got "
    344 			<< toHex(floatVector2[0]) << ", "
    345 			<< toHex(floatVector2[1]) << " "<< TestLog::EndMessage;
    346 
    347 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    348 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    349 	}
    350 }
    351 
    352 void GetIntegerVerifier::verifyFloat4Color (tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1, GLfloat reference2, GLfloat reference3)
    353 {
    354 	using tcu::TestLog;
    355 	using tcu::toHex;
    356 
    357 	const GLint referenceAsGLintMin[] =
    358 	{
    359 		clampToGLint(expandGLFloatToInteger(reference0) - FLOAT_EXPANSION_E),
    360 		clampToGLint(expandGLFloatToInteger(reference1) - FLOAT_EXPANSION_E),
    361 		clampToGLint(expandGLFloatToInteger(reference2) - FLOAT_EXPANSION_E),
    362 		clampToGLint(expandGLFloatToInteger(reference3) - FLOAT_EXPANSION_E)
    363 	};
    364 	const GLint referenceAsGLintMax[] =
    365 	{
    366 		clampToGLint(expandGLFloatToInteger(reference0) + FLOAT_EXPANSION_E),
    367 		clampToGLint(expandGLFloatToInteger(reference1) + FLOAT_EXPANSION_E),
    368 		clampToGLint(expandGLFloatToInteger(reference2) + FLOAT_EXPANSION_E),
    369 		clampToGLint(expandGLFloatToInteger(reference3) + FLOAT_EXPANSION_E)
    370 	};
    371 
    372 	StateQueryMemoryWriteGuard<GLint[4]> floatVector4;
    373 	glGetIntegerv(name, floatVector4);
    374 
    375 	if (!floatVector4.verifyValidity(testCtx))
    376 		return;
    377 
    378 	if (floatVector4[0] < referenceAsGLintMin[0] || floatVector4[0] > referenceAsGLintMax[0] ||
    379 		floatVector4[1] < referenceAsGLintMin[1] || floatVector4[1] > referenceAsGLintMax[1] ||
    380 		floatVector4[2] < referenceAsGLintMin[2] || floatVector4[2] > referenceAsGLintMax[2] ||
    381 		floatVector4[3] < referenceAsGLintMin[3] || floatVector4[3] > referenceAsGLintMax[3])
    382 	{
    383 		testCtx.getLog() << TestLog::Message
    384 			<< "// ERROR: expected in ranges "
    385 			<< "[" << toHex(referenceAsGLintMin[0]) << " " << toHex(referenceAsGLintMax[0]) << "], "
    386 			<< "[" << toHex(referenceAsGLintMin[1]) << " " << toHex(referenceAsGLintMax[1]) << "], "
    387 			<< "[" << toHex(referenceAsGLintMin[2]) << " " << toHex(referenceAsGLintMax[2]) << "], "
    388 			<< "[" << toHex(referenceAsGLintMin[3]) << " " << toHex(referenceAsGLintMax[3]) << "]"
    389 			<< "; got "
    390 			<< toHex(floatVector4[0]) << ", "
    391 			<< toHex(floatVector4[1]) << ", "
    392 			<< toHex(floatVector4[2]) << ", "
    393 			<< toHex(floatVector4[3]) << " "<< TestLog::EndMessage;
    394 
    395 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    396 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    397 	}
    398 }
    399 
    400 void GetIntegerVerifier::verifyFloatRange (tcu::TestContext& testCtx, GLenum name, GLfloat min, GLfloat max)
    401 {
    402 	using tcu::TestLog;
    403 
    404 	const GLint testRangeAsGLint[] =
    405 	{
    406 		StateQueryUtil::roundGLfloatToNearestIntegerHalfUp<GLint>(min),
    407 		StateQueryUtil::roundGLfloatToNearestIntegerHalfDown<GLint>(max)
    408 	};
    409 
    410 	StateQueryMemoryWriteGuard<GLint[2]> range;
    411 	glGetIntegerv(name, range);
    412 
    413 	if (!range.verifyValidity(testCtx))
    414 		return;
    415 
    416 	// check if test range outside of gl state range
    417 	if (testRangeAsGLint[0] < range[0] ||
    418 		testRangeAsGLint[1] > range[1])
    419 	{
    420 		testCtx.getLog() << TestLog::Message
    421 			<< "// ERROR: range ["
    422 			<< testRangeAsGLint[0] << ", "
    423 			<< testRangeAsGLint[1] << "]"
    424 			<< " is not in range ["
    425 			<< range[0] << ", "
    426 			<< range[1] << "]" << TestLog::EndMessage;
    427 
    428 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    429 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer range");
    430 	}
    431 }
    432 
    433 //GetInteger64Verifier
    434 
    435 class GetInteger64Verifier : public StateVerifier
    436 {
    437 public:
    438 			GetInteger64Verifier		(const glw::Functions& gl, tcu::TestLog& log);
    439 	void	verifyFloat						(tcu::TestContext& testCtx, GLenum name, GLfloat reference);
    440 	void	verifyFloatExpanded				(tcu::TestContext& testCtx, GLenum name, GLfloat reference);
    441 	void	verifyFloat2Expanded			(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1);
    442 	void	verifyFloat4Color				(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1, GLfloat reference2, GLfloat reference3);
    443 	void	verifyFloatRange				(tcu::TestContext& testCtx, GLenum name, GLfloat min, GLfloat max);
    444 };
    445 
    446 GetInteger64Verifier::GetInteger64Verifier (const glw::Functions& gl, tcu::TestLog& log)
    447 	: StateVerifier(gl, log, "_getinteger64")
    448 {
    449 }
    450 
    451 void GetInteger64Verifier::verifyFloat (tcu::TestContext& testCtx, GLenum name, GLfloat reference)
    452 {
    453 	using tcu::TestLog;
    454 
    455 	const GLint64 expectedGLStateMax = StateQueryUtil::roundGLfloatToNearestIntegerHalfUp<GLint64>(reference);
    456 	const GLint64 expectedGLStateMin = StateQueryUtil::roundGLfloatToNearestIntegerHalfDown<GLint64>(reference);
    457 
    458 	StateQueryMemoryWriteGuard<GLint64> state;
    459 	glGetInteger64v(name, &state);
    460 
    461 	if (!state.verifyValidity(testCtx))
    462 		return;
    463 
    464 	if (state < expectedGLStateMin || state > expectedGLStateMax)
    465 	{
    466 		testCtx.getLog() << TestLog::Message << "// ERROR: expected rounding to the nearest integer, valid range [" << expectedGLStateMin << "," << expectedGLStateMax << "]; 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 
    472 void GetInteger64Verifier::verifyFloatExpanded (tcu::TestContext& testCtx, GLenum name, GLfloat reference)
    473 {
    474 	DE_ASSERT(de::inRange(reference, -1.0f, 1.0f));
    475 
    476 	using tcu::TestLog;
    477 	using tcu::toHex;
    478 
    479 	const GLint64 expectedGLStateMax = expandGLFloatToInteger(reference) + FLOAT_EXPANSION_E;
    480 	const GLint64 expectedGLStateMin = expandGLFloatToInteger(reference) - FLOAT_EXPANSION_E;
    481 
    482 	StateQueryMemoryWriteGuard<GLint64> state;
    483 	glGetInteger64v(name, &state);
    484 
    485 	if (!state.verifyValidity(testCtx))
    486 		return;
    487 
    488 	if (state < expectedGLStateMin || state > expectedGLStateMax)
    489 	{
    490 		testCtx.getLog() << TestLog::Message << "// ERROR: expected in range [" << toHex(expectedGLStateMin) << "," << toHex(expectedGLStateMax) << "]; got " << toHex((GLint64)state) << TestLog::EndMessage;
    491 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    492 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    493 	}
    494 }
    495 
    496 void GetInteger64Verifier::verifyFloat2Expanded (tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1)
    497 {
    498 	DE_ASSERT(de::inRange(reference0, -1.0f, 1.0f));
    499 	DE_ASSERT(de::inRange(reference1, -1.0f, 1.0f));
    500 
    501 	using tcu::TestLog;
    502 	using tcu::toHex;
    503 
    504 	const GLint64 referenceAsGLintMin[] =
    505 	{
    506 		expandGLFloatToInteger(reference0) - FLOAT_EXPANSION_E,
    507 		expandGLFloatToInteger(reference1) - FLOAT_EXPANSION_E
    508 	};
    509 	const GLint64 referenceAsGLintMax[] =
    510 	{
    511 		expandGLFloatToInteger(reference0) + FLOAT_EXPANSION_E,
    512 		expandGLFloatToInteger(reference1) + FLOAT_EXPANSION_E
    513 	};
    514 
    515 	StateQueryMemoryWriteGuard<GLint64[2]> floatVector2;
    516 	glGetInteger64v(name, floatVector2);
    517 
    518 	if (!floatVector2.verifyValidity(testCtx))
    519 		return;
    520 
    521 	if (floatVector2[0] < referenceAsGLintMin[0] || floatVector2[0] > referenceAsGLintMax[0] ||
    522 		floatVector2[1] < referenceAsGLintMin[1] || floatVector2[1] > referenceAsGLintMax[1])
    523 	{
    524 		testCtx.getLog() << TestLog::Message
    525 			<< "// ERROR: expected in ranges "
    526 			<< "[" << toHex(referenceAsGLintMin[0]) << " " << toHex(referenceAsGLintMax[0]) << "], "
    527 			<< "[" << toHex(referenceAsGLintMin[1]) << " " << toHex(referenceAsGLintMax[1]) << "]"
    528 			<< "; got "
    529 			<< toHex(floatVector2[0]) << ", "
    530 			<< toHex(floatVector2[1]) << " "<< TestLog::EndMessage;
    531 
    532 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    533 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    534 	}
    535 }
    536 
    537 void GetInteger64Verifier::verifyFloat4Color (tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1, GLfloat reference2, GLfloat reference3)
    538 {
    539 	using tcu::TestLog;
    540 	using tcu::toHex;
    541 
    542 	const GLint64 referenceAsGLintMin[] =
    543 	{
    544 		expandGLFloatToInteger(reference0) - FLOAT_EXPANSION_E,
    545 		expandGLFloatToInteger(reference1) - FLOAT_EXPANSION_E,
    546 		expandGLFloatToInteger(reference2) - FLOAT_EXPANSION_E,
    547 		expandGLFloatToInteger(reference3) - FLOAT_EXPANSION_E
    548 	};
    549 	const GLint64 referenceAsGLintMax[] =
    550 	{
    551 		expandGLFloatToInteger(reference0) + FLOAT_EXPANSION_E,
    552 		expandGLFloatToInteger(reference1) + FLOAT_EXPANSION_E,
    553 		expandGLFloatToInteger(reference2) + FLOAT_EXPANSION_E,
    554 		expandGLFloatToInteger(reference3) + FLOAT_EXPANSION_E
    555 	};
    556 
    557 	StateQueryMemoryWriteGuard<GLint64[4]> floatVector4;
    558 	glGetInteger64v(name, floatVector4);
    559 
    560 	if (!floatVector4.verifyValidity(testCtx))
    561 		return;
    562 
    563 	if (floatVector4[0] < referenceAsGLintMin[0] || floatVector4[0] > referenceAsGLintMax[0] ||
    564 		floatVector4[1] < referenceAsGLintMin[1] || floatVector4[1] > referenceAsGLintMax[1] ||
    565 		floatVector4[2] < referenceAsGLintMin[2] || floatVector4[2] > referenceAsGLintMax[2] ||
    566 		floatVector4[3] < referenceAsGLintMin[3] || floatVector4[3] > referenceAsGLintMax[3])
    567 	{
    568 		testCtx.getLog() << TestLog::Message
    569 			<< "// ERROR: expected in ranges "
    570 			<< "[" << toHex(referenceAsGLintMin[0]) << " " << toHex(referenceAsGLintMax[0]) << "], "
    571 			<< "[" << toHex(referenceAsGLintMin[1]) << " " << toHex(referenceAsGLintMax[1]) << "], "
    572 			<< "[" << toHex(referenceAsGLintMin[2]) << " " << toHex(referenceAsGLintMax[2]) << "], "
    573 			<< "[" << toHex(referenceAsGLintMin[3]) << " " << toHex(referenceAsGLintMax[3]) << "]"
    574 			<< "; got "
    575 			<< toHex(floatVector4[0]) << ", "
    576 			<< toHex(floatVector4[1]) << ", "
    577 			<< toHex(floatVector4[2]) << ", "
    578 			<< toHex(floatVector4[3]) << " "<< TestLog::EndMessage;
    579 
    580 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    581 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value");
    582 	}
    583 }
    584 
    585 void GetInteger64Verifier::verifyFloatRange (tcu::TestContext& testCtx, GLenum name, GLfloat min, GLfloat max)
    586 {
    587 	using tcu::TestLog;
    588 
    589 	const GLint64 testRangeAsGLint[] =
    590 	{
    591 		StateQueryUtil::roundGLfloatToNearestIntegerHalfUp<GLint64>(min),
    592 		StateQueryUtil::roundGLfloatToNearestIntegerHalfDown<GLint64>(max)
    593 	};
    594 
    595 	StateQueryMemoryWriteGuard<GLint64[2]> range;
    596 	glGetInteger64v(name, range);
    597 
    598 	if (!range.verifyValidity(testCtx))
    599 		return;
    600 
    601 	// check if test range outside of gl state range
    602 	if (testRangeAsGLint[0] < range[0] ||
    603 		testRangeAsGLint[1] > range[1])
    604 	{
    605 		testCtx.getLog() << TestLog::Message
    606 			<< "// ERROR: range ["
    607 			<< testRangeAsGLint[0] << ", "
    608 			<< testRangeAsGLint[1] << "]"
    609 			<< " is not in range ["
    610 			<< range[0] << ", "
    611 			<< range[1] << "]" << TestLog::EndMessage;
    612 
    613 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    614 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer range");
    615 	}
    616 }
    617 
    618 //GetFloatVerifier
    619 
    620 class GetFloatVerifier : public StateVerifier
    621 {
    622 public:
    623 			GetFloatVerifier			(const glw::Functions& gl, tcu::TestLog& log);
    624 	void	verifyFloat						(tcu::TestContext& testCtx, GLenum name, GLfloat reference);
    625 	void	verifyFloatExpanded				(tcu::TestContext& testCtx, GLenum name, GLfloat reference);
    626 	void	verifyFloat2Expanded			(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1);
    627 	void	verifyFloat4Color				(tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1, GLfloat reference2, GLfloat reference3);
    628 	void	verifyFloatRange				(tcu::TestContext& testCtx, GLenum name, GLfloat min, GLfloat max);
    629 };
    630 
    631 GetFloatVerifier::GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log)
    632 	: StateVerifier(gl, log, "_getfloat")
    633 {
    634 }
    635 
    636 void GetFloatVerifier::verifyFloat (tcu::TestContext& testCtx, GLenum name, GLfloat reference)
    637 {
    638 	using tcu::TestLog;
    639 
    640 	StateQueryMemoryWriteGuard<GLfloat> state;
    641 	glGetFloatv(name, &state);
    642 
    643 	if (!state.verifyValidity(testCtx))
    644 		return;
    645 
    646 	if (state != reference)
    647 	{
    648 		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage;
    649 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    650 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
    651 	}
    652 }
    653 
    654 void GetFloatVerifier::verifyFloatExpanded (tcu::TestContext& testCtx, GLenum name, GLfloat reference)
    655 {
    656 	DE_ASSERT(de::inRange(reference, -1.0f, 1.0f));
    657 	verifyFloat(testCtx, name, reference);
    658 }
    659 
    660 void GetFloatVerifier::verifyFloat2Expanded (tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1)
    661 {
    662 	DE_ASSERT(de::inRange(reference0, -1.0f, 1.0f));
    663 	DE_ASSERT(de::inRange(reference1, -1.0f, 1.0f));
    664 
    665 	using tcu::TestLog;
    666 
    667 	StateQueryMemoryWriteGuard<GLfloat[2]> floatVector2;
    668 	glGetFloatv(name, floatVector2);
    669 
    670 	if (!floatVector2.verifyValidity(testCtx))
    671 		return;
    672 
    673 	if (floatVector2[0] != reference0 ||
    674 		floatVector2[1] != reference1)
    675 	{
    676 		testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference0 << ", " << reference1 << "; got " << floatVector2[0] << " " << floatVector2[1] << TestLog::EndMessage;
    677 
    678 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    679 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
    680 	}
    681 }
    682 
    683 void GetFloatVerifier::verifyFloat4Color (tcu::TestContext& testCtx, GLenum name, GLfloat reference0, GLfloat reference1, GLfloat reference2, GLfloat reference3)
    684 {
    685 	using tcu::TestLog;
    686 
    687 	StateQueryMemoryWriteGuard<GLfloat[4]> floatVector4;
    688 	glGetFloatv(name, floatVector4);
    689 
    690 	if (!floatVector4.verifyValidity(testCtx))
    691 		return;
    692 
    693 	if (floatVector4[0] != reference0 ||
    694 		floatVector4[1] != reference1 ||
    695 		floatVector4[2] != reference2 ||
    696 		floatVector4[3] != reference3)
    697 	{
    698 		testCtx.getLog() << TestLog::Message
    699 			<< "// ERROR: expected "<< reference0 << ", " << reference1 << ", " << reference2 << ", " << reference3
    700 			<< "; got " << floatVector4[0] << ", " << floatVector4[1] << ", " << floatVector4[2] << ", " << floatVector4[3]
    701 			<< TestLog::EndMessage;
    702 
    703 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    704 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value");
    705 	}
    706 }
    707 
    708 void GetFloatVerifier::verifyFloatRange (tcu::TestContext& testCtx, GLenum name, GLfloat min, GLfloat max)
    709 {
    710 	using tcu::TestLog;
    711 
    712 	StateQueryMemoryWriteGuard<GLfloat[2]> floatVector2;
    713 	glGetFloatv(name, floatVector2);
    714 
    715 	if (!floatVector2.verifyValidity(testCtx))
    716 		return;
    717 
    718 	if (floatVector2[0] > min ||
    719 		floatVector2[1] < max)
    720 	{
    721 		testCtx.getLog() << TestLog::Message << "// ERROR: expected in range [" << min << ", " << max << "]; got [" << floatVector2[0] << " " << floatVector2[1]  << "]" << TestLog::EndMessage;
    722 
    723 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
    724 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float range");
    725 	}
    726 }
    727 
    728 } // FloatStateQueryVerifiers
    729 
    730 namespace
    731 {
    732 
    733 using namespace FloatStateQueryVerifiers;
    734 
    735 class DepthRangeCase : public ApiCase
    736 {
    737 public:
    738 	DepthRangeCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    739 		: ApiCase		(context, name, description)
    740 		, m_verifier	(verifier)
    741 	{
    742 	}
    743 
    744 	void test (void)
    745 	{
    746 		de::Random rnd(0xabcdef);
    747 
    748 		m_verifier->verifyFloat2Expanded(m_testCtx, GL_DEPTH_RANGE, 0.0f, 1.0f);
    749 		expectError(GL_NO_ERROR);
    750 
    751 		{
    752 			const struct FixedTest
    753 			{
    754 				float n, f;
    755 			} fixedTests[] =
    756 			{
    757 				{ 0.5f, 1.0f },
    758 				{ 0.0f, 0.5f },
    759 				{ 0.0f, 0.0f },
    760 				{ 1.0f, 1.0f }
    761 			};
    762 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(fixedTests); ++ndx)
    763 			{
    764 				glDepthRangef(fixedTests[ndx].n, fixedTests[ndx].f);
    765 
    766 				m_verifier->verifyFloat2Expanded(m_testCtx, GL_DEPTH_RANGE, fixedTests[ndx].n, fixedTests[ndx].f);
    767 				expectError(GL_NO_ERROR);
    768 			}
    769 		}
    770 
    771 		{
    772 			const int numIterations = 120;
    773 			for (int i = 0; i < numIterations; ++i)
    774 			{
    775 				GLfloat n	= rnd.getFloat(0, 1);
    776 				GLfloat f	= rnd.getFloat(0, 1);
    777 
    778 				glDepthRangef(n, f);
    779 				m_verifier->verifyFloat2Expanded(m_testCtx, GL_DEPTH_RANGE, n, f);
    780 				expectError(GL_NO_ERROR);
    781 			}
    782 		}
    783 	}
    784 private:
    785 	StateVerifier*	m_verifier;
    786 };
    787 
    788 class LineWidthCase : public ApiCase
    789 {
    790 public:
    791 	LineWidthCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    792 		: ApiCase		(context, name, description)
    793 		, m_verifier	(verifier)
    794 	{
    795 	}
    796 
    797 	void test (void)
    798 	{
    799 		de::Random rnd(0xabcdef);
    800 
    801 		GLfloat range[2] = {1};
    802 		glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, range);
    803 		expectError(GL_NO_ERROR);
    804 
    805 		m_verifier->verifyFloat(m_testCtx, GL_LINE_WIDTH, 1.0f);
    806 		expectError(GL_NO_ERROR);
    807 
    808 		const int numIterations = 120;
    809 		for (int i = 0; i < numIterations; ++i)
    810 		{
    811 			const GLfloat reference = rnd.getFloat(range[0], range[1]);
    812 
    813 			glLineWidth(reference);
    814 			m_verifier->verifyFloat(m_testCtx, GL_LINE_WIDTH, reference);
    815 			expectError(GL_NO_ERROR);
    816 		}
    817 	}
    818 private:
    819 	StateVerifier*	m_verifier;
    820 };
    821 
    822 class PolygonOffsetFactorCase : public ApiCase
    823 {
    824 public:
    825 	PolygonOffsetFactorCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    826 		: ApiCase		(context, name, description)
    827 		, m_verifier	(verifier)
    828 	{
    829 	}
    830 
    831 	void test (void)
    832 	{
    833 		de::Random rnd(0xabcdef);
    834 
    835 		m_verifier->verifyFloat(m_testCtx, GL_POLYGON_OFFSET_FACTOR, 0.0f);
    836 		expectError(GL_NO_ERROR);
    837 
    838 		{
    839 			const float fixedTests[] =
    840 			{
    841 				0.0f, 0.5f, -0.5f, 1.5f
    842 			};
    843 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(fixedTests); ++ndx)
    844 			{
    845 				glPolygonOffset(fixedTests[ndx], 0);
    846 				m_verifier->verifyFloat(m_testCtx, GL_POLYGON_OFFSET_FACTOR, fixedTests[ndx]);
    847 				expectError(GL_NO_ERROR);
    848 			}
    849 		}
    850 
    851 		{
    852 			const int numIterations = 120;
    853 			for (int i = 0; i < numIterations; ++i)
    854 			{
    855 				const GLfloat reference = rnd.getFloat(-64000, 64000);
    856 
    857 				glPolygonOffset(reference, 0);
    858 				m_verifier->verifyFloat(m_testCtx, GL_POLYGON_OFFSET_FACTOR, reference);
    859 				expectError(GL_NO_ERROR);
    860 			}
    861 		}
    862 	}
    863 private:
    864 	StateVerifier*	m_verifier;
    865 };
    866 
    867 class PolygonOffsetUnitsCase : public ApiCase
    868 {
    869 public:
    870 	PolygonOffsetUnitsCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    871 		: ApiCase		(context, name, description)
    872 		, m_verifier	(verifier)
    873 	{
    874 	}
    875 
    876 	void test (void)
    877 	{
    878 		de::Random rnd(0xabcdef);
    879 
    880 		m_verifier->verifyFloat(m_testCtx, GL_POLYGON_OFFSET_UNITS, 0.0f);
    881 		expectError(GL_NO_ERROR);
    882 
    883 		{
    884 			const float fixedTests[] =
    885 			{
    886 				0.0f, 0.5f, -0.5f, 1.5f
    887 			};
    888 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(fixedTests); ++ndx)
    889 			{
    890 				glPolygonOffset(0, fixedTests[ndx]);
    891 				m_verifier->verifyFloat(m_testCtx, GL_POLYGON_OFFSET_UNITS, fixedTests[ndx]);
    892 				expectError(GL_NO_ERROR);
    893 			}
    894 		}
    895 
    896 		{
    897 			const int numIterations = 120;
    898 			for (int i = 0; i < numIterations; ++i)
    899 			{
    900 				const GLfloat reference = rnd.getFloat(-64000, 64000);
    901 
    902 				glPolygonOffset(0, reference);
    903 				m_verifier->verifyFloat(m_testCtx, GL_POLYGON_OFFSET_UNITS, reference);
    904 				expectError(GL_NO_ERROR);
    905 			}
    906 		}
    907 	}
    908 private:
    909 	StateVerifier*	m_verifier;
    910 };
    911 
    912 class SampleCoverageCase : public ApiCase
    913 {
    914 public:
    915 	SampleCoverageCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    916 		: ApiCase		(context, name, description)
    917 		, m_verifier	(verifier)
    918 	{
    919 	}
    920 
    921 	void test (void)
    922 	{
    923 		de::Random rnd(0xabcdef);
    924 
    925 		m_verifier->verifyFloat(m_testCtx, GL_SAMPLE_COVERAGE_VALUE, 1.0f);
    926 		expectError(GL_NO_ERROR);
    927 
    928 		{
    929 			const float fixedTests[] =
    930 			{
    931 				0.0f, 0.5f, 0.45f, 0.55f
    932 			};
    933 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(fixedTests); ++ndx)
    934 			{
    935 				glSampleCoverage(fixedTests[ndx], GL_FALSE);
    936 				m_verifier->verifyFloat(m_testCtx, GL_SAMPLE_COVERAGE_VALUE, fixedTests[ndx]);
    937 				expectError(GL_NO_ERROR);
    938 			}
    939 		}
    940 
    941 		{
    942 			const float clampTests[] =
    943 			{
    944 				-1.0f, -1.5f, 1.45f, 3.55f
    945 			};
    946 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(clampTests); ++ndx)
    947 			{
    948 				glSampleCoverage(clampTests[ndx], GL_FALSE);
    949 				m_verifier->verifyFloat(m_testCtx, GL_SAMPLE_COVERAGE_VALUE, de::clamp(clampTests[ndx], 0.0f, 1.0f));
    950 				expectError(GL_NO_ERROR);
    951 			}
    952 		}
    953 
    954 		{
    955 			const int numIterations = 120;
    956 			for (int i = 0; i < numIterations; ++i)
    957 			{
    958 				GLfloat		reference	= rnd.getFloat(0, 1);
    959 				GLboolean	invert		= rnd.getBool() ? GL_TRUE : GL_FALSE;
    960 
    961 				glSampleCoverage(reference, invert);
    962 				m_verifier->verifyFloat(m_testCtx, GL_SAMPLE_COVERAGE_VALUE, reference);
    963 				expectError(GL_NO_ERROR);
    964 			}
    965 		}
    966 	}
    967 private:
    968 	StateVerifier*	m_verifier;
    969 };
    970 
    971 class ColorClearCase : public ApiCase
    972 {
    973 public:
    974 	ColorClearCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
    975 		: ApiCase		(context, name, description)
    976 		, m_verifier	(verifier)
    977 	{
    978 	}
    979 
    980 	void test (void)
    981 	{
    982 		de::Random rnd(0xabcdef);
    983 
    984 		// \note Initial color clear value check is temorarily removed. (until the framework does not alter it)
    985 		//m_verifier->verifyFloat4Color(m_testCtx, GL_COLOR_CLEAR_VALUE, 0, 0, 0, 0);
    986 		//expectError(GL_NO_ERROR);
    987 
    988 		{
    989 			const struct FixedTest
    990 			{
    991 				float r, g, b, a;
    992 			} fixedTests[] =
    993 			{
    994 				{ 0.5f, 1.0f, 0.5f, 1.0f },
    995 				{ 0.0f, 0.5f, 0.0f, 0.5f },
    996 				{ 0.0f, 0.0f, 0.0f, 0.0f },
    997 				{ 1.0f, 1.0f, 1.0f, 1.0f },
    998 			};
    999 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(fixedTests); ++ndx)
   1000 			{
   1001 				glClearColor(fixedTests[ndx].r, fixedTests[ndx].g, fixedTests[ndx].b, fixedTests[ndx].a);
   1002 				m_verifier->verifyFloat4Color(m_testCtx, GL_COLOR_CLEAR_VALUE, fixedTests[ndx].r, fixedTests[ndx].g, fixedTests[ndx].b, fixedTests[ndx].a);
   1003 				expectError(GL_NO_ERROR);
   1004 			}
   1005 		}
   1006 
   1007 		{
   1008 			const int numIterations = 120;
   1009 			for (int i = 0; i < numIterations; ++i)
   1010 			{
   1011 				const GLfloat r = rnd.getFloat(0, 1);
   1012 				const GLfloat g = rnd.getFloat(0, 1);
   1013 				const GLfloat b = rnd.getFloat(0, 1);
   1014 				const GLfloat a = rnd.getFloat(0, 1);
   1015 
   1016 				glClearColor(r, g, b, a);
   1017 				m_verifier->verifyFloat4Color(m_testCtx, GL_COLOR_CLEAR_VALUE, r, g, b, a);
   1018 				expectError(GL_NO_ERROR);
   1019 			}
   1020 		}
   1021 	}
   1022 private:
   1023 	StateVerifier*	m_verifier;
   1024 };
   1025 
   1026 class DepthClearCase : public ApiCase
   1027 {
   1028 public:
   1029 	DepthClearCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
   1030 		: ApiCase		(context, name, description)
   1031 		, m_verifier	(verifier)
   1032 	{
   1033 	}
   1034 
   1035 	void test (void)
   1036 	{
   1037 		const int numIterations = 120;
   1038 
   1039 		de::Random rnd(0xabcdef);
   1040 
   1041 		m_verifier->verifyFloatExpanded(m_testCtx, GL_DEPTH_CLEAR_VALUE, 1);
   1042 		expectError(GL_NO_ERROR);
   1043 
   1044 		for (int i = 0; i < numIterations; ++i)
   1045 		{
   1046 			const GLfloat ref = rnd.getFloat(0, 1);
   1047 
   1048 			glClearDepthf(ref);
   1049 			m_verifier->verifyFloatExpanded(m_testCtx, GL_DEPTH_CLEAR_VALUE, ref);
   1050 			expectError(GL_NO_ERROR);
   1051 		}
   1052 	}
   1053 private:
   1054 	StateVerifier*	m_verifier;
   1055 };
   1056 
   1057 class AliasedPointSizeRangeCase : public ApiCase
   1058 {
   1059 public:
   1060 	AliasedPointSizeRangeCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
   1061 		: ApiCase		(context, name, description)
   1062 		, m_verifier	(verifier)
   1063 	{
   1064 	}
   1065 
   1066 	void test (void)
   1067 	{
   1068 		m_verifier->verifyFloatRange(m_testCtx, GL_ALIASED_POINT_SIZE_RANGE, 1, 1);
   1069 		expectError(GL_NO_ERROR);
   1070 	}
   1071 private:
   1072 	StateVerifier*	m_verifier;
   1073 };
   1074 
   1075 class AliasedLineWidthRangeCase : public ApiCase
   1076 {
   1077 public:
   1078 	AliasedLineWidthRangeCase (Context& context, StateVerifier* verifier, const char* name, const char* description)
   1079 		: ApiCase		(context, name, description)
   1080 		, m_verifier	(verifier)
   1081 	{
   1082 	}
   1083 
   1084 	void test (void)
   1085 	{
   1086 		m_verifier->verifyFloatRange(m_testCtx, GL_ALIASED_LINE_WIDTH_RANGE, 1, 1);
   1087 		expectError(GL_NO_ERROR);
   1088 	}
   1089 private:
   1090 	StateVerifier*	m_verifier;
   1091 };
   1092 
   1093 #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK)												\
   1094 	for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++)	\
   1095 	{																							\
   1096 		StateVerifier* verifier = VERIFIERS[_verifierNdx];										\
   1097 		CODE_BLOCK;																				\
   1098 	}
   1099 
   1100 } // anonymous
   1101 
   1102 FloatStateQueryTests::FloatStateQueryTests (Context& context)
   1103 	: TestCaseGroup			(context, "floats", "Float Values")
   1104 	, m_verifierBoolean		(DE_NULL)
   1105 	, m_verifierInteger		(DE_NULL)
   1106 	, m_verifierFloat		(DE_NULL)
   1107 {
   1108 }
   1109 
   1110 FloatStateQueryTests::~FloatStateQueryTests (void)
   1111 {
   1112 	deinit();
   1113 }
   1114 
   1115 void FloatStateQueryTests::init (void)
   1116 {
   1117 	DE_ASSERT(m_verifierBoolean == DE_NULL);
   1118 	DE_ASSERT(m_verifierInteger == DE_NULL);
   1119 	DE_ASSERT(m_verifierFloat == DE_NULL);
   1120 
   1121 	m_verifierBoolean		= new GetBooleanVerifier	(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
   1122 	m_verifierInteger		= new GetIntegerVerifier	(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
   1123 	m_verifierFloat			= new GetFloatVerifier		(m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog());
   1124 
   1125 	StateVerifier* verifiers[] = {m_verifierBoolean, m_verifierInteger, m_verifierFloat};
   1126 
   1127 	FOR_EACH_VERIFIER(verifiers, addChild(new DepthRangeCase				(m_context, verifier,	(std::string("depth_range")					+ verifier->getTestNamePostfix()).c_str(),	"DEPTH_RANGE")));
   1128 	FOR_EACH_VERIFIER(verifiers, addChild(new LineWidthCase					(m_context, verifier,	(std::string("line_width")					+ verifier->getTestNamePostfix()).c_str(),	"LINE_WIDTH")));
   1129 	FOR_EACH_VERIFIER(verifiers, addChild(new PolygonOffsetFactorCase		(m_context, verifier,	(std::string("polygon_offset_factor")		+ verifier->getTestNamePostfix()).c_str(),	"POLYGON_OFFSET_FACTOR")));
   1130 	FOR_EACH_VERIFIER(verifiers, addChild(new PolygonOffsetUnitsCase		(m_context, verifier,	(std::string("polygon_offset_units")		+ verifier->getTestNamePostfix()).c_str(),	"POLYGON_OFFSET_UNITS")));
   1131 	FOR_EACH_VERIFIER(verifiers, addChild(new SampleCoverageCase			(m_context, verifier,	(std::string("sample_coverage_value")		+ verifier->getTestNamePostfix()).c_str(),	"SAMPLE_COVERAGE_VALUE")));
   1132 	FOR_EACH_VERIFIER(verifiers, addChild(new ColorClearCase				(m_context, verifier,	(std::string("color_clear_value")			+ verifier->getTestNamePostfix()).c_str(),	"COLOR_CLEAR_VALUE")));
   1133 	FOR_EACH_VERIFIER(verifiers, addChild(new DepthClearCase				(m_context, verifier,	(std::string("depth_clear_value")			+ verifier->getTestNamePostfix()).c_str(),	"DEPTH_CLEAR_VALUE")));
   1134 	FOR_EACH_VERIFIER(verifiers, addChild(new AliasedPointSizeRangeCase		(m_context, verifier,	(std::string("aliased_point_size_range")	+ verifier->getTestNamePostfix()).c_str(),	"ALIASED_POINT_SIZE_RANGE")));
   1135 	FOR_EACH_VERIFIER(verifiers, addChild(new AliasedLineWidthRangeCase		(m_context, verifier,	(std::string("aliased_line_width_range")	+ verifier->getTestNamePostfix()).c_str(),	"ALIASED_LINE_WIDTH_RANGE")));
   1136 }
   1137 
   1138 void FloatStateQueryTests::deinit (void)
   1139 {
   1140 	if (m_verifierBoolean)
   1141 	{
   1142 		delete m_verifierBoolean;
   1143 		m_verifierBoolean = DE_NULL;
   1144 	}
   1145 	if (m_verifierInteger)
   1146 	{
   1147 		delete m_verifierInteger;
   1148 		m_verifierInteger = DE_NULL;
   1149 	}
   1150 	if (m_verifierFloat)
   1151 	{
   1152 		delete m_verifierFloat;
   1153 		m_verifierFloat = DE_NULL;
   1154 	}
   1155 
   1156 	this->TestCaseGroup::deinit();
   1157 }
   1158 
   1159 } // Functional
   1160 } // gles2
   1161 } // deqp
   1162