• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Negative Shader API tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es3fNegativeShaderApiTests.hpp"
25 #include "es3fApiCase.hpp"
26 #include "gluShaderProgram.hpp"
27 #include "gluContextInfo.hpp"
28 #include "deUniquePtr.hpp"
29 
30 #include "glwDefs.hpp"
31 #include "glwEnums.hpp"
32 
33 using namespace glw; // GL types
34 
35 namespace deqp
36 {
37 namespace gles3
38 {
39 namespace Functional
40 {
41 
42 using tcu::TestLog;
43 
44 static const char* vertexShaderSource		=	"#version 300 es\n"
45 												"void main (void)\n"
46 												"{\n"
47 												"	gl_Position = vec4(0.0);\n"
48 												"}\n\0";
49 
50 static const char* fragmentShaderSource		=	"#version 300 es\n"
51 												"layout(location = 0) out mediump vec4 fragColor;"
52 												"void main (void)\n"
53 												"{\n"
54 												"	fragColor = vec4(0.0);\n"
55 												"}\n\0";
56 
57 static const char* uniformTestVertSource	=	"#version 300 es\n"
58 												"uniform mediump vec4 vec4_v;\n"
59 												"uniform mediump mat4 mat4_v;\n"
60 												"void main (void)\n"
61 												"{\n"
62 												"	gl_Position = mat4_v * vec4_v;\n"
63 												"}\n\0";
64 
65 static const char* uniformTestFragSource	=	"#version 300 es\n"
66 												"uniform mediump ivec4 ivec4_f;\n"
67 												"uniform mediump uvec4 uvec4_f;\n"
68 												"uniform sampler2D sampler_f;\n"
69 												"layout(location = 0) out mediump vec4 fragColor;"
70 												"void main (void)\n"
71 												"{\n"
72 												"	fragColor.xy = (vec4(uvec4_f) + vec4(ivec4_f)).xy;\n"
73 												"	fragColor.zw = texture(sampler_f, vec2(0.0, 0.0)).zw;\n"
74 												"}\n\0";
75 
76 static const char* uniformBlockVertSource	=	"#version 300 es\n"
77 												"layout(shared) uniform Block { lowp float var; };\n"
78 												"void main (void)\n"
79 												"{\n"
80 												"	gl_Position = vec4(var);\n"
81 												"}\n\0";
82 
NegativeShaderApiTests(Context & context)83 NegativeShaderApiTests::NegativeShaderApiTests (Context& context)
84 	: TestCaseGroup(context, "shader", "Negative Shader API Cases")
85 {
86 }
87 
~NegativeShaderApiTests(void)88 NegativeShaderApiTests::~NegativeShaderApiTests (void)
89 {
90 }
91 
init(void)92 void NegativeShaderApiTests::init (void)
93 {
94 	// Shader control commands
95 
96 	ES3F_ADD_API_CASE(create_shader, "Invalid glCreateShader() usage",
97 		{
98 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if shaderType is not an accepted value.");
99 			glCreateShader(-1);
100 			expectError(GL_INVALID_ENUM);
101 			m_log << TestLog::EndSection;
102 		});
103 	ES3F_ADD_API_CASE(shader_source, "Invalid glShaderSource() usage",
104 		{
105 			// \note Shader compilation must be supported.
106 
107 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
108 			glShaderSource(1, 0, 0, 0);
109 			expectError(GL_INVALID_VALUE);
110 			m_log << TestLog::EndSection;
111 
112 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if count is less than 0.");
113 			GLuint shader = glCreateShader(GL_VERTEX_SHADER);
114 			glShaderSource(shader, -1, 0, 0);
115 			expectError(GL_INVALID_VALUE);
116 			m_log << TestLog::EndSection;
117 
118 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
119 			GLuint program = glCreateProgram();
120 			glShaderSource(program, 0, 0, 0);
121 			expectError(GL_INVALID_OPERATION);
122 			m_log << TestLog::EndSection;
123 
124 			glDeleteProgram(program);
125 			glDeleteShader(shader);
126 		});
127 	ES3F_ADD_API_CASE(compile_shader, "Invalid glCompileShader() usage",
128 		{
129 			// \note Shader compilation must be supported.
130 
131 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
132 			glCompileShader(9);
133 			expectError(GL_INVALID_VALUE);
134 			m_log << TestLog::EndSection;
135 
136 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
137 			GLuint program = glCreateProgram();
138 			glCompileShader(program);
139 			expectError(GL_INVALID_OPERATION);
140 			m_log << TestLog::EndSection;
141 
142 			glDeleteProgram(program);
143 		});
144 	ES3F_ADD_API_CASE(delete_shader, "Invalid glDeleteShader() usage",
145 		{
146 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
147 			glDeleteShader(9);
148 			expectError(GL_INVALID_VALUE);
149 			m_log << TestLog::EndSection;
150 		});
151 	ES3F_ADD_API_CASE(shader_binary, "Invalid glShaderBinary() usage",
152 		{
153 			std::vector<deInt32> binaryFormats;
154 			getSupportedExtensions(GL_NUM_SHADER_BINARY_FORMATS, GL_SHADER_BINARY_FORMATS, binaryFormats);
155 			deBool shaderBinarySupported = !binaryFormats.empty();
156 			if (!shaderBinarySupported)
157 				m_log << TestLog::Message << "// Shader binaries not supported." << TestLog::EndMessage;
158 			else
159 				m_log << TestLog::Message << "// Shader binaries supported" << TestLog::EndMessage;
160 
161 			GLuint shaders[2];
162 			shaders[0]		= glCreateShader(GL_VERTEX_SHADER);
163 			shaders[1]		= glCreateShader(GL_VERTEX_SHADER);
164 
165 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if binaryFormat is not an accepted value.");
166 			glShaderBinary(1, &shaders[0], -1, 0, 0);
167 			expectError(GL_INVALID_ENUM);
168 			m_log << TestLog::EndSection;
169 
170 			if (shaderBinarySupported)
171 			{
172 				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if the data pointed to by binary does not match the format specified by binaryFormat.");
173 				const GLbyte data = 0x005F;
174 				glShaderBinary(1, &shaders[0], binaryFormats[0], &data, 1);
175 				expectError(GL_INVALID_VALUE);
176 				m_log << TestLog::EndSection;
177 
178 				m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if more than one of the handles in shaders refers to the same type of shader, or GL_INVALID_VALUE due to invalid data pointer.");
179 				glShaderBinary(2, &shaders[0], binaryFormats[0], 0, 0);
180 				expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE);
181 				m_log << TestLog::EndSection;
182 			}
183 
184 			glDeleteShader(shaders[0]);
185 			glDeleteShader(shaders[1]);
186 		});
187 	ES3F_ADD_API_CASE(attach_shader, "Invalid glAttachShader() usage",
188 		{
189 			GLuint shader1 = glCreateShader(GL_VERTEX_SHADER);
190 			GLuint shader2 = glCreateShader(GL_VERTEX_SHADER);
191 			GLuint program = glCreateProgram();
192 
193 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
194 			glAttachShader(shader1, shader1);
195 			expectError(GL_INVALID_OPERATION);
196 			m_log << TestLog::EndSection;
197 
198 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
199 			glAttachShader(program, program);
200 			expectError(GL_INVALID_OPERATION);
201 			glAttachShader(shader1, program);
202 			expectError(GL_INVALID_OPERATION);
203 			m_log << TestLog::EndSection;
204 
205 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
206 			glAttachShader(program, -1);
207 			expectError(GL_INVALID_VALUE);
208 			glAttachShader(-1, shader1);
209 			expectError(GL_INVALID_VALUE);
210 			glAttachShader(-1, -1);
211 			expectError(GL_INVALID_VALUE);
212 			m_log << TestLog::EndSection;
213 
214 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is already attached to program.");
215 			glAttachShader(program, shader1);
216 			expectError(GL_NO_ERROR);
217 			glAttachShader(program, shader1);
218 			expectError(GL_INVALID_OPERATION);
219 			m_log << TestLog::EndSection;
220 
221 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a shader of the same type as shader is already attached to program.");
222 			glAttachShader(program, shader2);
223 			expectError(GL_INVALID_OPERATION);
224 			m_log << TestLog::EndSection;
225 
226 			glDeleteProgram(program);
227 			glDeleteShader(shader1);
228 			glDeleteShader(shader2);
229 		});
230 	ES3F_ADD_API_CASE(detach_shader, "Invalid glDetachShader() usage",
231 		{
232 			GLuint shader = glCreateShader(GL_VERTEX_SHADER);
233 			GLuint program = glCreateProgram();
234 
235 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
236 			glDetachShader(-1, shader);
237 			expectError(GL_INVALID_VALUE);
238 			glDetachShader(program, -1);
239 			expectError(GL_INVALID_VALUE);
240 			glDetachShader(-1, -1);
241 			expectError(GL_INVALID_VALUE);
242 			m_log << TestLog::EndSection;
243 
244 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
245 			glDetachShader(shader, shader);
246 			expectError(GL_INVALID_OPERATION);
247 			m_log << TestLog::EndSection;
248 
249 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
250 			glDetachShader(program, program);
251 			expectError(GL_INVALID_OPERATION);
252 			glDetachShader(shader, program);
253 			expectError(GL_INVALID_OPERATION);
254 			m_log << TestLog::EndSection;
255 
256 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not attached to program.");
257 			glDetachShader(program, shader);
258 			expectError(GL_INVALID_OPERATION);
259 			m_log << TestLog::EndSection;
260 
261 			glDeleteProgram(program);
262 			glDeleteShader(shader);
263 		});
264 	ES3F_ADD_API_CASE(link_program, "Invalid glLinkProgram() usage",
265 		{
266 			GLuint shader = glCreateShader(GL_VERTEX_SHADER);
267 
268 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
269 			glLinkProgram(-1);
270 			expectError(GL_INVALID_VALUE);
271 			m_log << TestLog::EndSection;
272 
273 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
274 			glLinkProgram(shader);
275 			expectError(GL_INVALID_OPERATION);
276 			m_log << TestLog::EndSection;
277 
278 			glDeleteShader(shader);
279 
280 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active.");
281 			glu::ShaderProgram			program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
282 			deUint32					buf;
283 			deUint32					tfID;
284 			const char* tfVarying		= "gl_Position";
285 
286 			glGenTransformFeedbacks		(1, &tfID);
287 			glGenBuffers				(1, &buf);
288 
289 			glUseProgram				(program.getProgram());
290 			glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
291 			glLinkProgram				(program.getProgram());
292 			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
293 			glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
294 			glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
295 			glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
296 			glBeginTransformFeedback	(GL_TRIANGLES);
297 			expectError					(GL_NO_ERROR);
298 
299 			glLinkProgram				(program.getProgram());
300 			expectError					(GL_INVALID_OPERATION);
301 
302 			glEndTransformFeedback		();
303 			glDeleteTransformFeedbacks	(1, &tfID);
304 			glDeleteBuffers				(1, &buf);
305 			expectError					(GL_NO_ERROR);
306 			m_log << TestLog::EndSection;
307 		});
308 	ES3F_ADD_API_CASE(use_program, "Invalid glUseProgram() usage",
309 		{
310 			GLuint shader = glCreateShader(GL_VERTEX_SHADER);
311 
312 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is neither 0 nor a value generated by OpenGL.");
313 			glUseProgram(-1);
314 			expectError(GL_INVALID_VALUE);
315 			m_log << TestLog::EndSection;
316 
317 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
318 			glUseProgram(shader);
319 			expectError(GL_INVALID_OPERATION);
320 			m_log << TestLog::EndSection;
321 
322 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if transform feedback mode is active and not paused.");
323 			glu::ShaderProgram			program1(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
324 			glu::ShaderProgram			program2(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
325 			deUint32					buf;
326 			deUint32					tfID;
327 			const char* tfVarying		= "gl_Position";
328 
329 			glGenTransformFeedbacks		(1, &tfID);
330 			glGenBuffers				(1, &buf);
331 
332 			glUseProgram				(program1.getProgram());
333 			glTransformFeedbackVaryings	(program1.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
334 			glLinkProgram				(program1.getProgram());
335 			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
336 			glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
337 			glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
338 			glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
339 			glBeginTransformFeedback	(GL_TRIANGLES);
340 			expectError					(GL_NO_ERROR);
341 
342 			glUseProgram				(program2.getProgram());
343 			expectError					(GL_INVALID_OPERATION);
344 
345 			glPauseTransformFeedback	();
346 			glUseProgram				(program2.getProgram());
347 			expectError					(GL_NO_ERROR);
348 
349 			glEndTransformFeedback		();
350 			glDeleteTransformFeedbacks	(1, &tfID);
351 			glDeleteBuffers				(1, &buf);
352 			expectError					(GL_NO_ERROR);
353 			m_log << TestLog::EndSection;
354 
355 			glUseProgram(0);
356 			glDeleteShader(shader);
357 		});
358 	ES3F_ADD_API_CASE(delete_program, "Invalid glDeleteProgram() usage",
359 		{
360 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
361 			glDeleteProgram(-1);
362 			expectError(GL_INVALID_VALUE);
363 			m_log << TestLog::EndSection;
364 		});
365 	ES3F_ADD_API_CASE(validate_program, "Invalid glValidateProgram() usage",
366 		{
367 			GLuint shader = glCreateShader(GL_VERTEX_SHADER);
368 
369 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
370 			glValidateProgram(-1);
371 			expectError(GL_INVALID_VALUE);
372 			m_log << TestLog::EndSection;
373 
374 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
375 			glValidateProgram(shader);
376 			expectError(GL_INVALID_OPERATION);
377 			m_log << TestLog::EndSection;
378 
379 			glDeleteShader(shader);
380 		});
381 	ES3F_ADD_API_CASE(get_program_binary, "Invalid glGetProgramBinary() usage",
382 		{
383 			glu::ShaderProgram				program			(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
384 			glu::ShaderProgram				programInvalid	(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
385 			GLenum							binaryFormat	= -1;
386 			GLsizei							binaryLength	= -1;
387 			GLint							binaryPtr		= -1;
388 			GLint							bufSize			= -1;
389 			GLint							linkStatus		= -1;
390 
391 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if bufSize is less than the size of GL_PROGRAM_BINARY_LENGTH for program.");
392 			glGetProgramiv		(program.getProgram(), GL_PROGRAM_BINARY_LENGTH,	&bufSize);
393 			expectError			(GL_NO_ERROR);
394 			glGetProgramiv		(program.getProgram(), GL_LINK_STATUS,				&linkStatus);
395 			m_log << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
396 			m_log << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
397 			expectError			(GL_NO_ERROR);
398 
399 			glGetProgramBinary	(program.getProgram(), 0, &binaryLength, &binaryFormat, &binaryPtr);
400 			expectError			(GL_INVALID_OPERATION);
401 			if (bufSize > 0)
402 			{
403 				glGetProgramBinary	(program.getProgram(), bufSize-1, &binaryLength, &binaryFormat, &binaryPtr);
404 				expectError			(GL_INVALID_OPERATION);
405 			}
406 			m_log << TestLog::EndSection;
407 
408 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if GL_LINK_STATUS for the program object is false.");
409 			glGetProgramiv		(programInvalid.getProgram(), GL_PROGRAM_BINARY_LENGTH,	&bufSize);
410 			expectError			(GL_NO_ERROR);
411 			glGetProgramiv		(programInvalid.getProgram(), GL_LINK_STATUS,			&linkStatus);
412 			m_log << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
413 			m_log << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
414 			expectError			(GL_NO_ERROR);
415 
416 			glGetProgramBinary	(programInvalid.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryPtr);
417 			expectError			(GL_INVALID_OPERATION);
418 			m_log << TestLog::EndSection;
419 		});
420 	ES3F_ADD_API_CASE(program_binary, "Invalid glProgramBinary() usage",
421 		{
422 			glu::ShaderProgram		srcProgram		(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
423 			GLuint					dstProgram		= glCreateProgram();
424 			GLuint					dummyShader		= glCreateShader(GL_VERTEX_SHADER);
425 			GLenum					binaryFormat	= -1;
426 			GLsizei					binaryLength	= -1;
427 			std::vector<deUint8>	binaryBuf;
428 			GLint					bufSize			= -1;
429 			GLint					linkStatus		= -1;
430 
431 			glGetProgramiv		(srcProgram.getProgram(), GL_PROGRAM_BINARY_LENGTH,	&bufSize);
432 			glGetProgramiv		(srcProgram.getProgram(), GL_LINK_STATUS,			&linkStatus);
433 			m_log << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
434 			m_log << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
435 
436 			TCU_CHECK(bufSize >= 0);
437 
438 			if (bufSize > 0)
439 			{
440 				binaryBuf.resize(bufSize);
441 				glGetProgramBinary	(srcProgram.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryBuf[0]);
442 				expectError			(GL_NO_ERROR);
443 
444 				m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not the name of an existing program object.");
445 				glProgramBinary		(dummyShader, binaryFormat, &binaryBuf[0], binaryLength);
446 				expectError			(GL_INVALID_OPERATION);
447 				m_log << TestLog::EndSection;
448 
449 				m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if binaryFormat is not a value recognized by the implementation.");
450 				glProgramBinary		(dstProgram, -1, &binaryBuf[0], binaryLength);
451 				expectError			(GL_INVALID_ENUM);
452 				m_log << TestLog::EndSection;
453 			}
454 
455 			glDeleteShader(dummyShader);
456 			glDeleteProgram(dstProgram);
457 		});
458 	ES3F_ADD_API_CASE(program_parameteri, "Invalid glProgramParameteri() usage",
459 		{
460 			GLuint	program	= glCreateProgram();
461 
462 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not the name of an existing program object.");
463 			glProgramParameteri		(0, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
464 			expectError				(GL_INVALID_VALUE);
465 			m_log << TestLog::EndSection;
466 
467 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not GL_PROGRAM_BINARY_RETRIEVABLE_HINT.");
468 			glProgramParameteri		(program, -1, GL_TRUE);
469 			expectError				(GL_INVALID_ENUM);
470 			m_log << TestLog::EndSection;
471 
472 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if value is not GL_FALSE or GL_TRUE.");
473 			glProgramParameteri		(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, 2);
474 			expectError				(GL_INVALID_VALUE);
475 			m_log << TestLog::EndSection;
476 
477 			glDeleteProgram(program);
478 		});
479 	ES3F_ADD_API_CASE(gen_samplers, "Invalid glGenSamplers() usage",
480 		{
481 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
482 			GLuint sampler;
483 			glGenSamplers	(-1, &sampler);
484 			expectError		(GL_INVALID_VALUE);
485 			m_log << TestLog::EndSection;
486 		});
487 	ES3F_ADD_API_CASE(bind_sampler, "Invalid glBindSampler() usage",
488 		{
489 			int				maxTexImageUnits;
490 			GLuint			sampler;
491 			glGetIntegerv	(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTexImageUnits);
492 			glGenSamplers	(1, &sampler);
493 
494 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if unit is greater than or equal to the value of GL_MAX_COMBIED_TEXTURE_IMAGE_UNITS.");
495 			glBindSampler	(maxTexImageUnits, sampler);
496 			expectError		(GL_INVALID_VALUE);
497 			m_log << TestLog::EndSection;
498 
499 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if sampler is not zero or a name previously returned from a call to glGenSamplers.");
500 			glBindSampler	(1, -1);
501 			expectError		(GL_INVALID_OPERATION);
502 			m_log << TestLog::EndSection;
503 
504 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if sampler has been deleted by a call to glDeleteSamplers.");
505 			glDeleteSamplers(1, &sampler);
506 			glBindSampler	(1, sampler);
507 			expectError		(GL_INVALID_OPERATION);
508 			m_log << TestLog::EndSection;
509 		});
510 	ES3F_ADD_API_CASE(delete_samplers, "Invalid glDeleteSamplers() usage",
511 		{
512 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
513 			glDeleteSamplers(-1, 0);
514 			expectError		(GL_INVALID_VALUE);
515 			m_log << TestLog::EndSection;
516 		});
517 	ES3F_ADD_API_CASE(get_sampler_parameteriv, "Invalid glGetSamplerParameteriv() usage",
518 		{
519 			int				params	= -1;
520 			GLuint			sampler;
521 			glGenSamplers	(1, &sampler);
522 
523 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to glGenSamplers.");
524 			glGetSamplerParameteriv	(-1, GL_TEXTURE_MAG_FILTER, &params);
525 			expectError				(GL_INVALID_OPERATION);
526 			m_log << TestLog::EndSection;
527 
528 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
529 			glGetSamplerParameteriv	(sampler, -1, &params);
530 			expectError				(GL_INVALID_ENUM);
531 			m_log << TestLog::EndSection;
532 
533 			glDeleteSamplers(1, &sampler);
534 		});
535 	ES3F_ADD_API_CASE(get_sampler_parameterfv, "Invalid glGetSamplerParameterfv() usage",
536 		{
537 			float			params	= 0.0f;
538 			GLuint			sampler;
539 			glGenSamplers	(1, &sampler);
540 
541 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to glGenSamplers.");
542 			glGetSamplerParameterfv	(-1, GL_TEXTURE_MAG_FILTER, &params);
543 			expectError				(GL_INVALID_OPERATION);
544 			m_log << TestLog::EndSection;
545 
546 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
547 			glGetSamplerParameterfv	(sampler, -1, &params);
548 			expectError				(GL_INVALID_ENUM);
549 			m_log << TestLog::EndSection;
550 
551 			glDeleteSamplers(1, &sampler);
552 		});
553 	ES3F_ADD_API_CASE(sampler_parameteri, "Invalid glSamplerParameteri() usage",
554 		{
555 			GLuint			sampler;
556 			glGenSamplers	(1, &sampler);
557 
558 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to glGenSamplers.");
559 			glSamplerParameteri		(-1, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
560 			expectError				(GL_INVALID_OPERATION);
561 			m_log << TestLog::EndSection;
562 
563 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
564 			glSamplerParameteri		(sampler, GL_TEXTURE_WRAP_S, -1);
565 			expectError				(GL_INVALID_ENUM);
566 			m_log << TestLog::EndSection;
567 
568 			glDeleteSamplers(1, &sampler);
569 		});
570 	ES3F_ADD_API_CASE(sampler_parameteriv, "Invalid glSamplerParameteriv() usage",
571 		{
572 			int				params	= -1;
573 			GLuint			sampler;
574 			glGenSamplers	(1, &sampler);
575 
576 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to glGenSamplers.");
577 			params = GL_CLAMP_TO_EDGE;
578 			glSamplerParameteriv	(-1, GL_TEXTURE_WRAP_S, &params);
579 			expectError				(GL_INVALID_OPERATION);
580 			m_log << TestLog::EndSection;
581 
582 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
583 			params = -1;
584 			glSamplerParameteriv	(sampler, GL_TEXTURE_WRAP_S, &params);
585 			expectError				(GL_INVALID_ENUM);
586 			m_log << TestLog::EndSection;
587 
588 			glDeleteSamplers(1, &sampler);
589 		});
590 	ES3F_ADD_API_CASE(sampler_parameterf, "Invalid glSamplerParameterf() usage",
591 		{
592 			GLuint			sampler;
593 			glGenSamplers	(1, &sampler);
594 
595 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to glGenSamplers.");
596 			glSamplerParameterf		(-1, GL_TEXTURE_MIN_LOD, -1000.0f);
597 			expectError				(GL_INVALID_OPERATION);
598 			m_log << TestLog::EndSection;
599 
600 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
601 			glSamplerParameterf		(sampler, GL_TEXTURE_WRAP_S, -1.0f);
602 			expectError				(GL_INVALID_ENUM);
603 			m_log << TestLog::EndSection;
604 
605 			glDeleteSamplers(1, &sampler);
606 		});
607 	ES3F_ADD_API_CASE(sampler_parameterfv, "Invalid glSamplerParameterfv() usage",
608 		{
609 			float			params	= 0.0f;
610 			GLuint			sampler;
611 			glGenSamplers	(1, &sampler);
612 
613 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to glGenSamplers.");
614 			params = -1000.0f;
615 			glSamplerParameterfv	(-1, GL_TEXTURE_WRAP_S, &params);
616 			expectError				(GL_INVALID_OPERATION);
617 			m_log << TestLog::EndSection;
618 
619 			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
620 			params = -1.0f;
621 			glSamplerParameterfv	(sampler, GL_TEXTURE_WRAP_S, &params);
622 			expectError				(GL_INVALID_ENUM);
623 			m_log << TestLog::EndSection;
624 
625 			glDeleteSamplers(1, &sampler);
626 		});
627 
628 	// Shader data commands
629 
630 	ES3F_ADD_API_CASE(get_attrib_location, "Invalid glGetAttribLocation() usage",
631 		{
632 			GLuint programEmpty		= glCreateProgram();
633 			GLuint shader			= glCreateShader(GL_VERTEX_SHADER);
634 
635 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
636 
637 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
638 			glBindAttribLocation	(programEmpty, 0, "test");
639 			glGetAttribLocation		(programEmpty, "test");
640 			expectError				(GL_INVALID_OPERATION);
641 			m_log << TestLog::EndSection;
642 
643 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a program or shader object.");
644 			glUseProgram			(program.getProgram());
645 			glBindAttribLocation	(program.getProgram(), 0, "test");
646 			expectError				(GL_NO_ERROR);
647 			glGetAttribLocation		(program.getProgram(), "test");
648 			expectError				(GL_NO_ERROR);
649 			glGetAttribLocation		(-2, "test");
650 			expectError				(GL_INVALID_VALUE);
651 			m_log << TestLog::EndSection;
652 
653 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
654 			glGetAttribLocation		(shader, "test");
655 			expectError				(GL_INVALID_OPERATION);
656 			m_log << TestLog::EndSection;
657 
658 			glUseProgram			(0);
659 			glDeleteShader			(shader);
660 			glDeleteProgram			(programEmpty);
661 		});
662 	ES3F_ADD_API_CASE(get_uniform_location, "Invalid glGetUniformLocation() usage",
663 		{
664 			GLuint programEmpty = glCreateProgram();
665 			GLuint shader = glCreateShader(GL_VERTEX_SHADER);
666 
667 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
668 
669 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
670 			glGetUniformLocation(programEmpty, "test");
671 			expectError(GL_INVALID_OPERATION);
672 			m_log << TestLog::EndSection;
673 
674 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
675 			glUseProgram(program.getProgram());
676 			glGetUniformLocation(-2, "test");
677 			expectError(GL_INVALID_VALUE);
678 			m_log << TestLog::EndSection;
679 
680 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
681 			glGetAttribLocation(shader, "test");
682 			expectError(GL_INVALID_OPERATION);
683 			m_log << TestLog::EndSection;
684 
685 			glUseProgram(0);
686 			glDeleteProgram(programEmpty);
687 			glDeleteShader(shader);
688 		});
689 	ES3F_ADD_API_CASE(bind_attrib_location, "Invalid glBindAttribLocation() usage",
690 		{
691 			GLuint program = glCreateProgram();
692 			GLuint maxIndex = m_context.getContextInfo().getInt(GL_MAX_VERTEX_ATTRIBS);
693 			GLuint shader = glCreateShader(GL_VERTEX_SHADER);
694 
695 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
696 			glBindAttribLocation(program, maxIndex, "test");
697 			expectError(GL_INVALID_VALUE);
698 			m_log << TestLog::EndSection;
699 
700 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if name starts with the reserved prefix \"gl_\".");
701 			glBindAttribLocation(program, maxIndex-1, "gl_test");
702 			expectError(GL_INVALID_OPERATION);
703 			m_log << TestLog::EndSection;
704 
705 			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
706 			glBindAttribLocation(-1, maxIndex-1, "test");
707 			expectError(GL_INVALID_VALUE);
708 			m_log << TestLog::EndSection;
709 
710 			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
711 			glBindAttribLocation(shader, maxIndex-1, "test");
712 			expectError(GL_INVALID_OPERATION);
713 			m_log << TestLog::EndSection;
714 
715 			glDeleteProgram(program);
716 			glDeleteShader(shader);
717 		});
718 	ES3F_ADD_API_CASE(uniform_block_binding, "Invalid glUniformBlockBinding() usage",
719 		{
720 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformBlockVertSource, uniformTestFragSource));
721 
722 			glUseProgram	(program.getProgram());
723 
724 			GLint			maxUniformBufferBindings;
725 			GLint			numActiveUniforms			= -1;
726 			GLint			numActiveBlocks				= -1;
727 			glGetIntegerv	(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
728 			glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORMS,			&numActiveUniforms);
729 			glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS,	&numActiveBlocks);
730 			m_log << TestLog::Message << "// GL_MAX_UNIFORM_BUFFER_BINDINGS = " << maxUniformBufferBindings << TestLog::EndMessage;
731 			m_log << TestLog::Message << "// GL_ACTIVE_UNIFORMS = "				<< numActiveUniforms		<< TestLog::EndMessage;
732 			m_log << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = "		<< numActiveBlocks			<< TestLog::EndMessage;
733 			expectError		(GL_NO_ERROR);
734 
735 			m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if uniformBlockIndex is not an active uniform block index of program.");
736 			glUniformBlockBinding(program.getProgram(), -1, 0);
737 			expectError(GL_INVALID_VALUE);
738 			glUniformBlockBinding(program.getProgram(), 5, 0);
739 			expectError(GL_INVALID_VALUE);
740 			m_log << tcu::TestLog::EndSection;
741 
742 			m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if uniformBlockBinding is greater than or equal to the value of GL_MAX_UNIFORM_BUFFER_BINDINGS.");
743 			glUniformBlockBinding(program.getProgram(), maxUniformBufferBindings, 0);
744 			expectError(GL_INVALID_VALUE);
745 			m_log << tcu::TestLog::EndSection;
746 
747 			m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if program is not the name of a program object generated by the GL.");
748 			glUniformBlockBinding(-1, 0, 0);
749 			expectError(GL_INVALID_VALUE);
750 			m_log << tcu::TestLog::EndSection;
751 		});
752 
753 	// glUniform*f
754 
755 	ES3F_ADD_API_CASE(uniformf_invalid_program, "Invalid glUniform{1234}f() usage",
756 		{
757 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object.");
758 			glUseProgram(0);
759 			glUniform1f(-1, 0.0f);
760 			expectError(GL_INVALID_OPERATION);
761 			glUniform2f(-1, 0.0f, 0.0f);
762 			expectError(GL_INVALID_OPERATION);
763 			glUniform3f(-1, 0.0f, 0.0f, 0.0f);
764 			expectError(GL_INVALID_OPERATION);
765 			glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
766 			expectError(GL_INVALID_OPERATION);
767 			m_log << tcu::TestLog::EndSection;
768 		});
769 	ES3F_ADD_API_CASE(uniformf_incompatible_type, "Invalid glUniform{1234}f() usage",
770 		{
771 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
772 
773 			glUseProgram(program.getProgram());
774 			GLint vec4_v	= glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
775 			GLint ivec4_f	= glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
776 			GLint uvec4_f	= glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
777 			GLint sampler_f	= glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
778 			expectError(GL_NO_ERROR);
779 
780 			if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
781 			{
782 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
783 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
784 			}
785 
786 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command.");
787 			glUseProgram(program.getProgram());
788 			glUniform1f(vec4_v, 0.0f);
789 			expectError(GL_INVALID_OPERATION);
790 			glUniform2f(vec4_v, 0.0f, 0.0f);
791 			expectError(GL_INVALID_OPERATION);
792 			glUniform3f(vec4_v, 0.0f, 0.0f, 0.0f);
793 			expectError(GL_INVALID_OPERATION);
794 			glUniform4f(vec4_v, 0.0f, 0.0f, 0.0f, 0.0f);
795 			expectError(GL_NO_ERROR);
796 			m_log << tcu::TestLog::EndSection;
797 
798 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}f is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4.");
799 			glUseProgram(program.getProgram());
800 			glUniform4f(ivec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
801 			expectError(GL_INVALID_OPERATION);
802 			glUniform4f(uvec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
803 			expectError(GL_INVALID_OPERATION);
804 			m_log << tcu::TestLog::EndSection;
805 
806 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than glUniform1i and glUniform1iv.");
807 			glUseProgram(program.getProgram());
808 			glUniform1f(sampler_f, 0.0f);
809 			expectError(GL_INVALID_OPERATION);
810 			m_log << tcu::TestLog::EndSection;
811 
812 			glUseProgram(0);
813 		});
814 	ES3F_ADD_API_CASE(uniformf_invalid_location, "Invalid glUniform{1234}f() usage",
815 		{
816 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
817 
818 			glUseProgram(program.getProgram());
819 			expectError(GL_NO_ERROR);
820 
821 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
822 			glUseProgram(program.getProgram());
823 			glUniform1f(-2, 0.0f);
824 			expectError(GL_INVALID_OPERATION);
825 			glUniform2f(-2, 0.0f, 0.0f);
826 			expectError(GL_INVALID_OPERATION);
827 			glUniform3f(-2, 0.0f, 0.0f, 0.0f);
828 			expectError(GL_INVALID_OPERATION);
829 			glUniform4f(-2, 0.0f, 0.0f, 0.0f, 0.0f);
830 			expectError(GL_INVALID_OPERATION);
831 
832 			glUseProgram(program.getProgram());
833 			glUniform1f(-1, 0.0f);
834 			expectError(GL_NO_ERROR);
835 			glUniform2f(-1, 0.0f, 0.0f);
836 			expectError(GL_NO_ERROR);
837 			glUniform3f(-1, 0.0f, 0.0f, 0.0f);
838 			expectError(GL_NO_ERROR);
839 			glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
840 			expectError(GL_NO_ERROR);
841 			m_log << tcu::TestLog::EndSection;
842 
843 			glUseProgram(0);
844 		});
845 
846 	// glUniform*fv
847 
848 	ES3F_ADD_API_CASE(uniformfv_invalid_program, "Invalid glUniform{1234}fv() usage",
849 		{
850 			std::vector<GLfloat> data(4);
851 
852 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object.");
853 			glUseProgram(0);
854 			glUniform1fv(-1, 1, &data[0]);
855 			expectError(GL_INVALID_OPERATION);
856 			glUniform2fv(-1, 1, &data[0]);
857 			expectError(GL_INVALID_OPERATION);
858 			glUniform3fv(-1, 1, &data[0]);
859 			expectError(GL_INVALID_OPERATION);
860 			glUniform4fv(-1, 1, &data[0]);
861 			expectError(GL_INVALID_OPERATION);
862 			m_log << tcu::TestLog::EndSection;
863 		});
864 	ES3F_ADD_API_CASE(uniformfv_incompatible_type, "Invalid glUniform{1234}fv() usage",
865 		{
866 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
867 
868 			glUseProgram(program.getProgram());
869 			GLint vec4_v	= glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
870 			GLint ivec4_f	= glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
871 			GLint uvec4_f	= glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
872 			GLint sampler_f	= glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
873 			expectError(GL_NO_ERROR);
874 
875 			if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
876 			{
877 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
878 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
879 			}
880 
881 			std::vector<GLfloat> data(4);
882 
883 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command.");
884 			glUseProgram(program.getProgram());
885 			glUniform1fv(vec4_v, 1, &data[0]);
886 			expectError(GL_INVALID_OPERATION);
887 			glUniform2fv(vec4_v, 1, &data[0]);
888 			expectError(GL_INVALID_OPERATION);
889 			glUniform3fv(vec4_v, 1, &data[0]);
890 			expectError(GL_INVALID_OPERATION);
891 			glUniform4fv(vec4_v, 1, &data[0]);
892 			expectError(GL_NO_ERROR);
893 			m_log << tcu::TestLog::EndSection;
894 
895 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}fv is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4.");
896 			glUseProgram(program.getProgram());
897 			glUniform4fv(ivec4_f, 1, &data[0]);
898 			expectError(GL_INVALID_OPERATION);
899 			glUniform4fv(uvec4_f, 1, &data[0]);
900 			expectError(GL_INVALID_OPERATION);
901 			m_log << tcu::TestLog::EndSection;
902 
903 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than glUniform1i and glUniform1iv.");
904 			glUseProgram(program.getProgram());
905 			glUniform1fv(sampler_f, 1, &data[0]);
906 			expectError(GL_INVALID_OPERATION);
907 			m_log << tcu::TestLog::EndSection;
908 
909 			glUseProgram(0);
910 		});
911 	ES3F_ADD_API_CASE(uniformfv_invalid_location, "Invalid glUniform{1234}fv() usage",
912 		{
913 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
914 
915 			glUseProgram(program.getProgram());
916 			expectError(GL_NO_ERROR);
917 
918 			std::vector<GLfloat> data(4);
919 
920 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
921 			glUseProgram(program.getProgram());
922 			glUniform1fv(-2, 1, &data[0]);
923 			expectError(GL_INVALID_OPERATION);
924 			glUniform2fv(-2, 1, &data[0]);
925 			expectError(GL_INVALID_OPERATION);
926 			glUniform3fv(-2, 1, &data[0]);
927 			expectError(GL_INVALID_OPERATION);
928 			glUniform4fv(-2, 1, &data[0]);
929 			expectError(GL_INVALID_OPERATION);
930 
931 			glUseProgram(program.getProgram());
932 			glUniform1fv(-1, 1, &data[0]);
933 			expectError(GL_NO_ERROR);
934 			glUniform2fv(-1, 1, &data[0]);
935 			expectError(GL_NO_ERROR);
936 			glUniform3fv(-1, 1, &data[0]);
937 			expectError(GL_NO_ERROR);
938 			glUniform4fv(-1, 1, &data[0]);
939 			expectError(GL_NO_ERROR);
940 			m_log << tcu::TestLog::EndSection;
941 
942 			glUseProgram(0);
943 		});
944 	ES3F_ADD_API_CASE(uniformfv_invalid_count, "Invalid glUniform{1234}fv() usage",
945 		{
946 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
947 
948 			glUseProgram			(program.getProgram());
949 			GLint vec4_v			= glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
950 			expectError(GL_NO_ERROR);
951 
952 			if (vec4_v == -1)
953 			{
954 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
955 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
956 			}
957 
958 			std::vector<GLfloat> data(8);
959 
960 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
961 			glUseProgram(program.getProgram());
962 			glUniform1fv(vec4_v, 2, &data[0]);
963 			expectError(GL_INVALID_OPERATION);
964 			glUniform2fv(vec4_v, 2, &data[0]);
965 			expectError(GL_INVALID_OPERATION);
966 			glUniform3fv(vec4_v, 2, &data[0]);
967 			expectError(GL_INVALID_OPERATION);
968 			glUniform4fv(vec4_v, 2, &data[0]);
969 			expectError(GL_INVALID_OPERATION);
970 			m_log << tcu::TestLog::EndSection;
971 
972 			glUseProgram(0);
973 		});
974 
975 	// glUniform*i
976 
977 	ES3F_ADD_API_CASE(uniformi_invalid_program, "Invalid glUniform{1234}i() usage",
978 		{
979 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object.");
980 			glUseProgram(0);
981 			glUniform1i(-1, 0);
982 			expectError(GL_INVALID_OPERATION);
983 			glUniform2i(-1, 0, 0);
984 			expectError(GL_INVALID_OPERATION);
985 			glUniform3i(-1, 0, 0, 0);
986 			expectError(GL_INVALID_OPERATION);
987 			glUniform4i(-1, 0, 0, 0, 0);
988 			expectError(GL_INVALID_OPERATION);
989 			m_log << tcu::TestLog::EndSection;
990 		});
991 	ES3F_ADD_API_CASE(uniformi_incompatible_type, "Invalid glUniform{1234}i() usage",
992 		{
993 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
994 
995 			glUseProgram(program.getProgram());
996 			GLint vec4_v	= glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
997 			GLint ivec4_f	= glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
998 			GLint uvec4_f	= glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
999 			GLint sampler_f	= glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1000 			expectError(GL_NO_ERROR);
1001 
1002 			if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1003 			{
1004 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1005 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
1006 			}
1007 
1008 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command.");
1009 			glUseProgram(program.getProgram());
1010 			glUniform1i(ivec4_f, 0);
1011 			expectError(GL_INVALID_OPERATION);
1012 			glUniform2i(ivec4_f, 0, 0);
1013 			expectError(GL_INVALID_OPERATION);
1014 			glUniform3i(ivec4_f, 0, 0, 0);
1015 			expectError(GL_INVALID_OPERATION);
1016 			glUniform4i(ivec4_f, 0, 0, 0, 0);
1017 			expectError(GL_NO_ERROR);
1018 			m_log << tcu::TestLog::EndSection;
1019 
1020 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}i is used to load a uniform variable of type unsigned int, uvec2, uvec3, uvec4, or an array of these.");
1021 			glUseProgram(program.getProgram());
1022 			glUniform1i(uvec4_f, 0);
1023 			expectError(GL_INVALID_OPERATION);
1024 			glUniform2i(uvec4_f, 0, 0);
1025 			expectError(GL_INVALID_OPERATION);
1026 			glUniform3i(uvec4_f, 0, 0, 0);
1027 			expectError(GL_INVALID_OPERATION);
1028 			glUniform4i(uvec4_f, 0, 0, 0, 0);
1029 			expectError(GL_INVALID_OPERATION);
1030 			m_log << tcu::TestLog::EndSection;
1031 
1032 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1033 			glUseProgram(program.getProgram());
1034 			glUniform1i(vec4_v, 0);
1035 			expectError(GL_INVALID_OPERATION);
1036 			glUniform2i(vec4_v, 0, 0);
1037 			expectError(GL_INVALID_OPERATION);
1038 			glUniform3i(vec4_v, 0, 0, 0);
1039 			expectError(GL_INVALID_OPERATION);
1040 			glUniform4i(vec4_v, 0, 0, 0, 0);
1041 			expectError(GL_INVALID_OPERATION);
1042 			m_log << tcu::TestLog::EndSection;
1043 
1044 			glUseProgram(0);
1045 		});
1046 	ES3F_ADD_API_CASE(uniformi_invalid_location, "Invalid glUniform{1234}i() usage",
1047 		{
1048 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1049 
1050 			glUseProgram(program.getProgram());
1051 			expectError(GL_NO_ERROR);
1052 
1053 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1054 			glUseProgram(program.getProgram());
1055 			glUniform1i(-2, 0);
1056 			expectError(GL_INVALID_OPERATION);
1057 			glUniform2i(-2, 0, 0);
1058 			expectError(GL_INVALID_OPERATION);
1059 			glUniform3i(-2, 0, 0, 0);
1060 			expectError(GL_INVALID_OPERATION);
1061 			glUniform4i(-2, 0, 0, 0, 0);
1062 			expectError(GL_INVALID_OPERATION);
1063 
1064 			glUseProgram(program.getProgram());
1065 			glUniform1i(-1, 0);
1066 			expectError(GL_NO_ERROR);
1067 			glUniform2i(-1, 0, 0);
1068 			expectError(GL_NO_ERROR);
1069 			glUniform3i(-1, 0, 0, 0);
1070 			expectError(GL_NO_ERROR);
1071 			glUniform4i(-1, 0, 0, 0, 0);
1072 			expectError(GL_NO_ERROR);
1073 			m_log << tcu::TestLog::EndSection;
1074 
1075 			glUseProgram(0);
1076 		});
1077 
1078 	// glUniform*iv
1079 
1080 	ES3F_ADD_API_CASE(uniformiv_invalid_program, "Invalid glUniform{1234}iv() usage",
1081 		{
1082 			std::vector<GLint> data(4);
1083 
1084 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object.");
1085 			glUseProgram(0);
1086 			glUniform1iv(-1, 1, &data[0]);
1087 			expectError(GL_INVALID_OPERATION);
1088 			glUniform2iv(-1, 1, &data[0]);
1089 			expectError(GL_INVALID_OPERATION);
1090 			glUniform3iv(-1, 1, &data[0]);
1091 			expectError(GL_INVALID_OPERATION);
1092 			glUniform4iv(-1, 1, &data[0]);
1093 			expectError(GL_INVALID_OPERATION);
1094 			m_log << tcu::TestLog::EndSection;
1095 		});
1096 	ES3F_ADD_API_CASE(uniformiv_incompatible_type, "Invalid glUniform{1234}iv() usage",
1097 		{
1098 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1099 
1100 			glUseProgram(program.getProgram());
1101 			GLint vec4_v	= glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1102 			GLint ivec4_f	= glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
1103 			GLint uvec4_f	= glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
1104 			GLint sampler_f	= glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1105 			expectError(GL_NO_ERROR);
1106 
1107 			if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1108 			{
1109 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1110 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
1111 			}
1112 
1113 			std::vector<GLint> data(4);
1114 
1115 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command.");
1116 			glUseProgram(program.getProgram());
1117 			glUniform1iv(ivec4_f, 1, &data[0]);
1118 			expectError(GL_INVALID_OPERATION);
1119 			glUniform2iv(ivec4_f, 1, &data[0]);
1120 			expectError(GL_INVALID_OPERATION);
1121 			glUniform3iv(ivec4_f, 1, &data[0]);
1122 			expectError(GL_INVALID_OPERATION);
1123 			glUniform4iv(ivec4_f, 1, &data[0]);
1124 			expectError(GL_NO_ERROR);
1125 			m_log << tcu::TestLog::EndSection;
1126 
1127 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}iv is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1128 			glUseProgram(program.getProgram());
1129 			glUniform1iv(vec4_v, 1, &data[0]);
1130 			expectError(GL_INVALID_OPERATION);
1131 			glUniform2iv(vec4_v, 1, &data[0]);
1132 			expectError(GL_INVALID_OPERATION);
1133 			glUniform3iv(vec4_v, 1, &data[0]);
1134 			expectError(GL_INVALID_OPERATION);
1135 			glUniform4iv(vec4_v, 1, &data[0]);
1136 			expectError(GL_INVALID_OPERATION);
1137 			m_log << tcu::TestLog::EndSection;
1138 
1139 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}iv is used to load a uniform variable of type unsigned int, uvec2, uvec3 or uvec4.");
1140 			glUseProgram(program.getProgram());
1141 			glUniform1iv(uvec4_f, 1, &data[0]);
1142 			expectError(GL_INVALID_OPERATION);
1143 			glUniform2iv(uvec4_f, 1, &data[0]);
1144 			expectError(GL_INVALID_OPERATION);
1145 			glUniform3iv(uvec4_f, 1, &data[0]);
1146 			expectError(GL_INVALID_OPERATION);
1147 			glUniform4iv(uvec4_f, 1, &data[0]);
1148 			expectError(GL_INVALID_OPERATION);
1149 			m_log << tcu::TestLog::EndSection;
1150 
1151 			glUseProgram(0);
1152 		});
1153 	ES3F_ADD_API_CASE(uniformiv_invalid_location, "Invalid glUniform{1234}iv() usage",
1154 		{
1155 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1156 
1157 			glUseProgram(program.getProgram());
1158 			expectError(GL_NO_ERROR);
1159 
1160 			std::vector<GLint> data(4);
1161 
1162 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1163 			glUseProgram(program.getProgram());
1164 			glUniform1iv(-2, 1, &data[0]);
1165 			expectError(GL_INVALID_OPERATION);
1166 			glUniform2iv(-2, 1, &data[0]);
1167 			expectError(GL_INVALID_OPERATION);
1168 			glUniform3iv(-2, 1, &data[0]);
1169 			expectError(GL_INVALID_OPERATION);
1170 			glUniform4iv(-2, 1, &data[0]);
1171 			expectError(GL_INVALID_OPERATION);
1172 
1173 			glUseProgram(program.getProgram());
1174 			glUniform1iv(-1, 1, &data[0]);
1175 			expectError(GL_NO_ERROR);
1176 			glUniform2iv(-1, 1, &data[0]);
1177 			expectError(GL_NO_ERROR);
1178 			glUniform3iv(-1, 1, &data[0]);
1179 			expectError(GL_NO_ERROR);
1180 			glUniform4iv(-1, 1, &data[0]);
1181 			expectError(GL_NO_ERROR);
1182 			m_log << tcu::TestLog::EndSection;
1183 
1184 			glUseProgram(0);
1185 		});
1186 	ES3F_ADD_API_CASE(uniformiv_invalid_count, "Invalid glUniform{1234}iv() usage",
1187 		{
1188 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1189 
1190 			glUseProgram			(program.getProgram());
1191 			GLint ivec4_f			= glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1192 			expectError(GL_NO_ERROR);
1193 
1194 			if (ivec4_f == -1)
1195 			{
1196 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1197 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
1198 			}
1199 
1200 			std::vector<GLint> data(8);
1201 
1202 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1203 			glUseProgram(program.getProgram());
1204 			glUniform1iv(ivec4_f, 2, &data[0]);
1205 			expectError(GL_INVALID_OPERATION);
1206 			glUniform2iv(ivec4_f, 2, &data[0]);
1207 			expectError(GL_INVALID_OPERATION);
1208 			glUniform3iv(ivec4_f, 2, &data[0]);
1209 			expectError(GL_INVALID_OPERATION);
1210 			glUniform4iv(ivec4_f, 2, &data[0]);
1211 			expectError(GL_INVALID_OPERATION);
1212 			m_log << tcu::TestLog::EndSection;
1213 
1214 			glUseProgram(0);
1215 		});
1216 
1217 	// glUniform{1234}ui
1218 
1219 	ES3F_ADD_API_CASE(uniformui_invalid_program, "Invalid glUniform{234}ui() usage",
1220 		{
1221 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object.");
1222 			glUseProgram(0);
1223 			glUniform1ui(-1, 0);
1224 			expectError(GL_INVALID_OPERATION);
1225 			glUniform2ui(-1, 0, 0);
1226 			expectError(GL_INVALID_OPERATION);
1227 			glUniform3ui(-1, 0, 0, 0);
1228 			expectError(GL_INVALID_OPERATION);
1229 			glUniform4ui(-1, 0, 0, 0, 0);
1230 			expectError(GL_INVALID_OPERATION);
1231 			m_log << tcu::TestLog::EndSection;
1232 		});
1233 	ES3F_ADD_API_CASE(uniformui_incompatible_type, "Invalid glUniform{1234}ui() usage",
1234 		{
1235 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1236 
1237 			glUseProgram(program.getProgram());
1238 			GLint vec4_v	= glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1239 			GLint ivec4_f	= glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
1240 			GLint uvec4_f	= glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
1241 			GLint sampler_f	= glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1242 			expectError(GL_NO_ERROR);
1243 
1244 			if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1245 			{
1246 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1247 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
1248 			}
1249 
1250 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command.");
1251 			glUseProgram(program.getProgram());
1252 			glUniform1ui(uvec4_f, 0);
1253 			expectError(GL_INVALID_OPERATION);
1254 			glUniform2ui(uvec4_f, 0, 0);
1255 			expectError(GL_INVALID_OPERATION);
1256 			glUniform3ui(uvec4_f, 0, 0, 0);
1257 			expectError(GL_INVALID_OPERATION);
1258 			glUniform4ui(uvec4_f, 0, 0, 0, 0);
1259 			expectError(GL_NO_ERROR);
1260 			m_log << tcu::TestLog::EndSection;
1261 
1262 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}i is used to load a uniform variable of type int, ivec2, ivec3, ivec4, or an array of these.");
1263 			glUseProgram(program.getProgram());
1264 			glUniform1ui(ivec4_f, 0);
1265 			expectError(GL_INVALID_OPERATION);
1266 			glUniform2ui(ivec4_f, 0, 0);
1267 			expectError(GL_INVALID_OPERATION);
1268 			glUniform3ui(ivec4_f, 0, 0, 0);
1269 			expectError(GL_INVALID_OPERATION);
1270 			glUniform4ui(ivec4_f, 0, 0, 0, 0);
1271 			expectError(GL_INVALID_OPERATION);
1272 			m_log << tcu::TestLog::EndSection;
1273 
1274 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1275 			glUseProgram(program.getProgram());
1276 			glUniform1ui(vec4_v, 0);
1277 			expectError(GL_INVALID_OPERATION);
1278 			glUniform2ui(vec4_v, 0, 0);
1279 			expectError(GL_INVALID_OPERATION);
1280 			glUniform3ui(vec4_v, 0, 0, 0);
1281 			expectError(GL_INVALID_OPERATION);
1282 			glUniform4ui(vec4_v, 0, 0, 0, 0);
1283 			expectError(GL_INVALID_OPERATION);
1284 			m_log << tcu::TestLog::EndSection;
1285 
1286 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than glUniform1i and glUniform1iv.");
1287 			glUseProgram(program.getProgram());
1288 			glUniform1ui(sampler_f, 0);
1289 			expectError(GL_INVALID_OPERATION);
1290 			m_log << tcu::TestLog::EndSection;
1291 
1292 			glUseProgram(0);
1293 		});
1294 	ES3F_ADD_API_CASE(uniformui_invalid_location, "Invalid glUniform{1234}ui() usage",
1295 		{
1296 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1297 
1298 			glUseProgram(program.getProgram());
1299 			expectError(GL_NO_ERROR);
1300 
1301 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1302 			glUseProgram(program.getProgram());
1303 			glUniform1i(-2, 0);
1304 			expectError(GL_INVALID_OPERATION);
1305 			glUniform2i(-2, 0, 0);
1306 			expectError(GL_INVALID_OPERATION);
1307 			glUniform3i(-2, 0, 0, 0);
1308 			expectError(GL_INVALID_OPERATION);
1309 			glUniform4i(-2, 0, 0, 0, 0);
1310 			expectError(GL_INVALID_OPERATION);
1311 
1312 			glUseProgram(program.getProgram());
1313 			glUniform1i(-1, 0);
1314 			expectError(GL_NO_ERROR);
1315 			glUniform2i(-1, 0, 0);
1316 			expectError(GL_NO_ERROR);
1317 			glUniform3i(-1, 0, 0, 0);
1318 			expectError(GL_NO_ERROR);
1319 			glUniform4i(-1, 0, 0, 0, 0);
1320 			expectError(GL_NO_ERROR);
1321 			m_log << tcu::TestLog::EndSection;
1322 
1323 			glUseProgram(0);
1324 		});
1325 
1326 	// glUniform{1234}uiv
1327 
1328 	ES3F_ADD_API_CASE(uniformuiv_invalid_program, "Invalid glUniform{234}uiv() usage",
1329 		{
1330 			std::vector<GLuint> data(4);
1331 
1332 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object.");
1333 			glUseProgram(0);
1334 			glUniform1uiv(-1, 1, &data[0]);
1335 			expectError(GL_INVALID_OPERATION);
1336 			glUniform2uiv(-1, 1, &data[0]);
1337 			expectError(GL_INVALID_OPERATION);
1338 			glUniform3uiv(-1, 1, &data[0]);
1339 			expectError(GL_INVALID_OPERATION);
1340 			glUniform4uiv(-1, 1, &data[0]);
1341 			expectError(GL_INVALID_OPERATION);
1342 			m_log << tcu::TestLog::EndSection;
1343 		});
1344 	ES3F_ADD_API_CASE(uniformuiv_incompatible_type, "Invalid glUniform{1234}uiv() usage",
1345 		{
1346 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1347 
1348 			glUseProgram(program.getProgram());
1349 			GLint vec4_v	= glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1350 			GLint ivec4_f	= glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
1351 			GLint uvec4_f	= glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
1352 			GLint sampler_f	= glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1353 			expectError(GL_NO_ERROR);
1354 
1355 			if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1356 			{
1357 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1358 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
1359 			}
1360 
1361 			std::vector<GLuint> data(4);
1362 
1363 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command.");
1364 			glUseProgram(program.getProgram());
1365 			glUniform1uiv(uvec4_f, 1, &data[0]);
1366 			expectError(GL_INVALID_OPERATION);
1367 			glUniform2uiv(uvec4_f, 1, &data[0]);
1368 			expectError(GL_INVALID_OPERATION);
1369 			glUniform3uiv(uvec4_f, 1, &data[0]);
1370 			expectError(GL_INVALID_OPERATION);
1371 			glUniform4uiv(uvec4_f, 1, &data[0]);
1372 			expectError(GL_NO_ERROR);
1373 			m_log << tcu::TestLog::EndSection;
1374 
1375 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}uiv is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1376 			glUseProgram(program.getProgram());
1377 			glUniform1uiv(vec4_v, 1, &data[0]);
1378 			expectError(GL_INVALID_OPERATION);
1379 			glUniform2uiv(vec4_v, 1, &data[0]);
1380 			expectError(GL_INVALID_OPERATION);
1381 			glUniform3uiv(vec4_v, 1, &data[0]);
1382 			expectError(GL_INVALID_OPERATION);
1383 			glUniform4uiv(vec4_v, 1, &data[0]);
1384 			expectError(GL_INVALID_OPERATION);
1385 			m_log << tcu::TestLog::EndSection;
1386 
1387 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if glUniform{1234}uiv is used to load a uniform variable of type int, ivec2, ivec3 or ivec4.");
1388 			glUseProgram(program.getProgram());
1389 			glUniform1uiv(ivec4_f, 1, &data[0]);
1390 			expectError(GL_INVALID_OPERATION);
1391 			glUniform2uiv(ivec4_f, 1, &data[0]);
1392 			expectError(GL_INVALID_OPERATION);
1393 			glUniform3uiv(ivec4_f, 1, &data[0]);
1394 			expectError(GL_INVALID_OPERATION);
1395 			glUniform4uiv(ivec4_f, 1, &data[0]);
1396 			expectError(GL_INVALID_OPERATION);
1397 			m_log << tcu::TestLog::EndSection;
1398 
1399 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than glUniform1i and glUniform1iv.");
1400 			glUseProgram(program.getProgram());
1401 			glUniform1uiv(sampler_f, 1, &data[0]);
1402 			expectError(GL_INVALID_OPERATION);
1403 			m_log << tcu::TestLog::EndSection;
1404 
1405 			glUseProgram(0);
1406 		});
1407 	ES3F_ADD_API_CASE(uniformuiv_invalid_location, "Invalid glUniform{1234}uiv() usage",
1408 		{
1409 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1410 
1411 			glUseProgram(program.getProgram());
1412 			expectError(GL_NO_ERROR);
1413 
1414 			std::vector<GLuint> data(4);
1415 
1416 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1417 			glUseProgram(program.getProgram());
1418 			glUniform1uiv(-2, 1, &data[0]);
1419 			expectError(GL_INVALID_OPERATION);
1420 			glUniform2uiv(-2, 1, &data[0]);
1421 			expectError(GL_INVALID_OPERATION);
1422 			glUniform3uiv(-2, 1, &data[0]);
1423 			expectError(GL_INVALID_OPERATION);
1424 			glUniform4uiv(-2, 1, &data[0]);
1425 			expectError(GL_INVALID_OPERATION);
1426 
1427 			glUseProgram(program.getProgram());
1428 			glUniform1uiv(-1, 1, &data[0]);
1429 			expectError(GL_NO_ERROR);
1430 			glUniform2uiv(-1, 1, &data[0]);
1431 			expectError(GL_NO_ERROR);
1432 			glUniform3uiv(-1, 1, &data[0]);
1433 			expectError(GL_NO_ERROR);
1434 			glUniform4uiv(-1, 1, &data[0]);
1435 			expectError(GL_NO_ERROR);
1436 			m_log << tcu::TestLog::EndSection;
1437 
1438 			glUseProgram(0);
1439 		});
1440 	ES3F_ADD_API_CASE(uniformuiv_invalid_count, "Invalid glUniform{1234}uiv() usage",
1441 		{
1442 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1443 
1444 			glUseProgram			(program.getProgram());
1445 			int uvec4_f				= glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1446 			expectError(GL_NO_ERROR);
1447 
1448 			if (uvec4_f == -1)
1449 			{
1450 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1451 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
1452 			}
1453 
1454 			std::vector<GLuint> data(8);
1455 
1456 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1457 			glUseProgram(program.getProgram());
1458 			glUniform1uiv(uvec4_f, 2, &data[0]);
1459 			expectError(GL_INVALID_OPERATION);
1460 			glUniform2uiv(uvec4_f, 2, &data[0]);
1461 			expectError(GL_INVALID_OPERATION);
1462 			glUniform3uiv(uvec4_f, 2, &data[0]);
1463 			expectError(GL_INVALID_OPERATION);
1464 			glUniform4uiv(uvec4_f, 2, &data[0]);
1465 			expectError(GL_INVALID_OPERATION);
1466 			m_log << tcu::TestLog::EndSection;
1467 
1468 			glUseProgram(0);
1469 		});
1470 
1471 
1472 	// glUniformMatrix*fv
1473 
1474 	ES3F_ADD_API_CASE(uniform_matrixfv_invalid_program, "Invalid glUniformMatrix{234}fv() usage",
1475 		{
1476 			std::vector<GLfloat> data(16);
1477 
1478 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if there is no current program object.");
1479 			glUseProgram(0);
1480 			glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
1481 			expectError(GL_INVALID_OPERATION);
1482 			glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
1483 			expectError(GL_INVALID_OPERATION);
1484 			glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
1485 			expectError(GL_INVALID_OPERATION);
1486 
1487 			glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
1488 			expectError(GL_INVALID_OPERATION);
1489 			glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
1490 			expectError(GL_INVALID_OPERATION);
1491 			glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
1492 			expectError(GL_INVALID_OPERATION);
1493 			glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
1494 			expectError(GL_INVALID_OPERATION);
1495 			glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
1496 			expectError(GL_INVALID_OPERATION);
1497 			glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
1498 			expectError(GL_INVALID_OPERATION);
1499 			m_log << tcu::TestLog::EndSection;
1500 		});
1501 	ES3F_ADD_API_CASE(uniform_matrixfv_incompatible_type, "Invalid glUniformMatrix{234}fv() usage",
1502 		{
1503 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1504 
1505 			glUseProgram			(program.getProgram());
1506 			GLint mat4_v			= glGetUniformLocation(program.getProgram(), "mat4_v");	// mat4
1507 			GLint sampler_f			= glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1508 			expectError(GL_NO_ERROR);
1509 
1510 			if (mat4_v == -1 || sampler_f == -1)
1511 			{
1512 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1513 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
1514 			}
1515 
1516 			std::vector<GLfloat> data(16);
1517 
1518 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the glUniform command.");
1519 			glUseProgram(program.getProgram());
1520 			glUniformMatrix2fv(mat4_v, 1, GL_FALSE, &data[0]);
1521 			expectError(GL_INVALID_OPERATION);
1522 			glUniformMatrix3fv(mat4_v, 1, GL_FALSE, &data[0]);
1523 			expectError(GL_INVALID_OPERATION);
1524 			glUniformMatrix4fv(mat4_v, 1, GL_FALSE, &data[0]);
1525 			expectError(GL_NO_ERROR);
1526 
1527 			glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1528 			expectError(GL_INVALID_OPERATION);
1529 			glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1530 			expectError(GL_INVALID_OPERATION);
1531 			glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1532 			expectError(GL_INVALID_OPERATION);
1533 			glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1534 			expectError(GL_INVALID_OPERATION);
1535 			glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1536 			expectError(GL_INVALID_OPERATION);
1537 			glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1538 			expectError(GL_INVALID_OPERATION);
1539 			m_log << tcu::TestLog::EndSection;
1540 
1541 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than glUniform1i and glUniform1iv.");
1542 			glUseProgram(program.getProgram());
1543 			glUniformMatrix2fv(sampler_f, 1, GL_FALSE, &data[0]);
1544 			expectError(GL_INVALID_OPERATION);
1545 			glUniformMatrix3fv(sampler_f, 1, GL_FALSE, &data[0]);
1546 			expectError(GL_INVALID_OPERATION);
1547 			glUniformMatrix4fv(sampler_f, 1, GL_FALSE, &data[0]);
1548 			expectError(GL_INVALID_OPERATION);
1549 
1550 			glUniformMatrix2x3fv(sampler_f, 1, GL_FALSE, &data[0]);
1551 			expectError(GL_INVALID_OPERATION);
1552 			glUniformMatrix3x2fv(sampler_f, 1, GL_FALSE, &data[0]);
1553 			expectError(GL_INVALID_OPERATION);
1554 			glUniformMatrix2x4fv(sampler_f, 1, GL_FALSE, &data[0]);
1555 			expectError(GL_INVALID_OPERATION);
1556 			glUniformMatrix4x2fv(sampler_f, 1, GL_FALSE, &data[0]);
1557 			expectError(GL_INVALID_OPERATION);
1558 			glUniformMatrix3x4fv(sampler_f, 1, GL_FALSE, &data[0]);
1559 			expectError(GL_INVALID_OPERATION);
1560 			glUniformMatrix4x3fv(sampler_f, 1, GL_FALSE, &data[0]);
1561 			expectError(GL_INVALID_OPERATION);
1562 			m_log << tcu::TestLog::EndSection;
1563 
1564 			glUseProgram(0);
1565 		});
1566 	ES3F_ADD_API_CASE(uniform_matrixfv_invalid_location, "Invalid glUniformMatrix{234}fv() usage",
1567 		{
1568 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1569 
1570 			glUseProgram(program.getProgram());
1571 			expectError(GL_NO_ERROR);
1572 
1573 			std::vector<GLfloat> data(16);
1574 
1575 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1576 			glUseProgram(program.getProgram());
1577 			glUniformMatrix2fv(-2, 1, GL_FALSE, &data[0]);
1578 			expectError(GL_INVALID_OPERATION);
1579 			glUniformMatrix3fv(-2, 1, GL_FALSE, &data[0]);
1580 			expectError(GL_INVALID_OPERATION);
1581 			glUniformMatrix4fv(-2, 1, GL_FALSE, &data[0]);
1582 			expectError(GL_INVALID_OPERATION);
1583 
1584 			glUniformMatrix2x3fv(-2, 1, GL_FALSE, &data[0]);
1585 			expectError(GL_INVALID_OPERATION);
1586 			glUniformMatrix3x2fv(-2, 1, GL_FALSE, &data[0]);
1587 			expectError(GL_INVALID_OPERATION);
1588 			glUniformMatrix2x4fv(-2, 1, GL_FALSE, &data[0]);
1589 			expectError(GL_INVALID_OPERATION);
1590 			glUniformMatrix4x2fv(-2, 1, GL_FALSE, &data[0]);
1591 			expectError(GL_INVALID_OPERATION);
1592 			glUniformMatrix3x4fv(-2, 1, GL_FALSE, &data[0]);
1593 			expectError(GL_INVALID_OPERATION);
1594 			glUniformMatrix4x3fv(-2, 1, GL_FALSE, &data[0]);
1595 			expectError(GL_INVALID_OPERATION);
1596 
1597 			glUseProgram(program.getProgram());
1598 			glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
1599 			expectError(GL_NO_ERROR);
1600 			glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
1601 			expectError(GL_NO_ERROR);
1602 			glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
1603 			expectError(GL_NO_ERROR);
1604 
1605 			glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
1606 			expectError(GL_NO_ERROR);
1607 			glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
1608 			expectError(GL_NO_ERROR);
1609 			glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
1610 			expectError(GL_NO_ERROR);
1611 			glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
1612 			expectError(GL_NO_ERROR);
1613 			glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
1614 			expectError(GL_NO_ERROR);
1615 			glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
1616 			expectError(GL_NO_ERROR);
1617 			m_log << tcu::TestLog::EndSection;
1618 
1619 			glUseProgram(0);
1620 		});
1621 	ES3F_ADD_API_CASE(uniform_matrixfv_invalid_count, "Invalid glUniformMatrix{234}fv() usage",
1622 		{
1623 			glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1624 
1625 			glUseProgram			(program.getProgram());
1626 			GLint mat4_v			= glGetUniformLocation(program.getProgram(), "mat4_v"); // mat4
1627 			expectError(GL_NO_ERROR);
1628 
1629 			if (mat4_v == -1)
1630 			{
1631 				m_log << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1632 				m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
1633 			}
1634 
1635 			std::vector<GLfloat> data(32);
1636 
1637 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1638 			glUseProgram(program.getProgram());
1639 			glUniformMatrix2fv(mat4_v, 2, GL_FALSE, &data[0]);
1640 			expectError(GL_INVALID_OPERATION);
1641 			glUniformMatrix3fv(mat4_v, 2, GL_FALSE, &data[0]);
1642 			expectError(GL_INVALID_OPERATION);
1643 			glUniformMatrix4fv(mat4_v, 2, GL_FALSE, &data[0]);
1644 			expectError(GL_INVALID_OPERATION);
1645 
1646 			glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1647 			expectError(GL_INVALID_OPERATION);
1648 			glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1649 			expectError(GL_INVALID_OPERATION);
1650 			glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1651 			expectError(GL_INVALID_OPERATION);
1652 			glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1653 			expectError(GL_INVALID_OPERATION);
1654 			glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1655 			expectError(GL_INVALID_OPERATION);
1656 			glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1657 			expectError(GL_INVALID_OPERATION);
1658 			m_log << tcu::TestLog::EndSection;
1659 
1660 			glUseProgram(0);
1661 		});
1662 
1663 	// Transform feedback
1664 
1665 	ES3F_ADD_API_CASE(gen_transform_feedbacks, "Invalid glGenTransformFeedbacks() usage",
1666 		{
1667 			m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1668 			GLuint id;
1669 			glGenTransformFeedbacks(-1, &id);
1670 			expectError(GL_INVALID_VALUE);
1671 			m_log << tcu::TestLog::EndSection;
1672 		});
1673 	ES3F_ADD_API_CASE(bind_transform_feedback, "Invalid glBindTransformFeedback() usage",
1674 		{
1675 			GLuint						tfID[2];
1676 			glu::ShaderProgram			program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1677 			deUint32					buf;
1678 			const char* tfVarying		= "gl_Position";
1679 
1680 			glGenBuffers				(1, &buf);
1681 			glGenTransformFeedbacks		(2, tfID);
1682 
1683 			m_log << tcu::TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK.");
1684 			glBindTransformFeedback(-1, tfID[0]);
1685 			expectError(GL_INVALID_ENUM);
1686 			m_log << tcu::TestLog::EndSection;
1687 
1688 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the transform feedback operation is active on the currently bound transform feedback object, and is not paused.");
1689 			glUseProgram				(program.getProgram());
1690 			glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1691 			glLinkProgram				(program.getProgram());
1692 			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
1693 			glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1694 			glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1695 			glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1696 			glBeginTransformFeedback	(GL_TRIANGLES);
1697 			expectError					(GL_NO_ERROR);
1698 
1699 			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[1]);
1700 			expectError					(GL_INVALID_OPERATION);
1701 
1702 			glEndTransformFeedback		();
1703 			expectError					(GL_NO_ERROR);
1704 			m_log << tcu::TestLog::EndSection;
1705 
1706 			glUseProgram				(0);
1707 			glDeleteBuffers				(1, &buf);
1708 			glDeleteTransformFeedbacks	(2, tfID);
1709 			expectError					(GL_NO_ERROR);
1710 		});
1711 	ES3F_ADD_API_CASE(delete_transform_feedbacks, "Invalid glDeleteTransformFeedbacks() usage",
1712 		{
1713 			GLuint id;
1714 			glGenTransformFeedbacks(1, &id);
1715 
1716 			m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
1717 			glDeleteTransformFeedbacks(-1, &id);
1718 			expectError(GL_INVALID_VALUE);
1719 			m_log << tcu::TestLog::EndSection;
1720 
1721 			glDeleteTransformFeedbacks(1, &id);
1722 		});
1723 	ES3F_ADD_API_CASE(begin_transform_feedback, "Invalid glBeginTransformFeedback() usage",
1724 		{
1725 			GLuint						tfID[2];
1726 			glu::ShaderProgram			program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1727 			deUint32					buf;
1728 			const char* tfVarying		= "gl_Position";
1729 
1730 			glGenBuffers				(1, &buf);
1731 			glGenTransformFeedbacks		(2, tfID);
1732 
1733 			glUseProgram				(program.getProgram());
1734 			glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1735 			glLinkProgram				(program.getProgram());
1736 			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
1737 			glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1738 			glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1739 			glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1740 			expectError					(GL_NO_ERROR);
1741 
1742 			m_log << tcu::TestLog::Section("", "GL_INVALID_ENUM is generated if primitiveMode is not one of GL_POINTS, GL_LINES, or GL_TRIANGLES.");
1743 			glBeginTransformFeedback	(-1);
1744 			expectError					(GL_INVALID_ENUM);
1745 			m_log << tcu::TestLog::EndSection;
1746 
1747 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if transform feedback is already active.");
1748 			glBeginTransformFeedback	(GL_TRIANGLES);
1749 			expectError					(GL_NO_ERROR);
1750 			glBeginTransformFeedback	(GL_POINTS);
1751 			expectError					(GL_INVALID_OPERATION);
1752 			m_log << tcu::TestLog::EndSection;
1753 
1754 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if any binding point used in transform feedback mode does not have a buffer object bound.");
1755 			glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
1756 			glBeginTransformFeedback	(GL_TRIANGLES);
1757 			expectError					(GL_INVALID_OPERATION);
1758 			glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1759 			m_log << tcu::TestLog::EndSection;
1760 
1761 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if no binding points would be used because no program object is active.");
1762 			glUseProgram				(0);
1763 			glBeginTransformFeedback	(GL_TRIANGLES);
1764 			expectError					(GL_INVALID_OPERATION);
1765 			glUseProgram				(program.getProgram());
1766 			m_log << tcu::TestLog::EndSection;
1767 
1768 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if no binding points would be used because the active program object has specified no varying variables to record.");
1769 			glTransformFeedbackVaryings	(program.getProgram(), 0, 0, GL_INTERLEAVED_ATTRIBS);
1770 			glBeginTransformFeedback	(GL_TRIANGLES);
1771 			expectError					(GL_INVALID_OPERATION);
1772 			m_log << tcu::TestLog::EndSection;
1773 
1774 			glEndTransformFeedback		();
1775 			glDeleteBuffers				(1, &buf);
1776 			glDeleteTransformFeedbacks	(2, tfID);
1777 			expectError					(GL_NO_ERROR);
1778 		});
1779 	ES3F_ADD_API_CASE(pause_transform_feedback, "Invalid glPauseTransformFeedback() usage",
1780 		{
1781 			GLuint						tfID[2];
1782 			glu::ShaderProgram			program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1783 			deUint32					buf;
1784 			const char* tfVarying		= "gl_Position";
1785 
1786 			glGenBuffers				(1, &buf);
1787 			glGenTransformFeedbacks		(2, tfID);
1788 
1789 			glUseProgram				(program.getProgram());
1790 			glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1791 			glLinkProgram				(program.getProgram());
1792 			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
1793 			glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1794 			glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1795 			glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1796 			expectError					(GL_NO_ERROR);
1797 
1798 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is paused.");
1799 			glPauseTransformFeedback	();
1800 			expectError					(GL_INVALID_OPERATION);
1801 			glBeginTransformFeedback	(GL_TRIANGLES);
1802 			glPauseTransformFeedback	();
1803 			expectError					(GL_NO_ERROR);
1804 			glPauseTransformFeedback	();
1805 			expectError					(GL_INVALID_OPERATION);
1806 			m_log << tcu::TestLog::EndSection;
1807 
1808 			glEndTransformFeedback		();
1809 			glDeleteBuffers				(1, &buf);
1810 			glDeleteTransformFeedbacks	(2, tfID);
1811 			expectError					(GL_NO_ERROR);
1812 		});
1813 	ES3F_ADD_API_CASE(resume_transform_feedback, "Invalid glResumeTransformFeedback() usage",
1814 		{
1815 			GLuint						tfID[2];
1816 			glu::ShaderProgram			program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1817 			deUint32					buf;
1818 			const char* tfVarying		= "gl_Position";
1819 
1820 			glGenBuffers				(1, &buf);
1821 			glGenTransformFeedbacks		(2, tfID);
1822 
1823 			glUseProgram				(program.getProgram());
1824 			glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1825 			glLinkProgram				(program.getProgram());
1826 			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
1827 			glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1828 			glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1829 			glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1830 			expectError					(GL_NO_ERROR);
1831 
1832 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is not paused.");
1833 			glResumeTransformFeedback	();
1834 			expectError					(GL_INVALID_OPERATION);
1835 			glBeginTransformFeedback	(GL_TRIANGLES);
1836 			glResumeTransformFeedback	();
1837 			expectError					(GL_INVALID_OPERATION);
1838 			glPauseTransformFeedback	();
1839 			glResumeTransformFeedback	();
1840 			expectError					(GL_NO_ERROR);
1841 			m_log << tcu::TestLog::EndSection;
1842 
1843 			glEndTransformFeedback		();
1844 			glDeleteBuffers				(1, &buf);
1845 			glDeleteTransformFeedbacks	(2, tfID);
1846 			expectError					(GL_NO_ERROR);
1847 		});
1848 	ES3F_ADD_API_CASE(end_transform_feedback, "Invalid glEndTransformFeedback() usage",
1849 		{
1850 			GLuint						tfID;
1851 			glu::ShaderProgram			program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1852 			deUint32					buf;
1853 			const char* tfVarying		= "gl_Position";
1854 
1855 			glGenBuffers				(1, &buf);
1856 			glGenTransformFeedbacks		(1, &tfID);
1857 
1858 			glUseProgram				(program.getProgram());
1859 			glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1860 			glLinkProgram				(program.getProgram());
1861 			glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
1862 			glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1863 			glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1864 			glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1865 			expectError					(GL_NO_ERROR);
1866 
1867 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION is generated if transform feedback is not active.");
1868 			glEndTransformFeedback		();
1869 			expectError					(GL_INVALID_OPERATION);
1870 			glBeginTransformFeedback	(GL_TRIANGLES);
1871 			glEndTransformFeedback		();
1872 			expectError					(GL_NO_ERROR);
1873 			m_log << tcu::TestLog::EndSection;
1874 
1875 			glDeleteBuffers				(1, &buf);
1876 			glDeleteTransformFeedbacks	(1, &tfID);
1877 			expectError					(GL_NO_ERROR);
1878 		});
1879 	ES3F_ADD_API_CASE(get_transform_feedback_varying, "Invalid glGetTransformFeedbackVarying() usage",
1880 		{
1881 			GLuint					tfID;
1882 			glu::ShaderProgram		program			(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1883 			glu::ShaderProgram		programInvalid	(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
1884 			const char* tfVarying	= "gl_Position";
1885 			int						maxTransformFeedbackVaryings = 0;
1886 
1887 			GLsizei					length;
1888 			GLsizei					size;
1889 			GLenum					type;
1890 			char					name[32];
1891 
1892 			glGenTransformFeedbacks			(1, &tfID);
1893 
1894 			glTransformFeedbackVaryings		(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1895 			expectError						(GL_NO_ERROR);
1896 			glLinkProgram					(program.getProgram());
1897 			expectError						(GL_NO_ERROR);
1898 
1899 			glBindTransformFeedback			(GL_TRANSFORM_FEEDBACK, tfID);
1900 			expectError						(GL_NO_ERROR);
1901 
1902 			m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if program is not the name of a program object.");
1903 			glGetTransformFeedbackVarying	(-1, 0, 32, &length, &size, &type, &name[0]);
1904 			expectError						(GL_INVALID_VALUE);
1905 			m_log << tcu::TestLog::EndSection;
1906 
1907 			m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater or equal to the value of GL_TRANSFORM_FEEDBACK_VARYINGS.");
1908 			glGetProgramiv					(program.getProgram(), GL_TRANSFORM_FEEDBACK_VARYINGS, &maxTransformFeedbackVaryings);
1909 			glGetTransformFeedbackVarying	(program.getProgram(), maxTransformFeedbackVaryings, 32, &length, &size, &type, &name[0]);
1910 			expectError						(GL_INVALID_VALUE);
1911 			m_log << tcu::TestLog::EndSection;
1912 
1913 			m_log << tcu::TestLog::Section("", "GL_INVALID_OPERATION or GL_INVALID_VALUE is generated program has not been linked.");
1914 			glGetTransformFeedbackVarying	(programInvalid.getProgram(), 0, 32, &length, &size, &type, &name[0]);
1915 			expectError						(GL_INVALID_OPERATION, GL_INVALID_VALUE);
1916 			m_log << tcu::TestLog::EndSection;
1917 
1918 			glDeleteTransformFeedbacks		(1, &tfID);
1919 			expectError						(GL_NO_ERROR);
1920 		});
1921 	ES3F_ADD_API_CASE(transform_feedback_varyings, "Invalid glTransformFeedbackVaryings() usage",
1922 		{
1923 			GLuint					tfID;
1924 			glu::ShaderProgram		program(m_context.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1925 			const char* tfVarying	= "gl_Position";
1926 			GLint					maxTransformFeedbackSeparateAttribs = 0;
1927 
1928 			glGenTransformFeedbacks			(1, &tfID);
1929 			expectError						(GL_NO_ERROR);
1930 
1931 			m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if program is not the name of a program object.");
1932 			glTransformFeedbackVaryings		(0, 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1933 			expectError						(GL_INVALID_VALUE);
1934 			m_log << tcu::TestLog::EndSection;
1935 
1936 			m_log << tcu::TestLog::Section("", "GL_INVALID_VALUE is generated if bufferMode is GL_SEPARATE_ATTRIBS and count is greater than GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
1937 			glGetIntegerv					(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTransformFeedbackSeparateAttribs);
1938 			glTransformFeedbackVaryings		(program.getProgram(), maxTransformFeedbackSeparateAttribs+1, &tfVarying, GL_SEPARATE_ATTRIBS);
1939 			expectError						(GL_INVALID_VALUE);
1940 			m_log << tcu::TestLog::EndSection;
1941 
1942 			glDeleteTransformFeedbacks		(1, &tfID);
1943 			expectError						(GL_NO_ERROR);
1944 		});
1945 }
1946 
1947 } // Functional
1948 } // gles3
1949 } // deqp
1950