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