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 "deMemory.h"
34
35 namespace deqp
36 {
37 namespace gles31
38 {
39 namespace Functional
40 {
41 namespace NegativeTestShared
42 {
43
44 using tcu::TestLog;
45 using glu::CallLogWrapper;
46 using namespace glw;
47
48 static const char* uniformTestVertSource = "#version 300 es\n"
49 "uniform mediump vec4 vUnif_vec4;\n"
50 "in mediump vec4 attr;"
51 "layout(shared) uniform Block { mediump vec4 blockVar; };\n"
52 "void main (void)\n"
53 "{\n"
54 " gl_Position = vUnif_vec4 + blockVar + attr;\n"
55 "}\n\0";
56 static const char* uniformTestFragSource = "#version 300 es\n"
57 "uniform mediump ivec4 fUnif_ivec4;\n"
58 "uniform mediump uvec4 fUnif_uvec4;\n"
59 "layout(location = 0) out mediump vec4 fragColor;"
60 "void main (void)\n"
61 "{\n"
62 " fragColor = vec4(vec4(fUnif_ivec4) + vec4(fUnif_uvec4));\n"
63 "}\n\0";
64
65 // Enabling & disabling states
enable(NegativeTestContext & ctx)66 void enable (NegativeTestContext& ctx)
67 {
68 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
69 ctx.glEnable(-1);
70 ctx.expectError(GL_INVALID_ENUM);
71 ctx.endSection();
72 }
73
disable(NegativeTestContext & ctx)74 void disable (NegativeTestContext& ctx)
75 {
76 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not one of the allowed values.");
77 ctx.glDisable(-1);
78 ctx.expectError(GL_INVALID_ENUM);
79 ctx.endSection();
80 }
81
82 // Simple state queries
get_booleanv(NegativeTestContext & ctx)83 void get_booleanv (NegativeTestContext& ctx)
84 {
85 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
86 GLboolean params = GL_FALSE;
87 ctx.glGetBooleanv(-1, ¶ms);
88 ctx.expectError(GL_INVALID_ENUM);
89 ctx.endSection();
90 }
91
get_floatv(NegativeTestContext & ctx)92 void get_floatv (NegativeTestContext& ctx)
93 {
94 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
95 GLfloat params = 0.0f;
96 ctx.glGetFloatv(-1, ¶ms);
97 ctx.expectError(GL_INVALID_ENUM);
98 ctx.endSection();
99 }
100
get_integerv(NegativeTestContext & ctx)101 void get_integerv (NegativeTestContext& ctx)
102 {
103 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
104 GLint params = -1;
105 ctx.glGetIntegerv(-1, ¶ms);
106 ctx.expectError(GL_INVALID_ENUM);
107 ctx.endSection();
108 }
109
get_integer64v(NegativeTestContext & ctx)110 void get_integer64v (NegativeTestContext& ctx)
111 {
112 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the allowed values.");
113 GLint64 params = -1;
114 ctx.glGetInteger64v(-1, ¶ms);
115 ctx.expectError(GL_INVALID_ENUM);
116 ctx.endSection();
117 }
118
get_integeri_v(NegativeTestContext & ctx)119 void get_integeri_v (NegativeTestContext& ctx)
120 {
121 GLint data = -1;
122 GLint maxUniformBufferBindings = 0;
123
124 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
125 ctx.glGetIntegeri_v(-1, 0, &data);
126 ctx.expectError(GL_INVALID_ENUM);
127 ctx.endSection();
128
129 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
130 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
131 ctx.expectError(GL_NO_ERROR);
132 ctx.glGetIntegeri_v(GL_UNIFORM_BUFFER_BINDING, maxUniformBufferBindings, &data);
133 ctx.expectError(GL_INVALID_VALUE);
134 ctx.endSection();
135 }
136
get_integer64i_v(NegativeTestContext & ctx)137 void get_integer64i_v (NegativeTestContext& ctx)
138 {
139 GLint64 data = (GLint64)-1;
140 GLint maxUniformBufferBindings = 0;
141
142 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
143 ctx.glGetInteger64i_v(-1, 0, &data);
144 ctx.expectError(GL_INVALID_ENUM);
145 ctx.endSection();
146
147 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside of the valid range for the indexed state target.");
148 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings);
149 ctx.expectError(GL_NO_ERROR);
150 ctx.glGetInteger64i_v(GL_UNIFORM_BUFFER_START, maxUniformBufferBindings, &data);
151 ctx.expectError(GL_INVALID_VALUE);
152 ctx.endSection();
153 }
154
get_string(NegativeTestContext & ctx)155 void get_string (NegativeTestContext& ctx)
156 {
157 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
158 ctx.glGetString(-1);
159 ctx.expectError(GL_INVALID_ENUM);
160 ctx.endSection();
161 }
162
get_stringi(NegativeTestContext & ctx)163 void get_stringi (NegativeTestContext& ctx)
164 {
165 GLint numExtensions = 0;
166
167 ctx.beginSection("GL_INVALID_ENUM is generated if name is not an accepted value.");
168 ctx.glGetStringi(-1, 0);
169 ctx.expectError(GL_INVALID_ENUM);
170 ctx.endSection();
171
172 ctx.beginSection("GL_INVALID_VALUE is generated if index is outside the valid range for indexed state name.");
173 ctx.glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
174 ctx.glGetStringi(GL_EXTENSIONS, numExtensions);
175 ctx.expectError(GL_INVALID_VALUE);
176 ctx.endSection();
177 }
178
179 // Enumerated state queries: Shaders
180
get_attached_shaders(NegativeTestContext & ctx)181 void get_attached_shaders (NegativeTestContext& ctx)
182 {
183 GLuint shaders[1] = { 0 };
184 GLuint shaderObject = ctx.glCreateShader(GL_VERTEX_SHADER);
185 GLuint program = ctx.glCreateProgram();
186 GLsizei count[1] = { 0 };
187
188 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
189 ctx.glGetAttachedShaders(-1, 1, &count[0], &shaders[0]);
190 ctx.expectError(GL_INVALID_VALUE);
191 ctx.endSection();
192
193 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
194 ctx.glGetAttachedShaders(shaderObject, 1, &count[0], &shaders[0]);
195 ctx.expectError(GL_INVALID_OPERATION);
196 ctx.endSection();
197
198 ctx.beginSection("GL_INVALID_VALUE is generated if maxCount is less than 0.");
199 ctx.glGetAttachedShaders(program, -1, &count[0], &shaders[0]);
200 ctx.expectError(GL_INVALID_VALUE);
201 ctx.endSection();
202
203 ctx.glDeleteShader(shaderObject);
204 ctx.glDeleteProgram(program);
205 }
206
get_shaderiv(NegativeTestContext & ctx)207 void get_shaderiv (NegativeTestContext& ctx)
208 {
209 GLboolean shaderCompilerSupported;
210 ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
211 ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
212
213 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
214 GLuint program = ctx.glCreateProgram();
215 GLint param[1] = { -1 };
216
217 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
218 ctx.glGetShaderiv(shader, -1, ¶m[0]);
219 ctx.expectError(GL_INVALID_ENUM);
220 ctx.endSection();
221
222 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
223 ctx.glGetShaderiv(-1, GL_SHADER_TYPE, ¶m[0]);
224 ctx.expectError(GL_INVALID_VALUE);
225 ctx.endSection();
226
227 ctx.beginSection("GL_INVALID_OPERATION is generated if shader does not refer to a shader object.");
228 ctx.glGetShaderiv(program, GL_SHADER_TYPE, ¶m[0]);
229 ctx.expectError(GL_INVALID_OPERATION);
230 ctx.endSection();
231
232 ctx.glDeleteShader(shader);
233 ctx.glDeleteProgram(program);
234 }
235
get_shader_info_log(NegativeTestContext & ctx)236 void get_shader_info_log (NegativeTestContext& ctx)
237 {
238 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
239 GLuint program = ctx.glCreateProgram();
240 GLsizei length[1] = { -1 };
241 char infoLog[128] = { 0 };
242
243 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
244 ctx.glGetShaderInfoLog(-1, 128, &length[0], &infoLog[0]);
245 ctx.expectError(GL_INVALID_VALUE);
246 ctx.endSection();
247
248 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
249 ctx.glGetShaderInfoLog(program, 128, &length[0], &infoLog[0]);
250 ctx.expectError(GL_INVALID_OPERATION);
251 ctx.endSection();
252
253 ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0.");
254 ctx.glGetShaderInfoLog(shader, -1, &length[0], &infoLog[0]);
255 ctx.expectError(GL_INVALID_VALUE);
256 ctx.endSection();
257
258 ctx.glDeleteShader(shader);
259 ctx.glDeleteProgram(program);
260 }
261
get_shader_precision_format(NegativeTestContext & ctx)262 void get_shader_precision_format (NegativeTestContext& ctx)
263 {
264 GLboolean shaderCompilerSupported;
265 ctx.glGetBooleanv(GL_SHADER_COMPILER, &shaderCompilerSupported);
266 ctx.getLog() << TestLog::Message << "// GL_SHADER_COMPILER = " << (shaderCompilerSupported ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage;
267
268 GLint range[2];
269 GLint precision[1];
270
271 deMemset(&range[0], 0xcd, sizeof(range));
272 deMemset(&precision[0], 0xcd, sizeof(precision));
273
274 ctx.beginSection("GL_INVALID_ENUM is generated if shaderType or precisionType is not an accepted value.");
275 ctx.glGetShaderPrecisionFormat (-1, GL_MEDIUM_FLOAT, &range[0], &precision[0]);
276 ctx.expectError(GL_INVALID_ENUM);
277 ctx.glGetShaderPrecisionFormat (GL_VERTEX_SHADER, -1, &range[0], &precision[0]);
278 ctx.expectError(GL_INVALID_ENUM);
279 ctx.glGetShaderPrecisionFormat (-1, -1, &range[0], &precision[0]);
280 ctx.expectError(GL_INVALID_ENUM);
281 ctx.endSection();
282 }
283
get_shader_source(NegativeTestContext & ctx)284 void get_shader_source (NegativeTestContext& ctx)
285 {
286 GLsizei length[1] = { 0 };
287 char source[1] = { 0 };
288 GLuint program = ctx.glCreateProgram();
289 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
290
291 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.");
292 ctx.glGetShaderSource(-1, 1, &length[0], &source[0]);
293 ctx.expectError(GL_INVALID_VALUE);
294 ctx.endSection();
295
296 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object.");
297 ctx.glGetShaderSource(program, 1, &length[0], &source[0]);
298 ctx.expectError(GL_INVALID_OPERATION);
299 ctx.endSection();
300
301 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
302 ctx.glGetShaderSource(shader, -1, &length[0], &source[0]);
303 ctx.expectError(GL_INVALID_VALUE);
304 ctx.endSection();
305
306 ctx.glDeleteProgram(program);
307 ctx.glDeleteShader(shader);
308 }
309
310 // Enumerated state queries: Programs
311
get_programiv(NegativeTestContext & ctx)312 void get_programiv (NegativeTestContext& ctx)
313 {
314 GLuint program = ctx.glCreateProgram();
315 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
316 GLint params[1] = { 0 };
317
318 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
319 ctx.glGetProgramiv(program, -1, ¶ms[0]);
320 ctx.expectError(GL_INVALID_ENUM);
321 ctx.endSection();
322
323 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
324 ctx.glGetProgramiv(-1, GL_LINK_STATUS, ¶ms[0]);
325 ctx.expectError(GL_INVALID_VALUE);
326 ctx.endSection();
327
328 ctx.beginSection("GL_INVALID_OPERATION is generated if program does not refer to a program object.");
329 ctx.glGetProgramiv(shader, GL_LINK_STATUS, ¶ms[0]);
330 ctx.expectError(GL_INVALID_OPERATION);
331 ctx.endSection();
332
333 ctx.glDeleteProgram(program);
334 ctx.glDeleteShader(shader);
335 }
336
get_program_info_log(NegativeTestContext & ctx)337 void get_program_info_log (NegativeTestContext& ctx)
338 {
339 GLuint program = ctx.glCreateProgram();
340 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
341 GLsizei length[1] = { 0 };
342 char infoLog[1] = { 'x' };
343
344 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
345 ctx.glGetProgramInfoLog (-1, 1, &length[0], &infoLog[0]);
346 ctx.expectError(GL_INVALID_VALUE);
347 ctx.endSection();
348
349 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
350 ctx.glGetProgramInfoLog (shader, 1, &length[0], &infoLog[0]);
351 ctx.expectError(GL_INVALID_OPERATION);
352 ctx.endSection();
353
354 ctx.beginSection("GL_INVALID_VALUE is generated if maxLength is less than 0.");
355 ctx.glGetProgramInfoLog (program, -1, &length[0], &infoLog[0]);
356 ctx.expectError(GL_INVALID_VALUE);
357 ctx.endSection();
358
359 ctx.glDeleteProgram(program);
360 ctx.glDeleteShader(shader);
361 }
362
363 // Enumerated state queries: Shader variables
364
get_tex_parameterfv(NegativeTestContext & ctx)365 void get_tex_parameterfv (NegativeTestContext& ctx)
366 {
367 GLfloat params[1] = { 0 };
368
369 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
370 ctx.glGetTexParameterfv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
371 ctx.expectError(GL_INVALID_ENUM);
372 ctx.glGetTexParameterfv (GL_TEXTURE_2D, -1, ¶ms[0]);
373 ctx.expectError(GL_INVALID_ENUM);
374 ctx.glGetTexParameterfv (-1, -1, ¶ms[0]);
375 ctx.expectError(GL_INVALID_ENUM);
376 ctx.endSection();
377 }
378
get_tex_parameteriv(NegativeTestContext & ctx)379 void get_tex_parameteriv (NegativeTestContext& ctx)
380 {
381 GLint params[1] = { 0 };
382
383 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
384 ctx.glGetTexParameteriv (-1, GL_TEXTURE_MAG_FILTER, ¶ms[0]);
385 ctx.expectError(GL_INVALID_ENUM);
386 ctx.glGetTexParameteriv (GL_TEXTURE_2D, -1, ¶ms[0]);
387 ctx.expectError(GL_INVALID_ENUM);
388 ctx.glGetTexParameteriv (-1, -1, ¶ms[0]);
389 ctx.expectError(GL_INVALID_ENUM);
390 ctx.endSection();
391 }
392
get_uniformfv(NegativeTestContext & ctx)393 void get_uniformfv (NegativeTestContext& ctx)
394 {
395 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
396 ctx.glUseProgram(program.getProgram());
397
398 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "vUnif_vec4"); // vec4
399 if (unif == -1)
400 ctx.fail("Failed to retrieve uniform location");
401
402 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
403 GLuint programEmpty = ctx.glCreateProgram();
404 GLfloat params[4] = { 0.f };
405
406 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
407 ctx.glGetUniformfv (-1, unif, ¶ms[0]);
408 ctx.expectError(GL_INVALID_VALUE);
409 ctx.endSection();
410
411 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
412 ctx.glGetUniformfv (shader, unif, ¶ms[0]);
413 ctx.expectError(GL_INVALID_OPERATION);
414 ctx.endSection();
415
416 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
417 ctx.glGetUniformfv (programEmpty, unif, ¶ms[0]);
418 ctx.expectError(GL_INVALID_OPERATION);
419 ctx.endSection();
420
421 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
422 ctx.glGetUniformfv (program.getProgram(), -1, ¶ms[0]);
423 ctx.expectError(GL_INVALID_OPERATION);
424 ctx.endSection();
425
426 ctx.glDeleteShader(shader);
427 ctx.glDeleteProgram(programEmpty);
428 }
429
get_uniformiv(NegativeTestContext & ctx)430 void get_uniformiv (NegativeTestContext& ctx)
431 {
432 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
433 ctx.glUseProgram(program.getProgram());
434
435 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_ivec4"); // ivec4
436 if (unif == -1)
437 ctx.fail("Failed to retrieve uniform location");
438
439 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
440 GLuint programEmpty = ctx.glCreateProgram();
441 GLint params[4] = { 0 };
442
443 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
444 ctx.glGetUniformiv (-1, unif, ¶ms[0]);
445 ctx.expectError(GL_INVALID_VALUE);
446 ctx.endSection();
447
448 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
449 ctx.glGetUniformiv (shader, unif, ¶ms[0]);
450 ctx.expectError(GL_INVALID_OPERATION);
451 ctx.endSection();
452
453 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
454 ctx.glGetUniformiv (programEmpty, unif, ¶ms[0]);
455 ctx.expectError(GL_INVALID_OPERATION);
456 ctx.endSection();
457
458 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
459 ctx.glGetUniformiv (program.getProgram(), -1, ¶ms[0]);
460 ctx.expectError(GL_INVALID_OPERATION);
461 ctx.endSection();
462
463 ctx.glDeleteShader(shader);
464 ctx.glDeleteProgram(programEmpty);
465 }
466
get_uniformuiv(NegativeTestContext & ctx)467 void get_uniformuiv (NegativeTestContext& ctx)
468 {
469 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
470 ctx.glUseProgram(program.getProgram());
471
472 GLint unif = ctx.glGetUniformLocation(program.getProgram(), "fUnif_uvec4"); // uvec4
473 if (unif == -1)
474 ctx.fail("Failed to retrieve uniform location");
475
476 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
477 GLuint programEmpty = ctx.glCreateProgram();
478 GLuint params[4] = { 0 };
479
480 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
481 ctx.glGetUniformuiv (-1, unif, ¶ms[0]);
482 ctx.expectError(GL_INVALID_VALUE);
483 ctx.endSection();
484
485 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
486 ctx.glGetUniformuiv (shader, unif, ¶ms[0]);
487 ctx.expectError(GL_INVALID_OPERATION);
488 ctx.endSection();
489
490 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked.");
491 ctx.glGetUniformuiv (programEmpty, unif, ¶ms[0]);
492 ctx.expectError(GL_INVALID_OPERATION);
493 ctx.endSection();
494
495 ctx.beginSection("GL_INVALID_OPERATION is generated if location does not correspond to a valid uniform variable location for the specified program object.");
496 ctx.glGetUniformuiv (program.getProgram(), -1, ¶ms[0]);
497 ctx.expectError(GL_INVALID_OPERATION);
498 ctx.endSection();
499
500 ctx.glDeleteShader(shader);
501 ctx.glDeleteProgram(programEmpty);
502 }
503
get_active_uniform(NegativeTestContext & ctx)504 void get_active_uniform (NegativeTestContext& ctx)
505 {
506 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
507 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
508 GLint numActiveUniforms = -1;
509
510 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
511 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
512
513 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
514 ctx.glGetActiveUniform(-1, 0, 0, 0, 0, 0, 0);
515 ctx.expectError(GL_INVALID_VALUE);
516 ctx.endSection();
517
518 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
519 ctx.glGetActiveUniform(shader, 0, 0, 0, 0, 0, 0);
520 ctx.expectError(GL_INVALID_OPERATION);
521 ctx.endSection();
522
523 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to the number of active uniform variables in program.");
524 ctx.glUseProgram(program.getProgram());
525 ctx.glGetActiveUniform(program.getProgram(), numActiveUniforms, 0, 0, 0, 0, 0);
526 ctx.expectError(GL_INVALID_VALUE);
527 ctx.endSection();
528
529 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
530 ctx.glGetActiveUniform(program.getProgram(), 0, -1, 0, 0, 0, 0);
531 ctx.expectError(GL_INVALID_VALUE);
532 ctx.endSection();
533
534 ctx.glUseProgram(0);
535 ctx.glDeleteShader(shader);
536 }
537
get_active_uniformsiv(NegativeTestContext & ctx)538 void get_active_uniformsiv (NegativeTestContext& ctx)
539 {
540 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
541 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
542 GLuint dummyUniformIndex = 1;
543 GLint dummyParamDst = -1;
544 GLint numActiveUniforms = -1;
545
546 ctx.glUseProgram(program.getProgram());
547
548 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms);
549 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << " (expected 4)." << TestLog::EndMessage;
550
551 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
552 ctx.glGetActiveUniformsiv(-1, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
553 ctx.expectError(GL_INVALID_VALUE);
554 ctx.endSection();
555
556 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
557 ctx.glGetActiveUniformsiv(shader, 1, &dummyUniformIndex, GL_UNIFORM_TYPE, &dummyParamDst);
558 ctx.expectError(GL_INVALID_OPERATION);
559 ctx.endSection();
560
561 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.");
562 for (int excess = 0; excess <= 2; excess++)
563 {
564 std::vector<GLuint> invalidUniformIndices;
565 invalidUniformIndices.push_back(1);
566 invalidUniformIndices.push_back(numActiveUniforms-1+excess);
567 invalidUniformIndices.push_back(1);
568
569 std::vector<GLint> dummyParamsDst(invalidUniformIndices.size());
570 ctx.glGetActiveUniformsiv(program.getProgram(), (GLsizei)invalidUniformIndices.size(), &invalidUniformIndices[0], GL_UNIFORM_TYPE, &dummyParamsDst[0]);
571 ctx.expectError(excess == 0 ? GL_NO_ERROR : GL_INVALID_VALUE);
572 }
573 ctx.endSection();
574
575 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted token.");
576 ctx.glGetActiveUniformsiv(program.getProgram(), 1, &dummyUniformIndex, -1, &dummyParamDst);
577 ctx.expectError(GL_INVALID_ENUM);
578 ctx.endSection();
579
580 ctx.glUseProgram(0);
581 ctx.glDeleteShader(shader);
582 }
583
get_active_uniform_blockiv(NegativeTestContext & ctx)584 void get_active_uniform_blockiv (NegativeTestContext& ctx)
585 {
586 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
587 GLint params = -1;
588 GLint numActiveBlocks = -1;
589
590 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
591 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
592 ctx.expectError (GL_NO_ERROR);
593
594 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.");
595 ctx.glUseProgram(program.getProgram());
596 ctx.expectError(GL_NO_ERROR);
597 ctx.glGetActiveUniformBlockiv(program.getProgram(), numActiveBlocks, GL_UNIFORM_BLOCK_BINDING, ¶ms);
598 ctx.expectError(GL_INVALID_VALUE);
599 ctx.endSection();
600
601 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
602 ctx.glGetActiveUniformBlockiv(program.getProgram(), 0, -1, ¶ms);
603 ctx.expectError(GL_INVALID_ENUM);
604 ctx.endSection();
605
606 ctx.glUseProgram(0);
607 }
608
get_active_uniform_block_name(NegativeTestContext & ctx)609 void get_active_uniform_block_name (NegativeTestContext& ctx)
610 {
611 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
612 GLsizei length = -1;
613 GLint numActiveBlocks = -1;
614 GLchar uniformBlockName[128];
615
616 deMemset(&uniformBlockName[0], 0, sizeof(uniformBlockName));
617
618 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
619 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << " (expected 1)." << TestLog::EndMessage;
620 ctx.expectError (GL_NO_ERROR);
621
622 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.");
623 ctx.glUseProgram(program.getProgram());
624 ctx.expectError(GL_NO_ERROR);
625 ctx.glGetActiveUniformBlockName(program.getProgram(), numActiveBlocks, (int)sizeof(uniformBlockName), &length, &uniformBlockName[0]);
626 ctx.expectError(GL_INVALID_VALUE);
627 ctx.endSection();
628
629 ctx.glUseProgram(0);
630 }
631
get_active_attrib(NegativeTestContext & ctx)632 void get_active_attrib (NegativeTestContext& ctx)
633 {
634 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
635 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
636 GLint numActiveAttributes = -1;
637
638 GLsizei length = -1;
639 GLint size = -1;
640 GLenum type = -1;
641 GLchar name[32];
642
643 deMemset(&name[0], 0, sizeof(name));
644
645 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_ATTRIBUTES, &numActiveAttributes);
646 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_ATTRIBUTES = " << numActiveAttributes << " (expected 1)." << TestLog::EndMessage;
647
648 ctx.glUseProgram(program.getProgram());
649
650 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.");
651 ctx.glGetActiveAttrib(-1, 0, 32, &length, &size, &type, &name[0]);
652 ctx.expectError(GL_INVALID_VALUE);
653 ctx.endSection();
654
655 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object.");
656 ctx.glGetActiveAttrib(shader, 0, 32, &length, &size, &type, &name[0]);
657 ctx.expectError(GL_INVALID_OPERATION);
658 ctx.endSection();
659
660 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_ACTIVE_ATTRIBUTES.");
661 ctx.glGetActiveAttrib(program.getProgram(), numActiveAttributes, (int)sizeof(name), &length, &size, &type, &name[0]);
662 ctx.expectError(GL_INVALID_VALUE);
663 ctx.endSection();
664
665 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is less than 0.");
666 ctx.glGetActiveAttrib(program.getProgram(), 0, -1, &length, &size, &type, &name[0]);
667 ctx.expectError(GL_INVALID_VALUE);
668 ctx.endSection();
669
670 ctx.glUseProgram(0);
671 ctx.glDeleteShader(shader);
672 }
673
get_uniform_indices(NegativeTestContext & ctx)674 void get_uniform_indices (NegativeTestContext& ctx)
675 {
676 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
677 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource));
678 GLint numActiveBlocks = -1;
679 const GLchar* uniformName = "Block.blockVar";
680 GLuint uniformIndices = -1;
681
682 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks);
683 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << TestLog::EndMessage;
684 ctx.expectError (GL_NO_ERROR);
685
686 ctx.beginSection("GL_INVALID_OPERATION is generated if program is a name of shader object.");
687 ctx.glGetUniformIndices(shader, 1, &uniformName, &uniformIndices);
688 ctx.expectError(GL_INVALID_OPERATION);
689 ctx.endSection();
690
691 ctx.beginSection("GL_INVALID_VALUE is generated if program is not name of program or shader object.");
692 GLuint invalid = -1;
693 ctx.glGetUniformIndices(invalid, 1, &uniformName, &uniformIndices);
694 ctx.expectError(GL_INVALID_VALUE);
695 ctx.endSection();
696
697 ctx.glUseProgram(0);
698 ctx.glDeleteShader(shader);
699 }
700
get_vertex_attribfv(NegativeTestContext & ctx)701 void get_vertex_attribfv (NegativeTestContext& ctx)
702 {
703 GLfloat params = 0.0f;
704
705 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
706 ctx.glGetVertexAttribfv(0, -1, ¶ms);
707 ctx.expectError(GL_INVALID_ENUM);
708 ctx.endSection();
709
710 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
711 GLint maxVertexAttribs;
712 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
713 ctx.glGetVertexAttribfv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
714 ctx.expectError(GL_INVALID_VALUE);
715 ctx.endSection();
716 }
717
get_vertex_attribiv(NegativeTestContext & ctx)718 void get_vertex_attribiv (NegativeTestContext& ctx)
719 {
720 GLint params = -1;
721
722 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
723 ctx.glGetVertexAttribiv(0, -1, ¶ms);
724 ctx.expectError(GL_INVALID_ENUM);
725 ctx.endSection();
726
727 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
728 GLint maxVertexAttribs;
729 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
730 ctx.glGetVertexAttribiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
731 ctx.expectError(GL_INVALID_VALUE);
732 ctx.endSection();
733 }
734
get_vertex_attribi_iv(NegativeTestContext & ctx)735 void get_vertex_attribi_iv (NegativeTestContext& ctx)
736 {
737 GLint params = -1;
738
739 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
740 ctx.glGetVertexAttribIiv(0, -1, ¶ms);
741 ctx.expectError(GL_INVALID_ENUM);
742 ctx.endSection();
743
744 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
745 GLint maxVertexAttribs;
746 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
747 ctx.glGetVertexAttribIiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
748 ctx.expectError(GL_INVALID_VALUE);
749 ctx.endSection();
750 }
751
get_vertex_attribi_uiv(NegativeTestContext & ctx)752 void get_vertex_attribi_uiv (NegativeTestContext& ctx)
753 {
754 GLuint params = (GLuint)-1;
755
756 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
757 ctx.glGetVertexAttribIuiv(0, -1, ¶ms);
758 ctx.expectError(GL_INVALID_ENUM);
759 ctx.endSection();
760
761 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
762 GLint maxVertexAttribs;
763 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
764 ctx.glGetVertexAttribIuiv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_ENABLED, ¶ms);
765 ctx.expectError(GL_INVALID_VALUE);
766 ctx.endSection();
767 }
768
get_vertex_attrib_pointerv(NegativeTestContext & ctx)769 void get_vertex_attrib_pointerv (NegativeTestContext& ctx)
770 {
771 GLvoid* ptr[1] = { DE_NULL };
772
773 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
774 ctx.glGetVertexAttribPointerv(0, -1, &ptr[0]);
775 ctx.expectError(GL_INVALID_ENUM);
776 ctx.endSection();
777
778 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
779 GLint maxVertexAttribs;
780 ctx.glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs);
781 ctx.glGetVertexAttribPointerv(maxVertexAttribs, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr[0]);
782 ctx.expectError(GL_INVALID_VALUE);
783 ctx.endSection();
784 }
785
get_frag_data_location(NegativeTestContext & ctx)786 void get_frag_data_location (NegativeTestContext& ctx)
787 {
788 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER);
789 GLuint program = ctx.glCreateProgram();
790
791 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the name of a shader object.");
792 ctx.glGetFragDataLocation(shader, "gl_FragColor");
793 ctx.expectError(GL_INVALID_OPERATION);
794 ctx.endSection();
795
796 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been linked.");
797 ctx.glGetFragDataLocation(program, "gl_FragColor");
798 ctx.expectError(GL_INVALID_OPERATION);
799 ctx.endSection();
800
801 ctx.glDeleteProgram(program);
802 ctx.glDeleteShader(shader);
803 }
804
805 // Enumerated state queries: Buffers
806
get_buffer_parameteriv(NegativeTestContext & ctx)807 void get_buffer_parameteriv (NegativeTestContext& ctx)
808 {
809 GLint params = -1;
810 GLuint buf;
811 ctx.glGenBuffers(1, &buf);
812 ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
813
814 ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value.");
815 ctx.glGetBufferParameteriv(-1, GL_BUFFER_SIZE, ¶ms);
816 ctx.expectError(GL_INVALID_ENUM);
817 ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, -1, ¶ms);
818 ctx.expectError(GL_INVALID_ENUM);
819 ctx.glGetBufferParameteriv(-1, -1, ¶ms);
820 ctx.expectError(GL_INVALID_ENUM);
821 ctx.endSection();
822
823 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
824 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
825 ctx.glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, ¶ms);
826 ctx.expectError(GL_INVALID_OPERATION);
827 ctx.endSection();
828
829 ctx.glDeleteBuffers(1, &buf);
830 }
831
get_buffer_parameteri64v(NegativeTestContext & ctx)832 void get_buffer_parameteri64v (NegativeTestContext& ctx)
833 {
834 GLint64 params = -1;
835 GLuint buf;
836 ctx.glGenBuffers(1, &buf);
837 ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
838
839 ctx.beginSection("GL_INVALID_ENUM is generated if target or value is not an accepted value.");
840 ctx.glGetBufferParameteri64v(-1, GL_BUFFER_SIZE, ¶ms);
841 ctx.expectError(GL_INVALID_ENUM);
842 ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER , -1, ¶ms);
843 ctx.expectError(GL_INVALID_ENUM);
844 ctx.glGetBufferParameteri64v(-1, -1, ¶ms);
845 ctx.expectError(GL_INVALID_ENUM);
846 ctx.endSection();
847
848 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
849 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
850 ctx.glGetBufferParameteri64v(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, ¶ms);
851 ctx.expectError(GL_INVALID_OPERATION);
852 ctx.endSection();
853
854 ctx.glDeleteBuffers(1, &buf);
855 }
856
get_buffer_pointerv(NegativeTestContext & ctx)857 void get_buffer_pointerv (NegativeTestContext& ctx)
858 {
859 GLvoid* params = DE_NULL;
860 GLuint buf;
861 ctx.glGenBuffers(1, &buf);
862 ctx.glBindBuffer(GL_ARRAY_BUFFER, buf);
863
864 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
865 ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, -1, ¶ms);
866 ctx.expectError(GL_INVALID_ENUM);
867 ctx.glGetBufferPointerv(-1, GL_BUFFER_MAP_POINTER, ¶ms);
868 ctx.expectError(GL_INVALID_ENUM);
869 ctx.endSection();
870
871 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
872 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
873 ctx.glGetBufferPointerv(GL_ARRAY_BUFFER, GL_BUFFER_MAP_POINTER, ¶ms);
874 ctx.expectError(GL_INVALID_OPERATION);
875 ctx.endSection();
876
877 ctx.glDeleteBuffers(1, &buf);
878 }
879
get_framebuffer_attachment_parameteriv(NegativeTestContext & ctx)880 void get_framebuffer_attachment_parameteriv (NegativeTestContext& ctx)
881 {
882 GLint params[1] = { -1 };
883 GLuint fbo;
884 GLuint rbo[2];
885
886 ctx.glGenFramebuffers (1, &fbo);
887 ctx.glGenRenderbuffers (2, rbo);
888
889 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
890 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
891 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 16, 16);
892 ctx.glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
893 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
894 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_STENCIL_INDEX8, 16, 16);
895 ctx.glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
896 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
897 ctx.expectError (GL_NO_ERROR);
898
899 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
900 ctx.glGetFramebufferAttachmentParameteriv(-1, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, ¶ms[0]); // TYPE is GL_RENDERBUFFER
901 ctx.expectError(GL_INVALID_ENUM);
902 ctx.endSection();
903
904 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not valid for the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE.");
905 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, ¶ms[0]); // TYPE is GL_RENDERBUFFER
906 ctx.expectError(GL_INVALID_ENUM);
907 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
908 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // TYPE is GL_FRAMEBUFFER_DEFAULT
909 ctx.expectError(GL_INVALID_ENUM);
910 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
911 ctx.endSection();
912
913 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.");
914 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]);
915 ctx.expectError(GL_INVALID_OPERATION);
916 ctx.endSection();
917
918 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.");
919 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // TYPE is GL_NONE
920 ctx.expectError(GL_NO_ERROR);
921 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, ¶ms[0]); // TYPE is GL_NONE
922 ctx.expectError(GL_INVALID_OPERATION);
923 ctx.endSection();
924
925 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.");
926 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // A FBO is bound so GL_BACK is invalid
927 ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
928 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
929 ctx.glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, ¶ms[0]); // Default framebuffer is bound so GL_COLOR_ATTACHMENT0 is invalid
930 ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_ENUM);
931 ctx.endSection();
932
933 ctx.glDeleteFramebuffers(1, &fbo);
934 }
935
get_renderbuffer_parameteriv(NegativeTestContext & ctx)936 void get_renderbuffer_parameteriv (NegativeTestContext& ctx)
937 {
938 GLint params[1] = { -1 };
939 GLuint rbo;
940 ctx.glGenRenderbuffers(1, &rbo);
941 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
942
943 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
944 ctx.glGetRenderbufferParameteriv(-1, GL_RENDERBUFFER_WIDTH, ¶ms[0]);
945 ctx.expectError(GL_INVALID_ENUM);
946 ctx.endSection();
947
948 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
949 ctx.glGetRenderbufferParameteriv(GL_RENDERBUFFER, -1, ¶ms[0]);
950 ctx.expectError(GL_INVALID_ENUM);
951 ctx.endSection();
952
953 ctx.glDeleteRenderbuffers(1, &rbo);
954 ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
955 }
956
get_internalformativ(NegativeTestContext & ctx)957 void get_internalformativ (NegativeTestContext& ctx)
958 {
959 GLint params[16];
960
961 deMemset(¶ms[0], 0xcd, sizeof(params));
962
963 ctx.beginSection("GL_INVALID_VALUE is generated if bufSize is negative.");
964 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, -1, ¶ms[0]);
965 ctx.expectError (GL_INVALID_VALUE);
966 ctx.endSection();
967
968 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_SAMPLES or GL_NUM_SAMPLE_COUNTS.");
969 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8, -1, 16, ¶ms[0]);
970 ctx.expectError (GL_INVALID_ENUM);
971 ctx.endSection();
972
973 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not color-, depth-, or stencil-renderable.");
974
975 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_render_snorm"))
976 {
977 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RG8_SNORM, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
978 ctx.expectError (GL_INVALID_ENUM);
979 }
980
981 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_COMPRESSED_RGB8_ETC2, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
982 ctx.expectError (GL_INVALID_ENUM);
983 ctx.endSection();
984
985 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
986 ctx.glGetInternalformativ (-1, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
987 ctx.expectError (GL_INVALID_ENUM);
988 ctx.glGetInternalformativ (GL_FRAMEBUFFER, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
989 ctx.expectError (GL_INVALID_ENUM);
990
991 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_sparse_texture"))
992 {
993 ctx.glGetInternalformativ (GL_TEXTURE_2D, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, 16, ¶ms[0]);
994 ctx.expectError (GL_INVALID_ENUM);
995 }
996
997 ctx.endSection();
998 }
999
1000 // Query object queries
1001
get_queryiv(NegativeTestContext & ctx)1002 void get_queryiv (NegativeTestContext& ctx)
1003 {
1004 GLint params = -1;
1005
1006 ctx.beginSection("GL_INVALID_ENUM is generated if target or pname is not an accepted value.");
1007 ctx.glGetQueryiv (GL_ANY_SAMPLES_PASSED, -1, ¶ms);
1008 ctx.expectError (GL_INVALID_ENUM);
1009 ctx.glGetQueryiv (-1, GL_CURRENT_QUERY, ¶ms);
1010 ctx.expectError (GL_INVALID_ENUM);
1011 ctx.glGetQueryiv (-1, -1, ¶ms);
1012 ctx.expectError (GL_INVALID_ENUM);
1013 ctx.endSection();
1014 }
1015
get_query_objectuiv(NegativeTestContext & ctx)1016 void get_query_objectuiv (NegativeTestContext& ctx)
1017 {
1018 GLuint params = -1;
1019 GLuint id;
1020 ctx.glGenQueries (1, &id);
1021
1022 ctx.beginSection("GL_INVALID_OPERATION is generated if id is not the name of a query object.");
1023 ctx.glGetQueryObjectuiv (-1, GL_QUERY_RESULT_AVAILABLE, ¶ms);
1024 ctx.expectError (GL_INVALID_OPERATION);
1025 ctx.getLog() << TestLog::Message << "// Note: " << id << " is not a query object yet, since it hasn't been used by glBeginQuery" << TestLog::EndMessage;
1026 ctx.glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms);
1027 ctx.expectError (GL_INVALID_OPERATION);
1028 ctx.endSection();
1029
1030 ctx.glBeginQuery (GL_ANY_SAMPLES_PASSED, id);
1031 ctx.glEndQuery (GL_ANY_SAMPLES_PASSED);
1032
1033 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value.");
1034 ctx.glGetQueryObjectuiv (id, -1, ¶ms);
1035 ctx.expectError (GL_INVALID_ENUM);
1036 ctx.endSection();
1037
1038 ctx.beginSection("GL_INVALID_OPERATION is generated if id is the name of a currently active query object.");
1039 ctx.glBeginQuery (GL_ANY_SAMPLES_PASSED, id);
1040 ctx.expectError (GL_NO_ERROR);
1041 ctx.glGetQueryObjectuiv (id, GL_QUERY_RESULT_AVAILABLE, ¶ms);
1042 ctx.expectError (GL_INVALID_OPERATION);
1043 ctx.glEndQuery (GL_ANY_SAMPLES_PASSED);
1044 ctx.expectError (GL_NO_ERROR);
1045 ctx.endSection();
1046
1047 ctx.glDeleteQueries (1, &id);
1048 }
1049
1050 // Sync object queries
1051
get_synciv(NegativeTestContext & ctx)1052 void get_synciv (NegativeTestContext& ctx)
1053 {
1054 GLsizei length = -1;
1055 GLint values[32];
1056 GLsync sync;
1057
1058 deMemset(&values[0], 0xcd, sizeof(values));
1059
1060 ctx.beginSection("GL_INVALID_VALUE is generated if sync is not the name of a sync object.");
1061 ctx.glGetSynciv (0, GL_OBJECT_TYPE, 32, &length, &values[0]);
1062 ctx.expectError (GL_INVALID_VALUE);
1063 ctx.endSection();
1064
1065 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not one of the accepted tokens.");
1066 sync = ctx.glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1067 ctx.expectError (GL_NO_ERROR);
1068 ctx.glGetSynciv (sync, -1, 32, &length, &values[0]);
1069 ctx.expectError (GL_INVALID_ENUM);
1070 ctx.endSection();
1071
1072 ctx.glDeleteSync(sync);
1073 }
1074
1075 // Enumerated boolean state queries
1076
is_enabled(NegativeTestContext & ctx)1077 void is_enabled (NegativeTestContext& ctx)
1078 {
1079 ctx.beginSection("GL_INVALID_ENUM is generated if cap is not an accepted value.");
1080 ctx.glIsEnabled(-1);
1081 ctx.expectError(GL_INVALID_ENUM);
1082 ctx.glIsEnabled(GL_TRIANGLES);
1083 ctx.expectError(GL_INVALID_ENUM);
1084 ctx.endSection();
1085 }
1086
1087 // Hints
1088
hint(NegativeTestContext & ctx)1089 void hint (NegativeTestContext& ctx)
1090 {
1091 ctx.beginSection("GL_INVALID_ENUM is generated if either target or mode is not an accepted value.");
1092 ctx.glHint(GL_GENERATE_MIPMAP_HINT, -1);
1093 ctx.expectError(GL_INVALID_ENUM);
1094 ctx.glHint(-1, GL_FASTEST);
1095 ctx.expectError(GL_INVALID_ENUM);
1096 ctx.glHint(-1, -1);
1097 ctx.expectError(GL_INVALID_ENUM);
1098 ctx.endSection();
1099 }
1100
getNegativeStateApiTestFunctions()1101 std::vector<FunctionContainer> getNegativeStateApiTestFunctions ()
1102 {
1103 FunctionContainer funcs[] =
1104 {
1105 {enable, "enable", "Invalid glEnable() usage" },
1106 {disable, "disable", "Invalid glDisable() usage" },
1107 {get_booleanv, "get_booleanv", "Invalid glGetBooleanv() usage" },
1108 {get_floatv, "get_floatv", "Invalid glGetFloatv() usage" },
1109 {get_integerv, "get_integerv", "Invalid glGetIntegerv() usage" },
1110 {get_integer64v, "get_integer64v", "Invalid glGetInteger64v() usage" },
1111 {get_integeri_v, "get_integeri_v", "Invalid glGetIntegeri_v() usage" },
1112 {get_integer64i_v, "get_integer64i_v", "Invalid glGetInteger64i_v() usage" },
1113 {get_string, "get_string", "Invalid glGetString() usage" },
1114 {get_stringi, "get_stringi", "Invalid glGetStringi() usage" },
1115 {get_attached_shaders, "get_attached_shaders", "Invalid glGetAttachedShaders() usage" },
1116 {get_shaderiv, "get_shaderiv", "Invalid glGetShaderiv() usage" },
1117 {get_shader_info_log, "get_shader_info_log", "Invalid glGetShaderInfoLog() usage" },
1118 {get_shader_precision_format, "get_shader_precision_format", "Invalid glGetShaderPrecisionFormat() usage" },
1119 {get_shader_source, "get_shader_source", "Invalid glGetShaderSource() usage" },
1120 {get_programiv, "get_programiv", "Invalid glGetProgramiv() usage" },
1121 {get_program_info_log, "get_program_info_log", "Invalid glGetProgramInfoLog() usage" },
1122 {get_tex_parameterfv, "get_tex_parameterfv", "Invalid glGetTexParameterfv() usage" },
1123 {get_tex_parameteriv, "get_tex_parameteriv", "Invalid glGetTexParameteriv() usage" },
1124 {get_uniformfv, "get_uniformfv", "Invalid glGetUniformfv() usage" },
1125 {get_uniformiv, "get_uniformiv", "Invalid glGetUniformiv() usage" },
1126 {get_uniformuiv, "get_uniformuiv", "Invalid glGetUniformuiv() usage" },
1127 {get_active_uniform, "get_active_uniform", "Invalid glGetActiveUniform() usage" },
1128 {get_active_uniformsiv, "get_active_uniformsiv", "Invalid glGetActiveUniformsiv() usage" },
1129 {get_active_uniform_blockiv, "get_active_uniform_blockiv", "Invalid glGetActiveUniformBlockiv() usage" },
1130 {get_active_uniform_block_name, "get_active_uniform_block_name", "Invalid glGetActiveUniformBlockName() usage" },
1131 {get_active_attrib, "get_active_attrib", "Invalid glGetActiveAttrib() usage" },
1132 {get_uniform_indices, "get_uniform_indices", "Invalid glGetUniformIndices() usage" },
1133 {get_vertex_attribfv, "get_vertex_attribfv", "Invalid glGetVertexAttribfv() usage" },
1134 {get_vertex_attribiv, "get_vertex_attribiv", "Invalid glGetVertexAttribiv() usage" },
1135 {get_vertex_attribi_iv, "get_vertex_attribi_iv", "Invalid glGetVertexAttribIiv() usage" },
1136 {get_vertex_attribi_uiv, "get_vertex_attribi_uiv", "Invalid glGetVertexAttribIuiv() usage" },
1137 {get_vertex_attrib_pointerv, "get_vertex_attrib_pointerv", "Invalid glGetVertexAttribPointerv() usage" },
1138 {get_frag_data_location, "get_frag_data_location", "Invalid glGetFragDataLocation() usage" },
1139 {get_buffer_parameteriv, "get_buffer_parameteriv", "Invalid glGetBufferParameteriv() usage" },
1140 {get_buffer_parameteri64v, "get_buffer_parameteri64v", "Invalid glGetBufferParameteri64v() usage" },
1141 {get_buffer_pointerv, "get_buffer_pointerv", "Invalid glGetBufferPointerv() usage" },
1142 {get_framebuffer_attachment_parameteriv, "get_framebuffer_attachment_parameteriv", "Invalid glGetFramebufferAttachmentParameteriv() usage"},
1143 {get_renderbuffer_parameteriv, "get_renderbuffer_parameteriv", "Invalid glGetRenderbufferParameteriv() usage" },
1144 {get_internalformativ, "get_internalformativ", "Invalid glGetInternalformativ() usage" },
1145 {get_queryiv, "get_queryiv", "Invalid glGetQueryiv() usage" },
1146 {get_query_objectuiv, "get_query_objectuiv", "Invalid glGetQueryObjectuiv() usage" },
1147 {get_synciv, "get_synciv", "Invalid glGetSynciv() usage" },
1148 {is_enabled, "is_enabled", "Invalid glIsEnabled() usage" },
1149 {hint, "hint", "Invalid glHint() usage" },
1150 };
1151
1152 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
1153 }
1154
1155 } // NegativeTestShared
1156 } // Functional
1157 } // gles3
1158 } // deqp
1159