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