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