1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Negative GL State API tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es31fNegativeStateApiTests.hpp"
25 
26 #include "gluCallLogWrapper.hpp"
27 #include "gluContextInfo.hpp"
28 #include "gluShaderProgram.hpp"
29 
30 #include "glwDefs.hpp"
31 #include "glwEnums.hpp"
32 
33 #include "tcuStringTemplate.hpp"
34 
35 #include "deMemory.h"
36 
37 #include <string>
38 #include <map>
39 
40 namespace deqp
41 {
42 namespace gles31
43 {
44 namespace Functional
45 {
46 namespace NegativeTestShared
47 {
48 
49 using tcu::TestLog;
50 using glu::CallLogWrapper;
51 using namespace glw;
52 
53 static const char* uniformTestVertSource	=	"${GLSL_VERSION_DECL}\n"
54 												"uniform mediump vec4 vUnif_vec4;\n"
55 												"in mediump vec4 attr;"
56 												"layout(shared) uniform Block { mediump vec4 blockVar; };\n"
57 												"void main (void)\n"
58 												"{\n"
59 												"	gl_Position = vUnif_vec4 + blockVar + attr;\n"
60 												"}\n\0";
61 
62 static const char* uniformTestFragSource	=	"${GLSL_VERSION_DECL}\n"
63 												"uniform mediump ivec4 fUnif_ivec4;\n"
64 												"uniform mediump uvec4 fUnif_uvec4;\n"
65 												"layout(location = 0) out mediump vec4 fragColor;"
66 												"void main (void)\n"
67 												"{\n"
68 												"	fragColor = vec4(vec4(fUnif_ivec4) + vec4(fUnif_uvec4));\n"
69 												"}\n\0";
70 
getVtxFragVersionSources(const std::string source,NegativeTestContext & ctx)71 static std::string getVtxFragVersionSources (const std::string source, NegativeTestContext& ctx)
72 {
73 	const bool supportsES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
74 
75 	std::map<std::string, std::string> args;
76 
77 	args["GLSL_VERSION_DECL"] = supportsES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_300_ES);
78 
79 	return tcu::StringTemplate(source).specialize(args);
80 }
81 
82 // Enabling & disabling states
enable(NegativeTestContext & ctx)83 void enable (NegativeTestContext& ctx)
84 {
85 	ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
86 	ctx.glEnable(-1);
87 	ctx.expectError(GL_INVALID_ENUM);
88 	ctx.endSection();
89 }
90 
91 // Enabling & disabling states
enablei(NegativeTestContext & ctx)92 void enablei (NegativeTestContext& ctx)
93 {
94 	TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
95 
96 	ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
97 	ctx.glEnablei(-1, -1);
98 	ctx.expectError(GL_INVALID_ENUM);
99 	ctx.endSection();
100 
101 	ctx.beginSection("GL_INVALID_VALUE is generated  if index is greater than or equal to the number of indexed capabilities for cap.");
102 	ctx.glEnablei(GL_BLEND, -1);
103 	ctx.expectError(GL_INVALID_VALUE);
104 	ctx.endSection();
105 }
106 
disable(NegativeTestContext & ctx)107 void disable (NegativeTestContext& ctx)
108 {
109 	ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
110 	ctx.glDisable(-1);
111 	ctx.expectError(GL_INVALID_ENUM);
112 	ctx.endSection();
113 }
114 
disablei(NegativeTestContext & ctx)115 void disablei (NegativeTestContext& ctx)
116 {
117 	TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
118 
119 	ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
120 	ctx.glDisablei(-1,-1);
121 	ctx.expectError(GL_INVALID_ENUM);
122 	ctx.endSection();
123 
124 	ctx.beginSection("GL_INVALID_VALUE is generated  if index is greater than or equal to the number of indexed capabilities for cap.");
125 	ctx.glDisablei(GL_BLEND, -1);
126 	ctx.expectError(GL_INVALID_VALUE);
127 	ctx.endSection();
128 }
129 
130 // Simple state queries
get_booleanv(NegativeTestContext & ctx)131 void get_booleanv (NegativeTestContext& ctx)
132 {
133 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
134 	GLboolean params = GL_FALSE;
135 	ctx.glGetBooleanv(-1, &params);
136 	ctx.expectError(GL_INVALID_ENUM);
137 	ctx.endSection();
138 }
139 
get_booleani_v(NegativeTestContext & ctx)140 void get_booleani_v (NegativeTestContext& ctx)
141 {
142 	GLboolean	data						= -1;
143 	GLint		maxUniformBufferBindings	= 0;
144 
145 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not indexed state queriable with these commands.");
146 	ctx.glGetBooleani_v(-1, 0, &data);
147 	ctx.expectError(GL_INVALID_ENUM);
148 	ctx.endSection();
149 
150 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
151 	ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
152 	ctx.expectError(GL_NO_ERROR);
153 	ctx.glGetBooleani_v(GL_UNIFORM_BUFFER_BINDING, maxUniformBufferBindings, &data);
154 	ctx.expectError(GL_INVALID_VALUE);
155 	ctx.endSection();
156 }
157 
get_floatv(NegativeTestContext & ctx)158 void get_floatv (NegativeTestContext& ctx)
159 {
160 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
161 	GLfloat params = 0.0f;
162 	ctx.glGetFloatv(-1, &params);
163 	ctx.expectError(GL_INVALID_ENUM);
164 	ctx.endSection();
165 }
166 
get_integerv(NegativeTestContext & ctx)167 void get_integerv (NegativeTestContext& ctx)
168 {
169 	GLint params = -1;
170 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
171 	ctx.glGetIntegerv(-1, &params);
172 	ctx.expectError(GL_INVALID_ENUM);
173 	ctx.endSection();
174 }
175 
get_integer64v(NegativeTestContext & ctx)176 void get_integer64v (NegativeTestContext& ctx)
177 {
178 	GLint64 params = -1;
179 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
180 	ctx.glGetInteger64v(-1, &params);
181 	ctx.expectError(GL_INVALID_ENUM);
182 	ctx.endSection();
183 }
184 
get_integeri_v(NegativeTestContext & ctx)185 void get_integeri_v (NegativeTestContext& ctx)
186 {
187 	GLint data								= -1;
188 	GLint maxUniformBufferBindings			=  0;
189 	GLint maxShaderStorageBufferBindings	=  0;
190 
191 	ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
192 	ctx.glGetIntegeri_v(-1, 0, &data);
193 	ctx.expectError(GL_INVALID_ENUM);
194 	ctx.endSection();
195 
196 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
197 	ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
198 	ctx.expectError(GL_NO_ERROR);
199 	ctx.glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, maxUniformBufferBindings, &data);
200 	ctx.expectError(GL_INVALID_VALUE);
201 	ctx.endSection();
202 
203 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
204 	ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxShaderStorageBufferBindings);
205 	ctx.expectError(GL_NO_ERROR);
206 	ctx.glGetIntegeri_v(GL_SHADER_STORAGE_BUFFER_BINDING, maxShaderStorageBufferBindings, &data);
207 	ctx.expectError(GL_INVALID_VALUE);
208 	ctx.endSection();
209 }
210 
get_integer64i_v(NegativeTestContext & ctx)211 void get_integer64i_v (NegativeTestContext& ctx)
212 {
213 	GLint64	data							= (GLint64)-1;
214 	GLint	maxUniformBufferBindings		= 0;
215 	GLint	maxShaderStorageBufferBindings	= 0;
216 
217 	ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
218 	ctx.glGetInteger64i_v(-1, 0, &data);
219 	ctx.expectError(GL_INVALID_ENUM);
220 	ctx.endSection();
221 
222 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
223 	ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
224 	ctx.expectError(GL_NO_ERROR);
225 	ctx.glGetInteger64i_v(GL_UNIFORM_BUFFER_START, maxUniformBufferBindings, &data);
226 	ctx.expectError(GL_INVALID_VALUE);
227 	ctx.endSection();
228 
229 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
230 	ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxShaderStorageBufferBindings);
231 	ctx.expectError(GL_NO_ERROR);
232 	ctx.glGetInteger64i_v(GL_SHADER_STORAGE_BUFFER_START, maxShaderStorageBufferBindings, &data);
233 	ctx.expectError(GL_INVALID_VALUE);
234 	ctx.glGetInteger64i_v(GL_SHADER_STORAGE_BUFFER_SIZE, maxShaderStorageBufferBindings, &data);
235 	ctx.expectError(GL_INVALID_VALUE);
236 	ctx.endSection();
237 }
238 
get_string(NegativeTestContext & ctx)239 void get_string (NegativeTestContext& ctx)
240 {
241 	ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
242 	ctx.glGetString(-1);
243 	ctx.expectError(GL_INVALID_ENUM);
244 	ctx.endSection();
245 }
246 
get_stringi(NegativeTestContext & ctx)247 void get_stringi (NegativeTestContext& ctx)
248 {
249 	GLint numExtensions	= 0;
250 
251 	ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
252 	ctx.glGetStringi(-1, 0);
253 	ctx.expectError(GL_INVALID_ENUM);
254 	ctx.endSection();
255 
256 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside the valid range for indexed state name.");
257 	ctx.glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
258 	ctx.glGetStringi(GL_EXTENSIONS, numExtensions);
259 	ctx.expectError(GL_INVALID_VALUE);
260 	ctx.endSection();
261 }
262 
263 // Enumerated state queries: Shaders
264 
get_attached_shaders(NegativeTestContext & ctx)265 void get_attached_shaders (NegativeTestContext& ctx)
266 {
267 	GLuint	shaders[1]		= { 0 };
268 	GLuint	shaderObject	= ctx.glCreateShader(GL_VERTEX_SHADER);
269 	GLuint	program			= ctx.glCreateProgram();
270 	GLsizei	count[1]		= { 0 };
271 
272 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
273 	ctx.glGetAttachedShaders(-1, 1, &count[0], &shaders[0]);
274 	ctx.expectError(GL_INVALID_VALUE);
275 	ctx.endSection();
276 
277 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
278 	ctx.glGetAttachedShaders(shaderObject, 1, &count[0], &shaders[0]);
279 	ctx.expectError(GL_INVALID_OPERATION);
280 	ctx.endSection();
281 
282 	ctx.beginSection("GL_INVALID_VALUE is generated if maxCount is less than 0.");
283 	ctx.glGetAttachedShaders(program, -1, &count[0], &shaders[0]);
284 	ctx.expectError(GL_INVALID_VALUE);
285 	ctx.endSection();
286 
287 	ctx.glDeleteShader(shaderObject);
288 	ctx.glDeleteProgram(program);
289 }
290 
get_shaderiv(NegativeTestContext & ctx)291 void get_shaderiv (NegativeTestContext& ctx)
292 {
293 	GLboolean	shaderCompilerSupported;
294 	GLuint		shader		= ctx.glCreateShader(GL_VERTEX_SHADER);
295 	GLuint		program		= ctx.glCreateProgram();
296 	GLint		param[1]	= { -1 };
297 
298 	ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
299 	ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
300 
301 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
302 	ctx.glGetShaderiv(shader, -1, &param[0]);
303 	ctx.expectError(GL_INVALID_ENUM);
304 	ctx.endSection();
305 
306 	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
307 	ctx.glGetShaderiv(-1, GL_SHADER_TYPE, &param[0]);
308 	ctx.expectError(GL_INVALID_VALUE);
309 	ctx.endSection();
310 
311 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader does not refer to a shader object.");
312 	ctx.glGetShaderiv(program, GL_SHADER_TYPE, &param[0]);
313 	ctx.expectError(GL_INVALID_OPERATION);
314 	ctx.endSection();
315 
316 	ctx.glDeleteShader(shader);
317 	ctx.glDeleteProgram(program);
318 }
319 
get_shader_info_log(NegativeTestContext & ctx)320 void get_shader_info_log (NegativeTestContext& ctx)
321 {
322 	GLuint shader		= ctx.glCreateShader(GL_VERTEX_SHADER);
323 	GLuint program		= ctx.glCreateProgram();
324 	GLsizei length[1]	= { -1 };
325 	char infoLog[128]	= { 0 };
326 
327 	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
328 	ctx.glGetShaderInfoLog(-1, 128, &length[0], &infoLog[0]);
329 	ctx.expectError(GL_INVALID_VALUE);
330 	ctx.endSection();
331 
332 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
333 	ctx.glGetShaderInfoLog(program, 128, &length[0], &infoLog[0]);
334 	ctx.expectError(GL_INVALID_OPERATION);
335 	ctx.endSection();
336 
337 	ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0.");
338 	ctx.glGetShaderInfoLog(shader, -1, &length[0], &infoLog[0]);
339 	ctx.expectError(GL_INVALID_VALUE);
340 	ctx.endSection();
341 
342 	ctx.glDeleteShader(shader);
343 	ctx.glDeleteProgram(program);
344 }
345 
get_shader_precision_format(NegativeTestContext & ctx)346 void get_shader_precision_format (NegativeTestContext& ctx)
347 {
348 	GLboolean	shaderCompilerSupported;
349 	GLint		range[2];
350 	GLint		precision[1];
351 
352 	ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
353 	ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
354 
355 	deMemset(&range[0], 0xcd, sizeof(range));
356 	deMemset(&precision[0], 0xcd, sizeof(precision));
357 
358 	ctx.beginSection("GL_INVALID_ENUM is generated if shaderType or precisionType is not an accepted value.");
359 	ctx.glGetShaderPrecisionFormat (-1, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
360 	ctx.expectError(GL_INVALID_ENUM);
361 	ctx.glGetShaderPrecisionFormat (GL_VERTEX_SHADER, -1, &range[0], &precision[0]);
362 	ctx.expectError(GL_INVALID_ENUM);
363 	ctx.glGetShaderPrecisionFormat (-1, -1, &range[0], &precision[0]);
364 	ctx.expectError(GL_INVALID_ENUM);
365 	ctx.endSection();
366 }
367 
get_shader_source(NegativeTestContext & ctx)368 void get_shader_source (NegativeTestContext& ctx)
369 {
370 	GLsizei	length[1]	= { 0 };
371 	char	source[1]	= { 0 };
372 	GLuint	program		= ctx.glCreateProgram();
373 	GLuint	shader		= ctx.glCreateShader(GL_VERTEX_SHADER);
374 
375 	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
376 	ctx.glGetShaderSource(-1, 1, &length[0], &source[0]);
377 	ctx.expectError(GL_INVALID_VALUE);
378 	ctx.endSection();
379 
380 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
381 	ctx.glGetShaderSource(program, 1, &length[0], &source[0]);
382 	ctx.expectError(GL_INVALID_OPERATION);
383 	ctx.endSection();
384 
385 	ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
386 	ctx.glGetShaderSource(shader, -1, &length[0], &source[0]);
387 	ctx.expectError(GL_INVALID_VALUE);
388 	ctx.endSection();
389 
390 	ctx.glDeleteProgram(program);
391 	ctx.glDeleteShader(shader);
392 }
393 
394 // Enumerated state queries: Programs
395 
get_programiv(NegativeTestContext & ctx)396 void get_programiv (NegativeTestContext& ctx)
397 {
398 	GLuint	program		= ctx.glCreateProgram();
399 	GLuint	shader		= ctx.glCreateShader(GL_VERTEX_SHADER);
400 	GLint	params[1]	= { 0 };
401 
402 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
403 	ctx.glGetProgramiv(program, -1, &params[0]);
404 	ctx.expectError(GL_INVALID_ENUM);
405 	ctx.endSection();
406 
407 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
408 	ctx.glGetProgramiv(-1, GL_LINK_STATUS, &params[0]);
409 	ctx.expectError(GL_INVALID_VALUE);
410 	ctx.endSection();
411 
412 	ctx.beginSection("GL_INVALID_OPERATION is generated if program does not refer to a program object.");
413 	ctx.glGetProgramiv(shader, GL_LINK_STATUS, &params[0]);
414 	ctx.expectError(GL_INVALID_OPERATION);
415 	ctx.endSection();
416 
417 	ctx.glDeleteProgram(program);
418 	ctx.glDeleteShader(shader);
419 }
420 
get_program_info_log(NegativeTestContext & ctx)421 void get_program_info_log (NegativeTestContext& ctx)
422 {
423 	GLuint	program		= ctx.glCreateProgram();
424 	GLuint	shader		= ctx.glCreateShader(GL_VERTEX_SHADER);
425 	GLsizei	length[1]	= { 0 };
426 	char	infoLog[1]	= { 'x' };
427 
428 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
429 	ctx.glGetProgramInfoLog (-1, 1, &length[0], &infoLog[0]);
430 	ctx.expectError(GL_INVALID_VALUE);
431 	ctx.endSection();
432 
433 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
434 	ctx.glGetProgramInfoLog (shader, 1, &length[0], &infoLog[0]);
435 	ctx.expectError(GL_INVALID_OPERATION);
436 	ctx.endSection();
437 
438 	ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0.");
439 	ctx.glGetProgramInfoLog (program, -1, &length[0], &infoLog[0]);
440 	ctx.expectError(GL_INVALID_VALUE);
441 	ctx.endSection();
442 
443 	ctx.glDeleteProgram(program);
444 	ctx.glDeleteShader(shader);
445 }
446 
447 // Enumerated state queries: Shader variables
448 
get_tex_parameterfv(NegativeTestContext & ctx)449 void get_tex_parameterfv (NegativeTestContext& ctx)
450 {
451 	GLfloat params[1] = { 0 };
452 
453 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
454 	ctx.glGetTexParameterfv (-1, GL_TEXTURE_MAG_FILTER, &params[0]);
455 	ctx.expectError(GL_INVALID_ENUM);
456 	ctx.glGetTexParameterfv (GL_TEXTURE_2D, -1, &params[0]);
457 	ctx.expectError(GL_INVALID_ENUM);
458 	ctx.glGetTexParameterfv (-1, -1, &params[0]);
459 	ctx.expectError(GL_INVALID_ENUM);
460 	ctx.endSection();
461 }
462 
get_tex_parameteriv(NegativeTestContext & ctx)463 void get_tex_parameteriv (NegativeTestContext& ctx)
464 {
465 	GLint params[1] = { 0 };
466 
467 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
468 	ctx.glGetTexParameteriv (-1, GL_TEXTURE_MAG_FILTER, &params[0]);
469 	ctx.expectError(GL_INVALID_ENUM);
470 	ctx.glGetTexParameteriv (GL_TEXTURE_2D, -1, &params[0]);
471 	ctx.expectError(GL_INVALID_ENUM);
472 	ctx.glGetTexParameteriv (-1, -1, &params[0]);
473 	ctx.expectError(GL_INVALID_ENUM);
474 	ctx.endSection();
475 }
476 
get_tex_parameteriiv(NegativeTestContext & ctx)477 void get_tex_parameteriiv (NegativeTestContext& ctx)
478 {
479 	TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
480 
481 	GLint params[1] = { 0 };
482 
483 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
484 	ctx.glGetTexParameterIiv(-1, GL_TEXTURE_MAG_FILTER, &params[0]);
485 	ctx.expectError(GL_INVALID_ENUM);
486 	ctx.glGetTexParameterIiv(GL_TEXTURE_2D, -1, &params[0]);
487 	ctx.expectError(GL_INVALID_ENUM);
488 	ctx.glGetTexParameterIiv(-1, -1, &params[0]);
489 	ctx.expectError(GL_INVALID_ENUM);
490 	ctx.endSection();
491 }
492 
get_tex_parameteriuiv(NegativeTestContext & ctx)493 void get_tex_parameteriuiv (NegativeTestContext& ctx)
494 {
495 	TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
496 
497 	GLuint params[1] = { 0 };
498 
499 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
500 	ctx.glGetTexParameterIuiv(-1, GL_TEXTURE_MAG_FILTER, &params[0]);
501 	ctx.expectError(GL_INVALID_ENUM);
502 	ctx.glGetTexParameterIuiv(GL_TEXTURE_2D, -1, &params[0]);
503 	ctx.expectError(GL_INVALID_ENUM);
504 	ctx.glGetTexParameterIuiv(-1, -1, &params[0]);
505 	ctx.expectError(GL_INVALID_ENUM);
506 	ctx.endSection();
507 }
508 
get_uniformfv(NegativeTestContext & ctx)509 void get_uniformfv (NegativeTestContext& ctx)
510 {
511 	glu::ShaderProgram	program		(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
512 	GLfloat				params[4]	= { 0.f };
513 	GLuint				shader;
514 	GLuint				programEmpty;
515 	GLint				unif;
516 
517 	ctx.glUseProgram(program.getProgram());
518 
519 	unif = ctx.glGetUniformLocation(program.getProgram(), "vUnif_vec4");	// vec4
520 	if (unif == -1)
521 		ctx.fail("Failed to retrieve uniform location");
522 
523 	shader = ctx.glCreateShader(GL_VERTEX_SHADER);
524 	programEmpty = ctx.glCreateProgram();
525 
526 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
527 	ctx.glGetUniformfv (-1, unif, &params[0]);
528 	ctx.expectError(GL_INVALID_VALUE);
529 	ctx.endSection();
530 
531 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
532 	ctx.glGetUniformfv (shader, unif, &params[0]);
533 	ctx.expectError(GL_INVALID_OPERATION);
534 	ctx.endSection();
535 
536 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
537 	ctx.glGetUniformfv (programEmpty, unif, &params[0]);
538 	ctx.expectError(GL_INVALID_OPERATION);
539 	ctx.endSection();
540 
541 	ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
542 	ctx.glGetUniformfv (program.getProgram(), -1, &params[0]);
543 	ctx.expectError(GL_INVALID_OPERATION);
544 	ctx.endSection();
545 
546 	ctx.glDeleteShader(shader);
547 	ctx.glDeleteProgram(programEmpty);
548 }
549 
get_nuniformfv(NegativeTestContext & ctx)550 void get_nuniformfv (NegativeTestContext& ctx)
551 {
552 	TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
553 
554 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
555 	GLint				unif			= ctx.glGetUniformLocation(program.getProgram(), "vUnif_vec4");
556 	GLfloat				params[4]		= { 0.0f, 0.0f, 0.0f, 0.0f };
557 	GLuint				shader;
558 	GLuint				programEmpty;
559 	GLsizei				bufferSize;
560 
561 	ctx.glUseProgram(program.getProgram());
562 
563 	if (unif == -1)
564 		ctx.fail("Failed to retrieve uniform location");
565 
566 	shader			= ctx.glCreateShader(GL_VERTEX_SHADER);
567 	programEmpty	= ctx.glCreateProgram();
568 
569 	ctx.glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &bufferSize);
570 
571 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
572 	ctx.glGetnUniformfv(-1, unif, bufferSize, &params[0]);
573 	ctx.expectError(GL_INVALID_VALUE);
574 	ctx.endSection();
575 
576 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
577 	ctx.glGetnUniformfv(shader, unif, bufferSize, &params[0]);
578 	ctx.expectError(GL_INVALID_OPERATION);
579 	ctx.endSection();
580 
581 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
582 	ctx.glGetnUniformfv(programEmpty, unif, bufferSize, &params[0]);
583 	ctx.expectError(GL_INVALID_OPERATION);
584 	ctx.endSection();
585 
586 	ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
587 	ctx.glGetnUniformfv(program.getProgram(), -1, bufferSize, &params[0]);
588 	ctx.expectError(GL_INVALID_OPERATION);
589 	ctx.endSection();
590 
591 	ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer size required to store the requested data is greater than bufSize.");
592 	ctx.glGetnUniformfv(program.getProgram(), unif, 0, &params[0]);
593 	ctx.expectError(GL_INVALID_OPERATION);
594 	ctx.endSection();
595 
596 	ctx.glDeleteShader(shader);
597 	ctx.glDeleteProgram(programEmpty);
598 }
599 
get_uniformiv(NegativeTestContext & ctx)600 void get_uniformiv (NegativeTestContext& ctx)
601 {
602 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
603 	GLint				unif			= ctx.glGetUniformLocation(program.getProgram(), "fUnif_ivec4");
604 	GLint				params[4]		= { 0, 0, 0, 0 };
605 	GLuint				shader;
606 	GLuint				programEmpty;
607 
608 	ctx.glUseProgram(program.getProgram());
609 
610 	if (unif == -1)
611 		ctx.fail("Failed to retrieve uniform location");
612 
613 	shader = ctx.glCreateShader(GL_VERTEX_SHADER);
614 	programEmpty = ctx.glCreateProgram();
615 
616 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
617 	ctx.glGetUniformiv (-1, unif, &params[0]);
618 	ctx.expectError(GL_INVALID_VALUE);
619 	ctx.endSection();
620 
621 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
622 	ctx.glGetUniformiv (shader, unif, &params[0]);
623 	ctx.expectError(GL_INVALID_OPERATION);
624 	ctx.endSection();
625 
626 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
627 	ctx.glGetUniformiv (programEmpty, unif, &params[0]);
628 	ctx.expectError(GL_INVALID_OPERATION);
629 	ctx.endSection();
630 
631 	ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
632 	ctx.glGetUniformiv (program.getProgram(), -1, &params[0]);
633 	ctx.expectError(GL_INVALID_OPERATION);
634 	ctx.endSection();
635 
636 	ctx.glDeleteShader(shader);
637 	ctx.glDeleteProgram(programEmpty);
638 }
639 
get_nuniformiv(NegativeTestContext & ctx)640 void get_nuniformiv (NegativeTestContext& ctx)
641 {
642 	TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
643 
644 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
645 	GLint				unif			= ctx.glGetUniformLocation(program.getProgram(), "fUnif_ivec4");
646 	GLint				params[4]		= { 0, 0, 0, 0 };
647 	GLuint				shader;
648 	GLuint				programEmpty;
649 	GLsizei				bufferSize;
650 
651 	ctx.glUseProgram(program.getProgram());
652 
653 	if (unif == -1)
654 		ctx.fail("Failed to retrieve uniform location");
655 
656 	shader = ctx.glCreateShader(GL_VERTEX_SHADER);
657 	programEmpty = ctx.glCreateProgram();
658 
659 	ctx.glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &bufferSize);
660 
661 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
662 	ctx.glGetnUniformiv(-1, unif, bufferSize, &params[0]);
663 	ctx.expectError(GL_INVALID_VALUE);
664 	ctx.endSection();
665 
666 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
667 	ctx.glGetnUniformiv(shader, unif, bufferSize, &params[0]);
668 	ctx.expectError(GL_INVALID_OPERATION);
669 	ctx.endSection();
670 
671 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
672 	ctx.glGetnUniformiv(programEmpty, unif, bufferSize, &params[0]);
673 	ctx.expectError(GL_INVALID_OPERATION);
674 	ctx.endSection();
675 
676 	ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
677 	ctx.glGetnUniformiv(program.getProgram(), -1, bufferSize, &params[0]);
678 	ctx.expectError(GL_INVALID_OPERATION);
679 	ctx.endSection();
680 
681 	ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer size required to store the requested data is greater than bufSize.");
682 	ctx.glGetnUniformiv(program.getProgram(), unif, - 1, &params[0]);
683 	ctx.expectError(GL_INVALID_OPERATION);
684 	ctx.endSection();
685 
686 	ctx.glDeleteShader(shader);
687 	ctx.glDeleteProgram(programEmpty);
688 }
689 
get_uniformuiv(NegativeTestContext & ctx)690 void get_uniformuiv (NegativeTestContext& ctx)
691 {
692 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
693 	GLint				unif			= ctx.glGetUniformLocation(program.getProgram(), "fUnif_uvec4");
694 	GLuint				params[4]		= { 0, 0, 0, 0 };
695 	GLuint				shader;
696 	GLuint				programEmpty;
697 
698 	ctx.glUseProgram(program.getProgram());
699 
700 	if (unif == -1)
701 		ctx.fail("Failed to retrieve uniform location");
702 
703 	shader = ctx.glCreateShader(GL_VERTEX_SHADER);
704 	programEmpty = ctx.glCreateProgram();
705 
706 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
707 	ctx.glGetUniformuiv (-1, unif, &params[0]);
708 	ctx.expectError(GL_INVALID_VALUE);
709 	ctx.endSection();
710 
711 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
712 	ctx.glGetUniformuiv (shader, unif, &params[0]);
713 	ctx.expectError(GL_INVALID_OPERATION);
714 	ctx.endSection();
715 
716 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
717 	ctx.glGetUniformuiv (programEmpty, unif, &params[0]);
718 	ctx.expectError(GL_INVALID_OPERATION);
719 	ctx.endSection();
720 
721 	ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
722 	ctx.glGetUniformuiv (program.getProgram(), -1, &params[0]);
723 	ctx.expectError(GL_INVALID_OPERATION);
724 	ctx.endSection();
725 
726 	ctx.glDeleteShader(shader);
727 	ctx.glDeleteProgram(programEmpty);
728 }
729 
get_nuniformuiv(NegativeTestContext & ctx)730 void get_nuniformuiv (NegativeTestContext& ctx)
731 {
732 	TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
733 
734 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
735 	GLint				unif			= ctx.glGetUniformLocation(program.getProgram(), "fUnif_ivec4");
736 	GLuint				params[4]		= { 0, 0, 0, 0 };
737 	GLuint				shader;
738 	GLuint				programEmpty;
739 	GLsizei				bufferSize;
740 
741 	ctx.glUseProgram(program.getProgram());
742 
743 	if (unif == -1)
744 		ctx.fail("Failed to retrieve uniform location");
745 
746 	shader = ctx.glCreateShader(GL_VERTEX_SHADER);
747 	programEmpty = ctx.glCreateProgram();
748 
749 	ctx.glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &bufferSize);
750 
751 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
752 	ctx.glGetnUniformuiv(-1, unif, bufferSize, &params[0]);
753 	ctx.expectError(GL_INVALID_VALUE);
754 	ctx.endSection();
755 
756 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
757 	ctx.glGetnUniformuiv(shader, unif, bufferSize, &params[0]);
758 	ctx.expectError(GL_INVALID_OPERATION);
759 	ctx.endSection();
760 
761 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
762 	ctx.glGetnUniformuiv(programEmpty, unif, bufferSize, &params[0]);
763 	ctx.expectError(GL_INVALID_OPERATION);
764 	ctx.endSection();
765 
766 	ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
767 	ctx.glGetnUniformuiv(program.getProgram(), -1, bufferSize, &params[0]);
768 	ctx.expectError(GL_INVALID_OPERATION);
769 	ctx.endSection();
770 
771 	ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer size required to store the requested data is greater than bufSize.");
772 	ctx.glGetnUniformuiv(program.getProgram(), unif, -1, &params[0]);
773 	ctx.expectError(GL_INVALID_OPERATION);
774 	ctx.endSection();
775 
776 	ctx.glDeleteShader(shader);
777 	ctx.glDeleteProgram(programEmpty);
778 }
779 
get_active_uniform(NegativeTestContext & ctx)780 void get_active_uniform (NegativeTestContext& ctx)
781 {
782 	GLuint				shader				= ctx.glCreateShader(GL_VERTEX_SHADER);
783 	glu::ShaderProgram	program				(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
784 	GLint				numActiveUniforms	= -1;
785 
786 	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORMS,	&numActiveUniforms);
787 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
788 
789 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
790 	ctx.glGetActiveUniform(-1, 0, 0, 0, 0, 0, 0);
791 	ctx.expectError(GL_INVALID_VALUE);
792 	ctx.endSection();
793 
794 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
795 	ctx.glGetActiveUniform(shader, 0, 0, 0, 0, 0, 0);
796 	ctx.expectError(GL_INVALID_OPERATION);
797 	ctx.endSection();
798 
799 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to the number of active uniform variables in program.");
800 	ctx.glUseProgram(program.getProgram());
801 	ctx.glGetActiveUniform(program.getProgram(), numActiveUniforms, 0, 0, 0, 0, 0);
802 	ctx.expectError(GL_INVALID_VALUE);
803 	ctx.endSection();
804 
805 	ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
806 	ctx.glGetActiveUniform(program.getProgram(), 0, -1, 0, 0, 0, 0);
807 	ctx.expectError(GL_INVALID_VALUE);
808 	ctx.endSection();
809 
810 	ctx.glUseProgram(0);
811 	ctx.glDeleteShader(shader);
812 }
813 
get_active_uniformsiv(NegativeTestContext & ctx)814 void get_active_uniformsiv (NegativeTestContext& ctx)
815 {
816 	GLuint					shader				= ctx.glCreateShader(GL_VERTEX_SHADER);
817 	glu::ShaderProgram		program				(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
818 	GLuint					dummyUniformIndex	= 1;
819 	GLint					dummyParamDst		= -1;
820 	GLint					numActiveUniforms	= -1;
821 
822 	ctx.glUseProgram(program.getProgram());
823 
824 	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
825 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
826 
827 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
828 	ctx.glGetActiveUniformsiv(-1, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
829 	ctx.expectError(GL_INVALID_VALUE);
830 	ctx.endSection();
831 
832 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
833 	ctx.glGetActiveUniformsiv(shader, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
834 	ctx.expectError(GL_INVALID_OPERATION);
835 	ctx.endSection();
836 
837 	ctx.beginSection("GL_INVALID_VALUE is generated if any value in uniformIndices is greater than or equal to the value of GL_ACTIVE_UNIFORMS for program.");
838 	for (int excess = 0; excess <= 2; excess++)
839 	{
840 		std::vector<GLuint> invalidUniformIndices;
841 		invalidUniformIndices.push_back(1);
842 		invalidUniformIndices.push_back(numActiveUniforms-1+excess);
843 		invalidUniformIndices.push_back(1);
844 
845 		std::vector<GLint> dummyParamsDst(invalidUniformIndices.size());
846 		ctx.glGetActiveUniformsiv(program.getProgram(), (GLsizei)invalidUniformIndices.size(), &invalidUniformIndices[0], GL_UNIFORM_TYPE, &dummyParamsDst[0]);
847 		ctx.expectError(excess == 0 ? GL_NO_ERROR : GL_INVALID_VALUE);
848 	}
849 	ctx.endSection();
850 
851 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted token.");
852 	ctx.glGetActiveUniformsiv(program.getProgram(), 1, &dummyUniformIndex, -1, &dummyParamDst);
853 	ctx.expectError(GL_INVALID_ENUM);
854 	ctx.endSection();
855 
856 	ctx.glUseProgram(0);
857 	ctx.glDeleteShader(shader);
858 }
859 
get_active_uniform_blockiv(NegativeTestContext & ctx)860 void get_active_uniform_blockiv (NegativeTestContext& ctx)
861 {
862 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
863 	GLuint				shader			= ctx.glCreateShader(GL_VERTEX_SHADER);
864 	GLint				params			= -1;
865 	GLint				numActiveBlocks	= -1;
866 
867 	ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
868 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
869 	ctx.expectError(GL_NO_ERROR);
870 
871 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of either a program or shader object.");
872 	ctx.glGetActiveUniformBlockiv(-1, 0, GL_UNIFORM_BLOCK_BINDING, &params);
873 	ctx.expectError(GL_INVALID_VALUE);
874 	ctx.endSection();
875 
876 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object");
877 	ctx.glGetActiveUniformBlockiv(shader, 0, GL_UNIFORM_BLOCK_BINDING, &params);
878 	ctx.expectError(GL_INVALID_OPERATION);
879 	ctx.endSection();
880 
881 	ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockIndex is greater than or equal to the value of GL_ACTIVE_UNIFORM_BLOCKS or is not the index of an active uniform block in program.");
882 	ctx.glUseProgram(program.getProgram());
883 	ctx.expectError(GL_NO_ERROR);
884 	ctx.glGetActiveUniformBlockiv(program.getProgram(), numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, &params);
885 	ctx.expectError(GL_INVALID_VALUE);
886 	ctx.endSection();
887 
888 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
889 	ctx.glGetActiveUniformBlockiv(program.getProgram(), 0, -1, &params);
890 	ctx.expectError(GL_INVALID_ENUM);
891 	ctx.endSection();
892 
893 	ctx.glUseProgram(0);
894 }
895 
get_active_uniform_block_name(NegativeTestContext & ctx)896 void get_active_uniform_block_name (NegativeTestContext& ctx)
897 {
898 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
899 	GLuint				shader			= ctx.glCreateShader(GL_VERTEX_SHADER);
900 	GLsizei				length			= -1;
901 	GLint				numActiveBlocks	= -1;
902 	GLchar				uniformBlockName[128];
903 
904 	deMemset(&uniformBlockName[0], 0, sizeof(uniformBlockName));
905 
906 	ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
907 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
908 	ctx.expectError(GL_NO_ERROR);
909 
910 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
911 	ctx.glGetActiveUniformBlockName(shader, numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, &length, &uniformBlockName[0]);
912 	ctx.expectError(GL_INVALID_OPERATION);
913 	ctx.endSection();
914 
915 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of either a program or shader object.");
916 	ctx.glGetActiveUniformBlockName(-1, numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, &length, &uniformBlockName[0]);
917 	ctx.expectError(GL_INVALID_VALUE);
918 	ctx.endSection();
919 
920 	ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockIndex is greater than or equal to the value of GL_ACTIVE_UNIFORM_BLOCKS or is not the index of an active uniform block in program.");
921 	ctx.glUseProgram(program.getProgram());
922 	ctx.expectError(GL_NO_ERROR);
923 	ctx.glGetActiveUniformBlockName(program.getProgram(), numActiveBlocks, (int)sizeof(uniformBlockName), &length, &uniformBlockName[0]);
924 	ctx.expectError(GL_INVALID_VALUE);
925 	ctx.endSection();
926 
927 	ctx.glUseProgram(0);
928 }
929 
get_active_attrib(NegativeTestContext & ctx)930 void get_active_attrib (NegativeTestContext& ctx)
931 {
932 	GLuint				shader				= ctx.glCreateShader(GL_VERTEX_SHADER);
933 	glu::ShaderProgram	program				(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
934 	GLint				numActiveAttributes	= -1;
935 	GLsizei				length				= -1;
936 	GLint				size				= -1;
937 	GLenum				type				= -1;
938 	GLchar				name[32];
939 
940 	deMemset(&name[0], 0, sizeof(name));
941 
942 	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_ATTRIBUTES,	&numActiveAttributes);
943 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_ATTRIBUTES = " << numActiveAttributes << " (expected 1)." << TestLog::EndMessage;
944 
945 	ctx.glUseProgram(program.getProgram());
946 
947 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
948 	ctx.glGetActiveAttrib(-1, 0, 32, &length, &size, &type, &name[0]);
949 	ctx.expectError(GL_INVALID_VALUE);
950 	ctx.endSection();
951 
952 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
953 	ctx.glGetActiveAttrib(shader, 0, 32, &length, &size, &type, &name[0]);
954 	ctx.expectError(GL_INVALID_OPERATION);
955 	ctx.endSection();
956 
957 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_ACTIVE_ATTRIBUTES.");
958 	ctx.glGetActiveAttrib(program.getProgram(), numActiveAttributes, (int)sizeof(name), &length, &size, &type, &name[0]);
959 	ctx.expectError(GL_INVALID_VALUE);
960 	ctx.endSection();
961 
962 	ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
963 	ctx.glGetActiveAttrib(program.getProgram(), 0, -1, &length, &size, &type, &name[0]);
964 	ctx.expectError(GL_INVALID_VALUE);
965 	ctx.endSection();
966 
967 	ctx.glUseProgram(0);
968 	ctx.glDeleteShader(shader);
969 }
970 
get_uniform_indices(NegativeTestContext & ctx)971 void get_uniform_indices (NegativeTestContext& ctx)
972 {
973 	GLuint				shader			= ctx.glCreateShader(GL_VERTEX_SHADER);
974 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
975 	GLint				numActiveBlocks	= -1;
976 	const GLchar*		uniformName		= "Block.blockVar";
977 	GLuint				uniformIndices	= -1;
978 	GLuint				invalid			= -1;
979 
980 	ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS,	&numActiveBlocks);
981 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = "		<< numActiveBlocks			<< TestLog::EndMessage;
982 	ctx.expectError(GL_NO_ERROR);
983 
984 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is a name of shader object.");
985 	ctx.glGetUniformIndices(shader, 1, &uniformName, &uniformIndices);
986 	ctx.expectError(GL_INVALID_OPERATION);
987 	ctx.endSection();
988 
989 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not name of program or shader object.");
990 	ctx.glGetUniformIndices(invalid, 1, &uniformName, &uniformIndices);
991 	ctx.expectError(GL_INVALID_VALUE);
992 	ctx.endSection();
993 
994 	ctx.glUseProgram(0);
995 	ctx.glDeleteShader(shader);
996 }
997 
get_vertex_attribfv(NegativeTestContext & ctx)998 void get_vertex_attribfv (NegativeTestContext& ctx)
999 {
1000 	GLfloat	params				= 0.0f;
1001 	GLint	maxVertexAttribs;
1002 
1003 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1004 	ctx.glGetVertexAttribfv(0, -1, &params);
1005 	ctx.expectError(GL_INVALID_ENUM);
1006 	ctx.endSection();
1007 
1008 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1009 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
1010 	ctx.glGetVertexAttribfv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
1011 	ctx.expectError(GL_INVALID_VALUE);
1012 	ctx.endSection();
1013 }
1014 
get_vertex_attribiv(NegativeTestContext & ctx)1015 void get_vertex_attribiv (NegativeTestContext& ctx)
1016 {
1017 	GLint	params				= -1;
1018 	GLint	maxVertexAttribs;
1019 
1020 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1021 	ctx.glGetVertexAttribiv(0, -1, &params);
1022 	ctx.expectError(GL_INVALID_ENUM);
1023 	ctx.endSection();
1024 
1025 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1026 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
1027 	ctx.glGetVertexAttribiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
1028 	ctx.expectError(GL_INVALID_VALUE);
1029 	ctx.endSection();
1030 }
1031 
get_vertex_attribi_iv(NegativeTestContext & ctx)1032 void get_vertex_attribi_iv (NegativeTestContext& ctx)
1033 {
1034 	GLint	params				= -1;
1035 	GLint	maxVertexAttribs;
1036 
1037 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1038 	ctx.glGetVertexAttribIiv(0, -1, &params);
1039 	ctx.expectError(GL_INVALID_ENUM);
1040 	ctx.endSection();
1041 
1042 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1043 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
1044 	ctx.glGetVertexAttribIiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
1045 	ctx.expectError(GL_INVALID_VALUE);
1046 	ctx.endSection();
1047 }
1048 
get_vertex_attribi_uiv(NegativeTestContext & ctx)1049 void get_vertex_attribi_uiv (NegativeTestContext& ctx)
1050 {
1051 	GLuint	params				= (GLuint)-1;
1052 	GLint	maxVertexAttribs;
1053 
1054 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1055 	ctx.glGetVertexAttribIuiv(0, -1, &params);
1056 	ctx.expectError(GL_INVALID_ENUM);
1057 	ctx.endSection();
1058 
1059 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1060 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
1061 	ctx.glGetVertexAttribIuiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
1062 	ctx.expectError(GL_INVALID_VALUE);
1063 	ctx.endSection();
1064 }
1065 
get_vertex_attrib_pointerv(NegativeTestContext & ctx)1066 void get_vertex_attrib_pointerv (NegativeTestContext& ctx)
1067 {
1068 	GLvoid*	ptr[1]				= { DE_NULL };
1069 	GLint	maxVertexAttribs;
1070 
1071 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1072 	ctx.glGetVertexAttribPointerv(0, -1, &ptr[0]);
1073 	ctx.expectError(GL_INVALID_ENUM);
1074 	ctx.endSection();
1075 
1076 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1077 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
1078 	ctx.glGetVertexAttribPointerv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr[0]);
1079 	ctx.expectError(GL_INVALID_VALUE);
1080 	ctx.endSection();
1081 }
1082 
get_frag_data_location(NegativeTestContext & ctx)1083 void get_frag_data_location (NegativeTestContext& ctx)
1084 {
1085 	GLuint shader	= ctx.glCreateShader(GL_VERTEX_SHADER);
1086 	GLuint program	= ctx.glCreateProgram();
1087 
1088 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
1089 	ctx.glGetFragDataLocation(shader, "gl_FragColor");
1090 	ctx.expectError(GL_INVALID_OPERATION);
1091 	ctx.endSection();
1092 
1093 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been linked.");
1094 	ctx.glGetFragDataLocation(program, "gl_FragColor");
1095 	ctx.expectError(GL_INVALID_OPERATION);
1096 	ctx.endSection();
1097 
1098 	ctx.glDeleteProgram(program);
1099 	ctx.glDeleteShader(shader);
1100 }
1101 
1102 // Enumerated state queries: Buffers
1103 
get_buffer_parameteriv(NegativeTestContext & ctx)1104 void get_buffer_parameteriv (NegativeTestContext& ctx)
1105 {
1106 	GLint	params	= -1;
1107 	GLuint	buf;
1108 	ctx.glGenBuffers(1, &buf);
1109 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
1110 
1111 	ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value.");
1112 	ctx.glGetBufferParameteriv(-1, GL_BUFFER_SIZE, &params);
1113 	ctx.expectError(GL_INVALID_ENUM);
1114 	ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, -1, &params);
1115 	ctx.expectError(GL_INVALID_ENUM);
1116 	ctx.glGetBufferParameteriv(-1, -1, &params);
1117 	ctx.expectError(GL_INVALID_ENUM);
1118 	ctx.endSection();
1119 
1120 	ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
1121 	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
1122 	ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &params);
1123 	ctx.expectError(GL_INVALID_OPERATION);
1124 	ctx.endSection();
1125 
1126 	ctx.glDeleteBuffers(1, &buf);
1127 }
1128 
get_buffer_parameteri64v(NegativeTestContext & ctx)1129 void get_buffer_parameteri64v (NegativeTestContext& ctx)
1130 {
1131 	GLint64	params	= -1;
1132 	GLuint	buf;
1133 	ctx.glGenBuffers(1, &buf);
1134 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
1135 
1136 	ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value.");
1137 	ctx.glGetBufferParameteri64v(-1, GL_BUFFER_SIZE, &params);
1138 	ctx.expectError(GL_INVALID_ENUM);
1139 	ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER , -1, &params);
1140 	ctx.expectError(GL_INVALID_ENUM);
1141 	ctx.glGetBufferParameteri64v(-1, -1, &params);
1142 	ctx.expectError(GL_INVALID_ENUM);
1143 	ctx.endSection();
1144 
1145 	ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
1146 	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
1147 	ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &params);
1148 	ctx.expectError(GL_INVALID_OPERATION);
1149 	ctx.endSection();
1150 
1151 	ctx.glDeleteBuffers(1, &buf);
1152 }
1153 
get_buffer_pointerv(NegativeTestContext & ctx)1154 void get_buffer_pointerv (NegativeTestContext& ctx)
1155 {
1156 	GLvoid*	params	= DE_NULL;
1157 	GLuint	buf;
1158 	ctx.glGenBuffers(1, &buf);
1159 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
1160 
1161 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
1162 	ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, -1, &params);
1163 	ctx.expectError(GL_INVALID_ENUM);
1164 	ctx.glGetBufferPointerv(-1, GL_BUFFER_MAP_POINTER, &params);
1165 	ctx.expectError(GL_INVALID_ENUM);
1166 	ctx.endSection();
1167 
1168 	ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
1169 	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
1170 	ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, GL_BUFFER_MAP_POINTER, &params);
1171 	ctx.expectError(GL_INVALID_OPERATION);
1172 	ctx.endSection();
1173 
1174 	ctx.glDeleteBuffers(1, &buf);
1175 }
1176 
get_framebuffer_attachment_parameteriv(NegativeTestContext & ctx)1177 void get_framebuffer_attachment_parameteriv (NegativeTestContext& ctx)
1178 {
1179 	GLint	params[1]	= { -1 };
1180 	GLuint	fbo;
1181 	GLuint	rbo[2];
1182 
1183 	ctx.glGenFramebuffers			(1, &fbo);
1184 	ctx.glGenRenderbuffers			(2, rbo);
1185 
1186 	ctx.glBindFramebuffer			(GL_FRAMEBUFFER,	fbo);
1187 	ctx.glBindRenderbuffer			(GL_RENDERBUFFER,	rbo[0]);
1188 	ctx.glRenderbufferStorage		(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 16, 16);
1189 	ctx.glFramebufferRenderbuffer	(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1190 	ctx.glBindRenderbuffer			(GL_RENDERBUFFER,	rbo[1]);
1191 	ctx.glRenderbufferStorage		(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 16, 16);
1192 	ctx.glFramebufferRenderbuffer	(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1193 	ctx.glCheckFramebufferStatus	(GL_FRAMEBUFFER);
1194 	ctx.expectError					(GL_NO_ERROR);
1195 
1196 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1197 	ctx.glGetFramebufferAttachmentParameteriv(-1, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &params[0]);					// TYPE is GL_RENDERBUFFER
1198 	ctx.expectError(GL_INVALID_ENUM);
1199 	ctx.endSection();
1200 
1201 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
1202 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &params[0]);	// TYPE is GL_RENDERBUFFER
1203 	ctx.expectError(GL_INVALID_ENUM);
1204 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1205 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);					// TYPE is GL_FRAMEBUFFER_DEFAULT
1206 	ctx.expectError(GL_INVALID_ENUM);
1207 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1208 	ctx.endSection();
1209 
1210 	ctx.beginSection("GL_INVALID_OPERATION is generated if attachment is GL_DEPTH_STENCIL_ATTACHMENT and different objects are bound to the depth and stencil attachment points of target.");
1211 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);
1212 	ctx.expectError(GL_INVALID_OPERATION);
1213 	ctx.endSection();
1214 
1215 	ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME.");
1216 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);		// TYPE is GL_NONE
1217 	ctx.expectError(GL_NO_ERROR);
1218 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, &params[0]);	// TYPE is GL_NONE
1219 	ctx.expectError(GL_INVALID_OPERATION);
1220 	ctx.endSection();
1221 
1222 	ctx.beginSection("GL_INVALID_OPERATION or GL_INVALID_ENUM is generated if attachment is not one of the accepted values for the current binding of target.");
1223 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);					// A FBO is bound so GL_BACK is invalid
1224 	ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
1225 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1226 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);		// Default framebuffer is bound so GL_COLOR_ATTACHMENT0 is invalid
1227 	ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
1228 	ctx.endSection();
1229 
1230 	ctx.glDeleteFramebuffers(1, &fbo);
1231 }
1232 
get_renderbuffer_parameteriv(NegativeTestContext & ctx)1233 void get_renderbuffer_parameteriv (NegativeTestContext& ctx)
1234 {
1235 	GLint	params[1] = { -1 };
1236 	GLuint	rbo;
1237 	ctx.glGenRenderbuffers(1, &rbo);
1238 	ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1239 
1240 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1241 	ctx.glGetRenderbufferParameteriv(-1, GL_RENDERBUFFER_WIDTH, &params[0]);
1242 	ctx.expectError(GL_INVALID_ENUM);
1243 	ctx.endSection();
1244 
1245 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
1246 	ctx.glGetRenderbufferParameteriv(GL_RENDERBUFFER, -1, &params[0]);
1247 	ctx.expectError(GL_INVALID_ENUM);
1248 	ctx.endSection();
1249 
1250 	ctx.beginSection("GL_INVALID_OPERATION  is generated if the renderbuffer currently bound to target is zero.");
1251 	ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
1252 	ctx.expectError(GL_NO_ERROR);
1253 	ctx.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &params[0]);
1254 	ctx.expectError(GL_INVALID_OPERATION);
1255 	ctx.endSection();
1256 
1257 	ctx.glDeleteRenderbuffers(1, &rbo);
1258 	ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
1259 }
1260 
get_internalformativ(NegativeTestContext & ctx)1261 void get_internalformativ (NegativeTestContext& ctx)
1262 {
1263 	GLint params[16];
1264 
1265 	deMemset(&params[0], 0xcd, sizeof(params));
1266 
1267 	ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is negative.");
1268 	ctx.glGetInternalformativ	(GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, -1, &params[0]);
1269 	ctx.expectError				(GL_INVALID_VALUE);
1270 	ctx.endSection();
1271 
1272 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_SAMPLES or GL_NUM_SAMPLE_COUNTS.");
1273 	ctx.glGetInternalformativ	(GL_RENDERBUFFER, GL_RGBA8, -1, 16, &params[0]);
1274 	ctx.expectError				(GL_INVALID_ENUM);
1275 	ctx.endSection();
1276 
1277 	ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not color-, depth-, or stencil-renderable.");
1278 
1279 	if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_render_snorm"))
1280 	{
1281 		ctx.glGetInternalformativ	(GL_RENDERBUFFER, GL_RG8_SNORM, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
1282 		ctx.expectError				(GL_INVALID_ENUM);
1283 	}
1284 
1285 	ctx.glGetInternalformativ	(GL_RENDERBUFFER, GL_COMPRESSED_RGB8_ETC2, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
1286 	ctx.expectError				(GL_INVALID_ENUM);
1287 	ctx.endSection();
1288 
1289 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1290 	ctx.glGetInternalformativ	(-1, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
1291 	ctx.expectError				(GL_INVALID_ENUM);
1292 	ctx.glGetInternalformativ	(GL_FRAMEBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
1293 	ctx.expectError				(GL_INVALID_ENUM);
1294 
1295 	if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_sparse_texture"))
1296 	{
1297 		ctx.glGetInternalformativ	(GL_TEXTURE_2D, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
1298 		ctx.expectError				(GL_INVALID_ENUM);
1299 	}
1300 
1301 	ctx.endSection();
1302 }
1303 
1304 // Query object queries
1305 
get_queryiv(NegativeTestContext & ctx)1306 void get_queryiv (NegativeTestContext& ctx)
1307 {
1308 	GLint params = -1;
1309 
1310 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
1311 	ctx.glGetQueryiv	(GL_ANY_SAMPLES_PASSED, -1, &params);
1312 	ctx.expectError		(GL_INVALID_ENUM);
1313 	ctx.glGetQueryiv	(-1, GL_CURRENT_QUERY, &params);
1314 	ctx.expectError		(GL_INVALID_ENUM);
1315 	ctx.glGetQueryiv	(-1, -1, &params);
1316 	ctx.expectError		(GL_INVALID_ENUM);
1317 	ctx.endSection();
1318 }
1319 
get_query_objectuiv(NegativeTestContext & ctx)1320 void get_query_objectuiv (NegativeTestContext& ctx)
1321 {
1322 	GLuint params	= -1;
1323 	GLuint id;
1324 	ctx.glGenQueries		(1, &id);
1325 
1326 	ctx.beginSection("GL_INVALID_OPERATION is generated if id is not the name of a query object.");
1327 	ctx.glGetQueryObjectuiv	(-1, GL_QUERY_RESULT_AVAILABLE, &params);
1328 	ctx.expectError			(GL_INVALID_OPERATION);
1329 	ctx.getLog() << TestLog::Message << "// Note: " << id << " is not a query object yet, since it hasn't been used by glBeginQuery" << TestLog::EndMessage;
1330 	ctx.glGetQueryObjectuiv	(id, GL_QUERY_RESULT_AVAILABLE, &params);
1331 	ctx.expectError			(GL_INVALID_OPERATION);
1332 	ctx.endSection();
1333 
1334 	ctx.glBeginQuery		(GL_ANY_SAMPLES_PASSED, id);
1335 	ctx.glEndQuery			(GL_ANY_SAMPLES_PASSED);
1336 
1337 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1338 	ctx.glGetQueryObjectuiv	(id, -1, &params);
1339 	ctx.expectError			(GL_INVALID_ENUM);
1340 	ctx.endSection();
1341 
1342 	ctx.beginSection("GL_INVALID_OPERATION is generated if id is the name of a currently active query object.");
1343 	ctx.glBeginQuery		(GL_ANY_SAMPLES_PASSED, id);
1344 	ctx.expectError			(GL_NO_ERROR);
1345 	ctx.glGetQueryObjectuiv	(id, GL_QUERY_RESULT_AVAILABLE, &params);
1346 	ctx.expectError			(GL_INVALID_OPERATION);
1347 	ctx.glEndQuery			(GL_ANY_SAMPLES_PASSED);
1348 	ctx.expectError			(GL_NO_ERROR);
1349 	ctx.endSection();
1350 
1351 	ctx.glDeleteQueries		(1, &id);
1352 }
1353 
1354 // Sync object queries
1355 
get_synciv(NegativeTestContext & ctx)1356 void get_synciv (NegativeTestContext& ctx)
1357 {
1358 	GLsizei	length		= -1;
1359 	GLint	values[32];
1360 	GLsync	sync;
1361 
1362 	deMemset(&values[0], 0xcd, sizeof(values));
1363 
1364 	ctx.beginSection("GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
1365 	ctx.glGetSynciv(0, GL_OBJECT_TYPE, 32, &length, &values[0]);
1366 	ctx.expectError(GL_INVALID_VALUE);
1367 	ctx.endSection();
1368 
1369 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
1370 	sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1371 	ctx.expectError(GL_NO_ERROR);
1372 	ctx.glGetSynciv(sync, -1, 32, &length, &values[0]);
1373 	ctx.expectError(GL_INVALID_ENUM);
1374 	ctx.endSection();
1375 
1376 	ctx.glDeleteSync(sync);
1377 
1378 	ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is negative.");
1379 	sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1380 	ctx.expectError(GL_NO_ERROR);
1381 	ctx.glGetSynciv(sync, GL_OBJECT_TYPE, -1, &length, &values[0]);
1382 	ctx.expectError(GL_INVALID_VALUE);
1383 	ctx.endSection();
1384 
1385 	ctx.glDeleteSync(sync);
1386 }
1387 
1388 // Enumerated boolean state queries
1389 
is_enabled(NegativeTestContext & ctx)1390 void is_enabled (NegativeTestContext& ctx)
1391 {
1392 	ctx.beginSection("GL_INVALID_ENUM is generated if cap is not an accepted value.");
1393 	ctx.glIsEnabled(-1);
1394 	ctx.expectError(GL_INVALID_ENUM);
1395 	ctx.glIsEnabled(GL_TRIANGLES);
1396 	ctx.expectError(GL_INVALID_ENUM);
1397 	ctx.endSection();
1398 }
1399 
is_enabledi(NegativeTestContext & ctx)1400 void is_enabledi (NegativeTestContext& ctx)
1401 {
1402 	TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
1403 
1404 	ctx.beginSection("GL_INVALID_ENUM is generated if cap is not an accepted value.");
1405 	ctx.glIsEnabledi(-1, 1);
1406 	ctx.expectError(GL_INVALID_ENUM);
1407 	ctx.glIsEnabledi(GL_TRIANGLES, 1);
1408 	ctx.expectError(GL_INVALID_ENUM);
1409 	ctx.endSection();
1410 
1411 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside the valid range for the indexed state cap.");
1412 	ctx.glIsEnabledi(GL_BLEND, -1);
1413 	ctx.expectError(GL_INVALID_VALUE);
1414 	ctx.endSection();
1415 }
1416 
1417 // Hints
1418 
hint(NegativeTestContext & ctx)1419 void hint (NegativeTestContext& ctx)
1420 {
1421 	ctx.beginSection("GL_INVALID_ENUM is generated if either target or mode is not an accepted value.");
1422 	ctx.glHint(GL_GENERATE_MIPMAP_HINT, -1);
1423 	ctx.expectError(GL_INVALID_ENUM);
1424 	ctx.glHint(-1, GL_FASTEST);
1425 	ctx.expectError(GL_INVALID_ENUM);
1426 	ctx.glHint(-1, -1);
1427 	ctx.expectError(GL_INVALID_ENUM);
1428 	ctx.endSection();
1429 }
1430 
getNegativeStateApiTestFunctions()1431 std::vector<FunctionContainer> getNegativeStateApiTestFunctions ()
1432 {
1433 	const FunctionContainer funcs[] =
1434 	{
1435 		{enable,									"enable",									"Invalid glEnable() usage"								},
1436 		{disable,									"disable",									"Invalid glDisable() usage"								},
1437 		{get_booleanv,								"get_booleanv",								"Invalid glGetBooleanv() usage"							},
1438 		{get_floatv,								"get_floatv",								"Invalid glGetFloatv() usage"							},
1439 		{get_integerv,								"get_integerv",								"Invalid glGetIntegerv() usage"							},
1440 		{get_integer64v,							"get_integer64v",							"Invalid glGetInteger64v() usage"						},
1441 		{get_integeri_v,							"get_integeri_v",							"Invalid glGetIntegeri_v() usage"						},
1442 		{get_booleani_v,							"get_booleani_v",							"Invalid glGetBooleani_v() usage"						},
1443 		{get_integer64i_v,							"get_integer64i_v",							"Invalid glGetInteger64i_v() usage"						},
1444 		{get_string,								"get_string",								"Invalid glGetString() usage"							},
1445 		{get_stringi,								"get_stringi",								"Invalid glGetStringi() usage"							},
1446 		{get_attached_shaders,						"get_attached_shaders",						"Invalid glGetAttachedShaders() usage"					},
1447 		{get_shaderiv,								"get_shaderiv",								"Invalid glGetShaderiv() usage"							},
1448 		{get_shader_info_log,						"get_shader_info_log",						"Invalid glGetShaderInfoLog() usage"					},
1449 		{get_shader_precision_format,				"get_shader_precision_format",				"Invalid glGetShaderPrecisionFormat() usage"			},
1450 		{get_shader_source,							"get_shader_source",						"Invalid glGetShaderSource() usage"						},
1451 		{get_programiv,								"get_programiv",							"Invalid glGetProgramiv() usage"						},
1452 		{get_program_info_log,						"get_program_info_log",						"Invalid glGetProgramInfoLog() usage"					},
1453 		{get_tex_parameterfv,						"get_tex_parameterfv",						"Invalid glGetTexParameterfv() usage"					},
1454 		{get_tex_parameteriv,						"get_tex_parameteriv",						"Invalid glGetTexParameteriv() usage"					},
1455 		{get_uniformfv,								"get_uniformfv",							"Invalid glGetUniformfv() usage"						},
1456 		{get_uniformiv,								"get_uniformiv",							"Invalid glGetUniformiv() usage"						},
1457 		{get_uniformuiv,							"get_uniformuiv",							"Invalid glGetUniformuiv() usage"						},
1458 		{get_active_uniform,						"get_active_uniform",						"Invalid glGetActiveUniform() usage"					},
1459 		{get_active_uniformsiv,						"get_active_uniformsiv",					"Invalid glGetActiveUniformsiv() usage"					},
1460 		{get_active_uniform_blockiv,				"get_active_uniform_blockiv",				"Invalid glGetActiveUniformBlockiv() usage"				},
1461 		{get_active_uniform_block_name,				"get_active_uniform_block_name",			"Invalid glGetActiveUniformBlockName() usage"			},
1462 		{get_active_attrib,							"get_active_attrib",						"Invalid glGetActiveAttrib() usage"						},
1463 		{get_uniform_indices,						"get_uniform_indices",						"Invalid glGetUniformIndices() usage"					},
1464 		{get_vertex_attribfv,						"get_vertex_attribfv",						"Invalid glGetVertexAttribfv() usage"					},
1465 		{get_vertex_attribiv,						"get_vertex_attribiv",						"Invalid glGetVertexAttribiv() usage"					},
1466 		{get_vertex_attribi_iv,						"get_vertex_attribi_iv",					"Invalid glGetVertexAttribIiv() usage"					},
1467 		{get_vertex_attribi_uiv,					"get_vertex_attribi_uiv",					"Invalid glGetVertexAttribIuiv() usage"					},
1468 		{get_vertex_attrib_pointerv,				"get_vertex_attrib_pointerv",				"Invalid glGetVertexAttribPointerv() usage"				},
1469 		{get_frag_data_location,					"get_frag_data_location",					"Invalid glGetFragDataLocation() usage"					},
1470 		{get_buffer_parameteriv,					"get_buffer_parameteriv",					"Invalid glGetBufferParameteriv() usage"				},
1471 		{get_buffer_parameteri64v,					"get_buffer_parameteri64v",					"Invalid glGetBufferParameteri64v() usage"				},
1472 		{get_buffer_pointerv,						"get_buffer_pointerv",						"Invalid glGetBufferPointerv() usage"					},
1473 		{get_framebuffer_attachment_parameteriv,	"get_framebuffer_attachment_parameteriv",	"Invalid glGetFramebufferAttachmentParameteriv() usage"	},
1474 		{get_renderbuffer_parameteriv,				"get_renderbuffer_parameteriv",				"Invalid glGetRenderbufferParameteriv() usage"			},
1475 		{get_internalformativ,						"get_internalformativ",						"Invalid glGetInternalformativ() usage"					},
1476 		{get_queryiv,								"get_queryiv",								"Invalid glGetQueryiv() usage"							},
1477 		{get_query_objectuiv,						"get_query_objectuiv",						"Invalid glGetQueryObjectuiv() usage"					},
1478 		{get_synciv,								"get_synciv",								"Invalid glGetSynciv() usage"							},
1479 		{is_enabled,								"is_enabled",								"Invalid glIsEnabled() usage"							},
1480 		{hint,										"hint",										"Invalid glHint() usage"								},
1481 		{enablei,									"enablei",									"Invalid glEnablei() usage"								},
1482 		{disablei,									"disablei",									"Invalid glDisablei() usage"							},
1483 		{get_tex_parameteriiv,						"get_tex_parameteriiv",						"Invalid glGetTexParameterIiv() usage"					},
1484 		{get_tex_parameteriuiv,						"get_tex_parameteriuiv",					"Invalid glGetTexParameterIuiv() usage"					},
1485 		{get_nuniformfv,							"get_nuniformfv",							"Invalid glGetnUniformfv() usage"						},
1486 		{get_nuniformiv,							"get_nuniformiv",							"Invalid glGetnUniformiv() usage"						},
1487 		{get_nuniformuiv,							"get_nuniformuiv",							"Invalid glGetnUniformuiv() usage"						},
1488 		{is_enabledi,								"is_enabledi",								"Invalid glIsEnabledi() usage"							},
1489 	};
1490 
1491 	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
1492 }
1493 
1494 } // NegativeTestShared
1495 } // Functional
1496 } // gles3
1497 } // deqp
1498