1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.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 "es2fNegativeStateApiTests.hpp"
25 #include "es2fApiCase.hpp"
26 #include "gluShaderProgram.hpp"
27 #include "deMemory.h"
28
29 #include "glwEnums.hpp"
30 #include "glwDefs.hpp"
31
32 using namespace glw; // GL types
33
34 namespace deqp
35 {
36 namespace gles2
37 {
38 namespace Functional
39 {
40
41 using tcu::TestLog;
42
43 static const char *uniformTestVertSource = "uniform mediump vec4 vTest;\n"
44 "void main (void)\n"
45 "{\n"
46 " gl_Position = vTest;\n"
47 "}\n\0";
48 static const char *uniformTestFragSource = "uniform mediump ivec4 fTest;\n"
49 "void main (void)\n"
50 "{\n"
51 " gl_FragColor = vec4(fTest);\n"
52 "}\n\0";
53
NegativeStateApiTests(Context & context)54 NegativeStateApiTests::NegativeStateApiTests(Context &context)
55 : TestCaseGroup(context, "state", "Negative GL State API Cases")
56 {
57 }
58
~NegativeStateApiTests(void)59 NegativeStateApiTests::~NegativeStateApiTests(void)
60 {
61 }
62
init(void)63 void NegativeStateApiTests::init(void)
64 {
65 // Enabling & disabling states
66
67 ES2F_ADD_API_CASE(enable, "Invalid glEnable() usage", {
68 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
69 glEnable(-1);
70 expectError(GL_INVALID_ENUM);
71 m_log << TestLog::EndSection;
72 });
73 ES2F_ADD_API_CASE(disable, "Invalid glDisable() usage", {
74 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
75 glDisable(-1);
76 expectError(GL_INVALID_ENUM);
77 m_log << TestLog::EndSection;
78 });
79
80 // Simple state queries
81
82 ES2F_ADD_API_CASE(get_booleanv, "Invalid glGetBooleanv() usage", {
83 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
84 GLboolean params[1] = {GL_FALSE};
85 glGetBooleanv(-1, ¶ms[0]);
86 expectError(GL_INVALID_ENUM);
87 m_log << TestLog::EndSection;
88 });
89 ES2F_ADD_API_CASE(get_floatv, "Invalid glGetFloatv() usage", {
90 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
91 GLfloat params[1] = {0.0f};
92 glGetFloatv(-1, ¶ms[0]);
93 expectError(GL_INVALID_ENUM);
94 m_log << TestLog::EndSection;
95 });
96 ES2F_ADD_API_CASE(get_integerv, "Invalid glGetIntegerv() usage", {
97 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
98 GLint params[1] = {0};
99 glGetIntegerv(-1, ¶ms[0]);
100 expectError(GL_INVALID_ENUM);
101 m_log << TestLog::EndSection;
102 });
103 ES2F_ADD_API_CASE(get_string, "Invalid glGetString() usage", {
104 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
105 glGetString(0);
106 expectError(GL_INVALID_ENUM);
107 m_log << TestLog::EndSection;
108 });
109
110 // Enumerated state queries: Shaders
111
112 ES2F_ADD_API_CASE(get_attached_shaders, "Invalid glGetAttachedShaders() usage", {
113 GLuint shaders[1] = {0};
114 GLuint shaderObject = glCreateShader(GL_VERTEX_SHADER);
115 GLuint program = glCreateProgram();
116 GLsizei count[1] = {-1};
117
118 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
119 glGetAttachedShaders(-1, 1, &count[0], &shaders[0]);
120 expectError(GL_INVALID_VALUE);
121 m_log << TestLog::EndSection;
122
123 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
124 glGetAttachedShaders(shaderObject, 1, &count[0], &shaders[0]);
125 expectError(GL_INVALID_OPERATION);
126 m_log << TestLog::EndSection;
127
128 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxCount is less than 0.");
129 glGetAttachedShaders(program, -1, &count[0], &shaders[0]);
130 expectError(GL_INVALID_VALUE);
131 m_log << TestLog::EndSection;
132
133 glDeleteShader(shaderObject);
134 glDeleteProgram(program);
135 });
136 ES2F_ADD_API_CASE(get_shaderiv, "Invalid glGetShaderiv() usage", {
137 GLboolean shaderCompilerSupported;
138 glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
139 if (!shaderCompilerSupported)
140 m_log << TestLog::Message << "// Shader compiler not supported, always expect GL_INVALID_OPERATION"
141 << TestLog::EndMessage;
142 else
143 m_log << TestLog::Message << "// Shader compiler supported" << TestLog::EndMessage;
144
145 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
146 GLuint program = glCreateProgram();
147 GLint param[1] = {-1};
148
149 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
150 glGetShaderiv(shader, -1, ¶m[0]);
151 expectError(GL_INVALID_ENUM);
152 m_log << TestLog::EndSection;
153
154 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
155 glGetShaderiv(-1, GL_SHADER_TYPE, ¶m[0]);
156 expectError(GL_INVALID_VALUE);
157 m_log << TestLog::EndSection;
158
159 m_log << TestLog::Section(
160 "", "GL_INVALID_OPERATION is generated if pname is GL_COMPILE_STATUS, GL_INFO_LOG_LENGTH, or "
161 "GL_SHADER_SOURCE_LENGTH but a shader compiler is not supported.");
162 glGetShaderiv(shader, GL_COMPILE_STATUS, ¶m[0]);
163 expectError(shaderCompilerSupported ? GL_NO_ERROR : GL_INVALID_OPERATION);
164 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, ¶m[0]);
165 expectError(shaderCompilerSupported ? GL_NO_ERROR : GL_INVALID_OPERATION);
166 glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, ¶m[0]);
167 expectError(shaderCompilerSupported ? GL_NO_ERROR : GL_INVALID_OPERATION);
168 m_log << TestLog::EndSection;
169
170 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader does not refer to a shader object.");
171 glGetShaderiv(program, GL_SHADER_TYPE, ¶m[0]);
172 expectError(GL_INVALID_OPERATION);
173 m_log << TestLog::EndSection;
174
175 glDeleteShader(shader);
176 glDeleteProgram(program);
177 });
178 ES2F_ADD_API_CASE(get_shader_info_log, "Invalid glGetShaderInfoLog() usage", {
179 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
180 GLuint program = glCreateProgram();
181 GLsizei length[1] = {-1};
182 char infoLog[128];
183
184 deMemset(&infoLog[0], 0, sizeof(infoLog));
185
186 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
187 glGetShaderInfoLog(-1, 128, &length[0], &infoLog[0]);
188 expectError(GL_INVALID_VALUE);
189 m_log << TestLog::EndSection;
190
191 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
192 glGetShaderInfoLog(program, 128, &length[0], &infoLog[0]);
193 expectError(GL_INVALID_OPERATION);
194 m_log << TestLog::EndSection;
195
196 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxLength is less than 0.");
197 glGetShaderInfoLog(shader, -1, &length[0], &infoLog[0]);
198 expectError(GL_INVALID_VALUE);
199 m_log << TestLog::EndSection;
200
201 glDeleteShader(shader);
202 glDeleteProgram(program);
203 });
204 ES2F_ADD_API_CASE(get_shader_precision_format, "Invalid glGetShaderPrecisionFormat() usage", {
205 GLboolean shaderCompilerSupported;
206 glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
207 if (!shaderCompilerSupported)
208 m_log << TestLog::Message << "// Shader compiler not supported, always expect GL_INVALID_OPERATION"
209 << TestLog::EndMessage;
210 else
211 m_log << TestLog::Message << "// Shader compiler supported" << TestLog::EndMessage;
212
213 GLint range[2];
214 range[0] = -1;
215 range[1] = -1;
216 GLint precision[1] = {-1};
217
218 m_log << TestLog::Section(
219 "", "GL_INVALID_ENUM is generated if shaderType or precisionType is not an accepted value.");
220 glGetShaderPrecisionFormat(-1, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
221 expectError(shaderCompilerSupported ? GL_INVALID_ENUM : GL_INVALID_OPERATION);
222 glGetShaderPrecisionFormat(GL_VERTEX_SHADER, -1, &range[0], &precision[0]);
223 expectError(shaderCompilerSupported ? GL_INVALID_ENUM : GL_INVALID_OPERATION);
224 glGetShaderPrecisionFormat(-1, -1, &range[0], &precision[0]);
225 expectError(shaderCompilerSupported ? GL_INVALID_ENUM : GL_INVALID_OPERATION);
226 m_log << TestLog::EndSection;
227
228 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if a shader compiler is not supported.");
229 glGetShaderPrecisionFormat(GL_VERTEX_SHADER, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
230 expectError(shaderCompilerSupported ? GL_NO_ERROR : GL_INVALID_OPERATION);
231 m_log << TestLog::EndSection;
232 });
233 ES2F_ADD_API_CASE(get_shader_source, "Invalid glGetShaderSource() usage", {
234 GLsizei length[1] = {-1};
235 char source[1] = {0};
236 GLuint program = glCreateProgram();
237 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
238
239 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
240 glGetShaderSource(-1, 1, &length[0], &source[0]);
241 expectError(GL_INVALID_VALUE);
242 m_log << TestLog::EndSection;
243
244 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
245 glGetShaderSource(program, 1, &length[0], &source[0]);
246 expectError(GL_INVALID_OPERATION);
247 m_log << TestLog::EndSection;
248
249 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0.");
250 glGetShaderSource(shader, -1, &length[0], &source[0]);
251 expectError(GL_INVALID_VALUE);
252 m_log << TestLog::EndSection;
253
254 glDeleteProgram(program);
255 glDeleteShader(shader);
256 });
257
258 // Enumerated state queries: Programs
259
260 ES2F_ADD_API_CASE(get_programiv, "Invalid glGetProgramiv() usage", {
261 GLuint program = glCreateProgram();
262 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
263 GLint params[1] = {-1};
264
265 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
266 glGetProgramiv(program, -1, ¶ms[0]);
267 expectError(GL_INVALID_ENUM);
268 m_log << TestLog::EndSection;
269
270 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
271 glGetProgramiv(-1, GL_LINK_STATUS, ¶ms[0]);
272 expectError(GL_INVALID_VALUE);
273 m_log << TestLog::EndSection;
274
275 m_log << TestLog::Section("",
276 "GL_INVALID_OPERATION is generated if program does not refer to a program object.");
277 glGetProgramiv(shader, GL_LINK_STATUS, ¶ms[0]);
278 expectError(GL_INVALID_OPERATION);
279 m_log << TestLog::EndSection;
280
281 glDeleteProgram(program);
282 glDeleteShader(shader);
283 });
284 ES2F_ADD_API_CASE(get_program_info_log, "Invalid glGetProgramInfoLog() usage", {
285 GLuint program = glCreateProgram();
286 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
287 GLsizei length[1] = {-1};
288 char infoLog[1] = {0};
289
290 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
291 glGetProgramInfoLog(-1, 1, &length[0], &infoLog[0]);
292 expectError(GL_INVALID_VALUE);
293 m_log << TestLog::EndSection;
294
295 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
296 glGetProgramInfoLog(shader, 1, &length[0], &infoLog[0]);
297 expectError(GL_INVALID_OPERATION);
298 m_log << TestLog::EndSection;
299
300 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxLength is less than 0.");
301 glGetProgramInfoLog(program, -1, &length[0], &infoLog[0]);
302 expectError(GL_INVALID_VALUE);
303 m_log << TestLog::EndSection;
304
305 glDeleteProgram(program);
306 glDeleteShader(shader);
307 });
308
309 // Enumerated state queries: Shader variables
310
311 ES2F_ADD_API_CASE(get_tex_parameterfv, "Invalid glGetTexParameterfv() usage", {
312 GLfloat params[1] = {0.0f};
313
314 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
315 glGetTexParameterfv(-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
316 expectError(GL_INVALID_ENUM);
317 glGetTexParameterfv(GL_TEXTURE_2D, -1, ¶ms[0]);
318 expectError(GL_INVALID_ENUM);
319 glGetTexParameterfv(-1, -1, ¶ms[0]);
320 expectError(GL_INVALID_ENUM);
321 m_log << TestLog::EndSection;
322 });
323 ES2F_ADD_API_CASE(get_tex_parameteriv, "Invalid glGetTexParameteriv() usage", {
324 GLint params[1] = {-1};
325
326 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
327 glGetTexParameteriv(-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
328 expectError(GL_INVALID_ENUM);
329 glGetTexParameteriv(GL_TEXTURE_2D, -1, ¶ms[0]);
330 expectError(GL_INVALID_ENUM);
331 glGetTexParameteriv(-1, -1, ¶ms[0]);
332 expectError(GL_INVALID_ENUM);
333 m_log << TestLog::EndSection;
334 });
335 ES2F_ADD_API_CASE(get_uniformfv, "Invalid glGetUniformfv() usage", {
336 glu::ShaderProgram program(m_context.getRenderContext(),
337 glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
338 glUseProgram(program.getProgram());
339
340 GLint vUnif = glGetUniformLocation(program.getProgram(), "vTest"); // vec4
341 GLint fUnif = glGetUniformLocation(program.getProgram(), "fTest"); // ivec4
342 if (vUnif == -1 || fUnif == -1)
343 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
344
345 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
346 GLuint programEmpty = glCreateProgram();
347 GLfloat params[4];
348
349 deMemset(¶ms[0], 0, sizeof(params));
350
351 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
352 glGetUniformfv(-1, vUnif, ¶ms[0]);
353 expectError(GL_INVALID_VALUE);
354 m_log << TestLog::EndSection;
355
356 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
357 glGetUniformfv(shader, vUnif, ¶ms[0]);
358 expectError(GL_INVALID_OPERATION);
359 m_log << TestLog::EndSection;
360
361 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
362 glGetUniformfv(programEmpty, vUnif, ¶ms[0]);
363 expectError(GL_INVALID_OPERATION);
364 m_log << TestLog::EndSection;
365
366 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if location does not correspond to a valid "
367 "uniform variable location for the specified program object.");
368 glGetUniformfv(program.getProgram(), de::max(vUnif, fUnif) + 1, ¶ms[0]);
369 expectError(GL_INVALID_OPERATION);
370 m_log << TestLog::EndSection;
371
372 glDeleteShader(shader);
373 glDeleteProgram(programEmpty);
374 });
375 ES2F_ADD_API_CASE(get_uniformiv, "Invalid glGetUniformiv() usage", {
376 glu::ShaderProgram program(m_context.getRenderContext(),
377 glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
378 glUseProgram(program.getProgram());
379
380 GLint vUnif = glGetUniformLocation(program.getProgram(), "vTest"); // vec4
381 GLint fUnif = glGetUniformLocation(program.getProgram(), "fTest"); // ivec4
382 if (vUnif == -1 || fUnif == -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 GLint params[4];
388
389 deMemset(¶ms[0], 0, sizeof(params));
390
391 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
392 glGetUniformiv(-1, vUnif, ¶ms[0]);
393 expectError(GL_INVALID_VALUE);
394 m_log << TestLog::EndSection;
395
396 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
397 glGetUniformiv(shader, vUnif, ¶ms[0]);
398 expectError(GL_INVALID_OPERATION);
399 m_log << TestLog::EndSection;
400
401 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
402 glGetUniformiv(programEmpty, vUnif, ¶ms[0]);
403 expectError(GL_INVALID_OPERATION);
404 m_log << TestLog::EndSection;
405
406 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if location does not correspond to a valid "
407 "uniform variable location for the specified program object.");
408 glGetUniformiv(program.getProgram(), de::max(vUnif, fUnif) + 1, ¶ms[0]);
409 expectError(GL_INVALID_OPERATION);
410 m_log << TestLog::EndSection;
411
412 glDeleteShader(shader);
413 glDeleteProgram(programEmpty);
414 });
415 ES2F_ADD_API_CASE(get_vertex_attribfv, "Invalid glGetVertexAttribfv() usage", {
416 GLfloat params[1];
417
418 deMemset(¶ms[0], 0, sizeof(params));
419
420 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
421 glGetVertexAttribfv(0, -1, ¶ms[0]);
422 expectError(GL_INVALID_ENUM);
423 m_log << TestLog::EndSection;
424
425 m_log << TestLog::Section(
426 "", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
427 GLint maxVertexAttribs;
428 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
429 glGetVertexAttribfv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms[0]);
430 expectError(GL_INVALID_VALUE);
431 m_log << TestLog::EndSection;
432 });
433 ES2F_ADD_API_CASE(get_vertex_attribiv, "Invalid glGetVertexAttribiv() usage", {
434 GLint params[1];
435
436 deMemset(¶ms[0], 0, sizeof(params));
437
438 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
439 glGetVertexAttribiv(0, -1, ¶ms[0]);
440 expectError(GL_INVALID_ENUM);
441 m_log << TestLog::EndSection;
442
443 m_log << TestLog::Section(
444 "", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
445 GLint maxVertexAttribs;
446 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
447 glGetVertexAttribiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms[0]);
448 expectError(GL_INVALID_VALUE);
449 m_log << TestLog::EndSection;
450 });
451 ES2F_ADD_API_CASE(get_vertex_attrib_pointerv, "Invalid glGetVertexAttribPointerv() usage", {
452 GLvoid *ptr[1] = {DE_NULL};
453
454 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
455 glGetVertexAttribPointerv(0, -1, &ptr[0]);
456 expectError(GL_INVALID_ENUM);
457 m_log << TestLog::EndSection;
458
459 m_log << TestLog::Section(
460 "", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
461 GLint maxVertexAttribs;
462 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
463 glGetVertexAttribPointerv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr[0]);
464 expectError(GL_INVALID_VALUE);
465 m_log << TestLog::EndSection;
466 });
467
468 // Enumerated state queries: Buffers
469
470 ES2F_ADD_API_CASE(get_buffer_parameteriv, "Invalid glGetBufferParameteriv() usage", {
471 GLint params[1];
472 GLuint buf;
473 glGenBuffers(1, &buf);
474 glBindBuffer(GL_ARRAY_BUFFER, buf);
475
476 deMemset(¶ms[0], 0, sizeof(params));
477
478 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or value is not an accepted value.");
479 glGetBufferParameteriv(-1, GL_BUFFER_SIZE, ¶ms[0]);
480 expectError(GL_INVALID_ENUM);
481 glGetBufferParameteriv(GL_ARRAY_BUFFER, -1, ¶ms[0]);
482 expectError(GL_INVALID_ENUM);
483 glGetBufferParameteriv(-1, -1, ¶ms[0]);
484 expectError(GL_INVALID_ENUM);
485 m_log << TestLog::EndSection;
486
487 m_log << TestLog::Section(
488 "", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
489 glBindBuffer(GL_ARRAY_BUFFER, 0);
490 glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, ¶ms[0]);
491 expectError(GL_INVALID_OPERATION);
492 m_log << TestLog::EndSection;
493
494 glDeleteBuffers(1, &buf);
495 });
496 ES2F_ADD_API_CASE(get_framebuffer_attachment_parameteriv, "Invalid glGetFramebufferAttachmentParameteriv() usage", {
497 // GL_MAJOR_VERSION query does not exist on GLES2
498 // so succeeding query implies GLES3+ hardware.
499 bool isES3Compatible = false;
500 glw::GLint majorVersion = 0;
501 glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
502 if (glGetError() == GL_NO_ERROR)
503 isES3Compatible = true;
504
505 GLint params[1] = {-1};
506 GLuint fbo;
507 glGenFramebuffers(1, &fbo);
508 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
509
510 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
511 glGetFramebufferAttachmentParameteriv(-1, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
512 ¶ms[0]);
513 expectError(GL_INVALID_ENUM);
514 m_log << TestLog::EndSection;
515
516 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if there is no attached object at the named "
517 "attachment point and pname is not GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
518 if (isES3Compatible)
519 {
520 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
521 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // TYPE is GL_NONE
522 expectError(GL_NO_ERROR);
523 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
524 GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE,
525 ¶ms[0]); // TYPE is GL_NONE
526 expectError(GL_INVALID_OPERATION);
527 }
528 else
529 {
530 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
531 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]);
532 expectError(GL_INVALID_ENUM);
533 }
534 m_log << TestLog::EndSection;
535
536 if (!isES3Compatible)
537 {
538 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if the attached object at the named attachment "
539 "point is incompatible with pname.");
540 GLint attachmentObjectType = -1;
541 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
542 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &attachmentObjectType);
543 expectError(GL_NO_ERROR);
544
545 if (attachmentObjectType == GL_RENDERBUFFER)
546 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
547 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, ¶ms[0]);
548 else if (attachmentObjectType == GL_TEXTURE)
549 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, ¶ms[0]);
550 else if (attachmentObjectType == GL_NONE)
551 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
552 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]);
553 else
554 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL,
555 "Invalid return value from glGetFramebufferAttachmentParameteriv()");
556
557 expectError(GL_INVALID_ENUM);
558 m_log << TestLog::EndSection;
559 }
560
561 m_log << TestLog::Section(
562 "", "GL_INVALID_OPERATION is generated if the default framebuffer object name 0 is bound.");
563 glBindFramebuffer(GL_FRAMEBUFFER, 0);
564 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
565 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, ¶ms[0]);
566 if (isES3Compatible)
567 expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
568 else
569 expectError(GL_INVALID_OPERATION);
570 m_log << TestLog::EndSection;
571
572 glDeleteFramebuffers(1, &fbo);
573 });
574 ES2F_ADD_API_CASE(get_renderbuffer_parameteriv, "Invalid glGetRenderbufferParameteriv() usage", {
575 GLint params[1];
576 GLuint rbo;
577 glGenRenderbuffers(1, &rbo);
578 glBindRenderbuffer(GL_RENDERBUFFER, rbo);
579
580 deMemset(¶ms[0], 0, sizeof(params));
581
582 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
583 glGetRenderbufferParameteriv(-1, GL_RENDERBUFFER_WIDTH, ¶ms[0]);
584 expectError(GL_INVALID_ENUM);
585 m_log << TestLog::EndSection;
586
587 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
588 glGetRenderbufferParameteriv(GL_RENDERBUFFER, -1, ¶ms[0]);
589 expectError(GL_INVALID_ENUM);
590 m_log << TestLog::EndSection;
591
592 m_log << TestLog::Section(
593 "", "GL_INVALID_OPERATION is generated if the reserved renderbuffer object name 0 is bound.");
594 glBindRenderbuffer(GL_RENDERBUFFER, 0);
595 glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, ¶ms[0]);
596 expectError(GL_INVALID_OPERATION);
597 m_log << TestLog::EndSection;
598
599 glDeleteRenderbuffers(1, &rbo);
600 });
601
602 // Enumerated boolean state queries
603
604 ES2F_ADD_API_CASE(get_is_enabled, "Invalid glIsEnabled() usage", {
605 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not an accepted value.");
606 glIsEnabled(-1);
607 expectError(GL_INVALID_ENUM);
608 glIsEnabled(GL_TRIANGLES);
609 expectError(GL_INVALID_ENUM);
610 m_log << TestLog::EndSection;
611 });
612
613 // Hints
614
615 ES2F_ADD_API_CASE(hint, "Invalid glHint() usage", {
616 m_log << TestLog::Section("",
617 "GL_INVALID_ENUM is generated if either target or mode is not an accepted value.");
618 glHint(GL_GENERATE_MIPMAP_HINT, -1);
619 expectError(GL_INVALID_ENUM);
620 glHint(-1, GL_FASTEST);
621 expectError(GL_INVALID_ENUM);
622 glHint(-1, -1);
623 expectError(GL_INVALID_ENUM);
624 m_log << TestLog::EndSection;
625 });
626
627 // Named object usage
628
629 ES2F_ADD_API_CASE(is_buffer, "Invalid glIsBuffer() usage", {
630 GLuint buffer = 0;
631 GLboolean isBuffer;
632
633 m_log << TestLog::Section("", "A name returned by glGenBuffers, but not yet associated with a buffer object by "
634 "calling glBindBuffer, is not the name of a buffer object.");
635 isBuffer = glIsBuffer(buffer);
636 checkBooleans(isBuffer, GL_FALSE);
637
638 glGenBuffers(1, &buffer);
639 isBuffer = glIsBuffer(buffer);
640 checkBooleans(isBuffer, GL_FALSE);
641
642 glBindBuffer(GL_ARRAY_BUFFER, buffer);
643 isBuffer = glIsBuffer(buffer);
644 checkBooleans(isBuffer, GL_TRUE);
645
646 glBindBuffer(GL_ARRAY_BUFFER, 0);
647 glDeleteBuffers(1, &buffer);
648 isBuffer = glIsBuffer(buffer);
649 checkBooleans(isBuffer, GL_FALSE);
650 m_log << TestLog::EndSection;
651
652 expectError(GL_NO_ERROR);
653 });
654 ES2F_ADD_API_CASE(is_framebuffer, "Invalid glIsFramebuffer() usage", {
655 GLuint fbo = 0;
656 GLboolean isFbo;
657
658 m_log << TestLog::Section("", "A name returned by glGenFramebuffers, but not yet bound through a call to "
659 "glBindFramebuffer is not the name of a framebuffer object.");
660 isFbo = glIsFramebuffer(fbo);
661 checkBooleans(isFbo, GL_FALSE);
662
663 glGenFramebuffers(1, &fbo);
664 isFbo = glIsFramebuffer(fbo);
665 checkBooleans(isFbo, GL_FALSE);
666
667 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
668 isFbo = glIsFramebuffer(fbo);
669 checkBooleans(isFbo, GL_TRUE);
670
671 glBindFramebuffer(GL_FRAMEBUFFER, 0);
672 glDeleteFramebuffers(1, &fbo);
673 isFbo = glIsFramebuffer(fbo);
674 checkBooleans(isFbo, GL_FALSE);
675 m_log << TestLog::EndSection;
676
677 expectError(GL_NO_ERROR);
678 });
679 ES2F_ADD_API_CASE(is_program, "Invalid glIsProgram() usage", {
680 GLuint program = 0;
681 GLboolean isProgram;
682
683 m_log << TestLog::Section("", "A name created with glCreateProgram, and not yet deleted with glDeleteProgram "
684 "is a name of a program object.");
685 isProgram = glIsProgram(program);
686 checkBooleans(isProgram, GL_FALSE);
687
688 program = glCreateProgram();
689 isProgram = glIsProgram(program);
690 checkBooleans(isProgram, GL_TRUE);
691
692 glDeleteProgram(program);
693 isProgram = glIsProgram(program);
694 checkBooleans(isProgram, GL_FALSE);
695 m_log << TestLog::EndSection;
696
697 expectError(GL_NO_ERROR);
698 });
699 ES2F_ADD_API_CASE(is_renderbuffer, "Invalid glIsRenderbuffer() usage", {
700 GLuint rbo = 0;
701 GLboolean isRbo;
702
703 m_log << TestLog::Section(
704 "", "A name returned by glGenRenderbuffers, but not yet bound through a call to glBindRenderbuffer or "
705 "glFramebufferRenderbuffer is not the name of a renderbuffer object.");
706 isRbo = glIsRenderbuffer(rbo);
707 checkBooleans(isRbo, GL_FALSE);
708
709 glGenRenderbuffers(1, &rbo);
710 isRbo = glIsRenderbuffer(rbo);
711 checkBooleans(isRbo, GL_FALSE);
712
713 glBindRenderbuffer(GL_RENDERBUFFER, rbo);
714 isRbo = glIsRenderbuffer(rbo);
715 checkBooleans(isRbo, GL_TRUE);
716
717 glBindRenderbuffer(GL_RENDERBUFFER, 0);
718 glDeleteRenderbuffers(1, &rbo);
719 isRbo = glIsRenderbuffer(rbo);
720 checkBooleans(isRbo, GL_FALSE);
721 m_log << TestLog::EndSection;
722
723 expectError(GL_NO_ERROR);
724 });
725 ES2F_ADD_API_CASE(is_shader, "Invalid glIsShader() usage", {
726 GLuint shader = 0;
727 GLboolean isShader;
728
729 m_log << TestLog::Section("", "A name created with glCreateShader, and not yet deleted with glDeleteShader is "
730 "a name of a shader object.");
731 isShader = glIsProgram(shader);
732 checkBooleans(isShader, GL_FALSE);
733
734 shader = glCreateShader(GL_VERTEX_SHADER);
735 isShader = glIsShader(shader);
736 checkBooleans(isShader, GL_TRUE);
737
738 glDeleteShader(shader);
739 isShader = glIsShader(shader);
740 checkBooleans(isShader, GL_FALSE);
741 m_log << TestLog::EndSection;
742
743 expectError(GL_NO_ERROR);
744 });
745 ES2F_ADD_API_CASE(is_texture, "Invalid glIsTexture() usage", {
746 GLuint texture = 0;
747 GLboolean isTexture;
748
749 m_log << TestLog::Section("", "A name returned by glGenTextures, but not yet bound through a call to "
750 "glBindTexture is not the name of a texture.");
751 isTexture = glIsTexture(texture);
752 checkBooleans(isTexture, GL_FALSE);
753
754 glGenTextures(1, &texture);
755 isTexture = glIsTexture(texture);
756 checkBooleans(isTexture, GL_FALSE);
757
758 glBindTexture(GL_TEXTURE_2D, texture);
759 isTexture = glIsTexture(texture);
760 checkBooleans(isTexture, GL_TRUE);
761
762 glBindTexture(GL_TEXTURE_2D, 0);
763 glDeleteTextures(1, &texture);
764 isTexture = glIsTexture(texture);
765 checkBooleans(isTexture, GL_FALSE);
766 m_log << TestLog::EndSection;
767
768 expectError(GL_NO_ERROR);
769 });
770 }
771
772 } // namespace Functional
773 } // namespace gles2
774 } // namespace deqp
775