1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Negative GL State API tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es3fNegativeStateApiTests.hpp"
25 #include "es3fApiCase.hpp"
26 #include "gluShaderProgram.hpp"
27 #include "gluContextInfo.hpp"
30 #include "glwDefs.hpp"
31 #include "glwEnums.hpp"
33 using namespace glw; // GL types
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"
50 " gl_Position = vUnif_vec4 + blockVar + attr;\n"
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;"
58 " fragColor = vec4(vec4(fUnif_ivec4) + vec4(fUnif_uvec4));\n"
61 NegativeStateApiTests::NegativeStateApiTests (Context& context)
62 : TestCaseGroup(context, "state", "Negative GL State API Cases")
66 NegativeStateApiTests::~NegativeStateApiTests (void)
70 void NegativeStateApiTests::init (void)
72 // Enabling & disabling states
74 ES3F_ADD_API_CASE(enable, "Invalid glEnable() usage",
76 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
78 expectError(GL_INVALID_ENUM);
79 m_log << TestLog::EndSection;
81 ES3F_ADD_API_CASE(disable, "Invalid glDisable() usage",
83 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
85 expectError(GL_INVALID_ENUM);
86 m_log << TestLog::EndSection;
89 // Simple state queries
91 ES3F_ADD_API_CASE(get_booleanv, "Invalid glGetBooleanv() usage",
93 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
94 GLboolean params = GL_FALSE;
95 glGetBooleanv(-1, ¶ms);
96 expectError(GL_INVALID_ENUM);
97 m_log << TestLog::EndSection;
99 ES3F_ADD_API_CASE(get_floatv, "Invalid glGetFloatv() usage",
101 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
102 GLfloat params = 0.0f;
103 glGetFloatv(-1, ¶ms);
104 expectError(GL_INVALID_ENUM);
105 m_log << TestLog::EndSection;
107 ES3F_ADD_API_CASE(get_integerv, "Invalid glGetIntegerv() usage",
109 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
111 glGetIntegerv(-1, ¶ms);
112 expectError(GL_INVALID_ENUM);
113 m_log << TestLog::EndSection;
115 ES3F_ADD_API_CASE(get_integer64v, "Invalid glGetInteger64v() usage",
117 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
119 glGetInteger64v(-1, ¶ms);
120 expectError(GL_INVALID_ENUM);
121 m_log << TestLog::EndSection;
123 ES3F_ADD_API_CASE(get_integeri_v, "Invalid glGetIntegeri_v() usage",
126 GLint maxUniformBufferBindings;
128 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
129 glGetIntegeri_v(-1, 0, &data);
130 expectError(GL_INVALID_ENUM);
131 m_log << TestLog::EndSection;
133 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
134 glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
135 expectError(GL_NO_ERROR);
136 glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, maxUniformBufferBindings, &data);
137 expectError(GL_INVALID_VALUE);
138 m_log << TestLog::EndSection;
140 ES3F_ADD_API_CASE(get_integer64i_v, "Invalid glGetInteger64i_v() usage",
142 GLint64 data = (GLint64)-1;;
143 GLint maxUniformBufferBindings;
145 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
146 glGetInteger64i_v(-1, 0, &data);
147 expectError(GL_INVALID_ENUM);
148 m_log << TestLog::EndSection;
150 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
151 glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
152 expectError(GL_NO_ERROR);
153 glGetInteger64i_v(GL_UNIFORM_BUFFER_START, maxUniformBufferBindings, &data);
154 expectError(GL_INVALID_VALUE);
155 m_log << TestLog::EndSection;
157 ES3F_ADD_API_CASE(get_string, "Invalid glGetString() usage",
159 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
161 expectError(GL_INVALID_ENUM);
162 m_log << TestLog::EndSection;
164 ES3F_ADD_API_CASE(get_stringi, "Invalid glGetStringi() usage",
168 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if name is not an accepted value.");
170 expectError(GL_INVALID_ENUM);
171 m_log << TestLog::EndSection;
173 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is outside the valid range for indexed state name.");
174 glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
175 glGetStringi(GL_EXTENSIONS, numExtensions);
176 expectError(GL_INVALID_VALUE);
177 m_log << TestLog::EndSection;
180 // Enumerated state queries: Shaders
182 ES3F_ADD_API_CASE(get_attached_shaders, "Invalid glGetAttachedShaders() usage",
185 GLuint shaderObject = glCreateShader(GL_VERTEX_SHADER);
186 GLuint program = glCreateProgram();
189 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
190 glGetAttachedShaders(-1, 1, &count[0], &shaders[0]);
191 expectError(GL_INVALID_VALUE);
192 m_log << TestLog::EndSection;
194 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
195 glGetAttachedShaders(shaderObject, 1, &count[0], &shaders[0]);
196 expectError(GL_INVALID_OPERATION);
197 m_log << TestLog::EndSection;
199 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxCount is less than 0.");
200 glGetAttachedShaders(program, -1, &count[0], &shaders[0]);
201 expectError(GL_INVALID_VALUE);
202 m_log << TestLog::EndSection;
204 glDeleteShader(shaderObject);
205 glDeleteProgram(program);
207 ES3F_ADD_API_CASE(get_shaderiv, "Invalid glGetShaderiv() usage",
209 GLboolean shaderCompilerSupported;
210 glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
211 m_log << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
213 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
214 GLuint program = glCreateProgram();
215 GLint param[1] = { -1 };
217 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
218 glGetShaderiv(shader, -1, ¶m[0]);
219 expectError(GL_INVALID_ENUM);
220 m_log << TestLog::EndSection;
222 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
223 glGetShaderiv(-1, GL_SHADER_TYPE, ¶m[0]);
224 expectError(GL_INVALID_VALUE);
225 m_log << TestLog::EndSection;
227 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader does not refer to a shader object.");
228 glGetShaderiv(program, GL_SHADER_TYPE, ¶m[0]);
229 expectError(GL_INVALID_OPERATION);
230 m_log << TestLog::EndSection;
232 glDeleteShader(shader);
233 glDeleteProgram(program);
235 ES3F_ADD_API_CASE(get_shader_info_log, "Invalid glGetShaderInfoLog() usage",
237 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
238 GLuint program = glCreateProgram();
239 GLsizei length[1] = { 0 };
240 char infoLog[128] = { 0 };
242 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
243 glGetShaderInfoLog(-1, 128, &length[0], &infoLog[0]);
244 expectError(GL_INVALID_VALUE);
245 m_log << TestLog::EndSection;
247 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
248 glGetShaderInfoLog(program, 128, &length[0], &infoLog[0]);
249 expectError(GL_INVALID_OPERATION);
250 m_log << TestLog::EndSection;
252 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxLength is less than 0.");
253 glGetShaderInfoLog(shader, -1, &length[0], &infoLog[0]);
254 expectError(GL_INVALID_VALUE);
255 m_log << TestLog::EndSection;
257 glDeleteShader(shader);
258 glDeleteProgram(program);
260 ES3F_ADD_API_CASE(get_shader_precision_format, "Invalid glGetShaderPrecisionFormat() usage",
262 GLboolean shaderCompilerSupported;
263 glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
264 m_log << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
269 deMemset(&range[0], 0xcd, sizeof(range));
270 deMemset(&precision[0], 0xcd, sizeof(precision));
272 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if shaderType or precisionType is not an accepted value.");
273 glGetShaderPrecisionFormat (-1, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
274 expectError(GL_INVALID_ENUM);
275 glGetShaderPrecisionFormat (GL_VERTEX_SHADER, -1, &range[0], &precision[0]);
276 expectError(GL_INVALID_ENUM);
277 glGetShaderPrecisionFormat (-1, -1, &range[0], &precision[0]);
278 expectError(GL_INVALID_ENUM);
279 m_log << TestLog::EndSection;
281 ES3F_ADD_API_CASE(get_shader_source, "Invalid glGetShaderSource() usage",
283 GLsizei length[1] = { 0 };
284 char source[1] = { 0 };
285 GLuint program = glCreateProgram();
286 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
288 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
289 glGetShaderSource(-1, 1, &length[0], &source[0]);
290 expectError(GL_INVALID_VALUE);
291 m_log << TestLog::EndSection;
293 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if shader is not a shader object.");
294 glGetShaderSource(program, 1, &length[0], &source[0]);
295 expectError(GL_INVALID_OPERATION);
296 m_log << TestLog::EndSection;
298 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0.");
299 glGetShaderSource(shader, -1, &length[0], &source[0]);
300 expectError(GL_INVALID_VALUE);
301 m_log << TestLog::EndSection;
303 glDeleteProgram(program);
304 glDeleteShader(shader);
307 // Enumerated state queries: Programs
309 ES3F_ADD_API_CASE(get_programiv, "Invalid glGetProgramiv() usage",
311 GLuint program = glCreateProgram();
312 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
313 GLint params[1] = { -1 };
315 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
316 glGetProgramiv(program, -1, ¶ms[0]);
317 expectError(GL_INVALID_ENUM);
318 m_log << TestLog::EndSection;
320 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
321 glGetProgramiv(-1, GL_LINK_STATUS, ¶ms[0]);
322 expectError(GL_INVALID_VALUE);
323 m_log << TestLog::EndSection;
325 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program does not refer to a program object.");
326 glGetProgramiv(shader, GL_LINK_STATUS, ¶ms[0]);
327 expectError(GL_INVALID_OPERATION);
328 m_log << TestLog::EndSection;
330 glDeleteProgram(program);
331 glDeleteShader(shader);
333 ES3F_ADD_API_CASE(get_program_info_log, "Invalid glGetProgramInfoLog() usage",
335 GLuint program = glCreateProgram();
336 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
337 GLsizei length[1] = { 0 };
338 char infoLog[1] = { 0 };
340 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
341 glGetProgramInfoLog (-1, 1, &length[0], &infoLog[0]);
342 expectError(GL_INVALID_VALUE);
343 m_log << TestLog::EndSection;
345 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
346 glGetProgramInfoLog (shader, 1, &length[0], &infoLog[0]);
347 expectError(GL_INVALID_OPERATION);
348 m_log << TestLog::EndSection;
350 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if maxLength is less than 0.");
351 glGetProgramInfoLog (program, -1, &length[0], &infoLog[0]);
352 expectError(GL_INVALID_VALUE);
353 m_log << TestLog::EndSection;
355 glDeleteProgram(program);
356 glDeleteShader(shader);
359 // Enumerated state queries: Shader variables
361 ES3F_ADD_API_CASE(get_tex_parameterfv, "Invalid glGetTexParameterfv() usage",
363 GLfloat params[1] = { 0.0f };
365 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
366 glGetTexParameterfv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
367 expectError(GL_INVALID_ENUM);
368 glGetTexParameterfv (GL_TEXTURE_2D, -1, ¶ms[0]);
369 expectError(GL_INVALID_ENUM);
370 glGetTexParameterfv (-1, -1, ¶ms[0]);
371 expectError(GL_INVALID_ENUM);
372 m_log << TestLog::EndSection;
374 ES3F_ADD_API_CASE(get_tex_parameteriv, "Invalid glGetTexParameteriv() usage",
376 GLint params[1] = { 0 };
378 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
379 glGetTexParameteriv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
380 expectError(GL_INVALID_ENUM);
381 glGetTexParameteriv (GL_TEXTURE_2D, -1, ¶ms[0]);
382 expectError(GL_INVALID_ENUM);
383 glGetTexParameteriv (-1, -1, ¶ms[0]);
384 expectError(GL_INVALID_ENUM);
385 m_log << TestLog::EndSection;
387 ES3F_ADD_API_CASE(get_uniformfv, "Invalid glGetUniformfv() usage",
389 glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
390 glUseProgram(program.getProgram());
392 GLint unif = glGetUniformLocation(program.getProgram(), "vUnif_vec4"); // vec4
394 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
396 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
397 GLuint programEmpty = glCreateProgram();
398 GLfloat params[4] = { 0.0f };
400 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
401 glGetUniformfv (-1, unif, ¶ms[0]);
402 expectError(GL_INVALID_VALUE);
403 m_log << TestLog::EndSection;
405 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
406 glGetUniformfv (shader, unif, ¶ms[0]);
407 expectError(GL_INVALID_OPERATION);
408 m_log << TestLog::EndSection;
410 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
411 glGetUniformfv (programEmpty, unif, ¶ms[0]);
412 expectError(GL_INVALID_OPERATION);
413 m_log << TestLog::EndSection;
415 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
416 glGetUniformfv (program.getProgram(), -1, ¶ms[0]);
417 expectError(GL_INVALID_OPERATION);
418 m_log << TestLog::EndSection;
420 glDeleteShader(shader);
421 glDeleteProgram(programEmpty);
423 ES3F_ADD_API_CASE(get_uniformiv, "Invalid glGetUniformiv() usage",
425 glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
426 glUseProgram(program.getProgram());
428 GLint unif = glGetUniformLocation(program.getProgram(), "fUnif_ivec4"); // ivec4
430 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
432 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
433 GLuint programEmpty = glCreateProgram();
434 GLint params[4] = { 0 };
436 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
437 glGetUniformiv (-1, unif, ¶ms[0]);
438 expectError(GL_INVALID_VALUE);
439 m_log << TestLog::EndSection;
441 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
442 glGetUniformiv (shader, unif, ¶ms[0]);
443 expectError(GL_INVALID_OPERATION);
444 m_log << TestLog::EndSection;
446 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
447 glGetUniformiv (programEmpty, unif, ¶ms[0]);
448 expectError(GL_INVALID_OPERATION);
449 m_log << TestLog::EndSection;
451 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
452 glGetUniformiv (program.getProgram(), -1, ¶ms[0]);
453 expectError(GL_INVALID_OPERATION);
454 m_log << TestLog::EndSection;
456 glDeleteShader(shader);
457 glDeleteProgram(programEmpty);
459 ES3F_ADD_API_CASE(get_uniformuiv, "Invalid glGetUniformuiv() usage",
461 glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
462 glUseProgram(program.getProgram());
464 GLint unif = glGetUniformLocation(program.getProgram(), "fUnif_uvec4"); // uvec4
466 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Failed to retrieve uniform location");
468 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
469 GLuint programEmpty = glCreateProgram();
470 GLuint params[4] = { 0 };
472 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
473 glGetUniformuiv (-1, unif, ¶ms[0]);
474 expectError(GL_INVALID_VALUE);
475 m_log << TestLog::EndSection;
477 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
478 glGetUniformuiv (shader, unif, ¶ms[0]);
479 expectError(GL_INVALID_OPERATION);
480 m_log << TestLog::EndSection;
482 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been successfully linked.");
483 glGetUniformuiv (programEmpty, unif, ¶ms[0]);
484 expectError(GL_INVALID_OPERATION);
485 m_log << TestLog::EndSection;
487 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
488 glGetUniformuiv (program.getProgram(), -1, ¶ms[0]);
489 expectError(GL_INVALID_OPERATION);
490 m_log << TestLog::EndSection;
492 glDeleteShader(shader);
493 glDeleteProgram(programEmpty);
495 ES3F_ADD_API_CASE(get_active_uniform, "Invalid glGetActiveUniform() usage",
497 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
498 glu::ShaderProgram program (m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
499 GLint numActiveUniforms = -1;
501 glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
502 m_log << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
504 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
505 glGetActiveUniform(-1, 0, 0, 0, 0, 0, 0);
506 expectError(GL_INVALID_VALUE);
507 m_log << TestLog::EndSection;
509 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
510 glGetActiveUniform(shader, 0, 0, 0, 0, 0, 0);
511 expectError(GL_INVALID_OPERATION);
512 m_log << TestLog::EndSection;
514 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to the number of active uniform variables in program.");
515 glUseProgram(program.getProgram());
516 glGetActiveUniform(program.getProgram(), numActiveUniforms, 0, 0, 0, 0, 0);
517 expectError(GL_INVALID_VALUE);
518 m_log << TestLog::EndSection;
520 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0.");
521 glGetActiveUniform(program.getProgram(), 0, -1, 0, 0, 0, 0);
522 expectError(GL_INVALID_VALUE);
523 m_log << TestLog::EndSection;
526 glDeleteShader(shader);
528 ES3F_ADD_API_CASE(get_active_uniformsiv, "Invalid glGetActiveUniformsiv() usage",
530 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
531 glu::ShaderProgram program (m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
532 GLuint dummyUniformIndex = 1;
533 GLint dummyParamDst = -1;
534 GLint numActiveUniforms = -1;
536 glUseProgram(program.getProgram());
538 glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
539 m_log << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
541 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
542 glGetActiveUniformsiv(-1, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
543 expectError(GL_INVALID_VALUE);
544 m_log << TestLog::EndSection;
546 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
547 glGetActiveUniformsiv(shader, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
548 expectError(GL_INVALID_OPERATION);
549 m_log << TestLog::EndSection;
551 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if any value in uniformIndices is greater than or equal to the value of GL_ACTIVE_UNIFORMS for program.");
552 for (int excess = 0; excess <= 2; excess++)
554 std::vector<GLuint> invalidUniformIndices;
555 invalidUniformIndices.push_back(1);
556 invalidUniformIndices.push_back(numActiveUniforms-1+excess);
557 invalidUniformIndices.push_back(1);
559 std::vector<GLint> dummyParamsDst(invalidUniformIndices.size());
560 glGetActiveUniformsiv(program.getProgram(), (GLsizei)invalidUniformIndices.size(), &invalidUniformIndices[0], GL_UNIFORM_TYPE, &dummyParamsDst[0]);
561 expectError(excess == 0 ? GL_NO_ERROR : GL_INVALID_VALUE);
563 m_log << TestLog::EndSection;
565 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted token.");
566 glGetActiveUniformsiv(program.getProgram(), 1, &dummyUniformIndex, -1, &dummyParamDst);
567 expectError(GL_INVALID_ENUM);
568 m_log << TestLog::EndSection;
571 glDeleteShader(shader);
573 ES3F_ADD_API_CASE(get_active_uniform_blockiv, "Invalid glGetActiveUniformBlockiv() usage",
575 glu::ShaderProgram program (m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
577 GLint numActiveBlocks = -1;
579 glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
580 m_log << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
581 expectError (GL_NO_ERROR);
583 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if uniformBlockIndex is greater than or equal to the value of GL_ACTIVE_UNIFORM_BLOCKS or is not the index of an active uniform block in program.");
584 glUseProgram(program.getProgram());
585 expectError(GL_NO_ERROR);
586 glGetActiveUniformBlockiv(program.getProgram(), numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, ¶ms);
587 expectError(GL_INVALID_VALUE);
588 m_log << TestLog::EndSection;
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;
597 ES3F_ADD_API_CASE(get_active_uniform_block_name, "Invalid glGetActiveUniformBlockName() usage",
599 glu::ShaderProgram program (m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
601 GLint numActiveBlocks = -1;
602 GLchar uniformBlockName[128];
604 deMemset(&uniformBlockName[0], 0, sizeof(uniformBlockName));
606 glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
607 m_log << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
608 expectError (GL_NO_ERROR);
610 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if uniformBlockIndex is greater than or equal to the value of GL_ACTIVE_UNIFORM_BLOCKS or is not the index of an active uniform block in program.");
611 glUseProgram(program.getProgram());
612 expectError(GL_NO_ERROR);
613 glGetActiveUniformBlockName(program.getProgram(), numActiveBlocks, (int)sizeof(uniformBlockName), &length, &uniformBlockName[0]);
614 expectError(GL_INVALID_VALUE);
615 m_log << TestLog::EndSection;
619 ES3F_ADD_API_CASE(get_active_attrib, "Invalid glGetActiveAttrib() usage",
621 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
622 glu::ShaderProgram program (m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
623 GLint numActiveAttributes = -1;
630 deMemset(&name[0], 0, sizeof(name));
632 glGetProgramiv (program.getProgram(), GL_ACTIVE_ATTRIBUTES, &numActiveAttributes);
633 m_log << TestLog::Message << "// GL_ACTIVE_ATTRIBUTES = " << numActiveAttributes << " (expected 1)." << TestLog::EndMessage;
635 glUseProgram(program.getProgram());
637 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
638 glGetActiveAttrib(-1, 0, 32, &length, &size, &type, &name[0]);
639 expectError(GL_INVALID_VALUE);
640 m_log << TestLog::EndSection;
642 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is not a program object.");
643 glGetActiveAttrib(shader, 0, 32, &length, &size, &type, &name[0]);
644 expectError(GL_INVALID_OPERATION);
645 m_log << TestLog::EndSection;
647 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_ACTIVE_ATTRIBUTES.");
648 glGetActiveAttrib(program.getProgram(), numActiveAttributes, (int)sizeof(name), &length, &size, &type, &name[0]);
649 expectError(GL_INVALID_VALUE);
650 m_log << TestLog::EndSection;
652 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is less than 0.");
653 glGetActiveAttrib(program.getProgram(), 0, -1, &length, &size, &type, &name[0]);
654 expectError(GL_INVALID_VALUE);
655 m_log << TestLog::EndSection;
658 glDeleteShader(shader);
660 ES3F_ADD_API_CASE(get_uniform_indices, "Invalid glGetUniformIndices() usage",
662 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
663 glu::ShaderProgram program(m_context.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
664 GLint numActiveBlocks = -1;
665 const GLchar* uniformName = "Block.blockVar";
666 GLuint uniformIndices = -1;
668 glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
669 m_log << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << TestLog::EndMessage;
670 expectError (GL_NO_ERROR);
672 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is a name of shader object.");
673 glGetUniformIndices(shader, 1, &uniformName, &uniformIndices);
674 expectError(GL_INVALID_OPERATION);
675 m_log << TestLog::EndSection;
677 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if program is not name of program or shader object.");
679 glGetUniformIndices(invalid, 1, &uniformName, &uniformIndices);
680 expectError(GL_INVALID_VALUE);
681 m_log << TestLog::EndSection;
684 glDeleteShader(shader);
686 ES3F_ADD_API_CASE(get_vertex_attribfv, "Invalid glGetVertexAttribfv() usage",
688 GLfloat params = 0.0f;
690 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
691 glGetVertexAttribfv(0, -1, ¶ms);
692 expectError(GL_INVALID_ENUM);
693 m_log << TestLog::EndSection;
695 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
696 GLint maxVertexAttribs;
697 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
698 glGetVertexAttribfv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
699 expectError(GL_INVALID_VALUE);
700 m_log << TestLog::EndSection;
702 ES3F_ADD_API_CASE(get_vertex_attribiv, "Invalid glGetVertexAttribiv() usage",
706 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
707 glGetVertexAttribiv(0, -1, ¶ms);
708 expectError(GL_INVALID_ENUM);
709 m_log << TestLog::EndSection;
711 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
712 GLint maxVertexAttribs;
713 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
714 glGetVertexAttribiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
715 expectError(GL_INVALID_VALUE);
716 m_log << TestLog::EndSection;
718 ES3F_ADD_API_CASE(get_vertex_attribi_iv, "Invalid glGetVertexAttribIiv() usage",
722 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
723 glGetVertexAttribIiv(0, -1, ¶ms);
724 expectError(GL_INVALID_ENUM);
725 m_log << TestLog::EndSection;
727 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
728 GLint maxVertexAttribs;
729 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
730 glGetVertexAttribIiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
731 expectError(GL_INVALID_VALUE);
732 m_log << TestLog::EndSection;
734 ES3F_ADD_API_CASE(get_vertex_attribi_uiv, "Invalid glGetVertexAttribIuiv() usage",
736 GLuint params = (GLuint)-1;
738 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
739 glGetVertexAttribIuiv(0, -1, ¶ms);
740 expectError(GL_INVALID_ENUM);
741 m_log << TestLog::EndSection;
743 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
744 GLint maxVertexAttribs;
745 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
746 glGetVertexAttribIuiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
747 expectError(GL_INVALID_VALUE);
748 m_log << TestLog::EndSection;
750 ES3F_ADD_API_CASE(get_vertex_attrib_pointerv, "Invalid glGetVertexAttribPointerv() usage",
752 GLvoid* ptr[1] = { DE_NULL };
754 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
755 glGetVertexAttribPointerv(0, -1, &ptr[0]);
756 expectError(GL_INVALID_ENUM);
757 m_log << TestLog::EndSection;
759 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
760 GLint maxVertexAttribs;
761 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
762 glGetVertexAttribPointerv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr[0]);
763 expectError(GL_INVALID_VALUE);
764 m_log << TestLog::EndSection;
766 ES3F_ADD_API_CASE(get_frag_data_location, "Invalid glGetFragDataLocation() usage",
768 GLuint shader = glCreateShader(GL_VERTEX_SHADER);
769 GLuint program = glCreateProgram();
771 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program is the name of a shader object.");
772 glGetFragDataLocation(shader, "gl_FragColor");
773 expectError(GL_INVALID_OPERATION);
774 m_log << TestLog::EndSection;
776 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if program has not been linked.");
777 glGetFragDataLocation(program, "gl_FragColor");
778 expectError(GL_INVALID_OPERATION);
779 m_log << TestLog::EndSection;
781 glDeleteProgram(program);
782 glDeleteShader(shader);
785 // Enumerated state queries: Buffers
787 ES3F_ADD_API_CASE(get_buffer_parameteriv, "Invalid glGetBufferParameteriv() usage",
791 glGenBuffers(1, &buf);
792 glBindBuffer(GL_ARRAY_BUFFER, buf);
794 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or value is not an accepted value.");
795 glGetBufferParameteriv(-1, GL_BUFFER_SIZE, ¶ms);
796 expectError(GL_INVALID_ENUM);
797 glGetBufferParameteriv(GL_ARRAY_BUFFER, -1, ¶ms);
798 expectError(GL_INVALID_ENUM);
799 glGetBufferParameteriv(-1, -1, ¶ms);
800 expectError(GL_INVALID_ENUM);
801 m_log << TestLog::EndSection;
803 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
804 glBindBuffer(GL_ARRAY_BUFFER, 0);
805 glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, ¶ms);
806 expectError(GL_INVALID_OPERATION);
807 m_log << TestLog::EndSection;
809 glDeleteBuffers(1, &buf);
811 ES3F_ADD_API_CASE(get_buffer_parameteri64v, "Invalid glGetBufferParameteri64v() usage",
815 glGenBuffers(1, &buf);
816 glBindBuffer(GL_ARRAY_BUFFER, buf);
818 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or value is not an accepted value.");
819 glGetBufferParameteri64v(-1, GL_BUFFER_SIZE, ¶ms);
820 expectError(GL_INVALID_ENUM);
821 glGetBufferParameteri64v(GL_ARRAY_BUFFER , -1, ¶ms);
822 expectError(GL_INVALID_ENUM);
823 glGetBufferParameteri64v(-1, -1, ¶ms);
824 expectError(GL_INVALID_ENUM);
825 m_log << TestLog::EndSection;
827 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
828 glBindBuffer(GL_ARRAY_BUFFER, 0);
829 glGetBufferParameteri64v(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, ¶ms);
830 expectError(GL_INVALID_OPERATION);
831 m_log << TestLog::EndSection;
833 glDeleteBuffers(1, &buf);
835 ES3F_ADD_API_CASE(get_buffer_pointerv, "Invalid glGetBufferPointerv() usage",
837 GLvoid* params = DE_NULL;
839 glGenBuffers(1, &buf);
840 glBindBuffer(GL_ARRAY_BUFFER, buf);
842 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
843 glGetBufferPointerv(GL_ARRAY_BUFFER, -1, ¶ms);
844 expectError(GL_INVALID_ENUM);
845 glGetBufferPointerv(-1, GL_BUFFER_MAP_POINTER, ¶ms);
846 expectError(GL_INVALID_ENUM);
847 m_log << TestLog::EndSection;
849 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
850 glBindBuffer(GL_ARRAY_BUFFER, 0);
851 glGetBufferPointerv(GL_ARRAY_BUFFER, GL_BUFFER_MAP_POINTER, ¶ms);
852 expectError(GL_INVALID_OPERATION);
853 m_log << TestLog::EndSection;
855 glDeleteBuffers(1, &buf);
857 ES3F_ADD_API_CASE(get_framebuffer_attachment_parameteriv, "Invalid glGetFramebufferAttachmentParameteriv() usage",
859 GLint params[1] = { -1 };
863 glGenFramebuffers (1, &fbo);
864 glGenRenderbuffers (2, rbo);
866 glBindFramebuffer (GL_FRAMEBUFFER, fbo);
867 glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
868 glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 16, 16);
869 glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
870 glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
871 glRenderbufferStorage (GL_RENDERBUFFER, GL_STENCIL_INDEX8, 16, 16);
872 glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
873 glCheckFramebufferStatus (GL_FRAMEBUFFER);
874 expectError (GL_NO_ERROR);
876 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
877 glGetFramebufferAttachmentParameteriv(-1, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, ¶ms[0]); // TYPE is GL_RENDERBUFFER
878 expectError(GL_INVALID_ENUM);
879 m_log << TestLog::EndSection;
881 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
882 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, ¶ms[0]); // TYPE is GL_RENDERBUFFER
883 expectError(GL_INVALID_ENUM);
884 glBindFramebuffer(GL_FRAMEBUFFER, 0);
885 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // TYPE is GL_FRAMEBUFFER_DEFAULT
886 expectError(GL_INVALID_ENUM);
887 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
888 m_log << TestLog::EndSection;
890 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if attachment is GL_DEPTH_STENCIL_ATTACHMENT and different objects are bound to the depth and stencil attachment points of target.");
891 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]);
892 expectError(GL_INVALID_OPERATION);
893 m_log << TestLog::EndSection;
895 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE and pname is not GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME.");
896 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // TYPE is GL_NONE
897 expectError(GL_NO_ERROR);
898 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, ¶ms[0]); // TYPE is GL_NONE
899 expectError(GL_INVALID_OPERATION);
900 m_log << TestLog::EndSection;
902 m_log << TestLog::Section("", "GL_INVALID_OPERATION or GL_INVALID_ENUM is generated if attachment is not one of the accepted values for the current binding of target.");
903 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // A FBO is bound so GL_BACK is invalid
904 expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
905 glBindFramebuffer(GL_FRAMEBUFFER, 0);
906 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // Default framebuffer is bound so GL_COLOR_ATTACHMENT0 is invalid
907 expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
908 m_log << TestLog::EndSection;
910 glDeleteFramebuffers(1, &fbo);
912 ES3F_ADD_API_CASE(get_renderbuffer_parameteriv, "Invalid glGetRenderbufferParameteriv() usage",
914 GLint params[1] = { -1 };
916 glGenRenderbuffers(1, &rbo);
917 glBindRenderbuffer(GL_RENDERBUFFER, rbo);
919 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
920 glGetRenderbufferParameteriv(-1, GL_RENDERBUFFER_WIDTH, ¶ms[0]);
921 expectError(GL_INVALID_ENUM);
922 m_log << TestLog::EndSection;
924 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
925 glGetRenderbufferParameteriv(GL_RENDERBUFFER, -1, ¶ms[0]);
926 expectError(GL_INVALID_ENUM);
927 m_log << TestLog::EndSection;
929 glDeleteRenderbuffers(1, &rbo);
930 glBindRenderbuffer(GL_RENDERBUFFER, 0);
932 ES3F_ADD_API_CASE(get_internalformativ, "Invalid glGetInternalformativ() usage",
936 deMemset(¶ms[0], 0xcd, sizeof(params));
938 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if bufSize is negative.");
939 glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, -1, ¶ms[0]);
940 expectError (GL_INVALID_VALUE);
941 m_log << TestLog::EndSection;
943 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not GL_SAMPLES or GL_NUM_SAMPLE_COUNTS.");
944 glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, -1, 16, ¶ms[0]);
945 expectError (GL_INVALID_ENUM);
946 m_log << TestLog::EndSection;
948 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not color-, depth-, or stencil-renderable.");
949 if (!m_context.getContextInfo().isExtensionSupported("GL_EXT_render_snorm"))
951 glGetInternalformativ (GL_RENDERBUFFER, GL_RG8_SNORM, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
952 expectError (GL_INVALID_ENUM);
955 glGetInternalformativ (GL_RENDERBUFFER, GL_COMPRESSED_RGB8_ETC2, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
956 expectError (GL_INVALID_ENUM);
957 m_log << TestLog::EndSection;
959 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
960 glGetInternalformativ (-1, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
961 expectError (GL_INVALID_ENUM);
962 glGetInternalformativ (GL_FRAMEBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
963 expectError (GL_INVALID_ENUM);
965 if (!m_context.getContextInfo().isExtensionSupported("GL_EXT_sparse_texture"))
967 glGetInternalformativ (GL_TEXTURE_2D, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
968 expectError (GL_INVALID_ENUM);
970 m_log << TestLog::EndSection;
973 // Query object queries
975 ES3F_ADD_API_CASE(get_queryiv, "Invalid glGetQueryiv() usage",
979 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
980 glGetQueryiv (GL_ANY_SAMPLES_PASSED, -1, ¶ms);
981 expectError (GL_INVALID_ENUM);
982 glGetQueryiv (-1, GL_CURRENT_QUERY, ¶ms);
983 expectError (GL_INVALID_ENUM);
984 glGetQueryiv (-1, -1, ¶ms);
985 expectError (GL_INVALID_ENUM);
986 m_log << TestLog::EndSection;
988 ES3F_ADD_API_CASE(get_query_objectuiv, "Invalid glGetQueryObjectuiv() usage",
992 glGenQueries (1, &id);
994 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id is not the name of a query object.");
995 glGetQueryObjectuiv (-1, GL_QUERY_RESULT_AVAILABLE, ¶ms);
996 expectError (GL_INVALID_OPERATION);
997 m_log << TestLog::Message << "// Note: " << id << " is not a query object yet, since it hasn't been used by glBeginQuery" << TestLog::EndMessage;
998 glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms);
999 expectError (GL_INVALID_OPERATION);
1000 m_log << TestLog::EndSection;
1002 glBeginQuery (GL_ANY_SAMPLES_PASSED, id);
1003 glEndQuery (GL_ANY_SAMPLES_PASSED);
1005 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not an accepted value.");
1006 glGetQueryObjectuiv (id, -1, ¶ms);
1007 expectError (GL_INVALID_ENUM);
1008 m_log << TestLog::EndSection;
1010 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if id is the name of a currently active query object.");
1011 glBeginQuery (GL_ANY_SAMPLES_PASSED, id);
1012 expectError (GL_NO_ERROR);
1013 glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms);
1014 expectError (GL_INVALID_OPERATION);
1015 glEndQuery (GL_ANY_SAMPLES_PASSED);
1016 expectError (GL_NO_ERROR);
1017 m_log << TestLog::EndSection;
1019 glDeleteQueries (1, &id);
1022 // Sync object queries
1024 ES3F_ADD_API_CASE(get_synciv, "Invalid glGetSynciv() usage",
1026 GLsizei length = -1;
1030 deMemset(&values[0], 0xcd, sizeof(values));
1032 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
1033 glGetSynciv (0, GL_OBJECT_TYPE, 32, &length, &values[0]);
1034 expectError (GL_INVALID_VALUE);
1035 m_log << TestLog::EndSection;
1037 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
1038 sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1039 expectError (GL_NO_ERROR);
1040 glGetSynciv (sync, -1, 32, &length, &values[0]);
1041 expectError (GL_INVALID_ENUM);
1042 m_log << TestLog::EndSection;
1045 // Enumerated boolean state queries
1047 ES3F_ADD_API_CASE(is_enabled, "Invalid glIsEnabled() usage",
1049 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if cap is not an accepted value.");
1051 expectError(GL_INVALID_ENUM);
1052 glIsEnabled(GL_TRIANGLES);
1053 expectError(GL_INVALID_ENUM);
1054 m_log << TestLog::EndSection;
1059 ES3F_ADD_API_CASE(hint, "Invalid glHint() usage",
1061 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if either target or mode is not an accepted value.");
1062 glHint(GL_GENERATE_MIPMAP_HINT, -1);
1063 expectError(GL_INVALID_ENUM);
1064 glHint(-1, GL_FASTEST);
1065 expectError(GL_INVALID_ENUM);
1067 expectError(GL_INVALID_ENUM);
1068 m_log << TestLog::EndSection;
1071 // Named Object Usage
1073 ES3F_ADD_API_CASE(is_buffer, "Invalid glIsBuffer() usage",
1078 m_log << TestLog::Section("", "A name returned by glGenBuffers, but not yet associated with a buffer object by calling glBindBuffer, is not the name of a buffer object.");
1079 isBuffer = glIsBuffer(buffer);
1080 checkBooleans (isBuffer, GL_FALSE);
1082 glGenBuffers (1, &buffer);
1083 isBuffer = glIsBuffer(buffer);
1084 checkBooleans (isBuffer, GL_FALSE);
1086 glBindBuffer (GL_ARRAY_BUFFER, buffer);
1087 isBuffer = glIsBuffer(buffer);
1088 checkBooleans (isBuffer, GL_TRUE);
1090 glBindBuffer (GL_ARRAY_BUFFER, 0);
1091 glDeleteBuffers (1, &buffer);
1092 isBuffer = glIsBuffer(buffer);
1093 checkBooleans (isBuffer, GL_FALSE);
1094 m_log << TestLog::EndSection;
1096 expectError (GL_NO_ERROR);
1098 ES3F_ADD_API_CASE(is_framebuffer, "Invalid glIsFramebuffer() usage",
1103 m_log << TestLog::Section("", "A name returned by glGenFramebuffers, but not yet bound through a call to glBindFramebuffer is not the name of a framebuffer object.");
1104 isFbo = glIsFramebuffer(fbo);
1105 checkBooleans (isFbo, GL_FALSE);
1107 glGenFramebuffers (1, &fbo);
1108 isFbo = glIsFramebuffer(fbo);
1109 checkBooleans (isFbo, GL_FALSE);
1111 glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1112 isFbo = glIsFramebuffer(fbo);
1113 checkBooleans (isFbo, GL_TRUE);
1115 glBindFramebuffer (GL_FRAMEBUFFER, 0);
1116 glDeleteFramebuffers(1, &fbo);
1117 isFbo = glIsFramebuffer(fbo);
1118 checkBooleans (isFbo, GL_FALSE);
1119 m_log << TestLog::EndSection;
1121 expectError (GL_NO_ERROR);
1123 ES3F_ADD_API_CASE(is_program, "Invalid glIsProgram() usage",
1126 GLboolean isProgram;
1128 m_log << TestLog::Section("", "A name created with glCreateProgram, and not yet deleted with glDeleteProgram is a name of a program object.");
1129 isProgram = glIsProgram(program);
1130 checkBooleans (isProgram, GL_FALSE);
1132 program = glCreateProgram();
1133 isProgram = glIsProgram(program);
1134 checkBooleans (isProgram, GL_TRUE);
1136 glDeleteProgram (program);
1137 isProgram = glIsProgram(program);
1138 checkBooleans (isProgram, GL_FALSE);
1139 m_log << TestLog::EndSection;
1141 expectError (GL_NO_ERROR);
1143 ES3F_ADD_API_CASE(is_renderbuffer, "Invalid glIsRenderbuffer() usage",
1148 m_log << TestLog::Section("", "A name returned by glGenRenderbuffers, but not yet bound through a call to glBindRenderbuffer or glFramebufferRenderbuffer is not the name of a renderbuffer object.");
1149 isRbo = glIsRenderbuffer(rbo);
1150 checkBooleans (isRbo, GL_FALSE);
1152 glGenRenderbuffers (1, &rbo);
1153 isRbo = glIsRenderbuffer(rbo);
1154 checkBooleans (isRbo, GL_FALSE);
1156 glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1157 isRbo = glIsRenderbuffer(rbo);
1158 checkBooleans (isRbo, GL_TRUE);
1160 glBindRenderbuffer (GL_RENDERBUFFER, 0);
1161 glDeleteRenderbuffers (1, &rbo);
1162 isRbo = glIsRenderbuffer(rbo);
1163 checkBooleans (isRbo, GL_FALSE);
1164 m_log << TestLog::EndSection;
1166 expectError (GL_NO_ERROR);
1168 ES3F_ADD_API_CASE(is_shader, "Invalid glIsShader() usage",
1173 m_log << TestLog::Section("", "A name created with glCreateShader, and not yet deleted with glDeleteShader is a name of a shader object.");
1174 isShader = glIsProgram(shader);
1175 checkBooleans (isShader, GL_FALSE);
1177 shader = glCreateShader(GL_VERTEX_SHADER);
1178 isShader = glIsShader(shader);
1179 checkBooleans (isShader, GL_TRUE);
1181 glDeleteShader (shader);
1182 isShader = glIsShader(shader);
1183 checkBooleans (isShader, GL_FALSE);
1184 m_log << TestLog::EndSection;
1186 expectError (GL_NO_ERROR);
1188 ES3F_ADD_API_CASE(is_texture, "Invalid glIsTexture() usage",
1191 GLboolean isTexture;
1193 m_log << TestLog::Section("", "A name returned by glGenTextures, but not yet bound through a call to glBindTexture is not the name of a texture.");
1194 isTexture = glIsTexture(texture);
1195 checkBooleans (isTexture, GL_FALSE);
1197 glGenTextures (1, &texture);
1198 isTexture = glIsTexture(texture);
1199 checkBooleans (isTexture, GL_FALSE);
1201 glBindTexture (GL_TEXTURE_2D, texture);
1202 isTexture = glIsTexture(texture);
1203 checkBooleans (isTexture, GL_TRUE);
1205 glBindTexture (GL_TEXTURE_2D, 0);
1206 glDeleteTextures (1, &texture);
1207 isTexture = glIsTexture(texture);
1208 checkBooleans (isTexture, GL_FALSE);
1209 m_log << TestLog::EndSection;
1211 expectError (GL_NO_ERROR);
1213 ES3F_ADD_API_CASE(is_query, "Invalid glIsQuery() usage",
1218 m_log << TestLog::Section("", "A name returned by glGenQueries, but not yet associated with a query object by calling glBeginQuery, is not the name of a query object.");
1219 isQuery = glIsQuery(query);
1220 checkBooleans (isQuery, GL_FALSE);
1222 glGenQueries (1, &query);
1223 isQuery = glIsQuery(query);
1224 checkBooleans (isQuery, GL_FALSE);
1226 glBeginQuery (GL_ANY_SAMPLES_PASSED, query);
1227 isQuery = glIsQuery(query);
1228 checkBooleans (isQuery, GL_TRUE);
1230 glEndQuery (GL_ANY_SAMPLES_PASSED);
1231 glDeleteQueries (1, &query);
1232 isQuery = glIsQuery(query);
1233 checkBooleans (isQuery, GL_FALSE);
1234 m_log << TestLog::EndSection;
1236 expectError (GL_NO_ERROR);
1238 ES3F_ADD_API_CASE(is_sampler, "Invalid glIsSampler() usage",
1241 GLboolean isSampler;
1243 m_log << TestLog::Section("", "A name returned by glGenSamplers is the name of a sampler object.");
1244 isSampler = glIsSampler(sampler);
1245 checkBooleans (isSampler, GL_FALSE);
1247 glGenSamplers (1, &sampler);
1248 isSampler = glIsSampler(sampler);
1249 checkBooleans (isSampler, GL_TRUE);
1251 glBindSampler (0, sampler);
1252 isSampler = glIsSampler(sampler);
1253 checkBooleans (isSampler, GL_TRUE);
1255 glDeleteSamplers (1, &sampler);
1256 isSampler = glIsSampler(sampler);
1257 checkBooleans (isSampler, GL_FALSE);
1258 m_log << TestLog::EndSection;
1260 expectError (GL_NO_ERROR);
1262 ES3F_ADD_API_CASE(is_sync, "Invalid glIsSync() usage",
1267 m_log << TestLog::Section("", "A name returned by glFenceSync is the name of a sync object.");
1268 isSync = glIsSync(sync);
1269 checkBooleans (isSync, GL_FALSE);
1271 sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1272 isSync = glIsSync(sync);
1273 checkBooleans (isSync, GL_TRUE);
1275 glDeleteSync (sync);
1276 isSync = glIsSync(sync);
1277 checkBooleans (isSync, GL_FALSE);
1278 m_log << TestLog::EndSection;
1280 expectError (GL_NO_ERROR);
1282 ES3F_ADD_API_CASE(is_transform_feedback, "Invalid glIsTransformFeedback() usage",
1287 m_log << TestLog::Section("", "A name returned by glGenTransformFeedbacks, but not yet bound using glBindTransformFeedback, is not the name of a transform feedback object.");
1288 isTF = glIsTransformFeedback(tf);
1289 checkBooleans (isTF, GL_FALSE);
1291 glGenTransformFeedbacks (1, &tf);
1292 isTF = glIsTransformFeedback(tf);
1293 checkBooleans (isTF, GL_FALSE);
1295 glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tf);
1296 isTF = glIsTransformFeedback(tf);
1297 checkBooleans (isTF, GL_TRUE);
1299 glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, 0);
1300 glDeleteTransformFeedbacks (1, &tf);
1301 isTF = glIsTransformFeedback(tf);
1302 checkBooleans (isTF, GL_FALSE);
1303 m_log << TestLog::EndSection;
1305 expectError (GL_NO_ERROR);
1307 ES3F_ADD_API_CASE(is_vertex_array, "Invalid glIsVertexArray() usage",
1312 m_log << TestLog::Section("", "A name returned by glGenVertexArrays, but not yet bound using glBindVertexArray, is not the name of a vertex array object.");
1313 isVao = glIsVertexArray(vao);
1314 checkBooleans (isVao, GL_FALSE);
1316 glGenVertexArrays (1, &vao);
1317 isVao = glIsVertexArray(vao);
1318 checkBooleans (isVao, GL_FALSE);
1320 glBindVertexArray (vao);
1321 isVao = glIsVertexArray(vao);
1322 checkBooleans (isVao, GL_TRUE);
1324 glBindVertexArray (0);
1325 glDeleteVertexArrays (1, &vao);
1326 isVao = glIsVertexArray(vao);
1327 checkBooleans (isVao, GL_FALSE);
1328 m_log << TestLog::EndSection;
1330 expectError (GL_NO_ERROR);