Home | History | Annotate | Download | only in functional
      1 /*-------------------------------------------------------------------------
      2  * drawElements Quality Program OpenGL ES 3.1 Module
      3  * -------------------------------------------------
      4  *
      5  * Copyright 2016 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 Negative Shader Function Tests
     22  *//*--------------------------------------------------------------------*/
     23 
     24 #include "es31fNegativeShaderFunctionTests.hpp"
     25 
     26 #include "gluShaderProgram.hpp"
     27 
     28 namespace deqp
     29 {
     30 namespace gles31
     31 {
     32 namespace Functional
     33 {
     34 namespace NegativeTestShared
     35 {
     36 namespace
     37 {
     38 
     39 enum ShaderFunction
     40 {
     41 	SHADER_FUNCTION_BITFIELD_REVERSE = 0,
     42 	SHADER_FUNCTION_BIT_COUNT,
     43 	SHADER_FUNCTION_FIND_MSB,
     44 	SHADER_FUNCTION_FIND_LSB,
     45 	SHADER_FUNCTION_UADD_CARRY,
     46 	SHADER_FUNCTION_USUB_BORROW,
     47 	SHADER_FUNCTION_UMUL_EXTENDED,
     48 	SHADER_FUNCTION_IMUL_EXTENDED,
     49 	SHADER_FUNCTION_FREXP,
     50 	SHADER_FUNCTION_LDEXP,
     51 	SHADER_FUNCTION_PACK_UNORM_4X8,
     52 	SHADER_FUNCTION_PACK_SNORM_4X8,
     53 	SHADER_FUNCTION_UNPACK_SNORM_4X8,
     54 	SHADER_FUNCTION_UNPACK_UNORM_4X8,
     55 	SHADER_FUNCTION_EMIT_VERTEX,
     56 	SHADER_FUNCTION_END_PRIMITIVE,
     57 	SHADER_FUNCTION_ATOMIC_ADD,
     58 	SHADER_FUNCTION_ATOMIC_MIN,
     59 	SHADER_FUNCTION_ATOMIC_MAX,
     60 	SHADER_FUNCTION_ATOMIC_AND,
     61 	SHADER_FUNCTION_ATOMIC_OR,
     62 	SHADER_FUNCTION_ATOMIC_XOR,
     63 	SHADER_FUNCTION_ATOMIC_EXCHANGE,
     64 	SHADER_FUNCTION_ATOMIC_COMP_SWAP,
     65 	SHADER_FUNCTION_INTERPOLATED_AT_CENTROID,
     66 	SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE,
     67 	SHADER_FUNCTION_INTERPOLATED_AT_OFFSET,
     68 
     69 	SHADER_FUNCTION_LAST
     70 };
     71 
     72 enum FunctionTextureModes
     73 {
     74 	FUNCTION_TEXTURE_MODE_NO_BIAS_NO_COMPARE = 0,
     75 	FUNCTION_TEXTURE_MODE_BIAS_OR_COMPARE,
     76 
     77 	FUNCTION_TEXTURE_MODE_LAST
     78 };
     79 
     80 enum FunctionTextureGatherOffsetModes
     81 {
     82 	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP = 0,
     83 	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,
     84 
     85 	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_LAST
     86 };
     87 
     88 struct TextureGatherOffsetsTestSpec
     89 {
     90 	FunctionTextureGatherOffsetModes	mode;
     91 	glu::DataType						samplerDataType;
     92 	glu::DataType						pDataType;
     93 	glu::DataType						offsetsDataType;
     94 	glu::DataType						fourthArgument;
     95 	bool								offsetIsConst;
     96 	int									offsetArraySize;
     97 };
     98 
     99 static const glu::DataType s_floatTypes[] =
    100 {
    101 	glu::TYPE_FLOAT,
    102 	glu::TYPE_FLOAT_VEC2,
    103 	glu::TYPE_FLOAT_VEC3,
    104 	glu::TYPE_FLOAT_VEC4
    105 };
    106 
    107 static const glu::DataType s_intTypes[] =
    108 {
    109 	glu::TYPE_INT,
    110 	glu::TYPE_INT_VEC2,
    111 	glu::TYPE_INT_VEC3,
    112 	glu::TYPE_INT_VEC4
    113 };
    114 
    115 static const glu::DataType s_uintTypes[] =
    116 {
    117 	glu::TYPE_UINT,
    118 	glu::TYPE_UINT_VEC2,
    119 	glu::TYPE_UINT_VEC3,
    120 	glu::TYPE_UINT_VEC4
    121 };
    122 
    123 static const glu::DataType s_nonScalarIntTypes[] =
    124 {
    125 	glu::TYPE_FLOAT,
    126 	glu::TYPE_FLOAT_VEC2,
    127 	glu::TYPE_FLOAT_VEC3,
    128 	glu::TYPE_FLOAT_VEC4,
    129 	glu::TYPE_INT_VEC2,
    130 	glu::TYPE_INT_VEC3,
    131 	glu::TYPE_INT_VEC4,
    132 	glu::TYPE_UINT,
    133 	glu::TYPE_UINT_VEC2,
    134 	glu::TYPE_UINT_VEC3,
    135 	glu::TYPE_UINT_VEC4
    136 };
    137 
    138 static const glu::ShaderType s_shaders[] =
    139 {
    140 	glu::SHADERTYPE_VERTEX,
    141 	glu::SHADERTYPE_FRAGMENT,
    142 	glu::SHADERTYPE_GEOMETRY,
    143 	glu::SHADERTYPE_TESSELLATION_CONTROL,
    144 	glu::SHADERTYPE_TESSELLATION_EVALUATION,
    145 	glu::SHADERTYPE_COMPUTE
    146 };
    147 
    148 static const glu::DataType s_samplerTypes[] =
    149 {
    150 	glu::TYPE_SAMPLER_2D,
    151 	glu::TYPE_INT_SAMPLER_2D,
    152 	glu::TYPE_UINT_SAMPLER_2D,
    153 	glu::TYPE_SAMPLER_3D,
    154 	glu::TYPE_INT_SAMPLER_3D,
    155 	glu::TYPE_UINT_SAMPLER_3D,
    156 	glu::TYPE_SAMPLER_CUBE,
    157 	glu::TYPE_INT_SAMPLER_CUBE,
    158 	glu::TYPE_UINT_SAMPLER_CUBE,
    159 	glu::TYPE_SAMPLER_2D_ARRAY,
    160 	glu::TYPE_INT_SAMPLER_2D_ARRAY,
    161 	glu::TYPE_UINT_SAMPLER_2D_ARRAY,
    162 	glu::TYPE_SAMPLER_CUBE_SHADOW,
    163 	glu::TYPE_SAMPLER_2D_SHADOW,
    164 	glu::TYPE_SAMPLER_2D_ARRAY_SHADOW,
    165 	glu::TYPE_SAMPLER_CUBE_ARRAY,
    166 	glu::TYPE_INT_SAMPLER_CUBE_ARRAY,
    167 	glu::TYPE_UINT_SAMPLER_CUBE_ARRAY,
    168 	glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW,
    169 
    170 	glu::TYPE_SAMPLER_2D_MULTISAMPLE,
    171 	glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE,
    172 	glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE,
    173 
    174 	glu::TYPE_SAMPLER_BUFFER,
    175 	glu::TYPE_INT_SAMPLER_BUFFER,
    176 	glu::TYPE_UINT_SAMPLER_BUFFER,
    177 
    178 	glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY,
    179 	glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY,
    180 	glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY,
    181 };
    182 
    183 void verifyShader (NegativeTestContext& ctx, glu::ShaderType shaderType, std::string shaderSource)
    184 {
    185 	tcu::TestLog&	log		= ctx.getLog();
    186 	const char*		source	= shaderSource.c_str();
    187 	const int		length	= (int) shaderSource.size();
    188 	glu::Shader		shader	(ctx.getRenderContext(), shaderType);
    189 
    190 	shader.setSources(1, &source, &length);
    191 	shader.compile();
    192 
    193 	log << shader;
    194 	if (shader.getCompileStatus())
    195 	{
    196 		log << tcu::TestLog::Message << "Expected shader to fail, but compilation passed." << tcu::TestLog::EndMessage;
    197 		ctx.fail("Shader was not expected to compile.\n");
    198 	}
    199 }
    200 
    201 std::string declareAndInitializeShaderVariable (glu::DataType dataType, std::string varName)
    202 {
    203 	std::ostringstream variable;
    204 	variable << getDataTypeName(dataType) << " " << varName << " = " << getDataTypeName(dataType);
    205 	switch (dataType)
    206 	{
    207 		case glu::TYPE_FLOAT:		variable << "(1.0);\n";					break;
    208 		case glu::TYPE_FLOAT_VEC2:	variable << "(1.0, 1.0);\n";			break;
    209 		case glu::TYPE_FLOAT_VEC3:	variable << "(1.0, 1.0, 1.0);\n";		break;
    210 		case glu::TYPE_FLOAT_VEC4:	variable << "(1.0, 1.0, 1.0, 1.0);\n";	break;
    211 		case glu::TYPE_INT:			variable << "(1);\n";					break;
    212 		case glu::TYPE_INT_VEC2:	variable << "(1, 1);\n";				break;
    213 		case glu::TYPE_INT_VEC3:	variable << "(1, 1, 1);\n";				break;
    214 		case glu::TYPE_INT_VEC4:	variable << "(1, 1, 1, 1);\n";			break;
    215 		case glu::TYPE_UINT:		variable << "(1u);\n";					break;
    216 		case glu::TYPE_UINT_VEC2:	variable << "(1u, 1u);\n";				break;
    217 		case glu::TYPE_UINT_VEC3:	variable << "(1u, 1u, 1u);\n";			break;
    218 		case glu::TYPE_UINT_VEC4:	variable << "(1u, 1u, 1u, 1u);\n";		break;
    219 		default:
    220 			DE_FATAL("Unsupported data type.");
    221 	}
    222 	return variable.str();
    223 }
    224 
    225 std::string declareShaderUniform (glu::DataType dataType, std::string varName)
    226 {
    227 	std::ostringstream variable;
    228 	variable << getPrecisionName(glu::PRECISION_HIGHP) << " uniform " << getDataTypeName(dataType) << " " << varName << ";\n";
    229 	return variable.str();
    230 }
    231 
    232 std::string declareShaderInput (glu::DataType dataType, std::string varName)
    233 {
    234 	std::ostringstream variable;
    235 	variable << "in " << getPrecisionName(glu::PRECISION_HIGHP) << " " << getDataTypeName(dataType) << " " << varName << ";\n";
    236 	return variable.str();
    237 }
    238 
    239 std::string declareBuffer (glu::DataType dataType, std::string varName)
    240 {
    241 	std::ostringstream variable;
    242 	variable	<< "buffer SSBO {\n"
    243 				<< "    " << getDataTypeName(dataType) << " " << varName << ";\n"
    244 				<< "};\n";
    245 	return variable.str();
    246 }
    247 
    248 std::string declareShaderArrayVariable (glu::DataType dataType, std::string varName, const int arraySize)
    249 {
    250 	std::ostringstream source;
    251 	source << getDataTypeName(dataType) << " " << varName << "[" << arraySize << "]" << " = " << getDataTypeName(dataType) << "[](";
    252 
    253 	for (int ndx = 0; ndx < arraySize; ++ndx)
    254 		source << getDataTypeName(dataType) << "(" << 0 << ", " << 0 << ")" << ((ndx < arraySize -1) ? ", " : "");
    255 
    256 	source << ");";
    257 	return source.str();
    258 }
    259 
    260 std::string getShaderExtensionDeclaration (std::string extension)
    261 {
    262 	if (extension.empty())
    263 		return std::string("");
    264 	else
    265 	{
    266 		std::ostringstream source;
    267 		source << "#extension " << extension << " : enable\n";
    268 		return source.str();
    269 	}
    270 }
    271 
    272 std::string getDataTypeExtension (glu::DataType dataType)
    273 {
    274 	std::ostringstream source;
    275 	switch (dataType)
    276 	{
    277 		case glu::TYPE_SAMPLER_CUBE_ARRAY:
    278 		case glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW:
    279 		case glu::TYPE_INT_SAMPLER_CUBE_ARRAY:
    280 		case glu::TYPE_UINT_SAMPLER_CUBE_ARRAY:
    281 			source << "GL_EXT_texture_cube_map_array";
    282 			break;
    283 
    284 		case glu::TYPE_SAMPLER_BUFFER:
    285 		case glu::TYPE_INT_SAMPLER_BUFFER:
    286 		case glu::TYPE_UINT_SAMPLER_BUFFER:
    287 			source << "GL_EXT_texture_buffer";
    288 			break;
    289 
    290 		case glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY:
    291 		case glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
    292 		case glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY:
    293 			source << "GL_OES_texture_storage_multisample_2d_array";
    294 			break;
    295 
    296 		default:
    297 			break;
    298 	}
    299 
    300 	return source.str();
    301 }
    302 
    303 std::string getShaderInitialization (NegativeTestContext& ctx, glu::ShaderType shaderType)
    304 {
    305 	std::ostringstream source;
    306 
    307 	if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
    308 	{
    309 		switch (shaderType)
    310 		{
    311 			case glu::SHADERTYPE_GEOMETRY:
    312 				source << "#extension GL_EXT_geometry_shader : enable\n";
    313 				break;
    314 
    315 			case glu::SHADERTYPE_TESSELLATION_CONTROL:
    316 				source << "#extension GL_EXT_tessellation_shader : enable\n";
    317 				break;
    318 
    319 			case glu::SHADERTYPE_TESSELLATION_EVALUATION:
    320 				source << "#extension GL_EXT_tessellation_shader : enable\n";
    321 				break;
    322 
    323 			default:
    324 				break;
    325 		}
    326 	}
    327 
    328 	switch (shaderType)
    329 	{
    330 		case glu::SHADERTYPE_GEOMETRY:
    331 			source << "layout(max_vertices = 5) out;\n";
    332 			break;
    333 
    334 		case glu::SHADERTYPE_TESSELLATION_CONTROL:
    335 			source << "layout(vertices = 3) out;\n";
    336 			break;
    337 
    338 		case glu::SHADERTYPE_TESSELLATION_EVALUATION:
    339 			source << "layout(triangles, equal_spacing, cw) in;\n";
    340 			break;
    341 
    342 		default:
    343 			break;
    344 	}
    345 
    346 	return source.str();
    347 }
    348 
    349 std::string genShaderSourceBitfieldExtract (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType valueDataType, glu::DataType offsetDataType, glu::DataType bitsDataType)
    350 {
    351 	std::ostringstream source;
    352 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
    353 			<< getShaderInitialization(ctx, shaderType)
    354 			<< "void main(void)\n"
    355 			<< "{\n"
    356 			<< "    " << declareAndInitializeShaderVariable(valueDataType, "value")
    357 			<< "    " << declareAndInitializeShaderVariable(offsetDataType, "offset")
    358 			<< "    " << declareAndInitializeShaderVariable(bitsDataType, "bits")
    359 			<< "    bitfieldExtract(value, offset, bits);\n"
    360 			<< "}\n";
    361 
    362 	return source.str();
    363 }
    364 
    365 void bitfield_extract_invalid_value_type (NegativeTestContext& ctx)
    366 {
    367 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_intTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    368 
    369 	ctx.beginSection("bitfieldExtract: Invalid value type.");
    370 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    371 	{
    372 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    373 		{
    374 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    375 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    376 			{
    377 				const std::string shaderSource(genShaderSourceBitfieldExtract(ctx, s_shaders[shaderNdx], s_floatTypes[dataTypeNdx], glu::TYPE_INT, glu::TYPE_INT));
    378 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    379 			}
    380 			ctx.endSection();
    381 		}
    382 	}
    383 	ctx.endSection();
    384 }
    385 
    386 void bitfield_extract_invalid_offset_type (NegativeTestContext& ctx)
    387 {
    388 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_intTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    389 
    390 	ctx.beginSection("bitfieldExtract: Invalid offset type.");
    391 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    392 	{
    393 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    394 		{
    395 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    396 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
    397 			{
    398 				for (int nonIntNdx = 0; nonIntNdx < DE_LENGTH_OF_ARRAY(s_nonScalarIntTypes); ++nonIntNdx)
    399 				{
    400 					{
    401 						const std::string shaderSource(genShaderSourceBitfieldExtract(ctx, s_shaders[shaderNdx], s_intTypes[dataTypeNdx], s_nonScalarIntTypes[nonIntNdx], glu::TYPE_INT));
    402 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    403 					}
    404 					{
    405 						const std::string shaderSource(genShaderSourceBitfieldExtract(ctx, s_shaders[shaderNdx], s_uintTypes[dataTypeNdx], s_nonScalarIntTypes[nonIntNdx], glu::TYPE_INT));
    406 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    407 					}
    408 				}
    409 			}
    410 			ctx.endSection();
    411 		}
    412 	}
    413 	ctx.endSection();
    414 }
    415 
    416 void bitfield_extract_invalid_bits_type (NegativeTestContext& ctx)
    417 {
    418 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_intTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    419 
    420 	ctx.beginSection("bitfieldExtract: Invalid bits type.");
    421 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    422 	{
    423 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    424 		{
    425 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    426 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
    427 			{
    428 				for (int nonIntNdx = 0; nonIntNdx < DE_LENGTH_OF_ARRAY(s_nonScalarIntTypes); ++nonIntNdx)
    429 				{
    430 					{
    431 						const std::string shaderSource(genShaderSourceBitfieldExtract(ctx, s_shaders[shaderNdx], s_intTypes[dataTypeNdx], glu::TYPE_INT, s_nonScalarIntTypes[nonIntNdx]));
    432 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    433 					}
    434 					{
    435 						const std::string shaderSource(genShaderSourceBitfieldExtract(ctx, s_shaders[shaderNdx], s_uintTypes[dataTypeNdx], glu::TYPE_INT, s_nonScalarIntTypes[nonIntNdx]));
    436 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    437 					}
    438 				}
    439 			}
    440 			ctx.endSection();
    441 		}
    442 	}
    443 	ctx.endSection();
    444 }
    445 
    446 std::string genShaderSourceBitfieldInsert (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType baseDataType, glu::DataType insertDataType, glu::DataType offsetDataType, glu::DataType bitsDataType)
    447 {
    448 	std::ostringstream source;
    449 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
    450 			<< getShaderInitialization(ctx, shaderType)
    451 			<< "void main(void)\n"
    452 			<< "{\n"
    453 			<< "    " << declareAndInitializeShaderVariable(baseDataType, "base")
    454 			<< "    " << declareAndInitializeShaderVariable(insertDataType, "insert")
    455 			<< "    " << declareAndInitializeShaderVariable(offsetDataType, "offset")
    456 			<< "    " << declareAndInitializeShaderVariable(bitsDataType, "bits")
    457 			<< "    bitfieldInsert(base, insert, offset, bits);\n"
    458 			<< "}\n";
    459 
    460 	return source.str();
    461 }
    462 
    463 void bitfield_insert_invalid_base_type (NegativeTestContext& ctx)
    464 {
    465 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_intTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    466 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_intTypes) == DE_LENGTH_OF_ARRAY(s_floatTypes));
    467 
    468 	ctx.beginSection("bitfieldInsert: Invalid base type.");
    469 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    470 	{
    471 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    472 		{
    473 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    474 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    475 			{
    476 				{
    477 					const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_floatTypes[dataTypeNdx], s_intTypes[dataTypeNdx], glu::TYPE_INT, glu::TYPE_INT));
    478 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    479 				}
    480 				{
    481 					const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], glu::TYPE_INT, glu::TYPE_INT));
    482 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    483 				}
    484 			}
    485 			ctx.endSection();
    486 		}
    487 	}
    488 	ctx.endSection();
    489 }
    490 
    491 void bitfield_insert_invalid_insert_type (NegativeTestContext& ctx)
    492 {
    493 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_intTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    494 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_intTypes) == DE_LENGTH_OF_ARRAY(s_floatTypes));
    495 
    496 	ctx.beginSection("bitfieldInsert: Invalid insert type.");
    497 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    498 	{
    499 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    500 		{
    501 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    502 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
    503 			{
    504 				{
    505 					const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_intTypes[dataTypeNdx], s_floatTypes[dataTypeNdx], glu::TYPE_INT, glu::TYPE_INT));
    506 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    507 				}
    508 				{
    509 					const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_uintTypes[dataTypeNdx], s_floatTypes[dataTypeNdx], glu::TYPE_INT, glu::TYPE_INT));
    510 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    511 				}
    512 
    513 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx2)
    514 				{
    515 					if (s_intTypes[dataTypeNdx] == s_intTypes[dataTypeNdx2])
    516 						continue;
    517 
    518 					{
    519 						const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx2], glu::TYPE_INT, glu::TYPE_INT));
    520 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    521 					}
    522 					{
    523 						const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx2], glu::TYPE_INT, glu::TYPE_INT));
    524 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    525 					}
    526 				}
    527 
    528 			}
    529 			ctx.endSection();
    530 		}
    531 	}
    532 	ctx.endSection();
    533 }
    534 
    535 void bitfield_insert_invalid_offset_type (NegativeTestContext& ctx)
    536 {
    537 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_intTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    538 
    539 	ctx.beginSection("bitfieldInsert: Invalid offset type.");
    540 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    541 	{
    542 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    543 		{
    544 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    545 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
    546 			{
    547 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_nonScalarIntTypes); ++dataTypeNdx2)
    548 				{
    549 					{
    550 						const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_nonScalarIntTypes[dataTypeNdx2], glu::TYPE_INT));
    551 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    552 					}
    553 					{
    554 						const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_nonScalarIntTypes[dataTypeNdx2], glu::TYPE_INT));
    555 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    556 					}
    557 				}
    558 			}
    559 			ctx.endSection();
    560 		}
    561 	}
    562 	ctx.endSection();
    563 }
    564 
    565 void bitfield_insert_invalid_bits_type (NegativeTestContext& ctx)
    566 {
    567 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_intTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    568 
    569 	ctx.beginSection("bitfieldInsert: Invalid bits type.");
    570 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    571 	{
    572 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    573 		{
    574 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    575 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
    576 			{
    577 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_nonScalarIntTypes); ++dataTypeNdx2)
    578 				{
    579 					{
    580 						const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], glu::TYPE_INT, s_nonScalarIntTypes[dataTypeNdx2]));
    581 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    582 					}
    583 					{
    584 						const std::string shaderSource(genShaderSourceBitfieldInsert(ctx, s_shaders[shaderNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], glu::TYPE_INT, s_nonScalarIntTypes[dataTypeNdx2]));
    585 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    586 					}
    587 				}
    588 			}
    589 			ctx.endSection();
    590 		}
    591 	}
    592 	ctx.endSection();
    593 }
    594 
    595 // bitfieldReverse, bitCount, findMSB, findLSB
    596 std::string genShaderSourceReverseCountFind (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType baseDataType)
    597 {
    598 	DE_ASSERT(function == SHADER_FUNCTION_BITFIELD_REVERSE ||
    599 		function == SHADER_FUNCTION_BIT_COUNT ||
    600 		function == SHADER_FUNCTION_FIND_MSB ||
    601 		function == SHADER_FUNCTION_FIND_LSB);
    602 
    603 	std::ostringstream source;
    604 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
    605 			<< getShaderInitialization(ctx, shaderType)
    606 			<< "void main(void)\n"
    607 			<< "{\n"
    608 			<< "    " << declareAndInitializeShaderVariable(baseDataType, "value");
    609 
    610 	switch (function)
    611 	{
    612 		case SHADER_FUNCTION_BITFIELD_REVERSE:	source << "    bitfieldReverse(value);\n";	break;
    613 		case SHADER_FUNCTION_BIT_COUNT:			source << "    bitCount(value);\n";			break;
    614 		case SHADER_FUNCTION_FIND_MSB:			source << "    findMSB(value);\n";			break;
    615 		case SHADER_FUNCTION_FIND_LSB:			source << "    findLSB(value);\n";			break;
    616 		default:
    617 			DE_FATAL("Unsupported shader function.");
    618 	}
    619 
    620 	source << "}\n";
    621 
    622 	return source.str();
    623 }
    624 
    625 
    626 void bitfield_reverse (NegativeTestContext& ctx)
    627 {
    628 	ctx.beginSection("bitfieldReverse: Invalid value type.");
    629 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    630 	{
    631 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    632 		{
    633 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    634 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    635 			{
    636 				const std::string shaderSource(genShaderSourceReverseCountFind(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_BITFIELD_REVERSE, s_floatTypes[dataTypeNdx]));
    637 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    638 			}
    639 			ctx.endSection();
    640 		}
    641 	}
    642 	ctx.endSection();
    643 }
    644 
    645 void bit_count (NegativeTestContext& ctx)
    646 {
    647 	ctx.beginSection("bitCount: Invalid value type.");
    648 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    649 	{
    650 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    651 		{
    652 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    653 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    654 			{
    655 				const std::string shaderSource(genShaderSourceReverseCountFind(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_BIT_COUNT, s_floatTypes[dataTypeNdx]));
    656 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    657 			}
    658 			ctx.endSection();
    659 		}
    660 	}
    661 	ctx.endSection();
    662 }
    663 
    664 void find_msb (NegativeTestContext& ctx)
    665 {
    666 	ctx.beginSection("findMSB: Invalid value type.");
    667 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    668 	{
    669 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    670 		{
    671 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    672 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    673 			{
    674 				const std::string shaderSource(genShaderSourceReverseCountFind(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_FIND_MSB, s_floatTypes[dataTypeNdx]));
    675 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    676 			}
    677 			ctx.endSection();
    678 		}
    679 	}
    680 	ctx.endSection();
    681 }
    682 
    683 void find_lsb (NegativeTestContext& ctx)
    684 {
    685 	ctx.beginSection("findLSB: Invalid value type.");
    686 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    687 	{
    688 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    689 		{
    690 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    691 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    692 			{
    693 				const std::string shaderSource(genShaderSourceReverseCountFind(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_FIND_LSB, s_floatTypes[dataTypeNdx]));
    694 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    695 			}
    696 			ctx.endSection();
    697 		}
    698 	}
    699 	ctx.endSection();
    700 }
    701 
    702 // uaddCarry, usubBorrow
    703 std::string genShaderSourceAddCarrySubBorrow (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType xDataType, glu::DataType yDataType, glu::DataType carryBorrowDataType)
    704 {
    705 	DE_ASSERT(function == SHADER_FUNCTION_UADD_CARRY || function == SHADER_FUNCTION_USUB_BORROW);
    706 
    707 	std::ostringstream source;
    708 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
    709 			<< getShaderInitialization(ctx, shaderType)
    710 			<< "void main(void)\n"
    711 			<< "{\n"
    712 			<< "    " << declareAndInitializeShaderVariable(xDataType, "x")
    713 			<< "    " << declareAndInitializeShaderVariable(yDataType, "y");
    714 
    715 	switch (function)
    716 	{
    717 		case SHADER_FUNCTION_UADD_CARRY:
    718 			source	<< "    " << declareAndInitializeShaderVariable(carryBorrowDataType, "carry")
    719 					<< "    uaddCarry(x, y, carry);\n";
    720 			break;
    721 
    722 		case SHADER_FUNCTION_USUB_BORROW:
    723 			source	<< "    " << declareAndInitializeShaderVariable(carryBorrowDataType, "borrow")
    724 					<< "    usubBorrow(x, y, borrow);\n";
    725 			break;
    726 
    727 		default:
    728 			DE_FATAL("Unsupported shader function.");
    729 	}
    730 
    731 	source << "}\n";
    732 
    733 	return source.str();
    734 }
    735 
    736 void uadd_carry_invalid_x (NegativeTestContext& ctx)
    737 {
    738 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    739 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
    740 
    741 	ctx.beginSection("uaddCarry: Invalid x type.");
    742 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    743 	{
    744 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    745 		{
    746 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    747 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    748 			{
    749 				{
    750 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UADD_CARRY, s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    751 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    752 				}
    753 				{
    754 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UADD_CARRY, s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    755 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    756 				}
    757 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx2)
    758 				{
    759 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
    760 						continue;
    761 
    762 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UADD_CARRY, s_uintTypes[dataTypeNdx2], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    763 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    764 				}
    765 			}
    766 			ctx.endSection();
    767 		}
    768 	}
    769 	ctx.endSection();
    770 }
    771 
    772 void uadd_carry_invalid_y (NegativeTestContext& ctx)
    773 {
    774 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    775 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
    776 
    777 	ctx.beginSection("uaddCarry: Invalid y type.");
    778 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    779 	{
    780 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    781 		{
    782 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    783 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    784 			{
    785 				{
    786 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UADD_CARRY, s_uintTypes[dataTypeNdx], s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    787 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    788 				}
    789 				{
    790 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UADD_CARRY, s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    791 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    792 				}
    793 
    794 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx2)
    795 				{
    796 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
    797 						continue;
    798 
    799 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UADD_CARRY, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx2], s_uintTypes[dataTypeNdx]));
    800 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    801 				}
    802 			}
    803 			ctx.endSection();
    804 		}
    805 	}
    806 	ctx.endSection();
    807 }
    808 
    809 void uadd_carry_invalid_carry (NegativeTestContext& ctx)
    810 {
    811 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    812 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
    813 
    814 	ctx.beginSection("uaddCarry: Invalid carry type.");
    815 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    816 	{
    817 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    818 		{
    819 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    820 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    821 			{
    822 				{
    823 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UADD_CARRY, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_floatTypes[dataTypeNdx]));
    824 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    825 				}
    826 				{
    827 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UADD_CARRY, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
    828 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    829 				}
    830 
    831 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx2)
    832 				{
    833 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
    834 						continue;
    835 
    836 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UADD_CARRY, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx2]));
    837 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    838 				}
    839 			}
    840 			ctx.endSection();
    841 		}
    842 	}
    843 	ctx.endSection();
    844 }
    845 
    846 void usub_borrow_invalid_x (NegativeTestContext& ctx)
    847 {
    848 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    849 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
    850 
    851 	ctx.beginSection("usubBorrow: Invalid x type.");
    852 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    853 	{
    854 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    855 		{
    856 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    857 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    858 			{
    859 				{
    860 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_USUB_BORROW, s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    861 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    862 				}
    863 				{
    864 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_USUB_BORROW, s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    865 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    866 				}
    867 
    868 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx2)
    869 				{
    870 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
    871 						continue;
    872 
    873 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_USUB_BORROW, s_uintTypes[dataTypeNdx2], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    874 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    875 				}
    876 			}
    877 			ctx.endSection();
    878 		}
    879 	}
    880 	ctx.endSection();
    881 }
    882 
    883 void usub_borrow_invalid_y (NegativeTestContext& ctx)
    884 {
    885 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    886 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
    887 
    888 	ctx.beginSection("usubBorrow: Invalid y type.");
    889 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    890 	{
    891 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    892 		{
    893 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    894 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    895 			{
    896 				{
    897 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_USUB_BORROW, s_uintTypes[dataTypeNdx], s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    898 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    899 				}
    900 				{
    901 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_USUB_BORROW, s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
    902 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    903 				}
    904 
    905 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx2)
    906 				{
    907 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
    908 						continue;
    909 
    910 					const std::string shaderSource = genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_USUB_BORROW, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx2], s_uintTypes[dataTypeNdx]);
    911 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    912 				}
    913 			}
    914 			ctx.endSection();
    915 		}
    916 	}
    917 	ctx.endSection();
    918 }
    919 
    920 void usub_borrow_invalid_borrow (NegativeTestContext& ctx)
    921 {
    922 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    923 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
    924 
    925 	ctx.beginSection("usubBorrow: Invalid borrow type.");
    926 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    927 	{
    928 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    929 		{
    930 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    931 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
    932 			{
    933 				{
    934 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_USUB_BORROW, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_floatTypes[dataTypeNdx]));
    935 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    936 				}
    937 				{
    938 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_USUB_BORROW, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
    939 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    940 				}
    941 
    942 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx2)
    943 				{
    944 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
    945 						continue;
    946 
    947 					const std::string shaderSource(genShaderSourceAddCarrySubBorrow(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_USUB_BORROW, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx2]));
    948 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
    949 				}
    950 			}
    951 			ctx.endSection();
    952 		}
    953 	}
    954 	ctx.endSection();
    955 }
    956 
    957 // umulExtended, imulExtended
    958 std::string genShaderSourceMulExtended (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType xDataType, glu::DataType yDataType, glu::DataType msbDataType, glu::DataType lsbDataType)
    959 {
    960 	DE_ASSERT(function == SHADER_FUNCTION_UMUL_EXTENDED || function == SHADER_FUNCTION_IMUL_EXTENDED);
    961 
    962 	std::ostringstream source;
    963 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
    964 			<< getShaderInitialization(ctx, shaderType)
    965 			<< "void main(void)\n"
    966 			<< "{\n"
    967 			<< "    " << declareAndInitializeShaderVariable(xDataType, "x")
    968 			<< "    " << declareAndInitializeShaderVariable(yDataType, "y")
    969 			<< "    " << declareAndInitializeShaderVariable(msbDataType, "msb")
    970 			<< "    " << declareAndInitializeShaderVariable(lsbDataType, "lsb");
    971 
    972 	switch (function)
    973 	{
    974 		case SHADER_FUNCTION_UMUL_EXTENDED:	source << "    umulExtended(x, y, msb, lsb);\n";	break;
    975 		case SHADER_FUNCTION_IMUL_EXTENDED:	source << "    imulExtended(x, y, msb, lsb);\n";	break;
    976 		default:
    977 			DE_FATAL("Unsupported shader function.");
    978 	}
    979 
    980 	source << "}\n";
    981 
    982 	return source.str();
    983 }
    984 
    985 void umul_extended_invalid_x (NegativeTestContext& ctx)
    986 {
    987 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
    988 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
    989 
    990 	ctx.beginSection("umulExtended: Invalid x type.");
    991 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
    992 	{
    993 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
    994 		{
    995 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
    996 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx)
    997 			{
    998 				{
    999 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1000 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1001 				}
   1002 				{
   1003 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1004 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1005 				}
   1006 
   1007 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx2)
   1008 				{
   1009 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
   1010 						continue;
   1011 
   1012 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx2], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1013 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1014 				}
   1015 			}
   1016 			ctx.endSection();
   1017 		}
   1018 	}
   1019 	ctx.endSection();
   1020 }
   1021 
   1022 void umul_extended_invalid_y (NegativeTestContext& ctx)
   1023 {
   1024 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1025 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1026 
   1027 	ctx.beginSection("umulExtended: Invalid y type.");
   1028 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1029 	{
   1030 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1031 		{
   1032 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1033 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx)
   1034 			{
   1035 				{
   1036 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1037 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1038 				}
   1039 				{
   1040 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1041 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1042 				}
   1043 
   1044 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx2)
   1045 				{
   1046 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
   1047 						continue;
   1048 
   1049 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx2], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1050 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1051 				}
   1052 			}
   1053 			ctx.endSection();
   1054 		}
   1055 	}
   1056 	ctx.endSection();
   1057 }
   1058 
   1059 void umul_extended_invalid_msb (NegativeTestContext& ctx)
   1060 {
   1061 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1062 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1063 
   1064 	ctx.beginSection("umulExtended: Invalid msb type.");
   1065 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1066 	{
   1067 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1068 		{
   1069 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1070 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx)
   1071 			{
   1072 				{
   1073 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1074 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1075 				}
   1076 				{
   1077 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1078 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1079 				}
   1080 
   1081 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx2)
   1082 				{
   1083 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
   1084 						continue;
   1085 
   1086 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx2], s_uintTypes[dataTypeNdx]));
   1087 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1088 				}
   1089 			}
   1090 			ctx.endSection();
   1091 		}
   1092 	}
   1093 	ctx.endSection();
   1094 }
   1095 
   1096 void umul_extended_invalid_lsb (NegativeTestContext& ctx)
   1097 {
   1098 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1099 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1100 
   1101 	ctx.beginSection("umulExtended: Invalid lsb type.");
   1102 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1103 	{
   1104 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1105 		{
   1106 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1107 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx)
   1108 			{
   1109 				{
   1110 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_floatTypes[dataTypeNdx]));
   1111 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1112 				}
   1113 				{
   1114 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1115 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1116 				}
   1117 
   1118 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx2)
   1119 				{
   1120 					if (s_uintTypes[dataTypeNdx2] == s_uintTypes[dataTypeNdx])
   1121 						continue;
   1122 
   1123 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_uintTypes[dataTypeNdx2]));
   1124 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1125 				}
   1126 			}
   1127 			ctx.endSection();
   1128 		}
   1129 	}
   1130 	ctx.endSection();
   1131 }
   1132 
   1133 void imul_extended_invalid_x (NegativeTestContext& ctx)
   1134 {
   1135 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1136 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1137 
   1138 	ctx.beginSection("imulExtended: Invalid x type.");
   1139 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1140 	{
   1141 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1142 		{
   1143 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1144 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
   1145 			{
   1146 				{
   1147 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_floatTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1148 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1149 				}
   1150 				{
   1151 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1152 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1153 				}
   1154 
   1155 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx2)
   1156 				{
   1157 					if (s_intTypes[dataTypeNdx2] == s_intTypes[dataTypeNdx])
   1158 						continue;
   1159 
   1160 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx2], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1161 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1162 				}
   1163 			}
   1164 			ctx.endSection();
   1165 		}
   1166 	}
   1167 	ctx.endSection();
   1168 }
   1169 
   1170 void imul_extended_invalid_y (NegativeTestContext& ctx)
   1171 {
   1172 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1173 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1174 
   1175 	ctx.beginSection("imulExtended: Invalid y type.");
   1176 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1177 	{
   1178 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1179 		{
   1180 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1181 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
   1182 			{
   1183 				{
   1184 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx], s_floatTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1185 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1186 				}
   1187 				{
   1188 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1189 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1190 				}
   1191 
   1192 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx2)
   1193 				{
   1194 					if (s_intTypes[dataTypeNdx2] == s_intTypes[dataTypeNdx])
   1195 						continue;
   1196 
   1197 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx2], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1198 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1199 				}
   1200 			}
   1201 			ctx.endSection();
   1202 		}
   1203 	}
   1204 	ctx.endSection();
   1205 }
   1206 
   1207 void imul_extended_invalid_msb (NegativeTestContext& ctx)
   1208 {
   1209 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1210 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1211 
   1212 	ctx.beginSection("imulExtended: Invalid msb type.");
   1213 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1214 	{
   1215 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1216 		{
   1217 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1218 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
   1219 			{
   1220 				{
   1221 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_floatTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1222 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1223 				}
   1224 				{
   1225 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1226 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1227 				}
   1228 
   1229 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx2)
   1230 				{
   1231 					if (s_intTypes[dataTypeNdx2] == s_intTypes[dataTypeNdx])
   1232 						continue;
   1233 
   1234 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx2], s_intTypes[dataTypeNdx]));
   1235 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1236 				}
   1237 			}
   1238 			ctx.endSection();
   1239 		}
   1240 	}
   1241 	ctx.endSection();
   1242 }
   1243 
   1244 void imul_extended_invalid_lsb (NegativeTestContext& ctx)
   1245 {
   1246 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1247 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1248 
   1249 	ctx.beginSection("imulExtended: Invalid lsb type.");
   1250 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1251 	{
   1252 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1253 		{
   1254 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1255 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
   1256 			{
   1257 				{
   1258 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_floatTypes[dataTypeNdx]));
   1259 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1260 				}
   1261 				{
   1262 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1263 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1264 				}
   1265 
   1266 				for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx2)
   1267 				{
   1268 					if (s_intTypes[dataTypeNdx2] == s_intTypes[dataTypeNdx])
   1269 						continue;
   1270 
   1271 					const std::string shaderSource(genShaderSourceMulExtended(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_IMUL_EXTENDED, s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx2]));
   1272 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1273 				}
   1274 			}
   1275 			ctx.endSection();
   1276 		}
   1277 	}
   1278 	ctx.endSection();
   1279 }
   1280 
   1281 // frexp, ldexp
   1282 std::string genShaderSourceFrexpLdexp (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType xDataType, glu::DataType expDataType)
   1283 {
   1284 	DE_ASSERT(function == SHADER_FUNCTION_FREXP || function == SHADER_FUNCTION_LDEXP);
   1285 
   1286 	std::ostringstream source;
   1287 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   1288 			<< getShaderInitialization(ctx, shaderType)
   1289 			<< "void main(void)\n"
   1290 			<< "{\n"
   1291 			<< "    " << declareAndInitializeShaderVariable(xDataType, "x")
   1292 			<< "    " << declareAndInitializeShaderVariable(expDataType, "exp");
   1293 
   1294 	switch (function)
   1295 	{
   1296 		case SHADER_FUNCTION_FREXP:
   1297 			source << "    frexp(x, exp);\n";
   1298 			break;
   1299 
   1300 		case SHADER_FUNCTION_LDEXP:
   1301 			source << "    ldexp(x, exp);\n";
   1302 			break;
   1303 
   1304 		default:
   1305 			DE_FATAL("Unsupported shader function.");
   1306 	}
   1307 
   1308 	source << "}\n";
   1309 
   1310 	return source.str();
   1311 }
   1312 
   1313 void frexp_invalid_x (NegativeTestContext& ctx)
   1314 {
   1315 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1316 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1317 
   1318 	ctx.beginSection("frexp: Invalid x type.");
   1319 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1320 	{
   1321 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1322 		{
   1323 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1324 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   1325 			{
   1326 				{
   1327 					const std::string shaderSource(genShaderSourceFrexpLdexp(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_FREXP, s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1328 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1329 				}
   1330 				{
   1331 					const std::string shaderSource(genShaderSourceFrexpLdexp(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_FREXP, s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1332 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1333 				}
   1334 			}
   1335 			ctx.endSection();
   1336 		}
   1337 	}
   1338 	ctx.endSection();
   1339 }
   1340 
   1341 void frexp_invalid_exp (NegativeTestContext& ctx)
   1342 {
   1343 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1344 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1345 
   1346 	ctx.beginSection("frexp: Invalid exp type.");
   1347 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1348 	{
   1349 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1350 		{
   1351 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1352 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   1353 			{
   1354 				{
   1355 					const std::string shaderSource(genShaderSourceFrexpLdexp(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_FREXP, s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1356 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1357 				}
   1358 				{
   1359 					const std::string shaderSource(genShaderSourceFrexpLdexp(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_FREXP, s_floatTypes[dataTypeNdx], s_floatTypes[dataTypeNdx]));
   1360 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1361 				}
   1362 			}
   1363 			ctx.endSection();
   1364 		}
   1365 	}
   1366 	ctx.endSection();
   1367 }
   1368 
   1369 void ldexp_invalid_x (NegativeTestContext& ctx)
   1370 {
   1371 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1372 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1373 
   1374 	ctx.beginSection("ldexp: Invalid x type.");
   1375 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1376 	{
   1377 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1378 		{
   1379 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1380 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   1381 			{
   1382 				{
   1383 					const std::string shaderSource(genShaderSourceFrexpLdexp(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_LDEXP, s_intTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1384 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1385 				}
   1386 				{
   1387 					const std::string shaderSource(genShaderSourceFrexpLdexp(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_LDEXP, s_uintTypes[dataTypeNdx], s_intTypes[dataTypeNdx]));
   1388 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1389 				}
   1390 			}
   1391 			ctx.endSection();
   1392 		}
   1393 	}
   1394 	ctx.endSection();
   1395 }
   1396 
   1397 void ldexp_invalid_exp (NegativeTestContext& ctx)
   1398 {
   1399 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1400 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1401 
   1402 	ctx.beginSection("ldexp: Invalid exp type.");
   1403 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1404 	{
   1405 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1406 		{
   1407 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1408 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   1409 			{
   1410 				{
   1411 					const std::string shaderSource(genShaderSourceFrexpLdexp(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_LDEXP, s_floatTypes[dataTypeNdx], s_uintTypes[dataTypeNdx]));
   1412 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1413 				}
   1414 				{
   1415 					const std::string shaderSource(genShaderSourceFrexpLdexp(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_LDEXP, s_floatTypes[dataTypeNdx], s_floatTypes[dataTypeNdx]));
   1416 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1417 				}
   1418 			}
   1419 			ctx.endSection();
   1420 		}
   1421 	}
   1422 	ctx.endSection();
   1423 }
   1424 
   1425 // packUnorm4x8, packSnorm4x8, unpackSnorm4x8, unpackUnorm4x8
   1426 std::string genShaderSourcePackUnpackNorm4x8 (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType dataType)
   1427 {
   1428 	DE_ASSERT(function == SHADER_FUNCTION_PACK_UNORM_4X8 ||
   1429 		function == SHADER_FUNCTION_PACK_SNORM_4X8 ||
   1430 		function == SHADER_FUNCTION_UNPACK_SNORM_4X8 ||
   1431 		function == SHADER_FUNCTION_UNPACK_UNORM_4X8);
   1432 
   1433 	std::ostringstream source;
   1434 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   1435 			<< getShaderInitialization(ctx, shaderType)
   1436 			<< "void main(void)\n"
   1437 			<< "{\n";
   1438 
   1439 	switch (function)
   1440 	{
   1441 		case SHADER_FUNCTION_PACK_UNORM_4X8:
   1442 			source	<< "    mediump " << declareAndInitializeShaderVariable(dataType, "v")
   1443 					<< "    packUnorm4x8(v);\n";
   1444 			break;
   1445 
   1446 		case SHADER_FUNCTION_PACK_SNORM_4X8:
   1447 			source	<< "    mediump " << declareAndInitializeShaderVariable(dataType, "v")
   1448 					<< "    packSnorm4x8(v);\n";
   1449 			break;
   1450 
   1451 		case SHADER_FUNCTION_UNPACK_SNORM_4X8:
   1452 			source	<< "    highp " << declareAndInitializeShaderVariable(dataType, "p")
   1453 					<< "    unpackSnorm4x8(p);\n";
   1454 			break;
   1455 
   1456 		case SHADER_FUNCTION_UNPACK_UNORM_4X8:
   1457 			source	<< "    highp " << declareAndInitializeShaderVariable(dataType, "p")
   1458 					<< "    unpackUnorm4x8(p);\n";
   1459 			break;
   1460 
   1461 		default:
   1462 			DE_FATAL("Unsupported shader function.");
   1463 	}
   1464 
   1465 	source << "}\n";
   1466 
   1467 	return source.str();
   1468 }
   1469 
   1470 void pack_unorm_4x8 (NegativeTestContext& ctx)
   1471 {
   1472 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1473 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1474 
   1475 	ctx.beginSection("packUnorm4x8: Invalid v type.");
   1476 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1477 	{
   1478 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1479 		{
   1480 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1481 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   1482 			{
   1483 				if (s_floatTypes[dataTypeNdx] == glu::TYPE_FLOAT_VEC4)
   1484 					continue;
   1485 
   1486 				const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_PACK_UNORM_4X8, s_floatTypes[dataTypeNdx]));
   1487 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1488 			}
   1489 
   1490 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
   1491 			{
   1492 				{
   1493 					const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_PACK_UNORM_4X8, s_intTypes[dataTypeNdx]));
   1494 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1495 				}
   1496 				{
   1497 					const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_PACK_UNORM_4X8, s_uintTypes[dataTypeNdx]));
   1498 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1499 				}
   1500 			}
   1501 			ctx.endSection();
   1502 		}
   1503 	}
   1504 	ctx.endSection();
   1505 }
   1506 
   1507 void pack_snorm_4x8 (NegativeTestContext& ctx)
   1508 {
   1509 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1510 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1511 
   1512 	ctx.beginSection("packSnorm4x8: Invalid v type.");
   1513 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1514 	{
   1515 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1516 		{
   1517 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1518 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   1519 			{
   1520 				if (s_floatTypes[dataTypeNdx] == glu::TYPE_FLOAT_VEC4)
   1521 					continue;
   1522 
   1523 				const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_PACK_SNORM_4X8, s_floatTypes[dataTypeNdx]));
   1524 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1525 			}
   1526 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
   1527 			{
   1528 				{
   1529 					const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_PACK_SNORM_4X8, s_intTypes[dataTypeNdx]));
   1530 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1531 				}
   1532 				{
   1533 					const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_PACK_SNORM_4X8, s_uintTypes[dataTypeNdx]));
   1534 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1535 				}
   1536 			}
   1537 			ctx.endSection();
   1538 		}
   1539 	}
   1540 	ctx.endSection();
   1541 }
   1542 
   1543 void unpack_snorm_4x8 (NegativeTestContext& ctx)
   1544 {
   1545 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1546 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1547 
   1548 	ctx.beginSection("unpackSnorm4x8: Invalid v type.");
   1549 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1550 	{
   1551 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1552 		{
   1553 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1554 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx)
   1555 			{
   1556 				if (s_uintTypes[dataTypeNdx] == glu::TYPE_UINT)
   1557 					continue;
   1558 
   1559 				const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UNPACK_SNORM_4X8, s_uintTypes[dataTypeNdx]));
   1560 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1561 			}
   1562 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
   1563 			{
   1564 				{
   1565 					const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UNPACK_SNORM_4X8, s_intTypes[dataTypeNdx]));
   1566 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1567 				}
   1568 				{
   1569 					const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UNPACK_SNORM_4X8, s_floatTypes[dataTypeNdx]));
   1570 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1571 				}
   1572 			}
   1573 			ctx.endSection();
   1574 		}
   1575 	}
   1576 	ctx.endSection();
   1577 }
   1578 
   1579 void unpack_unorm_4x8 (NegativeTestContext& ctx)
   1580 {
   1581 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1582 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1583 
   1584 	ctx.beginSection("unpackUnorm4x8: Invalid v type.");
   1585 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1586 	{
   1587 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1588 		{
   1589 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1590 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_uintTypes); ++dataTypeNdx)
   1591 			{
   1592 				if (s_uintTypes[dataTypeNdx] == glu::TYPE_UINT)
   1593 					continue;
   1594 
   1595 				const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UNPACK_UNORM_4X8, s_uintTypes[dataTypeNdx]));
   1596 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1597 			}
   1598 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_intTypes); ++dataTypeNdx)
   1599 			{
   1600 				{
   1601 					const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UNPACK_UNORM_4X8, s_intTypes[dataTypeNdx]));
   1602 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1603 				}
   1604 				{
   1605 					const std::string shaderSource(genShaderSourcePackUnpackNorm4x8(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_UNPACK_UNORM_4X8, s_floatTypes[dataTypeNdx]));
   1606 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1607 				}
   1608 			}
   1609 			ctx.endSection();
   1610 		}
   1611 	}
   1612 	ctx.endSection();
   1613 }
   1614 
   1615 // textureSize
   1616 std::string genShaderSourceTextureSize_sampler (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType lodDataType)
   1617 {
   1618 	std::ostringstream source;
   1619 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   1620 			<< getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
   1621 			<< getShaderInitialization(ctx, shaderType)
   1622 			<< declareShaderUniform(samplerDataType, "sampler")
   1623 			<< "void main(void)\n"
   1624 			<< "{\n";
   1625 
   1626 	switch (samplerDataType)
   1627 	{
   1628 		case glu::TYPE_SAMPLER_2D:
   1629 		case glu::TYPE_INT_SAMPLER_2D:
   1630 		case glu::TYPE_UINT_SAMPLER_2D:
   1631 		case glu::TYPE_SAMPLER_3D:
   1632 		case glu::TYPE_INT_SAMPLER_3D:
   1633 		case glu::TYPE_UINT_SAMPLER_3D:
   1634 		case glu::TYPE_SAMPLER_CUBE:
   1635 		case glu::TYPE_INT_SAMPLER_CUBE:
   1636 		case glu::TYPE_UINT_SAMPLER_CUBE:
   1637 		case glu::TYPE_SAMPLER_2D_ARRAY:
   1638 		case glu::TYPE_INT_SAMPLER_2D_ARRAY:
   1639 		case glu::TYPE_UINT_SAMPLER_2D_ARRAY:
   1640 		case glu::TYPE_SAMPLER_CUBE_SHADOW:
   1641 		case glu::TYPE_SAMPLER_2D_SHADOW:
   1642 		case glu::TYPE_SAMPLER_2D_ARRAY_SHADOW:
   1643 		case glu::TYPE_SAMPLER_CUBE_ARRAY:
   1644 		case glu::TYPE_INT_SAMPLER_CUBE_ARRAY:
   1645 		case glu::TYPE_UINT_SAMPLER_CUBE_ARRAY:
   1646 		case glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW:
   1647 			source << "    textureSize(sampler);\n";
   1648 			break;
   1649 
   1650 		case glu::TYPE_SAMPLER_2D_MULTISAMPLE:
   1651 		case glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE:
   1652 		case glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE:
   1653 		case glu::TYPE_SAMPLER_BUFFER:
   1654 		case glu::TYPE_INT_SAMPLER_BUFFER:
   1655 		case glu::TYPE_UINT_SAMPLER_BUFFER:
   1656 		case glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY:
   1657 		case glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
   1658 		case glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY:
   1659 			source	<< "    " << declareAndInitializeShaderVariable(lodDataType, "lod")
   1660 					<< "    textureSize(sampler, lod);\n";
   1661 			break;
   1662 
   1663 		default:
   1664 			DE_FATAL("Unsupported data type.");
   1665 	}
   1666 
   1667 	source << "}\n";
   1668 
   1669 	return source.str();
   1670 }
   1671 
   1672 void texture_size_invalid_sampler (NegativeTestContext& ctx)
   1673 {
   1674 	ctx.beginSection("textureSize: Invalid sampler type - some overloads take two arguments while others take only one.");
   1675 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1676 	{
   1677 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1678 		{
   1679 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1680 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_samplerTypes); ++dataTypeNdx)
   1681 			{
   1682 				if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(s_samplerTypes[dataTypeNdx])))
   1683 				{
   1684 					ctx.beginSection("Verify sampler data type: " + std::string(getDataTypeName(s_samplerTypes[dataTypeNdx])));
   1685 					const std::string shaderSource(genShaderSourceTextureSize_sampler(ctx, s_shaders[shaderNdx], s_samplerTypes[dataTypeNdx], glu::TYPE_INT));
   1686 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1687 					ctx.endSection();
   1688 				}
   1689 			}
   1690 			ctx.endSection();
   1691 		}
   1692 	}
   1693 	ctx.endSection();
   1694 }
   1695 
   1696 std::string genShaderSourceTextureSize_lod (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType lodDataType)
   1697 {
   1698 	std::ostringstream source;
   1699 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   1700 			<< getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
   1701 			<< getShaderInitialization(ctx, shaderType)
   1702 			<< declareShaderUniform(samplerDataType, "sampler")
   1703 			<< "void main(void)\n"
   1704 			<< "{\n"
   1705 			<< "    " << declareAndInitializeShaderVariable(lodDataType, "lod")
   1706 			<< "    textureSize(sampler, lod);\n"
   1707 			<< "}\n";
   1708 
   1709 	return source.str();
   1710 }
   1711 
   1712 void texture_size_invalid_lod (NegativeTestContext& ctx)
   1713 {
   1714 	ctx.beginSection("textureSize: Invalid lod type.");
   1715 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1716 	{
   1717 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1718 		{
   1719 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1720 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_samplerTypes); ++dataTypeNdx)
   1721 			{
   1722 				if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(s_samplerTypes[dataTypeNdx])))
   1723 				{
   1724 					ctx.beginSection("Verify sampler/lod data type" + std::string(getDataTypeName(s_samplerTypes[dataTypeNdx])));
   1725 					for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_nonScalarIntTypes); ++dataTypeNdx2)
   1726 					{
   1727 						if (s_nonScalarIntTypes[dataTypeNdx2] == glu::TYPE_INT)
   1728 							continue;
   1729 
   1730 						const std::string shaderSource(genShaderSourceTextureSize_lod(ctx, s_shaders[shaderNdx], s_samplerTypes[dataTypeNdx], s_nonScalarIntTypes[dataTypeNdx2]));
   1731 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1732 					}
   1733 					ctx.endSection();
   1734 				}
   1735 			}
   1736 			ctx.endSection();
   1737 		}
   1738 	}
   1739 	ctx.endSection();
   1740 }
   1741 
   1742 // texture
   1743 std::string genShaderSourceTexture (NegativeTestContext& ctx, glu::ShaderType shaderType, FunctionTextureModes mode, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType thirdArgumentDataType)
   1744 {
   1745 	std::ostringstream source;
   1746 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   1747 			<< getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
   1748 			<< getShaderInitialization(ctx, shaderType)
   1749 			<< declareShaderUniform(samplerDataType, "sampler")
   1750 			<< "void main(void)\n"
   1751 			<< "{\n"
   1752 			<< "    highp " << declareAndInitializeShaderVariable(pDataType, "lod");
   1753 
   1754 	switch (mode)
   1755 	{
   1756 		case FUNCTION_TEXTURE_MODE_NO_BIAS_NO_COMPARE:
   1757 			source << "    texture(sampler, lod);\n";
   1758 			break;
   1759 
   1760 		case FUNCTION_TEXTURE_MODE_BIAS_OR_COMPARE:
   1761 			source	<< "    highp " << declareAndInitializeShaderVariable(thirdArgumentDataType, "thirdArgument")
   1762 					<< "    texture(sampler, lod, thirdArgument);\n";
   1763 			break;
   1764 
   1765 		default:
   1766 			DE_FATAL("Unsupported shader function overload.");
   1767 	}
   1768 
   1769 	source << "}\n";
   1770 
   1771 	return source.str();
   1772 }
   1773 
   1774 std::string genShaderSourceTexture (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType)
   1775 {
   1776 	return genShaderSourceTexture(ctx, shaderType, FUNCTION_TEXTURE_MODE_NO_BIAS_NO_COMPARE, samplerDataType, pDataType, glu::TYPE_LAST);
   1777 }
   1778 
   1779 std::string genShaderSourceTexture (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType thirdArgumentDataType)
   1780 {
   1781 	return genShaderSourceTexture(ctx, shaderType, FUNCTION_TEXTURE_MODE_BIAS_OR_COMPARE, samplerDataType, pDataType, thirdArgumentDataType);
   1782 }
   1783 
   1784 void texture_invalid_p (NegativeTestContext& ctx)
   1785 {
   1786 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   1787 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   1788 
   1789 	ctx.beginSection("texture: Invalid P type.");
   1790 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   1791 	{
   1792 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   1793 		{
   1794 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   1795 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   1796 			{
   1797 				// SAMPLER_2D
   1798 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC2)
   1799 				{
   1800 					{
   1801 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_floatTypes[dataTypeNdx]));
   1802 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1803 					}
   1804 					{
   1805 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1806 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1807 					}
   1808 					{
   1809 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_floatTypes[dataTypeNdx]));
   1810 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1811 					}
   1812 					{
   1813 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1814 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1815 					}
   1816 					{
   1817 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_floatTypes[dataTypeNdx]));
   1818 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1819 					}
   1820 					{
   1821 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1822 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1823 					}
   1824 				}
   1825 				{
   1826 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_intTypes[dataTypeNdx]));
   1827 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1828 				}
   1829 				{
   1830 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1831 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1832 				}
   1833 				{
   1834 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_intTypes[dataTypeNdx]));
   1835 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1836 				}
   1837 				{
   1838 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1839 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1840 				}
   1841 				{
   1842 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_intTypes[dataTypeNdx]));
   1843 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1844 				}
   1845 				{
   1846 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1847 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1848 				}
   1849 				{
   1850 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_uintTypes[dataTypeNdx]));
   1851 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1852 				}
   1853 				{
   1854 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1855 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1856 				}
   1857 				{
   1858 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_uintTypes[dataTypeNdx]));
   1859 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1860 				}
   1861 				{
   1862 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1863 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1864 				}
   1865 				{
   1866 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_uintTypes[dataTypeNdx]));
   1867 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1868 				}
   1869 				{
   1870 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1871 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1872 				}
   1873 
   1874 				// SAMPLER_3D
   1875 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC3)
   1876 				{
   1877 					{
   1878 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_floatTypes[dataTypeNdx]));
   1879 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1880 					}
   1881 					{
   1882 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1883 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1884 					}
   1885 					{
   1886 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_floatTypes[dataTypeNdx]));
   1887 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1888 					}
   1889 					{
   1890 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1891 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1892 					}
   1893 					{
   1894 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_floatTypes[dataTypeNdx]));
   1895 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1896 					}
   1897 					{
   1898 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1899 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1900 					}
   1901 				}
   1902 				{
   1903 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_intTypes[dataTypeNdx]));
   1904 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1905 				}
   1906 				{
   1907 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1908 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1909 				}
   1910 				{
   1911 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_intTypes[dataTypeNdx]));
   1912 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1913 				}
   1914 				{
   1915 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1916 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1917 				}
   1918 				{
   1919 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_intTypes[dataTypeNdx]));
   1920 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1921 				}
   1922 				{
   1923 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1924 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1925 				}
   1926 				{
   1927 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_uintTypes[dataTypeNdx]));
   1928 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1929 				}
   1930 				{
   1931 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1932 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1933 				}
   1934 				{
   1935 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_uintTypes[dataTypeNdx]));
   1936 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1937 				}
   1938 				{
   1939 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1940 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1941 				}
   1942 				{
   1943 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_uintTypes[dataTypeNdx]));
   1944 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1945 				}
   1946 				{
   1947 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1948 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1949 				}
   1950 
   1951 				// SAMPLER_CUBE
   1952 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC3)
   1953 				{
   1954 					{
   1955 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_floatTypes[dataTypeNdx]));
   1956 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1957 					}
   1958 					{
   1959 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1960 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1961 					}
   1962 					{
   1963 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_floatTypes[dataTypeNdx]));
   1964 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1965 					}
   1966 					{
   1967 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1968 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1969 					}
   1970 					{
   1971 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_floatTypes[dataTypeNdx]));
   1972 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1973 					}
   1974 					{
   1975 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1976 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1977 					}
   1978 				}
   1979 				{
   1980 					{
   1981 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_intTypes[dataTypeNdx]));
   1982 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1983 					}
   1984 					{
   1985 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1986 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1987 					}
   1988 					{
   1989 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_intTypes[dataTypeNdx]));
   1990 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1991 					}
   1992 					{
   1993 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   1994 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1995 					}
   1996 					{
   1997 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_intTypes[dataTypeNdx]));
   1998 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   1999 					}
   2000 					{
   2001 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2002 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2003 					}
   2004 				}
   2005 				{
   2006 					{
   2007 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_uintTypes[dataTypeNdx]));
   2008 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2009 					}
   2010 					{
   2011 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2012 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2013 					}
   2014 					{
   2015 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_uintTypes[dataTypeNdx]));
   2016 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2017 					}
   2018 					{
   2019 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2020 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2021 					}
   2022 					{
   2023 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_uintTypes[dataTypeNdx]));
   2024 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2025 					}
   2026 					{
   2027 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2028 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2029 					}
   2030 				}
   2031 
   2032 				// SAMPLER_2D_ARRAY
   2033 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC3)
   2034 				{
   2035 					{
   2036 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx]));
   2037 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2038 					}
   2039 					{
   2040 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2041 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2042 					}
   2043 					{
   2044 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx]));
   2045 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2046 					}
   2047 					{
   2048 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2049 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2050 					}
   2051 					{
   2052 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx]));
   2053 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2054 					}
   2055 					{
   2056 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2057 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2058 					}
   2059 				}
   2060 				{
   2061 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx]));
   2062 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2063 				}
   2064 				{
   2065 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2066 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2067 				}
   2068 				{
   2069 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx]));
   2070 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2071 				}
   2072 				{
   2073 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2074 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2075 				}
   2076 				{
   2077 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx]));
   2078 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2079 				}
   2080 				{
   2081 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2082 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2083 				}
   2084 				{
   2085 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx]));
   2086 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2087 				}
   2088 				{
   2089 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2090 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2091 				}
   2092 				{
   2093 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx]));
   2094 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2095 				}
   2096 				{
   2097 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2098 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2099 				}
   2100 				{
   2101 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx]));
   2102 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2103 				}
   2104 				{
   2105 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2106 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2107 				}
   2108 
   2109 				// SAMPLER_2D_SHADOW
   2110 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC3)
   2111 				{
   2112 					{
   2113 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_floatTypes[dataTypeNdx]));
   2114 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2115 					}
   2116 					{
   2117 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2118 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2119 					}
   2120 				}
   2121 				{
   2122 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_intTypes[dataTypeNdx]));
   2123 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2124 				}
   2125 				{
   2126 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2127 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2128 				}
   2129 				{
   2130 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_uintTypes[dataTypeNdx]));
   2131 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2132 				}
   2133 				{
   2134 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2135 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2136 				}
   2137 
   2138 				// SAMPLER_CUBE_SHADOW
   2139 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
   2140 				{
   2141 					{
   2142 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_floatTypes[dataTypeNdx]));
   2143 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2144 					}
   2145 					{
   2146 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2147 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2148 					}
   2149 				}
   2150 				{
   2151 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_intTypes[dataTypeNdx]));
   2152 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2153 				}
   2154 				{
   2155 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2156 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2157 				}
   2158 				{
   2159 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_uintTypes[dataTypeNdx]));
   2160 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2161 				}
   2162 				{
   2163 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2164 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2165 				}
   2166 
   2167 				// SAMPLER_2D_ARRAY_SHADOW
   2168 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
   2169 				{
   2170 					{
   2171 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_floatTypes[dataTypeNdx]));
   2172 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2173 					}
   2174 					{
   2175 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2176 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2177 					}
   2178 				}
   2179 				{
   2180 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_intTypes[dataTypeNdx]));
   2181 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2182 				}
   2183 				{
   2184 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2185 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2186 				}
   2187 				{
   2188 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_uintTypes[dataTypeNdx]));
   2189 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2190 				}
   2191 				{
   2192 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2193 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2194 				}
   2195 
   2196 				// SAMPLER_CUBE_ARRAY
   2197 				if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
   2198 				{
   2199 					if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
   2200 					{
   2201 						{
   2202 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx]));
   2203 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2204 						}
   2205 						{
   2206 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2207 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2208 						}
   2209 						{
   2210 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx]));
   2211 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2212 						}
   2213 						{
   2214 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2215 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2216 						}
   2217 						{
   2218 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx]));
   2219 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2220 						}
   2221 						{
   2222 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2223 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2224 						}
   2225 					}
   2226 					{
   2227 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx]));
   2228 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2229 					}
   2230 					{
   2231 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2232 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2233 					}
   2234 					{
   2235 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx]));
   2236 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2237 					}
   2238 					{
   2239 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2240 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2241 					}
   2242 					{
   2243 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx]));
   2244 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2245 					}
   2246 					{
   2247 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2248 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2249 					}
   2250 					{
   2251 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx]));
   2252 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2253 					}
   2254 					{
   2255 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2256 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2257 					}
   2258 					{
   2259 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx]));
   2260 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2261 					}
   2262 					{
   2263 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2264 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2265 					}
   2266 					{
   2267 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx]));
   2268 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2269 					}
   2270 					{
   2271 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2272 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2273 					}
   2274 				}
   2275 
   2276 				// SAMPLER_CUBE_ARRAY_SHADOW
   2277 				if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW)))
   2278 				{
   2279 					if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
   2280 					{
   2281 						std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2282 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2283 					}
   2284 					{
   2285 						std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2286 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2287 					}
   2288 					{
   2289 						std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2290 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2291 					}
   2292 				}
   2293 			}
   2294 			ctx.endSection();
   2295 		}
   2296 	}
   2297 	ctx.endSection();
   2298 }
   2299 
   2300 void texture_invalid_bias_or_compare (NegativeTestContext& ctx)
   2301 {
   2302 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   2303 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   2304 
   2305 	ctx.beginSection("texture: Invalid bias/compare type.");
   2306 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   2307 	{
   2308 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   2309 		{
   2310 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   2311 			for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   2312 			{
   2313 				// SAMPLER_2D
   2314 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
   2315 				{
   2316 					{
   2317 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_floatTypes[dataTypeNdx]));
   2318 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2319 					}
   2320 					{
   2321 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_floatTypes[dataTypeNdx]));
   2322 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2323 					}
   2324 					{
   2325 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_floatTypes[dataTypeNdx]));
   2326 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2327 					}
   2328 				}
   2329 				{
   2330 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_intTypes[dataTypeNdx]));
   2331 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2332 				}
   2333 				{
   2334 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_uintTypes[dataTypeNdx]));
   2335 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2336 				}
   2337 				{
   2338 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_intTypes[dataTypeNdx]));
   2339 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2340 				}
   2341 				{
   2342 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_uintTypes[dataTypeNdx]));
   2343 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2344 				}
   2345 				{
   2346 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_intTypes[dataTypeNdx]));
   2347 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2348 				}
   2349 				{
   2350 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_uintTypes[dataTypeNdx]));
   2351 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2352 				}
   2353 
   2354 				// SAMPLER_3D
   2355 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
   2356 				{
   2357 					{
   2358 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
   2359 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2360 					}
   2361 					{
   2362 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
   2363 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2364 					}
   2365 					{
   2366 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
   2367 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2368 					}
   2369 				}
   2370 				{
   2371 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2372 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2373 				}
   2374 				{
   2375 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2376 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2377 				}
   2378 				{
   2379 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2380 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2381 				}
   2382 				{
   2383 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2384 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2385 				}
   2386 				{
   2387 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2388 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2389 				}
   2390 				{
   2391 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2392 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2393 				}
   2394 
   2395 				// SAMPLER_CUBE
   2396 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
   2397 				{
   2398 					std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
   2399 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2400 					shaderSource = genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]);
   2401 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2402 					shaderSource = genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]);
   2403 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2404 				}
   2405 				{
   2406 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2407 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2408 				}
   2409 				{
   2410 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2411 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2412 				}
   2413 				{
   2414 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2415 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2416 				}
   2417 				{
   2418 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2419 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2420 				}
   2421 				{
   2422 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2423 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2424 				}
   2425 				{
   2426 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2427 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2428 				}
   2429 
   2430 				// SAMPLER_2D_ARRAY
   2431 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
   2432 				{
   2433 					{
   2434 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
   2435 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2436 					}
   2437 					{
   2438 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
   2439 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2440 					}
   2441 					{
   2442 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
   2443 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2444 					}
   2445 				}
   2446 				{
   2447 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2448 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2449 				}
   2450 				{
   2451 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2452 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2453 				}
   2454 				{
   2455 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2456 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2457 				}
   2458 				{
   2459 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2460 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2461 				}
   2462 				{
   2463 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2464 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2465 				}
   2466 				{
   2467 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2468 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2469 				}
   2470 
   2471 				// SAMPLER_2D_SHADOW
   2472 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
   2473 				{
   2474 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
   2475 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2476 				}
   2477 				{
   2478 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
   2479 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2480 				}
   2481 				{
   2482 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
   2483 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2484 				}
   2485 
   2486 				// SAMPLER_CUBE_SHADOW
   2487 				if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
   2488 				{
   2489 					std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
   2490 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2491 				}
   2492 				{
   2493 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
   2494 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2495 				}
   2496 				{
   2497 					const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
   2498 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2499 				}
   2500 
   2501 				// SAMPLER_CUBE_ARRAY
   2502 				if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
   2503 				{
   2504 					if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
   2505 					{
   2506 						{
   2507 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
   2508 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2509 						}
   2510 						{
   2511 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
   2512 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2513 						}
   2514 						{
   2515 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
   2516 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2517 						}
   2518 					}
   2519 					{
   2520 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
   2521 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2522 					}
   2523 					{
   2524 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
   2525 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2526 					}
   2527 					{
   2528 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
   2529 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2530 					}
   2531 					{
   2532 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
   2533 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2534 					}
   2535 					{
   2536 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
   2537 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2538 					}
   2539 					{
   2540 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
   2541 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2542 					}
   2543 				}
   2544 
   2545 				// SAMPLER_CUBE_ARRAY_SHADOW
   2546 				if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW)))
   2547 				{
   2548 					if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
   2549 					{
   2550 						{
   2551 							const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
   2552 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2553 						}
   2554 					}
   2555 					{
   2556 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
   2557 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2558 					}
   2559 					{
   2560 						const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
   2561 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2562 					}
   2563 				}
   2564 			}
   2565 			ctx.endSection();
   2566 		}
   2567 	}
   2568 	ctx.endSection();
   2569 }
   2570 
   2571 // textureLod
   2572 std::string genShaderSourceTextureLod (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType lodDataType)
   2573 {
   2574 	std::ostringstream source;
   2575 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   2576 			<< getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
   2577 			<< getShaderInitialization(ctx, shaderType)
   2578 			<< declareShaderUniform(samplerDataType, "sampler")
   2579 			<< "void main(void)\n"
   2580 			<< "{\n"
   2581 			<< "    " << declareAndInitializeShaderVariable(pDataType, "P")
   2582 			<< "    " << declareAndInitializeShaderVariable(lodDataType, "lod")
   2583 			<< "    textureLod(sampler, P, lod);\n"
   2584 			<< "}\n";
   2585 
   2586 	return source.str();
   2587 }
   2588 
   2589 void texture_lod_invalid_p (NegativeTestContext& ctx)
   2590 {
   2591 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   2592 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   2593 
   2594 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
   2595 	{
   2596 		ctx.beginSection("textureLod: Invalid P type.");
   2597 		for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   2598 		{
   2599 			if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   2600 			{
   2601 				ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   2602 				for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   2603 				{
   2604 					if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
   2605 					{
   2606 						{
   2607 							const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2608 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2609 						}
   2610 						{
   2611 							const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2612 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2613 						}
   2614 						{
   2615 							const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2616 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2617 						}
   2618 					}
   2619 					{
   2620 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2621 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2622 					}
   2623 					{
   2624 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2625 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2626 					}
   2627 					{
   2628 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2629 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2630 					}
   2631 					{
   2632 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2633 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2634 					}
   2635 					{
   2636 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2637 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2638 					}
   2639 					{
   2640 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
   2641 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2642 					}
   2643 				}
   2644 				ctx.endSection();
   2645 			}
   2646 		}
   2647 		ctx.endSection();
   2648 	}
   2649 }
   2650 
   2651 void texture_lod_invalid_lod (NegativeTestContext& ctx)
   2652 {
   2653 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   2654 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   2655 
   2656 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
   2657 	{
   2658 		ctx.beginSection("textureLod: Invalid lod type.");
   2659 		for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   2660 		{
   2661 			if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   2662 			{
   2663 				ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   2664 				for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   2665 				{
   2666 					if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
   2667 					{
   2668 						{
   2669 							const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, s_floatTypes[dataTypeNdx]));
   2670 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2671 						}
   2672 						{
   2673 							const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, s_floatTypes[dataTypeNdx]));
   2674 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2675 						}
   2676 						{
   2677 							const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, s_floatTypes[dataTypeNdx]));
   2678 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2679 						}
   2680 					}
   2681 					{
   2682 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
   2683 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2684 					}
   2685 					{
   2686 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
   2687 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2688 					}
   2689 					{
   2690 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
   2691 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2692 					}
   2693 					{
   2694 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
   2695 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2696 					}
   2697 					{
   2698 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
   2699 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2700 					}
   2701 					{
   2702 						const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
   2703 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2704 					}
   2705 				}
   2706 				ctx.endSection();
   2707 			}
   2708 		}
   2709 		ctx.endSection();
   2710 	}
   2711 }
   2712 
   2713 // texelFetch
   2714 std::string genShaderSourceTexelFetch (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType sampleDataType)
   2715 {
   2716 	std::ostringstream source;
   2717 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   2718 			<< getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
   2719 			<< getShaderInitialization(ctx, shaderType)
   2720 			<< declareShaderUniform(samplerDataType, "sampler")
   2721 			<< "void main(void)\n"
   2722 			<< "{\n"
   2723 			<< "    " << declareAndInitializeShaderVariable(pDataType, "P");
   2724 
   2725 	switch (samplerDataType)
   2726 	{
   2727 		case glu::TYPE_SAMPLER_2D_MULTISAMPLE:
   2728 		case glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE:
   2729 		case glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE:
   2730 		case glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY:
   2731 		case glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
   2732 		case glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY:
   2733 			source	<< "    " << declareAndInitializeShaderVariable(sampleDataType, "varSample")
   2734 					<< "    texelFetch(sampler, P, varSample);\n";
   2735 			break;
   2736 
   2737 		case glu::TYPE_SAMPLER_BUFFER:
   2738 		case glu::TYPE_INT_SAMPLER_BUFFER:
   2739 		case glu::TYPE_UINT_SAMPLER_BUFFER:
   2740 			source << "    texelFetch(sampler, P);\n";
   2741 			break;
   2742 
   2743 		default:
   2744 			DE_FATAL("Unsupported data type.");
   2745 	}
   2746 
   2747 	source << "}\n";
   2748 
   2749 	return source.str();
   2750 }
   2751 
   2752 std::string genShaderSourceTexelFetch (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType)
   2753 {
   2754 	return genShaderSourceTexelFetch(ctx, shaderType, samplerDataType, pDataType, glu::TYPE_LAST);
   2755 }
   2756 
   2757 void texel_fetch_invalid_p (NegativeTestContext& ctx)
   2758 {
   2759 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   2760 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   2761 
   2762 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
   2763 	{
   2764 		ctx.beginSection("texelFetch: Invalid P type.");
   2765 		for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   2766 		{
   2767 			if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   2768 			{
   2769 				ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   2770 				for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   2771 				{
   2772 					// SAMPLER_2D_MULTISAMPLE
   2773 					{
   2774 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
   2775 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2776 					}
   2777 					{
   2778 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
   2779 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2780 					}
   2781 					{
   2782 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
   2783 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2784 					}
   2785 
   2786 					if (s_intTypes[dataTypeNdx] != glu::TYPE_INT_VEC2)
   2787 					{
   2788 						{
   2789 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, s_intTypes[dataTypeNdx], glu::TYPE_INT));
   2790 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2791 						}
   2792 						{
   2793 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, s_intTypes[dataTypeNdx], glu::TYPE_INT));
   2794 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2795 						}
   2796 						{
   2797 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, s_intTypes[dataTypeNdx], glu::TYPE_INT));
   2798 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2799 						}
   2800 					}
   2801 					{
   2802 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
   2803 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2804 					}
   2805 					{
   2806 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
   2807 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2808 					}
   2809 					{
   2810 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
   2811 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2812 					}
   2813 
   2814 					// SAMPLER_BUFFER
   2815 					{
   2816 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_BUFFER, s_floatTypes[dataTypeNdx]));
   2817 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2818 					}
   2819 					{
   2820 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_BUFFER, s_floatTypes[dataTypeNdx]));
   2821 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2822 					}
   2823 					{
   2824 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_BUFFER, s_floatTypes[dataTypeNdx]));
   2825 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2826 					}
   2827 
   2828 					if (s_intTypes[dataTypeNdx] != glu::TYPE_INT)
   2829 					{
   2830 						{
   2831 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_BUFFER, s_intTypes[dataTypeNdx]));
   2832 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2833 						}
   2834 						{
   2835 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_BUFFER, s_intTypes[dataTypeNdx]));
   2836 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2837 						}
   2838 						{
   2839 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_BUFFER, s_intTypes[dataTypeNdx]));
   2840 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2841 						}
   2842 					}
   2843 
   2844 					{
   2845 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_BUFFER, s_uintTypes[dataTypeNdx]));
   2846 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2847 					}
   2848 					{
   2849 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_BUFFER, s_uintTypes[dataTypeNdx]));
   2850 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2851 					}
   2852 					{
   2853 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_BUFFER, s_uintTypes[dataTypeNdx]));
   2854 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2855 					}
   2856 
   2857 					// SAMPLER_2D_MULTISAMPLE_ARRAY
   2858 					{
   2859 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
   2860 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2861 					}
   2862 					{
   2863 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
   2864 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2865 					}
   2866 					{
   2867 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
   2868 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2869 					}
   2870 
   2871 					if (s_intTypes[dataTypeNdx] != glu::TYPE_INT_VEC3)
   2872 					{
   2873 						{
   2874 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_INT));
   2875 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2876 						}
   2877 						{
   2878 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_INT));
   2879 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2880 						}
   2881 						{
   2882 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_INT));
   2883 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2884 						}
   2885 					}
   2886 					{
   2887 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
   2888 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2889 					}
   2890 					{
   2891 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
   2892 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2893 					}
   2894 					{
   2895 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
   2896 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2897 					}
   2898 				}
   2899 				ctx.endSection();
   2900 			}
   2901 		}
   2902 		ctx.endSection();
   2903 	}
   2904 }
   2905 
   2906 void texel_fetch_invalid_sample (NegativeTestContext& ctx)
   2907 {
   2908 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
   2909 	DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
   2910 
   2911 	if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
   2912 	{
   2913 		ctx.beginSection("texelFetch: Invalid sample type.");
   2914 		for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   2915 		{
   2916 			if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   2917 			{
   2918 				ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   2919 				for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
   2920 				{
   2921 					// SAMPLER_2D_MULTISAMPLE
   2922 					{
   2923 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_floatTypes[dataTypeNdx]));
   2924 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2925 					}
   2926 					{
   2927 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_floatTypes[dataTypeNdx]));
   2928 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2929 					}
   2930 					{
   2931 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_floatTypes[dataTypeNdx]));
   2932 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2933 					}
   2934 
   2935 					// SAMPLER_2D_MULTISAMPLE_ARRAY
   2936 					{
   2937 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_floatTypes[dataTypeNdx]));
   2938 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2939 					}
   2940 					{
   2941 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_floatTypes[dataTypeNdx]));
   2942 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2943 					}
   2944 					{
   2945 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_floatTypes[dataTypeNdx]));
   2946 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2947 					}
   2948 
   2949 					if (s_intTypes[dataTypeNdx] != glu::TYPE_INT)
   2950 					{
   2951 						// SAMPLER_2D_MULTISAMPLE
   2952 						{
   2953 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_intTypes[dataTypeNdx]));
   2954 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2955 						}
   2956 						{
   2957 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_intTypes[dataTypeNdx]));
   2958 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2959 						}
   2960 						{
   2961 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_intTypes[dataTypeNdx]));
   2962 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2963 						}
   2964 
   2965 						// SAMPLER_2D_MULTISAMPLE_ARRAY
   2966 						{
   2967 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_intTypes[dataTypeNdx]));
   2968 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2969 						}
   2970 						{
   2971 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_intTypes[dataTypeNdx]));
   2972 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2973 						}
   2974 						{
   2975 							const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_intTypes[dataTypeNdx]));
   2976 							verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2977 						}
   2978 					}
   2979 
   2980 					// SAMPLER_2D_MULTISAMPLE
   2981 					{
   2982 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_uintTypes[dataTypeNdx]));
   2983 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2984 					}
   2985 					{
   2986 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_uintTypes[dataTypeNdx]));
   2987 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2988 					}
   2989 					{
   2990 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_uintTypes[dataTypeNdx]));
   2991 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2992 					}
   2993 
   2994 					// SAMPLER_2D_MULTISAMPLE_ARRAY
   2995 					{
   2996 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_uintTypes[dataTypeNdx]));
   2997 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   2998 					}
   2999 					{
   3000 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_uintTypes[dataTypeNdx]));
   3001 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3002 					}
   3003 					{
   3004 						const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_uintTypes[dataTypeNdx]));
   3005 						verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3006 					}
   3007 				}
   3008 				ctx.endSection();
   3009 			}
   3010 		}
   3011 		ctx.endSection();
   3012 	}
   3013 }
   3014 
   3015 // EmitVertex, EndPrimitive
   3016 std::string genShaderSourceGeometry (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function)
   3017 {
   3018 	DE_ASSERT(function == SHADER_FUNCTION_EMIT_VERTEX || function == SHADER_FUNCTION_END_PRIMITIVE);
   3019 
   3020 	std::ostringstream source;
   3021 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   3022 			<< getShaderInitialization(ctx, shaderType)
   3023 			<< "void main(void)\n"
   3024 			<< "{\n";
   3025 
   3026 	switch (function)
   3027 	{
   3028 		case SHADER_FUNCTION_EMIT_VERTEX:
   3029 			source << "    EmitVertex();\n";
   3030 			break;
   3031 
   3032 		case SHADER_FUNCTION_END_PRIMITIVE:
   3033 			source << "    EndPrimitive();\n";
   3034 			break;
   3035 
   3036 		default:
   3037 			DE_FATAL("Unsupported shader function.");
   3038 	}
   3039 
   3040 	source << "}\n";
   3041 
   3042 	return source.str();
   3043 }
   3044 
   3045 void emit_vertex (NegativeTestContext& ctx)
   3046 {
   3047 	ctx.beginSection("EmitVertex.");
   3048 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3049 	{
   3050 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3051 		{
   3052 			if (s_shaders[shaderNdx] == glu::SHADERTYPE_GEOMETRY)
   3053 				continue;
   3054 
   3055 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3056 			const std::string shaderSource =	genShaderSourceGeometry(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_EMIT_VERTEX);
   3057 			verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3058 			ctx.endSection();
   3059 		}
   3060 	}
   3061 	ctx.endSection();
   3062 }
   3063 
   3064 void end_primitive (NegativeTestContext& ctx)
   3065 {
   3066 	ctx.beginSection("EndPrimitieve.");
   3067 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3068 	{
   3069 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3070 		{
   3071 			if (s_shaders[shaderNdx] == glu::SHADERTYPE_GEOMETRY)
   3072 				continue;
   3073 
   3074 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3075 			const std::string shaderSource =	genShaderSourceGeometry(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_END_PRIMITIVE);
   3076 			verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3077 			ctx.endSection();
   3078 		}
   3079 	}
   3080 	ctx.endSection();
   3081 }
   3082 
   3083 // textureGrad
   3084 std::string genShaderSourceTextureGrad (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType dpdxDataType, glu::DataType dpdyDataType)
   3085 {
   3086 	std::ostringstream source;
   3087 
   3088 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   3089 			<< getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
   3090 			<< getShaderInitialization(ctx, shaderType)
   3091 			<< declareShaderUniform(samplerDataType, "sampler")
   3092 			<< "void main(void)\n"
   3093 			<< "{\n"
   3094 			<< "	mediump " << declareAndInitializeShaderVariable(pDataType, "P")
   3095 			<< "	mediump " << declareAndInitializeShaderVariable(dpdxDataType, "dPdx")
   3096 			<< "	mediump " << declareAndInitializeShaderVariable(dpdyDataType, "dPdy")
   3097 			<< "	textureGrad(sampler, P, dPdx, dPdy);\n"
   3098 			<< "}\n";
   3099 
   3100 	return source.str();
   3101 }
   3102 
   3103 void texture_grad (NegativeTestContext& ctx)
   3104 {
   3105 	TCU_CHECK_AND_THROW(NotSupportedError, ctx.isExtensionSupported("GL_EXT_texture_cube_map_array") || contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "Test requires support for GL_EXT_texture_cube_map_array or version 3.2.");
   3106 
   3107 	ctx.beginSection("textureGrad.");
   3108 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3109 	{
   3110 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3111 		{
   3112 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3113 			{
   3114 				const std::string shaderSource(genShaderSourceTextureGrad(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT_VEC3));
   3115 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3116 			}
   3117 			{
   3118 				const std::string shaderSource(genShaderSourceTextureGrad(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT, glu::TYPE_FLOAT_VEC3));
   3119 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3120 			}
   3121 			{
   3122 				const std::string shaderSource(genShaderSourceTextureGrad(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3123 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3124 			}
   3125 			{
   3126 				const std::string shaderSource(genShaderSourceTextureGrad(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT_VEC3));
   3127 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3128 			}
   3129 			{
   3130 				const std::string shaderSource(genShaderSourceTextureGrad(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT, glu::TYPE_FLOAT_VEC3));
   3131 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3132 			}
   3133 			{
   3134 				const std::string shaderSource(genShaderSourceTextureGrad(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3135 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3136 			}
   3137 			{
   3138 				const std::string shaderSource(genShaderSourceTextureGrad(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT_VEC3));
   3139 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3140 			}
   3141 			{
   3142 				const std::string shaderSource(genShaderSourceTextureGrad(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT, glu::TYPE_FLOAT_VEC3));
   3143 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3144 			}
   3145 			{
   3146 				const std::string shaderSource(genShaderSourceTextureGrad(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3147 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3148 			}
   3149 			ctx.endSection();
   3150 		}
   3151 	}
   3152 	ctx.endSection();
   3153 }
   3154 
   3155 // textureGather
   3156 std::string genShaderSourceTextureGather (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType thirdArgument)
   3157 {
   3158 	std::ostringstream source;
   3159 
   3160 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   3161 			<< getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
   3162 			<< getShaderInitialization(ctx, shaderType)
   3163 			<< declareShaderUniform(samplerDataType, "sampler")
   3164 			<< "void main(void)\n"
   3165 			<< "{\n"
   3166 			<< "	mediump " << declareAndInitializeShaderVariable(pDataType, "P");
   3167 
   3168 	if (thirdArgument != glu::TYPE_LAST)
   3169 		source	<< "	mediump " << declareAndInitializeShaderVariable(thirdArgument, "arg3")
   3170 				<< "	textureGather(sampler, P, arg3);\n";
   3171 	else
   3172 		source << "	textureGather(sampler, P);\n";
   3173 
   3174 	source << "}\n";
   3175 
   3176 	return source.str();
   3177 }
   3178 
   3179 std::string genShaderSourceTextureGather (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType)
   3180 {
   3181 	return genShaderSourceTextureGather(ctx, shaderType, samplerDataType, pDataType, glu::TYPE_LAST);
   3182 }
   3183 
   3184 void texture_gather_sampler_2d (NegativeTestContext& ctx)
   3185 {
   3186 	ctx.beginSection("textureGrad - sampler2D");
   3187 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3188 	{
   3189 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3190 		{
   3191 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3192 			{
   3193 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT));
   3194 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3195 			}
   3196 			{
   3197 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
   3198 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3199 			}
   3200 			{
   3201 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT));
   3202 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3203 			}
   3204 			{
   3205 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT));
   3206 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3207 			}
   3208 			{
   3209 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
   3210 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3211 			}
   3212 			{
   3213 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT));
   3214 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3215 			}
   3216 			{
   3217 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT));
   3218 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3219 			}
   3220 			{
   3221 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
   3222 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3223 			}
   3224 			{
   3225 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT));
   3226 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3227 			}
   3228 			{
   3229 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC2));
   3230 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3231 			}
   3232 			{
   3233 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT));
   3234 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3235 			}
   3236 			ctx.endSection();
   3237 		}
   3238 	}
   3239 	ctx.endSection();
   3240 }
   3241 
   3242 void texture_gather_sampler_2d_array (NegativeTestContext& ctx)
   3243 {
   3244 	ctx.beginSection("textureGrad - sampler2DArray");
   3245 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3246 	{
   3247 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3248 		{
   3249 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3250 			{
   3251 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT));
   3252 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3253 			}
   3254 			{
   3255 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3256 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3257 			}
   3258 			{
   3259 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
   3260 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3261 			}
   3262 			{
   3263 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT));
   3264 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3265 			}
   3266 			{
   3267 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3268 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3269 			}
   3270 			{
   3271 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
   3272 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3273 			}
   3274 			{
   3275 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT));
   3276 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3277 			}
   3278 			{
   3279 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3280 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3281 			}
   3282 			{
   3283 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
   3284 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3285 			}
   3286 			{
   3287 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3));
   3288 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3289 			}
   3290 			{
   3291 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
   3292 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3293 			}
   3294 			ctx.endSection();
   3295 		}
   3296 	}
   3297 	ctx.endSection();
   3298 }
   3299 
   3300 void texture_gather_sampler_cube (NegativeTestContext& ctx)
   3301 {
   3302 	ctx.beginSection("textureGrad - samplerCube");
   3303 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3304 	{
   3305 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3306 		{
   3307 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3308 			{
   3309 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT));
   3310 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3311 			}
   3312 			{
   3313 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3314 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3315 			}
   3316 			{
   3317 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT, glu::TYPE_INT));
   3318 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3319 			}
   3320 			{
   3321 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT));
   3322 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3323 			}
   3324 			{
   3325 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3326 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3327 			}
   3328 			{
   3329 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT, glu::TYPE_INT));
   3330 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3331 			}
   3332 			{
   3333 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT));
   3334 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3335 			}
   3336 			{
   3337 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3338 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3339 			}
   3340 			{
   3341 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT, glu::TYPE_INT));
   3342 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3343 			}
   3344 			{
   3345 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3));
   3346 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3347 			}
   3348 			{
   3349 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
   3350 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3351 			}
   3352 			ctx.endSection();
   3353 		}
   3354 	}
   3355 	ctx.endSection();
   3356 }
   3357 
   3358 void texture_gather_sampler_2d_shadow (NegativeTestContext& ctx)
   3359 {
   3360 	ctx.beginSection("textureGrad - sampler2DShadow");
   3361 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3362 	{
   3363 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3364 		{
   3365 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3366 			{
   3367 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT));
   3368 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3369 			}
   3370 			{
   3371 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT));
   3372 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3373 			}
   3374 			{
   3375 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
   3376 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3377 			}
   3378 			{
   3379 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
   3380 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3381 			}
   3382 			ctx.endSection();
   3383 		}
   3384 	}
   3385 	ctx.endSection();
   3386 }
   3387 
   3388 void texture_gather_sampler_2d_array_shadow (NegativeTestContext& ctx)
   3389 {
   3390 	ctx.beginSection("textureGrad - sampler2DArrayShadow");
   3391 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3392 	{
   3393 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3394 		{
   3395 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3396 			{
   3397 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, glu::TYPE_FLOAT));
   3398 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3399 			}
   3400 			{
   3401 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
   3402 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3403 			}
   3404 			{
   3405 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
   3406 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3407 			}
   3408 			{
   3409 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3410 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3411 			}
   3412 			ctx.endSection();
   3413 		}
   3414 	}
   3415 	ctx.endSection();
   3416 }
   3417 
   3418 void texture_gather_sampler_cube_shadow (NegativeTestContext& ctx)
   3419 {
   3420 	ctx.beginSection("textureGrad - samplerCubeShadow");
   3421 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3422 	{
   3423 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3424 		{
   3425 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3426 			{
   3427 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT));
   3428 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3429 			}
   3430 			{
   3431 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
   3432 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3433 			}
   3434 			{
   3435 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
   3436 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3437 			}
   3438 			{
   3439 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   3440 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3441 			}
   3442 			ctx.endSection();
   3443 		}
   3444 	}
   3445 	ctx.endSection();
   3446 }
   3447 
   3448 void texture_gather_sampler_cube_array (NegativeTestContext& ctx)
   3449 {
   3450 	TCU_CHECK_AND_THROW(
   3451 		NotSupportedError,
   3452 		contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported("GL_EXT_texture_cube_map_array"),
   3453 		"Test requires extension GL_EXT_texture_cube_map_array or context version 3.2 or higher.");
   3454 
   3455 	ctx.beginSection("textureGrad - samplerCubeArray");
   3456 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3457 	{
   3458 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3459 		{
   3460 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3461 			{
   3462 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT));
   3463 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3464 			}
   3465 			{
   3466 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
   3467 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3468 			}
   3469 			{
   3470 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
   3471 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3472 			}
   3473 			{
   3474 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT));
   3475 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3476 			}
   3477 			{
   3478 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
   3479 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3480 			}
   3481 			{
   3482 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
   3483 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3484 			}
   3485 			{
   3486 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT));
   3487 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3488 			}
   3489 			{
   3490 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
   3491 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3492 			}
   3493 			{
   3494 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
   3495 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3496 			}
   3497 			{
   3498 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC4, glu::TYPE_INT));
   3499 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3500 			}
   3501 			ctx.endSection();
   3502 		}
   3503 	}
   3504 	ctx.endSection();
   3505 }
   3506 
   3507 void texture_gather_sampler_cube_array_shadow (NegativeTestContext& ctx)
   3508 {
   3509 	TCU_CHECK_AND_THROW(
   3510 		NotSupportedError,
   3511 		contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported("GL_EXT_texture_cube_map_array"),
   3512 		"Test requires extension GL_EXT_texture_cube_map_array or context version 3.2 or higher.");
   3513 
   3514 	ctx.beginSection("textureGrad - samplerCubeArrayShadow");
   3515 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3516 	{
   3517 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3518 		{
   3519 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3520 			{
   3521 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT));
   3522 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3523 			}
   3524 			{
   3525 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
   3526 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3527 			}
   3528 			{
   3529 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC4, glu::TYPE_INT));
   3530 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3531 			}
   3532 			{
   3533 				const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
   3534 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3535 			}
   3536 			ctx.endSection();
   3537 		}
   3538 	}
   3539 	ctx.endSection();
   3540 }
   3541 
   3542 // textureGatherOffset
   3543 std::string genShaderSourceTextureGatherOffset (NegativeTestContext& ctx, glu::ShaderType shaderType, FunctionTextureGatherOffsetModes mode, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType offsetDataType, glu::DataType fourthArgument)
   3544 {
   3545 	DE_ASSERT(mode < FUNCTION_TEXTURE_GATHER_OFFSET_MODE_LAST);
   3546 
   3547 	std::ostringstream source;
   3548 
   3549 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   3550 			<< getShaderInitialization(ctx, shaderType)
   3551 			<< declareShaderUniform(samplerDataType, "sampler")
   3552 			<< "void main(void)\n"
   3553 			<< "{\n"
   3554 			<< "	mediump " << declareAndInitializeShaderVariable(pDataType, "P")
   3555 			<< "	mediump " << declareAndInitializeShaderVariable(offsetDataType, "offset");
   3556 
   3557 	switch (mode)
   3558 	{
   3559 		case FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP:
   3560 		{
   3561 			if (fourthArgument != glu::TYPE_LAST)
   3562 				source	<< "	mediump " << declareAndInitializeShaderVariable(fourthArgument, "comp")
   3563 						<< "	textureGatherOffset(sampler, P, offset, comp);\n";
   3564 			else
   3565 				source << "	textureGatherOffset(sampler, P, offset);\n";
   3566 			break;
   3567 		}
   3568 
   3569 		case FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z:
   3570 		{
   3571 			source	<< "	mediump " << declareAndInitializeShaderVariable(fourthArgument, "refZ")
   3572 					<< "	textureGatherOffset(sampler, P, refZ, offset);\n";
   3573 			break;
   3574 		}
   3575 
   3576 		default:
   3577 			DE_FATAL("Unsupported shader function overload.");
   3578 	}
   3579 
   3580 	source << "}\n";
   3581 
   3582 	return source.str();
   3583 }
   3584 
   3585 std::string genShaderSourceTextureGatherOffset (NegativeTestContext& ctx, glu::ShaderType shaderType, FunctionTextureGatherOffsetModes mode, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType offsetDataType)
   3586 {
   3587 	DE_ASSERT(mode == FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP);
   3588 
   3589 	return genShaderSourceTextureGatherOffset(ctx, shaderType, mode, samplerDataType, pDataType, offsetDataType, glu::TYPE_LAST);
   3590 }
   3591 
   3592 void texture_gather_offset_sampler_2d (NegativeTestContext& ctx)
   3593 {
   3594 	ctx.beginSection("textureGatherOffset - sampler2D");
   3595 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3596 	{
   3597 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3598 		{
   3599 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3600 			{
   3601 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2));
   3602 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3603 			}
   3604 			{
   3605 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT));
   3606 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3607 			}
   3608 			{
   3609 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3610 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3611 			}
   3612 			{
   3613 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_INT));
   3614 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3615 			}
   3616 			{
   3617 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
   3618 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3619 			}
   3620 			{
   3621 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2));
   3622 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3623 			}
   3624 			{
   3625 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT));
   3626 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3627 			}
   3628 			{
   3629 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3630 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3631 			}
   3632 			{
   3633 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_INT));
   3634 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3635 			}
   3636 			{
   3637 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
   3638 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3639 			}
   3640 			{
   3641 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2));
   3642 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3643 			}
   3644 			{
   3645 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT));
   3646 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3647 			}
   3648 			{
   3649 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3650 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3651 			}
   3652 			{
   3653 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_INT));
   3654 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3655 			}
   3656 			{
   3657 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
   3658 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3659 			}
   3660 			{
   3661 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2));
   3662 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3663 			}
   3664 			{
   3665 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3666 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3667 			}
   3668 			ctx.endSection();
   3669 		}
   3670 	}
   3671 	ctx.endSection();
   3672 }
   3673 
   3674 void texture_gather_offset_sampler_2d_array (NegativeTestContext& ctx)
   3675 {
   3676 	ctx.beginSection("textureGatherOffset - sampler2DArray");
   3677 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3678 	{
   3679 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3680 		{
   3681 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3682 			{
   3683 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2));
   3684 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3685 			}
   3686 			{
   3687 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
   3688 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3689 			}
   3690 			{
   3691 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3692 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3693 			}
   3694 			{
   3695 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_INT));
   3696 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3697 			}
   3698 			{
   3699 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_FLOAT));
   3700 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3701 			}
   3702 			{
   3703 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2));
   3704 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3705 			}
   3706 			{
   3707 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
   3708 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3709 			}
   3710 			{
   3711 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3712 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3713 			}
   3714 			{
   3715 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_INT));
   3716 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3717 			}
   3718 			{
   3719 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_FLOAT));
   3720 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3721 			}
   3722 			{
   3723 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2));
   3724 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3725 			}
   3726 			{
   3727 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
   3728 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3729 			}
   3730 			{
   3731 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3732 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3733 			}
   3734 			{
   3735 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_INT));
   3736 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3737 			}
   3738 			{
   3739 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_FLOAT));
   3740 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3741 			}
   3742 			{
   3743 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3744 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3745 			}
   3746 			ctx.endSection();
   3747 		}
   3748 	}
   3749 	ctx.endSection();
   3750 }
   3751 
   3752 void texture_gather_offset_sampler_2d_shadow (NegativeTestContext& ctx)
   3753 {
   3754 	ctx.beginSection("textureGatherOffset - sampler2DShadow");
   3755 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3756 	{
   3757 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3758 		{
   3759 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3760 			{
   3761 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
   3762 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3763 			}
   3764 			{
   3765 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3766 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3767 			}
   3768 			{
   3769 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_FLOAT));
   3770 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3771 			}
   3772 			{
   3773 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
   3774 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3775 			}
   3776 			ctx.endSection();
   3777 		}
   3778 	}
   3779 	ctx.endSection();
   3780 }
   3781 
   3782 void texture_gather_offset_sampler_2d_array_shadow (NegativeTestContext& ctx)
   3783 {
   3784 	ctx.beginSection("textureGatherOffset - sampler2DShadow");
   3785 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3786 	{
   3787 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3788 		{
   3789 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3790 			{
   3791 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
   3792 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3793 			}
   3794 			{
   3795 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT_VEC2, glu::TYPE_INT));
   3796 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3797 			}
   3798 			{
   3799 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_FLOAT));
   3800 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3801 			}
   3802 			{
   3803 				const std::string shaderSource(genShaderSourceTextureGatherOffset(ctx, s_shaders[shaderNdx], FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
   3804 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3805 			}
   3806 			ctx.endSection();
   3807 		}
   3808 	}
   3809 	ctx.endSection();
   3810 }
   3811 
   3812 // atomicAdd, atomicMin, atomicMax, atomicAnd, atomicOr, atomixXor, atomixExchange, atomicCompSwap
   3813 std::string genShaderSourceAtomicOperations (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType memDataType, glu::DataType dataDataType, glu::DataType compareDataType)
   3814 {
   3815 	DE_ASSERT(SHADER_FUNCTION_ATOMIC_ADD <= function && function <= SHADER_FUNCTION_ATOMIC_COMP_SWAP);
   3816 
   3817 	std::ostringstream source;
   3818 
   3819 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   3820 			<< getShaderInitialization(ctx, shaderType)
   3821 			<< declareBuffer(memDataType, "mem")
   3822 			<< "void main()\n"
   3823 			<< "{\n"
   3824 			<< "	mediump " << declareAndInitializeShaderVariable(dataDataType, "data");
   3825 
   3826 	switch (function)
   3827 	{
   3828 		case SHADER_FUNCTION_ATOMIC_ADD:		source << "    atomicAdd(mem, data);\n";		break;
   3829 		case SHADER_FUNCTION_ATOMIC_MIN:		source << "    atomicMin(mem, data);\n";		break;
   3830 		case SHADER_FUNCTION_ATOMIC_MAX:		source << "    atomicMax(mem, data);\n";		break;
   3831 		case SHADER_FUNCTION_ATOMIC_AND:		source << "    atomicAnd(mem, data);\n";		break;
   3832 		case SHADER_FUNCTION_ATOMIC_OR:			source << "    atomicOr(mem, data);\n";			break;
   3833 		case SHADER_FUNCTION_ATOMIC_XOR:		source << "    atomicXor(mem, data);\n";		break;
   3834 		case SHADER_FUNCTION_ATOMIC_EXCHANGE:	source << "    atomicExchange(mem, data);\n";	break;
   3835 		case SHADER_FUNCTION_ATOMIC_COMP_SWAP:
   3836 			source	<< "	mediump " << declareAndInitializeShaderVariable(compareDataType, "compare")
   3837 					<< "    atomicCompSwap(mem, compare, data);\n";
   3838 			break;
   3839 
   3840 		default:
   3841 			DE_FATAL("Unsupported shader function.");
   3842 	}
   3843 
   3844 	source << "}\n";
   3845 
   3846 	return source.str();
   3847 }
   3848 
   3849 std::string genShaderSourceAtomicOperations (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType memDataType, glu::DataType dataDataType)
   3850 {
   3851 	DE_ASSERT(function != SHADER_FUNCTION_ATOMIC_COMP_SWAP);
   3852 
   3853 	return genShaderSourceAtomicOperations(ctx, shaderType, function, memDataType, dataDataType, glu::TYPE_LAST);
   3854 }
   3855 
   3856 void atomic_add (NegativeTestContext& ctx)
   3857 {
   3858 	ctx.beginSection("atomicAdd");
   3859 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3860 	{
   3861 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3862 		{
   3863 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3864 			{
   3865 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_ADD, glu::TYPE_UINT, glu::TYPE_INT));
   3866 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3867 			}
   3868 			{
   3869 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_ADD, glu::TYPE_INT, glu::TYPE_UINT));
   3870 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3871 			}
   3872 			ctx.endSection();
   3873 		}
   3874 	}
   3875 	ctx.endSection();
   3876 }
   3877 
   3878 void atomic_min (NegativeTestContext& ctx)
   3879 {
   3880 	ctx.beginSection("atomicMin");
   3881 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3882 	{
   3883 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3884 		{
   3885 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3886 			{
   3887 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_MIN, glu::TYPE_UINT, glu::TYPE_INT));
   3888 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3889 			}
   3890 			{
   3891 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_MIN, glu::TYPE_INT, glu::TYPE_UINT));
   3892 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3893 			}
   3894 			ctx.endSection();
   3895 		}
   3896 	}
   3897 	ctx.endSection();
   3898 }
   3899 
   3900 void atomic_max (NegativeTestContext& ctx)
   3901 {
   3902 	ctx.beginSection("atomicMax");
   3903 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3904 	{
   3905 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3906 		{
   3907 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3908 			{
   3909 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_MAX, glu::TYPE_UINT, glu::TYPE_INT));
   3910 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3911 			}
   3912 			{
   3913 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_MAX, glu::TYPE_INT, glu::TYPE_UINT));
   3914 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3915 			}
   3916 			ctx.endSection();
   3917 		}
   3918 	}
   3919 	ctx.endSection();
   3920 }
   3921 
   3922 void atomic_and (NegativeTestContext& ctx)
   3923 {
   3924 	ctx.beginSection("atomicAnd");
   3925 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3926 	{
   3927 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3928 		{
   3929 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3930 			{
   3931 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_AND, glu::TYPE_UINT, glu::TYPE_INT));
   3932 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3933 			}
   3934 			{
   3935 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_AND, glu::TYPE_INT, glu::TYPE_UINT));
   3936 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3937 			}
   3938 			ctx.endSection();
   3939 		}
   3940 	}
   3941 	ctx.endSection();
   3942 }
   3943 
   3944 void atomic_or (NegativeTestContext& ctx)
   3945 {
   3946 	ctx.beginSection("atomicOr");
   3947 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3948 	{
   3949 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3950 		{
   3951 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3952 			{
   3953 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_OR, glu::TYPE_UINT, glu::TYPE_INT));
   3954 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3955 			}
   3956 			{
   3957 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_OR, glu::TYPE_INT, glu::TYPE_UINT));
   3958 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3959 			}
   3960 			ctx.endSection();
   3961 		}
   3962 	}
   3963 	ctx.endSection();
   3964 }
   3965 
   3966 void atomic_xor (NegativeTestContext& ctx)
   3967 {
   3968 	ctx.beginSection("atomicXor");
   3969 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3970 	{
   3971 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3972 		{
   3973 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3974 			{
   3975 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_XOR, glu::TYPE_UINT, glu::TYPE_INT));
   3976 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3977 			}
   3978 			{
   3979 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_XOR, glu::TYPE_INT, glu::TYPE_UINT));
   3980 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3981 			}
   3982 			ctx.endSection();
   3983 		}
   3984 	}
   3985 	ctx.endSection();
   3986 }
   3987 
   3988 void atomic_exchange (NegativeTestContext& ctx)
   3989 {
   3990 	ctx.beginSection("atomicExchange");
   3991 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   3992 	{
   3993 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   3994 		{
   3995 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   3996 			{
   3997 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_EXCHANGE, glu::TYPE_UINT, glu::TYPE_INT));
   3998 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   3999 			}
   4000 			{
   4001 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_EXCHANGE, glu::TYPE_INT, glu::TYPE_UINT));
   4002 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4003 			}
   4004 			ctx.endSection();
   4005 		}
   4006 	}
   4007 	ctx.endSection();
   4008 }
   4009 
   4010 void atomic_comp_swap (NegativeTestContext& ctx)
   4011 {
   4012 	ctx.beginSection("atomicCompSwap");
   4013 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   4014 	{
   4015 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   4016 		{
   4017 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   4018 			{
   4019 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_COMP_SWAP, glu::TYPE_UINT, glu::TYPE_INT, glu::TYPE_INT));
   4020 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4021 			}
   4022 			{
   4023 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_COMP_SWAP, glu::TYPE_INT, glu::TYPE_UINT, glu::TYPE_INT));
   4024 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4025 			}
   4026 			{
   4027 				const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_COMP_SWAP, glu::TYPE_INT, glu::TYPE_INT, glu::TYPE_UINT));
   4028 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4029 			}
   4030 			ctx.endSection();
   4031 		}
   4032 	}
   4033 	ctx.endSection();
   4034 }
   4035 
   4036 // interpolatedAtCentroid, interpolatedAtSample, interpolateAtOffset,
   4037 std::string genShaderSourceInterpolateAt (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType interpolantDataType, glu::DataType secondArgumentDataType)
   4038 {
   4039 	DE_ASSERT(function >= SHADER_FUNCTION_INTERPOLATED_AT_CENTROID && function <= SHADER_FUNCTION_INTERPOLATED_AT_OFFSET);
   4040 
   4041 	const bool			isES32 = contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
   4042 	std::ostringstream	source;
   4043 
   4044 	source	<< (isES32 ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   4045 			<< getShaderInitialization(ctx, shaderType)
   4046 			<< (isES32 ? "" : getShaderExtensionDeclaration("GL_OES_shader_multisample_interpolation"))
   4047 			<< declareShaderInput(interpolantDataType, "interpolant")
   4048 			<< "void main()\n"
   4049 			<< "{\n";
   4050 
   4051 	switch (function)
   4052 	{
   4053 		case SHADER_FUNCTION_INTERPOLATED_AT_CENTROID:
   4054 			source << "    interpolateAtCentroid(interpolant);\n";
   4055 			break;
   4056 
   4057 		case SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE:
   4058 			source	<< "	mediump " << declareAndInitializeShaderVariable(secondArgumentDataType, "sample")
   4059 					<< "    interpolateAtSample(interpolant, sample);\n";
   4060 			break;
   4061 
   4062 		case SHADER_FUNCTION_INTERPOLATED_AT_OFFSET:
   4063 			source	<< "	mediump " << declareAndInitializeShaderVariable(secondArgumentDataType, "offset")
   4064 					<< "    interpolateAtOffset(interpolant, offset);\n";
   4065 			break;
   4066 
   4067 		default:
   4068 			DE_FATAL("Unsupported shader function.");
   4069 	}
   4070 
   4071 	source << "}\n";
   4072 
   4073 	return source.str();
   4074 }
   4075 
   4076 std::string genShaderSourceInterpolateAt (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType interpolantDataType)
   4077 {
   4078 	DE_ASSERT(function == SHADER_FUNCTION_INTERPOLATED_AT_CENTROID);
   4079 
   4080 	return genShaderSourceInterpolateAt(ctx, shaderType, function, interpolantDataType, glu::TYPE_LAST);
   4081 }
   4082 
   4083 void interpolate_at_centroid (NegativeTestContext& ctx)
   4084 {
   4085 	TCU_CHECK_AND_THROW(NotSupportedError,
   4086 		contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported("GL_OES_shader_multisample_interpolation"),
   4087 		"This test requires a context version 3.2 or higher.");
   4088 
   4089 	ctx.beginSection("interpolateAtCentroid");
   4090 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   4091 	{
   4092 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   4093 		{
   4094 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   4095 			if (s_shaders[shaderNdx] == glu::SHADERTYPE_FRAGMENT)
   4096 			{
   4097 				const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_INT));
   4098 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4099 			}
   4100 			else
   4101 			{
   4102 				{
   4103 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_FLOAT));
   4104 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4105 				}
   4106 				{
   4107 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_FLOAT_VEC2));
   4108 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4109 				}
   4110 				{
   4111 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_FLOAT_VEC3));
   4112 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4113 				}
   4114 				{
   4115 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_FLOAT_VEC4));
   4116 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4117 				}
   4118 			}
   4119 			ctx.endSection();
   4120 		}
   4121 	}
   4122 	ctx.endSection();
   4123 }
   4124 
   4125 void interpolate_at_sample (NegativeTestContext& ctx)
   4126 {
   4127 	TCU_CHECK_AND_THROW(NotSupportedError,
   4128 		contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported("GL_OES_shader_multisample_interpolation"),
   4129 		"This test requires a context version 3.2 or higher.");
   4130 
   4131 	ctx.beginSection("interpolateAtSample");
   4132 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   4133 	{
   4134 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   4135 		{
   4136 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   4137 			if (s_shaders[shaderNdx] == glu::SHADERTYPE_FRAGMENT)
   4138 			{
   4139 				{
   4140 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_INT, glu::TYPE_INT));
   4141 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4142 				}
   4143 				{
   4144 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
   4145 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4146 				}
   4147 				{
   4148 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
   4149 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4150 				}
   4151 				{
   4152 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   4153 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4154 				}
   4155 				{
   4156 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
   4157 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4158 				}
   4159 			}
   4160 			else
   4161 			{
   4162 				{
   4163 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT, glu::TYPE_INT));
   4164 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4165 				}
   4166 				{
   4167 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT));
   4168 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4169 				}
   4170 				{
   4171 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
   4172 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4173 				}
   4174 				{
   4175 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC4, glu::TYPE_INT));
   4176 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4177 				}
   4178 			}
   4179 			ctx.endSection();
   4180 		}
   4181 	}
   4182 	ctx.endSection();
   4183 }
   4184 
   4185 void interpolate_at_offset (NegativeTestContext& ctx)
   4186 {
   4187 	TCU_CHECK_AND_THROW(NotSupportedError,
   4188 		contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported("GL_OES_shader_multisample_interpolation"),
   4189 		"This test requires a context version 3.2 or higher.");
   4190 
   4191 	ctx.beginSection("interpolateAtOffset");
   4192 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   4193 	{
   4194 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   4195 		{
   4196 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   4197 			if (s_shaders[shaderNdx] == glu::SHADERTYPE_FRAGMENT)
   4198 			{
   4199 				{
   4200 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_INT, glu::TYPE_FLOAT_VEC2));
   4201 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4202 				}
   4203 				{
   4204 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
   4205 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4206 				}
   4207 				{
   4208 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
   4209 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4210 				}
   4211 				{
   4212 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
   4213 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4214 				}
   4215 				{
   4216 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
   4217 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4218 				}
   4219 			}
   4220 			else
   4221 			{
   4222 				{
   4223 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT, glu::TYPE_FLOAT_VEC2));
   4224 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4225 				}
   4226 				{
   4227 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT_VEC2));
   4228 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4229 				}
   4230 				{
   4231 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT_VEC2));
   4232 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4233 				}
   4234 				{
   4235 					const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT_VEC2));
   4236 					verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4237 				}
   4238 			}
   4239 			ctx.endSection();
   4240 		}
   4241 	}
   4242 	ctx.endSection();
   4243 }
   4244 
   4245 
   4246 // textureGatherOffsets
   4247 std::string genShaderSourceTextureGatherOffsets (NegativeTestContext& ctx, glu::ShaderType shaderType, const TextureGatherOffsetsTestSpec& spec)
   4248 {
   4249 	std::ostringstream source;
   4250 
   4251 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   4252 			<< getShaderInitialization(ctx, shaderType)
   4253 			<< declareShaderUniform(spec.samplerDataType, "sampler")
   4254 			<< "void main(void)\n"
   4255 			<< "{\n"
   4256 			<< "	mediump " << declareAndInitializeShaderVariable(spec.pDataType, "P")
   4257 			<< "    mediump " << (spec.offsetIsConst ? "const " : "") << declareShaderArrayVariable(spec.offsetsDataType, "offsets", spec.offsetArraySize) << "\n";
   4258 
   4259 	switch (spec.mode)
   4260 	{
   4261 		case FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP:
   4262 		{
   4263 			if (spec.fourthArgument != glu::TYPE_LAST)
   4264 				source	<< "	mediump " << declareAndInitializeShaderVariable(spec.fourthArgument, "comp")
   4265 						<< "	textureGatherOffsets(sampler, P, offsets, comp);\n";
   4266 			else
   4267 				source << "	textureGatherOffsets(sampler, P, offsets);\n";
   4268 			break;
   4269 		}
   4270 
   4271 		case FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z:
   4272 		{
   4273 			source	<< "	mediump " << declareAndInitializeShaderVariable(spec.fourthArgument, "refZ")
   4274 					<< "	textureGatherOffsets(sampler, P, refZ, offsets);\n";
   4275 			break;
   4276 		}
   4277 
   4278 		default:
   4279 			DE_FATAL("Unsupported shader function overload.");
   4280 			break;
   4281 	}
   4282 
   4283 	source << "}\n";
   4284 	return source.str();
   4285 }
   4286 
   4287 void texture_gather_offsets (NegativeTestContext& ctx)
   4288 {
   4289 	TCU_CHECK_AND_THROW(NotSupportedError,
   4290 		contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported("GL_EXT_gpu_shader5"),
   4291 		"This test requires a context version 3.2 or higher.");
   4292 
   4293 	const struct TextureGatherOffsetsTestSpec testSpecs[] =
   4294 	{
   4295 			//mode										samplerDataType						pDataType				offsetsDataType			fourthArgument		offsetIsConst	offsetArraySize
   4296 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D,				glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT_VEC2,		glu::TYPE_LAST,		false,			4,		},
   4297 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D,				glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT_VEC2,		glu::TYPE_LAST,		true,			3,		},
   4298 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D,				glu::TYPE_FLOAT,		glu::TYPE_INT_VEC2,		glu::TYPE_LAST,		true,			4,		},
   4299 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D,				glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT,			glu::TYPE_LAST,		true,			4,		},
   4300 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D,				glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT_VEC2,		glu::TYPE_INT,		false,			4,		},
   4301 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D,				glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT_VEC2,		glu::TYPE_FLOAT,	true,			4,		},
   4302 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D,				glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT_VEC2,		glu::TYPE_INT,		true,			3,		},
   4303 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D,				glu::TYPE_FLOAT,		glu::TYPE_INT_VEC2,		glu::TYPE_INT,		true,			4,		},
   4304 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D,				glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT,			glu::TYPE_INT,		true,			4,		},
   4305 
   4306 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D_ARRAY,			glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT_VEC2,		glu::TYPE_LAST,		false,			4,		},
   4307 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D_ARRAY,			glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT_VEC2,		glu::TYPE_LAST,		true,			3,		},
   4308 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D_ARRAY,			glu::TYPE_FLOAT,		glu::TYPE_INT_VEC2,		glu::TYPE_LAST,		true,			4,		},
   4309 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D_ARRAY,			glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT,			glu::TYPE_LAST,		true,			4,		},
   4310 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D_ARRAY,			glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT_VEC2,		glu::TYPE_INT,		false,			4,		},
   4311 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D_ARRAY,			glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT_VEC2,		glu::TYPE_FLOAT,	true,			4,		},
   4312 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D_ARRAY,			glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT_VEC2,		glu::TYPE_INT,		true,			3,		},
   4313 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D_ARRAY,			glu::TYPE_FLOAT,		glu::TYPE_INT_VEC2,		glu::TYPE_INT,		true,			4,		},
   4314 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP,	glu::TYPE_SAMPLER_2D_ARRAY,			glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT,			glu::TYPE_INT,		true,			4,		},
   4315 
   4316 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_SHADOW,		glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT_VEC2,		glu::TYPE_FLOAT,	false,			4,		},
   4317 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_SHADOW,		glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT_VEC2,		glu::TYPE_FLOAT,	true,			3,		},
   4318 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_SHADOW,		glu::TYPE_FLOAT,		glu::TYPE_INT_VEC2,		glu::TYPE_FLOAT,	true,			4,		},
   4319 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_SHADOW,		glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT,			glu::TYPE_FLOAT,	true,			4,		},
   4320 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_SHADOW,		glu::TYPE_FLOAT_VEC2,	glu::TYPE_INT_VEC2,		glu::TYPE_INT,		true,			4,		},
   4321 
   4322 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_ARRAY_SHADOW,	glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT_VEC2,		glu::TYPE_FLOAT,	false,			4,		},
   4323 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_ARRAY_SHADOW,	glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT_VEC2,		glu::TYPE_FLOAT,	true,			3,		},
   4324 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_ARRAY_SHADOW,	glu::TYPE_FLOAT,		glu::TYPE_INT_VEC2,		glu::TYPE_FLOAT,	true,			4,		},
   4325 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_ARRAY_SHADOW,	glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT,			glu::TYPE_FLOAT,	true,			4,		},
   4326 		{	FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z,	glu::TYPE_SAMPLER_2D_ARRAY_SHADOW,	glu::TYPE_FLOAT_VEC3,	glu::TYPE_INT_VEC2,		glu::TYPE_INT,		true,			4,		},
   4327 	};
   4328 
   4329 	ctx.beginSection("textureGatherOffsets");
   4330 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   4331 	{
   4332 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   4333 		{
   4334 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   4335 			for (int specNdx = 0; specNdx < DE_LENGTH_OF_ARRAY(testSpecs); ++specNdx)
   4336 			{
   4337 				const std::string shaderSource(genShaderSourceTextureGatherOffsets(ctx, s_shaders[shaderNdx], testSpecs[specNdx]));
   4338 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4339 			}
   4340 			ctx.endSection();
   4341 		}
   4342 	}
   4343 	ctx.endSection();
   4344 }
   4345 
   4346 // fma
   4347 std::string genShaderSourceFma (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType aDataType, glu::DataType bDataType, glu::DataType cDataType)
   4348 {
   4349 	std::ostringstream source;
   4350 
   4351 	source	<< (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
   4352 			<< getShaderInitialization(ctx, shaderType)
   4353 			<< "void main(void)\n"
   4354 			<< "{\n"
   4355 			<< "	mediump " << declareAndInitializeShaderVariable(aDataType, "a")
   4356 			<< "	mediump " << declareAndInitializeShaderVariable(bDataType, "b")
   4357 			<< "	mediump " << declareAndInitializeShaderVariable(cDataType, "c")
   4358 			<< "	fma(a, b, c);"
   4359 			<< "}\n";
   4360 	return source.str();
   4361 }
   4362 
   4363 void fma (NegativeTestContext& ctx)
   4364 {
   4365 	TCU_CHECK_AND_THROW(NotSupportedError,
   4366 		contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) || ctx.isExtensionSupported("GL_EXT_gpu_shader5"),
   4367 		"This test requires a context version 3.2 or higher.");
   4368 
   4369 	ctx.beginSection("fma");
   4370 	for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
   4371 	{
   4372 		if (ctx.isShaderSupported(s_shaders[shaderNdx]))
   4373 		{
   4374 			ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
   4375 			{
   4376 				const std::string shaderSource(genShaderSourceFma(ctx, s_shaders[shaderNdx], glu::TYPE_FLOAT, glu::TYPE_FLOAT, glu::TYPE_INT));
   4377 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4378 			}
   4379 			{
   4380 				const std::string shaderSource(genShaderSourceFma(ctx, s_shaders[shaderNdx], glu::TYPE_FLOAT, glu::TYPE_INT, glu::TYPE_FLOAT));
   4381 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4382 			}
   4383 			{
   4384 				const std::string shaderSource(genShaderSourceFma(ctx, s_shaders[shaderNdx], glu::TYPE_INT, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
   4385 				verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
   4386 			}
   4387 			ctx.endSection();
   4388 		}
   4389 	}
   4390 	ctx.endSection();
   4391 }
   4392 
   4393 } // anonymous
   4394 
   4395 std::vector<FunctionContainer> getNegativeShaderFunctionTestFunctions ()
   4396 {
   4397 	const FunctionContainer funcs[] =
   4398 	{
   4399 		{bitfield_extract_invalid_value_type,				"bitfield_extract_invalid_value_type",				"Invalid usage of bitfieldExtract."			},
   4400 		{bitfield_extract_invalid_offset_type,				"bitfield_extract_invalid_offset_type",				"Invalid usage of bitfieldExtract."			},
   4401 		{bitfield_extract_invalid_bits_type,				"bitfield_extract_invalid_bits_type",				"Invalid usage of bitfieldExtract."			},
   4402 		{bitfield_insert_invalid_base_type,					"bitfield_insert_invalid_base_type",				"Invalid usage of bitfieldInsert."			},
   4403 		{bitfield_insert_invalid_insert_type,				"bitfield_insert_invalid_insert_type",				"Invalid usage of bitfieldInsert."			},
   4404 		{bitfield_insert_invalid_offset_type,				"bitfield_insert_invalid_offset_type",				"Invalid usage of bitfieldInsert."			},
   4405 		{bitfield_insert_invalid_bits_type,					"bitfield_insert_invalid_bits_type",				"Invalid usage of bitfieldInsert."			},
   4406 		{bitfield_reverse,									"bitfield_reverse",									"Invalid usage of bitfieldReverse."			},
   4407 		{bit_count,											"bit_count",										"Invalid usage of bitCount."				},
   4408 		{find_msb,											"find_msb",											"Invalid usage of findMSB."					},
   4409 		{find_lsb,											"find_lsb",											"Invalid usage of findLSB."					},
   4410 		{uadd_carry_invalid_x,								"uadd_carry_invalid_x",								"Invalid usage of uaddCarry."				},
   4411 		{uadd_carry_invalid_y,								"uadd_carry_invalid_y",								"Invalid usage of uaddCarry."				},
   4412 		{uadd_carry_invalid_carry,							"uadd_carry_invalid_carry",							"Invalid usage of uaddCarry."				},
   4413 		{usub_borrow_invalid_x,								"usub_borrow_invalid_x",							"Invalid usage of usubBorrow."				},
   4414 		{usub_borrow_invalid_y,								"usub_borrow_invalid_y",							"Invalid usage of usubBorrow."				},
   4415 		{usub_borrow_invalid_borrow,						"usub_borrow_invalid_borrow",						"Invalid usage of usubBorrow."				},
   4416 		{umul_extended_invalid_x,							"umul_extended_invalid_x",							"Invalid usage of umulExtended."			},
   4417 		{umul_extended_invalid_y,							"umul_extended_invalid_y",							"Invalid usage of umulExtended."			},
   4418 		{umul_extended_invalid_msb,							"umul_extended_invalid_msb",						"Invalid usage of umulExtended."			},
   4419 		{umul_extended_invalid_lsb,							"umul_extended_invalid_lsb",						"Invalid usage of umulExtended."			},
   4420 		{imul_extended_invalid_x,							"imul_extended_invalid_x",							"Invalid usage of imulExtended."			},
   4421 		{imul_extended_invalid_y,							"imul_extended_invalid_y",							"Invalid usage of imulExtended."			},
   4422 		{imul_extended_invalid_msb,							"imul_extended_invalid_msb",						"Invalid usage of imulExtended."			},
   4423 		{imul_extended_invalid_lsb,							"imul_extended_invalid_lsb",						"Invalid usage of imulExtended."			},
   4424 		{frexp_invalid_x,									"frexp_invalid_x",									"Invalid usage of frexp."					},
   4425 		{frexp_invalid_exp,									"frexp_invalid_exp",								"Invalid usage of frexp."					},
   4426 		{ldexp_invalid_x,									"ldexp_invalid_x",									"Invalid usage of ldexp."					},
   4427 		{ldexp_invalid_exp,									"ldexp_invalid_exp",								"Invalid usage of ldexp."					},
   4428 		{pack_unorm_4x8,									"pack_unorm_4x8",									"Invalid usage of packUnorm4x8."			},
   4429 		{pack_snorm_4x8,									"pack_snorm_4x8",									"Invalid usage of packSnorm4x8."			},
   4430 		{unpack_snorm_4x8,									"unpack_snorm_4x8",									"Invalid usage of unpackSnorm4x8."			},
   4431 		{unpack_unorm_4x8,									"unpack_unorm_4x8",									"Invalid usage of unpackUnorm4x8."			},
   4432 		{texture_size_invalid_sampler,						"texture_size_invalid_sampler",						"Invalid usage of textureSize."				},
   4433 		{texture_size_invalid_lod,							"texture_size_invalid_lod",							"Invalid usage of textureSize."				},
   4434 		{texture_invalid_p,									"texture_invalid_p",								"Invalid usage of texture."					},
   4435 		{texture_invalid_bias_or_compare,					"texture_invalid_bias_or_compare",					"Invalid usage of texture."					},
   4436 		{texture_lod_invalid_p,								"texture_lod_invalid_p",							"Invalid usage of textureLod."				},
   4437 		{texture_lod_invalid_lod,							"texture_lod_invalid_lod",							"Invalid usage of textureLod."				},
   4438 		{texel_fetch_invalid_p,								"texel_fetch_invalid_p",							"Invalid usage of texelFetch."				},
   4439 		{texel_fetch_invalid_sample,						"texel_fetch_invalid_sample",						"Invalid usage of texelFetch."				},
   4440 		{emit_vertex,										"emit_vertex",										"Invalid usage of EmitVertex."				},
   4441 		{end_primitive,										"end_primitive",									"Invalid usage of EndPrimitive."			},
   4442 		{texture_grad,										"texture_grad",										"Invalid usage of textureGrad."				},
   4443 		{texture_gather_sampler_2d,							"texture_gather_sampler_2d",						"Invalid usage of textureGather."			},
   4444 		{texture_gather_sampler_2d_array,					"texture_gather_sampler_2d_array",					"Invalid usage of textureGather."			},
   4445 		{texture_gather_sampler_cube,						"texture_gather_sampler_cube",						"Invalid usage of textureGather."			},
   4446 		{texture_gather_sampler_2d_shadow,					"texture_gather_sampler_2d_shadow",					"Invalid usage of textureGather."			},
   4447 		{texture_gather_sampler_2d_array_shadow,			"texture_gather_sampler_2d_array_shadow",			"Invalid usage of textureGather."			},
   4448 		{texture_gather_sampler_cube_shadow,				"texture_gather_sampler_cube_shadow",				"Invalid usage of textureGather."			},
   4449 		{texture_gather_sampler_cube_array,					"texture_gather_sampler_cube_array",				"Invalid usage of textureGather."			},
   4450 		{texture_gather_sampler_cube_array_shadow,			"texture_gather_sampler_cube_array_shadow",			"Invalid usage of textureGather."			},
   4451 		{texture_gather_offset_sampler_2d,					"texture_gather_offset_sampler_2d",					"Invalid usage of textureGatherOffset."		},
   4452 		{texture_gather_offset_sampler_2d_array,			"texture_gather_offset_sampler_2d_array",			"Invalid usage of textureGatherOffset."		},
   4453 		{texture_gather_offset_sampler_2d_shadow,			"texture_gather_offset_sampler_2d_shadow",			"Invalid usage of textureGatherOffset."		},
   4454 		{texture_gather_offset_sampler_2d_array_shadow,		"texture_gather_offset_sampler_2d_array_shadow",	"Invalid usage of textureGatherOffset."		},
   4455 		{texture_gather_offsets,							"texture_gather_offsets",							"Invalid usage of textureGatherOffsets."	},
   4456 		{atomic_add,										"atomic_add",										"Invalid usage of atomicAdd."				},
   4457 		{atomic_min,										"atomic_min",										"Invalid usage of atomicMin."				},
   4458 		{atomic_max,										"atomic_max",										"Invalid usage of atomicMax."				},
   4459 		{atomic_and,										"atomic_and",										"Invalid usage of atomicAnd."				},
   4460 		{atomic_or,											"atomic_or",										"Invalid usage of atomicOr."				},
   4461 		{atomic_xor,										"atomic_xor",										"Invalid usage of atomicXor."				},
   4462 		{atomic_exchange,									"atomic_exchange",									"Invalid usage of atomicExchange."			},
   4463 		{atomic_comp_swap,									"atomic_comp_swap",									"Invalid usage of atomicCompSwap."			},
   4464 		{interpolate_at_centroid,							"interpolate_at_centroid",							"Invalid usage of interpolateAtCentroid."	},
   4465 		{interpolate_at_sample,								"interpolate_at_sample",							"Invalid usage of interpolateAtSample."		},
   4466 		{interpolate_at_offset,								"interpolate_at_offset",							"Invalid usage of interpolateAtOffset."		},
   4467 		{fma,												"fma",												"Invalid usage of fma."						},
   4468 	};
   4469 
   4470 	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
   4471 }
   4472 
   4473 } // NegativeTestShared
   4474 } // Functional
   4475 } // gles31
   4476 } // deqp
   4477