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