Home | History | Annotate | Download | only in glshared
      1 /*-------------------------------------------------------------------------
      2  * drawElements Quality Program OpenGL (ES) Module
      3  * -----------------------------------------------
      4  *
      5  * Copyright 2015 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 Texture State Query tests.
     22  *//*--------------------------------------------------------------------*/
     23 
     24 #include "glsTextureStateQueryTests.hpp"
     25 #include "gluStrUtil.hpp"
     26 #include "gluObjectWrapper.hpp"
     27 #include "gluCallLogWrapper.hpp"
     28 #include "gluContextInfo.hpp"
     29 #include "gluTextureUtil.hpp"
     30 #include "glwEnums.hpp"
     31 #include "deUniquePtr.hpp"
     32 #include "deRandom.hpp"
     33 #include "deStringUtil.hpp"
     34 
     35 namespace deqp
     36 {
     37 namespace gls
     38 {
     39 namespace TextureStateQueryTests
     40 {
     41 namespace
     42 {
     43 
     44 using namespace glw;
     45 using namespace gls::StateQueryUtil;
     46 
     47 static glw::GLenum mapTesterToPname (TesterType tester)
     48 {
     49 
     50 #define CASE_ALL_SETTERS(X) case X: case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
     51 
     52 	switch (tester)
     53 	{
     54 		CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_R):				return GL_TEXTURE_SWIZZLE_R;
     55 		CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_G):				return GL_TEXTURE_SWIZZLE_G;
     56 		CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_B):				return GL_TEXTURE_SWIZZLE_B;
     57 		CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_A):				return GL_TEXTURE_SWIZZLE_A;
     58 
     59 		CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S):
     60 		case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:				return GL_TEXTURE_WRAP_S;
     61 
     62 		CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T):
     63 		case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:				return GL_TEXTURE_WRAP_T;
     64 
     65 		CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R):
     66 		case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:				return GL_TEXTURE_WRAP_R;
     67 
     68 		CASE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER):			return GL_TEXTURE_MAG_FILTER;
     69 		CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER):			return GL_TEXTURE_MIN_FILTER;
     70 		CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD):				return GL_TEXTURE_MIN_LOD;
     71 		CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD):				return GL_TEXTURE_MAX_LOD;
     72 		CASE_ALL_SETTERS(TESTER_TEXTURE_BASE_LEVEL):			return GL_TEXTURE_BASE_LEVEL;
     73 		CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LEVEL):				return GL_TEXTURE_MAX_LEVEL;
     74 		CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE):			return GL_TEXTURE_COMPARE_MODE;
     75 		CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC):			return GL_TEXTURE_COMPARE_FUNC;
     76 		case TESTER_TEXTURE_IMMUTABLE_LEVELS:					return GL_TEXTURE_IMMUTABLE_LEVELS;
     77 		case TESTER_TEXTURE_IMMUTABLE_FORMAT:					return GL_TEXTURE_IMMUTABLE_FORMAT;
     78 		CASE_ALL_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE):	return GL_DEPTH_STENCIL_TEXTURE_MODE;
     79 		CASE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT):		return GL_TEXTURE_SRGB_DECODE_EXT;
     80 		case TESTER_TEXTURE_BORDER_COLOR:						return GL_TEXTURE_BORDER_COLOR;
     81 
     82 		default:
     83 			DE_ASSERT(false);
     84 			return -1;
     85 	}
     86 
     87 #undef CASE_PURE_SETTERS
     88 }
     89 
     90 static bool querySupportsSigned (QueryType type)
     91 {
     92 	return	type != QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER &&
     93 			type != QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER;
     94 }
     95 
     96 static bool isPureIntTester (TesterType tester)
     97 {
     98 #define HANDLE_ALL_SETTERS(X) \
     99 		case X: \
    100 		case X ## _SET_PURE_UINT: return false; \
    101 		case X ## _SET_PURE_INT: return true;
    102 
    103 	switch (tester)
    104 	{
    105 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_R)
    106 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_G)
    107 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_B)
    108 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_A)
    109 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S)
    110 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T)
    111 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R)
    112 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER)
    113 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER)
    114 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD)
    115 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD)
    116 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_BASE_LEVEL)
    117 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAX_LEVEL)
    118 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE)
    119 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC)
    120 		HANDLE_ALL_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE)
    121 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT)
    122 
    123 		case TESTER_TEXTURE_IMMUTABLE_LEVELS:
    124 		case TESTER_TEXTURE_IMMUTABLE_FORMAT:
    125 		case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
    126 		case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
    127 		case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
    128 		case TESTER_TEXTURE_BORDER_COLOR:
    129 			return false;
    130 
    131 		default:
    132 			DE_ASSERT(false);
    133 			return false;
    134 	}
    135 
    136 #undef HANDLE_ALL_SETTERS
    137 }
    138 
    139 static bool isPureUintTester (TesterType tester)
    140 {
    141 #define HANDLE_ALL_SETTERS(X) \
    142 		case X: \
    143 		case X ## _SET_PURE_INT: return false; \
    144 		case X ## _SET_PURE_UINT: return true;
    145 
    146 	switch (tester)
    147 	{
    148 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_R)
    149 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_G)
    150 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_B)
    151 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_A)
    152 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S)
    153 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T)
    154 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R)
    155 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER)
    156 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER)
    157 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD)
    158 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD)
    159 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_BASE_LEVEL)
    160 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_MAX_LEVEL)
    161 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE)
    162 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC)
    163 		HANDLE_ALL_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE)
    164 		HANDLE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT)
    165 
    166 		case TESTER_TEXTURE_IMMUTABLE_LEVELS:
    167 		case TESTER_TEXTURE_IMMUTABLE_FORMAT:
    168 		case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
    169 		case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
    170 		case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
    171 		case TESTER_TEXTURE_BORDER_COLOR:
    172 			return false;
    173 
    174 		default:
    175 			DE_ASSERT(false);
    176 			return false;
    177 	}
    178 
    179 #undef HANDLE_ALL_SETTERS
    180 }
    181 
    182 class RequiredExtensions
    183 {
    184 public:
    185 								RequiredExtensions	(void)									{ }
    186 	explicit					RequiredExtensions	(const char* ext)						{ add(ext);				}
    187 								RequiredExtensions	(const char* extA, const char* extB)	{ add(extA); add(extB);	}
    188 
    189 	void						add					(const char* ext);
    190 	void						add					(const RequiredExtensions& other);
    191 	void						check				(const glu::ContextInfo&) const;
    192 
    193 private:
    194 	std::vector<const char*>	m_extensions;
    195 };
    196 
    197 void RequiredExtensions::add (const char* ext)
    198 {
    199 	for (int ndx = 0; ndx < (int)m_extensions.size(); ++ndx)
    200 		if (deStringEqual(m_extensions[ndx], ext) == DE_TRUE)
    201 			return;
    202 	m_extensions.push_back(ext);
    203 }
    204 
    205 void RequiredExtensions::add (const RequiredExtensions& other)
    206 {
    207 	for (int ndx = 0; ndx < (int)other.m_extensions.size(); ++ndx)
    208 		add(other.m_extensions[ndx]);
    209 }
    210 
    211 void RequiredExtensions::check (const glu::ContextInfo& ctxInfo) const
    212 {
    213 	std::vector<const char*> failedExtensions;
    214 
    215 	for (int ndx = 0; ndx < (int)m_extensions.size(); ++ndx)
    216 		if (!ctxInfo.isExtensionSupported(m_extensions[ndx]))
    217 			failedExtensions.push_back(m_extensions[ndx]);
    218 
    219 	if (!failedExtensions.empty())
    220 	{
    221 		std::ostringstream buf;
    222 		buf << "Test requires extension: ";
    223 
    224 		for (int ndx = 0; ndx < (int)failedExtensions.size(); ++ndx)
    225 		{
    226 			if (ndx)
    227 				buf << ", ";
    228 			buf << failedExtensions[ndx];
    229 		}
    230 
    231 		throw tcu::NotSupportedError(buf.str());
    232 	}
    233 }
    234 
    235 namespace es30
    236 {
    237 
    238 static bool isCoreTextureTarget (glw::GLenum target)
    239 {
    240 	return	target == GL_TEXTURE_2D			||
    241 			target == GL_TEXTURE_3D			||
    242 			target == GL_TEXTURE_2D_ARRAY	||
    243 			target == GL_TEXTURE_CUBE_MAP;
    244 }
    245 
    246 static RequiredExtensions getTextureTargetExtension (glw::GLenum target)
    247 {
    248 	DE_UNREF(target);
    249 	DE_ASSERT(false);
    250 	return RequiredExtensions();
    251 }
    252 
    253 static bool isCoreTextureParam (glw::GLenum pname)
    254 {
    255 	return	pname == GL_TEXTURE_BASE_LEVEL			||
    256 			pname == GL_TEXTURE_COMPARE_MODE		||
    257 			pname == GL_TEXTURE_COMPARE_FUNC		||
    258 			pname == GL_TEXTURE_MAG_FILTER			||
    259 			pname == GL_TEXTURE_MAX_LEVEL			||
    260 			pname == GL_TEXTURE_MAX_LOD				||
    261 			pname == GL_TEXTURE_MIN_FILTER			||
    262 			pname == GL_TEXTURE_MIN_LOD				||
    263 			pname == GL_TEXTURE_SWIZZLE_R			||
    264 			pname == GL_TEXTURE_SWIZZLE_G			||
    265 			pname == GL_TEXTURE_SWIZZLE_B			||
    266 			pname == GL_TEXTURE_SWIZZLE_A			||
    267 			pname == GL_TEXTURE_WRAP_S				||
    268 			pname == GL_TEXTURE_WRAP_T				||
    269 			pname == GL_TEXTURE_WRAP_R				||
    270 			pname == GL_TEXTURE_IMMUTABLE_FORMAT	||
    271 			pname == GL_TEXTURE_IMMUTABLE_LEVELS;
    272 }
    273 
    274 static RequiredExtensions getTextureParamExtension (glw::GLenum pname)
    275 {
    276 	DE_UNREF(pname);
    277 	DE_ASSERT(false);
    278 	return RequiredExtensions();
    279 }
    280 
    281 static bool isCoreQuery (QueryType query)
    282 {
    283 	return	query == QUERY_TEXTURE_PARAM_INTEGER		||
    284 			query == QUERY_TEXTURE_PARAM_FLOAT			||
    285 			query == QUERY_TEXTURE_PARAM_INTEGER_VEC4	||
    286 			query == QUERY_TEXTURE_PARAM_FLOAT_VEC4		||
    287 			query == QUERY_SAMPLER_PARAM_INTEGER		||
    288 			query == QUERY_SAMPLER_PARAM_FLOAT			||
    289 			query == QUERY_SAMPLER_PARAM_INTEGER_VEC4	||
    290 			query == QUERY_SAMPLER_PARAM_FLOAT_VEC4;
    291 }
    292 
    293 static RequiredExtensions getQueryExtension (QueryType query)
    294 {
    295 	DE_UNREF(query);
    296 	DE_ASSERT(false);
    297 	return RequiredExtensions();
    298 }
    299 
    300 static bool isCoreTester (TesterType tester)
    301 {
    302 	return	tester == TESTER_TEXTURE_SWIZZLE_R			||
    303 			tester == TESTER_TEXTURE_SWIZZLE_G			||
    304 			tester == TESTER_TEXTURE_SWIZZLE_B			||
    305 			tester == TESTER_TEXTURE_SWIZZLE_A			||
    306 			tester == TESTER_TEXTURE_WRAP_S				||
    307 			tester == TESTER_TEXTURE_WRAP_T				||
    308 			tester == TESTER_TEXTURE_WRAP_R				||
    309 			tester == TESTER_TEXTURE_MAG_FILTER			||
    310 			tester == TESTER_TEXTURE_MIN_FILTER			||
    311 			tester == TESTER_TEXTURE_MIN_LOD			||
    312 			tester == TESTER_TEXTURE_MAX_LOD			||
    313 			tester == TESTER_TEXTURE_BASE_LEVEL			||
    314 			tester == TESTER_TEXTURE_MAX_LEVEL			||
    315 			tester == TESTER_TEXTURE_COMPARE_MODE		||
    316 			tester == TESTER_TEXTURE_COMPARE_FUNC		||
    317 			tester == TESTER_TEXTURE_IMMUTABLE_LEVELS	||
    318 			tester == TESTER_TEXTURE_IMMUTABLE_FORMAT;
    319 }
    320 
    321 static RequiredExtensions getTesterExtension (TesterType tester)
    322 {
    323 	DE_UNREF(tester);
    324 	DE_ASSERT(false);
    325 	return RequiredExtensions();
    326 }
    327 
    328 } // es30
    329 
    330 namespace es31
    331 {
    332 
    333 static bool isCoreTextureTarget (glw::GLenum target)
    334 {
    335 	return	es30::isCoreTextureTarget(target) ||
    336 			target == GL_TEXTURE_2D_MULTISAMPLE;
    337 }
    338 
    339 static RequiredExtensions getTextureTargetExtension (glw::GLenum target)
    340 {
    341 	switch (target)
    342 	{
    343 		case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:	return RequiredExtensions("GL_OES_texture_storage_multisample_2d_array");
    344 		case GL_TEXTURE_BUFFER:					return RequiredExtensions("GL_EXT_texture_buffer");
    345 		case GL_TEXTURE_CUBE_MAP_ARRAY:			return RequiredExtensions("GL_EXT_texture_cube_map_array");
    346 		default:
    347 			DE_ASSERT(false);
    348 			return RequiredExtensions();
    349 	}
    350 }
    351 
    352 static bool isCoreTextureParam (glw::GLenum pname)
    353 {
    354 	return	es30::isCoreTextureParam(pname) ||
    355 			pname == GL_DEPTH_STENCIL_TEXTURE_MODE;
    356 }
    357 
    358 static RequiredExtensions getTextureParamExtension (glw::GLenum pname)
    359 {
    360 	switch (pname)
    361 	{
    362 		case GL_TEXTURE_SRGB_DECODE_EXT:	return RequiredExtensions("GL_EXT_texture_sRGB_decode");
    363 		case GL_TEXTURE_BORDER_COLOR:		return RequiredExtensions("GL_EXT_texture_border_clamp");
    364 		default:
    365 			DE_ASSERT(false);
    366 			return RequiredExtensions();
    367 	}
    368 }
    369 
    370 static bool isCoreQuery (QueryType query)
    371 {
    372 	return es30::isCoreQuery(query);
    373 }
    374 
    375 static RequiredExtensions getQueryExtension (QueryType query)
    376 {
    377 	switch (query)
    378 	{
    379 		case QUERY_TEXTURE_PARAM_PURE_INTEGER:
    380 		case QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER:
    381 		case QUERY_TEXTURE_PARAM_PURE_INTEGER_VEC4:
    382 		case QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER_VEC4:
    383 		case QUERY_SAMPLER_PARAM_PURE_INTEGER:
    384 		case QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER:
    385 		case QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4:
    386 		case QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4:
    387 			return RequiredExtensions("GL_EXT_texture_border_clamp");
    388 
    389 		default:
    390 			DE_ASSERT(false);
    391 			return RequiredExtensions();
    392 	}
    393 }
    394 
    395 static bool isCoreTester (TesterType tester)
    396 {
    397 	return	es30::isCoreTester(tester)							||
    398 			tester == TESTER_DEPTH_STENCIL_TEXTURE_MODE;
    399 }
    400 
    401 static RequiredExtensions getTesterExtension (TesterType tester)
    402 {
    403 #define CASE_PURE_SETTERS(X) case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
    404 
    405 	switch (tester)
    406 	{
    407 		CASE_PURE_SETTERS(TESTER_TEXTURE_SWIZZLE_R):
    408 		CASE_PURE_SETTERS(TESTER_TEXTURE_SWIZZLE_G):
    409 		CASE_PURE_SETTERS(TESTER_TEXTURE_SWIZZLE_B):
    410 		CASE_PURE_SETTERS(TESTER_TEXTURE_SWIZZLE_A):
    411 		CASE_PURE_SETTERS(TESTER_TEXTURE_WRAP_S):
    412 		CASE_PURE_SETTERS(TESTER_TEXTURE_WRAP_T):
    413 		CASE_PURE_SETTERS(TESTER_TEXTURE_WRAP_R):
    414 		CASE_PURE_SETTERS(TESTER_TEXTURE_MAG_FILTER):
    415 		CASE_PURE_SETTERS(TESTER_TEXTURE_MIN_FILTER):
    416 		CASE_PURE_SETTERS(TESTER_TEXTURE_MIN_LOD):
    417 		CASE_PURE_SETTERS(TESTER_TEXTURE_MAX_LOD):
    418 		CASE_PURE_SETTERS(TESTER_TEXTURE_BASE_LEVEL):
    419 		CASE_PURE_SETTERS(TESTER_TEXTURE_MAX_LEVEL):
    420 		CASE_PURE_SETTERS(TESTER_TEXTURE_COMPARE_MODE):
    421 		CASE_PURE_SETTERS(TESTER_TEXTURE_COMPARE_FUNC):
    422 		CASE_PURE_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE):
    423 		case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
    424 		case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
    425 		case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
    426 		case TESTER_TEXTURE_BORDER_COLOR:
    427 			return RequiredExtensions("GL_EXT_texture_border_clamp");
    428 
    429 		case TESTER_TEXTURE_SRGB_DECODE_EXT:
    430 			return RequiredExtensions("GL_EXT_texture_sRGB_decode");
    431 
    432 		CASE_PURE_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT):
    433 			return RequiredExtensions("GL_EXT_texture_sRGB_decode", "GL_EXT_texture_border_clamp");
    434 
    435 		default:
    436 			DE_ASSERT(false);
    437 			return RequiredExtensions();
    438 	}
    439 
    440 #undef CASE_PURE_SETTERS
    441 }
    442 
    443 } // es31
    444 
    445 namespace es32
    446 {
    447 
    448 static bool isCoreTextureTarget (glw::GLenum target)
    449 {
    450 	return	es31::isCoreTextureTarget(target)			||
    451 			target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY	||
    452 			target == GL_TEXTURE_BUFFER					||
    453 			target == GL_TEXTURE_CUBE_MAP_ARRAY;
    454 }
    455 
    456 static RequiredExtensions getTextureTargetExtension (glw::GLenum target)
    457 {
    458 	DE_UNREF(target);
    459 	DE_ASSERT(false);
    460 	return RequiredExtensions();
    461 }
    462 
    463 static bool isCoreTextureParam (glw::GLenum pname)
    464 {
    465 	return	es31::isCoreTextureParam(pname)		||
    466 			pname == GL_TEXTURE_BORDER_COLOR;
    467 }
    468 
    469 static RequiredExtensions getTextureParamExtension (glw::GLenum pname)
    470 {
    471 	switch (pname)
    472 	{
    473 		case GL_TEXTURE_SRGB_DECODE_EXT:	return RequiredExtensions("GL_EXT_texture_sRGB_decode");
    474 		default:
    475 			DE_ASSERT(false);
    476 			return RequiredExtensions();
    477 	}
    478 }
    479 
    480 static bool isCoreQuery (QueryType query)
    481 {
    482 	return	es31::isCoreQuery(query)								||
    483 			query == QUERY_TEXTURE_PARAM_PURE_INTEGER				||
    484 			query == QUERY_TEXTURE_PARAM_PURE_INTEGER				||
    485 			query == QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER		||
    486 			query == QUERY_TEXTURE_PARAM_PURE_INTEGER_VEC4			||
    487 			query == QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER_VEC4	||
    488 			query == QUERY_SAMPLER_PARAM_PURE_INTEGER				||
    489 			query == QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER		||
    490 			query == QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4			||
    491 			query == QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4;
    492 }
    493 
    494 static RequiredExtensions getQueryExtension (QueryType query)
    495 {
    496 	DE_UNREF(query);
    497 	DE_ASSERT(false);
    498 	return RequiredExtensions();
    499 }
    500 
    501 static bool isCoreTester (TesterType tester)
    502 {
    503 #define COMPARE_PURE_SETTERS(TESTER, X) ((TESTER) == X ## _SET_PURE_INT) || ((TESTER) == X ## _SET_PURE_UINT)
    504 
    505 	return	es31::isCoreTester(tester)										||
    506 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_SWIZZLE_R)			||
    507 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_SWIZZLE_G)			||
    508 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_SWIZZLE_B)			||
    509 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_SWIZZLE_A)			||
    510 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_WRAP_S)				||
    511 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_WRAP_T)				||
    512 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_WRAP_R)				||
    513 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MAG_FILTER)			||
    514 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MIN_FILTER)			||
    515 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MIN_LOD)			||
    516 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MAX_LOD)			||
    517 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_BASE_LEVEL)			||
    518 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_MAX_LEVEL)			||
    519 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_COMPARE_MODE)		||
    520 			COMPARE_PURE_SETTERS(tester, TESTER_TEXTURE_COMPARE_FUNC)		||
    521 			COMPARE_PURE_SETTERS(tester, TESTER_DEPTH_STENCIL_TEXTURE_MODE)	||
    522 			tester == TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER					||
    523 			tester == TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER					||
    524 			tester == TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER					||
    525 			tester == TESTER_TEXTURE_BORDER_COLOR;
    526 
    527 #undef COMPARE_PURE_SETTERS
    528 }
    529 
    530 static RequiredExtensions getTesterExtension (TesterType tester)
    531 {
    532 #define CASE_PURE_SETTERS(X) case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
    533 
    534 	switch (tester)
    535 	{
    536 		CASE_PURE_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT):
    537 		case TESTER_TEXTURE_SRGB_DECODE_EXT:
    538 			return RequiredExtensions("GL_EXT_texture_sRGB_decode");
    539 
    540 		default:
    541 			DE_ASSERT(false);
    542 			return RequiredExtensions();
    543 	}
    544 
    545 #undef CASE_PURE_SETTERS
    546 }
    547 
    548 } // es32
    549 
    550 static bool isCoreTextureTarget (const glu::ContextType& contextType, glw::GLenum target)
    551 {
    552 	if (contextSupports(contextType, glu::ApiType::es(3,2)))
    553 		return es32::isCoreTextureTarget(target);
    554 	else if (contextSupports(contextType, glu::ApiType::es(3,1)))
    555 		return es31::isCoreTextureTarget(target);
    556 	else if (contextSupports(contextType, glu::ApiType::es(3,0)))
    557 		return es30::isCoreTextureTarget(target);
    558 	else
    559 	{
    560 		DE_ASSERT(false);
    561 		return DE_NULL;
    562 	}
    563 }
    564 
    565 static bool isCoreTextureParam (const glu::ContextType& contextType, glw::GLenum pname)
    566 {
    567 	if (contextSupports(contextType, glu::ApiType::es(3,2)))
    568 		return es32::isCoreTextureParam(pname);
    569 	else if (contextSupports(contextType, glu::ApiType::es(3,1)))
    570 		return es31::isCoreTextureParam(pname);
    571 	else if (contextSupports(contextType, glu::ApiType::es(3,0)))
    572 		return es30::isCoreTextureParam(pname);
    573 	else
    574 	{
    575 		DE_ASSERT(false);
    576 		return DE_NULL;
    577 	}
    578 }
    579 
    580 static bool isCoreQuery (const glu::ContextType& contextType, QueryType query)
    581 {
    582 	if (contextSupports(contextType, glu::ApiType::es(3,2)))
    583 		return es32::isCoreQuery(query);
    584 	else if (contextSupports(contextType, glu::ApiType::es(3,1)))
    585 		return es31::isCoreQuery(query);
    586 	else if (contextSupports(contextType, glu::ApiType::es(3,0)))
    587 		return es30::isCoreQuery(query);
    588 	else
    589 	{
    590 		DE_ASSERT(false);
    591 		return DE_NULL;
    592 	}
    593 }
    594 
    595 static bool isCoreTester (const glu::ContextType& contextType, TesterType tester)
    596 {
    597 	if (contextSupports(contextType, glu::ApiType::es(3,2)))
    598 		return es32::isCoreTester(tester);
    599 	else if (contextSupports(contextType, glu::ApiType::es(3,1)))
    600 		return es31::isCoreTester(tester);
    601 	else if (contextSupports(contextType, glu::ApiType::es(3,0)))
    602 		return es30::isCoreTester(tester);
    603 	else
    604 	{
    605 		DE_ASSERT(false);
    606 		return DE_NULL;
    607 	}
    608 }
    609 
    610 static RequiredExtensions getTextureTargetExtension (const glu::ContextType& contextType, glw::GLenum target)
    611 {
    612 	DE_ASSERT(!isCoreTextureTarget(contextType, target));
    613 
    614 	if (contextSupports(contextType, glu::ApiType::es(3,2)))
    615 		return es32::getTextureTargetExtension(target);
    616 	if (contextSupports(contextType, glu::ApiType::es(3,1)))
    617 		return es31::getTextureTargetExtension(target);
    618 	else if (contextSupports(contextType, glu::ApiType::es(3,0)))
    619 		return es30::getTextureTargetExtension(target);
    620 	else
    621 	{
    622 		DE_ASSERT(false);
    623 		return RequiredExtensions();
    624 	}
    625 }
    626 
    627 static RequiredExtensions getTextureParamExtension (const glu::ContextType& contextType, glw::GLenum pname)
    628 {
    629 	DE_ASSERT(!isCoreTextureParam(contextType, pname));
    630 
    631 	if (contextSupports(contextType, glu::ApiType::es(3,2)))
    632 		return es32::getTextureParamExtension(pname);
    633 	else if (contextSupports(contextType, glu::ApiType::es(3,1)))
    634 		return es31::getTextureParamExtension(pname);
    635 	else if (contextSupports(contextType, glu::ApiType::es(3,0)))
    636 		return es30::getTextureParamExtension(pname);
    637 	else
    638 	{
    639 		DE_ASSERT(false);
    640 		return RequiredExtensions();
    641 	}
    642 }
    643 
    644 static RequiredExtensions getQueryExtension (const glu::ContextType& contextType, QueryType query)
    645 {
    646 	DE_ASSERT(!isCoreQuery(contextType, query));
    647 
    648 	if (contextSupports(contextType, glu::ApiType::es(3,2)))
    649 		return es32::getQueryExtension(query);
    650 	else if (contextSupports(contextType, glu::ApiType::es(3,1)))
    651 		return es31::getQueryExtension(query);
    652 	else if (contextSupports(contextType, glu::ApiType::es(3,0)))
    653 		return es30::getQueryExtension(query);
    654 	else
    655 	{
    656 		DE_ASSERT(false);
    657 		return RequiredExtensions();
    658 	}
    659 }
    660 
    661 static RequiredExtensions getTesterExtension (const glu::ContextType& contextType, TesterType tester)
    662 {
    663 	DE_ASSERT(!isCoreTester(contextType, tester));
    664 
    665 	if (contextSupports(contextType, glu::ApiType::es(3,2)))
    666 		return es32::getTesterExtension(tester);
    667 	else if (contextSupports(contextType, glu::ApiType::es(3,1)))
    668 		return es31::getTesterExtension(tester);
    669 	else if (contextSupports(contextType, glu::ApiType::es(3,0)))
    670 		return es30::getTesterExtension(tester);
    671 	else
    672 	{
    673 		DE_ASSERT(false);
    674 		return RequiredExtensions();
    675 	}
    676 }
    677 
    678 class TextureTest : public tcu::TestCase
    679 {
    680 public:
    681 						TextureTest	(tcu::TestContext&			testCtx,
    682 									 const glu::RenderContext&	renderCtx,
    683 									 const char*				name,
    684 									 const char*				desc,
    685 									 glw::GLenum				target,
    686 									 TesterType					tester,
    687 									 QueryType					type);
    688 
    689 	void				init		(void);
    690 	IterateResult		iterate		(void);
    691 
    692 	virtual void		test		(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const = 0;
    693 
    694 protected:
    695 	const glu::RenderContext&	m_renderCtx;
    696 	const glw::GLenum			m_target;
    697 	const glw::GLenum			m_pname;
    698 	const TesterType			m_tester;
    699 	const QueryType				m_type;
    700 };
    701 
    702 TextureTest::TextureTest (tcu::TestContext&			testCtx,
    703 						  const glu::RenderContext&	renderCtx,
    704 						  const char*				name,
    705 						  const char*				desc,
    706 						  glw::GLenum				target,
    707 						  TesterType				tester,
    708 						  QueryType					type)
    709 	: TestCase		(testCtx, name, desc)
    710 	, m_renderCtx	(renderCtx)
    711 	, m_target		(target)
    712 	, m_pname		(mapTesterToPname(tester))
    713 	, m_tester		(tester)
    714 	, m_type		(type)
    715 {
    716 }
    717 
    718 void TextureTest::init (void)
    719 {
    720 	const de::UniquePtr<glu::ContextInfo>	ctxInfo		(glu::ContextInfo::create(m_renderCtx));
    721 	RequiredExtensions						extensions;
    722 
    723 	// target
    724 	if (!isCoreTextureTarget(m_renderCtx.getType(), m_target))
    725 		extensions.add(getTextureTargetExtension(m_renderCtx.getType(), m_target));
    726 
    727 	// param
    728 	if (!isCoreTextureParam(m_renderCtx.getType(), m_pname))
    729 		extensions.add(getTextureParamExtension(m_renderCtx.getType(), m_pname));
    730 
    731 	// query
    732 	if (!isCoreQuery(m_renderCtx.getType(), m_type))
    733 		extensions.add(getQueryExtension(m_renderCtx.getType(), m_type));
    734 
    735 	// test type
    736 	if (!isCoreTester(m_renderCtx.getType(), m_tester))
    737 		extensions.add(getTesterExtension(m_renderCtx.getType(), m_tester));
    738 
    739 	extensions.check(*ctxInfo);
    740 }
    741 
    742 TextureTest::IterateResult TextureTest::iterate (void)
    743 {
    744 	glu::CallLogWrapper		gl		(m_renderCtx.getFunctions(), m_testCtx.getLog());
    745 	tcu::ResultCollector	result	(m_testCtx.getLog(), " // ERROR: ");
    746 
    747 	gl.enableLogging(true);
    748 	test(gl, result);
    749 
    750 	result.setTestContextResult(m_testCtx);
    751 	return STOP;
    752 }
    753 
    754 class IsTextureCase : public tcu::TestCase
    755 {
    756 public:
    757 								IsTextureCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target);
    758 
    759 	void						init			(void);
    760 	IterateResult				iterate			(void);
    761 
    762 protected:
    763 	const glu::RenderContext&	m_renderCtx;
    764 	const glw::GLenum			m_target;
    765 };
    766 
    767 IsTextureCase::IsTextureCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target)
    768 	: tcu::TestCase	(testCtx, name, desc)
    769 	, m_renderCtx	(renderCtx)
    770 	, m_target		(target)
    771 {
    772 }
    773 
    774 void IsTextureCase::init (void)
    775 {
    776 	const de::UniquePtr<glu::ContextInfo>	ctxInfo		(glu::ContextInfo::create(m_renderCtx));
    777 	RequiredExtensions						extensions;
    778 
    779 	// target
    780 	if (!isCoreTextureTarget(m_renderCtx.getType(), m_target))
    781 		extensions.add(getTextureTargetExtension(m_renderCtx.getType(), m_target));
    782 
    783 	extensions.check(*ctxInfo);
    784 }
    785 
    786 IsTextureCase::IterateResult IsTextureCase::iterate (void)
    787 {
    788 	glu::CallLogWrapper		gl			(m_renderCtx.getFunctions(), m_testCtx.getLog());
    789 	tcu::ResultCollector	result		(m_testCtx.getLog(), " // ERROR: ");
    790 	glw::GLuint				textureId	= 0;
    791 
    792 	gl.enableLogging(true);
    793 
    794 	gl.glGenTextures(1, &textureId);
    795 	gl.glBindTexture(m_target, textureId);
    796 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
    797 
    798 	verifyStateObjectBoolean(result, gl, textureId, true, QUERY_ISTEXTURE);
    799 
    800 	gl.glDeleteTextures(1, &textureId);
    801 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
    802 
    803 	verifyStateObjectBoolean(result, gl, textureId, false, QUERY_ISTEXTURE);
    804 
    805 	result.setTestContextResult(m_testCtx);
    806 	return STOP;
    807 }
    808 
    809 class DepthStencilModeCase : public TextureTest
    810 {
    811 public:
    812 			DepthStencilModeCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
    813 	void	test					(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
    814 };
    815 
    816 DepthStencilModeCase::DepthStencilModeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
    817 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
    818 {
    819 }
    820 
    821 void DepthStencilModeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
    822 {
    823 	const bool		isPureCase	= isPureIntTester(m_tester) || isPureUintTester(m_tester);
    824 	glu::Texture	texture		(m_renderCtx);
    825 
    826 	gl.glBindTexture(m_target, *texture);
    827 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind");
    828 
    829 	if (!isPureCase)
    830 	{
    831 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
    832 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
    833 	}
    834 
    835 	if (!isPureCase)
    836 	{
    837 		const tcu::ScopedLogSection	section				(m_testCtx.getLog(), "Toggle", "Toggle");
    838 		const glw::GLint			depthComponentInt	= GL_DEPTH_COMPONENT;
    839 		const glw::GLfloat			depthComponentFloat	= (glw::GLfloat)GL_DEPTH_COMPONENT;
    840 
    841 		gl.glTexParameteri(m_target, m_pname, GL_STENCIL_INDEX);
    842 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
    843 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_STENCIL_INDEX, m_type);
    844 
    845 		gl.glTexParameteriv(m_target, m_pname, &depthComponentInt);
    846 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
    847 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
    848 
    849 		gl.glTexParameterf(m_target, m_pname, GL_STENCIL_INDEX);
    850 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
    851 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_STENCIL_INDEX, m_type);
    852 
    853 		gl.glTexParameterfv(m_target, m_pname, &depthComponentFloat);
    854 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
    855 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
    856 	}
    857 
    858 	if (isPureIntTester(m_tester))
    859 	{
    860 		const glw::GLint depthComponent	= GL_DEPTH_COMPONENT;
    861 		const glw::GLint stencilIndex	= GL_STENCIL_INDEX;
    862 
    863 		gl.glTexParameterIiv(m_target, m_pname, &stencilIndex);
    864 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
    865 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_STENCIL_INDEX, m_type);
    866 
    867 		gl.glTexParameterIiv(m_target, m_pname, &depthComponent);
    868 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
    869 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
    870 	}
    871 
    872 	if (isPureUintTester(m_tester))
    873 	{
    874 		const glw::GLuint depthComponent	= GL_DEPTH_COMPONENT;
    875 		const glw::GLuint stencilIndex	= GL_STENCIL_INDEX;
    876 
    877 		gl.glTexParameterIuiv(m_target, m_pname, &stencilIndex);
    878 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
    879 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_STENCIL_INDEX, m_type);
    880 
    881 		gl.glTexParameterIuiv(m_target, m_pname, &depthComponent);
    882 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
    883 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DEPTH_COMPONENT, m_type);
    884 	}
    885 }
    886 
    887 class TextureSRGBDecodeCase : public TextureTest
    888 {
    889 public:
    890 			TextureSRGBDecodeCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
    891 	void	test					(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
    892 };
    893 
    894 TextureSRGBDecodeCase::TextureSRGBDecodeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
    895 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
    896 {
    897 }
    898 
    899 void TextureSRGBDecodeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
    900 {
    901 	const bool		isPureCase	= isPureIntTester(m_tester) || isPureUintTester(m_tester);
    902 	glu::Texture	texture		(m_renderCtx);
    903 
    904 	gl.glBindTexture(m_target, *texture);
    905 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind");
    906 
    907 	if (!isPureCase)
    908 	{
    909 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
    910 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
    911 	}
    912 
    913 	if (!isPureCase)
    914 	{
    915 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Toggle", "Toggle");
    916 		const glw::GLint			decodeInt		= GL_DECODE_EXT;
    917 		const glw::GLfloat			decodeFloat		= (glw::GLfloat)GL_DECODE_EXT;
    918 
    919 		gl.glTexParameteri(m_target, m_pname, GL_SKIP_DECODE_EXT);
    920 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
    921 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
    922 
    923 		gl.glTexParameteriv(m_target, m_pname, &decodeInt);
    924 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
    925 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
    926 
    927 		gl.glTexParameterf(m_target, m_pname, GL_SKIP_DECODE_EXT);
    928 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
    929 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
    930 
    931 		gl.glTexParameterfv(m_target, m_pname, &decodeFloat);
    932 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
    933 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
    934 	}
    935 
    936 	if (isPureIntTester(m_tester))
    937 	{
    938 		const glw::GLint skipDecode	= GL_SKIP_DECODE_EXT;
    939 		const glw::GLint decode		= GL_DECODE_EXT;
    940 
    941 		gl.glTexParameterIiv(m_target, m_pname, &skipDecode);
    942 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
    943 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
    944 
    945 		gl.glTexParameterIiv(m_target, m_pname, &decode);
    946 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
    947 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
    948 	}
    949 
    950 	if (isPureUintTester(m_tester))
    951 	{
    952 		const glw::GLuint skipDecode	= GL_SKIP_DECODE_EXT;
    953 		const glw::GLuint decode		= GL_DECODE_EXT;
    954 
    955 		gl.glTexParameterIuiv(m_target, m_pname, &skipDecode);
    956 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
    957 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
    958 
    959 		gl.glTexParameterIuiv(m_target, m_pname, &decode);
    960 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
    961 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
    962 	}
    963 }
    964 
    965 class TextureSwizzleCase : public TextureTest
    966 {
    967 public:
    968 			TextureSwizzleCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
    969 	void	test				(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
    970 };
    971 
    972 TextureSwizzleCase::TextureSwizzleCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
    973 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
    974 {
    975 }
    976 
    977 void TextureSwizzleCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
    978 {
    979 	const bool	isPureCase		= isPureIntTester(m_tester) || isPureUintTester(m_tester);
    980 	const int	initialValue	= (m_pname == GL_TEXTURE_SWIZZLE_R) ? (GL_RED) :
    981 								  (m_pname == GL_TEXTURE_SWIZZLE_G) ? (GL_GREEN) :
    982 								  (m_pname == GL_TEXTURE_SWIZZLE_B) ? (GL_BLUE) :
    983 								  (m_pname == GL_TEXTURE_SWIZZLE_A) ? (GL_ALPHA) :
    984 								  (-1);
    985 
    986 	if (!isPureCase)
    987 	{
    988 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
    989 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, initialValue, m_type);
    990 	}
    991 
    992 	{
    993 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
    994 		const GLenum				swizzleValues[]	= {GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_ZERO, GL_ONE};
    995 
    996 		if (isPureCase)
    997 		{
    998 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(swizzleValues); ++ndx)
    999 			{
   1000 				if (isPureIntTester(m_tester))
   1001 				{
   1002 					const glw::GLint value = (glw::GLint)swizzleValues[ndx];
   1003 					gl.glTexParameterIiv(m_target, m_pname, &value);
   1004 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
   1005 				}
   1006 				else
   1007 				{
   1008 					DE_ASSERT(isPureUintTester(m_tester));
   1009 
   1010 					const glw::GLuint value = swizzleValues[ndx];
   1011 					gl.glTexParameterIuiv(m_target, m_pname, &value);
   1012 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
   1013 				}
   1014 
   1015 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, swizzleValues[ndx], m_type);
   1016 			}
   1017 		}
   1018 		else
   1019 		{
   1020 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(swizzleValues); ++ndx)
   1021 			{
   1022 				gl.glTexParameteri(m_target, m_pname, swizzleValues[ndx]);
   1023 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1024 
   1025 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, swizzleValues[ndx], m_type);
   1026 			}
   1027 
   1028 			//check unit conversions with float
   1029 
   1030 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(swizzleValues); ++ndx)
   1031 			{
   1032 				gl.glTexParameterf(m_target, m_pname, (GLfloat)swizzleValues[ndx]);
   1033 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
   1034 
   1035 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, swizzleValues[ndx], m_type);
   1036 			}
   1037 		}
   1038 	}
   1039 }
   1040 
   1041 class TextureWrapCase : public TextureTest
   1042 {
   1043 public:
   1044 			TextureWrapCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
   1045 	void	test			(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1046 };
   1047 
   1048 TextureWrapCase::TextureWrapCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
   1049 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
   1050 {
   1051 }
   1052 
   1053 void TextureWrapCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1054 {
   1055 	const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
   1056 
   1057 	if (!isPureCase)
   1058 	{
   1059 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1060 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_REPEAT, m_type);
   1061 	}
   1062 
   1063 	{
   1064 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   1065 		const GLenum				wrapValues[]	= {GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT};
   1066 
   1067 		if (isPureCase)
   1068 		{
   1069 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
   1070 			{
   1071 				if (isPureIntTester(m_tester))
   1072 				{
   1073 					const glw::GLint value = (glw::GLint)wrapValues[ndx];
   1074 					gl.glTexParameterIiv(m_target, m_pname, &value);
   1075 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
   1076 				}
   1077 				else
   1078 				{
   1079 					DE_ASSERT(isPureUintTester(m_tester));
   1080 
   1081 					const glw::GLuint value = wrapValues[ndx];
   1082 					gl.glTexParameterIuiv(m_target, m_pname, &value);
   1083 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
   1084 				}
   1085 
   1086 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
   1087 			}
   1088 		}
   1089 		else
   1090 		{
   1091 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
   1092 			{
   1093 				gl.glTexParameteri(m_target, m_pname, wrapValues[ndx]);
   1094 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1095 
   1096 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
   1097 			}
   1098 
   1099 			//check unit conversions with float
   1100 
   1101 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
   1102 			{
   1103 				gl.glTexParameterf(m_target, m_pname, (GLfloat)wrapValues[ndx]);
   1104 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
   1105 
   1106 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
   1107 			}
   1108 		}
   1109 	}
   1110 }
   1111 
   1112 class TextureFilterCase : public TextureTest
   1113 {
   1114 public:
   1115 			TextureFilterCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
   1116 	void	test				(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1117 };
   1118 
   1119 TextureFilterCase::TextureFilterCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
   1120 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
   1121 {
   1122 }
   1123 
   1124 void TextureFilterCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1125 {
   1126 	const bool			isPureCase	= isPureIntTester(m_tester) || isPureUintTester(m_tester);
   1127 	const glw::GLenum	initial		= (m_pname == GL_TEXTURE_MAG_FILTER) ? (GL_LINEAR)
   1128 									: (m_pname == GL_TEXTURE_MIN_FILTER) ? (GL_NEAREST_MIPMAP_LINEAR)
   1129 									: (0);
   1130 
   1131 	if (!isPureCase)
   1132 	{
   1133 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1134 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, initial, m_type);
   1135 	}
   1136 
   1137 	{
   1138 		const tcu::ScopedLogSection	section		(m_testCtx.getLog(), "Set", "Set");
   1139 		std::vector<GLenum>			values;
   1140 
   1141 		values.push_back(GL_NEAREST);
   1142 		values.push_back(GL_LINEAR);
   1143 		if (m_pname == GL_TEXTURE_MIN_FILTER)
   1144 		{
   1145 			values.push_back(GL_NEAREST_MIPMAP_NEAREST);
   1146 			values.push_back(GL_NEAREST_MIPMAP_LINEAR);
   1147 			values.push_back(GL_LINEAR_MIPMAP_NEAREST);
   1148 			values.push_back(GL_LINEAR_MIPMAP_LINEAR);
   1149 		}
   1150 
   1151 		if (isPureCase)
   1152 		{
   1153 			for (int ndx = 0; ndx < (int)values.size(); ++ndx)
   1154 			{
   1155 				if (isPureIntTester(m_tester))
   1156 				{
   1157 					const glw::GLint value = (glw::GLint)values[ndx];
   1158 					gl.glTexParameterIiv(m_target, m_pname, &value);
   1159 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
   1160 				}
   1161 				else
   1162 				{
   1163 					DE_ASSERT(isPureUintTester(m_tester));
   1164 
   1165 					const glw::GLuint value = values[ndx];
   1166 					gl.glTexParameterIuiv(m_target, m_pname, &value);
   1167 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
   1168 				}
   1169 
   1170 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
   1171 			}
   1172 		}
   1173 		else
   1174 		{
   1175 			for (int ndx = 0; ndx < (int)values.size(); ++ndx)
   1176 			{
   1177 				gl.glTexParameteri(m_target, m_pname, values[ndx]);
   1178 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1179 
   1180 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
   1181 			}
   1182 
   1183 			//check unit conversions with float
   1184 
   1185 			for (int ndx = 0; ndx < (int)values.size(); ++ndx)
   1186 			{
   1187 				gl.glTexParameterf(m_target, m_pname, (GLfloat)values[ndx]);
   1188 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
   1189 
   1190 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
   1191 			}
   1192 		}
   1193 	}
   1194 }
   1195 
   1196 class TextureLODCase : public TextureTest
   1197 {
   1198 public:
   1199 			TextureLODCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
   1200 	void	test			(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1201 };
   1202 
   1203 TextureLODCase::TextureLODCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
   1204 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
   1205 {
   1206 }
   1207 
   1208 void TextureLODCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1209 {
   1210 	const bool	isPureCase		= isPureIntTester(m_tester) || isPureUintTester(m_tester);
   1211 	const int	initialValue	= (m_pname == GL_TEXTURE_MIN_LOD) ? (-1000)
   1212 								: (m_pname == GL_TEXTURE_MAX_LOD) ? (1000)
   1213 								: (-1);
   1214 
   1215 	if ((querySupportsSigned(m_type) || initialValue >= 0) && !isPureCase)
   1216 	{
   1217 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1218 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, initialValue, m_type);
   1219 	}
   1220 
   1221 	{
   1222 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   1223 		const int					numIterations	= 20;
   1224 		de::Random					rnd				(0xabcdef);
   1225 
   1226 		if (isPureCase)
   1227 		{
   1228 			if (isPureIntTester(m_tester))
   1229 			{
   1230 				for (int ndx = 0; ndx < numIterations; ++ndx)
   1231 				{
   1232 					const GLint ref = rnd.getInt(-1000, 1000);
   1233 
   1234 					gl.glTexParameterIiv(m_target, m_pname, &ref);
   1235 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
   1236 
   1237 					verifyStateTextureParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
   1238 				}
   1239 			}
   1240 			else
   1241 			{
   1242 				DE_ASSERT(isPureUintTester(m_tester));
   1243 
   1244 				for (int ndx = 0; ndx < numIterations; ++ndx)
   1245 				{
   1246 					const GLuint ref = (glw::GLuint)rnd.getInt(0, 1000);
   1247 
   1248 					gl.glTexParameterIuiv(m_target, m_pname, &ref);
   1249 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
   1250 
   1251 					verifyStateTextureParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
   1252 				}
   1253 			}
   1254 		}
   1255 		else
   1256 		{
   1257 			const int minLimit = (querySupportsSigned(m_type)) ? (-1000) : (0);
   1258 
   1259 			for (int ndx = 0; ndx < numIterations; ++ndx)
   1260 			{
   1261 				const GLfloat ref = rnd.getFloat((float)minLimit, 1000.f);
   1262 
   1263 				gl.glTexParameterf(m_target, m_pname, ref);
   1264 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
   1265 
   1266 				verifyStateTextureParamFloat(result, gl, m_target, m_pname, ref, m_type);
   1267 			}
   1268 
   1269 			// check unit conversions with int
   1270 
   1271 			for (int ndx = 0; ndx < numIterations; ++ndx)
   1272 			{
   1273 				const GLint ref = rnd.getInt(minLimit, 1000);
   1274 
   1275 				gl.glTexParameteri(m_target, m_pname, ref);
   1276 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1277 
   1278 				verifyStateTextureParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
   1279 			}
   1280 		}
   1281 	}
   1282 }
   1283 
   1284 class TextureLevelCase : public TextureTest
   1285 {
   1286 public:
   1287 			TextureLevelCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
   1288 	void	test				(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1289 };
   1290 
   1291 TextureLevelCase::TextureLevelCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
   1292 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
   1293 {
   1294 }
   1295 
   1296 void TextureLevelCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1297 {
   1298 	const bool	isPureCase		= isPureIntTester(m_tester) || isPureUintTester(m_tester);
   1299 	const int	initialValue	= (m_pname == GL_TEXTURE_BASE_LEVEL) ? (0)
   1300 								: (m_pname == GL_TEXTURE_MAX_LEVEL)	? (1000)
   1301 								: (-1);
   1302 
   1303 	if (!isPureCase)
   1304 	{
   1305 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1306 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, initialValue, m_type);
   1307 	}
   1308 
   1309 	if (m_target == GL_TEXTURE_2D_MULTISAMPLE		||
   1310 		m_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
   1311 	{
   1312 		// only 0 allowed
   1313 		{
   1314 			const tcu::ScopedLogSection section(m_testCtx.getLog(), "Set", "Set");
   1315 
   1316 			gl.glTexParameteri(m_target, m_pname, 0);
   1317 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1318 			verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
   1319 
   1320 			gl.glTexParameterf(m_target, m_pname, 0.0f);
   1321 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
   1322 			verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
   1323 		}
   1324 	}
   1325 	else
   1326 	{
   1327 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   1328 		const int					numIterations	= 20;
   1329 		de::Random					rnd				(0xabcdef);
   1330 
   1331 		if (isPureCase)
   1332 		{
   1333 			for (int ndx = 0; ndx < numIterations; ++ndx)
   1334 			{
   1335 				const GLint		ref		= rnd.getInt(0, 64000);
   1336 				const GLuint	uRef	= (glw::GLuint)ref;
   1337 
   1338 				if (isPureIntTester(m_tester))
   1339 				{
   1340 					gl.glTexParameterIiv(m_target, m_pname, &ref);
   1341 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
   1342 				}
   1343 				else
   1344 				{
   1345 					DE_ASSERT(isPureUintTester(m_tester));
   1346 					gl.glTexParameterIuiv(m_target, m_pname, &uRef);
   1347 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
   1348 				}
   1349 
   1350 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, ref, m_type);
   1351 			}
   1352 		}
   1353 		else
   1354 		{
   1355 			for (int ndx = 0; ndx < numIterations; ++ndx)
   1356 			{
   1357 				const GLint ref = rnd.getInt(0, 64000);
   1358 
   1359 				gl.glTexParameteri(m_target, m_pname, ref);
   1360 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1361 
   1362 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, ref, m_type);
   1363 			}
   1364 
   1365 			// check unit conversions with float
   1366 
   1367 			const float nonSignificantOffsets[] = {-0.45f, -0.25f, 0, 0.45f}; // offsets O so that for any integers z in Z, o in O roundToClosestInt(z+o)==z
   1368 
   1369 			const int numConversionIterations = 30;
   1370 			for (int ndx = 0; ndx < numConversionIterations; ++ndx)
   1371 			{
   1372 				const GLint ref = rnd.getInt(1, 64000);
   1373 
   1374 				for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(nonSignificantOffsets); ++offsetNdx)
   1375 				{
   1376 					gl.glTexParameterf(m_target, m_pname, ((GLfloat)ref) + nonSignificantOffsets[offsetNdx]);
   1377 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
   1378 
   1379 					verifyStateTextureParamInteger(result, gl, m_target, m_pname, ref, m_type);
   1380 				}
   1381 			}
   1382 		}
   1383 	}
   1384 }
   1385 
   1386 class TextureCompareModeCase : public TextureTest
   1387 {
   1388 public:
   1389 			TextureCompareModeCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
   1390 	void	test					(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1391 };
   1392 
   1393 TextureCompareModeCase::TextureCompareModeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
   1394 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
   1395 {
   1396 }
   1397 
   1398 void TextureCompareModeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1399 {
   1400 	const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
   1401 
   1402 	if (!isPureCase)
   1403 	{
   1404 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1405 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_NONE, m_type);
   1406 	}
   1407 
   1408 	{
   1409 		const tcu::ScopedLogSection	section		(m_testCtx.getLog(), "Set", "Set");
   1410 		const GLenum				modes[]		= {GL_COMPARE_REF_TO_TEXTURE, GL_NONE};
   1411 
   1412 		if (isPureCase)
   1413 		{
   1414 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
   1415 			{
   1416 				if (isPureIntTester(m_tester))
   1417 				{
   1418 					const glw::GLint value = (glw::GLint)modes[ndx];
   1419 					gl.glTexParameterIiv(m_target, m_pname, &value);
   1420 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
   1421 				}
   1422 				else
   1423 				{
   1424 					DE_ASSERT(isPureUintTester(m_tester));
   1425 
   1426 					const glw::GLuint value = modes[ndx];
   1427 					gl.glTexParameterIuiv(m_target, m_pname, &value);
   1428 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
   1429 				}
   1430 
   1431 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
   1432 			}
   1433 		}
   1434 		else
   1435 		{
   1436 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
   1437 			{
   1438 				gl.glTexParameteri(m_target, m_pname, modes[ndx]);
   1439 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1440 
   1441 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
   1442 			}
   1443 
   1444 			//check unit conversions with float
   1445 
   1446 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
   1447 			{
   1448 				gl.glTexParameterf(m_target, m_pname, (GLfloat)modes[ndx]);
   1449 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
   1450 
   1451 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
   1452 			}
   1453 		}
   1454 	}
   1455 }
   1456 
   1457 class TextureCompareFuncCase : public TextureTest
   1458 {
   1459 public:
   1460 			TextureCompareFuncCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
   1461 	void	test					(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1462 };
   1463 
   1464 TextureCompareFuncCase::TextureCompareFuncCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
   1465 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
   1466 {
   1467 }
   1468 
   1469 void TextureCompareFuncCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1470 {
   1471 	const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
   1472 
   1473 	if (!isPureCase)
   1474 	{
   1475 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1476 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_LEQUAL, m_type);
   1477 	}
   1478 
   1479 	{
   1480 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   1481 		const GLenum				compareFuncs[]	= {GL_LEQUAL, GL_GEQUAL, GL_LESS, GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_ALWAYS, GL_NEVER};
   1482 
   1483 		if (isPureCase)
   1484 		{
   1485 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
   1486 			{
   1487 				if (isPureIntTester(m_tester))
   1488 				{
   1489 					const glw::GLint value = (glw::GLint)compareFuncs[ndx];
   1490 					gl.glTexParameterIiv(m_target, m_pname, &value);
   1491 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
   1492 				}
   1493 				else
   1494 				{
   1495 					DE_ASSERT(isPureUintTester(m_tester));
   1496 
   1497 					const glw::GLuint value = compareFuncs[ndx];
   1498 					gl.glTexParameterIuiv(m_target, m_pname, &value);
   1499 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
   1500 				}
   1501 
   1502 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
   1503 			}
   1504 		}
   1505 		else
   1506 		{
   1507 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
   1508 			{
   1509 				gl.glTexParameteri(m_target, m_pname, compareFuncs[ndx]);
   1510 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1511 
   1512 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
   1513 			}
   1514 
   1515 			//check unit conversions with float
   1516 
   1517 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
   1518 			{
   1519 				gl.glTexParameterf(m_target, m_pname, (GLfloat)compareFuncs[ndx]);
   1520 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
   1521 
   1522 				verifyStateTextureParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
   1523 			}
   1524 		}
   1525 	}
   1526 }
   1527 
   1528 class TextureImmutableLevelsCase : public TextureTest
   1529 {
   1530 public:
   1531 			TextureImmutableLevelsCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, QueryType type);
   1532 	void	test						(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1533 };
   1534 
   1535 TextureImmutableLevelsCase::TextureImmutableLevelsCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, QueryType type)
   1536 	: TextureTest(testCtx, renderCtx, name, desc, target, TESTER_TEXTURE_IMMUTABLE_LEVELS, type)
   1537 {
   1538 }
   1539 
   1540 void TextureImmutableLevelsCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1541 {
   1542 	{
   1543 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1544 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
   1545 	}
   1546 
   1547 	if (m_target == GL_TEXTURE_2D_MULTISAMPLE		||
   1548 		m_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
   1549 	{
   1550 		// no levels
   1551 		const tcu::ScopedLogSection	section		(m_testCtx.getLog(), "Level", "Level");
   1552 		GLuint						textureID	= 0;
   1553 
   1554 		gl.glGenTextures(1, &textureID);
   1555 		gl.glBindTexture(m_target, textureID);
   1556 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
   1557 
   1558 		if (m_target == GL_TEXTURE_2D_MULTISAMPLE)
   1559 			gl.glTexStorage2DMultisample(m_target, 2, GL_RGB8, 64, 64, GL_FALSE);
   1560 		else if (m_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
   1561 			gl.glTexStorage3DMultisample(m_target, 2, GL_RGB8, 64, 64, 2, GL_FALSE);
   1562 		else
   1563 			DE_ASSERT(false);
   1564 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexStorage");
   1565 
   1566 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, 1, m_type);
   1567 
   1568 		gl.glDeleteTextures(1, &textureID);
   1569 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
   1570 	}
   1571 	else
   1572 	{
   1573 		for (int level = 1; level <= 7; ++level)
   1574 		{
   1575 			const tcu::ScopedLogSection	section		(m_testCtx.getLog(), "Levels", "Levels = " + de::toString(level));
   1576 			GLuint						textureID	= 0;
   1577 
   1578 			gl.glGenTextures(1, &textureID);
   1579 			gl.glBindTexture(m_target, textureID);
   1580 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
   1581 
   1582 			if (m_target == GL_TEXTURE_2D || m_target == GL_TEXTURE_CUBE_MAP)
   1583 				gl.glTexStorage2D(m_target, level, GL_RGB8, 64, 64);
   1584 			else if (m_target == GL_TEXTURE_2D_ARRAY || m_target == GL_TEXTURE_3D)
   1585 				gl.glTexStorage3D(m_target, level, GL_RGB8, 64, 64, 64);
   1586 			else if (m_target == GL_TEXTURE_CUBE_MAP_ARRAY)
   1587 				gl.glTexStorage3D(m_target, level, GL_RGB8, 64, 64, 6 * 2);
   1588 			else
   1589 				DE_ASSERT(false);
   1590 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexStorage");
   1591 
   1592 			verifyStateTextureParamInteger(result, gl, m_target, m_pname, level, m_type);
   1593 
   1594 			gl.glDeleteTextures(1, &textureID);
   1595 			GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
   1596 		}
   1597 	}
   1598 }
   1599 
   1600 class TextureImmutableFormatCase : public TextureTest
   1601 {
   1602 public:
   1603 			TextureImmutableFormatCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, QueryType type);
   1604 	void	test						(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1605 };
   1606 
   1607 TextureImmutableFormatCase::TextureImmutableFormatCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, QueryType type)
   1608 	: TextureTest(testCtx, renderCtx, name, desc, target, TESTER_TEXTURE_IMMUTABLE_FORMAT, type)
   1609 {
   1610 }
   1611 
   1612 void TextureImmutableFormatCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1613 {
   1614 	{
   1615 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1616 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
   1617 	}
   1618 
   1619 	{
   1620 		const tcu::ScopedLogSection	subsection	(m_testCtx.getLog(), "Immutable", "Immutable");
   1621 		GLuint						textureID	= 0;
   1622 
   1623 		gl.glGenTextures(1, &textureID);
   1624 		gl.glBindTexture(m_target, textureID);
   1625 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
   1626 
   1627 		switch (m_target)
   1628 		{
   1629 			case GL_TEXTURE_2D:
   1630 			case GL_TEXTURE_CUBE_MAP:
   1631 			{
   1632 				gl.glTexStorage2D(m_target, 1, GL_RGBA8, 32, 32);
   1633 				break;
   1634 			}
   1635 			case GL_TEXTURE_2D_ARRAY:
   1636 			case GL_TEXTURE_3D:
   1637 			{
   1638 				gl.glTexStorage3D(m_target, 1, GL_RGBA8, 32, 32, 8);
   1639 				break;
   1640 			}
   1641 			case GL_TEXTURE_2D_MULTISAMPLE:
   1642 			{
   1643 				gl.glTexStorage2DMultisample(m_target, 2, GL_RGB8, 64, 64, GL_FALSE);
   1644 				break;
   1645 			}
   1646 			case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
   1647 			{
   1648 				gl.glTexStorage3DMultisample(m_target, 2, GL_RGB8, 64, 64, 2, GL_FALSE);
   1649 				break;
   1650 			}
   1651 			case GL_TEXTURE_CUBE_MAP_ARRAY:
   1652 			{
   1653 				gl.glTexStorage3D(m_target, 1, GL_RGBA8, 32, 32, 6 * 2);
   1654 				break;
   1655 			}
   1656 			default:
   1657 				DE_ASSERT(false);
   1658 		}
   1659 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "setup texture");
   1660 
   1661 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, 1, m_type);
   1662 
   1663 		gl.glDeleteTextures(1, &textureID);
   1664 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
   1665 	}
   1666 
   1667 	// no mutable
   1668 	if (m_target == GL_TEXTURE_2D_MULTISAMPLE ||
   1669 		m_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
   1670 		return;
   1671 
   1672 	// test mutable
   1673 	{
   1674 		const tcu::ScopedLogSection	subsection		(m_testCtx.getLog(), "Mutable", "Mutable");
   1675 		GLuint						textureID		= 0;
   1676 
   1677 		gl.glGenTextures(1, &textureID);
   1678 		gl.glBindTexture(m_target, textureID);
   1679 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture");
   1680 
   1681 		switch (m_target)
   1682 		{
   1683 			case GL_TEXTURE_2D:
   1684 			{
   1685 				gl.glTexImage2D(m_target, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
   1686 				break;
   1687 			}
   1688 			case GL_TEXTURE_CUBE_MAP:
   1689 			{
   1690 				gl.glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
   1691 				break;
   1692 			}
   1693 			case GL_TEXTURE_2D_ARRAY:
   1694 			case GL_TEXTURE_3D:
   1695 			{
   1696 				gl.glTexImage3D(m_target, 0, GL_RGBA8, 32, 32, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
   1697 				break;
   1698 			}
   1699 			case GL_TEXTURE_CUBE_MAP_ARRAY:
   1700 			{
   1701 				gl.glTexImage3D(m_target, 0, GL_RGBA8, 32, 32, 6 * 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
   1702 				break;
   1703 			}
   1704 			default:
   1705 				DE_ASSERT(false);
   1706 		}
   1707 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "setup texture");
   1708 
   1709 		verifyStateTextureParamInteger(result, gl, m_target, m_pname, 0, m_type);
   1710 
   1711 		gl.glDeleteTextures(1, &textureID);
   1712 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures");
   1713 	}
   1714 }
   1715 
   1716 class TextureWrapClampToBorderCase : public TextureTest
   1717 {
   1718 public:
   1719 			TextureWrapClampToBorderCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type);
   1720 	void	test							(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1721 };
   1722 
   1723 TextureWrapClampToBorderCase::TextureWrapClampToBorderCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, TesterType tester, QueryType type)
   1724 	: TextureTest(testCtx, renderCtx, name, desc, target, tester, type)
   1725 {
   1726 }
   1727 
   1728 void TextureWrapClampToBorderCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1729 {
   1730 	gl.glTexParameteri(m_target, m_pname, GL_CLAMP_TO_BORDER_EXT);
   1731 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1732 	verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_CLAMP_TO_BORDER_EXT, m_type);
   1733 
   1734 	gl.glTexParameteri(m_target, m_pname, GL_REPEAT);
   1735 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteri");
   1736 
   1737 	gl.glTexParameterf(m_target, m_pname, (GLfloat)GL_CLAMP_TO_BORDER_EXT);
   1738 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterf");
   1739 
   1740 	verifyStateTextureParamInteger(result, gl, m_target, m_pname, GL_CLAMP_TO_BORDER_EXT, m_type);
   1741 }
   1742 
   1743 class TextureBorderColorCase : public TextureTest
   1744 {
   1745 public:
   1746 			TextureBorderColorCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, glw::GLenum target, QueryType type);
   1747 	void	test					(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1748 };
   1749 
   1750 TextureBorderColorCase::TextureBorderColorCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, glw::GLenum target, QueryType type)
   1751 	: TextureTest(testCtx, renderCtx, name, desc, target, TESTER_TEXTURE_BORDER_COLOR, type)
   1752 {
   1753 }
   1754 
   1755 void TextureBorderColorCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1756 {
   1757 	// border color is undefined if queried with pure type and was not set to pure value
   1758 	if (m_type == QUERY_TEXTURE_PARAM_INTEGER_VEC4 || m_type == QUERY_TEXTURE_PARAM_FLOAT_VEC4)
   1759 	{
   1760 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1761 		verifyStateTextureParamFloatVec4(result, gl, m_target, m_pname, tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), m_type);
   1762 	}
   1763 
   1764 	if (m_type == QUERY_TEXTURE_PARAM_PURE_INTEGER_VEC4)
   1765 	{
   1766 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   1767 		const tcu::IVec4			color			(0x7FFFFFFF, -2, 3, -128);
   1768 
   1769 		gl.glTexParameterIiv(m_target, m_pname, color.getPtr());
   1770 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIiv");
   1771 
   1772 		verifyStateTextureParamIntegerVec4(result, gl, m_target, m_pname, color, m_type);
   1773 	}
   1774 	else if (m_type == QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER_VEC4)
   1775 	{
   1776 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   1777 		const tcu::UVec4			color			(0x8000000ul, 2, 3, 128);
   1778 
   1779 		gl.glTexParameterIuiv(m_target, m_pname, color.getPtr());
   1780 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterIuiv");
   1781 
   1782 		verifyStateTextureParamUnsignedIntegerVec4(result, gl, m_target, m_pname, color, m_type);
   1783 	}
   1784 	else
   1785 	{
   1786 		DE_ASSERT(m_type == QUERY_TEXTURE_PARAM_INTEGER_VEC4 || m_type == QUERY_TEXTURE_PARAM_FLOAT_VEC4);
   1787 
   1788 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   1789 		const tcu::Vec4				color			(0.25f, 1.0f, 0.0f, 0.77f);
   1790 		const tcu::IVec4			icolor			(0x8000000ul, 0x7FFFFFFF, 0, 0x0FFFFFFF);
   1791 
   1792 		gl.glTexParameterfv(m_target, m_pname, color.getPtr());
   1793 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameterfv");
   1794 
   1795 		verifyStateTextureParamFloatVec4(result, gl, m_target, m_pname, color, m_type);
   1796 
   1797 		gl.glTexParameteriv(m_target, m_pname, icolor.getPtr());
   1798 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glTexParameteriv");
   1799 
   1800 		verifyStateTextureParamNormalizedI32Vec4(result, gl, m_target, m_pname, icolor, m_type);
   1801 	}
   1802 }
   1803 
   1804 class SamplerTest : public tcu::TestCase
   1805 {
   1806 public:
   1807 						SamplerTest	(tcu::TestContext&			testCtx,
   1808 									 const glu::RenderContext&	renderCtx,
   1809 									 const char*				name,
   1810 									 const char*				desc,
   1811 									 TesterType					tester,
   1812 									 QueryType					type);
   1813 
   1814 	void				init		(void);
   1815 	IterateResult		iterate		(void);
   1816 
   1817 	virtual void		test		(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const = 0;
   1818 
   1819 protected:
   1820 	const glu::RenderContext&	m_renderCtx;
   1821 	const glw::GLenum			m_pname;
   1822 	const TesterType			m_tester;
   1823 	const QueryType				m_type;
   1824 	glw::GLuint					m_target;
   1825 };
   1826 
   1827 SamplerTest::SamplerTest (tcu::TestContext&			testCtx,
   1828 						  const glu::RenderContext&	renderCtx,
   1829 						  const char*				name,
   1830 						  const char*				desc,
   1831 						  TesterType				tester,
   1832 						  QueryType					type)
   1833 	: TestCase		(testCtx, name, desc)
   1834 	, m_renderCtx	(renderCtx)
   1835 	, m_pname		(mapTesterToPname(tester))
   1836 	, m_tester		(tester)
   1837 	, m_type		(type)
   1838 	, m_target		(0)
   1839 {
   1840 }
   1841 
   1842 void SamplerTest::init (void)
   1843 {
   1844 	const de::UniquePtr<glu::ContextInfo>	ctxInfo		(glu::ContextInfo::create(m_renderCtx));
   1845 	RequiredExtensions						extensions;
   1846 
   1847 	// param
   1848 	if (!isCoreTextureParam(m_renderCtx.getType(), m_pname))
   1849 		extensions.add(getTextureParamExtension(m_renderCtx.getType(), m_pname));
   1850 
   1851 	// query
   1852 	if (!isCoreQuery(m_renderCtx.getType(), m_type))
   1853 		extensions.add(getQueryExtension(m_renderCtx.getType(), m_type));
   1854 
   1855 	// test type
   1856 	if (!isCoreTester(m_renderCtx.getType(), m_tester))
   1857 		extensions.add(getTesterExtension(m_renderCtx.getType(), m_tester));
   1858 
   1859 	extensions.check(*ctxInfo);
   1860 }
   1861 
   1862 SamplerTest::IterateResult SamplerTest::iterate (void)
   1863 {
   1864 	glu::CallLogWrapper		gl		(m_renderCtx.getFunctions(), m_testCtx.getLog());
   1865 	tcu::ResultCollector	result	(m_testCtx.getLog(), " // ERROR: ");
   1866 	glu::Sampler			sampler	(m_renderCtx);
   1867 
   1868 	gl.enableLogging(true);
   1869 
   1870 	m_target = *sampler;
   1871 	test(gl, result);
   1872 	m_target = 0;
   1873 
   1874 	result.setTestContextResult(m_testCtx);
   1875 	return STOP;
   1876 }
   1877 
   1878 class SamplerWrapCase : public SamplerTest
   1879 {
   1880 public:
   1881 			SamplerWrapCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
   1882 	void	test			(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1883 };
   1884 
   1885 SamplerWrapCase::SamplerWrapCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
   1886 	: SamplerTest(testCtx, renderCtx, name, desc, tester, type)
   1887 {
   1888 }
   1889 
   1890 void SamplerWrapCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1891 {
   1892 	const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
   1893 
   1894 	if (!isPureCase)
   1895 	{
   1896 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1897 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_REPEAT, m_type);
   1898 	}
   1899 
   1900 	{
   1901 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   1902 		const GLenum				wrapValues[]	= {GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT};
   1903 
   1904 		if (isPureCase)
   1905 		{
   1906 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
   1907 			{
   1908 				if (isPureIntTester(m_tester))
   1909 				{
   1910 					const glw::GLint value = (glw::GLint)wrapValues[ndx];
   1911 					gl.glSamplerParameterIiv(m_target, m_pname, &value);
   1912 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
   1913 				}
   1914 				else
   1915 				{
   1916 					DE_ASSERT(isPureUintTester(m_tester));
   1917 
   1918 					const glw::GLuint value = wrapValues[ndx];
   1919 					gl.glSamplerParameterIuiv(m_target, m_pname, &value);
   1920 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
   1921 				}
   1922 
   1923 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
   1924 			}
   1925 		}
   1926 		else
   1927 		{
   1928 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
   1929 			{
   1930 				gl.glSamplerParameteri(m_target, m_pname, wrapValues[ndx]);
   1931 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
   1932 
   1933 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
   1934 			}
   1935 
   1936 			//check unit conversions with float
   1937 
   1938 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(wrapValues); ++ndx)
   1939 			{
   1940 				gl.glSamplerParameterf(m_target, m_pname, (GLfloat)wrapValues[ndx]);
   1941 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
   1942 
   1943 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, wrapValues[ndx], m_type);
   1944 			}
   1945 		}
   1946 	}
   1947 }
   1948 
   1949 class SamplerFilterCase : public SamplerTest
   1950 {
   1951 public:
   1952 			SamplerFilterCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
   1953 	void	test				(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   1954 };
   1955 
   1956 SamplerFilterCase::SamplerFilterCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
   1957 	: SamplerTest(testCtx, renderCtx, name, desc, tester, type)
   1958 {
   1959 }
   1960 
   1961 void SamplerFilterCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   1962 {
   1963 	const bool			isPureCase	= isPureIntTester(m_tester) || isPureUintTester(m_tester);
   1964 	const glw::GLenum	initial		= (m_pname == GL_TEXTURE_MAG_FILTER) ? (GL_LINEAR)
   1965 									: (m_pname == GL_TEXTURE_MIN_FILTER) ? (GL_NEAREST_MIPMAP_LINEAR)
   1966 									: (0);
   1967 
   1968 	if (!isPureCase)
   1969 	{
   1970 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   1971 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, initial, m_type);
   1972 	}
   1973 
   1974 	{
   1975 		const tcu::ScopedLogSection	section		(m_testCtx.getLog(), "Set", "Set");
   1976 		std::vector<GLenum>			values;
   1977 
   1978 		values.push_back(GL_NEAREST);
   1979 		values.push_back(GL_LINEAR);
   1980 		if (m_pname == GL_TEXTURE_MIN_FILTER)
   1981 		{
   1982 			values.push_back(GL_NEAREST_MIPMAP_NEAREST);
   1983 			values.push_back(GL_NEAREST_MIPMAP_LINEAR);
   1984 			values.push_back(GL_LINEAR_MIPMAP_NEAREST);
   1985 			values.push_back(GL_LINEAR_MIPMAP_LINEAR);
   1986 		}
   1987 
   1988 		if (isPureCase)
   1989 		{
   1990 			for (int ndx = 0; ndx < (int)values.size(); ++ndx)
   1991 			{
   1992 				if (isPureIntTester(m_tester))
   1993 				{
   1994 					const glw::GLint value = (glw::GLint)values[ndx];
   1995 					gl.glSamplerParameterIiv(m_target, m_pname, &value);
   1996 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
   1997 				}
   1998 				else
   1999 				{
   2000 					DE_ASSERT(isPureUintTester(m_tester));
   2001 
   2002 					const glw::GLuint value = values[ndx];
   2003 					gl.glSamplerParameterIuiv(m_target, m_pname, &value);
   2004 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
   2005 				}
   2006 
   2007 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
   2008 			}
   2009 		}
   2010 		else
   2011 		{
   2012 			for (int ndx = 0; ndx < (int)values.size(); ++ndx)
   2013 			{
   2014 				gl.glSamplerParameteri(m_target, m_pname, values[ndx]);
   2015 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
   2016 
   2017 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
   2018 			}
   2019 
   2020 			//check unit conversions with float
   2021 
   2022 			for (int ndx = 0; ndx < (int)values.size(); ++ndx)
   2023 			{
   2024 				gl.glSamplerParameterf(m_target, m_pname, (GLfloat)values[ndx]);
   2025 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
   2026 
   2027 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, values[ndx], m_type);
   2028 			}
   2029 		}
   2030 	}
   2031 }
   2032 
   2033 class SamplerLODCase : public SamplerTest
   2034 {
   2035 public:
   2036 			SamplerLODCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
   2037 	void	test			(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   2038 };
   2039 
   2040 SamplerLODCase::SamplerLODCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
   2041 	: SamplerTest(testCtx, renderCtx, name, desc, tester, type)
   2042 {
   2043 }
   2044 
   2045 void SamplerLODCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   2046 {
   2047 	const bool	isPureCase		= isPureIntTester(m_tester) || isPureUintTester(m_tester);
   2048 	const int	initialValue	= (m_pname == GL_TEXTURE_MIN_LOD) ? (-1000)
   2049 								: (m_pname == GL_TEXTURE_MAX_LOD) ? (1000)
   2050 								: (-1);
   2051 
   2052 	if ((querySupportsSigned(m_type) || initialValue >= 0) && !isPureCase)
   2053 	{
   2054 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   2055 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, initialValue, m_type);
   2056 	}
   2057 
   2058 	{
   2059 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   2060 		const int					numIterations	= 20;
   2061 		de::Random					rnd				(0xabcdef);
   2062 
   2063 		if (isPureCase)
   2064 		{
   2065 			if (isPureIntTester(m_tester))
   2066 			{
   2067 				for (int ndx = 0; ndx < numIterations; ++ndx)
   2068 				{
   2069 					const GLint ref = rnd.getInt(-1000, 1000);
   2070 
   2071 					gl.glSamplerParameterIiv(m_target, m_pname, &ref);
   2072 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
   2073 
   2074 					verifyStateSamplerParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
   2075 				}
   2076 			}
   2077 			else
   2078 			{
   2079 				DE_ASSERT(isPureUintTester(m_tester));
   2080 
   2081 				for (int ndx = 0; ndx < numIterations; ++ndx)
   2082 				{
   2083 					const GLuint ref = (glw::GLuint)rnd.getInt(0, 1000);
   2084 
   2085 					gl.glSamplerParameterIuiv(m_target, m_pname, &ref);
   2086 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
   2087 
   2088 					verifyStateSamplerParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
   2089 				}
   2090 			}
   2091 		}
   2092 		else
   2093 		{
   2094 			const int minLimit = (querySupportsSigned(m_type)) ? (-1000) : (0);
   2095 
   2096 			for (int ndx = 0; ndx < numIterations; ++ndx)
   2097 			{
   2098 				const GLfloat ref = rnd.getFloat((float)minLimit, 1000.f);
   2099 
   2100 				gl.glSamplerParameterf(m_target, m_pname, ref);
   2101 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
   2102 
   2103 				verifyStateSamplerParamFloat(result, gl, m_target, m_pname, ref, m_type);
   2104 			}
   2105 
   2106 			// check unit conversions with int
   2107 
   2108 			for (int ndx = 0; ndx < numIterations; ++ndx)
   2109 			{
   2110 				const GLint ref = rnd.getInt(minLimit, 1000);
   2111 
   2112 				gl.glSamplerParameteri(m_target, m_pname, ref);
   2113 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
   2114 
   2115 				verifyStateSamplerParamFloat(result, gl, m_target, m_pname, (float)ref, m_type);
   2116 			}
   2117 		}
   2118 	}
   2119 }
   2120 
   2121 class SamplerCompareModeCase : public SamplerTest
   2122 {
   2123 public:
   2124 			SamplerCompareModeCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
   2125 	void	test					(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   2126 };
   2127 
   2128 SamplerCompareModeCase::SamplerCompareModeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
   2129 	: SamplerTest(testCtx, renderCtx, name, desc, tester, type)
   2130 {
   2131 }
   2132 
   2133 void SamplerCompareModeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   2134 {
   2135 	const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
   2136 
   2137 	if (!isPureCase)
   2138 	{
   2139 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   2140 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_NONE, m_type);
   2141 	}
   2142 
   2143 	{
   2144 		const tcu::ScopedLogSection	section		(m_testCtx.getLog(), "Set", "Set");
   2145 		const GLenum				modes[]		= {GL_COMPARE_REF_TO_TEXTURE, GL_NONE};
   2146 
   2147 		if (isPureCase)
   2148 		{
   2149 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
   2150 			{
   2151 				if (isPureIntTester(m_tester))
   2152 				{
   2153 					const glw::GLint value = (glw::GLint)modes[ndx];
   2154 					gl.glSamplerParameterIiv(m_target, m_pname, &value);
   2155 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
   2156 				}
   2157 				else
   2158 				{
   2159 					DE_ASSERT(isPureUintTester(m_tester));
   2160 
   2161 					const glw::GLuint value = modes[ndx];
   2162 					gl.glSamplerParameterIuiv(m_target, m_pname, &value);
   2163 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
   2164 				}
   2165 
   2166 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
   2167 			}
   2168 		}
   2169 		else
   2170 		{
   2171 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
   2172 			{
   2173 				gl.glSamplerParameteri(m_target, m_pname, modes[ndx]);
   2174 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
   2175 
   2176 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
   2177 			}
   2178 
   2179 			//check unit conversions with float
   2180 
   2181 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(modes); ++ndx)
   2182 			{
   2183 				gl.glSamplerParameterf(m_target, m_pname, (GLfloat)modes[ndx]);
   2184 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
   2185 
   2186 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, modes[ndx], m_type);
   2187 			}
   2188 		}
   2189 	}
   2190 }
   2191 
   2192 class SamplerCompareFuncCase : public SamplerTest
   2193 {
   2194 public:
   2195 			SamplerCompareFuncCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
   2196 	void	test					(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   2197 };
   2198 
   2199 SamplerCompareFuncCase::SamplerCompareFuncCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
   2200 	: SamplerTest(testCtx, renderCtx, name, desc, tester, type)
   2201 {
   2202 }
   2203 
   2204 void SamplerCompareFuncCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   2205 {
   2206 	const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
   2207 
   2208 	if (!isPureCase)
   2209 	{
   2210 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   2211 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_LEQUAL, m_type);
   2212 	}
   2213 
   2214 	{
   2215 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   2216 		const GLenum				compareFuncs[]	= {GL_LEQUAL, GL_GEQUAL, GL_LESS, GL_GREATER, GL_EQUAL, GL_NOTEQUAL, GL_ALWAYS, GL_NEVER};
   2217 
   2218 		if (isPureCase)
   2219 		{
   2220 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
   2221 			{
   2222 				if (isPureIntTester(m_tester))
   2223 				{
   2224 					const glw::GLint value = (glw::GLint)compareFuncs[ndx];
   2225 					gl.glSamplerParameterIiv(m_target, m_pname, &value);
   2226 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
   2227 				}
   2228 				else
   2229 				{
   2230 					DE_ASSERT(isPureUintTester(m_tester));
   2231 
   2232 					const glw::GLuint value = compareFuncs[ndx];
   2233 					gl.glSamplerParameterIuiv(m_target, m_pname, &value);
   2234 					GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
   2235 				}
   2236 
   2237 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
   2238 			}
   2239 		}
   2240 		else
   2241 		{
   2242 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
   2243 			{
   2244 				gl.glSamplerParameteri(m_target, m_pname, compareFuncs[ndx]);
   2245 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
   2246 
   2247 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
   2248 			}
   2249 
   2250 			//check unit conversions with float
   2251 
   2252 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(compareFuncs); ++ndx)
   2253 			{
   2254 				gl.glSamplerParameterf(m_target, m_pname, (GLfloat)compareFuncs[ndx]);
   2255 				GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
   2256 
   2257 				verifyStateSamplerParamInteger(result, gl, m_target, m_pname, compareFuncs[ndx], m_type);
   2258 			}
   2259 		}
   2260 	}
   2261 }
   2262 
   2263 class SamplerWrapClampToBorderCase : public SamplerTest
   2264 {
   2265 public:
   2266 			SamplerWrapClampToBorderCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
   2267 	void	test							(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   2268 };
   2269 
   2270 SamplerWrapClampToBorderCase::SamplerWrapClampToBorderCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
   2271 	: SamplerTest(testCtx, renderCtx, name, desc, tester, type)
   2272 {
   2273 }
   2274 
   2275 void SamplerWrapClampToBorderCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   2276 {
   2277 	gl.glSamplerParameteri(m_target, m_pname, GL_CLAMP_TO_BORDER_EXT);
   2278 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
   2279 	verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_CLAMP_TO_BORDER_EXT, m_type);
   2280 
   2281 	gl.glSamplerParameteri(m_target, m_pname, GL_REPEAT);
   2282 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteri");
   2283 
   2284 	gl.glSamplerParameterf(m_target, m_pname, (GLfloat)GL_CLAMP_TO_BORDER_EXT);
   2285 	GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterf");
   2286 
   2287 	verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_CLAMP_TO_BORDER_EXT, m_type);
   2288 }
   2289 
   2290 class SamplerSRGBDecodeCase : public SamplerTest
   2291 {
   2292 public:
   2293 			SamplerSRGBDecodeCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, TesterType tester, QueryType type);
   2294 	void	test					(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   2295 };
   2296 
   2297 SamplerSRGBDecodeCase::SamplerSRGBDecodeCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, TesterType tester, QueryType type)
   2298 	: SamplerTest(testCtx, renderCtx, name, desc, tester, type)
   2299 {
   2300 }
   2301 
   2302 void SamplerSRGBDecodeCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   2303 {
   2304 	const bool isPureCase = isPureIntTester(m_tester) || isPureUintTester(m_tester);
   2305 
   2306 	if (!isPureCase)
   2307 	{
   2308 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   2309 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
   2310 	}
   2311 
   2312 	{
   2313 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Toggle", "Toggle");
   2314 		const glw::GLint			decodeInt		= GL_DECODE_EXT;
   2315 		const glw::GLfloat			decodeFloat		= (glw::GLfloat)GL_DECODE_EXT;
   2316 
   2317 		gl.glSamplerParameteri(m_target, m_pname, GL_SKIP_DECODE_EXT);
   2318 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
   2319 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
   2320 
   2321 		gl.glSamplerParameteriv(m_target, m_pname, &decodeInt);
   2322 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
   2323 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
   2324 
   2325 		gl.glSamplerParameterf(m_target, m_pname, GL_SKIP_DECODE_EXT);
   2326 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
   2327 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
   2328 
   2329 		gl.glSamplerParameterfv(m_target, m_pname, &decodeFloat);
   2330 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "set state");
   2331 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
   2332 	}
   2333 
   2334 	if (isPureIntTester(m_tester))
   2335 	{
   2336 		const glw::GLint skipDecode	= GL_SKIP_DECODE_EXT;
   2337 		const glw::GLint decode		= GL_DECODE_EXT;
   2338 
   2339 		gl.glSamplerParameterIiv(m_target, m_pname, &skipDecode);
   2340 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
   2341 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
   2342 
   2343 		gl.glSamplerParameterIiv(m_target, m_pname, &decode);
   2344 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
   2345 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
   2346 	}
   2347 
   2348 	if (isPureUintTester(m_tester))
   2349 	{
   2350 		const glw::GLuint skipDecode	= GL_SKIP_DECODE_EXT;
   2351 		const glw::GLuint decode		= GL_DECODE_EXT;
   2352 
   2353 		gl.glSamplerParameterIuiv(m_target, m_pname, &skipDecode);
   2354 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
   2355 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_SKIP_DECODE_EXT, m_type);
   2356 
   2357 		gl.glSamplerParameterIuiv(m_target, m_pname, &decode);
   2358 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
   2359 		verifyStateSamplerParamInteger(result, gl, m_target, m_pname, GL_DECODE_EXT, m_type);
   2360 	}
   2361 }
   2362 
   2363 class SamplerBorderColorCase : public SamplerTest
   2364 {
   2365 public:
   2366 			SamplerBorderColorCase	(tcu::TestContext& testCtx, const glu::RenderContext& renderContext, const char* name, const char* desc, QueryType type);
   2367 	void	test					(glu::CallLogWrapper& gl, tcu::ResultCollector& result) const;
   2368 };
   2369 
   2370 SamplerBorderColorCase::SamplerBorderColorCase (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const char* name, const char* desc, QueryType type)
   2371 	: SamplerTest(testCtx, renderCtx, name, desc, TESTER_TEXTURE_BORDER_COLOR, type)
   2372 {
   2373 	DE_ASSERT(m_type == QUERY_SAMPLER_PARAM_INTEGER_VEC4					||
   2374 			  m_type == QUERY_SAMPLER_PARAM_FLOAT_VEC4						||
   2375 			  m_type == QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4				||
   2376 			  m_type == QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4);
   2377 }
   2378 
   2379 void SamplerBorderColorCase::test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const
   2380 {
   2381 	// border color is undefined if queried with pure type and was not set to pure value
   2382 	if (m_type == QUERY_SAMPLER_PARAM_INTEGER_VEC4 || m_type == QUERY_SAMPLER_PARAM_FLOAT_VEC4)
   2383 	{
   2384 		const tcu::ScopedLogSection section(m_testCtx.getLog(), "Initial", "Initial");
   2385 		verifyStateSamplerParamFloatVec4(result, gl, m_target, m_pname, tcu::Vec4(0.0f, 0.0f, 0.0f, 0.0f), m_type);
   2386 	}
   2387 
   2388 	if (m_type == QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4)
   2389 	{
   2390 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   2391 		const tcu::IVec4			color			(0x7FFFFFFF, -2, 3, -128);
   2392 
   2393 		gl.glSamplerParameterIiv(m_target, m_pname, color.getPtr());
   2394 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIiv");
   2395 
   2396 		verifyStateSamplerParamIntegerVec4(result, gl, m_target, m_pname, color, m_type);
   2397 	}
   2398 	else if (m_type == QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4)
   2399 	{
   2400 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   2401 		const tcu::UVec4			color			(0x8000000ul, 2, 3, 128);
   2402 
   2403 		gl.glSamplerParameterIuiv(m_target, m_pname, color.getPtr());
   2404 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterIuiv");
   2405 
   2406 		verifyStateSamplerParamUnsignedIntegerVec4(result, gl, m_target, m_pname, color, m_type);
   2407 	}
   2408 	else
   2409 	{
   2410 		DE_ASSERT(m_type == QUERY_SAMPLER_PARAM_INTEGER_VEC4 || m_type == QUERY_SAMPLER_PARAM_FLOAT_VEC4);
   2411 
   2412 		const tcu::ScopedLogSection	section			(m_testCtx.getLog(), "Set", "Set");
   2413 		const tcu::Vec4				color			(0.25f, 1.0f, 0.0f, 0.77f);
   2414 		const tcu::IVec4			icolor			(0x8000000ul, 0x7FFFFFFF, 0, 0x0FFFFFFF);
   2415 
   2416 		gl.glSamplerParameterfv(m_target, m_pname, color.getPtr());
   2417 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameterfv");
   2418 
   2419 		verifyStateSamplerParamFloatVec4(result, gl, m_target, m_pname, color, m_type);
   2420 
   2421 		gl.glSamplerParameteriv(m_target, m_pname, icolor.getPtr());
   2422 		GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glSamplerParameteriv");
   2423 
   2424 		verifyStateSamplerParamNormalizedI32Vec4(result, gl, m_target, m_pname, icolor, m_type);
   2425 	}
   2426 }
   2427 
   2428 } // anonymous
   2429 
   2430 bool isLegalTesterForTarget (glw::GLenum target, TesterType tester)
   2431 {
   2432 	// no 3d filtering on 2d targets
   2433 	if ((tester == TESTER_TEXTURE_WRAP_R || tester == TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER) &&  target != GL_TEXTURE_3D)
   2434 		return false;
   2435 
   2436 	// no sampling on multisample
   2437 	if (isMultisampleTarget(target) && isSamplerStateTester(tester))
   2438 		return false;
   2439 
   2440 	// no states in buffer
   2441 	if (target == GL_TEXTURE_BUFFER)
   2442 		return false;
   2443 
   2444 	return true;
   2445 }
   2446 
   2447 bool isMultisampleTarget (glw::GLenum target)
   2448 {
   2449 	return	target == GL_TEXTURE_2D_MULTISAMPLE			||
   2450 			target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
   2451 }
   2452 
   2453 bool isSamplerStateTester (TesterType tester)
   2454 {
   2455 	return	tester == TESTER_TEXTURE_WRAP_S					||
   2456 			tester == TESTER_TEXTURE_WRAP_T					||
   2457 			tester == TESTER_TEXTURE_WRAP_R					||
   2458 			tester == TESTER_TEXTURE_MAG_FILTER				||
   2459 			tester == TESTER_TEXTURE_MIN_FILTER				||
   2460 			tester == TESTER_TEXTURE_MIN_LOD				||
   2461 			tester == TESTER_TEXTURE_MAX_LOD				||
   2462 			tester == TESTER_TEXTURE_COMPARE_MODE			||
   2463 			tester == TESTER_TEXTURE_COMPARE_FUNC			||
   2464 			tester == TESTER_TEXTURE_SRGB_DECODE_EXT		||
   2465 			tester == TESTER_TEXTURE_BORDER_COLOR			||
   2466 			tester == TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER	||
   2467 			tester == TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER	||
   2468 			tester == TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER;
   2469 }
   2470 
   2471 tcu::TestCase* createIsTextureTest (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const std::string& name, const std::string& description, glw::GLenum target)
   2472 {
   2473 	return new IsTextureCase(testCtx, renderCtx, name.c_str(), description.c_str(), target);
   2474 }
   2475 
   2476 tcu::TestCase* createTexParamTest (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const std::string& name, const std::string& description, QueryType queryType, glw::GLenum target, TesterType tester)
   2477 {
   2478 	if (isMultisampleTarget(target) && isSamplerStateTester(tester))
   2479 	{
   2480 		DE_FATAL("Multisample textures have no sampler state");
   2481 		return DE_NULL;
   2482 	}
   2483 	if (target == GL_TEXTURE_BUFFER)
   2484 	{
   2485 		DE_FATAL("Buffer textures have no texture state");
   2486 		return DE_NULL;
   2487 	}
   2488 	if (target != GL_TEXTURE_3D && mapTesterToPname(tester) == GL_TEXTURE_WRAP_R)
   2489 	{
   2490 		DE_FATAL("Only 3D textures have wrap r filter");
   2491 		return DE_NULL;
   2492 	}
   2493 
   2494 #define CASE_ALL_SETTERS(X) case X: case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
   2495 
   2496 	switch (tester)
   2497 	{
   2498 		CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_R):
   2499 		CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_G):
   2500 		CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_B):
   2501 		CASE_ALL_SETTERS(TESTER_TEXTURE_SWIZZLE_A):
   2502 			return new TextureSwizzleCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2503 
   2504 		CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S):
   2505 		CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T):
   2506 		CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R):
   2507 			return new TextureWrapCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2508 
   2509 		CASE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER):
   2510 		CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER):
   2511 			return new TextureFilterCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2512 
   2513 		CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD):
   2514 		CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD):
   2515 			return new TextureLODCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2516 
   2517 		CASE_ALL_SETTERS(TESTER_TEXTURE_BASE_LEVEL):
   2518 		CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LEVEL):
   2519 			return new TextureLevelCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2520 
   2521 		CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE):
   2522 			return new TextureCompareModeCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2523 
   2524 		CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC):
   2525 			return new TextureCompareFuncCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2526 
   2527 		case TESTER_TEXTURE_IMMUTABLE_LEVELS:
   2528 			return new TextureImmutableLevelsCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, queryType);
   2529 
   2530 		case TESTER_TEXTURE_IMMUTABLE_FORMAT:
   2531 			return new TextureImmutableFormatCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, queryType);
   2532 
   2533 		case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
   2534 		case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
   2535 		case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
   2536 			return new TextureWrapClampToBorderCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2537 
   2538 		CASE_ALL_SETTERS(TESTER_DEPTH_STENCIL_TEXTURE_MODE):
   2539 			return new DepthStencilModeCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2540 
   2541 		CASE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT):
   2542 			return new TextureSRGBDecodeCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, tester, queryType);
   2543 
   2544 		case TESTER_TEXTURE_BORDER_COLOR:
   2545 			return new TextureBorderColorCase(testCtx, renderCtx, name.c_str(), description.c_str(), target, queryType);
   2546 
   2547 		default:
   2548 			break;
   2549 	}
   2550 
   2551 #undef CASE_ALL_SETTERS
   2552 
   2553 	DE_ASSERT(false);
   2554 	return DE_NULL;
   2555 }
   2556 
   2557 tcu::TestCase* createSamplerParamTest (tcu::TestContext& testCtx, const glu::RenderContext& renderCtx, const std::string& name, const std::string& description, StateQueryUtil::QueryType queryType, TesterType tester)
   2558 {
   2559 #define CASE_ALL_SETTERS(X) case X: case X ## _SET_PURE_INT: case X ## _SET_PURE_UINT
   2560 
   2561 	switch (tester)
   2562 	{
   2563 		CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_S):
   2564 		CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_T):
   2565 		CASE_ALL_SETTERS(TESTER_TEXTURE_WRAP_R):
   2566 			return new SamplerWrapCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
   2567 
   2568 		CASE_ALL_SETTERS(TESTER_TEXTURE_MAG_FILTER):
   2569 		CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_FILTER):
   2570 			return new SamplerFilterCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
   2571 
   2572 		CASE_ALL_SETTERS(TESTER_TEXTURE_MIN_LOD):
   2573 		CASE_ALL_SETTERS(TESTER_TEXTURE_MAX_LOD):
   2574 			return new SamplerLODCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
   2575 
   2576 		CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_MODE):
   2577 			return new SamplerCompareModeCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
   2578 
   2579 		CASE_ALL_SETTERS(TESTER_TEXTURE_COMPARE_FUNC):
   2580 			return new SamplerCompareFuncCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
   2581 
   2582 		case TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER:
   2583 		case TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER:
   2584 		case TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER:
   2585 			return new SamplerWrapClampToBorderCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
   2586 
   2587 		CASE_ALL_SETTERS(TESTER_TEXTURE_SRGB_DECODE_EXT):
   2588 			return new SamplerSRGBDecodeCase(testCtx, renderCtx, name.c_str(), description.c_str(), tester, queryType);
   2589 
   2590 		case TESTER_TEXTURE_BORDER_COLOR:
   2591 			return new SamplerBorderColorCase(testCtx, renderCtx, name.c_str(), description.c_str(), queryType);
   2592 
   2593 		default:
   2594 			break;
   2595 	}
   2596 
   2597 #undef CASE_ALL_SETTERS
   2598 
   2599 	DE_ASSERT(false);
   2600 	return DE_NULL;
   2601 }
   2602 
   2603 } // TextureStateQueryTests
   2604 } // gls
   2605 } // deqp
   2606