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