• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 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 "es31fNegativeShaderApiTests.hpp"
25 
26 #include "deUniquePtr.hpp"
27 
28 #include "glwDefs.hpp"
29 #include "glwEnums.hpp"
30 
31 #include "gluShaderProgram.hpp"
32 #include "gluCallLogWrapper.hpp"
33 
34 #include "gluContextInfo.hpp"
35 #include "gluRenderContext.hpp"
36 
37 
38 namespace deqp
39 {
40 namespace gles31
41 {
42 namespace Functional
43 {
44 namespace NegativeTestShared
45 {
46 using tcu::TestLog;
47 using glu::CallLogWrapper;
48 using namespace glw;
49 
50 static const char* vertexShaderSource		=	"#version 300 es\n"
51 												"void main (void)\n"
52 												"{\n"
53 												"	gl_Position = vec4(0.0);\n"
54 												"}\n\0";
55 
56 static const char* fragmentShaderSource		=	"#version 300 es\n"
57 												"layout(location = 0) out mediump vec4 fragColor;"
58 												"void main (void)\n"
59 												"{\n"
60 												"	fragColor = vec4(0.0);\n"
61 												"}\n\0";
62 
63 static const char* uniformTestVertSource	=	"#version 300 es\n"
64 												"uniform mediump vec4 vec4_v;\n"
65 												"uniform mediump mat4 mat4_v;\n"
66 												"void main (void)\n"
67 												"{\n"
68 												"	gl_Position = mat4_v * vec4_v;\n"
69 												"}\n\0";
70 
71 static const char* uniformTestFragSource	=	"#version 300 es\n"
72 												"uniform mediump ivec4 ivec4_f;\n"
73 												"uniform mediump uvec4 uvec4_f;\n"
74 												"uniform sampler2D sampler_f;\n"
75 												"layout(location = 0) out mediump vec4 fragColor;"
76 												"void main (void)\n"
77 												"{\n"
78 												"	fragColor.xy = (vec4(uvec4_f) + vec4(ivec4_f)).xy;\n"
79 												"	fragColor.zw = texture(sampler_f, vec2(0.0, 0.0)).zw;\n"
80 												"}\n\0";
81 
82 static const char* uniformBlockVertSource	=	"#version 300 es\n"
83 												"layout(shared) uniform Block { lowp float var; };\n"
84 												"void main (void)\n"
85 												"{\n"
86 												"	gl_Position = vec4(var);\n"
87 												"}\n\0";
88 
supportsES32orGL45(NegativeTestContext & ctx)89 static bool supportsES32orGL45(NegativeTestContext& ctx)
90 {
91 	return contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ||
92 		   contextSupports(ctx.getRenderContext().getType(), glu::ApiType::core(4, 5));
93 }
94 
95 // Shader control commands
create_shader(NegativeTestContext & ctx)96 void create_shader (NegativeTestContext& ctx)
97 {
98 	ctx.beginSection("GL_INVALID_ENUM is generated if shaderType is not an accepted value.");
99 	ctx.glCreateShader(-1);
100 	ctx.expectError(GL_INVALID_ENUM);
101 	ctx.endSection();
102 }
103 
shader_source(NegativeTestContext & ctx)104 void shader_source (NegativeTestContext& ctx)
105 {
106 	// make notAShader not a shader id
107 	const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
108 	ctx.glDeleteShader(notAShader);
109 
110 	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
111 	ctx.glShaderSource(notAShader, 0, 0, 0);
112 	ctx.expectError(GL_INVALID_VALUE);
113 	ctx.endSection();
114 
115 	ctx.beginSection("GL_INVALID_VALUE is generated if count is less than 0.");
116 	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
117 	ctx.glShaderSource(shader, -1, 0, 0);
118 	ctx.expectError(GL_INVALID_VALUE);
119 	ctx.endSection();
120 
121 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
122 	GLuint program = ctx.glCreateProgram();
123 	ctx.glShaderSource(program, 0, 0, 0);
124 	ctx.expectError(GL_INVALID_OPERATION);
125 	ctx.endSection();
126 
127 	ctx.glDeleteProgram(program);
128 	ctx.glDeleteShader(shader);
129 }
130 
compile_shader(NegativeTestContext & ctx)131 void compile_shader (NegativeTestContext& ctx)
132 {
133 	const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
134 	ctx.glDeleteShader(notAShader);
135 
136 	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
137 	ctx.glCompileShader(notAShader);
138 	ctx.expectError(GL_INVALID_VALUE);
139 	ctx.endSection();
140 
141 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
142 	GLuint program = ctx.glCreateProgram();
143 	ctx.glCompileShader(program);
144 	ctx.expectError(GL_INVALID_OPERATION);
145 	ctx.endSection();
146 
147 	ctx.glDeleteProgram(program);
148 }
149 
delete_shader(NegativeTestContext & ctx)150 void delete_shader (NegativeTestContext& ctx)
151 {
152 	const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
153 	ctx.glDeleteShader(notAShader);
154 
155 	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
156 	ctx.glDeleteShader(notAShader);
157 	ctx.expectError(GL_INVALID_VALUE);
158 	ctx.endSection();
159 }
160 
shader_binary(NegativeTestContext & ctx)161 void shader_binary (NegativeTestContext& ctx)
162 {
163 	std::vector<deInt32> binaryFormats;
164 	deBool shaderBinarySupported = !binaryFormats.empty();
165 	GLuint shaders[2];
166 	GLuint shaderPair[2];
167 	GLuint nonProgram[2];
168 	GLuint shaderProgram[2];
169 
170 	{
171 		deInt32 numFormats = 0x1234;
172 		ctx.glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &numFormats);
173 
174 		if (numFormats == 0)
175 			ctx.getLog() << TestLog::Message << "// No supported extensions available." << TestLog::EndMessage;
176 		else
177 		{
178 			binaryFormats.resize(numFormats);
179 			ctx.glGetIntegerv(GL_SHADER_BINARY_FORMATS, &binaryFormats[0]);
180 		}
181 	}
182 
183 	if (!shaderBinarySupported)
184 		ctx.getLog() << TestLog::Message << "// Shader binaries not supported." << TestLog::EndMessage;
185 	else
186 		ctx.getLog() << TestLog::Message << "// Shader binaries supported" << TestLog::EndMessage;
187 
188 	shaders[0]			= ctx.glCreateShader(GL_VERTEX_SHADER);
189 	shaders[1]			= ctx.glCreateShader(GL_VERTEX_SHADER);
190 	shaderPair[0]		= ctx.glCreateShader(GL_VERTEX_SHADER);
191 	shaderPair[1]		= ctx.glCreateShader(GL_FRAGMENT_SHADER);
192 	nonProgram[0]		= -1;
193 	nonProgram[1]		= -1;
194 	shaderProgram[0]	= ctx.glCreateShader(GL_VERTEX_SHADER);
195 	shaderProgram[1]	= ctx.glCreateProgram();
196 
197 	ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not an accepted value.");
198 	ctx.glShaderBinary(1, &shaders[0], -1, 0, 0);
199 	ctx.expectError(GL_INVALID_ENUM);
200 	ctx.endSection();
201 
202 	if (shaderBinarySupported)
203 	{
204 		ctx.beginSection("GL_INVALID_VALUE is generated if the data pointed to by binary does not match the format specified by binaryFormat.");
205 		const GLbyte data = 0x005F;
206 		ctx.glShaderBinary(1, &shaders[0], binaryFormats[0], &data, 1);
207 		ctx.expectError(GL_INVALID_VALUE);
208 		ctx.endSection();
209 
210 		ctx.beginSection("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.");
211 		ctx.glShaderBinary(2, &shaders[0], binaryFormats[0], 0, 0);
212 		ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE);
213 		ctx.endSection();
214 
215 		ctx.beginSection("GL_INVALID_VALUE is generated if count or length is negative.");
216 		ctx.glShaderBinary(2, &shaderPair[0], binaryFormats[0], 0, -1);
217 		ctx.expectError(GL_INVALID_VALUE);
218 		ctx.glShaderBinary(-1, &shaderPair[0], binaryFormats[0], 0, 0);
219 		ctx.expectError(GL_INVALID_VALUE);
220 		ctx.endSection();
221 
222 		ctx.beginSection("GL_INVALID_VALUE is generated if shaders contains anything other than shader or program objects.");
223 		ctx.glShaderBinary(2, &nonProgram[0], binaryFormats[0], 0, 0);
224 		ctx.expectError(GL_INVALID_VALUE);
225 		ctx.endSection();
226 
227 		ctx.beginSection("GL_INVALID_OPERATION is generated if shaders refers to a program object.");
228 		ctx.glShaderBinary(2, &shaderProgram[0], binaryFormats[0], 0, 0);
229 		ctx.expectError(GL_INVALID_OPERATION);
230 		ctx.endSection();
231 	}
232 
233 	ctx.glDeleteShader(shaders[0]);
234 	ctx.glDeleteShader(shaders[1]);
235 }
236 
attach_shader(NegativeTestContext & ctx)237 void attach_shader (NegativeTestContext& ctx)
238 {
239 	GLuint shader1 = ctx.glCreateShader(GL_VERTEX_SHADER);
240 	GLuint shader2 = ctx.glCreateShader(GL_VERTEX_SHADER);
241 	GLuint program = ctx.glCreateProgram();
242 
243 	const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
244 	const GLuint notAProgram = ctx.glCreateProgram();
245 
246 	ctx.glDeleteShader(notAShader);
247 	ctx.glDeleteProgram(notAProgram);
248 
249 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
250 	ctx.glAttachShader(shader1, shader1);
251 	ctx.expectError(GL_INVALID_OPERATION);
252 	ctx.endSection();
253 
254 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
255 	ctx.glAttachShader(program, program);
256 	ctx.expectError(GL_INVALID_OPERATION);
257 	ctx.glAttachShader(shader1, program);
258 	ctx.expectError(GL_INVALID_OPERATION);
259 	ctx.endSection();
260 
261 	ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
262 	ctx.glAttachShader(program, notAShader);
263 	ctx.expectError(GL_INVALID_VALUE);
264 	ctx.glAttachShader(notAProgram, shader1);
265 	ctx.expectError(GL_INVALID_VALUE);
266 	ctx.glAttachShader(notAProgram, notAShader);
267 	ctx.expectError(GL_INVALID_VALUE);
268 	ctx.endSection();
269 
270 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is already attached to program.");
271 	ctx.glAttachShader(program, shader1);
272 	ctx.expectError(GL_NO_ERROR);
273 	ctx.glAttachShader(program, shader1);
274 	ctx.expectError(GL_INVALID_OPERATION);
275 	ctx.endSection();
276 
277 	if (glu::isContextTypeES(ctx.getRenderContext().getType()))
278 	{
279 		ctx.beginSection("GL_INVALID_OPERATION is generated if a shader of the same type as shader is already attached to program.");
280 		ctx.glAttachShader(program, shader2);
281 		ctx.expectError(GL_INVALID_OPERATION);
282 		ctx.endSection();
283 	}
284 
285 	ctx.glDeleteProgram(program);
286 	ctx.glDeleteShader(shader1);
287 	ctx.glDeleteShader(shader2);
288 }
289 
detach_shader(NegativeTestContext & ctx)290 void detach_shader (NegativeTestContext& ctx)
291 {
292 	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
293 	GLuint program = ctx.glCreateProgram();
294 
295 	const GLuint notAShader = ctx.glCreateShader(GL_VERTEX_SHADER);
296 	const GLuint notAProgram = ctx.glCreateProgram();
297 
298 	ctx.glDeleteShader(notAShader);
299 	ctx.glDeleteProgram(notAProgram);
300 
301 	ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL.");
302 	ctx.glDetachShader(notAProgram, shader);
303 	ctx.expectError(GL_INVALID_VALUE);
304 	ctx.glDetachShader(program, notAShader);
305 	ctx.expectError(GL_INVALID_VALUE);
306 	ctx.glDetachShader(notAProgram, notAShader);
307 	ctx.expectError(GL_INVALID_VALUE);
308 	ctx.endSection();
309 
310 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
311 	ctx.glDetachShader(shader, shader);
312 	ctx.expectError(GL_INVALID_OPERATION);
313 	ctx.endSection();
314 
315 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
316 	ctx.glDetachShader(program, program);
317 	ctx.expectError(GL_INVALID_OPERATION);
318 	ctx.glDetachShader(shader, program);
319 	ctx.expectError(GL_INVALID_OPERATION);
320 	ctx.endSection();
321 
322 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not attached to program.");
323 	ctx.glDetachShader(program, shader);
324 	ctx.expectError(GL_INVALID_OPERATION);
325 	ctx.endSection();
326 
327 	ctx.glDeleteProgram(program);
328 	ctx.glDeleteShader(shader);
329 }
330 
link_program(NegativeTestContext & ctx)331 void link_program (NegativeTestContext& ctx)
332 {
333 	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
334 
335 	const GLuint notAProgram = ctx.glCreateProgram();
336 	ctx.glDeleteProgram(notAProgram);
337 
338 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
339 	ctx.glLinkProgram(notAProgram);
340 	ctx.expectError(GL_INVALID_VALUE);
341 	ctx.endSection();
342 
343 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
344 	ctx.glLinkProgram(shader);
345 	ctx.expectError(GL_INVALID_OPERATION);
346 	ctx.endSection();
347 
348 	ctx.glDeleteShader(shader);
349 
350 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active.");
351 	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
352 	deUint32					buf = 0x1234;
353 	deUint32					tfID = 0x1234;
354 	const char* tfVarying		= "gl_Position";
355 
356 	ctx.glGenTransformFeedbacks		(1, &tfID);
357 	ctx.glGenBuffers				(1, &buf);
358 
359 	ctx.glUseProgram				(program.getProgram());
360 	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
361 	ctx.glLinkProgram				(program.getProgram());
362 	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
363 	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
364 	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
365 	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
366 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
367 	ctx.expectError					(GL_NO_ERROR);
368 
369 	ctx.glLinkProgram				(program.getProgram());
370 	ctx.expectError				(GL_INVALID_OPERATION);
371 
372 	ctx.glEndTransformFeedback		();
373 	ctx.glDeleteTransformFeedbacks	(1, &tfID);
374 	ctx.glDeleteBuffers				(1, &buf);
375 	ctx.expectError				(GL_NO_ERROR);
376 	ctx.endSection();
377 }
378 
use_program(NegativeTestContext & ctx)379 void use_program (NegativeTestContext& ctx)
380 {
381 	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
382 
383 	const GLuint notAProgram = ctx.glCreateProgram();
384 	ctx.glDeleteProgram(notAProgram);
385 
386 	ctx.beginSection("GL_INVALID_VALUE is generated if program is neither 0 nor a value generated by OpenGL.");
387 	ctx.glUseProgram(notAProgram);
388 	ctx.expectError(GL_INVALID_VALUE);
389 	ctx.endSection();
390 
391 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
392 	ctx.glUseProgram(shader);
393 	ctx.expectError(GL_INVALID_OPERATION);
394 	ctx.endSection();
395 
396 	ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback mode is active and not paused.");
397 	glu::ShaderProgram			program1(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
398 	glu::ShaderProgram			program2(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
399 	deUint32					buf = 0x1234;
400 	deUint32					tfID = 0x1234;
401 	const char* tfVarying		= "gl_Position";
402 
403 	ctx.glGenTransformFeedbacks		(1, &tfID);
404 	ctx.glGenBuffers				(1, &buf);
405 
406 	ctx.glUseProgram				(program1.getProgram());
407 	ctx.glTransformFeedbackVaryings	(program1.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
408 	ctx.glLinkProgram				(program1.getProgram());
409 	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
410 	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
411 	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
412 	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
413 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
414 	ctx.expectError					(GL_NO_ERROR);
415 
416 	ctx.glUseProgram				(program2.getProgram());
417 	ctx.expectError				(GL_INVALID_OPERATION);
418 
419 	ctx.glPauseTransformFeedback	();
420 	ctx.glUseProgram				(program2.getProgram());
421 	ctx.expectError				(GL_NO_ERROR);
422 
423 	ctx.glEndTransformFeedback		();
424 	ctx.glDeleteTransformFeedbacks	(1, &tfID);
425 	ctx.glDeleteBuffers				(1, &buf);
426 	ctx.expectError				(GL_NO_ERROR);
427 	ctx.endSection();
428 
429 	ctx.glUseProgram(0);
430 	ctx.glDeleteShader(shader);
431 }
432 
delete_program(NegativeTestContext & ctx)433 void delete_program (NegativeTestContext& ctx)
434 {
435 	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
436 
437 	const GLuint notAProgram = ctx.glCreateProgram();
438 	ctx.glDeleteProgram(notAProgram);
439 
440 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
441 	ctx.glDeleteProgram(notAProgram);
442 	ctx.expectError(GL_INVALID_VALUE);
443 	ctx.endSection();
444 
445 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not zero and is the name of a shader object.");
446 	ctx.glDeleteProgram(shader);
447 	ctx.expectError(GL_INVALID_OPERATION);
448 	ctx.endSection();
449 
450 	ctx.glDeleteShader(shader);
451 }
452 
validate_program(NegativeTestContext & ctx)453 void validate_program (NegativeTestContext& ctx)
454 {
455 	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
456 
457 	const GLuint notAProgram = ctx.glCreateProgram();
458 	ctx.glDeleteProgram(notAProgram);
459 
460 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
461 	ctx.glValidateProgram(notAProgram);
462 	ctx.expectError(GL_INVALID_VALUE);
463 	ctx.endSection();
464 
465 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
466 	ctx.glValidateProgram(shader);
467 	ctx.expectError(GL_INVALID_OPERATION);
468 	ctx.endSection();
469 
470 	ctx.glDeleteShader(shader);
471 }
472 
get_program_binary(NegativeTestContext & ctx)473 void get_program_binary (NegativeTestContext& ctx)
474 {
475 	glu::ShaderProgram				program			(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
476 	glu::ShaderProgram				programInvalid	(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
477 	GLenum							binaryFormat	= -1;
478 	GLsizei							binaryLength	= -1;
479 	GLint							binaryPtr		= -1;
480 	GLint							bufSize			= -1;
481 	GLint							linkStatus		= -1;
482 
483 	ctx.beginSection("GL_INVALID_OPERATION is generated if bufSize is less than the size of GL_PROGRAM_BINARY_LENGTH for program.");
484 	ctx.glGetProgramiv		(program.getProgram(), GL_PROGRAM_BINARY_LENGTH,	&bufSize);
485 	ctx.expectError		(GL_NO_ERROR);
486 	ctx.glGetProgramiv		(program.getProgram(), GL_LINK_STATUS,				&linkStatus);
487 	ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
488 	ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
489 	ctx.expectError		(GL_NO_ERROR);
490 
491 	ctx.glGetProgramBinary	(program.getProgram(), 0, &binaryLength, &binaryFormat, &binaryPtr);
492 	ctx.expectError		(GL_INVALID_OPERATION);
493 	if (bufSize > 0)
494 	{
495 		ctx.glGetProgramBinary	(program.getProgram(), bufSize-1, &binaryLength, &binaryFormat, &binaryPtr);
496 		ctx.expectError		(GL_INVALID_OPERATION);
497 	}
498 	ctx.endSection();
499 
500 	ctx.beginSection("GL_INVALID_OPERATION is generated if GL_LINK_STATUS for the program object is false.");
501 	ctx.glGetProgramiv		(programInvalid.getProgram(), GL_PROGRAM_BINARY_LENGTH,	&bufSize);
502 	ctx.expectError		(GL_NO_ERROR);
503 	ctx.glGetProgramiv		(programInvalid.getProgram(), GL_LINK_STATUS,			&linkStatus);
504 	ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
505 	ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
506 	ctx.expectError		(GL_NO_ERROR);
507 
508 	if (!linkStatus)
509 	{
510 		ctx.glGetProgramBinary	(programInvalid.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryPtr);
511 		ctx.expectError		(GL_INVALID_OPERATION);
512 		ctx.endSection();
513 	}
514 	else
515 	{
516 		if (isContextTypeES(ctx.getRenderContext().getType()))
517 			ctx.fail("Program should not have linked");
518 	}
519 }
520 
program_binary(NegativeTestContext & ctx)521 void program_binary (NegativeTestContext& ctx)
522 {
523 	glu::ShaderProgram		srcProgram		(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
524 	GLuint					dstProgram		= ctx.glCreateProgram();
525 	GLuint					unusedShader		= ctx.glCreateShader(GL_VERTEX_SHADER);
526 	GLenum					binaryFormat	= -1;
527 	GLsizei					binaryLength	= -1;
528 	std::vector<deUint8>	binaryBuf;
529 	GLint					bufSize			= -1;
530 	GLint					linkStatus		= -1;
531 
532 	ctx.glGetProgramiv		(srcProgram.getProgram(), GL_PROGRAM_BINARY_LENGTH,	&bufSize);
533 	ctx.glGetProgramiv		(srcProgram.getProgram(), GL_LINK_STATUS,			&linkStatus);
534 	ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage;
535 	ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage;
536 
537 	TCU_CHECK(bufSize >= 0);
538 	if (bufSize > 0)
539 	{
540 		binaryBuf.resize(bufSize);
541 		ctx.glGetProgramBinary	(srcProgram.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryBuf[0]);
542 		ctx.expectError			(GL_NO_ERROR);
543 
544 		ctx.beginSection("GL_INVALID_OPERATION is generated if program is not the name of an existing program object.");
545 		ctx.glProgramBinary		(unusedShader, binaryFormat, &binaryBuf[0], binaryLength);
546 		ctx.expectError			(GL_INVALID_OPERATION);
547 		ctx.endSection();
548 
549 		ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not a value recognized by the implementation.");
550 		ctx.glProgramBinary		(dstProgram, -1, &binaryBuf[0], binaryLength);
551 		ctx.expectError			(GL_INVALID_ENUM);
552 		ctx.endSection();
553 	}
554 
555 	ctx.glDeleteShader(unusedShader);
556 	ctx.glDeleteProgram(dstProgram);
557 }
558 
program_parameteri(NegativeTestContext & ctx)559 void program_parameteri (NegativeTestContext& ctx)
560 {
561 	GLuint program	= ctx.glCreateProgram();
562 	GLuint shader	= ctx.glCreateShader(GL_VERTEX_SHADER);
563 
564 	const GLuint notAProgram = ctx.glCreateProgram();
565 	ctx.glDeleteProgram(notAProgram);
566 
567 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of an existing program object.");
568 	ctx.glProgramParameteri(notAProgram, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
569 	ctx.expectError(GL_INVALID_VALUE);
570 	ctx.endSection();
571 
572 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
573 	ctx.glProgramParameteri(shader, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE);
574 	ctx.expectError(GL_INVALID_OPERATION);
575 	ctx.endSection();
576 
577 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_PROGRAM_BINARY_RETRIEVABLE_HINT or PROGRAM_SEPARABLE.");
578 	ctx.glProgramParameteri(program, -1, GL_TRUE);
579 	ctx.expectError(GL_INVALID_ENUM);
580 	ctx.endSection();
581 
582 	ctx.beginSection("GL_INVALID_VALUE is generated if value is not GL_FALSE or GL_TRUE.");
583 	ctx.glProgramParameteri(program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, 2);
584 	ctx.expectError(GL_INVALID_VALUE);
585 	ctx.endSection();
586 
587 	ctx.glDeleteProgram(program);
588 	ctx.glDeleteShader(shader);
589 }
590 
gen_samplers(NegativeTestContext & ctx)591 void gen_samplers (NegativeTestContext& ctx)
592 {
593 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
594 	GLuint sampler = 0;
595 	ctx.glGenSamplers	(-1, &sampler);
596 	ctx.expectError	(GL_INVALID_VALUE);
597 	ctx.endSection();
598 }
599 
bind_sampler(NegativeTestContext & ctx)600 void bind_sampler (NegativeTestContext& ctx)
601 {
602 	int				maxTexImageUnits = 0x1234;
603 	GLuint			sampler = 0;
604 	ctx.glGetIntegerv	(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTexImageUnits);
605 	ctx.glGenSamplers	(1, &sampler);
606 
607 	ctx.beginSection("GL_INVALID_VALUE is generated if unit is greater than or equal to the value of GL_MAX_COMBIED_TEXTURE_IMAGE_UNITS.");
608 	ctx.glBindSampler	(maxTexImageUnits, sampler);
609 	ctx.expectError	(GL_INVALID_VALUE);
610 	ctx.endSection();
611 
612 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not zero or a name previously returned from a call to ctx.glGenSamplers.");
613 	ctx.glBindSampler	(1, -1);
614 	ctx.expectError	(GL_INVALID_OPERATION);
615 	ctx.endSection();
616 
617 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler has been deleted by a call to ctx.glDeleteSamplers.");
618 	ctx.glDeleteSamplers(1, &sampler);
619 	ctx.glBindSampler	(1, sampler);
620 	ctx.expectError	(GL_INVALID_OPERATION);
621 	ctx.endSection();
622 }
623 
delete_samplers(NegativeTestContext & ctx)624 void delete_samplers (NegativeTestContext& ctx)
625 {
626 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
627 	ctx.glDeleteSamplers(-1, 0);
628 	ctx.expectError	(GL_INVALID_VALUE);
629 	ctx.endSection();
630 }
631 
get_sampler_parameteriv(NegativeTestContext & ctx)632 void get_sampler_parameteriv (NegativeTestContext& ctx)
633 {
634 	int				params = 0x1234;
635 	GLuint			sampler = 0;
636 	ctx.glGenSamplers	(1, &sampler);
637 
638 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
639 	ctx.glGetSamplerParameteriv	(-1, GL_TEXTURE_MAG_FILTER, &params);
640 	ctx.expectError			(GL_INVALID_OPERATION);
641 	ctx.endSection();
642 
643 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
644 	ctx.glGetSamplerParameteriv	(sampler, -1, &params);
645 	ctx.expectError			(GL_INVALID_ENUM);
646 	ctx.endSection();
647 
648 	ctx.glDeleteSamplers(1, &sampler);
649 }
650 
get_sampler_parameterfv(NegativeTestContext & ctx)651 void get_sampler_parameterfv (NegativeTestContext& ctx)
652 {
653 	float				params	= 0.0f;
654 	GLuint				sampler = 0;
655 	ctx.glGenSamplers	(1, &sampler);
656 
657 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
658 	ctx.glGetSamplerParameterfv	(-1, GL_TEXTURE_MAG_FILTER, &params);
659 	ctx.expectError			(GL_INVALID_OPERATION);
660 	ctx.endSection();
661 
662 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
663 	ctx.glGetSamplerParameterfv	(sampler, -1, &params);
664 	ctx.expectError			(GL_INVALID_ENUM);
665 	ctx.endSection();
666 
667 	ctx.glDeleteSamplers(1, &sampler);
668 }
669 
get_sampler_parameterIiv(NegativeTestContext & ctx)670 void get_sampler_parameterIiv (NegativeTestContext& ctx)
671 {
672 	if (!supportsES32orGL45(ctx))
673 		throw tcu::NotSupportedError("glGetSamplerParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
674 
675 	GLuint	sampler			= 0x1234;
676 	GLint	borderColor[]	= { 0x1234, 0x4123, 0x3412, 0x2341 };
677 
678 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
679 	ctx.glGetSamplerParameterIiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor[0]);
680 	ctx.expectError(GL_INVALID_OPERATION);
681 	ctx.endSection();
682 
683 	ctx.glGenSamplers(1, &sampler);
684 
685 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
686 	ctx.glGetSamplerParameterIiv(sampler, -1, &borderColor[0]);
687 	ctx.expectError(GL_INVALID_ENUM);
688 	ctx.endSection();
689 
690 	ctx.glDeleteSamplers(1, &sampler);
691 }
692 
get_sampler_parameterIuiv(NegativeTestContext & ctx)693 void get_sampler_parameterIuiv (NegativeTestContext& ctx)
694 {
695 	if (!supportsES32orGL45(ctx))
696 		throw tcu::NotSupportedError("glGetSamplerParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
697 
698 	GLuint	sampler			= 0x1234;
699 	GLuint	borderColor[]	= { 0x1234, 0x4123, 0x3412, 0x2341 };
700 
701 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers.");
702 	ctx.glGetSamplerParameterIuiv(sampler, GL_TEXTURE_BORDER_COLOR, &borderColor[0]);
703 	ctx.expectError(GL_INVALID_OPERATION);
704 	ctx.endSection();
705 
706 	ctx.glGenSamplers(1, &sampler);
707 
708 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
709 	ctx.glGetSamplerParameterIuiv(sampler, -1, &borderColor[0]);
710 	ctx.expectError(GL_INVALID_ENUM);
711 	ctx.endSection();
712 
713 	ctx.glDeleteSamplers(1, &sampler);
714 }
715 
sampler_parameteri(NegativeTestContext & ctx)716 void sampler_parameteri (NegativeTestContext& ctx)
717 {
718 	GLuint sampler = 0;
719 
720 	ctx.glGenSamplers(1, &sampler);
721 
722 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
723 	ctx.glSamplerParameteri(-1, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
724 	ctx.expectError(GL_INVALID_OPERATION);
725 	ctx.endSection();
726 
727 	ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
728 	ctx.glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, -1);
729 	ctx.expectError(GL_INVALID_ENUM);
730 	ctx.endSection();
731 
732 	if (supportsES32orGL45(ctx))
733 	{
734 		ctx.beginSection("GL_INVALID_ENUM is generated if glSamplerParameteri is called for a non-scalar parameter.");
735 		ctx.glSamplerParameteri(sampler, GL_TEXTURE_BORDER_COLOR, 0);
736 		ctx.expectError(GL_INVALID_ENUM);
737 		ctx.endSection();
738 	}
739 
740 	ctx.glDeleteSamplers(1, &sampler);
741 }
742 
sampler_parameteriv(NegativeTestContext & ctx)743 void sampler_parameteriv (NegativeTestContext& ctx)
744 {
745 	int				params = 0x1234;
746 	GLuint			sampler = 0;
747 	ctx.glGenSamplers	(1, &sampler);
748 
749 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
750 	params = GL_CLAMP_TO_EDGE;
751 	ctx.glSamplerParameteriv	(-1, GL_TEXTURE_WRAP_S, &params);
752 	ctx.expectError			(GL_INVALID_OPERATION);
753 	ctx.endSection();
754 
755 	ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
756 	params = -1;
757 	ctx.glSamplerParameteriv	(sampler, GL_TEXTURE_WRAP_S, &params);
758 	ctx.expectError			(GL_INVALID_ENUM);
759 	ctx.endSection();
760 
761 	ctx.glDeleteSamplers(1, &sampler);
762 }
763 
sampler_parameterf(NegativeTestContext & ctx)764 void sampler_parameterf (NegativeTestContext& ctx)
765 {
766 	GLuint sampler = 0;
767 
768 	ctx.glGenSamplers(1, &sampler);
769 
770 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
771 	ctx.glSamplerParameterf(-1, GL_TEXTURE_MIN_LOD, -1000.0f);
772 	ctx.expectError(GL_INVALID_OPERATION);
773 	ctx.endSection();
774 
775 	ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
776 	ctx.glSamplerParameterf(sampler, GL_TEXTURE_WRAP_S, -1.0f);
777 	ctx.expectError(GL_INVALID_ENUM);
778 	ctx.endSection();
779 
780 	if (supportsES32orGL45(ctx))
781 	{
782 		ctx.beginSection("GL_INVALID_ENUM is generated if glSamplerParameterf is called for a non-scalar parameter.");
783 		ctx.glSamplerParameteri(sampler, GL_TEXTURE_BORDER_COLOR, 0);
784 		ctx.expectError(GL_INVALID_ENUM);
785 		ctx.endSection();
786 	}
787 
788 	ctx.glDeleteSamplers(1, &sampler);
789 }
790 
sampler_parameterfv(NegativeTestContext & ctx)791 void sampler_parameterfv (NegativeTestContext& ctx)
792 {
793 	float			params;
794 	GLuint			sampler = 0;
795 	ctx.glGenSamplers	(1, &sampler);
796 
797 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
798 	params = -1000.0f;
799 	ctx.glSamplerParameterfv	(-1, GL_TEXTURE_WRAP_S, &params);
800 	ctx.expectError			(GL_INVALID_OPERATION);
801 	ctx.endSection();
802 
803 	ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not.");
804 	params = -1.0f;
805 	ctx.glSamplerParameterfv	(sampler, GL_TEXTURE_WRAP_S, &params);
806 	ctx.expectError			(GL_INVALID_ENUM);
807 	ctx.endSection();
808 
809 	ctx.glDeleteSamplers(1, &sampler);
810 }
811 
sampler_parameterIiv(NegativeTestContext & ctx)812 void sampler_parameterIiv (NegativeTestContext& ctx)
813 {
814 	if (!supportsES32orGL45(ctx))
815 		throw tcu::NotSupportedError("glSamplerParameterIiv is not supported.", DE_NULL, __FILE__, __LINE__);
816 
817 	GLuint	sampler;
818 	GLint	color[]	= {0, 0, 0, 0};
819 
820 	ctx.glGenSamplers(1, &sampler);
821 
822 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
823 	ctx.glSamplerParameterIiv(-1, GL_TEXTURE_BORDER_COLOR, color);
824 	ctx.expectError(GL_INVALID_OPERATION);
825 	ctx.endSection();
826 
827 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted sampler state name.");
828 	ctx.glSamplerParameterIiv(sampler, -1, color);
829 	ctx.expectError(GL_INVALID_ENUM);
830 	ctx.endSection();
831 }
832 
sampler_parameterIuiv(NegativeTestContext & ctx)833 void sampler_parameterIuiv (NegativeTestContext& ctx)
834 {
835 	if (!supportsES32orGL45(ctx))
836 		throw tcu::NotSupportedError("glSamplerParameterIuiv is not supported.", DE_NULL, __FILE__, __LINE__);
837 
838 	GLuint	sampler;
839 	GLuint	color[]	= {0, 0, 0, 0};
840 
841 	ctx.glGenSamplers(1, &sampler);
842 
843 	ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers.");
844 	ctx.glSamplerParameterIuiv(-1, GL_TEXTURE_BORDER_COLOR, color);
845 	ctx.expectError(GL_INVALID_OPERATION);
846 	ctx.endSection();
847 
848 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted sampler state name.");
849 	ctx.glSamplerParameterIuiv(sampler, -1, color);
850 	ctx.expectError(GL_INVALID_ENUM);
851 	ctx.endSection();
852 }
853 
854 // Shader data commands
855 
get_attrib_location(NegativeTestContext & ctx)856 void get_attrib_location (NegativeTestContext& ctx)
857 {
858 	GLuint programEmpty		= ctx.glCreateProgram();
859 	GLuint shader			= ctx.glCreateShader(GL_VERTEX_SHADER);
860 
861 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
862 
863 	const GLuint notAProgram = ctx.glCreateProgram();
864 	ctx.glDeleteProgram(notAProgram);
865 
866 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
867 	ctx.glBindAttribLocation		(programEmpty, 0, "test");
868 	ctx.glGetAttribLocation			(programEmpty, "test");
869 	ctx.expectError				(GL_INVALID_OPERATION);
870 	ctx.endSection();
871 
872 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a program or shader object.");
873 	ctx.glUseProgram				(program.getProgram());
874 	ctx.glBindAttribLocation		(program.getProgram(), 0, "test");
875 	ctx.expectError				(GL_NO_ERROR);
876 	ctx.glGetAttribLocation			(program.getProgram(), "test");
877 	ctx.expectError				(GL_NO_ERROR);
878 	ctx.glGetAttribLocation			(notAProgram, "test");
879 	ctx.expectError				(GL_INVALID_VALUE);
880 	ctx.endSection();
881 
882 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
883 	ctx.glGetAttribLocation			(shader, "test");
884 	ctx.expectError				(GL_INVALID_OPERATION);
885 	ctx.endSection();
886 
887 	ctx.glUseProgram				(0);
888 	ctx.glDeleteShader				(shader);
889 	ctx.glDeleteProgram				(programEmpty);
890 }
891 
get_uniform_location(NegativeTestContext & ctx)892 void get_uniform_location (NegativeTestContext& ctx)
893 {
894 	GLuint programEmpty = ctx.glCreateProgram();
895 	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
896 
897 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
898 
899 	const GLuint notAProgram = ctx.glCreateProgram();
900 	ctx.glDeleteProgram(notAProgram);
901 
902 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
903 	ctx.glGetUniformLocation(programEmpty, "test");
904 	ctx.expectError(GL_INVALID_OPERATION);
905 	ctx.endSection();
906 
907 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
908 	ctx.glUseProgram(program.getProgram());
909 	ctx.glGetUniformLocation(notAProgram, "test");
910 	ctx.expectError(GL_INVALID_VALUE);
911 	ctx.endSection();
912 
913 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
914 	ctx.glGetAttribLocation(shader, "test");
915 	ctx.expectError(GL_INVALID_OPERATION);
916 	ctx.endSection();
917 
918 	ctx.glUseProgram(0);
919 	ctx.glDeleteProgram(programEmpty);
920 	ctx.glDeleteShader(shader);
921 }
922 
bind_attrib_location(NegativeTestContext & ctx)923 void bind_attrib_location (NegativeTestContext& ctx)
924 {
925 	GLuint program = ctx.glCreateProgram();
926 	GLuint maxIndex = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
927 	GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
928 
929 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
930 	ctx.glBindAttribLocation(program, maxIndex, "test");
931 	ctx.expectError(GL_INVALID_VALUE);
932 	ctx.endSection();
933 
934 	ctx.beginSection("GL_INVALID_OPERATION is generated if name starts with the reserved prefix \"gl_\".");
935 	ctx.glBindAttribLocation(program, maxIndex-1, "gl_test");
936 	ctx.expectError(GL_INVALID_OPERATION);
937 	ctx.endSection();
938 
939 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
940 	ctx.glBindAttribLocation(-1, maxIndex-1, "test");
941 	ctx.expectError(GL_INVALID_VALUE);
942 	ctx.endSection();
943 
944 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
945 	ctx.glBindAttribLocation(shader, maxIndex-1, "test");
946 	ctx.expectError(GL_INVALID_OPERATION);
947 	ctx.endSection();
948 
949 	ctx.glDeleteProgram(program);
950 	ctx.glDeleteShader(shader);
951 }
952 
uniform_block_binding(NegativeTestContext & ctx)953 void uniform_block_binding (NegativeTestContext& ctx)
954 {
955 	GLint				maxUniformBufferBindings	= -1;
956 	GLint				numActiveUniforms			= -1;
957 	GLint				numActiveBlocks				= -1;
958 	GLuint				shader						= -1;
959 	glu::ShaderProgram	program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformBlockVertSource, uniformTestFragSource));
960 
961 	shader = ctx.glCreateShader(GL_VERTEX_SHADER);
962 	ctx.glUseProgram(program.getProgram());
963 
964 	ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
965 	ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
966 	ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
967 	ctx.getLog() << TestLog::Message << "// GL_MAX_UNIFORM_BUFFER_BINDINGS = " << maxUniformBufferBindings << TestLog::EndMessage;
968 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = "				<< numActiveUniforms		<< TestLog::EndMessage;
969 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = "		<< numActiveBlocks			<< TestLog::EndMessage;
970 	ctx.expectError	(GL_NO_ERROR);
971 
972 	ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockIndex is not an active uniform block index of program.");
973 	ctx.glUniformBlockBinding(program.getProgram(), -1, 0);
974 	ctx.expectError(GL_INVALID_VALUE);
975 	ctx.glUniformBlockBinding(program.getProgram(), 5, 0);
976 	ctx.expectError(GL_INVALID_VALUE);
977 	ctx.endSection();
978 
979 	ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockBinding is greater than or equal to the value of GL_MAX_UNIFORM_BUFFER_BINDINGS.");
980 	ctx.glUniformBlockBinding(program.getProgram(), maxUniformBufferBindings, 0);
981 	ctx.expectError(GL_INVALID_VALUE);
982 	ctx.endSection();
983 
984 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object generated by the GL.");
985 	ctx.glUniformBlockBinding(-1, 0, 0);
986 	ctx.expectError(GL_INVALID_VALUE);
987 	ctx.endSection();
988 
989 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
990 	ctx.glUniformBlockBinding(shader, 0, 0);
991 	ctx.expectError(GL_INVALID_OPERATION);
992 	ctx.endSection();
993 
994 	ctx.glDeleteShader(shader);
995 }
996 
997 // ctx.glUniform*f
998 
uniformf_invalid_program(NegativeTestContext & ctx)999 void uniformf_invalid_program (NegativeTestContext& ctx)
1000 {
1001 	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1002 	ctx.glUseProgram(0);
1003 	ctx.glUniform1f(-1, 0.0f);
1004 	ctx.expectError(GL_INVALID_OPERATION);
1005 	ctx.glUniform2f(-1, 0.0f, 0.0f);
1006 	ctx.expectError(GL_INVALID_OPERATION);
1007 	ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f);
1008 	ctx.expectError(GL_INVALID_OPERATION);
1009 	ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
1010 	ctx.expectError(GL_INVALID_OPERATION);
1011 	ctx.endSection();
1012 }
1013 
uniformf_incompatible_type(NegativeTestContext & ctx)1014 void uniformf_incompatible_type (NegativeTestContext& ctx)
1015 {
1016 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1017 
1018 	ctx.glUseProgram(program.getProgram());
1019 	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1020 	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
1021 	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
1022 	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1023 	ctx.expectError(GL_NO_ERROR);
1024 
1025 	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1026 	{
1027 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1028 		ctx.fail("Failed to retrieve uniform location");
1029 	}
1030 
1031 	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1032 	ctx.glUseProgram(program.getProgram());
1033 	ctx.glUniform1f(vec4_v, 0.0f);
1034 	ctx.expectError(GL_INVALID_OPERATION);
1035 	ctx.glUniform2f(vec4_v, 0.0f, 0.0f);
1036 	ctx.expectError(GL_INVALID_OPERATION);
1037 	ctx.glUniform3f(vec4_v, 0.0f, 0.0f, 0.0f);
1038 	ctx.expectError(GL_INVALID_OPERATION);
1039 	ctx.glUniform4f(vec4_v, 0.0f, 0.0f, 0.0f, 0.0f);
1040 	ctx.expectError(GL_NO_ERROR);
1041 	ctx.endSection();
1042 
1043 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}f is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4.");
1044 	ctx.glUseProgram(program.getProgram());
1045 	ctx.glUniform4f(ivec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
1046 	ctx.expectError(GL_INVALID_OPERATION);
1047 	ctx.glUniform4f(uvec4_f, 0.0f, 0.0f, 0.0f, 0.0f);
1048 	ctx.expectError(GL_INVALID_OPERATION);
1049 	ctx.endSection();
1050 
1051 	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1052 	ctx.glUseProgram(program.getProgram());
1053 	ctx.glUniform1f(sampler_f, 0.0f);
1054 	ctx.expectError(GL_INVALID_OPERATION);
1055 	ctx.endSection();
1056 
1057 	ctx.glUseProgram(0);
1058 }
1059 
uniformf_invalid_location(NegativeTestContext & ctx)1060 void uniformf_invalid_location (NegativeTestContext& ctx)
1061 {
1062 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1063 
1064 	ctx.glUseProgram(program.getProgram());
1065 	ctx.expectError(GL_NO_ERROR);
1066 
1067 	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1068 	ctx.glUseProgram(program.getProgram());
1069 	ctx.glUniform1f(-2, 0.0f);
1070 	ctx.expectError(GL_INVALID_OPERATION);
1071 	ctx.glUniform2f(-2, 0.0f, 0.0f);
1072 	ctx.expectError(GL_INVALID_OPERATION);
1073 	ctx.glUniform3f(-2, 0.0f, 0.0f, 0.0f);
1074 	ctx.expectError(GL_INVALID_OPERATION);
1075 	ctx.glUniform4f(-2, 0.0f, 0.0f, 0.0f, 0.0f);
1076 	ctx.expectError(GL_INVALID_OPERATION);
1077 
1078 	ctx.glUseProgram(program.getProgram());
1079 	ctx.glUniform1f(-1, 0.0f);
1080 	ctx.expectError(GL_NO_ERROR);
1081 	ctx.glUniform2f(-1, 0.0f, 0.0f);
1082 	ctx.expectError(GL_NO_ERROR);
1083 	ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f);
1084 	ctx.expectError(GL_NO_ERROR);
1085 	ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f);
1086 	ctx.expectError(GL_NO_ERROR);
1087 	ctx.endSection();
1088 
1089 	ctx.glUseProgram(0);
1090 }
1091 
1092 // ctx.glUniform*fv
1093 
uniformfv_invalid_program(NegativeTestContext & ctx)1094 void uniformfv_invalid_program (NegativeTestContext& ctx)
1095 {
1096 	std::vector<GLfloat> data(4);
1097 
1098 	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1099 	ctx.glUseProgram(0);
1100 	ctx.glUniform1fv(-1, 1, &data[0]);
1101 	ctx.expectError(GL_INVALID_OPERATION);
1102 	ctx.glUniform2fv(-1, 1, &data[0]);
1103 	ctx.expectError(GL_INVALID_OPERATION);
1104 	ctx.glUniform3fv(-1, 1, &data[0]);
1105 	ctx.expectError(GL_INVALID_OPERATION);
1106 	ctx.glUniform4fv(-1, 1, &data[0]);
1107 	ctx.expectError(GL_INVALID_OPERATION);
1108 	ctx.endSection();
1109 }
1110 
uniformfv_incompatible_type(NegativeTestContext & ctx)1111 void uniformfv_incompatible_type (NegativeTestContext& ctx)
1112 {
1113 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1114 
1115 	ctx.glUseProgram(program.getProgram());
1116 	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1117 	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
1118 	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
1119 	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1120 	ctx.expectError(GL_NO_ERROR);
1121 
1122 	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1123 	{
1124 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1125 		ctx.fail("Failed to retrieve uniform location");
1126 	}
1127 
1128 	std::vector<GLfloat> data(4);
1129 
1130 	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1131 	ctx.glUseProgram(program.getProgram());
1132 	ctx.glUniform1fv(vec4_v, 1, &data[0]);
1133 	ctx.expectError(GL_INVALID_OPERATION);
1134 	ctx.glUniform2fv(vec4_v, 1, &data[0]);
1135 	ctx.expectError(GL_INVALID_OPERATION);
1136 	ctx.glUniform3fv(vec4_v, 1, &data[0]);
1137 	ctx.expectError(GL_INVALID_OPERATION);
1138 	ctx.glUniform4fv(vec4_v, 1, &data[0]);
1139 	ctx.expectError(GL_NO_ERROR);
1140 	ctx.endSection();
1141 
1142 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}fv is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4.");
1143 	ctx.glUseProgram(program.getProgram());
1144 	ctx.glUniform4fv(ivec4_f, 1, &data[0]);
1145 	ctx.expectError(GL_INVALID_OPERATION);
1146 	ctx.glUniform4fv(uvec4_f, 1, &data[0]);
1147 	ctx.expectError(GL_INVALID_OPERATION);
1148 	ctx.endSection();
1149 
1150 	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1151 	ctx.glUseProgram(program.getProgram());
1152 	ctx.glUniform1fv(sampler_f, 1, &data[0]);
1153 	ctx.expectError(GL_INVALID_OPERATION);
1154 	ctx.endSection();
1155 
1156 	ctx.glUseProgram(0);
1157 }
1158 
uniformfv_invalid_location(NegativeTestContext & ctx)1159 void uniformfv_invalid_location (NegativeTestContext& ctx)
1160 {
1161 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1162 
1163 	ctx.glUseProgram(program.getProgram());
1164 	ctx.expectError(GL_NO_ERROR);
1165 
1166 	std::vector<GLfloat> data(4);
1167 
1168 	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1169 	ctx.glUseProgram(program.getProgram());
1170 	ctx.glUniform1fv(-2, 1, &data[0]);
1171 	ctx.expectError(GL_INVALID_OPERATION);
1172 	ctx.glUniform2fv(-2, 1, &data[0]);
1173 	ctx.expectError(GL_INVALID_OPERATION);
1174 	ctx.glUniform3fv(-2, 1, &data[0]);
1175 	ctx.expectError(GL_INVALID_OPERATION);
1176 	ctx.glUniform4fv(-2, 1, &data[0]);
1177 	ctx.expectError(GL_INVALID_OPERATION);
1178 
1179 	ctx.glUseProgram(program.getProgram());
1180 	ctx.glUniform1fv(-1, 1, &data[0]);
1181 	ctx.expectError(GL_NO_ERROR);
1182 	ctx.glUniform2fv(-1, 1, &data[0]);
1183 	ctx.expectError(GL_NO_ERROR);
1184 	ctx.glUniform3fv(-1, 1, &data[0]);
1185 	ctx.expectError(GL_NO_ERROR);
1186 	ctx.glUniform4fv(-1, 1, &data[0]);
1187 	ctx.expectError(GL_NO_ERROR);
1188 	ctx.endSection();
1189 
1190 	ctx.glUseProgram(0);
1191 }
1192 
uniformfv_invalid_count(NegativeTestContext & ctx)1193 void uniformfv_invalid_count (NegativeTestContext& ctx)
1194 {
1195 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1196 
1197 	ctx.glUseProgram	(program.getProgram());
1198 	GLint vec4_v			= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1199 	ctx.expectError(GL_NO_ERROR);
1200 
1201 	if (vec4_v == -1)
1202 	{
1203 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1204 		ctx.fail("Failed to retrieve uniform location");
1205 	}
1206 
1207 	std::vector<GLfloat> data(8);
1208 
1209 	ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1210 	ctx.glUseProgram(program.getProgram());
1211 	ctx.glUniform1fv(vec4_v, 2, &data[0]);
1212 	ctx.expectError(GL_INVALID_OPERATION);
1213 	ctx.glUniform2fv(vec4_v, 2, &data[0]);
1214 	ctx.expectError(GL_INVALID_OPERATION);
1215 	ctx.glUniform3fv(vec4_v, 2, &data[0]);
1216 	ctx.expectError(GL_INVALID_OPERATION);
1217 	ctx.glUniform4fv(vec4_v, 2, &data[0]);
1218 	ctx.expectError(GL_INVALID_OPERATION);
1219 	ctx.endSection();
1220 
1221 	ctx.glUseProgram(0);
1222 }
1223 
1224 // ctx.glUniform*i
1225 
uniformi_invalid_program(NegativeTestContext & ctx)1226 void uniformi_invalid_program (NegativeTestContext& ctx)
1227 {
1228 	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1229 	ctx.glUseProgram(0);
1230 	ctx.glUniform1i(-1, 0);
1231 	ctx.expectError(GL_INVALID_OPERATION);
1232 	ctx.glUniform2i(-1, 0, 0);
1233 	ctx.expectError(GL_INVALID_OPERATION);
1234 	ctx.glUniform3i(-1, 0, 0, 0);
1235 	ctx.expectError(GL_INVALID_OPERATION);
1236 	ctx.glUniform4i(-1, 0, 0, 0, 0);
1237 	ctx.expectError(GL_INVALID_OPERATION);
1238 	ctx.endSection();
1239 }
1240 
uniformi_incompatible_type(NegativeTestContext & ctx)1241 void uniformi_incompatible_type (NegativeTestContext& ctx)
1242 {
1243 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1244 
1245 	ctx.glUseProgram(program.getProgram());
1246 	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1247 	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
1248 	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
1249 	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1250 	ctx.expectError(GL_NO_ERROR);
1251 
1252 	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1253 	{
1254 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1255 		ctx.fail("Failed to retrieve uniform location");
1256 	}
1257 
1258 	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1259 	ctx.glUseProgram(program.getProgram());
1260 	ctx.glUniform1i(ivec4_f, 0);
1261 	ctx.expectError(GL_INVALID_OPERATION);
1262 	ctx.glUniform2i(ivec4_f, 0, 0);
1263 	ctx.expectError(GL_INVALID_OPERATION);
1264 	ctx.glUniform3i(ivec4_f, 0, 0, 0);
1265 	ctx.expectError(GL_INVALID_OPERATION);
1266 	ctx.glUniform4i(ivec4_f, 0, 0, 0, 0);
1267 	ctx.expectError(GL_NO_ERROR);
1268 	ctx.endSection();
1269 
1270 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type unsigned int, uvec2, uvec3, uvec4, or an array of these.");
1271 	ctx.glUseProgram(program.getProgram());
1272 	ctx.glUniform1i(uvec4_f, 0);
1273 	ctx.expectError(GL_INVALID_OPERATION);
1274 	ctx.glUniform2i(uvec4_f, 0, 0);
1275 	ctx.expectError(GL_INVALID_OPERATION);
1276 	ctx.glUniform3i(uvec4_f, 0, 0, 0);
1277 	ctx.expectError(GL_INVALID_OPERATION);
1278 	ctx.glUniform4i(uvec4_f, 0, 0, 0, 0);
1279 	ctx.expectError(GL_INVALID_OPERATION);
1280 	ctx.endSection();
1281 
1282 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1283 	ctx.glUseProgram(program.getProgram());
1284 	ctx.glUniform1i(vec4_v, 0);
1285 	ctx.expectError(GL_INVALID_OPERATION);
1286 	ctx.glUniform2i(vec4_v, 0, 0);
1287 	ctx.expectError(GL_INVALID_OPERATION);
1288 	ctx.glUniform3i(vec4_v, 0, 0, 0);
1289 	ctx.expectError(GL_INVALID_OPERATION);
1290 	ctx.glUniform4i(vec4_v, 0, 0, 0, 0);
1291 	ctx.expectError(GL_INVALID_OPERATION);
1292 	ctx.endSection();
1293 
1294 	ctx.glUseProgram(0);
1295 }
1296 
uniformi_invalid_location(NegativeTestContext & ctx)1297 void uniformi_invalid_location (NegativeTestContext& ctx)
1298 {
1299 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1300 
1301 	ctx.glUseProgram(program.getProgram());
1302 	ctx.expectError(GL_NO_ERROR);
1303 
1304 	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1305 	ctx.glUseProgram(program.getProgram());
1306 	ctx.glUniform1i(-2, 0);
1307 	ctx.expectError(GL_INVALID_OPERATION);
1308 	ctx.glUniform2i(-2, 0, 0);
1309 	ctx.expectError(GL_INVALID_OPERATION);
1310 	ctx.glUniform3i(-2, 0, 0, 0);
1311 	ctx.expectError(GL_INVALID_OPERATION);
1312 	ctx.glUniform4i(-2, 0, 0, 0, 0);
1313 	ctx.expectError(GL_INVALID_OPERATION);
1314 
1315 	ctx.glUseProgram(program.getProgram());
1316 	ctx.glUniform1i(-1, 0);
1317 	ctx.expectError(GL_NO_ERROR);
1318 	ctx.glUniform2i(-1, 0, 0);
1319 	ctx.expectError(GL_NO_ERROR);
1320 	ctx.glUniform3i(-1, 0, 0, 0);
1321 	ctx.expectError(GL_NO_ERROR);
1322 	ctx.glUniform4i(-1, 0, 0, 0, 0);
1323 	ctx.expectError(GL_NO_ERROR);
1324 	ctx.endSection();
1325 
1326 	ctx.glUseProgram(0);
1327 }
1328 
1329 // ctx.glUniform*iv
1330 
uniformiv_invalid_program(NegativeTestContext & ctx)1331 void uniformiv_invalid_program (NegativeTestContext& ctx)
1332 {
1333 	std::vector<GLint> data(4);
1334 
1335 	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1336 	ctx.glUseProgram(0);
1337 	ctx.glUniform1iv(-1, 1, &data[0]);
1338 	ctx.expectError(GL_INVALID_OPERATION);
1339 	ctx.glUniform2iv(-1, 1, &data[0]);
1340 	ctx.expectError(GL_INVALID_OPERATION);
1341 	ctx.glUniform3iv(-1, 1, &data[0]);
1342 	ctx.expectError(GL_INVALID_OPERATION);
1343 	ctx.glUniform4iv(-1, 1, &data[0]);
1344 	ctx.expectError(GL_INVALID_OPERATION);
1345 	ctx.endSection();
1346 }
1347 
uniformiv_incompatible_type(NegativeTestContext & ctx)1348 void uniformiv_incompatible_type (NegativeTestContext& ctx)
1349 {
1350 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1351 
1352 	ctx.glUseProgram(program.getProgram());
1353 	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1354 	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
1355 	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
1356 	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1357 	ctx.expectError(GL_NO_ERROR);
1358 
1359 	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1360 	{
1361 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1362 		ctx.fail("Failed to retrieve uniform location");
1363 	}
1364 
1365 	std::vector<GLint> data(4);
1366 
1367 	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1368 	ctx.glUseProgram(program.getProgram());
1369 	ctx.glUniform1iv(ivec4_f, 1, &data[0]);
1370 	ctx.expectError(GL_INVALID_OPERATION);
1371 	ctx.glUniform2iv(ivec4_f, 1, &data[0]);
1372 	ctx.expectError(GL_INVALID_OPERATION);
1373 	ctx.glUniform3iv(ivec4_f, 1, &data[0]);
1374 	ctx.expectError(GL_INVALID_OPERATION);
1375 	ctx.glUniform4iv(ivec4_f, 1, &data[0]);
1376 	ctx.expectError(GL_NO_ERROR);
1377 	ctx.endSection();
1378 
1379 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}iv is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1380 	ctx.glUseProgram(program.getProgram());
1381 	ctx.glUniform1iv(vec4_v, 1, &data[0]);
1382 	ctx.expectError(GL_INVALID_OPERATION);
1383 	ctx.glUniform2iv(vec4_v, 1, &data[0]);
1384 	ctx.expectError(GL_INVALID_OPERATION);
1385 	ctx.glUniform3iv(vec4_v, 1, &data[0]);
1386 	ctx.expectError(GL_INVALID_OPERATION);
1387 	ctx.glUniform4iv(vec4_v, 1, &data[0]);
1388 	ctx.expectError(GL_INVALID_OPERATION);
1389 	ctx.endSection();
1390 
1391 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}iv is used to load a uniform variable of type unsigned int, uvec2, uvec3 or uvec4.");
1392 	ctx.glUseProgram(program.getProgram());
1393 	ctx.glUniform1iv(uvec4_f, 1, &data[0]);
1394 	ctx.expectError(GL_INVALID_OPERATION);
1395 	ctx.glUniform2iv(uvec4_f, 1, &data[0]);
1396 	ctx.expectError(GL_INVALID_OPERATION);
1397 	ctx.glUniform3iv(uvec4_f, 1, &data[0]);
1398 	ctx.expectError(GL_INVALID_OPERATION);
1399 	ctx.glUniform4iv(uvec4_f, 1, &data[0]);
1400 	ctx.expectError(GL_INVALID_OPERATION);
1401 	ctx.endSection();
1402 
1403 	ctx.glUseProgram(0);
1404 }
1405 
uniformiv_invalid_location(NegativeTestContext & ctx)1406 void uniformiv_invalid_location (NegativeTestContext& ctx)
1407 {
1408 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1409 
1410 	ctx.glUseProgram(program.getProgram());
1411 	ctx.expectError(GL_NO_ERROR);
1412 
1413 	std::vector<GLint> data(4);
1414 
1415 	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1416 	ctx.glUseProgram(program.getProgram());
1417 	ctx.glUniform1iv(-2, 1, &data[0]);
1418 	ctx.expectError(GL_INVALID_OPERATION);
1419 	ctx.glUniform2iv(-2, 1, &data[0]);
1420 	ctx.expectError(GL_INVALID_OPERATION);
1421 	ctx.glUniform3iv(-2, 1, &data[0]);
1422 	ctx.expectError(GL_INVALID_OPERATION);
1423 	ctx.glUniform4iv(-2, 1, &data[0]);
1424 	ctx.expectError(GL_INVALID_OPERATION);
1425 
1426 	ctx.glUseProgram(program.getProgram());
1427 	ctx.glUniform1iv(-1, 1, &data[0]);
1428 	ctx.expectError(GL_NO_ERROR);
1429 	ctx.glUniform2iv(-1, 1, &data[0]);
1430 	ctx.expectError(GL_NO_ERROR);
1431 	ctx.glUniform3iv(-1, 1, &data[0]);
1432 	ctx.expectError(GL_NO_ERROR);
1433 	ctx.glUniform4iv(-1, 1, &data[0]);
1434 	ctx.expectError(GL_NO_ERROR);
1435 	ctx.endSection();
1436 
1437 	ctx.glUseProgram(0);
1438 }
1439 
uniformiv_invalid_count(NegativeTestContext & ctx)1440 void uniformiv_invalid_count (NegativeTestContext& ctx)
1441 {
1442 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1443 
1444 	ctx.glUseProgram			(program.getProgram());
1445 	GLint ivec4_f			= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4
1446 	ctx.expectError(GL_NO_ERROR);
1447 
1448 	if (ivec4_f == -1)
1449 	{
1450 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1451 		ctx.fail("Failed to retrieve uniform location");
1452 	}
1453 
1454 	std::vector<GLint> data(8);
1455 
1456 	ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1457 	ctx.glUseProgram(program.getProgram());
1458 	ctx.glUniform1iv(ivec4_f, 2, &data[0]);
1459 	ctx.expectError(GL_INVALID_OPERATION);
1460 	ctx.glUniform2iv(ivec4_f, 2, &data[0]);
1461 	ctx.expectError(GL_INVALID_OPERATION);
1462 	ctx.glUniform3iv(ivec4_f, 2, &data[0]);
1463 	ctx.expectError(GL_INVALID_OPERATION);
1464 	ctx.glUniform4iv(ivec4_f, 2, &data[0]);
1465 	ctx.expectError(GL_INVALID_OPERATION);
1466 	ctx.endSection();
1467 
1468 	ctx.glUseProgram(0);
1469 }
1470 
1471 // ctx.glUniform{1234}ui
1472 
uniformui_invalid_program(NegativeTestContext & ctx)1473 void uniformui_invalid_program (NegativeTestContext& ctx)
1474 {
1475 	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1476 	ctx.glUseProgram(0);
1477 	ctx.glUniform1ui(-1, 0);
1478 	ctx.expectError(GL_INVALID_OPERATION);
1479 	ctx.glUniform2ui(-1, 0, 0);
1480 	ctx.expectError(GL_INVALID_OPERATION);
1481 	ctx.glUniform3ui(-1, 0, 0, 0);
1482 	ctx.expectError(GL_INVALID_OPERATION);
1483 	ctx.glUniform4ui(-1, 0, 0, 0, 0);
1484 	ctx.expectError(GL_INVALID_OPERATION);
1485 	ctx.endSection();
1486 }
1487 
uniformui_incompatible_type(NegativeTestContext & ctx)1488 void uniformui_incompatible_type (NegativeTestContext& ctx)
1489 {
1490 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1491 
1492 	ctx.glUseProgram(program.getProgram());
1493 	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1494 	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
1495 	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
1496 	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1497 	ctx.expectError(GL_NO_ERROR);
1498 
1499 	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1500 	{
1501 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1502 		ctx.fail("Failed to retrieve uniform location");
1503 	}
1504 
1505 	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1506 	ctx.glUseProgram(program.getProgram());
1507 	ctx.glUniform1ui(uvec4_f, 0);
1508 	ctx.expectError(GL_INVALID_OPERATION);
1509 	ctx.glUniform2ui(uvec4_f, 0, 0);
1510 	ctx.expectError(GL_INVALID_OPERATION);
1511 	ctx.glUniform3ui(uvec4_f, 0, 0, 0);
1512 	ctx.expectError(GL_INVALID_OPERATION);
1513 	ctx.glUniform4ui(uvec4_f, 0, 0, 0, 0);
1514 	ctx.expectError(GL_NO_ERROR);
1515 	ctx.endSection();
1516 
1517 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type int, ivec2, ivec3, ivec4, or an array of these.");
1518 	ctx.glUseProgram(program.getProgram());
1519 	ctx.glUniform1ui(ivec4_f, 0);
1520 	ctx.expectError(GL_INVALID_OPERATION);
1521 	ctx.glUniform2ui(ivec4_f, 0, 0);
1522 	ctx.expectError(GL_INVALID_OPERATION);
1523 	ctx.glUniform3ui(ivec4_f, 0, 0, 0);
1524 	ctx.expectError(GL_INVALID_OPERATION);
1525 	ctx.glUniform4ui(ivec4_f, 0, 0, 0, 0);
1526 	ctx.expectError(GL_INVALID_OPERATION);
1527 	ctx.endSection();
1528 
1529 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1530 	ctx.glUseProgram(program.getProgram());
1531 	ctx.glUniform1ui(vec4_v, 0);
1532 	ctx.expectError(GL_INVALID_OPERATION);
1533 	ctx.glUniform2ui(vec4_v, 0, 0);
1534 	ctx.expectError(GL_INVALID_OPERATION);
1535 	ctx.glUniform3ui(vec4_v, 0, 0, 0);
1536 	ctx.expectError(GL_INVALID_OPERATION);
1537 	ctx.glUniform4ui(vec4_v, 0, 0, 0, 0);
1538 	ctx.expectError(GL_INVALID_OPERATION);
1539 	ctx.endSection();
1540 
1541 	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1542 	ctx.glUseProgram(program.getProgram());
1543 	ctx.glUniform1ui(sampler_f, 0);
1544 	ctx.expectError(GL_INVALID_OPERATION);
1545 	ctx.endSection();
1546 
1547 	ctx.glUseProgram(0);
1548 }
1549 
uniformui_invalid_location(NegativeTestContext & ctx)1550 void uniformui_invalid_location (NegativeTestContext& ctx)
1551 {
1552 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1553 
1554 	ctx.glUseProgram(program.getProgram());
1555 	ctx.expectError(GL_NO_ERROR);
1556 
1557 	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1558 	ctx.glUseProgram(program.getProgram());
1559 	ctx.glUniform1i(-2, 0);
1560 	ctx.expectError(GL_INVALID_OPERATION);
1561 	ctx.glUniform2i(-2, 0, 0);
1562 	ctx.expectError(GL_INVALID_OPERATION);
1563 	ctx.glUniform3i(-2, 0, 0, 0);
1564 	ctx.expectError(GL_INVALID_OPERATION);
1565 	ctx.glUniform4i(-2, 0, 0, 0, 0);
1566 	ctx.expectError(GL_INVALID_OPERATION);
1567 
1568 	ctx.glUseProgram(program.getProgram());
1569 	ctx.glUniform1i(-1, 0);
1570 	ctx.expectError(GL_NO_ERROR);
1571 	ctx.glUniform2i(-1, 0, 0);
1572 	ctx.expectError(GL_NO_ERROR);
1573 	ctx.glUniform3i(-1, 0, 0, 0);
1574 	ctx.expectError(GL_NO_ERROR);
1575 	ctx.glUniform4i(-1, 0, 0, 0, 0);
1576 	ctx.expectError(GL_NO_ERROR);
1577 	ctx.endSection();
1578 
1579 	ctx.glUseProgram(0);
1580 }
1581 
1582 // ctx.glUniform{1234}uiv
1583 
uniformuiv_invalid_program(NegativeTestContext & ctx)1584 void uniformuiv_invalid_program (NegativeTestContext& ctx)
1585 {
1586 	std::vector<GLuint> data(4);
1587 
1588 	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1589 	ctx.glUseProgram(0);
1590 	ctx.glUniform1uiv(-1, 1, &data[0]);
1591 	ctx.expectError(GL_INVALID_OPERATION);
1592 	ctx.glUniform2uiv(-1, 1, &data[0]);
1593 	ctx.expectError(GL_INVALID_OPERATION);
1594 	ctx.glUniform3uiv(-1, 1, &data[0]);
1595 	ctx.expectError(GL_INVALID_OPERATION);
1596 	ctx.glUniform4uiv(-1, 1, &data[0]);
1597 	ctx.expectError(GL_INVALID_OPERATION);
1598 	ctx.endSection();
1599 }
1600 
uniformuiv_incompatible_type(NegativeTestContext & ctx)1601 void uniformuiv_incompatible_type (NegativeTestContext& ctx)
1602 {
1603 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1604 
1605 	ctx.glUseProgram(program.getProgram());
1606 	GLint vec4_v	= ctx.glGetUniformLocation(program.getProgram(), "vec4_v");	// vec4
1607 	GLint ivec4_f	= ctx.glGetUniformLocation(program.getProgram(), "ivec4_f");	// ivec4
1608 	GLint uvec4_f	= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f");	// uvec4
1609 	GLint sampler_f	= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1610 	ctx.expectError(GL_NO_ERROR);
1611 
1612 	if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1)
1613 	{
1614 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1615 		ctx.fail("Failed to retrieve uniform location");
1616 	}
1617 
1618 	std::vector<GLuint> data(4);
1619 
1620 	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1621 	ctx.glUseProgram(program.getProgram());
1622 	ctx.glUniform1uiv(uvec4_f, 1, &data[0]);
1623 	ctx.expectError(GL_INVALID_OPERATION);
1624 	ctx.glUniform2uiv(uvec4_f, 1, &data[0]);
1625 	ctx.expectError(GL_INVALID_OPERATION);
1626 	ctx.glUniform3uiv(uvec4_f, 1, &data[0]);
1627 	ctx.expectError(GL_INVALID_OPERATION);
1628 	ctx.glUniform4uiv(uvec4_f, 1, &data[0]);
1629 	ctx.expectError(GL_NO_ERROR);
1630 	ctx.endSection();
1631 
1632 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}uiv is used to load a uniform variable of type float, vec2, vec3, or vec4.");
1633 	ctx.glUseProgram(program.getProgram());
1634 	ctx.glUniform1uiv(vec4_v, 1, &data[0]);
1635 	ctx.expectError(GL_INVALID_OPERATION);
1636 	ctx.glUniform2uiv(vec4_v, 1, &data[0]);
1637 	ctx.expectError(GL_INVALID_OPERATION);
1638 	ctx.glUniform3uiv(vec4_v, 1, &data[0]);
1639 	ctx.expectError(GL_INVALID_OPERATION);
1640 	ctx.glUniform4uiv(vec4_v, 1, &data[0]);
1641 	ctx.expectError(GL_INVALID_OPERATION);
1642 	ctx.endSection();
1643 
1644 	ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}uiv is used to load a uniform variable of type int, ivec2, ivec3 or ivec4.");
1645 	ctx.glUseProgram(program.getProgram());
1646 	ctx.glUniform1uiv(ivec4_f, 1, &data[0]);
1647 	ctx.expectError(GL_INVALID_OPERATION);
1648 	ctx.glUniform2uiv(ivec4_f, 1, &data[0]);
1649 	ctx.expectError(GL_INVALID_OPERATION);
1650 	ctx.glUniform3uiv(ivec4_f, 1, &data[0]);
1651 	ctx.expectError(GL_INVALID_OPERATION);
1652 	ctx.glUniform4uiv(ivec4_f, 1, &data[0]);
1653 	ctx.expectError(GL_INVALID_OPERATION);
1654 	ctx.endSection();
1655 
1656 	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1657 	ctx.glUseProgram(program.getProgram());
1658 	ctx.glUniform1uiv(sampler_f, 1, &data[0]);
1659 	ctx.expectError(GL_INVALID_OPERATION);
1660 	ctx.endSection();
1661 
1662 	ctx.glUseProgram(0);
1663 }
1664 
uniformuiv_invalid_location(NegativeTestContext & ctx)1665 void uniformuiv_invalid_location (NegativeTestContext& ctx)
1666 {
1667 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1668 
1669 	ctx.glUseProgram(program.getProgram());
1670 	ctx.expectError(GL_NO_ERROR);
1671 
1672 	std::vector<GLuint> data(4);
1673 
1674 	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1675 	ctx.glUseProgram(program.getProgram());
1676 	ctx.glUniform1uiv(-2, 1, &data[0]);
1677 	ctx.expectError(GL_INVALID_OPERATION);
1678 	ctx.glUniform2uiv(-2, 1, &data[0]);
1679 	ctx.expectError(GL_INVALID_OPERATION);
1680 	ctx.glUniform3uiv(-2, 1, &data[0]);
1681 	ctx.expectError(GL_INVALID_OPERATION);
1682 	ctx.glUniform4uiv(-2, 1, &data[0]);
1683 	ctx.expectError(GL_INVALID_OPERATION);
1684 
1685 	ctx.glUseProgram(program.getProgram());
1686 	ctx.glUniform1uiv(-1, 1, &data[0]);
1687 	ctx.expectError(GL_NO_ERROR);
1688 	ctx.glUniform2uiv(-1, 1, &data[0]);
1689 	ctx.expectError(GL_NO_ERROR);
1690 	ctx.glUniform3uiv(-1, 1, &data[0]);
1691 	ctx.expectError(GL_NO_ERROR);
1692 	ctx.glUniform4uiv(-1, 1, &data[0]);
1693 	ctx.expectError(GL_NO_ERROR);
1694 	ctx.endSection();
1695 
1696 	ctx.glUseProgram(0);
1697 }
1698 
uniformuiv_invalid_count(NegativeTestContext & ctx)1699 void uniformuiv_invalid_count (NegativeTestContext& ctx)
1700 {
1701 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1702 
1703 	ctx.glUseProgram			(program.getProgram());
1704 	int uvec4_f				= ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4
1705 	ctx.expectError(GL_NO_ERROR);
1706 
1707 	if (uvec4_f == -1)
1708 	{
1709 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1710 		ctx.fail("Failed to retrieve uniform location");
1711 	}
1712 
1713 	std::vector<GLuint> data(8);
1714 
1715 	ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1716 	ctx.glUseProgram(program.getProgram());
1717 	ctx.glUniform1uiv(uvec4_f, 2, &data[0]);
1718 	ctx.expectError(GL_INVALID_OPERATION);
1719 	ctx.glUniform2uiv(uvec4_f, 2, &data[0]);
1720 	ctx.expectError(GL_INVALID_OPERATION);
1721 	ctx.glUniform3uiv(uvec4_f, 2, &data[0]);
1722 	ctx.expectError(GL_INVALID_OPERATION);
1723 	ctx.glUniform4uiv(uvec4_f, 2, &data[0]);
1724 	ctx.expectError(GL_INVALID_OPERATION);
1725 	ctx.endSection();
1726 
1727 	ctx.glUseProgram(0);
1728 }
1729 
1730 
1731 // ctx.glUniformMatrix*fv
1732 
uniform_matrixfv_invalid_program(NegativeTestContext & ctx)1733 void uniform_matrixfv_invalid_program (NegativeTestContext& ctx)
1734 {
1735 	std::vector<GLfloat> data(16);
1736 
1737 	ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object.");
1738 	ctx.glUseProgram(0);
1739 	ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
1740 	ctx.expectError(GL_INVALID_OPERATION);
1741 	ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
1742 	ctx.expectError(GL_INVALID_OPERATION);
1743 	ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
1744 	ctx.expectError(GL_INVALID_OPERATION);
1745 
1746 	ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
1747 	ctx.expectError(GL_INVALID_OPERATION);
1748 	ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
1749 	ctx.expectError(GL_INVALID_OPERATION);
1750 	ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
1751 	ctx.expectError(GL_INVALID_OPERATION);
1752 	ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
1753 	ctx.expectError(GL_INVALID_OPERATION);
1754 	ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
1755 	ctx.expectError(GL_INVALID_OPERATION);
1756 	ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
1757 	ctx.expectError(GL_INVALID_OPERATION);
1758 	ctx.endSection();
1759 }
1760 
uniform_matrixfv_incompatible_type(NegativeTestContext & ctx)1761 void uniform_matrixfv_incompatible_type (NegativeTestContext& ctx)
1762 {
1763 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1764 
1765 	ctx.glUseProgram			(program.getProgram());
1766 	GLint mat4_v			= ctx.glGetUniformLocation(program.getProgram(), "mat4_v");	// mat4
1767 	GLint sampler_f			= ctx.glGetUniformLocation(program.getProgram(), "sampler_f");	// sampler2D
1768 	ctx.expectError(GL_NO_ERROR);
1769 
1770 	if (mat4_v == -1 || sampler_f == -1)
1771 	{
1772 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1773 		ctx.fail("Failed to retrieve uniform location");
1774 	}
1775 
1776 	std::vector<GLfloat> data(16);
1777 
1778 	ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command.");
1779 	ctx.glUseProgram(program.getProgram());
1780 	ctx.glUniformMatrix2fv(mat4_v, 1, GL_FALSE, &data[0]);
1781 	ctx.expectError(GL_INVALID_OPERATION);
1782 	ctx.glUniformMatrix3fv(mat4_v, 1, GL_FALSE, &data[0]);
1783 	ctx.expectError(GL_INVALID_OPERATION);
1784 	ctx.glUniformMatrix4fv(mat4_v, 1, GL_FALSE, &data[0]);
1785 	ctx.expectError(GL_NO_ERROR);
1786 
1787 	ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1788 	ctx.expectError(GL_INVALID_OPERATION);
1789 	ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1790 	ctx.expectError(GL_INVALID_OPERATION);
1791 	ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1792 	ctx.expectError(GL_INVALID_OPERATION);
1793 	ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1794 	ctx.expectError(GL_INVALID_OPERATION);
1795 	ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1796 	ctx.expectError(GL_INVALID_OPERATION);
1797 	ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1798 	ctx.expectError(GL_INVALID_OPERATION);
1799 	ctx.endSection();
1800 
1801 	ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv.");
1802 	ctx.glUseProgram(program.getProgram());
1803 	ctx.glUniformMatrix2fv(sampler_f, 1, GL_FALSE, &data[0]);
1804 	ctx.expectError(GL_INVALID_OPERATION);
1805 	ctx.glUniformMatrix3fv(sampler_f, 1, GL_FALSE, &data[0]);
1806 	ctx.expectError(GL_INVALID_OPERATION);
1807 	ctx.glUniformMatrix4fv(sampler_f, 1, GL_FALSE, &data[0]);
1808 	ctx.expectError(GL_INVALID_OPERATION);
1809 
1810 	ctx.glUniformMatrix2x3fv(sampler_f, 1, GL_FALSE, &data[0]);
1811 	ctx.expectError(GL_INVALID_OPERATION);
1812 	ctx.glUniformMatrix3x2fv(sampler_f, 1, GL_FALSE, &data[0]);
1813 	ctx.expectError(GL_INVALID_OPERATION);
1814 	ctx.glUniformMatrix2x4fv(sampler_f, 1, GL_FALSE, &data[0]);
1815 	ctx.expectError(GL_INVALID_OPERATION);
1816 	ctx.glUniformMatrix4x2fv(sampler_f, 1, GL_FALSE, &data[0]);
1817 	ctx.expectError(GL_INVALID_OPERATION);
1818 	ctx.glUniformMatrix3x4fv(sampler_f, 1, GL_FALSE, &data[0]);
1819 	ctx.expectError(GL_INVALID_OPERATION);
1820 	ctx.glUniformMatrix4x3fv(sampler_f, 1, GL_FALSE, &data[0]);
1821 	ctx.expectError(GL_INVALID_OPERATION);
1822 	ctx.endSection();
1823 
1824 	ctx.glUseProgram(0);
1825 }
1826 
uniform_matrixfv_invalid_location(NegativeTestContext & ctx)1827 void uniform_matrixfv_invalid_location (NegativeTestContext& ctx)
1828 {
1829 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1830 
1831 	ctx.glUseProgram(program.getProgram());
1832 	ctx.expectError(GL_NO_ERROR);
1833 
1834 	std::vector<GLfloat> data(16);
1835 
1836 	ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1.");
1837 	ctx.glUseProgram(program.getProgram());
1838 	ctx.glUniformMatrix2fv(-2, 1, GL_FALSE, &data[0]);
1839 	ctx.expectError(GL_INVALID_OPERATION);
1840 	ctx.glUniformMatrix3fv(-2, 1, GL_FALSE, &data[0]);
1841 	ctx.expectError(GL_INVALID_OPERATION);
1842 	ctx.glUniformMatrix4fv(-2, 1, GL_FALSE, &data[0]);
1843 	ctx.expectError(GL_INVALID_OPERATION);
1844 
1845 	ctx.glUniformMatrix2x3fv(-2, 1, GL_FALSE, &data[0]);
1846 	ctx.expectError(GL_INVALID_OPERATION);
1847 	ctx.glUniformMatrix3x2fv(-2, 1, GL_FALSE, &data[0]);
1848 	ctx.expectError(GL_INVALID_OPERATION);
1849 	ctx.glUniformMatrix2x4fv(-2, 1, GL_FALSE, &data[0]);
1850 	ctx.expectError(GL_INVALID_OPERATION);
1851 	ctx.glUniformMatrix4x2fv(-2, 1, GL_FALSE, &data[0]);
1852 	ctx.expectError(GL_INVALID_OPERATION);
1853 	ctx.glUniformMatrix3x4fv(-2, 1, GL_FALSE, &data[0]);
1854 	ctx.expectError(GL_INVALID_OPERATION);
1855 	ctx.glUniformMatrix4x3fv(-2, 1, GL_FALSE, &data[0]);
1856 	ctx.expectError(GL_INVALID_OPERATION);
1857 
1858 	ctx.glUseProgram(program.getProgram());
1859 	ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]);
1860 	ctx.expectError(GL_NO_ERROR);
1861 	ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]);
1862 	ctx.expectError(GL_NO_ERROR);
1863 	ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]);
1864 	ctx.expectError(GL_NO_ERROR);
1865 
1866 	ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]);
1867 	ctx.expectError(GL_NO_ERROR);
1868 	ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]);
1869 	ctx.expectError(GL_NO_ERROR);
1870 	ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]);
1871 	ctx.expectError(GL_NO_ERROR);
1872 	ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]);
1873 	ctx.expectError(GL_NO_ERROR);
1874 	ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]);
1875 	ctx.expectError(GL_NO_ERROR);
1876 	ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]);
1877 	ctx.expectError(GL_NO_ERROR);
1878 	ctx.endSection();
1879 
1880 	ctx.glUseProgram(0);
1881 }
1882 
uniform_matrixfv_invalid_count(NegativeTestContext & ctx)1883 void uniform_matrixfv_invalid_count (NegativeTestContext& ctx)
1884 {
1885 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
1886 
1887 	ctx.glUseProgram			(program.getProgram());
1888 	GLint mat4_v			= ctx.glGetUniformLocation(program.getProgram(), "mat4_v"); // mat4
1889 	ctx.expectError(GL_NO_ERROR);
1890 
1891 	if (mat4_v == -1)
1892 	{
1893 		ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage;
1894 		ctx.fail("Failed to retrieve uniform location");
1895 	}
1896 
1897 	std::vector<GLfloat> data(32);
1898 
1899 	ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable.");
1900 	ctx.glUseProgram(program.getProgram());
1901 	ctx.glUniformMatrix2fv(mat4_v, 2, GL_FALSE, &data[0]);
1902 	ctx.expectError(GL_INVALID_OPERATION);
1903 	ctx.glUniformMatrix3fv(mat4_v, 2, GL_FALSE, &data[0]);
1904 	ctx.expectError(GL_INVALID_OPERATION);
1905 	ctx.glUniformMatrix4fv(mat4_v, 2, GL_FALSE, &data[0]);
1906 	ctx.expectError(GL_INVALID_OPERATION);
1907 
1908 	ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1909 	ctx.expectError(GL_INVALID_OPERATION);
1910 	ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1911 	ctx.expectError(GL_INVALID_OPERATION);
1912 	ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1913 	ctx.expectError(GL_INVALID_OPERATION);
1914 	ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]);
1915 	ctx.expectError(GL_INVALID_OPERATION);
1916 	ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]);
1917 	ctx.expectError(GL_INVALID_OPERATION);
1918 	ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]);
1919 	ctx.expectError(GL_INVALID_OPERATION);
1920 	ctx.endSection();
1921 
1922 	ctx.glUseProgram(0);
1923 }
1924 
1925 // Transform feedback
gen_transform_feedbacks(NegativeTestContext & ctx)1926 void gen_transform_feedbacks (NegativeTestContext& ctx)
1927 {
1928 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1929 	GLuint id = 0;
1930 	ctx.glGenTransformFeedbacks(-1, &id);
1931 	ctx.expectError(GL_INVALID_VALUE);
1932 	ctx.endSection();
1933 }
1934 
bind_transform_feedback(NegativeTestContext & ctx)1935 void bind_transform_feedback (NegativeTestContext& ctx)
1936 {
1937 	GLuint						tfID[2];
1938 	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1939 	deUint32					buf = 0x1234;
1940 	const char* tfVarying		= "gl_Position";
1941 
1942 	ctx.glGenBuffers				(1, &buf);
1943 	ctx.glGenTransformFeedbacks		(2, tfID);
1944 
1945 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK.");
1946 	ctx.glBindTransformFeedback(-1, tfID[0]);
1947 	ctx.expectError(GL_INVALID_ENUM);
1948 	ctx.endSection();
1949 
1950 	ctx.beginSection("GL_INVALID_OPERATION is generated if the transform feedback operation is active on the currently bound transform feedback object, and is not paused.");
1951 	ctx.glUseProgram				(program.getProgram());
1952 	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1953 	ctx.glLinkProgram				(program.getProgram());
1954 	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
1955 	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1956 	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1957 	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1958 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
1959 	ctx.expectError				(GL_NO_ERROR);
1960 
1961 	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[1]);
1962 	ctx.expectError				(GL_INVALID_OPERATION);
1963 
1964 	ctx.glEndTransformFeedback		();
1965 	ctx.expectError				(GL_NO_ERROR);
1966 	ctx.endSection();
1967 
1968 	ctx.glUseProgram				(0);
1969 	ctx.glDeleteBuffers				(1, &buf);
1970 	ctx.glDeleteTransformFeedbacks	(2, tfID);
1971 	ctx.expectError				(GL_NO_ERROR);
1972 
1973 	ctx.beginSection("GL_INVALID_OPERATION is generated if id has been deleted with glDeleteTransformFeedback().");
1974 	ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID[0]);
1975 	ctx.expectError(GL_INVALID_OPERATION);
1976 	ctx.endSection();
1977 
1978 	ctx.beginSection("GL_INVALID_OPERATION is generated if id is not 0 or a value returned from glGenTransformFeedbacks().");
1979 	ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, -1);
1980 	ctx.expectError(GL_INVALID_OPERATION);
1981 	ctx.endSection();
1982 }
1983 
delete_transform_feedbacks(NegativeTestContext & ctx)1984 void delete_transform_feedbacks (NegativeTestContext& ctx)
1985 {
1986 	GLuint				id			= 0;
1987 	GLuint				tfID[2];
1988 	deUint32			buf			= 0x1234;
1989 	const char*			tfVarying	= "gl_Position";
1990 	glu::ShaderProgram	program		(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
1991 
1992 	ctx.glGenBuffers(1, &buf);
1993 	ctx.glGenTransformFeedbacks(1, &id);
1994 	ctx.glGenTransformFeedbacks(2, tfID);
1995 
1996 	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1997 	ctx.glDeleteTransformFeedbacks(-1, &id);
1998 	ctx.expectError(GL_INVALID_VALUE);
1999 	ctx.endSection();
2000 
2001 	ctx.beginSection("GL_INVALID_OPERATION is generated if the transform feedback operation for any object named by ids is currently active.");
2002 	ctx.glUseProgram(program.getProgram());
2003 	ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2004 	ctx.glLinkProgram(program.getProgram());
2005 	ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID[0]);
2006 	ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2007 	ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2008 	ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2009 	ctx.glBeginTransformFeedback(GL_TRIANGLES);
2010 	ctx.expectError(GL_NO_ERROR);
2011 
2012 	ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID[1]);
2013 	ctx.expectError(GL_INVALID_OPERATION);
2014 
2015 	ctx.glDeleteTransformFeedbacks(2, tfID);
2016 	ctx.expectError(GL_INVALID_OPERATION);
2017 
2018 	ctx.glEndTransformFeedback();
2019 	ctx.expectError(GL_NO_ERROR);
2020 	ctx.endSection();
2021 
2022 
2023 	ctx.glDeleteTransformFeedbacks(1, &id);
2024 	ctx.glDeleteTransformFeedbacks(2, tfID);
2025 	ctx.glDeleteBuffers(1, &buf);
2026 
2027 }
2028 
begin_transform_feedback(NegativeTestContext & ctx)2029 void begin_transform_feedback (NegativeTestContext& ctx)
2030 {
2031 	GLuint						tfID[2];
2032 	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2033 	deUint32					buf = 0x1234;
2034 	const char* tfVarying		= "gl_Position";
2035 
2036 	ctx.glGenBuffers				(1, &buf);
2037 	ctx.glGenTransformFeedbacks		(2, tfID);
2038 
2039 	ctx.glUseProgram				(program.getProgram());
2040 	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2041 	ctx.glLinkProgram				(program.getProgram());
2042 	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
2043 	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2044 	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2045 	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2046 	ctx.expectError					(GL_NO_ERROR);
2047 
2048 	ctx.beginSection("GL_INVALID_ENUM is generated if primitiveMode is not one of GL_POINTS, GL_LINES, or GL_TRIANGLES.");
2049 	ctx.glBeginTransformFeedback	(-1);
2050 	ctx.expectError					(GL_INVALID_ENUM);
2051 	ctx.endSection();
2052 
2053 	ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is already active.");
2054 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
2055 	ctx.expectError					(GL_NO_ERROR);
2056 	ctx.glBeginTransformFeedback	(GL_POINTS);
2057 	ctx.expectError					(GL_INVALID_OPERATION);
2058 	ctx.endSection();
2059 
2060 	ctx.beginSection("GL_INVALID_OPERATION is generated if any binding point used in transform feedback mode does not have a buffer object bound.");
2061 	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
2062 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
2063 	ctx.expectError					(GL_INVALID_OPERATION);
2064 	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2065 	ctx.endSection();
2066 
2067 	ctx.beginSection("GL_INVALID_OPERATION is generated if no binding points would be used because no program object is active.");
2068 	ctx.glUseProgram				(0);
2069 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
2070 	ctx.expectError					(GL_INVALID_OPERATION);
2071 	ctx.glUseProgram				(program.getProgram());
2072 	ctx.endSection();
2073 
2074 	ctx.beginSection("GL_INVALID_OPERATION is generated if no binding points would be used because the active program object has specified no varying variables to record.");
2075 	ctx.glTransformFeedbackVaryings	(program.getProgram(), 0, 0, GL_INTERLEAVED_ATTRIBS);
2076 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
2077 	ctx.expectError					(GL_INVALID_OPERATION);
2078 	ctx.endSection();
2079 
2080 	ctx.glEndTransformFeedback		();
2081 	ctx.glDeleteBuffers				(1, &buf);
2082 	ctx.glDeleteTransformFeedbacks	(2, tfID);
2083 	ctx.expectError					(GL_NO_ERROR);
2084 }
2085 
pause_transform_feedback(NegativeTestContext & ctx)2086 void pause_transform_feedback (NegativeTestContext& ctx)
2087 {
2088 	GLuint						tfID[2];
2089 	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2090 	deUint32					buf = 0x1234;
2091 	const char* tfVarying		= "gl_Position";
2092 
2093 	ctx.glGenBuffers				(1, &buf);
2094 	ctx.glGenTransformFeedbacks		(2, tfID);
2095 
2096 	ctx.glUseProgram				(program.getProgram());
2097 	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2098 	ctx.glLinkProgram				(program.getProgram());
2099 	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
2100 	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2101 	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2102 	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2103 	ctx.expectError					(GL_NO_ERROR);
2104 
2105 	ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is paused.");
2106 	ctx.glPauseTransformFeedback	();
2107 	ctx.expectError					(GL_INVALID_OPERATION);
2108 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
2109 	ctx.glPauseTransformFeedback	();
2110 	ctx.expectError					(GL_NO_ERROR);
2111 	ctx.glPauseTransformFeedback	();
2112 	ctx.expectError					(GL_INVALID_OPERATION);
2113 	ctx.endSection();
2114 
2115 	ctx.glEndTransformFeedback		();
2116 	ctx.glDeleteBuffers				(1, &buf);
2117 	ctx.glDeleteTransformFeedbacks	(2, tfID);
2118 	ctx.expectError					(GL_NO_ERROR);
2119 }
2120 
resume_transform_feedback(NegativeTestContext & ctx)2121 void resume_transform_feedback (NegativeTestContext& ctx)
2122 {
2123 	GLuint						tfID[2];
2124 	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2125 	deUint32					buf = 0x1234;
2126 	const char* tfVarying		= "gl_Position";
2127 
2128 	ctx.glGenBuffers				(1, &buf);
2129 	ctx.glGenTransformFeedbacks		(2, tfID);
2130 
2131 	ctx.glUseProgram				(program.getProgram());
2132 	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2133 	ctx.glLinkProgram				(program.getProgram());
2134 	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID[0]);
2135 	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2136 	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2137 	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2138 	ctx.expectError					(GL_NO_ERROR);
2139 
2140 	ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is not paused.");
2141 	ctx.glResumeTransformFeedback	();
2142 	ctx.expectError					(GL_INVALID_OPERATION);
2143 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
2144 	ctx.glResumeTransformFeedback	();
2145 	ctx.expectError					(GL_INVALID_OPERATION);
2146 	ctx.glPauseTransformFeedback	();
2147 	ctx.glResumeTransformFeedback	();
2148 	ctx.expectError					(GL_NO_ERROR);
2149 	ctx.endSection();
2150 
2151 	ctx.glEndTransformFeedback		();
2152 	ctx.glDeleteBuffers				(1, &buf);
2153 	ctx.glDeleteTransformFeedbacks	(2, tfID);
2154 	ctx.expectError					(GL_NO_ERROR);
2155 }
2156 
end_transform_feedback(NegativeTestContext & ctx)2157 void end_transform_feedback (NegativeTestContext& ctx)
2158 {
2159 	GLuint						tfID = 0;
2160 	glu::ShaderProgram			program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2161 	deUint32					buf = 0x1234;
2162 	const char* tfVarying		= "gl_Position";
2163 
2164 	ctx.glGenBuffers				(1, &buf);
2165 	ctx.glGenTransformFeedbacks		(1, &tfID);
2166 
2167 	ctx.glUseProgram				(program.getProgram());
2168 	ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2169 	ctx.glLinkProgram				(program.getProgram());
2170 	ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
2171 	ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
2172 	ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
2173 	ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
2174 	ctx.expectError					(GL_NO_ERROR);
2175 
2176 	ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is not active.");
2177 	ctx.glEndTransformFeedback		();
2178 	ctx.expectError					(GL_INVALID_OPERATION);
2179 	ctx.glBeginTransformFeedback	(GL_TRIANGLES);
2180 	ctx.glEndTransformFeedback		();
2181 	ctx.expectError					(GL_NO_ERROR);
2182 	ctx.endSection();
2183 
2184 	ctx.glDeleteBuffers				(1, &buf);
2185 	ctx.glDeleteTransformFeedbacks	(1, &tfID);
2186 	ctx.expectError					(GL_NO_ERROR);
2187 }
2188 
get_transform_feedback_varying(NegativeTestContext & ctx)2189 void get_transform_feedback_varying (NegativeTestContext& ctx)
2190 {
2191 	GLuint					tfID = 0;
2192 	glu::ShaderProgram		program			(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2193 	glu::ShaderProgram		programInvalid	(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, ""));
2194 	const char* tfVarying	= "gl_Position";
2195 	int						maxTransformFeedbackVaryings = 0;
2196 
2197 	GLsizei					length;
2198 	GLsizei					size;
2199 	GLenum					type;
2200 	char					name[32];
2201 
2202 	const GLuint notAProgram = ctx.glCreateProgram();
2203 	ctx.glDeleteProgram(notAProgram);
2204 
2205 	ctx.glGenTransformFeedbacks				(1, &tfID);
2206 
2207 	ctx.glTransformFeedbackVaryings			(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2208 	ctx.expectError						(GL_NO_ERROR);
2209 	ctx.glLinkProgram						(program.getProgram());
2210 	ctx.expectError						(GL_NO_ERROR);
2211 
2212 	ctx.glBindTransformFeedback				(GL_TRANSFORM_FEEDBACK, tfID);
2213 	ctx.expectError						(GL_NO_ERROR);
2214 
2215 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object.");
2216 	ctx.glGetTransformFeedbackVarying		(notAProgram, 0, 32, &length, &size, &type, &name[0]);
2217 	ctx.expectError						(GL_INVALID_VALUE);
2218 	ctx.endSection();
2219 
2220 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater or equal to the value of GL_TRANSFORM_FEEDBACK_VARYINGS.");
2221 	ctx.glGetProgramiv						(program.getProgram(), GL_TRANSFORM_FEEDBACK_VARYINGS, &maxTransformFeedbackVaryings);
2222 	ctx.glGetTransformFeedbackVarying		(program.getProgram(), maxTransformFeedbackVaryings, 32, &length, &size, &type, &name[0]);
2223 	ctx.expectError						(GL_INVALID_VALUE);
2224 	ctx.endSection();
2225 
2226 	ctx.beginSection("GL_INVALID_OPERATION or GL_INVALID_VALUE is generated program has not been linked.");
2227 	ctx.glGetTransformFeedbackVarying		(programInvalid.getProgram(), 0, 32, &length, &size, &type, &name[0]);
2228 	ctx.expectError						(GL_INVALID_OPERATION, GL_INVALID_VALUE);
2229 	ctx.endSection();
2230 
2231 	ctx.glDeleteTransformFeedbacks			(1, &tfID);
2232 	ctx.expectError						(GL_NO_ERROR);
2233 }
2234 
transform_feedback_varyings(NegativeTestContext & ctx)2235 void transform_feedback_varyings (NegativeTestContext& ctx)
2236 {
2237 	GLuint										tfID = 0;
2238 	GLuint shader								= ctx.glCreateShader(GL_VERTEX_SHADER);
2239 	glu::ShaderProgram program					(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2240 	const char* tfVarying						= "gl_Position";
2241 	GLint maxTransformFeedbackSeparateAttribs	= 0;
2242 
2243 	const GLuint notAProgram = ctx.glCreateProgram();
2244 	ctx.glDeleteProgram(notAProgram);
2245 
2246 	ctx.glGenTransformFeedbacks				(1, &tfID);
2247 	ctx.expectError						(GL_NO_ERROR);
2248 
2249 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object.");
2250 	ctx.glTransformFeedbackVaryings			(notAProgram, 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2251 	ctx.expectError						(GL_INVALID_VALUE);
2252 	ctx.endSection();
2253 
2254 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
2255 	ctx.glTransformFeedbackVaryings(shader, 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2256 	ctx.expectError(GL_INVALID_OPERATION);
2257 	ctx.glDeleteShader(shader);
2258 	ctx.endSection();
2259 
2260 	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
2261 	ctx.glTransformFeedbackVaryings(program.getProgram(), -1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
2262 	ctx.expectError(GL_INVALID_VALUE);
2263 	ctx.endSection();
2264 
2265 	ctx.beginSection("GL_INVALID_ENUM is generated if bufferMode is not SEPARATE_ATTRIBS or INTERLEAVED_ATTRIBS.");
2266 	ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, 0);
2267 	ctx.expectError(GL_INVALID_ENUM);
2268 	ctx.endSection();
2269 
2270 	ctx.beginSection("GL_INVALID_VALUE is generated if bufferMode is GL_SEPARATE_ATTRIBS and count is greater than GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
2271 	ctx.glGetIntegerv						(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTransformFeedbackSeparateAttribs);
2272 	ctx.glTransformFeedbackVaryings			(program.getProgram(), maxTransformFeedbackSeparateAttribs+1, &tfVarying, GL_SEPARATE_ATTRIBS);
2273 	ctx.expectError						(GL_INVALID_VALUE);
2274 	ctx.endSection();
2275 
2276 	ctx.glDeleteTransformFeedbacks			(1, &tfID);
2277 	ctx.expectError						(GL_NO_ERROR);
2278 
2279 }
2280 
link_compute_shader(NegativeTestContext & ctx)2281 void link_compute_shader (NegativeTestContext& ctx)
2282 {
2283 	const char* computeShaderSource		=	"#version 320 es\n"
2284 											"void main (void)\n"
2285 											"{\n"
2286 											"}\n\0";
2287 	{
2288 		const GLenum shaderTypes[]			=	{
2289 													GL_VERTEX_SHADER,
2290 													GL_FRAGMENT_SHADER,
2291 													GL_GEOMETRY_SHADER,
2292 													GL_TESS_CONTROL_SHADER,
2293 													GL_TESS_EVALUATION_SHADER
2294 												};
2295 
2296 		ctx.beginSection("Compute Shader linked with shader of other kind.");
2297 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(shaderTypes); ndx++)
2298 		{
2299 			GLint linkStatus				=	-1;
2300 			GLuint program					=	ctx.glCreateProgram();
2301 			GLuint computeShader			=	ctx.glCreateShader(GL_COMPUTE_SHADER);
2302 			GLuint otherShader				=	ctx.glCreateShader(shaderTypes[ndx]);
2303 			const char* otherShaderSource	=	(shaderTypes[ndx] != GL_GEOMETRY_SHADER)	?
2304 												computeShaderSource							:
2305 												"#version 320 es\n"
2306 												"layout(max_vertices = 3) out;\n"
2307 												"void main(void){}\n\0";
2308 
2309 			ctx.glShaderSource(computeShader, 1, &computeShaderSource, DE_NULL);
2310 			ctx.glShaderSource(otherShader, 1, &otherShaderSource, DE_NULL);
2311 			ctx.glCompileShader(computeShader);
2312 			ctx.glCompileShader(otherShader);
2313 			ctx.glAttachShader(program, computeShader);
2314 			ctx.glAttachShader(program, otherShader);
2315 			ctx.glLinkProgram(program);
2316 			ctx.glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
2317 			ctx.glDeleteShader(otherShader);
2318 			ctx.glDeleteShader(computeShader);
2319 			ctx.glDeleteProgram(program);
2320 			if (linkStatus != GL_FALSE)
2321 				ctx.fail("Program should not have linked");
2322 		}
2323 		ctx.endSection();
2324 	}
2325 	{
2326 		const char* computeShaderSource310	=	"#version 310 es\n"
2327 												"void main (void)\n"
2328 												"{\n"
2329 												"}\n\0";
2330 		GLint linkStatus					=	-1;
2331 		GLuint program						=	ctx.glCreateProgram();
2332 		GLuint computeShader				=	ctx.glCreateShader(GL_COMPUTE_SHADER);
2333 		GLuint computeShader310				=	ctx.glCreateShader(GL_FRAGMENT_SHADER);
2334 
2335 		ctx.glShaderSource(computeShader, 1, &computeShaderSource, DE_NULL);
2336 		ctx.glShaderSource(computeShader310, 1, &computeShaderSource310, DE_NULL);
2337 		ctx.beginSection("Compute Shader should not be linked with shaders of different version.");
2338 		ctx.glCompileShader(computeShader);
2339 		ctx.glCompileShader(computeShader310);
2340 		ctx.glAttachShader(program, computeShader);
2341 		ctx.glAttachShader(program, computeShader310);
2342 		ctx.glLinkProgram(program);
2343 		ctx.glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
2344 		ctx.glDeleteShader(computeShader310);
2345 		ctx.glDeleteShader(computeShader);
2346 		ctx.glDeleteProgram(program);
2347 		if (linkStatus != GL_FALSE)
2348 			ctx.fail("Program should not have linked");
2349 		ctx.endSection();
2350 	}
2351 }
2352 
compile_compute_shader_helper(NegativeTestContext & ctx,const char * const * computeShaderSource,GLint * compileStatus)2353 void compile_compute_shader_helper (NegativeTestContext& ctx, const char* const* computeShaderSource, GLint* compileStatus)
2354 {
2355 	GLuint shader = ctx.glCreateShader(GL_COMPUTE_SHADER);
2356 
2357 	*compileStatus = -1;
2358 	ctx.glShaderSource(shader, 1, computeShaderSource, DE_NULL);
2359 	ctx.glCompileShader(shader);
2360 	ctx.glGetShaderiv(shader, GL_COMPILE_STATUS, compileStatus);
2361 	ctx.glDeleteShader(shader);
2362 }
2363 
compile_compute_shader(NegativeTestContext & ctx)2364 void compile_compute_shader (NegativeTestContext& ctx)
2365 {
2366 	GLint compileStatus;
2367 	ctx.beginSection("Compile Computer Shader");
2368 
2369 	{
2370 		const char* const computeShaderSource		=	"#version 300 es\n"
2371 														"void main (void)\n"
2372 														"{\n"
2373 														"}\n";
2374 
2375 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2376 		if (compileStatus != GL_FALSE)
2377 			ctx.fail("Compute Shader should not have compiled with #version 300 es.");
2378 	}
2379 	{
2380 		const char* const computeShaderSource		=	"#version 310 es\n"
2381 														"buffer SSBO { vec4 data }"
2382 														"void main (void)\n"
2383 														"{\n"
2384 														"}\n";
2385 
2386 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2387 		if (compileStatus != GL_FALSE)
2388 			ctx.fail("Compute Shader should not have compiled: incorrect SSBO syntax.");
2389 	}
2390 	{
2391 		const char* const computeShaderSource		=	"#version 310 es\n"
2392 														"buffer SSBO { vec4 data;};"
2393 														"uniform mat4 data;"
2394 														"void main (void)\n"
2395 														"{\n"
2396 														"}\n";
2397 
2398 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2399 		if (compileStatus != GL_FALSE)
2400 			ctx.fail("Compute Shader should not have compiled: buffer variable redefinition.");
2401 	}
2402 	{
2403 		const char* const computeShaderSource		=	"#version 310 es\n"
2404 														"buffer SSBO { vec4 data[]; vec4 moreData;};"
2405 														"void main (void)\n"
2406 														"{\n"
2407 														"}\n";
2408 
2409 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2410 		if (compileStatus != GL_FALSE)
2411 			ctx.fail("Compute Shader should not have compiled: unspecified length buffer member not at the end.");
2412 	}
2413 	{
2414 		const char* const computeShaderSource		=	"#version 310 es\n"
2415 														"in vec4 data;"
2416 														"void main (void)\n"
2417 														"{\n"
2418 														"}\n";
2419 
2420 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2421 		if (compileStatus != GL_FALSE)
2422 			ctx.fail("Compute Shader should not have compiled: input qualifier used.");
2423 	}
2424 	{
2425 		const char* const computeShaderSource		=	"#version 310 es\n"
2426 														"shared uint data = 0;";
2427 
2428 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2429 		if (compileStatus != GL_FALSE)
2430 			ctx.fail("Compute Shader should not have compiled: shared-qualified variable initialized.");
2431 	}
2432 	{
2433 		const char* const computeShaderSource		=	"#version 310 es\n"
2434 														"buffer SSBO { vec4 data; vec4 moreData[];} ssbo;"
2435 														"void test (vec4 data[10]) {}"
2436 														"void main (void)\n"
2437 														"{\n"
2438 														"    test(ssbo.moreData);"
2439 														"}\n";
2440 
2441 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2442 		if (compileStatus != GL_FALSE)
2443 			ctx.fail("Compute Shader should not have compiled: unspecified length buffer member passed as argument to function.");
2444 	}
2445 	{
2446 		const char* const computeShaderSource		=	"#version 310 es\n"
2447 														"buffer SSBO { vec4 data; vec4 moreData[];} ssbo;"
2448 														"void main (void)\n"
2449 														"{\n"
2450 														"    vec4 var = ssbo.moreData[-1];"
2451 														"}\n";
2452 
2453 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2454 		if (compileStatus != GL_FALSE)
2455 			ctx.fail("Compute Shader should not have compiled: unspecified length buffer member indexed with negative constant expression.");
2456 	}
2457 	{
2458 		const char* const computeShaderSource		=	"#version 310 es\n"
2459 														"layout(binding=-1) buffer SSBO { vec4 data;};"
2460 														"void main (void)\n"
2461 														"{\n"
2462 														"}\n";
2463 
2464 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2465 		if (compileStatus != GL_FALSE)
2466 			ctx.fail("Compute Shader should not have compiled: binding point less than zero.");
2467 	}
2468 	{
2469 		const char* const computeShaderSource		=	"#version 310 es\n"
2470 														"layout(binding=1) buffer;"
2471 														"layout(binding=2) buffer SSBO { vec4 data;};"
2472 														"void main (void)\n"
2473 														"{\n"
2474 														"}\n";
2475 
2476 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2477 		if (compileStatus != GL_FALSE)
2478 			ctx.fail("Compute Shader should not have compiled: binding point specified for global scope.");
2479 	}
2480 	{
2481 		const char* const computeShaderSource		=	"#version 310 es\n"
2482 														"buffer SSBO {"
2483 														"	layout(binding=1) vec4 data;"
2484 														"	layout(binding=2) vec4 moreData[];"
2485 														"} ssbo;"
2486 														"void main (void)\n"
2487 														"{\n"
2488 														"}\n";
2489 
2490 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2491 		if (compileStatus != GL_FALSE)
2492 			ctx.fail("Compute Shader should not have compiled: binding point specified for block member declarations.");
2493 	}
2494 	{
2495 		const char* const computeShaderSource		=	"#version 310 es\n"
2496 														"readonly buffer SSBO {vec4 data;} ssbo;"
2497 														"void main (void)\n"
2498 														"{\n"
2499 															"ssbo.data = vec4(1, 1, 1, 1);"
2500 														"}\n";
2501 
2502 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2503 		if (compileStatus != GL_FALSE)
2504 			ctx.fail("Compute Shader should not have compiled: writing to buffer block qualified with readonly.");
2505 	}
2506 	{
2507 		const char* const computeShaderSource		=	"#version 310 es\n"
2508 														"writeonly buffer SSBO {vec4 data;} ssbo;"
2509 														"void main (void)\n"
2510 														"{\n"
2511 															"vec4 var = ssbo.data;"
2512 														"}\n";
2513 
2514 		compile_compute_shader_helper(ctx, &computeShaderSource, &compileStatus);
2515 		if (compileStatus != GL_FALSE)
2516 			ctx.fail("Compute Shader should not have compiled: reading from buffer block qualified with writeonly.");
2517 	}
2518 
2519 	ctx.endSection();
2520 }
2521 
srgb_decode_samplerparameteri(NegativeTestContext & ctx)2522 void srgb_decode_samplerparameteri (NegativeTestContext& ctx)
2523 {
2524 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2525 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2526 
2527 	GLuint	sampler		= 0x1234;
2528 	GLint	samplerMode	= -1;
2529 
2530 	ctx.glGenSamplers(1, &sampler);
2531 
2532 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2533 	ctx.glSamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2534 	ctx.expectError(GL_INVALID_ENUM);
2535 	ctx.endSection();
2536 
2537 	ctx.glDeleteSamplers(1, &sampler);
2538 }
2539 
srgb_decode_samplerparameterf(NegativeTestContext & ctx)2540 void srgb_decode_samplerparameterf (NegativeTestContext& ctx)
2541 {
2542 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2543 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2544 
2545 	GLuint	sampler	= 0x1234;
2546 	GLfloat	samplerMode	= -1.0f;
2547 
2548 	ctx.glGenSamplers(1, &sampler);
2549 
2550 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2551 	ctx.glSamplerParameterf(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2552 	ctx.expectError(GL_INVALID_ENUM);
2553 	ctx.endSection();
2554 
2555 	ctx.glDeleteSamplers(1, &sampler);
2556 }
2557 
srgb_decode_samplerparameteriv(NegativeTestContext & ctx)2558 void srgb_decode_samplerparameteriv (NegativeTestContext& ctx)
2559 {
2560 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2561 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2562 
2563 	int		params[1]	= { GL_LINEAR };
2564 	GLuint	sampler		= 0x1234;
2565 
2566 	ctx.glGenSamplers(1, &sampler);
2567 
2568 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2569 	params[0] = -1;
2570 	ctx.glSamplerParameteriv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, &params[0]);
2571 	ctx.expectError(GL_INVALID_ENUM);
2572 	ctx.endSection();
2573 
2574 	ctx.glDeleteSamplers(1, &sampler);
2575 }
2576 
srgb_decode_samplerparameterfv(NegativeTestContext & ctx)2577 void srgb_decode_samplerparameterfv (NegativeTestContext& ctx)
2578 {
2579 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2580 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2581 
2582 	float	params[1]	= { GL_LINEAR };
2583 	GLuint	sampler		= 0x1234;
2584 
2585 	ctx.glGenSamplers(1, &sampler);
2586 
2587 	params[0] = -1.0f;
2588 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2589 	ctx.glSamplerParameterfv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, &params[0]);
2590 	ctx.expectError(GL_INVALID_ENUM);
2591 	ctx.endSection();
2592 
2593 	ctx.glDeleteSamplers(1, &sampler);
2594 }
2595 
srgb_decode_samplerparameterIiv(NegativeTestContext & ctx)2596 void srgb_decode_samplerparameterIiv (NegativeTestContext& ctx)
2597 {
2598 	if (!supportsES32orGL45(ctx))
2599 		TCU_THROW(NotSupportedError, "glSamplerParameterIiv is not supported.");
2600 
2601 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2602 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2603 
2604 	GLint	samplerMode[]	= {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
2605 	GLuint	sampler			= 0x1234;
2606 
2607 	ctx.glGenSamplers(1, &sampler);
2608 
2609 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2610 	samplerMode[0] = -1;
2611 	samplerMode[1] = -1;
2612 	ctx.glSamplerParameterIiv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2613 	ctx.expectError(GL_INVALID_ENUM);
2614 	ctx.endSection();
2615 
2616 	ctx.glDeleteSamplers(1, &sampler);
2617 }
2618 
srgb_decode_samplerparameterIuiv(NegativeTestContext & ctx)2619 void srgb_decode_samplerparameterIuiv (NegativeTestContext& ctx)
2620 {
2621 	if (!supportsES32orGL45(ctx))
2622 		TCU_THROW(NotSupportedError, "glSamplerParameterIuiv is not supported.");
2623 
2624 	if (!ctx.isExtensionSupported("GL_EXT_texture_sRGB_decode"))
2625 		TCU_THROW(NotSupportedError, "GL_EXT_texture_sRGB_decode is not supported.");
2626 
2627 	GLuint	samplerMode[]	= {GL_DEPTH_COMPONENT, GL_STENCIL_INDEX};
2628 	GLuint	sampler			= 0x1234;
2629 
2630 	ctx.glGenSamplers(1, &sampler);
2631 
2632 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is GL_TEXTURE_SRGB_DECODE_EXT and the value of param(s) is not a valid value (one of DECODE_EXT, or SKIP_DECODE_EXT).");
2633 	samplerMode[0] = GL_DONT_CARE;
2634 	samplerMode[1] = GL_DONT_CARE;
2635 	ctx.glSamplerParameterIuiv(sampler, GL_TEXTURE_SRGB_DECODE_EXT, samplerMode);
2636 	ctx.expectError(GL_INVALID_ENUM);
2637 	ctx.endSection();
2638 
2639 	ctx.glDeleteSamplers(1, &sampler);
2640 }
2641 
getNegativeShaderApiTestFunctions()2642 std::vector<FunctionContainer> getNegativeShaderApiTestFunctions ()
2643 {
2644 	FunctionContainer funcs[] =
2645 	{
2646 		{create_shader,							"create_shader",						"Invalid glCreateShader() usage"			   },
2647 		{shader_source,							"shader_source",						"Invalid glShaderSource() usage"			   },
2648 		{compile_shader,						"compile_shader",						"Invalid glCompileShader() usage"			   },
2649 		{delete_shader,							"delete_shader",						"Invalid glDeleteShader() usage"			   },
2650 		{shader_binary,							"shader_binary",						"Invalid glShaderBinary() usage"			   },
2651 		{attach_shader,							"attach_shader",						"Invalid glAttachShader() usage"			   },
2652 		{detach_shader,							"detach_shader",						"Invalid glDetachShader() usage"			   },
2653 		{link_program,							"link_program",							"Invalid glLinkProgram() usage"				   },
2654 		{use_program,							"use_program",							"Invalid glUseProgram() usage"				   },
2655 		{delete_program,						"delete_program",						"Invalid glDeleteProgram() usage"			   },
2656 		{validate_program,						"validate_program",						"Invalid glValidateProgram() usage"			   },
2657 		{get_program_binary,					"get_program_binary",					"Invalid glGetProgramBinary() usage"		   },
2658 		{program_binary,						"program_binary",						"Invalid glProgramBinary() usage"			   },
2659 		{program_parameteri,					"program_parameteri",					"Invalid glProgramParameteri() usage"		   },
2660 		{gen_samplers,							"gen_samplers",							"Invalid glGenSamplers() usage"				   },
2661 		{bind_sampler,							"bind_sampler",							"Invalid glBindSampler() usage"				   },
2662 		{delete_samplers,						"delete_samplers",						"Invalid glDeleteSamplers() usage"			   },
2663 		{get_sampler_parameteriv,				"get_sampler_parameteriv",				"Invalid glGetSamplerParameteriv() usage"	   },
2664 		{get_sampler_parameterfv,				"get_sampler_parameterfv",				"Invalid glGetSamplerParameterfv() usage"	   },
2665 		{get_sampler_parameterIiv,				"get_sampler_parameterIiv",				"Invalid glGetSamplerParameterIiv() usage"	   },
2666 		{get_sampler_parameterIuiv,				"get_sampler_parameterIuiv",			"Invalid glGetSamplerParameterIuiv() usage"	   },
2667 		{sampler_parameteri,					"sampler_parameteri",					"Invalid glSamplerParameteri() usage"		   },
2668 		{sampler_parameteriv,					"sampler_parameteriv",					"Invalid glSamplerParameteriv() usage"		   },
2669 		{sampler_parameterf,					"sampler_parameterf",					"Invalid glSamplerParameterf() usage"		   },
2670 		{sampler_parameterfv,					"sampler_parameterfv",					"Invalid glSamplerParameterfv() usage"		   },
2671 		{sampler_parameterIiv,					"sampler_parameterIiv",					"Invalid glSamplerParameterIiv() usage"		   },
2672 		{sampler_parameterIuiv,					"sampler_parameterIuiv",				"Invalid glSamplerParameterIuiv() usage"	   },
2673 		{get_attrib_location,					"get_attrib_location",					"Invalid glGetAttribLocation() usage"		   },
2674 		{get_uniform_location,					"get_uniform_location",					"Invalid glGetUniformLocation() usage"		   },
2675 		{bind_attrib_location,					"bind_attrib_location",					"Invalid glBindAttribLocation() usage"		   },
2676 		{uniform_block_binding,					"uniform_block_binding",				"Invalid glUniformBlockBinding() usage"		   },
2677 		{uniformf_invalid_program,				"uniformf_invalid_program",				"Invalid glUniform{1234}f() usage"			   },
2678 		{uniformf_incompatible_type,			"uniformf_incompatible_type",			"Invalid glUniform{1234}f() usage"			   },
2679 		{uniformf_invalid_location,				"uniformf_invalid_location",			"Invalid glUniform{1234}f() usage"			   },
2680 		{uniformfv_invalid_program,				"uniformfv_invalid_program",			"Invalid glUniform{1234}fv() usage"			   },
2681 		{uniformfv_incompatible_type,			"uniformfv_incompatible_type",			"Invalid glUniform{1234}fv() usage"			   },
2682 		{uniformfv_invalid_location,			"uniformfv_invalid_location",			"Invalid glUniform{1234}fv() usage"			   },
2683 		{uniformfv_invalid_count,				"uniformfv_invalid_count",				"Invalid glUniform{1234}fv() usage"			   },
2684 		{uniformi_invalid_program,				"uniformi_invalid_program",				"Invalid glUniform{1234}i() usage"			   },
2685 		{uniformi_incompatible_type,			"uniformi_incompatible_type",			"Invalid glUniform{1234}i() usage"			   },
2686 		{uniformi_invalid_location,				"uniformi_invalid_location",			"Invalid glUniform{1234}i() usage"			   },
2687 		{uniformiv_invalid_program,				"uniformiv_invalid_program",			"Invalid glUniform{1234}iv() usage"			   },
2688 		{uniformiv_incompatible_type,			"uniformiv_incompatible_type",			"Invalid glUniform{1234}iv() usage"			   },
2689 		{uniformiv_invalid_location,			"uniformiv_invalid_location",			"Invalid glUniform{1234}iv() usage"			   },
2690 		{uniformiv_invalid_count,				"uniformiv_invalid_count",				"Invalid glUniform{1234}iv() usage"			   },
2691 		{uniformui_invalid_program,				"uniformui_invalid_program",			"Invalid glUniform{234}ui() usage"			   },
2692 		{uniformui_incompatible_type,			"uniformui_incompatible_type",			"Invalid glUniform{1234}ui() usage"			   },
2693 		{uniformui_invalid_location,			"uniformui_invalid_location",			"Invalid glUniform{1234}ui() usage"			   },
2694 		{uniformuiv_invalid_program,			"uniformuiv_invalid_program",			"Invalid glUniform{234}uiv() usage"			   },
2695 		{uniformuiv_incompatible_type,			"uniformuiv_incompatible_type",			"Invalid glUniform{1234}uiv() usage"		   },
2696 		{uniformuiv_invalid_location,			"uniformuiv_invalid_location",			"Invalid glUniform{1234}uiv() usage"		   },
2697 		{uniformuiv_invalid_count,				"uniformuiv_invalid_count",				"Invalid glUniform{1234}uiv() usage"		   },
2698 		{uniform_matrixfv_invalid_program,		"uniform_matrixfv_invalid_program",		"Invalid glUniformMatrix{234}fv() usage"	   },
2699 		{uniform_matrixfv_incompatible_type,	"uniform_matrixfv_incompatible_type",	"Invalid glUniformMatrix{234}fv() usage"	   },
2700 		{uniform_matrixfv_invalid_location,		"uniform_matrixfv_invalid_location",	"Invalid glUniformMatrix{234}fv() usage"	   },
2701 		{uniform_matrixfv_invalid_count,		"uniform_matrixfv_invalid_count",		"Invalid glUniformMatrix{234}fv() usage"	   },
2702 		{gen_transform_feedbacks,				"gen_transform_feedbacks",				"Invalid glGenTransformFeedbacks() usage"	   },
2703 		{bind_transform_feedback,				"bind_transform_feedback",				"Invalid glBindTransformFeedback() usage"	   },
2704 		{delete_transform_feedbacks,			"delete_transform_feedbacks",			"Invalid glDeleteTransformFeedbacks() usage"   },
2705 		{begin_transform_feedback,				"begin_transform_feedback",				"Invalid glBeginTransformFeedback() usage"	   },
2706 		{pause_transform_feedback,				"pause_transform_feedback",				"Invalid glPauseTransformFeedback() usage"	   },
2707 		{resume_transform_feedback,				"resume_transform_feedback",			"Invalid glResumeTransformFeedback() usage"	   },
2708 		{end_transform_feedback,				"end_transform_feedback",				"Invalid glEndTransformFeedback() usage"	   },
2709 		{get_transform_feedback_varying,		"get_transform_feedback_varying",		"Invalid glGetTransformFeedbackVarying() usage"},
2710 		{transform_feedback_varyings,			"transform_feedback_varyings",			"Invalid glTransformFeedbackVaryings() usage"  },
2711 		{compile_compute_shader,				"compile_compute_shader",				"Invalid Compute Shader compilation"		   },
2712 		{link_compute_shader,					"link_compute_shader",					"Invalid Compute Shader linkage"			   },
2713 		{srgb_decode_samplerparameteri,			"srgb_decode_samplerparameteri",		"Invalid glSamplerParameteri() usage srgb"	   },
2714 		{srgb_decode_samplerparameterf,			"srgb_decode_samplerparameterf",		"Invalid glSamplerParameterf() usage srgb"	   },
2715 		{srgb_decode_samplerparameteriv,		"srgb_decode_samplerparameteriv",		"Invalid glSamplerParameteriv() usage srgb"	   },
2716 		{srgb_decode_samplerparameterfv,		"srgb_decode_samplerparameterfv",		"Invalid glSamplerParameterfv() usage srgb"	   },
2717 		{srgb_decode_samplerparameterIiv,		"srgb_decode_samplerparameterIiv",		"Invalid glSamplerParameterIiv() usage srgb"   },
2718 		{srgb_decode_samplerparameterIuiv,		"srgb_decode_samplerparameterIuiv",		"Invalid glSamplerParameterIiuv() usage srgb"  },
2719 	};
2720 
2721 	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
2722 }
2723 
2724 } // NegativeTestShared
2725 } // Functional
2726 } // gles31
2727 } // deqp
2728