1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.0 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Negative GL State API tests.
22 *//*--------------------------------------------------------------------*/
23
24 #include "es31fNegativeStateApiTests.hpp"
25
26 #include "gluCallLogWrapper.hpp"
27 #include "gluContextInfo.hpp"
28 #include "gluShaderProgram.hpp"
29
30 #include "glwDefs.hpp"
31 #include "glwEnums.hpp"
32
33 #include "tcuStringTemplate.hpp"
34
35 #include "deMemory.h"
36
37 #include <string>
38 #include <map>
39
40 namespace deqp
41 {
42 namespace gles31
43 {
44 namespace Functional
45 {
46 namespace NegativeTestShared
47 {
48
49 using tcu::TestLog;
50 using glu::CallLogWrapper;
51 using namespace glw;
52
53 static const char* uniformTestVertSource = "${GLSL_VERSION_DECL}\n"
54 "uniform mediump vec4 vUnif_vec4;\n"
55 "in mediump vec4 attr;"
56 "layout(shared) uniform Block { mediump vec4 blockVar; };\n"
57 "void main (void)\n"
58 "{\n"
59 " gl_Position = vUnif_vec4 + blockVar + attr;\n"
60 "}\n\0";
61
62 static const char* uniformTestFragSource = "${GLSL_VERSION_DECL}\n"
63 "uniform mediump ivec4 fUnif_ivec4;\n"
64 "uniform mediump uvec4 fUnif_uvec4;\n"
65 "layout(location = 0) out mediump vec4 fragColor;"
66 "void main (void)\n"
67 "{\n"
68 " fragColor = vec4(vec4(fUnif_ivec4) + vec4(fUnif_uvec4));\n"
69 "}\n\0";
70
getVtxFragVersionSources(const std::string source,NegativeTestContext & ctx)71 static std::string getVtxFragVersionSources (const std::string source, NegativeTestContext& ctx)
72 {
73 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
74
75 std::map<std::string, std::string> args;
76
77 args["GLSL_VERSION_DECL"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_300_ES);
78
79 return tcu::StringTemplate(source).specialize(args);
80 }
81
82 // Enabling & disabling states
enable(NegativeTestContext & ctx)83 void enable (NegativeTestContext& ctx)
84 {
85 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
86 ctx.glEnable(-1);
87 ctx.expectError(GL_INVALID_ENUM);
88 ctx.endSection();
89 }
90
91 // Enabling & disabling states
enablei(NegativeTestContext & ctx)92 void enablei (NegativeTestContext& ctx)
93 {
94 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
95
96 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
97 ctx.glEnablei(-1, -1);
98 ctx.expectError(GL_INVALID_ENUM);
99 ctx.endSection();
100
101 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to the number of indexed capabilities for cap.");
102 ctx.glEnablei(GL_BLEND, -1);
103 ctx.expectError(GL_INVALID_VALUE);
104 ctx.endSection();
105 }
106
disable(NegativeTestContext & ctx)107 void disable (NegativeTestContext& ctx)
108 {
109 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
110 ctx.glDisable(-1);
111 ctx.expectError(GL_INVALID_ENUM);
112 ctx.endSection();
113 }
114
disablei(NegativeTestContext & ctx)115 void disablei (NegativeTestContext& ctx)
116 {
117 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
118
119 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
120 ctx.glDisablei(-1,-1);
121 ctx.expectError(GL_INVALID_ENUM);
122 ctx.endSection();
123
124 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to the number of indexed capabilities for cap.");
125 ctx.glDisablei(GL_BLEND, -1);
126 ctx.expectError(GL_INVALID_VALUE);
127 ctx.endSection();
128 }
129
130 // Simple state queries
get_booleanv(NegativeTestContext & ctx)131 void get_booleanv (NegativeTestContext& ctx)
132 {
133 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
134 GLboolean params = GL_FALSE;
135 ctx.glGetBooleanv(-1, ¶ms);
136 ctx.expectError(GL_INVALID_ENUM);
137 ctx.endSection();
138 }
139
get_booleani_v(NegativeTestContext & ctx)140 void get_booleani_v (NegativeTestContext& ctx)
141 {
142 GLboolean data = -1;
143 GLint maxUniformBufferBindings = 0;
144
145 ctx.beginSection("GL_INVALID_ENUM is generated if target is not indexed state queriable with these commands.");
146 ctx.glGetBooleani_v(-1, 0, &data);
147 ctx.expectError(GL_INVALID_ENUM);
148 ctx.endSection();
149
150 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
151 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
152 ctx.expectError(GL_NO_ERROR);
153 ctx.glGetBooleani_v(GL_UNIFORM_BUFFER_BINDING, maxUniformBufferBindings, &data);
154 ctx.expectError(GL_INVALID_VALUE);
155 ctx.endSection();
156 }
157
get_floatv(NegativeTestContext & ctx)158 void get_floatv (NegativeTestContext& ctx)
159 {
160 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
161 GLfloat params = 0.0f;
162 ctx.glGetFloatv(-1, ¶ms);
163 ctx.expectError(GL_INVALID_ENUM);
164 ctx.endSection();
165 }
166
get_integerv(NegativeTestContext & ctx)167 void get_integerv (NegativeTestContext& ctx)
168 {
169 GLint params = -1;
170 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
171 ctx.glGetIntegerv(-1, ¶ms);
172 ctx.expectError(GL_INVALID_ENUM);
173 ctx.endSection();
174 }
175
get_integer64v(NegativeTestContext & ctx)176 void get_integer64v (NegativeTestContext& ctx)
177 {
178 GLint64 params = -1;
179 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
180 ctx.glGetInteger64v(-1, ¶ms);
181 ctx.expectError(GL_INVALID_ENUM);
182 ctx.endSection();
183 }
184
get_integeri_v(NegativeTestContext & ctx)185 void get_integeri_v (NegativeTestContext& ctx)
186 {
187 GLint data = -1;
188 GLint maxUniformBufferBindings = 0;
189
190 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
191 ctx.glGetIntegeri_v(-1, 0, &data);
192 ctx.expectError(GL_INVALID_ENUM);
193 ctx.endSection();
194
195 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
196 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
197 ctx.expectError(GL_NO_ERROR);
198 ctx.glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, maxUniformBufferBindings, &data);
199 ctx.expectError(GL_INVALID_VALUE);
200 ctx.endSection();
201 }
202
get_integer64i_v(NegativeTestContext & ctx)203 void get_integer64i_v (NegativeTestContext& ctx)
204 {
205 GLint64 data = (GLint64)-1;
206 GLint maxUniformBufferBindings = 0;
207
208 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
209 ctx.glGetInteger64i_v(-1, 0, &data);
210 ctx.expectError(GL_INVALID_ENUM);
211 ctx.endSection();
212
213 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
214 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
215 ctx.expectError(GL_NO_ERROR);
216 ctx.glGetInteger64i_v(GL_UNIFORM_BUFFER_START, maxUniformBufferBindings, &data);
217 ctx.expectError(GL_INVALID_VALUE);
218 ctx.endSection();
219 }
220
get_string(NegativeTestContext & ctx)221 void get_string (NegativeTestContext& ctx)
222 {
223 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
224 ctx.glGetString(-1);
225 ctx.expectError(GL_INVALID_ENUM);
226 ctx.endSection();
227 }
228
get_stringi(NegativeTestContext & ctx)229 void get_stringi (NegativeTestContext& ctx)
230 {
231 GLint numExtensions = 0;
232
233 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
234 ctx.glGetStringi(-1, 0);
235 ctx.expectError(GL_INVALID_ENUM);
236 ctx.endSection();
237
238 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside the valid range for indexed state name.");
239 ctx.glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
240 ctx.glGetStringi(GL_EXTENSIONS, numExtensions);
241 ctx.expectError(GL_INVALID_VALUE);
242 ctx.endSection();
243 }
244
245 // Enumerated state queries: Shaders
246
get_attached_shaders(NegativeTestContext & ctx)247 void get_attached_shaders (NegativeTestContext& ctx)
248 {
249 GLuint shaders[1] = { 0 };
250 GLuint shaderObject = ctx.glCreateShader(GL_VERTEX_SHADER);
251 GLuint program = ctx.glCreateProgram();
252 GLsizei count[1] = { 0 };
253
254 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
255 ctx.glGetAttachedShaders(-1, 1, &count[0], &shaders[0]);
256 ctx.expectError(GL_INVALID_VALUE);
257 ctx.endSection();
258
259 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
260 ctx.glGetAttachedShaders(shaderObject, 1, &count[0], &shaders[0]);
261 ctx.expectError(GL_INVALID_OPERATION);
262 ctx.endSection();
263
264 ctx.beginSection("GL_INVALID_VALUE is generated if maxCount is less than 0.");
265 ctx.glGetAttachedShaders(program, -1, &count[0], &shaders[0]);
266 ctx.expectError(GL_INVALID_VALUE);
267 ctx.endSection();
268
269 ctx.glDeleteShader(shaderObject);
270 ctx.glDeleteProgram(program);
271 }
272
get_shaderiv(NegativeTestContext & ctx)273 void get_shaderiv (NegativeTestContext& ctx)
274 {
275 GLboolean shaderCompilerSupported;
276 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
277 GLuint program = ctx.glCreateProgram();
278 GLint param[1] = { -1 };
279
280 ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
281 ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
282
283 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
284 ctx.glGetShaderiv(shader, -1, ¶m[0]);
285 ctx.expectError(GL_INVALID_ENUM);
286 ctx.endSection();
287
288 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
289 ctx.glGetShaderiv(-1, GL_SHADER_TYPE, ¶m[0]);
290 ctx.expectError(GL_INVALID_VALUE);
291 ctx.endSection();
292
293 ctx.beginSection("GL_INVALID_OPERATION is generated if shader does not refer to a shader object.");
294 ctx.glGetShaderiv(program, GL_SHADER_TYPE, ¶m[0]);
295 ctx.expectError(GL_INVALID_OPERATION);
296 ctx.endSection();
297
298 ctx.glDeleteShader(shader);
299 ctx.glDeleteProgram(program);
300 }
301
get_shader_info_log(NegativeTestContext & ctx)302 void get_shader_info_log (NegativeTestContext& ctx)
303 {
304 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
305 GLuint program = ctx.glCreateProgram();
306 GLsizei length[1] = { -1 };
307 char infoLog[128] = { 0 };
308
309 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
310 ctx.glGetShaderInfoLog(-1, 128, &length[0], &infoLog[0]);
311 ctx.expectError(GL_INVALID_VALUE);
312 ctx.endSection();
313
314 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
315 ctx.glGetShaderInfoLog(program, 128, &length[0], &infoLog[0]);
316 ctx.expectError(GL_INVALID_OPERATION);
317 ctx.endSection();
318
319 ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0.");
320 ctx.glGetShaderInfoLog(shader, -1, &length[0], &infoLog[0]);
321 ctx.expectError(GL_INVALID_VALUE);
322 ctx.endSection();
323
324 ctx.glDeleteShader(shader);
325 ctx.glDeleteProgram(program);
326 }
327
get_shader_precision_format(NegativeTestContext & ctx)328 void get_shader_precision_format (NegativeTestContext& ctx)
329 {
330 GLboolean shaderCompilerSupported;
331 GLint range[2];
332 GLint precision[1];
333
334 ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
335 ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
336
337 deMemset(&range[0], 0xcd, sizeof(range));
338 deMemset(&precision[0], 0xcd, sizeof(precision));
339
340 ctx.beginSection("GL_INVALID_ENUM is generated if shaderType or precisionType is not an accepted value.");
341 ctx.glGetShaderPrecisionFormat (-1, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
342 ctx.expectError(GL_INVALID_ENUM);
343 ctx.glGetShaderPrecisionFormat (GL_VERTEX_SHADER, -1, &range[0], &precision[0]);
344 ctx.expectError(GL_INVALID_ENUM);
345 ctx.glGetShaderPrecisionFormat (-1, -1, &range[0], &precision[0]);
346 ctx.expectError(GL_INVALID_ENUM);
347 ctx.endSection();
348 }
349
get_shader_source(NegativeTestContext & ctx)350 void get_shader_source (NegativeTestContext& ctx)
351 {
352 GLsizei length[1] = { 0 };
353 char source[1] = { 0 };
354 GLuint program = ctx.glCreateProgram();
355 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
356
357 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
358 ctx.glGetShaderSource(-1, 1, &length[0], &source[0]);
359 ctx.expectError(GL_INVALID_VALUE);
360 ctx.endSection();
361
362 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
363 ctx.glGetShaderSource(program, 1, &length[0], &source[0]);
364 ctx.expectError(GL_INVALID_OPERATION);
365 ctx.endSection();
366
367 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
368 ctx.glGetShaderSource(shader, -1, &length[0], &source[0]);
369 ctx.expectError(GL_INVALID_VALUE);
370 ctx.endSection();
371
372 ctx.glDeleteProgram(program);
373 ctx.glDeleteShader(shader);
374 }
375
376 // Enumerated state queries: Programs
377
get_programiv(NegativeTestContext & ctx)378 void get_programiv (NegativeTestContext& ctx)
379 {
380 GLuint program = ctx.glCreateProgram();
381 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
382 GLint params[1] = { 0 };
383
384 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
385 ctx.glGetProgramiv(program, -1, ¶ms[0]);
386 ctx.expectError(GL_INVALID_ENUM);
387 ctx.endSection();
388
389 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
390 ctx.glGetProgramiv(-1, GL_LINK_STATUS, ¶ms[0]);
391 ctx.expectError(GL_INVALID_VALUE);
392 ctx.endSection();
393
394 ctx.beginSection("GL_INVALID_OPERATION is generated if program does not refer to a program object.");
395 ctx.glGetProgramiv(shader, GL_LINK_STATUS, ¶ms[0]);
396 ctx.expectError(GL_INVALID_OPERATION);
397 ctx.endSection();
398
399 ctx.glDeleteProgram(program);
400 ctx.glDeleteShader(shader);
401 }
402
get_program_info_log(NegativeTestContext & ctx)403 void get_program_info_log (NegativeTestContext& ctx)
404 {
405 GLuint program = ctx.glCreateProgram();
406 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
407 GLsizei length[1] = { 0 };
408 char infoLog[1] = { 'x' };
409
410 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
411 ctx.glGetProgramInfoLog (-1, 1, &length[0], &infoLog[0]);
412 ctx.expectError(GL_INVALID_VALUE);
413 ctx.endSection();
414
415 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
416 ctx.glGetProgramInfoLog (shader, 1, &length[0], &infoLog[0]);
417 ctx.expectError(GL_INVALID_OPERATION);
418 ctx.endSection();
419
420 ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0.");
421 ctx.glGetProgramInfoLog (program, -1, &length[0], &infoLog[0]);
422 ctx.expectError(GL_INVALID_VALUE);
423 ctx.endSection();
424
425 ctx.glDeleteProgram(program);
426 ctx.glDeleteShader(shader);
427 }
428
429 // Enumerated state queries: Shader variables
430
get_tex_parameterfv(NegativeTestContext & ctx)431 void get_tex_parameterfv (NegativeTestContext& ctx)
432 {
433 GLfloat params[1] = { 0 };
434
435 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
436 ctx.glGetTexParameterfv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
437 ctx.expectError(GL_INVALID_ENUM);
438 ctx.glGetTexParameterfv (GL_TEXTURE_2D, -1, ¶ms[0]);
439 ctx.expectError(GL_INVALID_ENUM);
440 ctx.glGetTexParameterfv (-1, -1, ¶ms[0]);
441 ctx.expectError(GL_INVALID_ENUM);
442 ctx.endSection();
443 }
444
get_tex_parameteriv(NegativeTestContext & ctx)445 void get_tex_parameteriv (NegativeTestContext& ctx)
446 {
447 GLint params[1] = { 0 };
448
449 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
450 ctx.glGetTexParameteriv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
451 ctx.expectError(GL_INVALID_ENUM);
452 ctx.glGetTexParameteriv (GL_TEXTURE_2D, -1, ¶ms[0]);
453 ctx.expectError(GL_INVALID_ENUM);
454 ctx.glGetTexParameteriv (-1, -1, ¶ms[0]);
455 ctx.expectError(GL_INVALID_ENUM);
456 ctx.endSection();
457 }
458
get_tex_parameteriiv(NegativeTestContext & ctx)459 void get_tex_parameteriiv (NegativeTestContext& ctx)
460 {
461 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
462
463 GLint params[1] = { 0 };
464
465 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
466 ctx.glGetTexParameterIiv(-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
467 ctx.expectError(GL_INVALID_ENUM);
468 ctx.glGetTexParameterIiv(GL_TEXTURE_2D, -1, ¶ms[0]);
469 ctx.expectError(GL_INVALID_ENUM);
470 ctx.glGetTexParameterIiv(-1, -1, ¶ms[0]);
471 ctx.expectError(GL_INVALID_ENUM);
472 ctx.endSection();
473 }
474
get_tex_parameteriuiv(NegativeTestContext & ctx)475 void get_tex_parameteriuiv (NegativeTestContext& ctx)
476 {
477 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
478
479 GLuint params[1] = { 0 };
480
481 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
482 ctx.glGetTexParameterIuiv(-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
483 ctx.expectError(GL_INVALID_ENUM);
484 ctx.glGetTexParameterIuiv(GL_TEXTURE_2D, -1, ¶ms[0]);
485 ctx.expectError(GL_INVALID_ENUM);
486 ctx.glGetTexParameterIuiv(-1, -1, ¶ms[0]);
487 ctx.expectError(GL_INVALID_ENUM);
488 ctx.endSection();
489 }
490
get_uniformfv(NegativeTestContext & ctx)491 void get_uniformfv (NegativeTestContext& ctx)
492 {
493 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
494 GLfloat params[4] = { 0.f };
495 GLuint shader;
496 GLuint programEmpty;
497 GLint unif;
498
499 ctx.glUseProgram(program.getProgram());
500
501 unif = ctx.glGetUniformLocation(program.getProgram(), "vUnif_vec4"); // vec4
502 if (unif == -1)
503 ctx.fail("Failed to retrieve uniform location");
504
505 shader = ctx.glCreateShader(GL_VERTEX_SHADER);
506 programEmpty = ctx.glCreateProgram();
507
508 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
509 ctx.glGetUniformfv (-1, unif, ¶ms[0]);
510 ctx.expectError(GL_INVALID_VALUE);
511 ctx.endSection();
512
513 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
514 ctx.glGetUniformfv (shader, unif, ¶ms[0]);
515 ctx.expectError(GL_INVALID_OPERATION);
516 ctx.endSection();
517
518 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
519 ctx.glGetUniformfv (programEmpty, unif, ¶ms[0]);
520 ctx.expectError(GL_INVALID_OPERATION);
521 ctx.endSection();
522
523 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
524 ctx.glGetUniformfv (program.getProgram(), -1, ¶ms[0]);
525 ctx.expectError(GL_INVALID_OPERATION);
526 ctx.endSection();
527
528 ctx.glDeleteShader(shader);
529 ctx.glDeleteProgram(programEmpty);
530 }
531
get_nuniformfv(NegativeTestContext & ctx)532 void get_nuniformfv (NegativeTestContext& ctx)
533 {
534 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
535
536 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
537 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "vUnif_vec4");
538 GLfloat params[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
539 GLuint shader;
540 GLuint programEmpty;
541 GLsizei bufferSize;
542
543 ctx.glUseProgram(program.getProgram());
544
545 if (unif == -1)
546 ctx.fail("Failed to retrieve uniform location");
547
548 shader = ctx.glCreateShader(GL_VERTEX_SHADER);
549 programEmpty = ctx.glCreateProgram();
550
551 ctx.glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &bufferSize);
552
553 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
554 ctx.glGetnUniformfv(-1, unif, bufferSize, ¶ms[0]);
555 ctx.expectError(GL_INVALID_VALUE);
556 ctx.endSection();
557
558 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
559 ctx.glGetnUniformfv(shader, unif, bufferSize, ¶ms[0]);
560 ctx.expectError(GL_INVALID_OPERATION);
561 ctx.endSection();
562
563 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
564 ctx.glGetnUniformfv(programEmpty, unif, bufferSize, ¶ms[0]);
565 ctx.expectError(GL_INVALID_OPERATION);
566 ctx.endSection();
567
568 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
569 ctx.glGetnUniformfv(program.getProgram(), -1, bufferSize, ¶ms[0]);
570 ctx.expectError(GL_INVALID_OPERATION);
571 ctx.endSection();
572
573 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer size required to store the requested data is greater than bufSize.");
574 ctx.glGetnUniformfv(program.getProgram(), unif, 0, ¶ms[0]);
575 ctx.expectError(GL_INVALID_OPERATION);
576 ctx.endSection();
577
578 ctx.glDeleteShader(shader);
579 ctx.glDeleteProgram(programEmpty);
580 }
581
get_uniformiv(NegativeTestContext & ctx)582 void get_uniformiv (NegativeTestContext& ctx)
583 {
584 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
585 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_ivec4");
586 GLint params[4] = { 0, 0, 0, 0 };
587 GLuint shader;
588 GLuint programEmpty;
589
590 ctx.glUseProgram(program.getProgram());
591
592 if (unif == -1)
593 ctx.fail("Failed to retrieve uniform location");
594
595 shader = ctx.glCreateShader(GL_VERTEX_SHADER);
596 programEmpty = ctx.glCreateProgram();
597
598 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
599 ctx.glGetUniformiv (-1, unif, ¶ms[0]);
600 ctx.expectError(GL_INVALID_VALUE);
601 ctx.endSection();
602
603 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
604 ctx.glGetUniformiv (shader, unif, ¶ms[0]);
605 ctx.expectError(GL_INVALID_OPERATION);
606 ctx.endSection();
607
608 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
609 ctx.glGetUniformiv (programEmpty, unif, ¶ms[0]);
610 ctx.expectError(GL_INVALID_OPERATION);
611 ctx.endSection();
612
613 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
614 ctx.glGetUniformiv (program.getProgram(), -1, ¶ms[0]);
615 ctx.expectError(GL_INVALID_OPERATION);
616 ctx.endSection();
617
618 ctx.glDeleteShader(shader);
619 ctx.glDeleteProgram(programEmpty);
620 }
621
get_nuniformiv(NegativeTestContext & ctx)622 void get_nuniformiv (NegativeTestContext& ctx)
623 {
624 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
625
626 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
627 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_ivec4");
628 GLint params[4] = { 0, 0, 0, 0 };
629 GLuint shader;
630 GLuint programEmpty;
631 GLsizei bufferSize;
632
633 ctx.glUseProgram(program.getProgram());
634
635 if (unif == -1)
636 ctx.fail("Failed to retrieve uniform location");
637
638 shader = ctx.glCreateShader(GL_VERTEX_SHADER);
639 programEmpty = ctx.glCreateProgram();
640
641 ctx.glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &bufferSize);
642
643 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
644 ctx.glGetnUniformiv(-1, unif, bufferSize, ¶ms[0]);
645 ctx.expectError(GL_INVALID_VALUE);
646 ctx.endSection();
647
648 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
649 ctx.glGetnUniformiv(shader, unif, bufferSize, ¶ms[0]);
650 ctx.expectError(GL_INVALID_OPERATION);
651 ctx.endSection();
652
653 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
654 ctx.glGetnUniformiv(programEmpty, unif, bufferSize, ¶ms[0]);
655 ctx.expectError(GL_INVALID_OPERATION);
656 ctx.endSection();
657
658 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
659 ctx.glGetnUniformiv(program.getProgram(), -1, bufferSize, ¶ms[0]);
660 ctx.expectError(GL_INVALID_OPERATION);
661 ctx.endSection();
662
663 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer size required to store the requested data is greater than bufSize.");
664 ctx.glGetnUniformiv(program.getProgram(), unif, - 1, ¶ms[0]);
665 ctx.expectError(GL_INVALID_OPERATION);
666 ctx.endSection();
667
668 ctx.glDeleteShader(shader);
669 ctx.glDeleteProgram(programEmpty);
670 }
671
get_uniformuiv(NegativeTestContext & ctx)672 void get_uniformuiv (NegativeTestContext& ctx)
673 {
674 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
675 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_uvec4");
676 GLuint params[4] = { 0, 0, 0, 0 };
677 GLuint shader;
678 GLuint programEmpty;
679
680 ctx.glUseProgram(program.getProgram());
681
682 if (unif == -1)
683 ctx.fail("Failed to retrieve uniform location");
684
685 shader = ctx.glCreateShader(GL_VERTEX_SHADER);
686 programEmpty = ctx.glCreateProgram();
687
688 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
689 ctx.glGetUniformuiv (-1, unif, ¶ms[0]);
690 ctx.expectError(GL_INVALID_VALUE);
691 ctx.endSection();
692
693 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
694 ctx.glGetUniformuiv (shader, unif, ¶ms[0]);
695 ctx.expectError(GL_INVALID_OPERATION);
696 ctx.endSection();
697
698 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
699 ctx.glGetUniformuiv (programEmpty, unif, ¶ms[0]);
700 ctx.expectError(GL_INVALID_OPERATION);
701 ctx.endSection();
702
703 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
704 ctx.glGetUniformuiv (program.getProgram(), -1, ¶ms[0]);
705 ctx.expectError(GL_INVALID_OPERATION);
706 ctx.endSection();
707
708 ctx.glDeleteShader(shader);
709 ctx.glDeleteProgram(programEmpty);
710 }
711
get_nuniformuiv(NegativeTestContext & ctx)712 void get_nuniformuiv (NegativeTestContext& ctx)
713 {
714 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
715
716 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
717 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_ivec4");
718 GLuint params[4] = { 0, 0, 0, 0 };
719 GLuint shader;
720 GLuint programEmpty;
721 GLsizei bufferSize;
722
723 ctx.glUseProgram(program.getProgram());
724
725 if (unif == -1)
726 ctx.fail("Failed to retrieve uniform location");
727
728 shader = ctx.glCreateShader(GL_VERTEX_SHADER);
729 programEmpty = ctx.glCreateProgram();
730
731 ctx.glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS, &bufferSize);
732
733 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
734 ctx.glGetnUniformuiv(-1, unif, bufferSize, ¶ms[0]);
735 ctx.expectError(GL_INVALID_VALUE);
736 ctx.endSection();
737
738 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
739 ctx.glGetnUniformuiv(shader, unif, bufferSize, ¶ms[0]);
740 ctx.expectError(GL_INVALID_OPERATION);
741 ctx.endSection();
742
743 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
744 ctx.glGetnUniformuiv(programEmpty, unif, bufferSize, ¶ms[0]);
745 ctx.expectError(GL_INVALID_OPERATION);
746 ctx.endSection();
747
748 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
749 ctx.glGetnUniformuiv(program.getProgram(), -1, bufferSize, ¶ms[0]);
750 ctx.expectError(GL_INVALID_OPERATION);
751 ctx.endSection();
752
753 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer size required to store the requested data is greater than bufSize.");
754 ctx.glGetnUniformuiv(program.getProgram(), unif, -1, ¶ms[0]);
755 ctx.expectError(GL_INVALID_OPERATION);
756 ctx.endSection();
757
758 ctx.glDeleteShader(shader);
759 ctx.glDeleteProgram(programEmpty);
760 }
761
get_active_uniform(NegativeTestContext & ctx)762 void get_active_uniform (NegativeTestContext& ctx)
763 {
764 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
765 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
766 GLint numActiveUniforms = -1;
767
768 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
769 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
770
771 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
772 ctx.glGetActiveUniform(-1, 0, 0, 0, 0, 0, 0);
773 ctx.expectError(GL_INVALID_VALUE);
774 ctx.endSection();
775
776 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
777 ctx.glGetActiveUniform(shader, 0, 0, 0, 0, 0, 0);
778 ctx.expectError(GL_INVALID_OPERATION);
779 ctx.endSection();
780
781 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to the number of active uniform variables in program.");
782 ctx.glUseProgram(program.getProgram());
783 ctx.glGetActiveUniform(program.getProgram(), numActiveUniforms, 0, 0, 0, 0, 0);
784 ctx.expectError(GL_INVALID_VALUE);
785 ctx.endSection();
786
787 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
788 ctx.glGetActiveUniform(program.getProgram(), 0, -1, 0, 0, 0, 0);
789 ctx.expectError(GL_INVALID_VALUE);
790 ctx.endSection();
791
792 ctx.glUseProgram(0);
793 ctx.glDeleteShader(shader);
794 }
795
get_active_uniformsiv(NegativeTestContext & ctx)796 void get_active_uniformsiv (NegativeTestContext& ctx)
797 {
798 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
799 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
800 GLuint dummyUniformIndex = 1;
801 GLint dummyParamDst = -1;
802 GLint numActiveUniforms = -1;
803
804 ctx.glUseProgram(program.getProgram());
805
806 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
807 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
808
809 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
810 ctx.glGetActiveUniformsiv(-1, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
811 ctx.expectError(GL_INVALID_VALUE);
812 ctx.endSection();
813
814 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
815 ctx.glGetActiveUniformsiv(shader, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
816 ctx.expectError(GL_INVALID_OPERATION);
817 ctx.endSection();
818
819 ctx.beginSection("GL_INVALID_VALUE is generated if any value in uniformIndices is greater than or equal to the value of GL_ACTIVE_UNIFORMS for program.");
820 for (int excess = 0; excess <= 2; excess++)
821 {
822 std::vector<GLuint> invalidUniformIndices;
823 invalidUniformIndices.push_back(1);
824 invalidUniformIndices.push_back(numActiveUniforms-1+excess);
825 invalidUniformIndices.push_back(1);
826
827 std::vector<GLint> dummyParamsDst(invalidUniformIndices.size());
828 ctx.glGetActiveUniformsiv(program.getProgram(), (GLsizei)invalidUniformIndices.size(), &invalidUniformIndices[0], GL_UNIFORM_TYPE, &dummyParamsDst[0]);
829 ctx.expectError(excess == 0 ? GL_NO_ERROR : GL_INVALID_VALUE);
830 }
831 ctx.endSection();
832
833 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted token.");
834 ctx.glGetActiveUniformsiv(program.getProgram(), 1, &dummyUniformIndex, -1, &dummyParamDst);
835 ctx.expectError(GL_INVALID_ENUM);
836 ctx.endSection();
837
838 ctx.glUseProgram(0);
839 ctx.glDeleteShader(shader);
840 }
841
get_active_uniform_blockiv(NegativeTestContext & ctx)842 void get_active_uniform_blockiv (NegativeTestContext& ctx)
843 {
844 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
845 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
846 GLint params = -1;
847 GLint numActiveBlocks = -1;
848
849 ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
850 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
851 ctx.expectError(GL_NO_ERROR);
852
853 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of either a program or shader object.");
854 ctx.glGetActiveUniformBlockiv(-1, 0, GL_UNIFORM_BLOCK_BINDING, ¶ms);
855 ctx.expectError(GL_INVALID_VALUE);
856 ctx.endSection();
857
858 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object");
859 ctx.glGetActiveUniformBlockiv(shader, 0, GL_UNIFORM_BLOCK_BINDING, ¶ms);
860 ctx.expectError(GL_INVALID_OPERATION);
861 ctx.endSection();
862
863 ctx.beginSection("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.");
864 ctx.glUseProgram(program.getProgram());
865 ctx.expectError(GL_NO_ERROR);
866 ctx.glGetActiveUniformBlockiv(program.getProgram(), numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, ¶ms);
867 ctx.expectError(GL_INVALID_VALUE);
868 ctx.endSection();
869
870 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
871 ctx.glGetActiveUniformBlockiv(program.getProgram(), 0, -1, ¶ms);
872 ctx.expectError(GL_INVALID_ENUM);
873 ctx.endSection();
874
875 ctx.glUseProgram(0);
876 }
877
get_active_uniform_block_name(NegativeTestContext & ctx)878 void get_active_uniform_block_name (NegativeTestContext& ctx)
879 {
880 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
881 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
882 GLsizei length = -1;
883 GLint numActiveBlocks = -1;
884 GLchar uniformBlockName[128];
885
886 deMemset(&uniformBlockName[0], 0, sizeof(uniformBlockName));
887
888 ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
889 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
890 ctx.expectError(GL_NO_ERROR);
891
892 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
893 ctx.glGetActiveUniformBlockName(shader, numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, &length, &uniformBlockName[0]);
894 ctx.expectError(GL_INVALID_OPERATION);
895 ctx.endSection();
896
897 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of either a program or shader object.");
898 ctx.glGetActiveUniformBlockName(-1, numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, &length, &uniformBlockName[0]);
899 ctx.expectError(GL_INVALID_VALUE);
900 ctx.endSection();
901
902 ctx.beginSection("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.");
903 ctx.glUseProgram(program.getProgram());
904 ctx.expectError(GL_NO_ERROR);
905 ctx.glGetActiveUniformBlockName(program.getProgram(), numActiveBlocks, (int)sizeof(uniformBlockName), &length, &uniformBlockName[0]);
906 ctx.expectError(GL_INVALID_VALUE);
907 ctx.endSection();
908
909 ctx.glUseProgram(0);
910 }
911
get_active_attrib(NegativeTestContext & ctx)912 void get_active_attrib (NegativeTestContext& ctx)
913 {
914 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
915 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
916 GLint numActiveAttributes = -1;
917 GLsizei length = -1;
918 GLint size = -1;
919 GLenum type = -1;
920 GLchar name[32];
921
922 deMemset(&name[0], 0, sizeof(name));
923
924 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_ATTRIBUTES, &numActiveAttributes);
925 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_ATTRIBUTES = " << numActiveAttributes << " (expected 1)." << TestLog::EndMessage;
926
927 ctx.glUseProgram(program.getProgram());
928
929 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
930 ctx.glGetActiveAttrib(-1, 0, 32, &length, &size, &type, &name[0]);
931 ctx.expectError(GL_INVALID_VALUE);
932 ctx.endSection();
933
934 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
935 ctx.glGetActiveAttrib(shader, 0, 32, &length, &size, &type, &name[0]);
936 ctx.expectError(GL_INVALID_OPERATION);
937 ctx.endSection();
938
939 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_ACTIVE_ATTRIBUTES.");
940 ctx.glGetActiveAttrib(program.getProgram(), numActiveAttributes, (int)sizeof(name), &length, &size, &type, &name[0]);
941 ctx.expectError(GL_INVALID_VALUE);
942 ctx.endSection();
943
944 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
945 ctx.glGetActiveAttrib(program.getProgram(), 0, -1, &length, &size, &type, &name[0]);
946 ctx.expectError(GL_INVALID_VALUE);
947 ctx.endSection();
948
949 ctx.glUseProgram(0);
950 ctx.glDeleteShader(shader);
951 }
952
get_uniform_indices(NegativeTestContext & ctx)953 void get_uniform_indices (NegativeTestContext& ctx)
954 {
955 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
956 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(getVtxFragVersionSources(uniformTestVertSource, ctx), getVtxFragVersionSources(uniformTestFragSource, ctx)));
957 GLint numActiveBlocks = -1;
958 const GLchar* uniformName = "Block.blockVar";
959 GLuint uniformIndices = -1;
960 GLuint invalid = -1;
961
962 ctx.glGetProgramiv(program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
963 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << TestLog::EndMessage;
964 ctx.expectError(GL_NO_ERROR);
965
966 ctx.beginSection("GL_INVALID_OPERATION is generated if program is a name of shader object.");
967 ctx.glGetUniformIndices(shader, 1, &uniformName, &uniformIndices);
968 ctx.expectError(GL_INVALID_OPERATION);
969 ctx.endSection();
970
971 ctx.beginSection("GL_INVALID_VALUE is generated if program is not name of program or shader object.");
972 ctx.glGetUniformIndices(invalid, 1, &uniformName, &uniformIndices);
973 ctx.expectError(GL_INVALID_VALUE);
974 ctx.endSection();
975
976 ctx.glUseProgram(0);
977 ctx.glDeleteShader(shader);
978 }
979
get_vertex_attribfv(NegativeTestContext & ctx)980 void get_vertex_attribfv (NegativeTestContext& ctx)
981 {
982 GLfloat params = 0.0f;
983 GLint maxVertexAttribs;
984
985 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
986 ctx.glGetVertexAttribfv(0, -1, ¶ms);
987 ctx.expectError(GL_INVALID_ENUM);
988 ctx.endSection();
989
990 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
991 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
992 ctx.glGetVertexAttribfv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
993 ctx.expectError(GL_INVALID_VALUE);
994 ctx.endSection();
995 }
996
get_vertex_attribiv(NegativeTestContext & ctx)997 void get_vertex_attribiv (NegativeTestContext& ctx)
998 {
999 GLint params = -1;
1000 GLint maxVertexAttribs;
1001
1002 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1003 ctx.glGetVertexAttribiv(0, -1, ¶ms);
1004 ctx.expectError(GL_INVALID_ENUM);
1005 ctx.endSection();
1006
1007 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1008 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
1009 ctx.glGetVertexAttribiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
1010 ctx.expectError(GL_INVALID_VALUE);
1011 ctx.endSection();
1012 }
1013
get_vertex_attribi_iv(NegativeTestContext & ctx)1014 void get_vertex_attribi_iv (NegativeTestContext& ctx)
1015 {
1016 GLint params = -1;
1017 GLint maxVertexAttribs;
1018
1019 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1020 ctx.glGetVertexAttribIiv(0, -1, ¶ms);
1021 ctx.expectError(GL_INVALID_ENUM);
1022 ctx.endSection();
1023
1024 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1025 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
1026 ctx.glGetVertexAttribIiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
1027 ctx.expectError(GL_INVALID_VALUE);
1028 ctx.endSection();
1029 }
1030
get_vertex_attribi_uiv(NegativeTestContext & ctx)1031 void get_vertex_attribi_uiv (NegativeTestContext& ctx)
1032 {
1033 GLuint params = (GLuint)-1;
1034 GLint maxVertexAttribs;
1035
1036 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1037 ctx.glGetVertexAttribIuiv(0, -1, ¶ms);
1038 ctx.expectError(GL_INVALID_ENUM);
1039 ctx.endSection();
1040
1041 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1042 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
1043 ctx.glGetVertexAttribIuiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
1044 ctx.expectError(GL_INVALID_VALUE);
1045 ctx.endSection();
1046 }
1047
get_vertex_attrib_pointerv(NegativeTestContext & ctx)1048 void get_vertex_attrib_pointerv (NegativeTestContext& ctx)
1049 {
1050 GLvoid* ptr[1] = { DE_NULL };
1051 GLint maxVertexAttribs;
1052
1053 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1054 ctx.glGetVertexAttribPointerv(0, -1, &ptr[0]);
1055 ctx.expectError(GL_INVALID_ENUM);
1056 ctx.endSection();
1057
1058 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1059 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
1060 ctx.glGetVertexAttribPointerv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr[0]);
1061 ctx.expectError(GL_INVALID_VALUE);
1062 ctx.endSection();
1063 }
1064
get_frag_data_location(NegativeTestContext & ctx)1065 void get_frag_data_location (NegativeTestContext& ctx)
1066 {
1067 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
1068 GLuint program = ctx.glCreateProgram();
1069
1070 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
1071 ctx.glGetFragDataLocation(shader, "gl_FragColor");
1072 ctx.expectError(GL_INVALID_OPERATION);
1073 ctx.endSection();
1074
1075 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been linked.");
1076 ctx.glGetFragDataLocation(program, "gl_FragColor");
1077 ctx.expectError(GL_INVALID_OPERATION);
1078 ctx.endSection();
1079
1080 ctx.glDeleteProgram(program);
1081 ctx.glDeleteShader(shader);
1082 }
1083
1084 // Enumerated state queries: Buffers
1085
get_buffer_parameteriv(NegativeTestContext & ctx)1086 void get_buffer_parameteriv (NegativeTestContext& ctx)
1087 {
1088 GLint params = -1;
1089 GLuint buf;
1090 ctx.glGenBuffers(1, &buf);
1091 ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
1092
1093 ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value.");
1094 ctx.glGetBufferParameteriv(-1, GL_BUFFER_SIZE, ¶ms);
1095 ctx.expectError(GL_INVALID_ENUM);
1096 ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, -1, ¶ms);
1097 ctx.expectError(GL_INVALID_ENUM);
1098 ctx.glGetBufferParameteriv(-1, -1, ¶ms);
1099 ctx.expectError(GL_INVALID_ENUM);
1100 ctx.endSection();
1101
1102 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
1103 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
1104 ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, ¶ms);
1105 ctx.expectError(GL_INVALID_OPERATION);
1106 ctx.endSection();
1107
1108 ctx.glDeleteBuffers(1, &buf);
1109 }
1110
get_buffer_parameteri64v(NegativeTestContext & ctx)1111 void get_buffer_parameteri64v (NegativeTestContext& ctx)
1112 {
1113 GLint64 params = -1;
1114 GLuint buf;
1115 ctx.glGenBuffers(1, &buf);
1116 ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
1117
1118 ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value.");
1119 ctx.glGetBufferParameteri64v(-1, GL_BUFFER_SIZE, ¶ms);
1120 ctx.expectError(GL_INVALID_ENUM);
1121 ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER , -1, ¶ms);
1122 ctx.expectError(GL_INVALID_ENUM);
1123 ctx.glGetBufferParameteri64v(-1, -1, ¶ms);
1124 ctx.expectError(GL_INVALID_ENUM);
1125 ctx.endSection();
1126
1127 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
1128 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
1129 ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, ¶ms);
1130 ctx.expectError(GL_INVALID_OPERATION);
1131 ctx.endSection();
1132
1133 ctx.glDeleteBuffers(1, &buf);
1134 }
1135
get_buffer_pointerv(NegativeTestContext & ctx)1136 void get_buffer_pointerv (NegativeTestContext& ctx)
1137 {
1138 GLvoid* params = DE_NULL;
1139 GLuint buf;
1140 ctx.glGenBuffers(1, &buf);
1141 ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
1142
1143 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
1144 ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, -1, ¶ms);
1145 ctx.expectError(GL_INVALID_ENUM);
1146 ctx.glGetBufferPointerv(-1, GL_BUFFER_MAP_POINTER, ¶ms);
1147 ctx.expectError(GL_INVALID_ENUM);
1148 ctx.endSection();
1149
1150 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
1151 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
1152 ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, GL_BUFFER_MAP_POINTER, ¶ms);
1153 ctx.expectError(GL_INVALID_OPERATION);
1154 ctx.endSection();
1155
1156 ctx.glDeleteBuffers(1, &buf);
1157 }
1158
get_framebuffer_attachment_parameteriv(NegativeTestContext & ctx)1159 void get_framebuffer_attachment_parameteriv (NegativeTestContext& ctx)
1160 {
1161 GLint params[1] = { -1 };
1162 GLuint fbo;
1163 GLuint rbo[2];
1164
1165 ctx.glGenFramebuffers (1, &fbo);
1166 ctx.glGenRenderbuffers (2, rbo);
1167
1168 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1169 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1170 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 16, 16);
1171 ctx.glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1172 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
1173 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_STENCIL_INDEX8, 16, 16);
1174 ctx.glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1175 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
1176 ctx.expectError (GL_NO_ERROR);
1177
1178 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1179 ctx.glGetFramebufferAttachmentParameteriv(-1, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, ¶ms[0]); // TYPE is GL_RENDERBUFFER
1180 ctx.expectError(GL_INVALID_ENUM);
1181 ctx.endSection();
1182
1183 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
1184 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, ¶ms[0]); // TYPE is GL_RENDERBUFFER
1185 ctx.expectError(GL_INVALID_ENUM);
1186 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1187 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // TYPE is GL_FRAMEBUFFER_DEFAULT
1188 ctx.expectError(GL_INVALID_ENUM);
1189 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1190 ctx.endSection();
1191
1192 ctx.beginSection("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.");
1193 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]);
1194 ctx.expectError(GL_INVALID_OPERATION);
1195 ctx.endSection();
1196
1197 ctx.beginSection("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.");
1198 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // TYPE is GL_NONE
1199 ctx.expectError(GL_NO_ERROR);
1200 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, ¶ms[0]); // TYPE is GL_NONE
1201 ctx.expectError(GL_INVALID_OPERATION);
1202 ctx.endSection();
1203
1204 ctx.beginSection("GL_INVALID_OPERATION or GL_INVALID_ENUM is generated if attachment is not one of the accepted values for the current binding of target.");
1205 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // A FBO is bound so GL_BACK is invalid
1206 ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
1207 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1208 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // Default framebuffer is bound so GL_COLOR_ATTACHMENT0 is invalid
1209 ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
1210 ctx.endSection();
1211
1212 ctx.glDeleteFramebuffers(1, &fbo);
1213 }
1214
get_renderbuffer_parameteriv(NegativeTestContext & ctx)1215 void get_renderbuffer_parameteriv (NegativeTestContext& ctx)
1216 {
1217 GLint params[1] = { -1 };
1218 GLuint rbo;
1219 ctx.glGenRenderbuffers(1, &rbo);
1220 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1221
1222 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1223 ctx.glGetRenderbufferParameteriv(-1, GL_RENDERBUFFER_WIDTH, ¶ms[0]);
1224 ctx.expectError(GL_INVALID_ENUM);
1225 ctx.endSection();
1226
1227 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
1228 ctx.glGetRenderbufferParameteriv(GL_RENDERBUFFER, -1, ¶ms[0]);
1229 ctx.expectError(GL_INVALID_ENUM);
1230 ctx.endSection();
1231
1232 ctx.beginSection("GL_INVALID_OPERATION is generated if the renderbuffer currently bound to target is zero.");
1233 ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
1234 ctx.expectError(GL_NO_ERROR);
1235 ctx.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, ¶ms[0]);
1236 ctx.expectError(GL_INVALID_OPERATION);
1237 ctx.endSection();
1238
1239 ctx.glDeleteRenderbuffers(1, &rbo);
1240 ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
1241 }
1242
get_internalformativ(NegativeTestContext & ctx)1243 void get_internalformativ (NegativeTestContext& ctx)
1244 {
1245 GLint params[16];
1246
1247 deMemset(¶ms[0], 0xcd, sizeof(params));
1248
1249 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is negative.");
1250 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, -1, ¶ms[0]);
1251 ctx.expectError (GL_INVALID_VALUE);
1252 ctx.endSection();
1253
1254 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_SAMPLES or GL_NUM_SAMPLE_COUNTS.");
1255 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, -1, 16, ¶ms[0]);
1256 ctx.expectError (GL_INVALID_ENUM);
1257 ctx.endSection();
1258
1259 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not color-, depth-, or stencil-renderable.");
1260
1261 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_render_snorm"))
1262 {
1263 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RG8_SNORM, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
1264 ctx.expectError (GL_INVALID_ENUM);
1265 }
1266
1267 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_COMPRESSED_RGB8_ETC2, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
1268 ctx.expectError (GL_INVALID_ENUM);
1269 ctx.endSection();
1270
1271 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1272 ctx.glGetInternalformativ (-1, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
1273 ctx.expectError (GL_INVALID_ENUM);
1274 ctx.glGetInternalformativ (GL_FRAMEBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
1275 ctx.expectError (GL_INVALID_ENUM);
1276
1277 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_sparse_texture"))
1278 {
1279 ctx.glGetInternalformativ (GL_TEXTURE_2D, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
1280 ctx.expectError (GL_INVALID_ENUM);
1281 }
1282
1283 ctx.endSection();
1284 }
1285
1286 // Query object queries
1287
get_queryiv(NegativeTestContext & ctx)1288 void get_queryiv (NegativeTestContext& ctx)
1289 {
1290 GLint params = -1;
1291
1292 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
1293 ctx.glGetQueryiv (GL_ANY_SAMPLES_PASSED, -1, ¶ms);
1294 ctx.expectError (GL_INVALID_ENUM);
1295 ctx.glGetQueryiv (-1, GL_CURRENT_QUERY, ¶ms);
1296 ctx.expectError (GL_INVALID_ENUM);
1297 ctx.glGetQueryiv (-1, -1, ¶ms);
1298 ctx.expectError (GL_INVALID_ENUM);
1299 ctx.endSection();
1300 }
1301
get_query_objectuiv(NegativeTestContext & ctx)1302 void get_query_objectuiv (NegativeTestContext& ctx)
1303 {
1304 GLuint params = -1;
1305 GLuint id;
1306 ctx.glGenQueries (1, &id);
1307
1308 ctx.beginSection("GL_INVALID_OPERATION is generated if id is not the name of a query object.");
1309 ctx.glGetQueryObjectuiv (-1, GL_QUERY_RESULT_AVAILABLE, ¶ms);
1310 ctx.expectError (GL_INVALID_OPERATION);
1311 ctx.getLog() << TestLog::Message << "// Note: " << id << " is not a query object yet, since it hasn't been used by glBeginQuery" << TestLog::EndMessage;
1312 ctx.glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms);
1313 ctx.expectError (GL_INVALID_OPERATION);
1314 ctx.endSection();
1315
1316 ctx.glBeginQuery (GL_ANY_SAMPLES_PASSED, id);
1317 ctx.glEndQuery (GL_ANY_SAMPLES_PASSED);
1318
1319 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1320 ctx.glGetQueryObjectuiv (id, -1, ¶ms);
1321 ctx.expectError (GL_INVALID_ENUM);
1322 ctx.endSection();
1323
1324 ctx.beginSection("GL_INVALID_OPERATION is generated if id is the name of a currently active query object.");
1325 ctx.glBeginQuery (GL_ANY_SAMPLES_PASSED, id);
1326 ctx.expectError (GL_NO_ERROR);
1327 ctx.glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms);
1328 ctx.expectError (GL_INVALID_OPERATION);
1329 ctx.glEndQuery (GL_ANY_SAMPLES_PASSED);
1330 ctx.expectError (GL_NO_ERROR);
1331 ctx.endSection();
1332
1333 ctx.glDeleteQueries (1, &id);
1334 }
1335
1336 // Sync object queries
1337
get_synciv(NegativeTestContext & ctx)1338 void get_synciv (NegativeTestContext& ctx)
1339 {
1340 GLsizei length = -1;
1341 GLint values[32];
1342 GLsync sync;
1343
1344 deMemset(&values[0], 0xcd, sizeof(values));
1345
1346 ctx.beginSection("GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
1347 ctx.glGetSynciv(0, GL_OBJECT_TYPE, 32, &length, &values[0]);
1348 ctx.expectError(GL_INVALID_VALUE);
1349 ctx.endSection();
1350
1351 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
1352 sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1353 ctx.expectError(GL_NO_ERROR);
1354 ctx.glGetSynciv(sync, -1, 32, &length, &values[0]);
1355 ctx.expectError(GL_INVALID_ENUM);
1356 ctx.endSection();
1357
1358 ctx.glDeleteSync(sync);
1359
1360 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is negative.");
1361 sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1362 ctx.expectError(GL_NO_ERROR);
1363 ctx.glGetSynciv(sync, GL_OBJECT_TYPE, -1, &length, &values[0]);
1364 ctx.expectError(GL_INVALID_VALUE);
1365 ctx.endSection();
1366
1367 ctx.glDeleteSync(sync);
1368 }
1369
1370 // Enumerated boolean state queries
1371
is_enabled(NegativeTestContext & ctx)1372 void is_enabled (NegativeTestContext& ctx)
1373 {
1374 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not an accepted value.");
1375 ctx.glIsEnabled(-1);
1376 ctx.expectError(GL_INVALID_ENUM);
1377 ctx.glIsEnabled(GL_TRIANGLES);
1378 ctx.expectError(GL_INVALID_ENUM);
1379 ctx.endSection();
1380 }
1381
is_enabledi(NegativeTestContext & ctx)1382 void is_enabledi (NegativeTestContext& ctx)
1383 {
1384 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a higher context version.");
1385
1386 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not an accepted value.");
1387 ctx.glIsEnabledi(-1, 1);
1388 ctx.expectError(GL_INVALID_ENUM);
1389 ctx.glIsEnabledi(GL_TRIANGLES, 1);
1390 ctx.expectError(GL_INVALID_ENUM);
1391 ctx.endSection();
1392
1393 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside the valid range for the indexed state cap.");
1394 ctx.glIsEnabledi(GL_BLEND, -1);
1395 ctx.expectError(GL_INVALID_VALUE);
1396 ctx.endSection();
1397 }
1398
1399 // Hints
1400
hint(NegativeTestContext & ctx)1401 void hint (NegativeTestContext& ctx)
1402 {
1403 ctx.beginSection("GL_INVALID_ENUM is generated if either target or mode is not an accepted value.");
1404 ctx.glHint(GL_GENERATE_MIPMAP_HINT, -1);
1405 ctx.expectError(GL_INVALID_ENUM);
1406 ctx.glHint(-1, GL_FASTEST);
1407 ctx.expectError(GL_INVALID_ENUM);
1408 ctx.glHint(-1, -1);
1409 ctx.expectError(GL_INVALID_ENUM);
1410 ctx.endSection();
1411 }
1412
getNegativeStateApiTestFunctions()1413 std::vector<FunctionContainer> getNegativeStateApiTestFunctions ()
1414 {
1415 const FunctionContainer funcs[] =
1416 {
1417 {enable, "enable", "Invalid glEnable() usage" },
1418 {disable, "disable", "Invalid glDisable() usage" },
1419 {get_booleanv, "get_booleanv", "Invalid glGetBooleanv() usage" },
1420 {get_floatv, "get_floatv", "Invalid glGetFloatv() usage" },
1421 {get_integerv, "get_integerv", "Invalid glGetIntegerv() usage" },
1422 {get_integer64v, "get_integer64v", "Invalid glGetInteger64v() usage" },
1423 {get_integeri_v, "get_integeri_v", "Invalid glGetIntegeri_v() usage" },
1424 {get_booleani_v, "get_booleani_v", "Invalid glGetBooleani_v() usage" },
1425 {get_integer64i_v, "get_integer64i_v", "Invalid glGetInteger64i_v() usage" },
1426 {get_string, "get_string", "Invalid glGetString() usage" },
1427 {get_stringi, "get_stringi", "Invalid glGetStringi() usage" },
1428 {get_attached_shaders, "get_attached_shaders", "Invalid glGetAttachedShaders() usage" },
1429 {get_shaderiv, "get_shaderiv", "Invalid glGetShaderiv() usage" },
1430 {get_shader_info_log, "get_shader_info_log", "Invalid glGetShaderInfoLog() usage" },
1431 {get_shader_precision_format, "get_shader_precision_format", "Invalid glGetShaderPrecisionFormat() usage" },
1432 {get_shader_source, "get_shader_source", "Invalid glGetShaderSource() usage" },
1433 {get_programiv, "get_programiv", "Invalid glGetProgramiv() usage" },
1434 {get_program_info_log, "get_program_info_log", "Invalid glGetProgramInfoLog() usage" },
1435 {get_tex_parameterfv, "get_tex_parameterfv", "Invalid glGetTexParameterfv() usage" },
1436 {get_tex_parameteriv, "get_tex_parameteriv", "Invalid glGetTexParameteriv() usage" },
1437 {get_uniformfv, "get_uniformfv", "Invalid glGetUniformfv() usage" },
1438 {get_uniformiv, "get_uniformiv", "Invalid glGetUniformiv() usage" },
1439 {get_uniformuiv, "get_uniformuiv", "Invalid glGetUniformuiv() usage" },
1440 {get_active_uniform, "get_active_uniform", "Invalid glGetActiveUniform() usage" },
1441 {get_active_uniformsiv, "get_active_uniformsiv", "Invalid glGetActiveUniformsiv() usage" },
1442 {get_active_uniform_blockiv, "get_active_uniform_blockiv", "Invalid glGetActiveUniformBlockiv() usage" },
1443 {get_active_uniform_block_name, "get_active_uniform_block_name", "Invalid glGetActiveUniformBlockName() usage" },
1444 {get_active_attrib, "get_active_attrib", "Invalid glGetActiveAttrib() usage" },
1445 {get_uniform_indices, "get_uniform_indices", "Invalid glGetUniformIndices() usage" },
1446 {get_vertex_attribfv, "get_vertex_attribfv", "Invalid glGetVertexAttribfv() usage" },
1447 {get_vertex_attribiv, "get_vertex_attribiv", "Invalid glGetVertexAttribiv() usage" },
1448 {get_vertex_attribi_iv, "get_vertex_attribi_iv", "Invalid glGetVertexAttribIiv() usage" },
1449 {get_vertex_attribi_uiv, "get_vertex_attribi_uiv", "Invalid glGetVertexAttribIuiv() usage" },
1450 {get_vertex_attrib_pointerv, "get_vertex_attrib_pointerv", "Invalid glGetVertexAttribPointerv() usage" },
1451 {get_frag_data_location, "get_frag_data_location", "Invalid glGetFragDataLocation() usage" },
1452 {get_buffer_parameteriv, "get_buffer_parameteriv", "Invalid glGetBufferParameteriv() usage" },
1453 {get_buffer_parameteri64v, "get_buffer_parameteri64v", "Invalid glGetBufferParameteri64v() usage" },
1454 {get_buffer_pointerv, "get_buffer_pointerv", "Invalid glGetBufferPointerv() usage" },
1455 {get_framebuffer_attachment_parameteriv, "get_framebuffer_attachment_parameteriv", "Invalid glGetFramebufferAttachmentParameteriv() usage" },
1456 {get_renderbuffer_parameteriv, "get_renderbuffer_parameteriv", "Invalid glGetRenderbufferParameteriv() usage" },
1457 {get_internalformativ, "get_internalformativ", "Invalid glGetInternalformativ() usage" },
1458 {get_queryiv, "get_queryiv", "Invalid glGetQueryiv() usage" },
1459 {get_query_objectuiv, "get_query_objectuiv", "Invalid glGetQueryObjectuiv() usage" },
1460 {get_synciv, "get_synciv", "Invalid glGetSynciv() usage" },
1461 {is_enabled, "is_enabled", "Invalid glIsEnabled() usage" },
1462 {hint, "hint", "Invalid glHint() usage" },
1463 {enablei, "enablei", "Invalid glEnablei() usage" },
1464 {disablei, "disablei", "Invalid glDisablei() usage" },
1465 {get_tex_parameteriiv, "get_tex_parameteriiv", "Invalid glGetTexParameterIiv() usage" },
1466 {get_tex_parameteriuiv, "get_tex_parameteriuiv", "Invalid glGetTexParameterIuiv() usage" },
1467 {get_nuniformfv, "get_nuniformfv", "Invalid glGetnUniformfv() usage" },
1468 {get_nuniformiv, "get_nuniformiv", "Invalid glGetnUniformiv() usage" },
1469 {get_nuniformuiv, "get_nuniformuiv", "Invalid glGetnUniformuiv() usage" },
1470 {is_enabledi, "is_enabledi", "Invalid glIsEnabledi() usage" },
1471 };
1472
1473 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
1474 }
1475
1476 } // NegativeTestShared
1477 } // Functional
1478 } // gles3
1479 } // deqp
1480