• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Negative GL State API tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es31fNegativeStateApiTests.hpp"
25 
26 #include "gluCallLogWrapper.hpp"
27 #include "gluShaderProgram.hpp"
28 
29 #include "glwDefs.hpp"
30 #include "glwEnums.hpp"
31 
32 #include "deMemory.h"
33 
34 namespace deqp
35 {
36 namespace gles31
37 {
38 namespace Functional
39 {
40 namespace NegativeTestShared
41 {
42 
43 using tcu::TestLog;
44 using glu::CallLogWrapper;
45 using namespace glw;
46 
47 static const char* uniformTestVertSource	=	"#version 300 es\n"
48 												"uniform mediump vec4 vUnif_vec4;\n"
49 												"in mediump vec4 attr;"
50 												"layout(shared) uniform Block { mediump vec4 blockVar; };\n"
51 												"void main (void)\n"
52 												"{\n"
53 												"	gl_Position = vUnif_vec4 + blockVar + attr;\n"
54 												"}\n\0";
55 static const char* uniformTestFragSource	=	"#version 300 es\n"
56 												"uniform mediump ivec4 fUnif_ivec4;\n"
57 												"uniform mediump uvec4 fUnif_uvec4;\n"
58 												"layout(location = 0) out mediump vec4 fragColor;"
59 												"void main (void)\n"
60 												"{\n"
61 												"	fragColor = vec4(vec4(fUnif_ivec4) + vec4(fUnif_uvec4));\n"
62 												"}\n\0";
63 
64 // Enabling & disabling states
enable(NegativeTestContext & ctx)65 void enable (NegativeTestContext& ctx)
66 {
67 	ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
68 	ctx.glEnable(-1);
69 	ctx.expectError(GL_INVALID_ENUM);
70 	ctx.endSection();
71 }
72 
disable(NegativeTestContext & ctx)73 void disable (NegativeTestContext& ctx)
74 {
75 	ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
76 	ctx.glDisable(-1);
77 	ctx.expectError(GL_INVALID_ENUM);
78 	ctx.endSection();
79 }
80 
81 // Simple state queries
get_booleanv(NegativeTestContext & ctx)82 void get_booleanv (NegativeTestContext& ctx)
83 {
84 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
85 	GLboolean params = GL_FALSE;
86 	ctx.glGetBooleanv(-1, &params);
87 	ctx.expectError(GL_INVALID_ENUM);
88 	ctx.endSection();
89 }
90 
get_floatv(NegativeTestContext & ctx)91 void get_floatv (NegativeTestContext& ctx)
92 {
93 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
94 	GLfloat params = 0.0f;
95 	ctx.glGetFloatv(-1, &params);
96 	ctx.expectError(GL_INVALID_ENUM);
97 	ctx.endSection();
98 }
99 
get_integerv(NegativeTestContext & ctx)100 void get_integerv (NegativeTestContext& ctx)
101 {
102 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
103 	GLint params = -1;
104 	ctx.glGetIntegerv(-1, &params);
105 	ctx.expectError(GL_INVALID_ENUM);
106 	ctx.endSection();
107 }
108 
get_integer64v(NegativeTestContext & ctx)109 void get_integer64v (NegativeTestContext& ctx)
110 {
111 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
112 	GLint64 params = -1;
113 	ctx.glGetInteger64v(-1, &params);
114 	ctx.expectError(GL_INVALID_ENUM);
115 	ctx.endSection();
116 }
117 
get_integeri_v(NegativeTestContext & ctx)118 void get_integeri_v (NegativeTestContext& ctx)
119 {
120 	GLint data = -1;
121 	GLint maxUniformBufferBindings;
122 
123 	ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
124 	ctx.glGetIntegeri_v(-1, 0, &data);
125 	ctx.expectError(GL_INVALID_ENUM);
126 	ctx.endSection();
127 
128 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
129 	ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
130 	ctx.expectError(GL_NO_ERROR);
131 	ctx.glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, maxUniformBufferBindings, &data);
132 	ctx.expectError(GL_INVALID_VALUE);
133 	ctx.endSection();
134 }
135 
get_integer64i_v(NegativeTestContext & ctx)136 void get_integer64i_v (NegativeTestContext& ctx)
137 {
138 	GLint64 data = (GLint64)-1;;
139 	GLint maxUniformBufferBindings;
140 
141 	ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
142 	ctx.glGetInteger64i_v(-1, 0, &data);
143 	ctx.expectError(GL_INVALID_ENUM);
144 	ctx.endSection();
145 
146 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
147 	ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
148 	ctx.expectError(GL_NO_ERROR);
149 	ctx.glGetInteger64i_v(GL_UNIFORM_BUFFER_START, maxUniformBufferBindings, &data);
150 	ctx.expectError(GL_INVALID_VALUE);
151 	ctx.endSection();
152 }
153 
get_string(NegativeTestContext & ctx)154 void get_string (NegativeTestContext& ctx)
155 {
156 	ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
157 	ctx.glGetString(-1);
158 	ctx.expectError(GL_INVALID_ENUM);
159 	ctx.endSection();
160 }
161 
get_stringi(NegativeTestContext & ctx)162 void get_stringi (NegativeTestContext& ctx)
163 {
164 	GLint numExtensions;
165 
166 	ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
167 	ctx.glGetStringi(-1, 0);
168 	ctx.expectError(GL_INVALID_ENUM);
169 	ctx.endSection();
170 
171 	ctx.beginSection("GL_INVALID_VALUE is generated if index is outside the valid range for indexed state name.");
172 	ctx.glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
173 	ctx.glGetStringi(GL_EXTENSIONS, numExtensions);
174 	ctx.expectError(GL_INVALID_VALUE);
175 	ctx.endSection();
176 }
177 
178 // Enumerated state queries: Shaders
179 
get_attached_shaders(NegativeTestContext & ctx)180 void get_attached_shaders (NegativeTestContext& ctx)
181 {
182 	GLuint shaders[1];
183 	GLuint shaderObject = ctx.glCreateShader(GL_VERTEX_SHADER);
184 	GLuint program		= ctx.glCreateProgram();
185 	GLsizei count[1];
186 
187 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
188 	ctx.glGetAttachedShaders(-1, 1, &count[0], &shaders[0]);
189 	ctx.expectError(GL_INVALID_VALUE);
190 	ctx.endSection();
191 
192 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
193 	ctx.glGetAttachedShaders(shaderObject, 1, &count[0], &shaders[0]);
194 	ctx.expectError(GL_INVALID_OPERATION);
195 	ctx.endSection();
196 
197 	ctx.beginSection("GL_INVALID_VALUE is generated if maxCount is less than 0.");
198 	ctx.glGetAttachedShaders(program, -1, &count[0], &shaders[0]);
199 	ctx.expectError(GL_INVALID_VALUE);
200 	ctx.endSection();
201 
202 	ctx.glDeleteShader(shaderObject);
203 	ctx.glDeleteProgram(program);
204 }
205 
get_shaderiv(NegativeTestContext & ctx)206 void get_shaderiv (NegativeTestContext& ctx)
207 {
208 	GLboolean shaderCompilerSupported;
209 	ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
210 	ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
211 
212 	GLuint shader	= ctx.glCreateShader(GL_VERTEX_SHADER);
213 	GLuint program	= ctx.glCreateProgram();
214 	GLint param[1]	= { -1 };
215 
216 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
217 	ctx.glGetShaderiv(shader, -1, &param[0]);
218 	ctx.expectError(GL_INVALID_ENUM);
219 	ctx.endSection();
220 
221 	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
222 	ctx.glGetShaderiv(-1, GL_SHADER_TYPE, &param[0]);
223 	ctx.expectError(GL_INVALID_VALUE);
224 	ctx.endSection();
225 
226 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader does not refer to a shader object.");
227 	ctx.glGetShaderiv(program, GL_SHADER_TYPE, &param[0]);
228 	ctx.expectError(GL_INVALID_OPERATION);
229 	ctx.endSection();
230 
231 	ctx.glDeleteShader(shader);
232 	ctx.glDeleteProgram(program);
233 }
234 
get_shader_info_log(NegativeTestContext & ctx)235 void get_shader_info_log (NegativeTestContext& ctx)
236 {
237 	GLuint shader		= ctx.glCreateShader(GL_VERTEX_SHADER);
238 	GLuint program		= ctx.glCreateProgram();
239 	GLsizei length[1]	= { -1 };
240 	char infoLog[128]	= { 0 };
241 
242 	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
243 	ctx.glGetShaderInfoLog(-1, 128, &length[0], &infoLog[0]);
244 	ctx.expectError(GL_INVALID_VALUE);
245 	ctx.endSection();
246 
247 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
248 	ctx.glGetShaderInfoLog(program, 128, &length[0], &infoLog[0]);
249 	ctx.expectError(GL_INVALID_OPERATION);
250 	ctx.endSection();
251 
252 	ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0.");
253 	ctx.glGetShaderInfoLog(shader, -1, &length[0], &infoLog[0]);
254 	ctx.expectError(GL_INVALID_VALUE);
255 	ctx.endSection();
256 
257 	ctx.glDeleteShader(shader);
258 	ctx.glDeleteProgram(program);
259 }
260 
get_shader_precision_format(NegativeTestContext & ctx)261 void get_shader_precision_format (NegativeTestContext& ctx)
262 {
263 	GLboolean shaderCompilerSupported;
264 	ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
265 	ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
266 
267 	GLint range[2];
268 	GLint precision[1];
269 
270 	deMemset(&range[0], 0xcd, sizeof(range));
271 	deMemset(&precision[0], 0xcd, sizeof(precision));
272 
273 	ctx.beginSection("GL_INVALID_ENUM is generated if shaderType or precisionType is not an accepted value.");
274 	ctx.glGetShaderPrecisionFormat (-1, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
275 	ctx.expectError(GL_INVALID_ENUM);
276 	ctx.glGetShaderPrecisionFormat (GL_VERTEX_SHADER, -1, &range[0], &precision[0]);
277 	ctx.expectError(GL_INVALID_ENUM);
278 	ctx.glGetShaderPrecisionFormat (-1, -1, &range[0], &precision[0]);
279 	ctx.expectError(GL_INVALID_ENUM);
280 	ctx.endSection();
281 }
282 
get_shader_source(NegativeTestContext & ctx)283 void get_shader_source (NegativeTestContext& ctx)
284 {
285 	GLsizei length[1];
286 	char source[1];
287 	GLuint program	= ctx.glCreateProgram();
288 	GLuint shader	= ctx.glCreateShader(GL_VERTEX_SHADER);
289 
290 	ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
291 	ctx.glGetShaderSource(-1, 1, &length[0], &source[0]);
292 	ctx.expectError(GL_INVALID_VALUE);
293 	ctx.endSection();
294 
295 	ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
296 	ctx.glGetShaderSource(program, 1, &length[0], &source[0]);
297 	ctx.expectError(GL_INVALID_OPERATION);
298 	ctx.endSection();
299 
300 	ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
301 	ctx.glGetShaderSource(shader, -1, &length[0], &source[0]);
302 	ctx.expectError(GL_INVALID_VALUE);
303 	ctx.endSection();
304 
305 	ctx.glDeleteProgram(program);
306 	ctx.glDeleteShader(shader);
307 }
308 
309 // Enumerated state queries: Programs
310 
get_programiv(NegativeTestContext & ctx)311 void get_programiv (NegativeTestContext& ctx)
312 {
313 	GLuint program	= ctx.glCreateProgram();
314 	GLuint shader	= ctx.glCreateShader(GL_VERTEX_SHADER);
315 	GLint params[1]	= { -1 };
316 
317 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
318 	ctx.glGetProgramiv(program, -1, &params[0]);
319 	ctx.expectError(GL_INVALID_ENUM);
320 	ctx.endSection();
321 
322 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
323 	ctx.glGetProgramiv(-1, GL_LINK_STATUS, &params[0]);
324 	ctx.expectError(GL_INVALID_VALUE);
325 	ctx.endSection();
326 
327 	ctx.beginSection("GL_INVALID_OPERATION is generated if program does not refer to a program object.");
328 	ctx.glGetProgramiv(shader, GL_LINK_STATUS, &params[0]);
329 	ctx.expectError(GL_INVALID_OPERATION);
330 	ctx.endSection();
331 
332 	ctx.glDeleteProgram(program);
333 	ctx.glDeleteShader(shader);
334 }
335 
get_program_info_log(NegativeTestContext & ctx)336 void get_program_info_log (NegativeTestContext& ctx)
337 {
338 	GLuint program	= ctx.glCreateProgram();
339 	GLuint shader	= ctx.glCreateShader(GL_VERTEX_SHADER);
340 	GLsizei length[1];
341 	char infoLog[1];
342 
343 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
344 	ctx.glGetProgramInfoLog (-1, 1, &length[0], &infoLog[0]);
345 	ctx.expectError(GL_INVALID_VALUE);
346 	ctx.endSection();
347 
348 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
349 	ctx.glGetProgramInfoLog (shader, 1, &length[0], &infoLog[0]);
350 	ctx.expectError(GL_INVALID_OPERATION);
351 	ctx.endSection();
352 
353 	ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0.");
354 	ctx.glGetProgramInfoLog (program, -1, &length[0], &infoLog[0]);
355 	ctx.expectError(GL_INVALID_VALUE);
356 	ctx.endSection();
357 
358 	ctx.glDeleteProgram(program);
359 	ctx.glDeleteShader(shader);
360 }
361 
362 // Enumerated state queries: Shader variables
363 
get_tex_parameterfv(NegativeTestContext & ctx)364 void get_tex_parameterfv (NegativeTestContext& ctx)
365 {
366 	GLfloat params[1];
367 
368 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
369 	ctx.glGetTexParameterfv (-1, GL_TEXTURE_MAG_FILTER, &params[0]);
370 	ctx.expectError(GL_INVALID_ENUM);
371 	ctx.glGetTexParameterfv (GL_TEXTURE_2D, -1, &params[0]);
372 	ctx.expectError(GL_INVALID_ENUM);
373 	ctx.glGetTexParameterfv (-1, -1, &params[0]);
374 	ctx.expectError(GL_INVALID_ENUM);
375 	ctx.endSection();
376 }
377 
get_tex_parameteriv(NegativeTestContext & ctx)378 void get_tex_parameteriv (NegativeTestContext& ctx)
379 {
380 	GLint params[1];
381 
382 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
383 	ctx.glGetTexParameteriv (-1, GL_TEXTURE_MAG_FILTER, &params[0]);
384 	ctx.expectError(GL_INVALID_ENUM);
385 	ctx.glGetTexParameteriv (GL_TEXTURE_2D, -1, &params[0]);
386 	ctx.expectError(GL_INVALID_ENUM);
387 	ctx.glGetTexParameteriv (-1, -1, &params[0]);
388 	ctx.expectError(GL_INVALID_ENUM);
389 	ctx.endSection();
390 }
391 
get_uniformfv(NegativeTestContext & ctx)392 void get_uniformfv (NegativeTestContext& ctx)
393 {
394 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
395 	ctx.glUseProgram(program.getProgram());
396 
397 	GLint unif = ctx.glGetUniformLocation(program.getProgram(), "vUnif_vec4");	// vec4
398 	if (unif == -1)
399 		ctx.fail("Failed to retrieve uniform location");
400 
401 	GLuint shader		= ctx.glCreateShader(GL_VERTEX_SHADER);
402 	GLuint programEmpty = ctx.glCreateProgram();
403 	GLfloat params[4];
404 
405 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
406 	ctx.glGetUniformfv (-1, unif, &params[0]);
407 	ctx.expectError(GL_INVALID_VALUE);
408 	ctx.endSection();
409 
410 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
411 	ctx.glGetUniformfv (shader, unif, &params[0]);
412 	ctx.expectError(GL_INVALID_OPERATION);
413 	ctx.endSection();
414 
415 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
416 	ctx.glGetUniformfv (programEmpty, unif, &params[0]);
417 	ctx.expectError(GL_INVALID_OPERATION);
418 	ctx.endSection();
419 
420 	ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
421 	ctx.glGetUniformfv (program.getProgram(), -1, &params[0]);
422 	ctx.expectError(GL_INVALID_OPERATION);
423 	ctx.endSection();
424 
425 	ctx.glDeleteShader(shader);
426 	ctx.glDeleteProgram(programEmpty);
427 }
428 
get_uniformiv(NegativeTestContext & ctx)429 void get_uniformiv (NegativeTestContext& ctx)
430 {
431 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
432 	ctx.glUseProgram(program.getProgram());
433 
434 	GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_ivec4");	// ivec4
435 	if (unif == -1)
436 		ctx.fail("Failed to retrieve uniform location");
437 
438 	GLuint shader		= ctx.glCreateShader(GL_VERTEX_SHADER);
439 	GLuint programEmpty = ctx.glCreateProgram();
440 	GLint params[4];
441 
442 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
443 	ctx.glGetUniformiv (-1, unif, &params[0]);
444 	ctx.expectError(GL_INVALID_VALUE);
445 	ctx.endSection();
446 
447 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
448 	ctx.glGetUniformiv (shader, unif, &params[0]);
449 	ctx.expectError(GL_INVALID_OPERATION);
450 	ctx.endSection();
451 
452 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
453 	ctx.glGetUniformiv (programEmpty, unif, &params[0]);
454 	ctx.expectError(GL_INVALID_OPERATION);
455 	ctx.endSection();
456 
457 	ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
458 	ctx.glGetUniformiv (program.getProgram(), -1, &params[0]);
459 	ctx.expectError(GL_INVALID_OPERATION);
460 	ctx.endSection();
461 
462 	ctx.glDeleteShader(shader);
463 	ctx.glDeleteProgram(programEmpty);
464 }
465 
get_uniformuiv(NegativeTestContext & ctx)466 void get_uniformuiv (NegativeTestContext& ctx)
467 {
468 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
469 	ctx.glUseProgram(program.getProgram());
470 
471 	GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_uvec4");	// uvec4
472 	if (unif == -1)
473 		ctx.fail("Failed to retrieve uniform location");
474 
475 	GLuint shader		= ctx.glCreateShader(GL_VERTEX_SHADER);
476 	GLuint programEmpty = ctx.glCreateProgram();
477 	GLuint params[4];
478 
479 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
480 	ctx.glGetUniformuiv (-1, unif, &params[0]);
481 	ctx.expectError(GL_INVALID_VALUE);
482 	ctx.endSection();
483 
484 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
485 	ctx.glGetUniformuiv (shader, unif, &params[0]);
486 	ctx.expectError(GL_INVALID_OPERATION);
487 	ctx.endSection();
488 
489 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
490 	ctx.glGetUniformuiv (programEmpty, unif, &params[0]);
491 	ctx.expectError(GL_INVALID_OPERATION);
492 	ctx.endSection();
493 
494 	ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
495 	ctx.glGetUniformuiv (program.getProgram(), -1, &params[0]);
496 	ctx.expectError(GL_INVALID_OPERATION);
497 	ctx.endSection();
498 
499 	ctx.glDeleteShader(shader);
500 	ctx.glDeleteProgram(programEmpty);
501 }
502 
get_active_uniform(NegativeTestContext & ctx)503 void get_active_uniform (NegativeTestContext& ctx)
504 {
505 	GLuint				shader				= ctx.glCreateShader(GL_VERTEX_SHADER);
506 	glu::ShaderProgram	program				(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
507 	GLint				numActiveUniforms	= -1;
508 
509 	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORMS,	&numActiveUniforms);
510 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
511 
512 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
513 	ctx.glGetActiveUniform(-1, 0, 0, 0, 0, 0, 0);
514 	ctx.expectError(GL_INVALID_VALUE);
515 	ctx.endSection();
516 
517 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
518 	ctx.glGetActiveUniform(shader, 0, 0, 0, 0, 0, 0);
519 	ctx.expectError(GL_INVALID_OPERATION);
520 	ctx.endSection();
521 
522 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to the number of active uniform variables in program.");
523 	ctx.glUseProgram(program.getProgram());
524 	ctx.glGetActiveUniform(program.getProgram(), numActiveUniforms, 0, 0, 0, 0, 0);
525 	ctx.expectError(GL_INVALID_VALUE);
526 	ctx.endSection();
527 
528 	ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
529 	ctx.glGetActiveUniform(program.getProgram(), 0, -1, 0, 0, 0, 0);
530 	ctx.expectError(GL_INVALID_VALUE);
531 	ctx.endSection();
532 
533 	ctx.glUseProgram(0);
534 	ctx.glDeleteShader(shader);
535 }
536 
get_active_uniformsiv(NegativeTestContext & ctx)537 void get_active_uniformsiv (NegativeTestContext& ctx)
538 {
539 	GLuint					shader				= ctx.glCreateShader(GL_VERTEX_SHADER);
540 	glu::ShaderProgram		program				(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
541 	GLuint					dummyUniformIndex	= 1;
542 	GLint					dummyParamDst		= -1;
543 	GLint					numActiveUniforms	= -1;
544 
545 	ctx.glUseProgram(program.getProgram());
546 
547 	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
548 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
549 
550 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
551 	ctx.glGetActiveUniformsiv(-1, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
552 	ctx.expectError(GL_INVALID_VALUE);
553 	ctx.endSection();
554 
555 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
556 	ctx.glGetActiveUniformsiv(shader, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
557 	ctx.expectError(GL_INVALID_OPERATION);
558 	ctx.endSection();
559 
560 	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.");
561 	for (int excess = 0; excess <= 2; excess++)
562 	{
563 		std::vector<GLuint> invalidUniformIndices;
564 		invalidUniformIndices.push_back(1);
565 		invalidUniformIndices.push_back(numActiveUniforms-1+excess);
566 		invalidUniformIndices.push_back(1);
567 
568 		std::vector<GLint> dummyParamsDst(invalidUniformIndices.size());
569 		ctx.glGetActiveUniformsiv(program.getProgram(), (GLsizei)invalidUniformIndices.size(), &invalidUniformIndices[0], GL_UNIFORM_TYPE, &dummyParamsDst[0]);
570 		ctx.expectError(excess == 0 ? GL_NO_ERROR : GL_INVALID_VALUE);
571 	}
572 	ctx.endSection();
573 
574 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted token.");
575 	ctx.glGetActiveUniformsiv(program.getProgram(), 1, &dummyUniformIndex, -1, &dummyParamDst);
576 	ctx.expectError(GL_INVALID_ENUM);
577 	ctx.endSection();
578 
579 	ctx.glUseProgram(0);
580 	ctx.glDeleteShader(shader);
581 }
582 
get_active_uniform_blockiv(NegativeTestContext & ctx)583 void get_active_uniform_blockiv (NegativeTestContext& ctx)
584 {
585 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
586 	GLint				params			= -1;
587 	GLint				numActiveBlocks	= -1;
588 
589 	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS,	&numActiveBlocks);
590 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
591 	ctx.expectError		(GL_NO_ERROR);
592 
593 	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.");
594 	ctx.glUseProgram(program.getProgram());
595 	ctx.expectError(GL_NO_ERROR);
596 	ctx.glGetActiveUniformBlockiv(program.getProgram(), numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, &params);
597 	ctx.expectError(GL_INVALID_VALUE);
598 	ctx.endSection();
599 
600 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
601 	ctx.glGetActiveUniformBlockiv(program.getProgram(), 0, -1, &params);
602 	ctx.expectError(GL_INVALID_ENUM);
603 	ctx.endSection();
604 
605 	ctx.glUseProgram(0);
606 }
607 
get_active_uniform_block_name(NegativeTestContext & ctx)608 void get_active_uniform_block_name (NegativeTestContext& ctx)
609 {
610 	glu::ShaderProgram	program			(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
611 	GLsizei				length			= -1;
612 	GLint				numActiveBlocks	= -1;
613 	GLchar				uniformBlockName[128];
614 
615 	deMemset(&uniformBlockName[0], 0, sizeof(uniformBlockName));
616 
617 	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS,	&numActiveBlocks);
618 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
619 	ctx.expectError		(GL_NO_ERROR);
620 
621 	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.");
622 	ctx.glUseProgram(program.getProgram());
623 	ctx.expectError(GL_NO_ERROR);
624 	ctx.glGetActiveUniformBlockName(program.getProgram(), numActiveBlocks, (int)sizeof(uniformBlockName), &length, &uniformBlockName[0]);
625 	ctx.expectError(GL_INVALID_VALUE);
626 	ctx.endSection();
627 
628 	ctx.glUseProgram(0);
629 }
630 
get_active_attrib(NegativeTestContext & ctx)631 void get_active_attrib (NegativeTestContext& ctx)
632 {
633 	GLuint				shader				= ctx.glCreateShader(GL_VERTEX_SHADER);
634 	glu::ShaderProgram	program				(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
635 	GLint				numActiveAttributes	= -1;
636 
637 	GLsizei				length				= -1;
638 	GLint				size				= -1;
639 	GLenum				type				= -1;
640 	GLchar				name[32];
641 
642 	deMemset(&name[0], 0, sizeof(name));
643 
644 	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_ATTRIBUTES,	&numActiveAttributes);
645 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_ATTRIBUTES = " << numActiveAttributes << " (expected 1)." << TestLog::EndMessage;
646 
647 	ctx.glUseProgram(program.getProgram());
648 
649 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
650 	ctx.glGetActiveAttrib(-1, 0, 32, &length, &size, &type, &name[0]);
651 	ctx.expectError(GL_INVALID_VALUE);
652 	ctx.endSection();
653 
654 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
655 	ctx.glGetActiveAttrib(shader, 0, 32, &length, &size, &type, &name[0]);
656 	ctx.expectError(GL_INVALID_OPERATION);
657 	ctx.endSection();
658 
659 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_ACTIVE_ATTRIBUTES.");
660 	ctx.glGetActiveAttrib(program.getProgram(), numActiveAttributes, (int)sizeof(name), &length, &size, &type, &name[0]);
661 	ctx.expectError(GL_INVALID_VALUE);
662 	ctx.endSection();
663 
664 	ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
665 	ctx.glGetActiveAttrib(program.getProgram(), 0, -1, &length, &size, &type, &name[0]);
666 	ctx.expectError(GL_INVALID_VALUE);
667 	ctx.endSection();
668 
669 	ctx.glUseProgram(0);
670 	ctx.glDeleteShader(shader);
671 }
672 
get_uniform_indices(NegativeTestContext & ctx)673 void get_uniform_indices (NegativeTestContext& ctx)
674 {
675 	GLuint shader			= ctx.glCreateShader(GL_VERTEX_SHADER);
676 	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
677 	GLint numActiveBlocks = -1;
678 	const GLchar* uniformName =  "Block.blockVar";
679 	GLuint uniformIndices = -1;
680 
681 	ctx.glGetProgramiv	(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS,	&numActiveBlocks);
682 	ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = "		<< numActiveBlocks			<< TestLog::EndMessage;
683 	ctx.expectError		(GL_NO_ERROR);
684 
685 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is a name of shader object.");
686 	ctx.glGetUniformIndices(shader, 1, &uniformName, &uniformIndices);
687 	ctx.expectError(GL_INVALID_OPERATION);
688 	ctx.endSection();
689 
690 	ctx.beginSection("GL_INVALID_VALUE is generated if program is not name of program or shader object.");
691 	GLuint invalid = -1;
692 	ctx.glGetUniformIndices(invalid, 1, &uniformName, &uniformIndices);
693 	ctx.expectError(GL_INVALID_VALUE);
694 	ctx.endSection();
695 
696 	ctx.glUseProgram(0);
697 	ctx.glDeleteShader(shader);
698 }
699 
get_vertex_attribfv(NegativeTestContext & ctx)700 void get_vertex_attribfv (NegativeTestContext& ctx)
701 {
702 	GLfloat params = 0.0f;
703 
704 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
705 	ctx.glGetVertexAttribfv(0, -1, &params);
706 	ctx.expectError(GL_INVALID_ENUM);
707 	ctx.endSection();
708 
709 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
710 	GLint maxVertexAttribs;
711 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
712 	ctx.glGetVertexAttribfv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
713 	ctx.expectError(GL_INVALID_VALUE);
714 	ctx.endSection();
715 }
716 
get_vertex_attribiv(NegativeTestContext & ctx)717 void get_vertex_attribiv (NegativeTestContext& ctx)
718 {
719 	GLint params = -1;
720 
721 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
722 	ctx.glGetVertexAttribiv(0, -1, &params);
723 	ctx.expectError(GL_INVALID_ENUM);
724 	ctx.endSection();
725 
726 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
727 	GLint maxVertexAttribs;
728 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
729 	ctx.glGetVertexAttribiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
730 	ctx.expectError(GL_INVALID_VALUE);
731 	ctx.endSection();
732 }
733 
get_vertex_attribi_iv(NegativeTestContext & ctx)734 void get_vertex_attribi_iv (NegativeTestContext& ctx)
735 {
736 	GLint params = -1;
737 
738 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
739 	ctx.glGetVertexAttribIiv(0, -1, &params);
740 	ctx.expectError(GL_INVALID_ENUM);
741 	ctx.endSection();
742 
743 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
744 	GLint maxVertexAttribs;
745 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
746 	ctx.glGetVertexAttribIiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
747 	ctx.expectError(GL_INVALID_VALUE);
748 	ctx.endSection();
749 }
750 
get_vertex_attribi_uiv(NegativeTestContext & ctx)751 void get_vertex_attribi_uiv (NegativeTestContext& ctx)
752 {
753 	GLuint params = (GLuint)-1;
754 
755 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
756 	ctx.glGetVertexAttribIuiv(0, -1, &params);
757 	ctx.expectError(GL_INVALID_ENUM);
758 	ctx.endSection();
759 
760 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
761 	GLint maxVertexAttribs;
762 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
763 	ctx.glGetVertexAttribIuiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &params);
764 	ctx.expectError(GL_INVALID_VALUE);
765 	ctx.endSection();
766 }
767 
get_vertex_attrib_pointerv(NegativeTestContext & ctx)768 void get_vertex_attrib_pointerv (NegativeTestContext& ctx)
769 {
770 	GLvoid* ptr[1] = { DE_NULL };
771 
772 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
773 	ctx.glGetVertexAttribPointerv(0, -1, &ptr[0]);
774 	ctx.expectError(GL_INVALID_ENUM);
775 	ctx.endSection();
776 
777 	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
778 	GLint maxVertexAttribs;
779 	ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
780 	ctx.glGetVertexAttribPointerv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr[0]);
781 	ctx.expectError(GL_INVALID_VALUE);
782 	ctx.endSection();
783 }
784 
get_frag_data_location(NegativeTestContext & ctx)785 void get_frag_data_location (NegativeTestContext& ctx)
786 {
787 	GLuint shader	= ctx.glCreateShader(GL_VERTEX_SHADER);
788 	GLuint program	= ctx.glCreateProgram();
789 
790 	ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
791 	ctx.glGetFragDataLocation(shader, "gl_FragColor");
792 	ctx.expectError(GL_INVALID_OPERATION);
793 	ctx.endSection();
794 
795 	ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been linked.");
796 	ctx.glGetFragDataLocation(program, "gl_FragColor");
797 	ctx.expectError(GL_INVALID_OPERATION);
798 	ctx.endSection();
799 
800 	ctx.glDeleteProgram(program);
801 	ctx.glDeleteShader(shader);
802 }
803 
804 // Enumerated state queries: Buffers
805 
get_buffer_parameteriv(NegativeTestContext & ctx)806 void get_buffer_parameteriv (NegativeTestContext& ctx)
807 {
808 	GLint params = -1;
809 	GLuint buf;
810 	ctx.glGenBuffers(1, &buf);
811 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
812 
813 	ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value.");
814 	ctx.glGetBufferParameteriv(-1, GL_BUFFER_SIZE, &params);
815 	ctx.expectError(GL_INVALID_ENUM);
816 	ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, -1, &params);
817 	ctx.expectError(GL_INVALID_ENUM);
818 	ctx.glGetBufferParameteriv(-1, -1, &params);
819 	ctx.expectError(GL_INVALID_ENUM);
820 	ctx.endSection();
821 
822 	ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
823 	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
824 	ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &params);
825 	ctx.expectError(GL_INVALID_OPERATION);
826 	ctx.endSection();
827 
828 	ctx.glDeleteBuffers(1, &buf);
829 }
830 
get_buffer_parameteri64v(NegativeTestContext & ctx)831 void get_buffer_parameteri64v (NegativeTestContext& ctx)
832 {
833 	GLint64 params = -1;
834 	GLuint buf;
835 	ctx.glGenBuffers(1, &buf);
836 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
837 
838 	ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value.");
839 	ctx.glGetBufferParameteri64v(-1, GL_BUFFER_SIZE, &params);
840 	ctx.expectError(GL_INVALID_ENUM);
841 	ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER , -1, &params);
842 	ctx.expectError(GL_INVALID_ENUM);
843 	ctx.glGetBufferParameteri64v(-1, -1, &params);
844 	ctx.expectError(GL_INVALID_ENUM);
845 	ctx.endSection();
846 
847 	ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
848 	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
849 	ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &params);
850 	ctx.expectError(GL_INVALID_OPERATION);
851 	ctx.endSection();
852 
853 	ctx.glDeleteBuffers(1, &buf);
854 }
855 
get_buffer_pointerv(NegativeTestContext & ctx)856 void get_buffer_pointerv (NegativeTestContext& ctx)
857 {
858 	GLvoid* params = DE_NULL;
859 	GLuint buf;
860 	ctx.glGenBuffers(1, &buf);
861 	ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
862 
863 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
864 	ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, -1, &params);
865 	ctx.expectError(GL_INVALID_ENUM);
866 	ctx.glGetBufferPointerv(-1, GL_BUFFER_MAP_POINTER, &params);
867 	ctx.expectError(GL_INVALID_ENUM);
868 	ctx.endSection();
869 
870 	ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
871 	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
872 	ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, GL_BUFFER_MAP_POINTER, &params);
873 	ctx.expectError(GL_INVALID_OPERATION);
874 	ctx.endSection();
875 
876 	ctx.glDeleteBuffers(1, &buf);
877 }
878 
get_framebuffer_attachment_parameteriv(NegativeTestContext & ctx)879 void get_framebuffer_attachment_parameteriv (NegativeTestContext& ctx)
880 {
881 	GLint params[1] = { -1 };
882 	GLuint fbo;
883 	GLuint rbo[2];
884 
885 	ctx.glGenFramebuffers			(1, &fbo);
886 	ctx.glGenRenderbuffers			(2, rbo);
887 
888 	ctx.glBindFramebuffer			(GL_FRAMEBUFFER,	fbo);
889 	ctx.glBindRenderbuffer			(GL_RENDERBUFFER,	rbo[0]);
890 	ctx.glRenderbufferStorage		(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 16, 16);
891 	ctx.glFramebufferRenderbuffer	(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
892 	ctx.glBindRenderbuffer			(GL_RENDERBUFFER,	rbo[1]);
893 	ctx.glRenderbufferStorage		(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 16, 16);
894 	ctx.glFramebufferRenderbuffer	(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
895 	ctx.glCheckFramebufferStatus	(GL_FRAMEBUFFER);
896 	ctx.expectError					(GL_NO_ERROR);
897 
898 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
899 	ctx.glGetFramebufferAttachmentParameteriv(-1, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &params[0]);					// TYPE is GL_RENDERBUFFER
900 	ctx.expectError(GL_INVALID_ENUM);
901 	ctx.endSection();
902 
903 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
904 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &params[0]);	// TYPE is GL_RENDERBUFFER
905 	ctx.expectError(GL_INVALID_ENUM);
906 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
907 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);					// TYPE is GL_FRAMEBUFFER_DEFAULT
908 	ctx.expectError(GL_INVALID_ENUM);
909 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
910 	ctx.endSection();
911 
912 	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.");
913 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);
914 	ctx.expectError(GL_INVALID_OPERATION);
915 	ctx.endSection();
916 
917 	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.");
918 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);		// TYPE is GL_NONE
919 	ctx.expectError(GL_NO_ERROR);
920 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, &params[0]);	// TYPE is GL_NONE
921 	ctx.expectError(GL_INVALID_OPERATION);
922 	ctx.endSection();
923 
924 	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.");
925 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);					// A FBO is bound so GL_BACK is invalid
926 	ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
927 	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
928 	ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &params[0]);		// Default framebuffer is bound so GL_COLOR_ATTACHMENT0 is invalid
929 	ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
930 	ctx.endSection();
931 
932 	ctx.glDeleteFramebuffers(1, &fbo);
933 }
934 
get_renderbuffer_parameteriv(NegativeTestContext & ctx)935 void get_renderbuffer_parameteriv (NegativeTestContext& ctx)
936 {
937 	GLint params[1] = { -1 };
938 	GLuint rbo;
939 	ctx.glGenRenderbuffers(1, &rbo);
940 	ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
941 
942 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
943 	ctx.glGetRenderbufferParameteriv(-1, GL_RENDERBUFFER_WIDTH, &params[0]);
944 	ctx.expectError(GL_INVALID_ENUM);
945 	ctx.endSection();
946 
947 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
948 	ctx.glGetRenderbufferParameteriv(GL_RENDERBUFFER, -1, &params[0]);
949 	ctx.expectError(GL_INVALID_ENUM);
950 	ctx.endSection();
951 
952 	ctx.glDeleteRenderbuffers(1, &rbo);
953 	ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
954 }
955 
get_internalformativ(NegativeTestContext & ctx)956 void get_internalformativ (NegativeTestContext& ctx)
957 {
958 	GLint params[16];
959 
960 	deMemset(&params[0], 0xcd, sizeof(params));
961 
962 	ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is negative.");
963 	ctx.glGetInternalformativ	(GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, -1, &params[0]);
964 	ctx.expectError				(GL_INVALID_VALUE);
965 	ctx.endSection();
966 
967 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_SAMPLES or GL_NUM_SAMPLE_COUNTS.");
968 	ctx.glGetInternalformativ	(GL_RENDERBUFFER, GL_RGBA8, -1, 16, &params[0]);
969 	ctx.expectError				(GL_INVALID_ENUM);
970 	ctx.endSection();
971 
972 	ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not color-, depth-, or stencil-renderable.");
973 	ctx.glGetInternalformativ	(GL_RENDERBUFFER, GL_RG8_SNORM, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
974 	ctx.expectError				(GL_INVALID_ENUM);
975 	ctx.glGetInternalformativ	(GL_RENDERBUFFER, GL_COMPRESSED_RGB8_ETC2, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
976 	ctx.expectError				(GL_INVALID_ENUM);
977 	ctx.endSection();
978 
979 	ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
980 	ctx.glGetInternalformativ	(-1, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
981 	ctx.expectError				(GL_INVALID_ENUM);
982 	ctx.glGetInternalformativ	(GL_FRAMEBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
983 	ctx.expectError				(GL_INVALID_ENUM);
984 	ctx.glGetInternalformativ	(GL_TEXTURE_2D, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, &params[0]);
985 	ctx.expectError				(GL_INVALID_ENUM);
986 	ctx.endSection();
987 }
988 
989 // Query object queries
990 
get_queryiv(NegativeTestContext & ctx)991 void get_queryiv (NegativeTestContext& ctx)
992 {
993 	GLint params = -1;
994 
995 	ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
996 	ctx.glGetQueryiv	(GL_ANY_SAMPLES_PASSED, -1, &params);
997 	ctx.expectError		(GL_INVALID_ENUM);
998 	ctx.glGetQueryiv	(-1, GL_CURRENT_QUERY, &params);
999 	ctx.expectError		(GL_INVALID_ENUM);
1000 	ctx.glGetQueryiv	(-1, -1, &params);
1001 	ctx.expectError		(GL_INVALID_ENUM);
1002 	ctx.endSection();
1003 }
1004 
get_query_objectuiv(NegativeTestContext & ctx)1005 void get_query_objectuiv (NegativeTestContext& ctx)
1006 {
1007 	GLuint params	= -1;
1008 	GLuint id;
1009 	ctx.glGenQueries		(1, &id);
1010 
1011 	ctx.beginSection("GL_INVALID_OPERATION is generated if id is not the name of a query object.");
1012 	ctx.glGetQueryObjectuiv	(-1, GL_QUERY_RESULT_AVAILABLE, &params);
1013 	ctx.expectError			(GL_INVALID_OPERATION);
1014 	ctx.getLog() << TestLog::Message << "// Note: " << id << " is not a query object yet, since it hasn't been used by glBeginQuery" << TestLog::EndMessage;
1015 	ctx.glGetQueryObjectuiv	(id, GL_QUERY_RESULT_AVAILABLE, &params);
1016 	ctx.expectError			(GL_INVALID_OPERATION);
1017 	ctx.endSection();
1018 
1019 	ctx.glBeginQuery		(GL_ANY_SAMPLES_PASSED, id);
1020 	ctx.glEndQuery			(GL_ANY_SAMPLES_PASSED);
1021 
1022 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1023 	ctx.glGetQueryObjectuiv	(id, -1, &params);
1024 	ctx.expectError			(GL_INVALID_ENUM);
1025 	ctx.endSection();
1026 
1027 	ctx.beginSection("GL_INVALID_OPERATION is generated if id is the name of a currently active query object.");
1028 	ctx.glBeginQuery		(GL_ANY_SAMPLES_PASSED, id);
1029 	ctx.expectError			(GL_NO_ERROR);
1030 	ctx.glGetQueryObjectuiv	(id, GL_QUERY_RESULT_AVAILABLE, &params);
1031 	ctx.expectError			(GL_INVALID_OPERATION);
1032 	ctx.glEndQuery			(GL_ANY_SAMPLES_PASSED);
1033 	ctx.expectError			(GL_NO_ERROR);
1034 	ctx.endSection();
1035 
1036 	ctx.glDeleteQueries		(1, &id);
1037 }
1038 
1039 // Sync object queries
1040 
get_synciv(NegativeTestContext & ctx)1041 void get_synciv (NegativeTestContext& ctx)
1042 {
1043 	GLsizei length	= -1;
1044 	GLint	values[32];
1045 	GLsync	sync;
1046 
1047 	deMemset(&values[0], 0xcd, sizeof(values));
1048 
1049 	ctx.beginSection("GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
1050 	ctx.glGetSynciv	(0, GL_OBJECT_TYPE, 32, &length, &values[0]);
1051 	ctx.expectError	(GL_INVALID_VALUE);
1052 	ctx.endSection();
1053 
1054 	ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
1055 	sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1056 	ctx.expectError	(GL_NO_ERROR);
1057 	ctx.glGetSynciv	(sync, -1, 32, &length, &values[0]);
1058 	ctx.expectError	(GL_INVALID_ENUM);
1059 	ctx.endSection();
1060 
1061 	ctx.glDeleteSync(sync);
1062 }
1063 
1064 // Enumerated boolean state queries
1065 
is_enabled(NegativeTestContext & ctx)1066 void is_enabled (NegativeTestContext& ctx)
1067 {
1068 	ctx.beginSection("GL_INVALID_ENUM is generated if cap is not an accepted value.");
1069 	ctx.glIsEnabled(-1);
1070 	ctx.expectError(GL_INVALID_ENUM);
1071 	ctx.glIsEnabled(GL_TRIANGLES);
1072 	ctx.expectError(GL_INVALID_ENUM);
1073 	ctx.endSection();
1074 }
1075 
1076 // Hints
1077 
hint(NegativeTestContext & ctx)1078 void hint (NegativeTestContext& ctx)
1079 {
1080 	ctx.beginSection("GL_INVALID_ENUM is generated if either target or mode is not an accepted value.");
1081 	ctx.glHint(GL_GENERATE_MIPMAP_HINT, -1);
1082 	ctx.expectError(GL_INVALID_ENUM);
1083 	ctx.glHint(-1, GL_FASTEST);
1084 	ctx.expectError(GL_INVALID_ENUM);
1085 	ctx.glHint(-1, -1);
1086 	ctx.expectError(GL_INVALID_ENUM);
1087 	ctx.endSection();
1088 }
1089 
getNegativeStateApiTestFunctions()1090 std::vector<FunctionContainer> getNegativeStateApiTestFunctions ()
1091 {
1092 	FunctionContainer funcs[] =
1093 	{
1094 		{enable,									"enable",									"Invalid glEnable() usage"							   },
1095 		{disable,									"disable",									"Invalid glDisable() usage"							   },
1096 		{get_booleanv,								"get_booleanv",								"Invalid glGetBooleanv() usage"						   },
1097 		{get_floatv,								"get_floatv",								"Invalid glGetFloatv() usage"						   },
1098 		{get_integerv,								"get_integerv",								"Invalid glGetIntegerv() usage"						   },
1099 		{get_integer64v,							"get_integer64v",							"Invalid glGetInteger64v() usage"					   },
1100 		{get_integeri_v,							"get_integeri_v",							"Invalid glGetIntegeri_v() usage"					   },
1101 		{get_integer64i_v,							"get_integer64i_v",							"Invalid glGetInteger64i_v() usage"					   },
1102 		{get_string,								"get_string",								"Invalid glGetString() usage"						   },
1103 		{get_stringi,								"get_stringi",								"Invalid glGetStringi() usage"						   },
1104 		{get_attached_shaders,						"get_attached_shaders",						"Invalid glGetAttachedShaders() usage"				   },
1105 		{get_shaderiv,								"get_shaderiv",								"Invalid glGetShaderiv() usage"						   },
1106 		{get_shader_info_log,						"get_shader_info_log",						"Invalid glGetShaderInfoLog() usage"				   },
1107 		{get_shader_precision_format,				"get_shader_precision_format",				"Invalid glGetShaderPrecisionFormat() usage"		   },
1108 		{get_shader_source,							"get_shader_source",						"Invalid glGetShaderSource() usage"					   },
1109 		{get_programiv,								"get_programiv",							"Invalid glGetProgramiv() usage"					   },
1110 		{get_program_info_log,						"get_program_info_log",						"Invalid glGetProgramInfoLog() usage"				   },
1111 		{get_tex_parameterfv,						"get_tex_parameterfv",						"Invalid glGetTexParameterfv() usage"				   },
1112 		{get_tex_parameteriv,						"get_tex_parameteriv",						"Invalid glGetTexParameteriv() usage"				   },
1113 		{get_uniformfv,								"get_uniformfv",							"Invalid glGetUniformfv() usage"					   },
1114 		{get_uniformiv,								"get_uniformiv",							"Invalid glGetUniformiv() usage"					   },
1115 		{get_uniformuiv,							"get_uniformuiv",							"Invalid glGetUniformuiv() usage"					   },
1116 		{get_active_uniform,						"get_active_uniform",						"Invalid glGetActiveUniform() usage"				   },
1117 		{get_active_uniformsiv,						"get_active_uniformsiv",					"Invalid glGetActiveUniformsiv() usage"				   },
1118 		{get_active_uniform_blockiv,				"get_active_uniform_blockiv",				"Invalid glGetActiveUniformBlockiv() usage"			   },
1119 		{get_active_uniform_block_name,				"get_active_uniform_block_name",			"Invalid glGetActiveUniformBlockName() usage"		   },
1120 		{get_active_attrib,							"get_active_attrib",						"Invalid glGetActiveAttrib() usage"					   },
1121 		{get_uniform_indices,						"get_uniform_indices",						"Invalid glGetUniformIndices() usage"				   },
1122 		{get_vertex_attribfv,						"get_vertex_attribfv",						"Invalid glGetVertexAttribfv() usage"				   },
1123 		{get_vertex_attribiv,						"get_vertex_attribiv",						"Invalid glGetVertexAttribiv() usage"				   },
1124 		{get_vertex_attribi_iv,						"get_vertex_attribi_iv",					"Invalid glGetVertexAttribIiv() usage"				   },
1125 		{get_vertex_attribi_uiv,					"get_vertex_attribi_uiv",					"Invalid glGetVertexAttribIuiv() usage"				   },
1126 		{get_vertex_attrib_pointerv,				"get_vertex_attrib_pointerv",				"Invalid glGetVertexAttribPointerv() usage"			   },
1127 		{get_frag_data_location,					"get_frag_data_location",					"Invalid glGetFragDataLocation() usage"				   },
1128 		{get_buffer_parameteriv,					"get_buffer_parameteriv",					"Invalid glGetBufferParameteriv() usage"			   },
1129 		{get_buffer_parameteri64v,					"get_buffer_parameteri64v",					"Invalid glGetBufferParameteri64v() usage"			   },
1130 		{get_buffer_pointerv,						"get_buffer_pointerv",						"Invalid glGetBufferPointerv() usage"				   },
1131 		{get_framebuffer_attachment_parameteriv,	"get_framebuffer_attachment_parameteriv",	"Invalid glGetFramebufferAttachmentParameteriv() usage"},
1132 		{get_renderbuffer_parameteriv,				"get_renderbuffer_parameteriv",				"Invalid glGetRenderbufferParameteriv() usage"		   },
1133 		{get_internalformativ,						"get_internalformativ",						"Invalid glGetInternalformativ() usage"				   },
1134 		{get_queryiv,								"get_queryiv",								"Invalid glGetQueryiv() usage"						   },
1135 		{get_query_objectuiv,						"get_query_objectuiv",						"Invalid glGetQueryObjectuiv() usage"				   },
1136 		{get_synciv,								"get_synciv",								"Invalid glGetSynciv() usage"						   },
1137 		{is_enabled,								"is_enabled",								"Invalid glIsEnabled() usage"						   },
1138 		{hint,										"hint",										"Invalid glHint() usage"							   },
1139 	};
1140 
1141 	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
1142 }
1143 
1144 } // NegativeTestShared
1145 } // Functional
1146 } // gles3
1147 } // deqp
1148