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
33 using namespace glw; // GL types
34
35 namespace deqp
36 {
37 namespace gles3
38 {
39 namespace Functional
40 {
41
42 using tcu::TestLog;
43
44 static 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";
52 static 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
NegativeStateApiTests(Context & context)61 NegativeStateApiTests::NegativeStateApiTests (Context& context)
62 : TestCaseGroup(context, "state", "Negative GL State API Cases")
63 {
64 }
65
~NegativeStateApiTests(void)66 NegativeStateApiTests::~NegativeStateApiTests (void)
67 {
68 }
69
init(void)70 void 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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶m[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, ¶m[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, ¶m[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[0]);
367 expectError(GL_INVALID_ENUM);
368 glGetTexParameterfv (GL_TEXTURE_2D, -1, ¶ms[0]);
369 expectError(GL_INVALID_ENUM);
370 glGetTexParameterfv (-1, -1, ¶ms[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, ¶ms[0]);
380 expectError(GL_INVALID_ENUM);
381 glGetTexParameteriv (GL_TEXTURE_2D, -1, ¶ms[0]);
382 expectError(GL_INVALID_ENUM);
383 glGetTexParameteriv (-1, -1, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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 dummyUniformIndex = 1;
533 GLint dummyParamDst = -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, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
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, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
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> dummyParamsDst(invalidUniformIndices.size());
560 glGetActiveUniformsiv(program.getProgram(), (GLsizei)invalidUniformIndices.size(), &invalidUniformIndices[0], GL_UNIFORM_TYPE, &dummyParamsDst[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, &dummyUniformIndex, -1, &dummyParamDst);
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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶ms);
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, ¶ms);
796 expectError(GL_INVALID_ENUM);
797 glGetBufferParameteriv(GL_ARRAY_BUFFER, -1, ¶ms);
798 expectError(GL_INVALID_ENUM);
799 glGetBufferParameteriv(-1, -1, ¶ms);
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, ¶ms);
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, ¶ms);
820 expectError(GL_INVALID_ENUM);
821 glGetBufferParameteri64v(GL_ARRAY_BUFFER , -1, ¶ms);
822 expectError(GL_INVALID_ENUM);
823 glGetBufferParameteri64v(-1, -1, ¶ms);
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, ¶ms);
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, ¶ms);
844 expectError(GL_INVALID_ENUM);
845 glGetBufferPointerv(-1, GL_BUFFER_MAP_POINTER, ¶ms);
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, ¶ms);
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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[0]); // TYPE is GL_NONE
897 expectError(GL_NO_ERROR);
898 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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, ¶ms[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 GLint params[16];
935
936 deMemset(¶ms[0], 0xcd, sizeof(params));
937
938 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is negative.");
939 glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, -1, ¶ms[0]);
940 expectError (GL_INVALID_VALUE);
941 m_log << TestLog::EndSection;
942
943 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not GL_SAMPLES or GL_NUM_SAMPLE_COUNTS.");
944 glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, -1, 16, ¶ms[0]);
945 expectError (GL_INVALID_ENUM);
946 m_log << TestLog::EndSection;
947
948 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not color-, depth-, or stencil-renderable.");
949 if (!m_context.getContextInfo().isExtensionSupported("GL_EXT_render_snorm"))
950 {
951 glGetInternalformativ (GL_RENDERBUFFER, GL_RG8_SNORM, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
952 expectError (GL_INVALID_ENUM);
953 }
954
955 glGetInternalformativ (GL_RENDERBUFFER, GL_COMPRESSED_RGB8_ETC2, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
956 expectError (GL_INVALID_ENUM);
957 m_log << TestLog::EndSection;
958
959 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
960 glGetInternalformativ (-1, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
961 expectError (GL_INVALID_ENUM);
962 glGetInternalformativ (GL_FRAMEBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
963 expectError (GL_INVALID_ENUM);
964
965 if (!m_context.getContextInfo().isExtensionSupported("GL_EXT_sparse_texture"))
966 {
967 glGetInternalformativ (GL_TEXTURE_2D, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
968 expectError (GL_INVALID_ENUM);
969 }
970 m_log << TestLog::EndSection;
971 });
972
973 // Query object queries
974
975 ES3F_ADD_API_CASE(get_queryiv, "Invalid glGetQueryiv() usage",
976 {
977 GLint params = -1;
978
979 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
980 glGetQueryiv (GL_ANY_SAMPLES_PASSED, -1, ¶ms);
981 expectError (GL_INVALID_ENUM);
982 glGetQueryiv (-1, GL_CURRENT_QUERY, ¶ms);
983 expectError (GL_INVALID_ENUM);
984 glGetQueryiv (-1, -1, ¶ms);
985 expectError (GL_INVALID_ENUM);
986 m_log << TestLog::EndSection;
987 });
988 ES3F_ADD_API_CASE(get_query_objectuiv, "Invalid glGetQueryObjectuiv() usage",
989 {
990 GLuint params = -1;
991 GLuint id;
992 glGenQueries (1, &id);
993
994 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id is not the name of a query object.");
995 glGetQueryObjectuiv (-1, GL_QUERY_RESULT_AVAILABLE, ¶ms);
996 expectError (GL_INVALID_OPERATION);
997 m_log << TestLog::Message << "// Note: " << id << " is not a query object yet, since it hasn't been used by glBeginQuery" << TestLog::EndMessage;
998 glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms);
999 expectError (GL_INVALID_OPERATION);
1000 m_log << TestLog::EndSection;
1001
1002 glBeginQuery (GL_ANY_SAMPLES_PASSED, id);
1003 glEndQuery (GL_ANY_SAMPLES_PASSED);
1004
1005 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
1006 glGetQueryObjectuiv (id, -1, ¶ms);
1007 expectError (GL_INVALID_ENUM);
1008 m_log << TestLog::EndSection;
1009
1010 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id is the name of a currently active query object.");
1011 glBeginQuery (GL_ANY_SAMPLES_PASSED, id);
1012 expectError (GL_NO_ERROR);
1013 glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms);
1014 expectError (GL_INVALID_OPERATION);
1015 glEndQuery (GL_ANY_SAMPLES_PASSED);
1016 expectError (GL_NO_ERROR);
1017 m_log << TestLog::EndSection;
1018
1019 glDeleteQueries (1, &id);
1020 });
1021
1022 // Sync object queries
1023
1024 ES3F_ADD_API_CASE(get_synciv, "Invalid glGetSynciv() usage",
1025 {
1026 GLsizei length = -1;
1027 GLint values[32];
1028 GLsync sync;
1029
1030 deMemset(&values[0], 0xcd, sizeof(values));
1031
1032 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
1033 glGetSynciv (0, GL_OBJECT_TYPE, 32, &length, &values[0]);
1034 expectError (GL_INVALID_VALUE);
1035 m_log << TestLog::EndSection;
1036
1037 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
1038 sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1039 expectError (GL_NO_ERROR);
1040 glGetSynciv (sync, -1, 32, &length, &values[0]);
1041 expectError (GL_INVALID_ENUM);
1042 m_log << TestLog::EndSection;
1043 });
1044
1045 // Enumerated boolean state queries
1046
1047 ES3F_ADD_API_CASE(is_enabled, "Invalid glIsEnabled() usage",
1048 {
1049 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not an accepted value.");
1050 glIsEnabled(-1);
1051 expectError(GL_INVALID_ENUM);
1052 glIsEnabled(GL_TRIANGLES);
1053 expectError(GL_INVALID_ENUM);
1054 m_log << TestLog::EndSection;
1055 });
1056
1057 // Hints
1058
1059 ES3F_ADD_API_CASE(hint, "Invalid glHint() usage",
1060 {
1061 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if either target or mode is not an accepted value.");
1062 glHint(GL_GENERATE_MIPMAP_HINT, -1);
1063 expectError(GL_INVALID_ENUM);
1064 glHint(-1, GL_FASTEST);
1065 expectError(GL_INVALID_ENUM);
1066 glHint(-1, -1);
1067 expectError(GL_INVALID_ENUM);
1068 m_log << TestLog::EndSection;
1069 });
1070
1071 // Named Object Usage
1072
1073 ES3F_ADD_API_CASE(is_buffer, "Invalid glIsBuffer() usage",
1074 {
1075 GLuint buffer = 0;
1076 GLboolean isBuffer;
1077
1078 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.");
1079 isBuffer = glIsBuffer(buffer);
1080 checkBooleans (isBuffer, GL_FALSE);
1081
1082 glGenBuffers (1, &buffer);
1083 isBuffer = glIsBuffer(buffer);
1084 checkBooleans (isBuffer, GL_FALSE);
1085
1086 glBindBuffer (GL_ARRAY_BUFFER, buffer);
1087 isBuffer = glIsBuffer(buffer);
1088 checkBooleans (isBuffer, GL_TRUE);
1089
1090 glBindBuffer (GL_ARRAY_BUFFER, 0);
1091 glDeleteBuffers (1, &buffer);
1092 isBuffer = glIsBuffer(buffer);
1093 checkBooleans (isBuffer, GL_FALSE);
1094 m_log << TestLog::EndSection;
1095
1096 expectError (GL_NO_ERROR);
1097 });
1098 ES3F_ADD_API_CASE(is_framebuffer, "Invalid glIsFramebuffer() usage",
1099 {
1100 GLuint fbo = 0;
1101 GLboolean isFbo;
1102
1103 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.");
1104 isFbo = glIsFramebuffer(fbo);
1105 checkBooleans (isFbo, GL_FALSE);
1106
1107 glGenFramebuffers (1, &fbo);
1108 isFbo = glIsFramebuffer(fbo);
1109 checkBooleans (isFbo, GL_FALSE);
1110
1111 glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1112 isFbo = glIsFramebuffer(fbo);
1113 checkBooleans (isFbo, GL_TRUE);
1114
1115 glBindFramebuffer (GL_FRAMEBUFFER, 0);
1116 glDeleteFramebuffers(1, &fbo);
1117 isFbo = glIsFramebuffer(fbo);
1118 checkBooleans (isFbo, GL_FALSE);
1119 m_log << TestLog::EndSection;
1120
1121 expectError (GL_NO_ERROR);
1122 });
1123 ES3F_ADD_API_CASE(is_program, "Invalid glIsProgram() usage",
1124 {
1125 GLuint program = 0;
1126 GLboolean isProgram;
1127
1128 m_log << TestLog::Section("", "A name created with glCreateProgram, and not yet deleted with glDeleteProgram is a name of a program object.");
1129 isProgram = glIsProgram(program);
1130 checkBooleans (isProgram, GL_FALSE);
1131
1132 program = glCreateProgram();
1133 isProgram = glIsProgram(program);
1134 checkBooleans (isProgram, GL_TRUE);
1135
1136 glDeleteProgram (program);
1137 isProgram = glIsProgram(program);
1138 checkBooleans (isProgram, GL_FALSE);
1139 m_log << TestLog::EndSection;
1140
1141 expectError (GL_NO_ERROR);
1142 });
1143 ES3F_ADD_API_CASE(is_renderbuffer, "Invalid glIsRenderbuffer() usage",
1144 {
1145 GLuint rbo = 0;
1146 GLboolean isRbo;
1147
1148 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.");
1149 isRbo = glIsRenderbuffer(rbo);
1150 checkBooleans (isRbo, GL_FALSE);
1151
1152 glGenRenderbuffers (1, &rbo);
1153 isRbo = glIsRenderbuffer(rbo);
1154 checkBooleans (isRbo, GL_FALSE);
1155
1156 glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1157 isRbo = glIsRenderbuffer(rbo);
1158 checkBooleans (isRbo, GL_TRUE);
1159
1160 glBindRenderbuffer (GL_RENDERBUFFER, 0);
1161 glDeleteRenderbuffers (1, &rbo);
1162 isRbo = glIsRenderbuffer(rbo);
1163 checkBooleans (isRbo, GL_FALSE);
1164 m_log << TestLog::EndSection;
1165
1166 expectError (GL_NO_ERROR);
1167 });
1168 ES3F_ADD_API_CASE(is_shader, "Invalid glIsShader() usage",
1169 {
1170 GLuint shader = 0;
1171 GLboolean isShader;
1172
1173 m_log << TestLog::Section("", "A name created with glCreateShader, and not yet deleted with glDeleteShader is a name of a shader object.");
1174 isShader = glIsProgram(shader);
1175 checkBooleans (isShader, GL_FALSE);
1176
1177 shader = glCreateShader(GL_VERTEX_SHADER);
1178 isShader = glIsShader(shader);
1179 checkBooleans (isShader, GL_TRUE);
1180
1181 glDeleteShader (shader);
1182 isShader = glIsShader(shader);
1183 checkBooleans (isShader, GL_FALSE);
1184 m_log << TestLog::EndSection;
1185
1186 expectError (GL_NO_ERROR);
1187 });
1188 ES3F_ADD_API_CASE(is_texture, "Invalid glIsTexture() usage",
1189 {
1190 GLuint texture = 0;
1191 GLboolean isTexture;
1192
1193 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.");
1194 isTexture = glIsTexture(texture);
1195 checkBooleans (isTexture, GL_FALSE);
1196
1197 glGenTextures (1, &texture);
1198 isTexture = glIsTexture(texture);
1199 checkBooleans (isTexture, GL_FALSE);
1200
1201 glBindTexture (GL_TEXTURE_2D, texture);
1202 isTexture = glIsTexture(texture);
1203 checkBooleans (isTexture, GL_TRUE);
1204
1205 glBindTexture (GL_TEXTURE_2D, 0);
1206 glDeleteTextures (1, &texture);
1207 isTexture = glIsTexture(texture);
1208 checkBooleans (isTexture, GL_FALSE);
1209 m_log << TestLog::EndSection;
1210
1211 expectError (GL_NO_ERROR);
1212 });
1213 ES3F_ADD_API_CASE(is_query, "Invalid glIsQuery() usage",
1214 {
1215 GLuint query = 0;
1216 GLboolean isQuery;
1217
1218 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.");
1219 isQuery = glIsQuery(query);
1220 checkBooleans (isQuery, GL_FALSE);
1221
1222 glGenQueries (1, &query);
1223 isQuery = glIsQuery(query);
1224 checkBooleans (isQuery, GL_FALSE);
1225
1226 glBeginQuery (GL_ANY_SAMPLES_PASSED, query);
1227 isQuery = glIsQuery(query);
1228 checkBooleans (isQuery, GL_TRUE);
1229
1230 glEndQuery (GL_ANY_SAMPLES_PASSED);
1231 glDeleteQueries (1, &query);
1232 isQuery = glIsQuery(query);
1233 checkBooleans (isQuery, GL_FALSE);
1234 m_log << TestLog::EndSection;
1235
1236 expectError (GL_NO_ERROR);
1237 });
1238 ES3F_ADD_API_CASE(is_sampler, "Invalid glIsSampler() usage",
1239 {
1240 GLuint sampler = 0;
1241 GLboolean isSampler;
1242
1243 m_log << TestLog::Section("", "A name returned by glGenSamplers is the name of a sampler object.");
1244 isSampler = glIsSampler(sampler);
1245 checkBooleans (isSampler, GL_FALSE);
1246
1247 glGenSamplers (1, &sampler);
1248 isSampler = glIsSampler(sampler);
1249 checkBooleans (isSampler, GL_TRUE);
1250
1251 glBindSampler (0, sampler);
1252 isSampler = glIsSampler(sampler);
1253 checkBooleans (isSampler, GL_TRUE);
1254
1255 glDeleteSamplers (1, &sampler);
1256 isSampler = glIsSampler(sampler);
1257 checkBooleans (isSampler, GL_FALSE);
1258 m_log << TestLog::EndSection;
1259
1260 expectError (GL_NO_ERROR);
1261 });
1262 ES3F_ADD_API_CASE(is_sync, "Invalid glIsSync() usage",
1263 {
1264 GLsync sync = 0;
1265 GLboolean isSync;
1266
1267 m_log << TestLog::Section("", "A name returned by glFenceSync is the name of a sync object.");
1268 isSync = glIsSync(sync);
1269 checkBooleans (isSync, GL_FALSE);
1270
1271 sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1272 isSync = glIsSync(sync);
1273 checkBooleans (isSync, GL_TRUE);
1274
1275 glDeleteSync (sync);
1276 isSync = glIsSync(sync);
1277 checkBooleans (isSync, GL_FALSE);
1278 m_log << TestLog::EndSection;
1279
1280 expectError (GL_NO_ERROR);
1281 });
1282 ES3F_ADD_API_CASE(is_transform_feedback, "Invalid glIsTransformFeedback() usage",
1283 {
1284 GLuint tf = 0;
1285 GLboolean isTF;
1286
1287 m_log << TestLog::Section("", "A name returned by glGenTransformFeedbacks, but not yet bound using glBindTransformFeedback, is not the name of a transform feedback object.");
1288 isTF = glIsTransformFeedback(tf);
1289 checkBooleans (isTF, GL_FALSE);
1290
1291 glGenTransformFeedbacks (1, &tf);
1292 isTF = glIsTransformFeedback(tf);
1293 checkBooleans (isTF, GL_FALSE);
1294
1295 glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tf);
1296 isTF = glIsTransformFeedback(tf);
1297 checkBooleans (isTF, GL_TRUE);
1298
1299 glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, 0);
1300 glDeleteTransformFeedbacks (1, &tf);
1301 isTF = glIsTransformFeedback(tf);
1302 checkBooleans (isTF, GL_FALSE);
1303 m_log << TestLog::EndSection;
1304
1305 expectError (GL_NO_ERROR);
1306 });
1307 ES3F_ADD_API_CASE(is_vertex_array, "Invalid glIsVertexArray() usage",
1308 {
1309 GLuint vao = 0;
1310 GLboolean isVao;
1311
1312 m_log << TestLog::Section("", "A name returned by glGenVertexArrays, but not yet bound using glBindVertexArray, is not the name of a vertex array object.");
1313 isVao = glIsVertexArray(vao);
1314 checkBooleans (isVao, GL_FALSE);
1315
1316 glGenVertexArrays (1, &vao);
1317 isVao = glIsVertexArray(vao);
1318 checkBooleans (isVao, GL_FALSE);
1319
1320 glBindVertexArray (vao);
1321 isVao = glIsVertexArray(vao);
1322 checkBooleans (isVao, GL_TRUE);
1323
1324 glBindVertexArray (0);
1325 glDeleteVertexArrays (1, &vao);
1326 isVao = glIsVertexArray(vao);
1327 checkBooleans (isVao, GL_FALSE);
1328 m_log << TestLog::EndSection;
1329
1330 expectError (GL_NO_ERROR);
1331 });
1332 }
1333
1334 } // Functional
1335 } // gles3
1336 } // deqp
1337