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
verifyShader(NegativeTestContext & ctx,glu::ShaderType shaderType,std::string shaderSource)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
declareAndInitializeShaderVariable(glu::DataType dataType,std::string varName)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
declareShaderUniform(glu::DataType dataType,std::string varName)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
declareShaderInput(glu::DataType dataType,std::string varName)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
declareBuffer(glu::DataType dataType,std::string varName)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
declareShaderArrayVariable(glu::DataType dataType,std::string varName,const int arraySize)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
getShaderExtensionDeclaration(std::string extension)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
getDataTypeExtension(glu::DataType dataType)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
getShaderInitialization(NegativeTestContext & ctx,glu::ShaderType shaderType)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
genShaderSourceBitfieldExtract(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType valueDataType,glu::DataType offsetDataType,glu::DataType bitsDataType)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
bitfield_extract_invalid_value_type(NegativeTestContext & ctx)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
bitfield_extract_invalid_offset_type(NegativeTestContext & ctx)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
bitfield_extract_invalid_bits_type(NegativeTestContext & ctx)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
genShaderSourceBitfieldInsert(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType baseDataType,glu::DataType insertDataType,glu::DataType offsetDataType,glu::DataType bitsDataType)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
bitfield_insert_invalid_base_type(NegativeTestContext & ctx)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
bitfield_insert_invalid_insert_type(NegativeTestContext & ctx)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
bitfield_insert_invalid_offset_type(NegativeTestContext & ctx)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
bitfield_insert_invalid_bits_type(NegativeTestContext & ctx)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
genShaderSourceReverseCountFind(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function,glu::DataType baseDataType)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
bitfield_reverse(NegativeTestContext & ctx)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
bit_count(NegativeTestContext & ctx)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
find_msb(NegativeTestContext & ctx)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
find_lsb(NegativeTestContext & ctx)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
genShaderSourceAddCarrySubBorrow(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function,glu::DataType xDataType,glu::DataType yDataType,glu::DataType carryBorrowDataType)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
uadd_carry_invalid_x(NegativeTestContext & ctx)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
uadd_carry_invalid_y(NegativeTestContext & ctx)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
uadd_carry_invalid_carry(NegativeTestContext & ctx)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
usub_borrow_invalid_x(NegativeTestContext & ctx)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
usub_borrow_invalid_y(NegativeTestContext & ctx)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
usub_borrow_invalid_borrow(NegativeTestContext & ctx)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
genShaderSourceMulExtended(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function,glu::DataType xDataType,glu::DataType yDataType,glu::DataType msbDataType,glu::DataType lsbDataType)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
umul_extended_invalid_x(NegativeTestContext & ctx)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
umul_extended_invalid_y(NegativeTestContext & ctx)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
umul_extended_invalid_msb(NegativeTestContext & ctx)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
umul_extended_invalid_lsb(NegativeTestContext & ctx)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
imul_extended_invalid_x(NegativeTestContext & ctx)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
imul_extended_invalid_y(NegativeTestContext & ctx)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
imul_extended_invalid_msb(NegativeTestContext & ctx)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
imul_extended_invalid_lsb(NegativeTestContext & ctx)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
genShaderSourceFrexpLdexp(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function,glu::DataType xDataType,glu::DataType expDataType)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
frexp_invalid_x(NegativeTestContext & ctx)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
frexp_invalid_exp(NegativeTestContext & ctx)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
ldexp_invalid_x(NegativeTestContext & ctx)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
ldexp_invalid_exp(NegativeTestContext & ctx)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
genShaderSourcePackUnpackNorm4x8(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function,glu::DataType dataType)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
pack_unorm_4x8(NegativeTestContext & ctx)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
pack_snorm_4x8(NegativeTestContext & ctx)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
unpack_snorm_4x8(NegativeTestContext & ctx)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
unpack_unorm_4x8(NegativeTestContext & ctx)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
genShaderSourceTextureSize_sampler(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType lodDataType)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
checkSupport(NegativeTestContext & ctx)1672 static bool checkSupport(NegativeTestContext& ctx)
1673 {
1674 auto ctxType = ctx.getRenderContext().getType();
1675 return contextSupports(ctxType, glu::ApiType::es(3, 2)) ||
1676 contextSupports(ctxType, glu::ApiType::core(4, 5));
1677 }
1678
texture_size_invalid_sampler(NegativeTestContext & ctx)1679 void texture_size_invalid_sampler (NegativeTestContext& ctx)
1680 {
1681 ctx.beginSection("textureSize: Invalid sampler type - some overloads take two arguments while others take only one.");
1682 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
1683 {
1684 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
1685 {
1686 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
1687 for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_samplerTypes); ++dataTypeNdx)
1688 {
1689 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(s_samplerTypes[dataTypeNdx])))
1690 {
1691 ctx.beginSection("Verify sampler data type: " + std::string(getDataTypeName(s_samplerTypes[dataTypeNdx])));
1692 const std::string shaderSource(genShaderSourceTextureSize_sampler(ctx, s_shaders[shaderNdx], s_samplerTypes[dataTypeNdx], glu::TYPE_INT));
1693 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1694 ctx.endSection();
1695 }
1696 }
1697 ctx.endSection();
1698 }
1699 }
1700 ctx.endSection();
1701 }
1702
genShaderSourceTextureSize_lod(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType lodDataType)1703 std::string genShaderSourceTextureSize_lod (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType lodDataType)
1704 {
1705 std::ostringstream source;
1706 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"
1707 << getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
1708 << getShaderInitialization(ctx, shaderType)
1709 << declareShaderUniform(samplerDataType, "sampler")
1710 << "void main(void)\n"
1711 << "{\n"
1712 << " " << declareAndInitializeShaderVariable(lodDataType, "lod")
1713 << " textureSize(sampler, lod);\n"
1714 << "}\n";
1715
1716 return source.str();
1717 }
1718
texture_size_invalid_lod(NegativeTestContext & ctx)1719 void texture_size_invalid_lod (NegativeTestContext& ctx)
1720 {
1721 ctx.beginSection("textureSize: Invalid lod type.");
1722 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
1723 {
1724 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
1725 {
1726 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
1727 for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_samplerTypes); ++dataTypeNdx)
1728 {
1729 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(s_samplerTypes[dataTypeNdx])))
1730 {
1731 ctx.beginSection("Verify sampler/lod data type" + std::string(getDataTypeName(s_samplerTypes[dataTypeNdx])));
1732 for (int dataTypeNdx2 = 0; dataTypeNdx2 < DE_LENGTH_OF_ARRAY(s_nonScalarIntTypes); ++dataTypeNdx2)
1733 {
1734 if (s_nonScalarIntTypes[dataTypeNdx2] == glu::TYPE_INT)
1735 continue;
1736
1737 const std::string shaderSource(genShaderSourceTextureSize_lod(ctx, s_shaders[shaderNdx], s_samplerTypes[dataTypeNdx], s_nonScalarIntTypes[dataTypeNdx2]));
1738 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1739 }
1740 ctx.endSection();
1741 }
1742 }
1743 ctx.endSection();
1744 }
1745 }
1746 ctx.endSection();
1747 }
1748
1749 // texture
genShaderSourceTexture(NegativeTestContext & ctx,glu::ShaderType shaderType,FunctionTextureModes mode,glu::DataType samplerDataType,glu::DataType pDataType,glu::DataType thirdArgumentDataType)1750 std::string genShaderSourceTexture (NegativeTestContext& ctx, glu::ShaderType shaderType, FunctionTextureModes mode, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType thirdArgumentDataType)
1751 {
1752 std::ostringstream source;
1753 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"
1754 << getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
1755 << getShaderInitialization(ctx, shaderType)
1756 << declareShaderUniform(samplerDataType, "sampler")
1757 << "void main(void)\n"
1758 << "{\n"
1759 << " highp " << declareAndInitializeShaderVariable(pDataType, "lod");
1760
1761 switch (mode)
1762 {
1763 case FUNCTION_TEXTURE_MODE_NO_BIAS_NO_COMPARE:
1764 source << " texture(sampler, lod);\n";
1765 break;
1766
1767 case FUNCTION_TEXTURE_MODE_BIAS_OR_COMPARE:
1768 source << " highp " << declareAndInitializeShaderVariable(thirdArgumentDataType, "thirdArgument")
1769 << " texture(sampler, lod, thirdArgument);\n";
1770 break;
1771
1772 default:
1773 DE_FATAL("Unsupported shader function overload.");
1774 }
1775
1776 source << "}\n";
1777
1778 return source.str();
1779 }
1780
genShaderSourceTexture(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType pDataType)1781 std::string genShaderSourceTexture (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType)
1782 {
1783 return genShaderSourceTexture(ctx, shaderType, FUNCTION_TEXTURE_MODE_NO_BIAS_NO_COMPARE, samplerDataType, pDataType, glu::TYPE_LAST);
1784 }
1785
genShaderSourceTexture(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType pDataType,glu::DataType thirdArgumentDataType)1786 std::string genShaderSourceTexture (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType thirdArgumentDataType)
1787 {
1788 return genShaderSourceTexture(ctx, shaderType, FUNCTION_TEXTURE_MODE_BIAS_OR_COMPARE, samplerDataType, pDataType, thirdArgumentDataType);
1789 }
1790
texture_invalid_p(NegativeTestContext & ctx)1791 void texture_invalid_p (NegativeTestContext& ctx)
1792 {
1793 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
1794 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
1795
1796 ctx.beginSection("texture: Invalid P type.");
1797 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
1798 {
1799 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
1800 {
1801 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
1802 for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
1803 {
1804 // SAMPLER_2D
1805 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC2)
1806 {
1807 {
1808 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_floatTypes[dataTypeNdx]));
1809 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1810 }
1811 {
1812 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
1813 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1814 }
1815 {
1816 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_floatTypes[dataTypeNdx]));
1817 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1818 }
1819 {
1820 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
1821 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1822 }
1823 {
1824 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_floatTypes[dataTypeNdx]));
1825 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1826 }
1827 {
1828 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
1829 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1830 }
1831 }
1832 {
1833 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_intTypes[dataTypeNdx]));
1834 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1835 }
1836 {
1837 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
1838 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1839 }
1840 {
1841 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_intTypes[dataTypeNdx]));
1842 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1843 }
1844 {
1845 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
1846 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1847 }
1848 {
1849 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_intTypes[dataTypeNdx]));
1850 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1851 }
1852 {
1853 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
1854 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1855 }
1856 {
1857 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_uintTypes[dataTypeNdx]));
1858 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1859 }
1860 {
1861 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
1862 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1863 }
1864 {
1865 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_uintTypes[dataTypeNdx]));
1866 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1867 }
1868 {
1869 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
1870 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1871 }
1872 {
1873 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_uintTypes[dataTypeNdx]));
1874 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1875 }
1876 {
1877 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
1878 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1879 }
1880
1881 // SAMPLER_3D
1882 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC3)
1883 {
1884 {
1885 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_floatTypes[dataTypeNdx]));
1886 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1887 }
1888 {
1889 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
1890 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1891 }
1892 {
1893 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_floatTypes[dataTypeNdx]));
1894 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1895 }
1896 {
1897 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
1898 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1899 }
1900 {
1901 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_floatTypes[dataTypeNdx]));
1902 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1903 }
1904 {
1905 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
1906 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1907 }
1908 }
1909 {
1910 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_intTypes[dataTypeNdx]));
1911 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1912 }
1913 {
1914 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
1915 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1916 }
1917 {
1918 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_intTypes[dataTypeNdx]));
1919 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1920 }
1921 {
1922 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
1923 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1924 }
1925 {
1926 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_intTypes[dataTypeNdx]));
1927 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1928 }
1929 {
1930 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
1931 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1932 }
1933 {
1934 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_uintTypes[dataTypeNdx]));
1935 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1936 }
1937 {
1938 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
1939 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1940 }
1941 {
1942 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_uintTypes[dataTypeNdx]));
1943 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1944 }
1945 {
1946 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
1947 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1948 }
1949 {
1950 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_uintTypes[dataTypeNdx]));
1951 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1952 }
1953 {
1954 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
1955 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1956 }
1957
1958 // SAMPLER_CUBE
1959 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC3)
1960 {
1961 {
1962 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_floatTypes[dataTypeNdx]));
1963 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1964 }
1965 {
1966 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
1967 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1968 }
1969 {
1970 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_floatTypes[dataTypeNdx]));
1971 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1972 }
1973 {
1974 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
1975 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1976 }
1977 {
1978 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_floatTypes[dataTypeNdx]));
1979 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1980 }
1981 {
1982 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
1983 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1984 }
1985 }
1986 {
1987 {
1988 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_intTypes[dataTypeNdx]));
1989 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1990 }
1991 {
1992 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
1993 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1994 }
1995 {
1996 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_intTypes[dataTypeNdx]));
1997 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
1998 }
1999 {
2000 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2001 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2002 }
2003 {
2004 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_intTypes[dataTypeNdx]));
2005 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2006 }
2007 {
2008 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2009 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2010 }
2011 }
2012 {
2013 {
2014 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_uintTypes[dataTypeNdx]));
2015 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2016 }
2017 {
2018 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2019 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2020 }
2021 {
2022 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_uintTypes[dataTypeNdx]));
2023 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2024 }
2025 {
2026 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2027 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2028 }
2029 {
2030 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_uintTypes[dataTypeNdx]));
2031 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2032 }
2033 {
2034 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2035 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2036 }
2037 }
2038
2039 // SAMPLER_2D_ARRAY
2040 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC3)
2041 {
2042 {
2043 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx]));
2044 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2045 }
2046 {
2047 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2048 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2049 }
2050 {
2051 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx]));
2052 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2053 }
2054 {
2055 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2056 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2057 }
2058 {
2059 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx]));
2060 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2061 }
2062 {
2063 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2064 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2065 }
2066 }
2067 {
2068 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx]));
2069 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2070 }
2071 {
2072 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2073 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2074 }
2075 {
2076 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx]));
2077 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2078 }
2079 {
2080 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2081 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2082 }
2083 {
2084 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx]));
2085 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2086 }
2087 {
2088 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2089 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2090 }
2091 {
2092 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx]));
2093 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2094 }
2095 {
2096 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2097 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2098 }
2099 {
2100 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx]));
2101 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2102 }
2103 {
2104 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2105 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2106 }
2107 {
2108 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx]));
2109 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2110 }
2111 {
2112 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2113 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2114 }
2115
2116 // SAMPLER_2D_SHADOW
2117 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC3)
2118 {
2119 {
2120 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_floatTypes[dataTypeNdx]));
2121 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2122 }
2123 {
2124 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2125 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2126 }
2127 }
2128 {
2129 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_intTypes[dataTypeNdx]));
2130 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2131 }
2132 {
2133 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2134 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2135 }
2136 {
2137 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_uintTypes[dataTypeNdx]));
2138 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2139 }
2140 {
2141 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2142 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2143 }
2144
2145 // SAMPLER_CUBE_SHADOW
2146 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
2147 {
2148 {
2149 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_floatTypes[dataTypeNdx]));
2150 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2151 }
2152 {
2153 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2154 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2155 }
2156 }
2157 {
2158 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_intTypes[dataTypeNdx]));
2159 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2160 }
2161 {
2162 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2163 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2164 }
2165 {
2166 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_uintTypes[dataTypeNdx]));
2167 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2168 }
2169 {
2170 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2171 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2172 }
2173
2174 // SAMPLER_2D_ARRAY_SHADOW
2175 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
2176 {
2177 {
2178 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_floatTypes[dataTypeNdx]));
2179 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2180 }
2181 {
2182 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2183 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2184 }
2185 }
2186 {
2187 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_intTypes[dataTypeNdx]));
2188 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2189 }
2190 {
2191 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2192 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2193 }
2194 {
2195 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_uintTypes[dataTypeNdx]));
2196 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2197 }
2198 {
2199 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2200 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2201 }
2202
2203 // SAMPLER_CUBE_ARRAY
2204 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
2205 {
2206 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
2207 {
2208 {
2209 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx]));
2210 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2211 }
2212 {
2213 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2214 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2215 }
2216 {
2217 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx]));
2218 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2219 }
2220 {
2221 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2222 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2223 }
2224 {
2225 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx]));
2226 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2227 }
2228 {
2229 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2230 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2231 }
2232 }
2233 {
2234 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx]));
2235 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2236 }
2237 {
2238 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2239 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2240 }
2241 {
2242 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx]));
2243 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2244 }
2245 {
2246 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2247 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2248 }
2249 {
2250 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx]));
2251 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2252 }
2253 {
2254 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2255 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2256 }
2257 {
2258 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx]));
2259 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2260 }
2261 {
2262 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2263 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2264 }
2265 {
2266 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx]));
2267 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2268 }
2269 {
2270 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2271 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2272 }
2273 {
2274 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx]));
2275 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2276 }
2277 {
2278 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2279 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2280 }
2281 }
2282
2283 // SAMPLER_CUBE_ARRAY_SHADOW
2284 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW)))
2285 {
2286 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
2287 {
2288 std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2289 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2290 }
2291 {
2292 std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2293 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2294 }
2295 {
2296 std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2297 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2298 }
2299 }
2300 }
2301 ctx.endSection();
2302 }
2303 }
2304 ctx.endSection();
2305 }
2306
texture_invalid_bias_or_compare(NegativeTestContext & ctx)2307 void texture_invalid_bias_or_compare (NegativeTestContext& ctx)
2308 {
2309 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
2310 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
2311
2312 ctx.beginSection("texture: Invalid bias/compare type.");
2313 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
2314 {
2315 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
2316 {
2317 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
2318 for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
2319 {
2320 // SAMPLER_2D
2321 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
2322 {
2323 {
2324 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_floatTypes[dataTypeNdx]));
2325 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2326 }
2327 {
2328 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_floatTypes[dataTypeNdx]));
2329 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2330 }
2331 {
2332 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_floatTypes[dataTypeNdx]));
2333 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2334 }
2335 }
2336 {
2337 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_intTypes[dataTypeNdx]));
2338 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2339 }
2340 {
2341 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_uintTypes[dataTypeNdx]));
2342 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2343 }
2344 {
2345 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_intTypes[dataTypeNdx]));
2346 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2347 }
2348 {
2349 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_uintTypes[dataTypeNdx]));
2350 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2351 }
2352 {
2353 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_intTypes[dataTypeNdx]));
2354 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2355 }
2356 {
2357 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, s_uintTypes[dataTypeNdx]));
2358 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2359 }
2360
2361 // SAMPLER_3D
2362 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
2363 {
2364 {
2365 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
2366 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2367 }
2368 {
2369 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
2370 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2371 }
2372 {
2373 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
2374 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2375 }
2376 }
2377 {
2378 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2379 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2380 }
2381 {
2382 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2383 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2384 }
2385 {
2386 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2387 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2388 }
2389 {
2390 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2391 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2392 }
2393 {
2394 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2395 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2396 }
2397 {
2398 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2399 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2400 }
2401
2402 // SAMPLER_CUBE
2403 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
2404 {
2405 std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
2406 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2407 shaderSource = genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]);
2408 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2409 shaderSource = genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]);
2410 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2411 }
2412 {
2413 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2414 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2415 }
2416 {
2417 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2418 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2419 }
2420 {
2421 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2422 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2423 }
2424 {
2425 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2426 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2427 }
2428 {
2429 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2430 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2431 }
2432 {
2433 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2434 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2435 }
2436
2437 // SAMPLER_2D_ARRAY
2438 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
2439 {
2440 {
2441 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
2442 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2443 }
2444 {
2445 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
2446 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2447 }
2448 {
2449 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
2450 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2451 }
2452 }
2453 {
2454 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2455 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2456 }
2457 {
2458 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2459 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2460 }
2461 {
2462 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2463 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2464 }
2465 {
2466 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2467 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2468 }
2469 {
2470 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2471 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2472 }
2473 {
2474 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2475 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2476 }
2477
2478 // SAMPLER_2D_SHADOW
2479 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
2480 {
2481 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC3, s_floatTypes[dataTypeNdx]));
2482 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2483 }
2484 {
2485 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC3, s_intTypes[dataTypeNdx]));
2486 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2487 }
2488 {
2489 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC3, s_uintTypes[dataTypeNdx]));
2490 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2491 }
2492
2493 // SAMPLER_CUBE_SHADOW
2494 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
2495 {
2496 std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
2497 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2498 }
2499 {
2500 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
2501 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2502 }
2503 {
2504 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
2505 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2506 }
2507
2508 // SAMPLER_CUBE_ARRAY
2509 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
2510 {
2511 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
2512 {
2513 {
2514 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
2515 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2516 }
2517 {
2518 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
2519 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2520 }
2521 {
2522 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
2523 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2524 }
2525 }
2526 {
2527 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
2528 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2529 }
2530 {
2531 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
2532 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2533 }
2534 {
2535 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
2536 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2537 }
2538 {
2539 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
2540 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2541 }
2542 {
2543 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
2544 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2545 }
2546 {
2547 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
2548 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2549 }
2550 }
2551
2552 // SAMPLER_CUBE_ARRAY_SHADOW
2553 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW)))
2554 {
2555 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
2556 {
2557 {
2558 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC4, s_floatTypes[dataTypeNdx]));
2559 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2560 }
2561 }
2562 {
2563 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
2564 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2565 }
2566 {
2567 const std::string shaderSource(genShaderSourceTexture(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
2568 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2569 }
2570 }
2571 }
2572 ctx.endSection();
2573 }
2574 }
2575 ctx.endSection();
2576 }
2577
2578 // textureLod
genShaderSourceTextureLod(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType pDataType,glu::DataType lodDataType)2579 std::string genShaderSourceTextureLod (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType lodDataType)
2580 {
2581 std::ostringstream source;
2582 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"
2583 << getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
2584 << getShaderInitialization(ctx, shaderType)
2585 << declareShaderUniform(samplerDataType, "sampler")
2586 << "void main(void)\n"
2587 << "{\n"
2588 << " " << declareAndInitializeShaderVariable(pDataType, "P")
2589 << " " << declareAndInitializeShaderVariable(lodDataType, "lod")
2590 << " textureLod(sampler, P, lod);\n"
2591 << "}\n";
2592
2593 return source.str();
2594 }
2595
texture_lod_invalid_p(NegativeTestContext & ctx)2596 void texture_lod_invalid_p (NegativeTestContext& ctx)
2597 {
2598 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
2599 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
2600
2601 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
2602 {
2603 ctx.beginSection("textureLod: Invalid P type.");
2604 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
2605 {
2606 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
2607 {
2608 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
2609 for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
2610 {
2611 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT_VEC4)
2612 {
2613 {
2614 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2615 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2616 }
2617 {
2618 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2619 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2620 }
2621 {
2622 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_FLOAT));
2623 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2624 }
2625 }
2626 {
2627 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2628 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2629 }
2630 {
2631 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2632 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2633 }
2634 {
2635 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_FLOAT));
2636 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2637 }
2638 {
2639 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2640 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2641 }
2642 {
2643 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2644 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2645 }
2646 {
2647 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_FLOAT));
2648 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2649 }
2650 }
2651 ctx.endSection();
2652 }
2653 }
2654 ctx.endSection();
2655 }
2656 }
2657
texture_lod_invalid_lod(NegativeTestContext & ctx)2658 void texture_lod_invalid_lod (NegativeTestContext& ctx)
2659 {
2660 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
2661 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
2662
2663 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
2664 {
2665 ctx.beginSection("textureLod: Invalid lod type.");
2666 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
2667 {
2668 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
2669 {
2670 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
2671 for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
2672 {
2673 if (s_floatTypes[dataTypeNdx] != glu::TYPE_FLOAT)
2674 {
2675 {
2676 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, s_floatTypes[dataTypeNdx]));
2677 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2678 }
2679 {
2680 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, s_floatTypes[dataTypeNdx]));
2681 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2682 }
2683 {
2684 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, s_floatTypes[dataTypeNdx]));
2685 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2686 }
2687 }
2688 {
2689 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
2690 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2691 }
2692 {
2693 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
2694 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2695 }
2696 {
2697 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_intTypes[dataTypeNdx]));
2698 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2699 }
2700 {
2701 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
2702 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2703 }
2704 {
2705 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
2706 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2707 }
2708 {
2709 const std::string shaderSource(genShaderSourceTextureLod(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, s_uintTypes[dataTypeNdx]));
2710 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2711 }
2712 }
2713 ctx.endSection();
2714 }
2715 }
2716 ctx.endSection();
2717 }
2718 }
2719
2720 // texelFetch
genShaderSourceTexelFetch(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType pDataType,glu::DataType sampleDataType)2721 std::string genShaderSourceTexelFetch (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType sampleDataType)
2722 {
2723 std::ostringstream source;
2724 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"
2725 << getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
2726 << getShaderInitialization(ctx, shaderType)
2727 << declareShaderUniform(samplerDataType, "sampler")
2728 << "void main(void)\n"
2729 << "{\n"
2730 << " " << declareAndInitializeShaderVariable(pDataType, "P");
2731
2732 switch (samplerDataType)
2733 {
2734 case glu::TYPE_SAMPLER_2D_MULTISAMPLE:
2735 case glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE:
2736 case glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE:
2737 case glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY:
2738 case glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
2739 case glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY:
2740 source << " " << declareAndInitializeShaderVariable(sampleDataType, "varSample")
2741 << " texelFetch(sampler, P, varSample);\n";
2742 break;
2743
2744 case glu::TYPE_SAMPLER_BUFFER:
2745 case glu::TYPE_INT_SAMPLER_BUFFER:
2746 case glu::TYPE_UINT_SAMPLER_BUFFER:
2747 source << " texelFetch(sampler, P);\n";
2748 break;
2749
2750 default:
2751 DE_FATAL("Unsupported data type.");
2752 }
2753
2754 source << "}\n";
2755
2756 return source.str();
2757 }
2758
genShaderSourceTexelFetch(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType pDataType)2759 std::string genShaderSourceTexelFetch (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType)
2760 {
2761 return genShaderSourceTexelFetch(ctx, shaderType, samplerDataType, pDataType, glu::TYPE_LAST);
2762 }
2763
texel_fetch_invalid_p(NegativeTestContext & ctx)2764 void texel_fetch_invalid_p (NegativeTestContext& ctx)
2765 {
2766 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
2767 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
2768
2769 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
2770 {
2771 ctx.beginSection("texelFetch: Invalid P type.");
2772 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
2773 {
2774 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
2775 {
2776 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
2777 for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
2778 {
2779 // SAMPLER_2D_MULTISAMPLE
2780 {
2781 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
2782 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2783 }
2784 {
2785 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
2786 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2787 }
2788 {
2789 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
2790 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2791 }
2792
2793 if (s_intTypes[dataTypeNdx] != glu::TYPE_INT_VEC2)
2794 {
2795 {
2796 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, s_intTypes[dataTypeNdx], glu::TYPE_INT));
2797 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2798 }
2799 {
2800 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, s_intTypes[dataTypeNdx], glu::TYPE_INT));
2801 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2802 }
2803 {
2804 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, s_intTypes[dataTypeNdx], glu::TYPE_INT));
2805 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2806 }
2807 }
2808 {
2809 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
2810 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2811 }
2812 {
2813 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
2814 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2815 }
2816 {
2817 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
2818 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2819 }
2820
2821 // SAMPLER_BUFFER
2822 {
2823 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_BUFFER, s_floatTypes[dataTypeNdx]));
2824 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2825 }
2826 {
2827 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_BUFFER, s_floatTypes[dataTypeNdx]));
2828 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2829 }
2830 {
2831 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_BUFFER, s_floatTypes[dataTypeNdx]));
2832 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2833 }
2834
2835 if (s_intTypes[dataTypeNdx] != glu::TYPE_INT)
2836 {
2837 {
2838 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_BUFFER, s_intTypes[dataTypeNdx]));
2839 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2840 }
2841 {
2842 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_BUFFER, s_intTypes[dataTypeNdx]));
2843 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2844 }
2845 {
2846 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_BUFFER, s_intTypes[dataTypeNdx]));
2847 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2848 }
2849 }
2850
2851 {
2852 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_BUFFER, s_uintTypes[dataTypeNdx]));
2853 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2854 }
2855 {
2856 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_BUFFER, s_uintTypes[dataTypeNdx]));
2857 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2858 }
2859 {
2860 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_BUFFER, s_uintTypes[dataTypeNdx]));
2861 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2862 }
2863
2864 // SAMPLER_2D_MULTISAMPLE_ARRAY
2865 {
2866 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
2867 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2868 }
2869 {
2870 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
2871 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2872 }
2873 {
2874 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_floatTypes[dataTypeNdx], glu::TYPE_INT));
2875 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2876 }
2877
2878 if (s_intTypes[dataTypeNdx] != glu::TYPE_INT_VEC3)
2879 {
2880 {
2881 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_INT));
2882 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2883 }
2884 {
2885 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_INT));
2886 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2887 }
2888 {
2889 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_intTypes[dataTypeNdx], glu::TYPE_INT));
2890 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2891 }
2892 }
2893 {
2894 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
2895 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2896 }
2897 {
2898 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
2899 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2900 }
2901 {
2902 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, s_uintTypes[dataTypeNdx], glu::TYPE_INT));
2903 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2904 }
2905 }
2906 ctx.endSection();
2907 }
2908 }
2909 ctx.endSection();
2910 }
2911 }
2912
texel_fetch_invalid_sample(NegativeTestContext & ctx)2913 void texel_fetch_invalid_sample (NegativeTestContext& ctx)
2914 {
2915 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_intTypes));
2916 DE_ASSERT(DE_LENGTH_OF_ARRAY(s_floatTypes) == DE_LENGTH_OF_ARRAY(s_uintTypes));
2917
2918 if (checkSupport(ctx) || ctx.isExtensionSupported(getDataTypeExtension(glu::TYPE_SAMPLER_CUBE_ARRAY)))
2919 {
2920 ctx.beginSection("texelFetch: Invalid sample type.");
2921 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
2922 {
2923 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
2924 {
2925 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
2926 for (int dataTypeNdx = 0; dataTypeNdx < DE_LENGTH_OF_ARRAY(s_floatTypes); ++dataTypeNdx)
2927 {
2928 // SAMPLER_2D_MULTISAMPLE
2929 {
2930 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_floatTypes[dataTypeNdx]));
2931 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2932 }
2933 {
2934 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_floatTypes[dataTypeNdx]));
2935 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2936 }
2937 {
2938 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_floatTypes[dataTypeNdx]));
2939 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2940 }
2941
2942 // SAMPLER_2D_MULTISAMPLE_ARRAY
2943 {
2944 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_floatTypes[dataTypeNdx]));
2945 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2946 }
2947 {
2948 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_floatTypes[dataTypeNdx]));
2949 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2950 }
2951 {
2952 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_floatTypes[dataTypeNdx]));
2953 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2954 }
2955
2956 if (s_intTypes[dataTypeNdx] != glu::TYPE_INT)
2957 {
2958 // SAMPLER_2D_MULTISAMPLE
2959 {
2960 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_intTypes[dataTypeNdx]));
2961 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2962 }
2963 {
2964 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_intTypes[dataTypeNdx]));
2965 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2966 }
2967 {
2968 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_intTypes[dataTypeNdx]));
2969 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2970 }
2971
2972 // SAMPLER_2D_MULTISAMPLE_ARRAY
2973 {
2974 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_intTypes[dataTypeNdx]));
2975 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2976 }
2977 {
2978 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_intTypes[dataTypeNdx]));
2979 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2980 }
2981 {
2982 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_intTypes[dataTypeNdx]));
2983 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2984 }
2985 }
2986
2987 // SAMPLER_2D_MULTISAMPLE
2988 {
2989 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_uintTypes[dataTypeNdx]));
2990 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2991 }
2992 {
2993 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_uintTypes[dataTypeNdx]));
2994 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2995 }
2996 {
2997 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE, glu::TYPE_INT_VEC2, s_uintTypes[dataTypeNdx]));
2998 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
2999 }
3000
3001 // SAMPLER_2D_MULTISAMPLE_ARRAY
3002 {
3003 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_uintTypes[dataTypeNdx]));
3004 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3005 }
3006 {
3007 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_uintTypes[dataTypeNdx]));
3008 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3009 }
3010 {
3011 const std::string shaderSource(genShaderSourceTexelFetch(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_MULTISAMPLE_ARRAY, glu::TYPE_INT_VEC3, s_uintTypes[dataTypeNdx]));
3012 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3013 }
3014 }
3015 ctx.endSection();
3016 }
3017 }
3018 ctx.endSection();
3019 }
3020 }
3021
3022 // EmitVertex, EndPrimitive
genShaderSourceGeometry(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function)3023 std::string genShaderSourceGeometry (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function)
3024 {
3025 DE_ASSERT(function == SHADER_FUNCTION_EMIT_VERTEX || function == SHADER_FUNCTION_END_PRIMITIVE);
3026
3027 std::ostringstream source;
3028 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"
3029 << getShaderInitialization(ctx, shaderType)
3030 << "void main(void)\n"
3031 << "{\n";
3032
3033 switch (function)
3034 {
3035 case SHADER_FUNCTION_EMIT_VERTEX:
3036 source << " EmitVertex();\n";
3037 break;
3038
3039 case SHADER_FUNCTION_END_PRIMITIVE:
3040 source << " EndPrimitive();\n";
3041 break;
3042
3043 default:
3044 DE_FATAL("Unsupported shader function.");
3045 }
3046
3047 source << "}\n";
3048
3049 return source.str();
3050 }
3051
emit_vertex(NegativeTestContext & ctx)3052 void emit_vertex (NegativeTestContext& ctx)
3053 {
3054 ctx.beginSection("EmitVertex.");
3055 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3056 {
3057 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3058 {
3059 if (s_shaders[shaderNdx] == glu::SHADERTYPE_GEOMETRY)
3060 continue;
3061
3062 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3063 const std::string shaderSource = genShaderSourceGeometry(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_EMIT_VERTEX);
3064 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3065 ctx.endSection();
3066 }
3067 }
3068 ctx.endSection();
3069 }
3070
end_primitive(NegativeTestContext & ctx)3071 void end_primitive (NegativeTestContext& ctx)
3072 {
3073 ctx.beginSection("EndPrimitieve.");
3074 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3075 {
3076 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3077 {
3078 if (s_shaders[shaderNdx] == glu::SHADERTYPE_GEOMETRY)
3079 continue;
3080
3081 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3082 const std::string shaderSource = genShaderSourceGeometry(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_END_PRIMITIVE);
3083 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3084 ctx.endSection();
3085 }
3086 }
3087 ctx.endSection();
3088 }
3089
3090 // textureGrad
genShaderSourceTextureGrad(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType pDataType,glu::DataType dpdxDataType,glu::DataType dpdyDataType)3091 std::string genShaderSourceTextureGrad (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType dpdxDataType, glu::DataType dpdyDataType)
3092 {
3093 std::ostringstream source;
3094
3095 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"
3096 << getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
3097 << getShaderInitialization(ctx, shaderType)
3098 << declareShaderUniform(samplerDataType, "sampler")
3099 << "void main(void)\n"
3100 << "{\n"
3101 << " mediump " << declareAndInitializeShaderVariable(pDataType, "P")
3102 << " mediump " << declareAndInitializeShaderVariable(dpdxDataType, "dPdx")
3103 << " mediump " << declareAndInitializeShaderVariable(dpdyDataType, "dPdy")
3104 << " textureGrad(sampler, P, dPdx, dPdy);\n"
3105 << "}\n";
3106
3107 return source.str();
3108 }
3109
texture_grad(NegativeTestContext & ctx)3110 void texture_grad (NegativeTestContext& ctx)
3111 {
3112 TCU_CHECK_AND_THROW(NotSupportedError, ctx.isExtensionSupported("GL_EXT_texture_cube_map_array") || checkSupport(ctx),
3113 "Test requires support for GL_EXT_texture_cube_map_array or version 3.2.");
3114
3115 ctx.beginSection("textureGrad.");
3116 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3117 {
3118 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3119 {
3120 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3121 {
3122 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));
3123 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3124 }
3125 {
3126 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));
3127 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3128 }
3129 {
3130 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));
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, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT_VEC3));
3135 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3136 }
3137 {
3138 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));
3139 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3140 }
3141 {
3142 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));
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, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT_VEC3));
3147 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3148 }
3149 {
3150 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));
3151 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3152 }
3153 {
3154 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));
3155 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3156 }
3157 ctx.endSection();
3158 }
3159 }
3160 ctx.endSection();
3161 }
3162
3163 // textureGather
genShaderSourceTextureGather(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType pDataType,glu::DataType thirdArgument)3164 std::string genShaderSourceTextureGather (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType thirdArgument)
3165 {
3166 std::ostringstream source;
3167
3168 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"
3169 << getShaderExtensionDeclaration(getDataTypeExtension(samplerDataType))
3170 << getShaderInitialization(ctx, shaderType)
3171 << declareShaderUniform(samplerDataType, "sampler")
3172 << "void main(void)\n"
3173 << "{\n"
3174 << " mediump " << declareAndInitializeShaderVariable(pDataType, "P");
3175
3176 if (thirdArgument != glu::TYPE_LAST)
3177 source << " mediump " << declareAndInitializeShaderVariable(thirdArgument, "arg3")
3178 << " textureGather(sampler, P, arg3);\n";
3179 else
3180 source << " textureGather(sampler, P);\n";
3181
3182 source << "}\n";
3183
3184 return source.str();
3185 }
3186
genShaderSourceTextureGather(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType samplerDataType,glu::DataType pDataType)3187 std::string genShaderSourceTextureGather (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType samplerDataType, glu::DataType pDataType)
3188 {
3189 return genShaderSourceTextureGather(ctx, shaderType, samplerDataType, pDataType, glu::TYPE_LAST);
3190 }
3191
texture_gather_sampler_2d(NegativeTestContext & ctx)3192 void texture_gather_sampler_2d (NegativeTestContext& ctx)
3193 {
3194 ctx.beginSection("textureGrad - sampler2D");
3195 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3196 {
3197 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3198 {
3199 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3200 {
3201 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT));
3202 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3203 }
3204 {
3205 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
3206 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3207 }
3208 {
3209 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT));
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));
3214 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3215 }
3216 {
3217 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
3218 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3219 }
3220 {
3221 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT));
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));
3226 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3227 }
3228 {
3229 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
3230 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3231 }
3232 {
3233 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT));
3234 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3235 }
3236 {
3237 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC2));
3238 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3239 }
3240 {
3241 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT));
3242 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3243 }
3244 ctx.endSection();
3245 }
3246 }
3247 ctx.endSection();
3248 }
3249
texture_gather_sampler_2d_array(NegativeTestContext & ctx)3250 void texture_gather_sampler_2d_array (NegativeTestContext& ctx)
3251 {
3252 ctx.beginSection("textureGrad - sampler2DArray");
3253 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3254 {
3255 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3256 {
3257 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3258 {
3259 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT));
3260 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3261 }
3262 {
3263 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
3264 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3265 }
3266 {
3267 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
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));
3272 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3273 }
3274 {
3275 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
3276 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3277 }
3278 {
3279 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
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));
3284 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3285 }
3286 {
3287 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
3288 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3289 }
3290 {
3291 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
3292 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3293 }
3294 {
3295 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3));
3296 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3297 }
3298 {
3299 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
3300 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3301 }
3302 ctx.endSection();
3303 }
3304 }
3305 ctx.endSection();
3306 }
3307
texture_gather_sampler_cube(NegativeTestContext & ctx)3308 void texture_gather_sampler_cube (NegativeTestContext& ctx)
3309 {
3310 ctx.beginSection("textureGrad - samplerCube");
3311 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3312 {
3313 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3314 {
3315 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3316 {
3317 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT));
3318 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3319 }
3320 {
3321 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
3322 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3323 }
3324 {
3325 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE, glu::TYPE_FLOAT, glu::TYPE_INT));
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));
3330 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3331 }
3332 {
3333 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
3334 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3335 }
3336 {
3337 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE, glu::TYPE_FLOAT, glu::TYPE_INT));
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));
3342 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3343 }
3344 {
3345 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
3346 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3347 }
3348 {
3349 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE, glu::TYPE_FLOAT, glu::TYPE_INT));
3350 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3351 }
3352 {
3353 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3));
3354 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3355 }
3356 {
3357 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
3358 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3359 }
3360 ctx.endSection();
3361 }
3362 }
3363 ctx.endSection();
3364 }
3365
texture_gather_sampler_2d_shadow(NegativeTestContext & ctx)3366 void texture_gather_sampler_2d_shadow (NegativeTestContext& ctx)
3367 {
3368 ctx.beginSection("textureGrad - sampler2DShadow");
3369 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3370 {
3371 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3372 {
3373 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3374 {
3375 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, 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_2D_SHADOW, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT));
3380 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3381 }
3382 {
3383 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
3384 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3385 }
3386 {
3387 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
3388 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3389 }
3390 ctx.endSection();
3391 }
3392 }
3393 ctx.endSection();
3394 }
3395
texture_gather_sampler_2d_array_shadow(NegativeTestContext & ctx)3396 void texture_gather_sampler_2d_array_shadow (NegativeTestContext& ctx)
3397 {
3398 ctx.beginSection("textureGrad - sampler2DArrayShadow");
3399 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3400 {
3401 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3402 {
3403 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3404 {
3405 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, 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_2D_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
3410 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3411 }
3412 {
3413 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_2D_ARRAY_SHADOW, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
3414 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3415 }
3416 {
3417 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
3418 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3419 }
3420 ctx.endSection();
3421 }
3422 }
3423 ctx.endSection();
3424 }
3425
texture_gather_sampler_cube_shadow(NegativeTestContext & ctx)3426 void texture_gather_sampler_cube_shadow (NegativeTestContext& ctx)
3427 {
3428 ctx.beginSection("textureGrad - samplerCubeShadow");
3429 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3430 {
3431 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3432 {
3433 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3434 {
3435 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, 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_CUBE_SHADOW, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
3440 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3441 }
3442 {
3443 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_SHADOW, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
3444 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3445 }
3446 {
3447 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
3448 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3449 }
3450 ctx.endSection();
3451 }
3452 }
3453 ctx.endSection();
3454 }
3455
texture_gather_sampler_cube_array(NegativeTestContext & ctx)3456 void texture_gather_sampler_cube_array (NegativeTestContext& ctx)
3457 {
3458 TCU_CHECK_AND_THROW(
3459 NotSupportedError,
3460 checkSupport(ctx) || ctx.isExtensionSupported("GL_EXT_texture_cube_map_array"),
3461 "Test requires extension GL_EXT_texture_cube_map_array or context version 3.2 or higher.");
3462
3463 ctx.beginSection("textureGrad - samplerCubeArray");
3464 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3465 {
3466 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3467 {
3468 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3469 {
3470 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT));
3471 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3472 }
3473 {
3474 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
3475 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3476 }
3477 {
3478 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
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));
3483 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3484 }
3485 {
3486 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
3487 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3488 }
3489 {
3490 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_INT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
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));
3495 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3496 }
3497 {
3498 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT));
3499 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3500 }
3501 {
3502 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_UINT_SAMPLER_CUBE_ARRAY, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
3503 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3504 }
3505 {
3506 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC4, glu::TYPE_INT));
3507 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3508 }
3509 ctx.endSection();
3510 }
3511 }
3512 ctx.endSection();
3513 }
3514
texture_gather_sampler_cube_array_shadow(NegativeTestContext & ctx)3515 void texture_gather_sampler_cube_array_shadow (NegativeTestContext& ctx)
3516 {
3517 TCU_CHECK_AND_THROW(
3518 NotSupportedError,
3519 checkSupport(ctx) || ctx.isExtensionSupported("GL_EXT_texture_cube_map_array"),
3520 "Test requires extension GL_EXT_texture_cube_map_array or context version 3.2 or higher.");
3521
3522 ctx.beginSection("textureGrad - samplerCubeArrayShadow");
3523 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3524 {
3525 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3526 {
3527 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3528 {
3529 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT));
3530 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3531 }
3532 {
3533 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
3534 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3535 }
3536 {
3537 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_CUBE_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC4, glu::TYPE_INT));
3538 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3539 }
3540 {
3541 const std::string shaderSource(genShaderSourceTextureGather(ctx, s_shaders[shaderNdx], glu::TYPE_SAMPLER_3D, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
3542 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3543 }
3544 ctx.endSection();
3545 }
3546 }
3547 ctx.endSection();
3548 }
3549
3550 // textureGatherOffset
genShaderSourceTextureGatherOffset(NegativeTestContext & ctx,glu::ShaderType shaderType,FunctionTextureGatherOffsetModes mode,glu::DataType samplerDataType,glu::DataType pDataType,glu::DataType offsetDataType,glu::DataType fourthArgument)3551 std::string genShaderSourceTextureGatherOffset (NegativeTestContext& ctx, glu::ShaderType shaderType, FunctionTextureGatherOffsetModes mode, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType offsetDataType, glu::DataType fourthArgument)
3552 {
3553 DE_ASSERT(mode < FUNCTION_TEXTURE_GATHER_OFFSET_MODE_LAST);
3554
3555 std::ostringstream source;
3556
3557 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"
3558 << getShaderInitialization(ctx, shaderType)
3559 << declareShaderUniform(samplerDataType, "sampler")
3560 << "void main(void)\n"
3561 << "{\n"
3562 << " mediump " << declareAndInitializeShaderVariable(pDataType, "P")
3563 << " mediump " << declareAndInitializeShaderVariable(offsetDataType, "offset");
3564
3565 switch (mode)
3566 {
3567 case FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP:
3568 {
3569 if (fourthArgument != glu::TYPE_LAST)
3570 source << " mediump " << declareAndInitializeShaderVariable(fourthArgument, "comp")
3571 << " textureGatherOffset(sampler, P, offset, comp);\n";
3572 else
3573 source << " textureGatherOffset(sampler, P, offset);\n";
3574 break;
3575 }
3576
3577 case FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z:
3578 {
3579 source << " mediump " << declareAndInitializeShaderVariable(fourthArgument, "refZ")
3580 << " textureGatherOffset(sampler, P, refZ, offset);\n";
3581 break;
3582 }
3583
3584 default:
3585 DE_FATAL("Unsupported shader function overload.");
3586 }
3587
3588 source << "}\n";
3589
3590 return source.str();
3591 }
3592
genShaderSourceTextureGatherOffset(NegativeTestContext & ctx,glu::ShaderType shaderType,FunctionTextureGatherOffsetModes mode,glu::DataType samplerDataType,glu::DataType pDataType,glu::DataType offsetDataType)3593 std::string genShaderSourceTextureGatherOffset (NegativeTestContext& ctx, glu::ShaderType shaderType, FunctionTextureGatherOffsetModes mode, glu::DataType samplerDataType, glu::DataType pDataType, glu::DataType offsetDataType)
3594 {
3595 DE_ASSERT(mode == FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP);
3596
3597 return genShaderSourceTextureGatherOffset(ctx, shaderType, mode, samplerDataType, pDataType, offsetDataType, glu::TYPE_LAST);
3598 }
3599
texture_gather_offset_sampler_2d(NegativeTestContext & ctx)3600 void texture_gather_offset_sampler_2d (NegativeTestContext& ctx)
3601 {
3602 ctx.beginSection("textureGatherOffset - sampler2D");
3603 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3604 {
3605 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3606 {
3607 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
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));
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));
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, glu::TYPE_INT_VEC2, glu::TYPE_INT));
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_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_INT));
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_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
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));
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));
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, glu::TYPE_INT_VEC2, glu::TYPE_INT));
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_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_INT));
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_INT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
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));
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));
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, glu::TYPE_INT_VEC2, glu::TYPE_INT));
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_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_INT));
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_UINT_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT));
3666 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3667 }
3668 {
3669 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));
3670 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3671 }
3672 {
3673 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));
3674 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3675 }
3676 ctx.endSection();
3677 }
3678 }
3679 ctx.endSection();
3680 }
3681
texture_gather_offset_sampler_2d_array(NegativeTestContext & ctx)3682 void texture_gather_offset_sampler_2d_array (NegativeTestContext& ctx)
3683 {
3684 ctx.beginSection("textureGatherOffset - sampler2DArray");
3685 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3686 {
3687 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3688 {
3689 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
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));
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));
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, glu::TYPE_INT_VEC2, glu::TYPE_INT));
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_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_INT));
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_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_FLOAT));
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));
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));
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, glu::TYPE_INT_VEC2, glu::TYPE_INT));
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_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_INT));
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_INT_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_FLOAT));
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));
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));
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, glu::TYPE_INT_VEC2, glu::TYPE_INT));
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_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_INT));
3744 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3745 }
3746 {
3747 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));
3748 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3749 }
3750 {
3751 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));
3752 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3753 }
3754 ctx.endSection();
3755 }
3756 }
3757 ctx.endSection();
3758 }
3759
texture_gather_offset_sampler_2d_shadow(NegativeTestContext & ctx)3760 void texture_gather_offset_sampler_2d_shadow (NegativeTestContext& ctx)
3761 {
3762 ctx.beginSection("textureGatherOffset - sampler2DShadow");
3763 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3764 {
3765 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3766 {
3767 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
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, glu::TYPE_INT_VEC2, 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_2D_SHADOW, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_INT));
3774 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3775 }
3776 {
3777 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));
3778 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3779 }
3780 {
3781 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));
3782 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3783 }
3784 ctx.endSection();
3785 }
3786 }
3787 ctx.endSection();
3788 }
3789
texture_gather_offset_sampler_2d_array_shadow(NegativeTestContext & ctx)3790 void texture_gather_offset_sampler_2d_array_shadow (NegativeTestContext& ctx)
3791 {
3792 ctx.beginSection("textureGatherOffset - sampler2DShadow");
3793 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3794 {
3795 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3796 {
3797 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
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, glu::TYPE_INT_VEC2, 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_2D_ARRAY_SHADOW, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT_VEC2, glu::TYPE_INT));
3804 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3805 }
3806 {
3807 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));
3808 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3809 }
3810 {
3811 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));
3812 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3813 }
3814 ctx.endSection();
3815 }
3816 }
3817 ctx.endSection();
3818 }
3819
3820 // atomicAdd, atomicMin, atomicMax, atomicAnd, atomicOr, atomixXor, atomixExchange, atomicCompSwap
genShaderSourceAtomicOperations(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function,glu::DataType memDataType,glu::DataType dataDataType,glu::DataType compareDataType)3821 std::string genShaderSourceAtomicOperations (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType memDataType, glu::DataType dataDataType, glu::DataType compareDataType)
3822 {
3823 DE_ASSERT(SHADER_FUNCTION_ATOMIC_ADD <= function && function <= SHADER_FUNCTION_ATOMIC_COMP_SWAP);
3824
3825 std::ostringstream source;
3826
3827 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"
3828 << getShaderInitialization(ctx, shaderType)
3829 << declareBuffer(memDataType, "mem")
3830 << "void main()\n"
3831 << "{\n"
3832 << " mediump " << declareAndInitializeShaderVariable(dataDataType, "data");
3833
3834 switch (function)
3835 {
3836 case SHADER_FUNCTION_ATOMIC_ADD: source << " atomicAdd(mem, data);\n"; break;
3837 case SHADER_FUNCTION_ATOMIC_MIN: source << " atomicMin(mem, data);\n"; break;
3838 case SHADER_FUNCTION_ATOMIC_MAX: source << " atomicMax(mem, data);\n"; break;
3839 case SHADER_FUNCTION_ATOMIC_AND: source << " atomicAnd(mem, data);\n"; break;
3840 case SHADER_FUNCTION_ATOMIC_OR: source << " atomicOr(mem, data);\n"; break;
3841 case SHADER_FUNCTION_ATOMIC_XOR: source << " atomicXor(mem, data);\n"; break;
3842 case SHADER_FUNCTION_ATOMIC_EXCHANGE: source << " atomicExchange(mem, data);\n"; break;
3843 case SHADER_FUNCTION_ATOMIC_COMP_SWAP:
3844 source << " mediump " << declareAndInitializeShaderVariable(compareDataType, "compare")
3845 << " atomicCompSwap(mem, compare, data);\n";
3846 break;
3847
3848 default:
3849 DE_FATAL("Unsupported shader function.");
3850 }
3851
3852 source << "}\n";
3853
3854 return source.str();
3855 }
3856
genShaderSourceAtomicOperations(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function,glu::DataType memDataType,glu::DataType dataDataType)3857 std::string genShaderSourceAtomicOperations (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType memDataType, glu::DataType dataDataType)
3858 {
3859 DE_ASSERT(function != SHADER_FUNCTION_ATOMIC_COMP_SWAP);
3860
3861 return genShaderSourceAtomicOperations(ctx, shaderType, function, memDataType, dataDataType, glu::TYPE_LAST);
3862 }
3863
atomic_add(NegativeTestContext & ctx)3864 void atomic_add (NegativeTestContext& ctx)
3865 {
3866 ctx.beginSection("atomicAdd");
3867 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3868 {
3869 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3870 {
3871 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3872 {
3873 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_ADD, glu::TYPE_UINT, glu::TYPE_INT));
3874 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3875 }
3876 {
3877 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_ADD, glu::TYPE_INT, glu::TYPE_UINT));
3878 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3879 }
3880 ctx.endSection();
3881 }
3882 }
3883 ctx.endSection();
3884 }
3885
atomic_min(NegativeTestContext & ctx)3886 void atomic_min (NegativeTestContext& ctx)
3887 {
3888 ctx.beginSection("atomicMin");
3889 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3890 {
3891 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3892 {
3893 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3894 {
3895 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_MIN, glu::TYPE_UINT, glu::TYPE_INT));
3896 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3897 }
3898 {
3899 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_MIN, glu::TYPE_INT, glu::TYPE_UINT));
3900 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3901 }
3902 ctx.endSection();
3903 }
3904 }
3905 ctx.endSection();
3906 }
3907
atomic_max(NegativeTestContext & ctx)3908 void atomic_max (NegativeTestContext& ctx)
3909 {
3910 ctx.beginSection("atomicMax");
3911 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3912 {
3913 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3914 {
3915 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3916 {
3917 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_MAX, glu::TYPE_UINT, glu::TYPE_INT));
3918 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3919 }
3920 {
3921 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_MAX, glu::TYPE_INT, glu::TYPE_UINT));
3922 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3923 }
3924 ctx.endSection();
3925 }
3926 }
3927 ctx.endSection();
3928 }
3929
atomic_and(NegativeTestContext & ctx)3930 void atomic_and (NegativeTestContext& ctx)
3931 {
3932 ctx.beginSection("atomicAnd");
3933 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3934 {
3935 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3936 {
3937 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3938 {
3939 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_AND, glu::TYPE_UINT, glu::TYPE_INT));
3940 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3941 }
3942 {
3943 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_AND, glu::TYPE_INT, glu::TYPE_UINT));
3944 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3945 }
3946 ctx.endSection();
3947 }
3948 }
3949 ctx.endSection();
3950 }
3951
atomic_or(NegativeTestContext & ctx)3952 void atomic_or (NegativeTestContext& ctx)
3953 {
3954 ctx.beginSection("atomicOr");
3955 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3956 {
3957 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3958 {
3959 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3960 {
3961 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_OR, glu::TYPE_UINT, glu::TYPE_INT));
3962 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3963 }
3964 {
3965 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_OR, glu::TYPE_INT, glu::TYPE_UINT));
3966 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3967 }
3968 ctx.endSection();
3969 }
3970 }
3971 ctx.endSection();
3972 }
3973
atomic_xor(NegativeTestContext & ctx)3974 void atomic_xor (NegativeTestContext& ctx)
3975 {
3976 ctx.beginSection("atomicXor");
3977 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
3978 {
3979 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
3980 {
3981 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
3982 {
3983 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_XOR, glu::TYPE_UINT, glu::TYPE_INT));
3984 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3985 }
3986 {
3987 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_XOR, glu::TYPE_INT, glu::TYPE_UINT));
3988 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
3989 }
3990 ctx.endSection();
3991 }
3992 }
3993 ctx.endSection();
3994 }
3995
atomic_exchange(NegativeTestContext & ctx)3996 void atomic_exchange (NegativeTestContext& ctx)
3997 {
3998 ctx.beginSection("atomicExchange");
3999 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
4000 {
4001 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
4002 {
4003 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
4004 {
4005 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_EXCHANGE, glu::TYPE_UINT, glu::TYPE_INT));
4006 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4007 }
4008 {
4009 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_EXCHANGE, glu::TYPE_INT, glu::TYPE_UINT));
4010 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4011 }
4012 ctx.endSection();
4013 }
4014 }
4015 ctx.endSection();
4016 }
4017
atomic_comp_swap(NegativeTestContext & ctx)4018 void atomic_comp_swap (NegativeTestContext& ctx)
4019 {
4020 ctx.beginSection("atomicCompSwap");
4021 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
4022 {
4023 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
4024 {
4025 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
4026 {
4027 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_COMP_SWAP, glu::TYPE_UINT, glu::TYPE_INT, glu::TYPE_INT));
4028 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4029 }
4030 {
4031 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_COMP_SWAP, glu::TYPE_INT, glu::TYPE_UINT, glu::TYPE_INT));
4032 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4033 }
4034 {
4035 const std::string shaderSource(genShaderSourceAtomicOperations(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_ATOMIC_COMP_SWAP, glu::TYPE_INT, glu::TYPE_INT, glu::TYPE_UINT));
4036 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4037 }
4038 ctx.endSection();
4039 }
4040 }
4041 ctx.endSection();
4042 }
4043
4044 // interpolatedAtCentroid, interpolatedAtSample, interpolateAtOffset,
genShaderSourceInterpolateAt(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function,glu::DataType interpolantDataType,glu::DataType secondArgumentDataType)4045 std::string genShaderSourceInterpolateAt (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType interpolantDataType, glu::DataType secondArgumentDataType)
4046 {
4047 DE_ASSERT(function >= SHADER_FUNCTION_INTERPOLATED_AT_CENTROID && function <= SHADER_FUNCTION_INTERPOLATED_AT_OFFSET);
4048
4049 auto ctxType = ctx.getRenderContext().getType();
4050 const bool isES32orGL45 = glu::contextSupports(ctxType, glu::ApiType::es(3, 2)) ||
4051 glu::contextSupports(ctxType, glu::ApiType::core(4, 5));
4052
4053 std::ostringstream source;
4054 source << (isES32orGL45 ? glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : glu::getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES)) << "\n"
4055 << getShaderInitialization(ctx, shaderType)
4056 << (isES32orGL45 ? "" : getShaderExtensionDeclaration("GL_OES_shader_multisample_interpolation"))
4057 << declareShaderInput(interpolantDataType, "interpolant")
4058 << "void main()\n"
4059 << "{\n";
4060
4061 switch (function)
4062 {
4063 case SHADER_FUNCTION_INTERPOLATED_AT_CENTROID:
4064 source << " interpolateAtCentroid(interpolant);\n";
4065 break;
4066
4067 case SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE:
4068 source << " mediump " << declareAndInitializeShaderVariable(secondArgumentDataType, "sample")
4069 << " interpolateAtSample(interpolant, sample);\n";
4070 break;
4071
4072 case SHADER_FUNCTION_INTERPOLATED_AT_OFFSET:
4073 source << " mediump " << declareAndInitializeShaderVariable(secondArgumentDataType, "offset")
4074 << " interpolateAtOffset(interpolant, offset);\n";
4075 break;
4076
4077 default:
4078 DE_FATAL("Unsupported shader function.");
4079 }
4080
4081 source << "}\n";
4082
4083 return source.str();
4084 }
4085
genShaderSourceInterpolateAt(NegativeTestContext & ctx,glu::ShaderType shaderType,ShaderFunction function,glu::DataType interpolantDataType)4086 std::string genShaderSourceInterpolateAt (NegativeTestContext& ctx, glu::ShaderType shaderType, ShaderFunction function, glu::DataType interpolantDataType)
4087 {
4088 DE_ASSERT(function == SHADER_FUNCTION_INTERPOLATED_AT_CENTROID);
4089
4090 return genShaderSourceInterpolateAt(ctx, shaderType, function, interpolantDataType, glu::TYPE_LAST);
4091 }
4092
interpolate_at_centroid(NegativeTestContext & ctx)4093 void interpolate_at_centroid (NegativeTestContext& ctx)
4094 {
4095 TCU_CHECK_AND_THROW(NotSupportedError,
4096 checkSupport(ctx) || ctx.isExtensionSupported("GL_OES_shader_multisample_interpolation"),
4097 "This test requires a context version 3.2 or higher.");
4098
4099 ctx.beginSection("interpolateAtCentroid");
4100 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
4101 {
4102 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
4103 {
4104 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
4105 if (s_shaders[shaderNdx] == glu::SHADERTYPE_FRAGMENT)
4106 {
4107 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_INT));
4108 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4109 }
4110 else
4111 {
4112 {
4113 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_FLOAT));
4114 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4115 }
4116 {
4117 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_FLOAT_VEC2));
4118 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4119 }
4120 {
4121 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_FLOAT_VEC3));
4122 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4123 }
4124 {
4125 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_CENTROID, glu::TYPE_FLOAT_VEC4));
4126 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4127 }
4128 }
4129 ctx.endSection();
4130 }
4131 }
4132 ctx.endSection();
4133 }
4134
interpolate_at_sample(NegativeTestContext & ctx)4135 void interpolate_at_sample (NegativeTestContext& ctx)
4136 {
4137 TCU_CHECK_AND_THROW(NotSupportedError,
4138 checkSupport(ctx) || ctx.isExtensionSupported("GL_OES_shader_multisample_interpolation"),
4139 "This test requires a context version 3.2 or higher.");
4140
4141 ctx.beginSection("interpolateAtSample");
4142 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
4143 {
4144 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
4145 {
4146 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
4147 if (s_shaders[shaderNdx] == glu::SHADERTYPE_FRAGMENT)
4148 {
4149 {
4150 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_INT, glu::TYPE_INT));
4151 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4152 }
4153 {
4154 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
4155 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4156 }
4157 {
4158 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
4159 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4160 }
4161 {
4162 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
4163 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4164 }
4165 {
4166 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
4167 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4168 }
4169 }
4170 else
4171 {
4172 {
4173 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT, glu::TYPE_INT));
4174 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4175 }
4176 {
4177 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT));
4178 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4179 }
4180 {
4181 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT));
4182 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4183 }
4184 {
4185 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_SAMPLE, glu::TYPE_FLOAT_VEC4, glu::TYPE_INT));
4186 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4187 }
4188 }
4189 ctx.endSection();
4190 }
4191 }
4192 ctx.endSection();
4193 }
4194
interpolate_at_offset(NegativeTestContext & ctx)4195 void interpolate_at_offset (NegativeTestContext& ctx)
4196 {
4197 TCU_CHECK_AND_THROW(NotSupportedError,
4198 checkSupport(ctx) || ctx.isExtensionSupported("GL_OES_shader_multisample_interpolation"),
4199 "This test requires a context version 3.2 or higher.");
4200
4201 ctx.beginSection("interpolateAtOffset");
4202 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
4203 {
4204 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
4205 {
4206 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
4207 if (s_shaders[shaderNdx] == glu::SHADERTYPE_FRAGMENT)
4208 {
4209 {
4210 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_INT, glu::TYPE_FLOAT_VEC2));
4211 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4212 }
4213 {
4214 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
4215 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4216 }
4217 {
4218 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT));
4219 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4220 }
4221 {
4222 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT));
4223 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4224 }
4225 {
4226 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT));
4227 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4228 }
4229 }
4230 else
4231 {
4232 {
4233 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT, glu::TYPE_FLOAT_VEC2));
4234 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4235 }
4236 {
4237 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC2, glu::TYPE_FLOAT_VEC2));
4238 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4239 }
4240 {
4241 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC3, glu::TYPE_FLOAT_VEC2));
4242 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4243 }
4244 {
4245 const std::string shaderSource(genShaderSourceInterpolateAt(ctx, s_shaders[shaderNdx], SHADER_FUNCTION_INTERPOLATED_AT_OFFSET, glu::TYPE_FLOAT_VEC4, glu::TYPE_FLOAT_VEC2));
4246 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4247 }
4248 }
4249 ctx.endSection();
4250 }
4251 }
4252 ctx.endSection();
4253 }
4254
4255
4256 // textureGatherOffsets
genShaderSourceTextureGatherOffsets(NegativeTestContext & ctx,glu::ShaderType shaderType,const TextureGatherOffsetsTestSpec & spec)4257 std::string genShaderSourceTextureGatherOffsets (NegativeTestContext& ctx, glu::ShaderType shaderType, const TextureGatherOffsetsTestSpec& spec)
4258 {
4259 std::ostringstream source;
4260
4261 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"
4262 << getShaderInitialization(ctx, shaderType)
4263 << declareShaderUniform(spec.samplerDataType, "sampler")
4264 << "void main(void)\n"
4265 << "{\n"
4266 << " mediump " << declareAndInitializeShaderVariable(spec.pDataType, "P")
4267 << " mediump " << (spec.offsetIsConst ? "const " : "") << declareShaderArrayVariable(spec.offsetsDataType, "offsets", spec.offsetArraySize) << "\n";
4268
4269 switch (spec.mode)
4270 {
4271 case FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP:
4272 {
4273 if (spec.fourthArgument != glu::TYPE_LAST)
4274 source << " mediump " << declareAndInitializeShaderVariable(spec.fourthArgument, "comp")
4275 << " textureGatherOffsets(sampler, P, offsets, comp);\n";
4276 else
4277 source << " textureGatherOffsets(sampler, P, offsets);\n";
4278 break;
4279 }
4280
4281 case FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z:
4282 {
4283 source << " mediump " << declareAndInitializeShaderVariable(spec.fourthArgument, "refZ")
4284 << " textureGatherOffsets(sampler, P, refZ, offsets);\n";
4285 break;
4286 }
4287
4288 default:
4289 DE_FATAL("Unsupported shader function overload.");
4290 break;
4291 }
4292
4293 source << "}\n";
4294 return source.str();
4295 }
4296
texture_gather_offsets(NegativeTestContext & ctx)4297 void texture_gather_offsets (NegativeTestContext& ctx)
4298 {
4299 TCU_CHECK_AND_THROW(NotSupportedError,
4300 checkSupport(ctx) || ctx.isExtensionSupported("GL_EXT_gpu_shader5"),
4301 "This test requires a context version 3.2 or higher.");
4302
4303 const struct TextureGatherOffsetsTestSpec testSpecs[] =
4304 {
4305 //mode samplerDataType pDataType offsetsDataType fourthArgument offsetIsConst offsetArraySize
4306 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_LAST, false, 4, },
4307 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_LAST, true, 3, },
4308 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_LAST, true, 4, },
4309 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_LAST, true, 4, },
4310 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_INT, false, 4, },
4311 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT, true, 4, },
4312 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT_VEC2, glu::TYPE_INT, true, 3, },
4313 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_INT, true, 4, },
4314 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_INT, true, 4, },
4315
4316 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT_VEC2, glu::TYPE_LAST, false, 4, },
4317 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT_VEC2, glu::TYPE_LAST, true, 3, },
4318 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_LAST, true, 4, },
4319 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_LAST, true, 4, },
4320 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT_VEC2, glu::TYPE_INT, false, 4, },
4321 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT, true, 4, },
4322 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT_VEC2, glu::TYPE_INT, true, 3, },
4323 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_INT, true, 4, },
4324 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_COMP, glu::TYPE_SAMPLER_2D_ARRAY, glu::TYPE_FLOAT_VEC3, glu::TYPE_INT, glu::TYPE_INT, true, 4, },
4325
4326 { 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, },
4327 { 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, },
4328 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT, glu::TYPE_INT_VEC2, glu::TYPE_FLOAT, true, 4, },
4329 { FUNCTION_TEXTURE_GATHER_OFFSET_MODE_REF_Z, glu::TYPE_SAMPLER_2D_SHADOW, glu::TYPE_FLOAT_VEC2, glu::TYPE_INT, glu::TYPE_FLOAT, true, 4, },
4330 { 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, },
4331
4332 { 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, },
4333 { 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, },
4334 { 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, },
4335 { 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, },
4336 { 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, },
4337 };
4338
4339 ctx.beginSection("textureGatherOffsets");
4340 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
4341 {
4342 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
4343 {
4344 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
4345 for (int specNdx = 0; specNdx < DE_LENGTH_OF_ARRAY(testSpecs); ++specNdx)
4346 {
4347 const std::string shaderSource(genShaderSourceTextureGatherOffsets(ctx, s_shaders[shaderNdx], testSpecs[specNdx]));
4348 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4349 }
4350 ctx.endSection();
4351 }
4352 }
4353 ctx.endSection();
4354 }
4355
4356 // fma
genShaderSourceFma(NegativeTestContext & ctx,glu::ShaderType shaderType,glu::DataType aDataType,glu::DataType bDataType,glu::DataType cDataType)4357 std::string genShaderSourceFma (NegativeTestContext& ctx, glu::ShaderType shaderType, glu::DataType aDataType, glu::DataType bDataType, glu::DataType cDataType)
4358 {
4359 std::ostringstream source;
4360
4361 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"
4362 << getShaderInitialization(ctx, shaderType)
4363 << "void main(void)\n"
4364 << "{\n"
4365 << " mediump " << declareAndInitializeShaderVariable(aDataType, "a")
4366 << " mediump " << declareAndInitializeShaderVariable(bDataType, "b")
4367 << " mediump " << declareAndInitializeShaderVariable(cDataType, "c")
4368 << " fma(a, b, c);"
4369 << "}\n";
4370 return source.str();
4371 }
4372
fma(NegativeTestContext & ctx)4373 void fma (NegativeTestContext& ctx)
4374 {
4375 TCU_CHECK_AND_THROW(NotSupportedError,
4376 checkSupport(ctx) || ctx.isExtensionSupported("GL_EXT_gpu_shader5"),
4377 "This test requires a context version 3.2 or higher.");
4378
4379 ctx.beginSection("fma");
4380 for (int shaderNdx = 0; shaderNdx < DE_LENGTH_OF_ARRAY(s_shaders); ++shaderNdx)
4381 {
4382 if (ctx.isShaderSupported(s_shaders[shaderNdx]))
4383 {
4384 ctx.beginSection("Verify shader: " + std::string(getShaderTypeName(s_shaders[shaderNdx])));
4385 {
4386 const std::string shaderSource(genShaderSourceFma(ctx, s_shaders[shaderNdx], glu::TYPE_FLOAT, glu::TYPE_FLOAT, glu::TYPE_INT));
4387 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4388 }
4389 {
4390 const std::string shaderSource(genShaderSourceFma(ctx, s_shaders[shaderNdx], glu::TYPE_FLOAT, glu::TYPE_INT, glu::TYPE_FLOAT));
4391 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4392 }
4393 {
4394 const std::string shaderSource(genShaderSourceFma(ctx, s_shaders[shaderNdx], glu::TYPE_INT, glu::TYPE_FLOAT, glu::TYPE_FLOAT));
4395 verifyShader(ctx, s_shaders[shaderNdx], shaderSource);
4396 }
4397 ctx.endSection();
4398 }
4399 }
4400 ctx.endSection();
4401 }
4402
4403 } // anonymous
4404
getNegativeShaderFunctionTestFunctions()4405 std::vector<FunctionContainer> getNegativeShaderFunctionTestFunctions ()
4406 {
4407 const FunctionContainer funcs[] =
4408 {
4409 {bitfield_extract_invalid_value_type, "bitfield_extract_invalid_value_type", "Invalid usage of bitfieldExtract." },
4410 {bitfield_extract_invalid_offset_type, "bitfield_extract_invalid_offset_type", "Invalid usage of bitfieldExtract." },
4411 {bitfield_extract_invalid_bits_type, "bitfield_extract_invalid_bits_type", "Invalid usage of bitfieldExtract." },
4412 {bitfield_insert_invalid_base_type, "bitfield_insert_invalid_base_type", "Invalid usage of bitfieldInsert." },
4413 {bitfield_insert_invalid_insert_type, "bitfield_insert_invalid_insert_type", "Invalid usage of bitfieldInsert." },
4414 {bitfield_insert_invalid_offset_type, "bitfield_insert_invalid_offset_type", "Invalid usage of bitfieldInsert." },
4415 {bitfield_insert_invalid_bits_type, "bitfield_insert_invalid_bits_type", "Invalid usage of bitfieldInsert." },
4416 {bitfield_reverse, "bitfield_reverse", "Invalid usage of bitfieldReverse." },
4417 {bit_count, "bit_count", "Invalid usage of bitCount." },
4418 {find_msb, "find_msb", "Invalid usage of findMSB." },
4419 {find_lsb, "find_lsb", "Invalid usage of findLSB." },
4420 {uadd_carry_invalid_x, "uadd_carry_invalid_x", "Invalid usage of uaddCarry." },
4421 {uadd_carry_invalid_y, "uadd_carry_invalid_y", "Invalid usage of uaddCarry." },
4422 {uadd_carry_invalid_carry, "uadd_carry_invalid_carry", "Invalid usage of uaddCarry." },
4423 {usub_borrow_invalid_x, "usub_borrow_invalid_x", "Invalid usage of usubBorrow." },
4424 {usub_borrow_invalid_y, "usub_borrow_invalid_y", "Invalid usage of usubBorrow." },
4425 {usub_borrow_invalid_borrow, "usub_borrow_invalid_borrow", "Invalid usage of usubBorrow." },
4426 {umul_extended_invalid_x, "umul_extended_invalid_x", "Invalid usage of umulExtended." },
4427 {umul_extended_invalid_y, "umul_extended_invalid_y", "Invalid usage of umulExtended." },
4428 {umul_extended_invalid_msb, "umul_extended_invalid_msb", "Invalid usage of umulExtended." },
4429 {umul_extended_invalid_lsb, "umul_extended_invalid_lsb", "Invalid usage of umulExtended." },
4430 {imul_extended_invalid_x, "imul_extended_invalid_x", "Invalid usage of imulExtended." },
4431 {imul_extended_invalid_y, "imul_extended_invalid_y", "Invalid usage of imulExtended." },
4432 {imul_extended_invalid_msb, "imul_extended_invalid_msb", "Invalid usage of imulExtended." },
4433 {imul_extended_invalid_lsb, "imul_extended_invalid_lsb", "Invalid usage of imulExtended." },
4434 {frexp_invalid_x, "frexp_invalid_x", "Invalid usage of frexp." },
4435 {frexp_invalid_exp, "frexp_invalid_exp", "Invalid usage of frexp." },
4436 {ldexp_invalid_x, "ldexp_invalid_x", "Invalid usage of ldexp." },
4437 {ldexp_invalid_exp, "ldexp_invalid_exp", "Invalid usage of ldexp." },
4438 {pack_unorm_4x8, "pack_unorm_4x8", "Invalid usage of packUnorm4x8." },
4439 {pack_snorm_4x8, "pack_snorm_4x8", "Invalid usage of packSnorm4x8." },
4440 {unpack_snorm_4x8, "unpack_snorm_4x8", "Invalid usage of unpackSnorm4x8." },
4441 {unpack_unorm_4x8, "unpack_unorm_4x8", "Invalid usage of unpackUnorm4x8." },
4442 {texture_size_invalid_sampler, "texture_size_invalid_sampler", "Invalid usage of textureSize." },
4443 {texture_size_invalid_lod, "texture_size_invalid_lod", "Invalid usage of textureSize." },
4444 {texture_invalid_p, "texture_invalid_p", "Invalid usage of texture." },
4445 {texture_invalid_bias_or_compare, "texture_invalid_bias_or_compare", "Invalid usage of texture." },
4446 {texture_lod_invalid_p, "texture_lod_invalid_p", "Invalid usage of textureLod." },
4447 {texture_lod_invalid_lod, "texture_lod_invalid_lod", "Invalid usage of textureLod." },
4448 {texel_fetch_invalid_p, "texel_fetch_invalid_p", "Invalid usage of texelFetch." },
4449 {texel_fetch_invalid_sample, "texel_fetch_invalid_sample", "Invalid usage of texelFetch." },
4450 {emit_vertex, "emit_vertex", "Invalid usage of EmitVertex." },
4451 {end_primitive, "end_primitive", "Invalid usage of EndPrimitive." },
4452 {texture_grad, "texture_grad", "Invalid usage of textureGrad." },
4453 {texture_gather_sampler_2d, "texture_gather_sampler_2d", "Invalid usage of textureGather." },
4454 {texture_gather_sampler_2d_array, "texture_gather_sampler_2d_array", "Invalid usage of textureGather." },
4455 {texture_gather_sampler_cube, "texture_gather_sampler_cube", "Invalid usage of textureGather." },
4456 {texture_gather_sampler_2d_shadow, "texture_gather_sampler_2d_shadow", "Invalid usage of textureGather." },
4457 {texture_gather_sampler_2d_array_shadow, "texture_gather_sampler_2d_array_shadow", "Invalid usage of textureGather." },
4458 {texture_gather_sampler_cube_shadow, "texture_gather_sampler_cube_shadow", "Invalid usage of textureGather." },
4459 {texture_gather_sampler_cube_array, "texture_gather_sampler_cube_array", "Invalid usage of textureGather." },
4460 {texture_gather_sampler_cube_array_shadow, "texture_gather_sampler_cube_array_shadow", "Invalid usage of textureGather." },
4461 {texture_gather_offset_sampler_2d, "texture_gather_offset_sampler_2d", "Invalid usage of textureGatherOffset." },
4462 {texture_gather_offset_sampler_2d_array, "texture_gather_offset_sampler_2d_array", "Invalid usage of textureGatherOffset." },
4463 {texture_gather_offset_sampler_2d_shadow, "texture_gather_offset_sampler_2d_shadow", "Invalid usage of textureGatherOffset." },
4464 {texture_gather_offset_sampler_2d_array_shadow, "texture_gather_offset_sampler_2d_array_shadow", "Invalid usage of textureGatherOffset." },
4465 {texture_gather_offsets, "texture_gather_offsets", "Invalid usage of textureGatherOffsets." },
4466 {atomic_add, "atomic_add", "Invalid usage of atomicAdd." },
4467 {atomic_min, "atomic_min", "Invalid usage of atomicMin." },
4468 {atomic_max, "atomic_max", "Invalid usage of atomicMax." },
4469 {atomic_and, "atomic_and", "Invalid usage of atomicAnd." },
4470 {atomic_or, "atomic_or", "Invalid usage of atomicOr." },
4471 {atomic_xor, "atomic_xor", "Invalid usage of atomicXor." },
4472 {atomic_exchange, "atomic_exchange", "Invalid usage of atomicExchange." },
4473 {atomic_comp_swap, "atomic_comp_swap", "Invalid usage of atomicCompSwap." },
4474 {interpolate_at_centroid, "interpolate_at_centroid", "Invalid usage of interpolateAtCentroid." },
4475 {interpolate_at_sample, "interpolate_at_sample", "Invalid usage of interpolateAtSample." },
4476 {interpolate_at_offset, "interpolate_at_offset", "Invalid usage of interpolateAtOffset." },
4477 {fma, "fma", "Invalid usage of fma." },
4478 };
4479
4480 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
4481 }
4482
4483 } // NegativeTestShared
4484 } // Functional
4485 } // gles31
4486 } // deqp
4487