1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * \brief Negative Vertex Array API tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es31fNegativeVertexArrayApiTests.hpp"
25 #include "gluCallLogWrapper.hpp"
26 #include "gluContextInfo.hpp"
27 #include "gluShaderProgram.hpp"
28 #include "glwDefs.hpp"
29 #include "glwEnums.hpp"
30 #include "tcuStringTemplate.hpp"
42 namespace NegativeTestShared
46 using glu::CallLogWrapper;
49 static const char* vertexShaderSource = "${GLSL_VERSION_STRING}\n"
52 " gl_Position = vec4(0.0);\n"
55 static const char* fragmentShaderSource = "${GLSL_VERSION_STRING}\n"
56 "layout(location = 0) out mediump vec4 fragColor;"
59 " fragColor = vec4(0.0);\n"
62 static const char* geometryShaderSource = "#version 320 es\n"
63 "layout(points) in;\n"
64 "layout(points, max_vertices = 3) out;\n"
69 void vertex_attribf (NegativeTestContext& ctx)
71 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
72 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
73 ctx.glVertexAttrib1f(maxVertexAttribs, 0.0f);
74 ctx.expectError(GL_INVALID_VALUE);
75 ctx.glVertexAttrib2f(maxVertexAttribs, 0.0f, 0.0f);
76 ctx.expectError(GL_INVALID_VALUE);
77 ctx.glVertexAttrib3f(maxVertexAttribs, 0.0f, 0.0f, 0.0f);
78 ctx.expectError(GL_INVALID_VALUE);
79 ctx.glVertexAttrib4f(maxVertexAttribs, 0.0f, 0.0f, 0.0f, 0.0f);
80 ctx.expectError(GL_INVALID_VALUE);
84 void vertex_attribfv (NegativeTestContext& ctx)
86 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
87 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
89 ctx.glVertexAttrib1fv(maxVertexAttribs, &v[0]);
90 ctx.expectError(GL_INVALID_VALUE);
91 ctx.glVertexAttrib2fv(maxVertexAttribs, &v[0]);
92 ctx.expectError(GL_INVALID_VALUE);
93 ctx.glVertexAttrib3fv(maxVertexAttribs, &v[0]);
94 ctx.expectError(GL_INVALID_VALUE);
95 ctx.glVertexAttrib4fv(maxVertexAttribs, &v[0]);
96 ctx.expectError(GL_INVALID_VALUE);
100 void vertex_attribi4 (NegativeTestContext& ctx)
102 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
106 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
107 ctx.glVertexAttribI4i(maxVertexAttribs, valInt, valInt, valInt, valInt);
108 ctx.expectError(GL_INVALID_VALUE);
109 ctx.glVertexAttribI4ui(maxVertexAttribs, valUint, valUint, valUint, valUint);
110 ctx.expectError(GL_INVALID_VALUE);
114 void vertex_attribi4v (NegativeTestContext& ctx)
116 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
117 GLint valInt[4] = { 0 };
118 GLuint valUint[4] = { 0 };
120 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
121 ctx.glVertexAttribI4iv(maxVertexAttribs, &valInt[0]);
122 ctx.expectError(GL_INVALID_VALUE);
123 ctx.glVertexAttribI4uiv(maxVertexAttribs, &valUint[0]);
124 ctx.expectError(GL_INVALID_VALUE);
128 void vertex_attrib_pointer (NegativeTestContext& ctx)
130 ctx.beginSection("GL_INVALID_ENUM is generated if type is not an accepted value.");
131 ctx.glVertexAttribPointer(0, 1, 0, GL_TRUE, 0, 0);
132 ctx.expectError(GL_INVALID_ENUM);
135 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
136 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
137 ctx.glVertexAttribPointer(maxVertexAttribs, 1, GL_BYTE, GL_TRUE, 0, 0);
138 ctx.expectError(GL_INVALID_VALUE);
141 ctx.beginSection("GL_INVALID_VALUE is generated if size is not 1, 2, 3, or 4.");
142 ctx.glVertexAttribPointer(0, 0, GL_BYTE, GL_TRUE, 0, 0);
143 ctx.expectError(GL_INVALID_VALUE);
146 ctx.beginSection("GL_INVALID_VALUE is generated if stride is negative.");
147 ctx.glVertexAttribPointer(0, 1, GL_BYTE, GL_TRUE, -1, 0);
148 ctx.expectError(GL_INVALID_VALUE);
151 ctx.beginSection("GL_INVALID_OPERATION is generated if type is GL_INT_2_10_10_10_REV or GL_UNSIGNED_INT_2_10_10_10_REV and size is not 4.");
152 ctx.glVertexAttribPointer(0, 2, GL_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
153 ctx.expectError(GL_INVALID_OPERATION);
154 ctx.glVertexAttribPointer(0, 2, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
155 ctx.expectError(GL_INVALID_OPERATION);
156 ctx.glVertexAttribPointer(0, 4, GL_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
157 ctx.expectError(GL_NO_ERROR);
158 ctx.glVertexAttribPointer(0, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
159 ctx.expectError(GL_NO_ERROR);
162 ctx.beginSection("GL_INVALID_OPERATION is generated a non-zero vertex array object is bound, zero is bound to the GL_ARRAY_BUFFER buffer object binding point and the pointer argument is not NULL.");
165 ctx.glGenVertexArrays(1, &vao);
166 ctx.glBindVertexArray(vao);
167 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
168 ctx.expectError(GL_NO_ERROR);
170 ctx.glVertexAttribPointer(0, 1, GL_BYTE, GL_TRUE, 0, &offset);
171 ctx.expectError(GL_INVALID_OPERATION);
173 ctx.glBindVertexArray(0);
174 ctx.glDeleteVertexArrays(1, &vao);
175 ctx.expectError(GL_NO_ERROR);
179 void vertex_attrib_i_pointer (NegativeTestContext& ctx)
181 ctx.beginSection("GL_INVALID_ENUM is generated if type is not an accepted value.");
182 ctx.glVertexAttribIPointer(0, 1, 0, 0, 0);
183 ctx.expectError(GL_INVALID_ENUM);
184 ctx.glVertexAttribIPointer(0, 4, GL_INT_2_10_10_10_REV, 0, 0);
185 ctx.expectError(GL_INVALID_ENUM);
186 ctx.glVertexAttribIPointer(0, 4, GL_UNSIGNED_INT_2_10_10_10_REV, 0, 0);
187 ctx.expectError(GL_INVALID_ENUM);
190 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
191 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
192 ctx.glVertexAttribIPointer(maxVertexAttribs, 1, GL_BYTE, 0, 0);
193 ctx.expectError(GL_INVALID_VALUE);
196 ctx.beginSection("GL_INVALID_VALUE is generated if size is not 1, 2, 3, or 4.");
197 ctx.glVertexAttribIPointer(0, 0, GL_BYTE, 0, 0);
198 ctx.expectError(GL_INVALID_VALUE);
201 ctx.beginSection("GL_INVALID_VALUE is generated if stride is negative.");
202 ctx.glVertexAttribIPointer(0, 1, GL_BYTE, -1, 0);
203 ctx.expectError(GL_INVALID_VALUE);
206 ctx.beginSection("GL_INVALID_OPERATION is generated a non-zero vertex array object is bound, zero is bound to the GL_ARRAY_BUFFER buffer object binding point and the pointer argument is not NULL.");
209 ctx.glGenVertexArrays(1, &vao);
210 ctx.glBindVertexArray(vao);
211 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
212 ctx.expectError(GL_NO_ERROR);
214 ctx.glVertexAttribIPointer(0, 1, GL_BYTE, 0, &offset);
215 ctx.expectError(GL_INVALID_OPERATION);
217 ctx.glBindVertexArray(0);
218 ctx.glDeleteVertexArrays(1, &vao);
219 ctx.expectError(GL_NO_ERROR);
223 void vertex_attrib_format (NegativeTestContext& ctx)
225 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
226 int maxVertexAttribRelativeOffset = ctx.getInteger(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET);
229 ctx.beginSection("GL_INVALID_VALUE is generated if attribindex is greater than or equal to the value of MAX_VERTEX_ATTRIBS.");
230 ctx.glGenVertexArrays(1, &vao);
231 ctx.glBindVertexArray(vao);
232 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
233 ctx.glVertexAttribFormat(maxVertexAttribs, 4, GL_FLOAT, GL_FALSE, maxVertexAttribRelativeOffset);
234 ctx.expectError(GL_INVALID_VALUE);
237 ctx.beginSection("GL_INVALID_VALUE is generated if size is not one of 1, 2, 3, 4.");
238 ctx.glGenVertexArrays(1, &vao);
239 ctx.glBindVertexArray(vao);
240 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
241 ctx.glVertexAttribFormat(1, 0, GL_FLOAT, GL_FALSE, maxVertexAttribRelativeOffset);
242 ctx.expectError(GL_INVALID_VALUE);
245 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the parameter token names allowed.");
246 ctx.glGenVertexArrays(1, &vao);
247 ctx.glBindVertexArray(vao);
248 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
249 ctx.glVertexAttribFormat(1, 4, 1, GL_FALSE, 0);
250 ctx.expectError(GL_INVALID_ENUM);
253 ctx.beginSection("GL_INVALID_OPERATION is generated if type is not a token name allowed.");
254 ctx.glGenVertexArrays(1, &vao);
255 ctx.glBindVertexArray(0);
256 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
257 ctx.glVertexAttribFormat(1, 4, GL_FLOAT, GL_FALSE, 0);
258 ctx.expectError(GL_INVALID_OPERATION);
261 ctx.beginSection("GL_INVALID_OPERATION is generated if type is GL_INT_2_10_10_10_REV and size is not 4.");
262 ctx.glGenVertexArrays(1, &vao);
263 ctx.glBindVertexArray(vao);
264 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
265 ctx.glVertexAttribFormat(1, 3, GL_INT_2_10_10_10_REV, GL_FALSE, 0);
266 ctx.expectError(GL_INVALID_OPERATION);
269 ctx.beginSection("GL_INVALID_OPERATION is generated if type is GL_UNSIGNED_INT_2_10_10_10_REV and size is not 4.");
270 ctx.glGenVertexArrays(1, &vao);
271 ctx.glBindVertexArray(vao);
272 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
273 ctx.glVertexAttribFormat(1, 3, GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 0);
274 ctx.expectError(GL_INVALID_OPERATION);
277 ctx.beginSection("GL_INVALID_VALUE is generated if relativeoffset is larger than the value of GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.");
278 ctx.glGenVertexArrays(1, &vao);
279 ctx.glBindVertexArray(vao);
280 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
281 ctx.glVertexAttribFormat(1, 4, GL_FLOAT, GL_FALSE, maxVertexAttribRelativeOffset + 1);
282 ctx.expectError(GL_INVALID_VALUE);
286 void vertex_attrib_i_format (NegativeTestContext& ctx)
288 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
289 int maxVertexAttribRelativeOffset = ctx.getInteger(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET);
292 ctx.beginSection("GL_INVALID_VALUE is generated if attribindex is greater than or equal to the value of GL_MAX_VERTEX_ATTRIBS.");
293 ctx.glGenVertexArrays(1, &vao);
294 ctx.glBindVertexArray(vao);
295 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
296 ctx.glVertexAttribIFormat(maxVertexAttribs, 4, GL_INT, 0);
297 ctx.expectError(GL_INVALID_VALUE);
300 ctx.beginSection("GL_INVALID_VALUE is generated if size is not one the values 1, 2, 3, 4.");
301 ctx.glGenVertexArrays(1, &vao);
302 ctx.glBindVertexArray(vao);
303 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
304 ctx.glVertexAttribIFormat(1, 0, GL_INT, 0);
305 ctx.expectError(GL_INVALID_VALUE);
308 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the parameter token names allowed.");
309 ctx.glGenVertexArrays(1, &vao);
310 ctx.glBindVertexArray(vao);
311 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
312 ctx.glVertexAttribIFormat(1, 4, GL_FLOAT, 0);
313 ctx.expectError(GL_INVALID_ENUM);
316 ctx.beginSection("GL_INVALID_OPERATION is generated if type is not a token name allowed.");
317 ctx.glGenVertexArrays(1, &vao);
318 ctx.glBindVertexArray(0);
319 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
320 ctx.glVertexAttribIFormat(1, 4, GL_INT, 0);
321 ctx.expectError(GL_INVALID_OPERATION);
324 ctx.beginSection("GL_INVALID_VALUE is generated if relativeoffset is larger than the value of GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.");
325 ctx.glGenVertexArrays(1, &vao);
326 ctx.glBindVertexArray(vao);
327 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
328 ctx.glVertexAttribIFormat(1, 4, GL_INT, maxVertexAttribRelativeOffset + 1);
329 ctx.expectError(GL_INVALID_VALUE);
333 void enable_vertex_attrib_array (NegativeTestContext& ctx)
335 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
337 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
338 ctx.glEnableVertexAttribArray(maxVertexAttribs);
339 ctx.expectError(GL_INVALID_VALUE);
343 void disable_vertex_attrib_array (NegativeTestContext& ctx)
345 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
347 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
348 ctx.glDisableVertexAttribArray(maxVertexAttribs);
349 ctx.expectError(GL_INVALID_VALUE);
353 void gen_vertex_arrays (NegativeTestContext& ctx)
357 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
358 ctx.glGenVertexArrays(-1, &arrays);
359 ctx.expectError(GL_INVALID_VALUE);
363 void bind_vertex_array (NegativeTestContext& ctx)
365 ctx.beginSection("GL_INVALID_OPERATION is generated if array is not zero or the name of an existing vertex array object.");
366 ctx.glBindVertexArray(-1);
367 ctx.expectError(GL_INVALID_OPERATION);
371 void delete_vertex_arrays (NegativeTestContext& ctx)
373 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
374 ctx.glDeleteVertexArrays(-1, 0);
375 ctx.expectError(GL_INVALID_VALUE);
379 void vertex_attrib_divisor (NegativeTestContext& ctx)
381 int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
383 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
384 ctx.glVertexAttribDivisor(maxVertexAttribs, 0);
385 ctx.expectError(GL_INVALID_VALUE);
389 void draw_arrays (NegativeTestContext& ctx)
391 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
393 map<string, string> args;
394 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
395 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
397 ctx.glUseProgram(program.getProgram());
398 ctx.expectError(GL_NO_ERROR);
400 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
401 ctx.glDrawArrays(-1, 0, 1);
402 ctx.expectError(GL_INVALID_ENUM);
405 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
406 ctx.glDrawArrays(GL_POINTS, 0, -1);
407 ctx.expectError(GL_INVALID_VALUE);
410 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
411 ctx.glGenFramebuffers(1, &fbo);
412 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
413 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
414 ctx.glDrawArrays(GL_POINTS, 0, 1);
415 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
416 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
417 ctx.glDeleteFramebuffers(1, &fbo);
423 void draw_arrays_invalid_program (NegativeTestContext& ctx)
428 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
429 ctx.glDrawArrays(-1, 0, 1);
430 ctx.expectError(GL_INVALID_ENUM);
433 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
434 ctx.glDrawArrays(GL_POINTS, 0, -1);
435 ctx.expectError(GL_INVALID_VALUE);
438 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
439 ctx.glGenFramebuffers(1, &fbo);
440 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
441 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
442 ctx.glDrawArrays(GL_POINTS, 0, 1);
443 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
444 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
445 ctx.glDeleteFramebuffers(1, &fbo);
449 void draw_arrays_incomplete_primitive (NegativeTestContext& ctx)
451 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
453 map<string, string> args;
454 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
455 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
457 ctx.glUseProgram(program.getProgram());
458 ctx.expectError(GL_NO_ERROR);
460 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
461 ctx.glDrawArrays(-1, 0, 1);
462 ctx.expectError(GL_INVALID_ENUM);
465 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
466 ctx.glDrawArrays(GL_TRIANGLES, 0, -1);
467 ctx.expectError(GL_INVALID_VALUE);
470 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
471 ctx.glGenFramebuffers(1, &fbo);
472 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
473 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
474 ctx.glDrawArrays(GL_TRIANGLES, 0, 1);
475 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
476 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
477 ctx.glDeleteFramebuffers(1, &fbo);
483 void draw_elements (NegativeTestContext& ctx)
485 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
490 map<string, string> args;
491 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
492 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
494 ctx.glUseProgram(program.getProgram());
495 ctx.expectError(GL_NO_ERROR);
497 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
498 ctx.glDrawElements(-1, 1, GL_UNSIGNED_BYTE, vertices);
499 ctx.expectError(GL_INVALID_ENUM);
502 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
503 ctx.glDrawElements(GL_POINTS, 1, -1, vertices);
504 ctx.expectError(GL_INVALID_ENUM);
505 ctx.glDrawElements(GL_POINTS, 1, GL_FLOAT, vertices);
506 ctx.expectError(GL_INVALID_ENUM);
509 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
510 ctx.glDrawElements(GL_POINTS, -1, GL_UNSIGNED_BYTE, vertices);
511 ctx.expectError(GL_INVALID_VALUE);
514 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
515 ctx.glGenFramebuffers(1, &fbo);
516 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
517 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
518 ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices);
519 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
520 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
521 ctx.glDeleteFramebuffers(1, &fbo);
524 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
526 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
527 const char* tfVarying = "gl_Position";
529 ctx.glGenBuffers(1, &buf);
530 ctx.glGenTransformFeedbacks(1, &tfID);
532 ctx.glUseProgram(program.getProgram());
533 ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
534 ctx.glLinkProgram(program.getProgram());
535 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
536 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
537 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
538 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
539 ctx.glBeginTransformFeedback(GL_POINTS);
540 ctx.expectError(GL_NO_ERROR);
542 ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices);
543 ctx.expectError(GL_INVALID_OPERATION);
545 ctx.glPauseTransformFeedback();
546 ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices);
547 ctx.expectError(GL_NO_ERROR);
549 ctx.glEndTransformFeedback();
550 ctx.glDeleteBuffers(1, &buf);
551 ctx.glDeleteTransformFeedbacks(1, &tfID);
552 ctx.expectError(GL_NO_ERROR);
559 void draw_elements_invalid_program (NegativeTestContext& ctx)
565 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
566 ctx.glDrawElements(-1, 1, GL_UNSIGNED_BYTE, vertices);
567 ctx.expectError(GL_INVALID_ENUM);
570 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
571 ctx.glDrawElements(GL_POINTS, 1, -1, vertices);
572 ctx.expectError(GL_INVALID_ENUM);
573 ctx.glDrawElements(GL_POINTS, 1, GL_FLOAT, vertices);
574 ctx.expectError(GL_INVALID_ENUM);
577 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
578 ctx.glDrawElements(GL_POINTS, -1, GL_UNSIGNED_BYTE, vertices);
579 ctx.expectError(GL_INVALID_VALUE);
582 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
583 ctx.glGenFramebuffers(1, &fbo);
584 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
585 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
586 ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices);
587 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
588 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
589 ctx.glDeleteFramebuffers(1, &fbo);
593 void draw_elements_incomplete_primitive (NegativeTestContext& ctx)
595 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
600 map<string, string> args;
601 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
602 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
604 ctx.glUseProgram(program.getProgram());
605 ctx.expectError(GL_NO_ERROR);
607 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
608 ctx.glDrawElements(-1, 1, GL_UNSIGNED_BYTE, vertices);
609 ctx.expectError(GL_INVALID_ENUM);
612 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
613 ctx.glDrawElements(GL_TRIANGLES, 1, -1, vertices);
614 ctx.expectError(GL_INVALID_ENUM);
615 ctx.glDrawElements(GL_TRIANGLES, 1, GL_FLOAT, vertices);
616 ctx.expectError(GL_INVALID_ENUM);
619 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
620 ctx.glDrawElements(GL_TRIANGLES, -1, GL_UNSIGNED_BYTE, vertices);
621 ctx.expectError(GL_INVALID_VALUE);
624 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
625 ctx.glGenFramebuffers(1, &fbo);
626 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
627 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
628 ctx.glDrawElements(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices);
629 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
630 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
631 ctx.glDeleteFramebuffers(1, &fbo);
634 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
636 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
637 const char* tfVarying= "gl_Position";
639 ctx.glGenBuffers(1, &buf);
640 ctx.glGenTransformFeedbacks(1, &tfID);
642 ctx.glUseProgram(program.getProgram());
643 ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
644 ctx.glLinkProgram(program.getProgram());
645 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
646 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
647 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
648 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
649 ctx.glBeginTransformFeedback(GL_TRIANGLES);
650 ctx.expectError(GL_NO_ERROR);
652 ctx.glDrawElements(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices);
653 ctx.expectError(GL_INVALID_OPERATION);
655 ctx.glPauseTransformFeedback();
656 ctx.glDrawElements(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices);
657 ctx.expectError(GL_NO_ERROR);
659 ctx.glEndTransformFeedback();
660 ctx.glDeleteBuffers(1, &buf);
661 ctx.glDeleteTransformFeedbacks(1, &tfID);
662 ctx.expectError(GL_NO_ERROR);
669 void draw_elements_base_vertex (NegativeTestContext& ctx)
671 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a 3.2 context or higher context version.");
676 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
677 ctx.glDrawElementsBaseVertex(-1, 1, GL_UNSIGNED_INT, vertices, 1);
678 ctx.expectError(GL_INVALID_ENUM);
681 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
682 ctx.glDrawElementsBaseVertex(GL_POINTS, 1, -1, vertices, 1);
683 ctx.expectError(GL_INVALID_ENUM);
684 ctx.glDrawElementsBaseVertex(GL_POINTS, 1, GL_FLOAT, vertices, 1);
685 ctx.expectError(GL_INVALID_ENUM);
688 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
689 ctx.glDrawElementsBaseVertex(GL_POINTS, -1, GL_UNSIGNED_INT, vertices, 1);
690 ctx.expectError(GL_INVALID_VALUE);
693 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
694 ctx.glGenFramebuffers(1, &fbo);
695 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
696 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
697 ctx.glDrawElementsBaseVertex(GL_POINTS, 1, GL_UNSIGNED_INT, vertices, 1);
698 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
699 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
700 ctx.glDeleteFramebuffers(1, &fbo);
704 void draw_elements_base_vertex_invalid_map (NegativeTestContext& ctx)
709 ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array or the element array and the buffer object's data store is currently mapped.");
710 ctx.glGenBuffers(1, &buf);
711 ctx.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf);
712 ctx.glBufferData(GL_ELEMENT_ARRAY_BUFFER, 10, 0, GL_STATIC_DRAW);
713 ctx.glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, 5, GL_MAP_READ_BIT);
714 ctx.expectError(GL_NO_ERROR);
715 ctx.glDrawElementsBaseVertex(GL_POINTS, 1, GL_UNSIGNED_INT, vertices, 1);
716 ctx.expectError(GL_INVALID_OPERATION);
717 ctx.glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
718 ctx.glDeleteBuffers(1, &buf);
722 void draw_elements_base_vertex_primitive_mode_mismatch (NegativeTestContext& ctx)
724 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a 3.2 context or higher context version.");
727 map<string, string> args;
728 args["GLSL_VERSION_STRING"] = getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES);
730 glu::ShaderProgram program(ctx.getRenderContext(), glu::ProgramSources() << glu::ProgramSeparable(true) << glu::VertexSource(tcu::StringTemplate(vertexShaderSource).specialize(args)) << glu::GeometrySource(geometryShaderSource));
732 ctx.beginSection("GL_INVALID_OPERATION is generated if a geometry shader is active and mode is incompatible with the input primitive type of the geometry shader in the currently installed program object.");
733 ctx.glUseProgram(program.getProgram());
734 ctx.glDrawElementsBaseVertex(GL_TRIANGLES, 1, GL_UNSIGNED_INT, vertices, 1);
735 ctx.expectError(GL_INVALID_OPERATION);
741 void draw_arrays_instanced (NegativeTestContext& ctx)
743 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
745 map<string, string> args;
746 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
747 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
749 ctx.glUseProgram(program.getProgram());
750 ctx.expectError(GL_NO_ERROR);
751 ctx.glVertexAttribDivisor(0, 1);
752 ctx.expectError(GL_NO_ERROR);
754 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
755 ctx.glDrawArraysInstanced(-1, 0, 1, 1);
756 ctx.expectError(GL_INVALID_ENUM);
759 ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
760 ctx.glDrawArraysInstanced(GL_POINTS, 0, -1, 1);
761 ctx.expectError(GL_INVALID_VALUE);
762 ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, -1);
763 ctx.expectError(GL_INVALID_VALUE);
766 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
767 ctx.glGenFramebuffers(1, &fbo);
768 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
769 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
770 ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, 1);
771 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
772 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
773 ctx.glDeleteFramebuffers(1, &fbo);
779 void draw_arrays_instanced_invalid_program (NegativeTestContext& ctx)
783 ctx.glVertexAttribDivisor(0, 1);
784 ctx.expectError(GL_NO_ERROR);
786 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
787 ctx.glDrawArraysInstanced(-1, 0, 1, 1);
788 ctx.expectError(GL_INVALID_ENUM);
791 ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
792 ctx.glDrawArraysInstanced(GL_POINTS, 0, -1, 1);
793 ctx.expectError(GL_INVALID_VALUE);
794 ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, -1);
795 ctx.expectError(GL_INVALID_VALUE);
798 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
799 ctx.glGenFramebuffers(1, &fbo);
800 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
801 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
802 ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, 1);
803 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
804 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
805 ctx.glDeleteFramebuffers(1, &fbo);
809 void draw_arrays_instanced_incomplete_primitive (NegativeTestContext& ctx)
811 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
813 map<string, string> args;
814 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
815 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
817 ctx.glVertexAttribDivisor(0, 1);
818 ctx.expectError(GL_NO_ERROR);
820 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
821 ctx.glDrawArraysInstanced(-1, 0, 1, 1);
822 ctx.expectError(GL_INVALID_ENUM);
825 ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
826 ctx.glDrawArraysInstanced(GL_TRIANGLES, 0, -1, 1);
827 ctx.expectError(GL_INVALID_VALUE);
828 ctx.glDrawArraysInstanced(GL_TRIANGLES, 0, 1, -1);
829 ctx.expectError(GL_INVALID_VALUE);
832 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
833 ctx.glGenFramebuffers(1, &fbo);
834 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
835 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
836 ctx.glDrawArraysInstanced(GL_TRIANGLES, 0, 1, 1);
837 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
838 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
839 ctx.glDeleteFramebuffers(1, &fbo);
845 void draw_elements_instanced (NegativeTestContext& ctx)
847 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
852 map<string, string> args;
853 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
854 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
856 ctx.glUseProgram(program.getProgram());
857 ctx.glVertexAttribDivisor(0, 1);
858 ctx.expectError(GL_NO_ERROR);
860 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
861 ctx.glDrawElementsInstanced(-1, 1, GL_UNSIGNED_BYTE, vertices, 1);
862 ctx.expectError(GL_INVALID_ENUM);
865 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
866 ctx.glDrawElementsInstanced(GL_POINTS, 1, -1, vertices, 1);
867 ctx.expectError(GL_INVALID_ENUM);
868 ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_FLOAT, vertices, 1);
869 ctx.expectError(GL_INVALID_ENUM);
872 ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
873 ctx.glDrawElementsInstanced(GL_POINTS, -1, GL_UNSIGNED_BYTE, vertices, 1);
874 ctx.expectError(GL_INVALID_VALUE);
875 ctx.glDrawElementsInstanced(GL_POINTS, 11, GL_UNSIGNED_BYTE, vertices, -1);
876 ctx.expectError(GL_INVALID_VALUE);
879 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
880 ctx.glGenFramebuffers(1, &fbo);
881 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
882 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
883 ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices, 1);
884 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
885 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
886 ctx.glDeleteFramebuffers(1, &fbo);
889 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
891 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
892 const char* tfVarying = "gl_Position";
894 ctx.glGenBuffers(1, &buf);
895 ctx.glGenTransformFeedbacks(1, &tfID);
897 ctx.glUseProgram(program.getProgram());
898 ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
899 ctx.glLinkProgram(program.getProgram());
900 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
901 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
902 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
903 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
904 ctx.glBeginTransformFeedback(GL_POINTS);
905 ctx.expectError(GL_NO_ERROR);
907 ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices, 1);
908 ctx.expectError(GL_INVALID_OPERATION);
910 ctx.glPauseTransformFeedback();
911 ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices, 1);
912 ctx.expectError(GL_NO_ERROR);
914 ctx.glEndTransformFeedback();
915 ctx.glDeleteBuffers(1, &buf);
916 ctx.glDeleteTransformFeedbacks(1, &tfID);
917 ctx.expectError(GL_NO_ERROR);
924 void draw_elements_instanced_invalid_program (NegativeTestContext& ctx)
929 ctx.glVertexAttribDivisor(0, 1);
930 ctx.expectError(GL_NO_ERROR);
932 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
933 ctx.glDrawElementsInstanced(-1, 1, GL_UNSIGNED_BYTE, vertices, 1);
934 ctx.expectError(GL_INVALID_ENUM);
937 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
938 ctx.glDrawElementsInstanced(GL_POINTS, 1, -1, vertices, 1);
939 ctx.expectError(GL_INVALID_ENUM);
940 ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_FLOAT, vertices, 1);
941 ctx.expectError(GL_INVALID_ENUM);
944 ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
945 ctx.glDrawElementsInstanced(GL_POINTS, -1, GL_UNSIGNED_BYTE, vertices, 1);
946 ctx.expectError(GL_INVALID_VALUE);
947 ctx.glDrawElementsInstanced(GL_POINTS, 11, GL_UNSIGNED_BYTE, vertices, -1);
948 ctx.expectError(GL_INVALID_VALUE);
951 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
952 ctx.glGenFramebuffers(1, &fbo);
953 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
954 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
955 ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices, 1);
956 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
957 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
958 ctx.glDeleteFramebuffers(1, &fbo);
962 void draw_elements_instanced_incomplete_primitive (NegativeTestContext& ctx)
964 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
969 map<string, string> args;
970 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
971 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
973 ctx.glUseProgram(program.getProgram());
974 ctx.glVertexAttribDivisor(0, 1);
975 ctx.expectError(GL_NO_ERROR);
977 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
978 ctx.glDrawElementsInstanced(-1, 1, GL_UNSIGNED_BYTE, vertices, 1);
979 ctx.expectError(GL_INVALID_ENUM);
982 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
983 ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, -1, vertices, 1);
984 ctx.expectError(GL_INVALID_ENUM);
985 ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, GL_FLOAT, vertices, 1);
986 ctx.expectError(GL_INVALID_ENUM);
989 ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
990 ctx.glDrawElementsInstanced(GL_TRIANGLES, -1, GL_UNSIGNED_BYTE, vertices, 1);
991 ctx.expectError(GL_INVALID_VALUE);
992 ctx.glDrawElementsInstanced(GL_TRIANGLES, 11, GL_UNSIGNED_BYTE, vertices, -1);
993 ctx.expectError(GL_INVALID_VALUE);
996 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
997 ctx.glGenFramebuffers(1, &fbo);
998 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
999 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1000 ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices, 1);
1001 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1002 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1003 ctx.glDeleteFramebuffers(1, &fbo);
1006 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
1008 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
1009 const char* tfVarying= "gl_Position";
1011 ctx.glGenBuffers(1, &buf);
1012 ctx.glGenTransformFeedbacks(1, &tfID);
1014 ctx.glUseProgram(program.getProgram());
1015 ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1016 ctx.glLinkProgram(program.getProgram());
1017 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
1018 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1019 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1020 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1021 ctx.glBeginTransformFeedback(GL_TRIANGLES);
1022 ctx.expectError(GL_NO_ERROR);
1024 ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices, 1);
1025 ctx.expectError(GL_INVALID_OPERATION);
1027 ctx.glPauseTransformFeedback();
1028 ctx.glDrawElementsInstanced (GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices, 1);
1029 ctx.expectError(GL_NO_ERROR);
1031 ctx.glEndTransformFeedback();
1032 ctx.glDeleteBuffers(1, &buf);
1033 ctx.glDeleteTransformFeedbacks(1, &tfID);
1034 ctx.expectError(GL_NO_ERROR);
1038 ctx.glUseProgram(0);
1041 void draw_elements_instanced_base_vertex (NegativeTestContext& ctx)
1043 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a 3.2 context or higher context version.");
1045 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
1047 GLfloat vertices[1];
1048 map<string, string> args;
1049 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
1050 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
1052 ctx.glUseProgram(program.getProgram());
1053 ctx.glVertexAttribDivisor(0, 1);
1054 ctx.expectError(GL_NO_ERROR);
1056 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1057 ctx.glDrawElementsInstancedBaseVertex(-1, 1, GL_UNSIGNED_BYTE, vertices, 1, 1);
1058 ctx.expectError(GL_INVALID_ENUM);
1061 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1062 ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, 1, -1, vertices, 1, 1);
1063 ctx.expectError(GL_INVALID_ENUM);
1064 ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, 1, GL_FLOAT, vertices, 1, 1);
1065 ctx.expectError(GL_INVALID_ENUM);
1068 ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
1069 ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, -1, GL_UNSIGNED_BYTE, vertices, 1, 1);
1070 ctx.expectError(GL_INVALID_VALUE);
1071 ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, 11, GL_UNSIGNED_BYTE, vertices, -1, 1);
1072 ctx.expectError(GL_INVALID_VALUE);
1075 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
1076 ctx.glGenFramebuffers(1, &fbo);
1077 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1078 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1079 ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices, 1, 1);
1080 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1081 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1082 ctx.glDeleteFramebuffers(1, &fbo);
1085 ctx.glUseProgram(0);
1088 void draw_elements_instanced_base_vertex_invalid_map (NegativeTestContext& ctx)
1090 GLfloat vertices[1];
1093 ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array or the element array and the buffer object's data store is currently mapped.");
1094 ctx.glGenBuffers(1, &buf);
1095 ctx.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf);
1096 ctx.glBufferData(GL_ELEMENT_ARRAY_BUFFER, 10, 0, GL_STATIC_DRAW);
1097 ctx.glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, 5, GL_MAP_READ_BIT);
1098 ctx.expectError(GL_NO_ERROR);
1099 ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, 1, GL_UNSIGNED_INT, vertices, 1, 1);
1100 ctx.expectError(GL_INVALID_OPERATION);
1101 ctx.glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
1102 ctx.glDeleteBuffers(1, &buf);
1107 void draw_elements_instanced_base_vertex_primitive_mode_mismatch (NegativeTestContext& ctx)
1109 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a 3.2 context or higher context version.");
1111 GLfloat vertices[1];
1112 map<string, string> args;
1113 args["GLSL_VERSION_STRING"] = getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES);
1114 glu::ShaderProgram geometryProgram(ctx.getRenderContext(), glu::ProgramSources() << glu::ProgramSeparable(true) << glu::VertexSource(tcu::StringTemplate(vertexShaderSource).specialize(args)) << glu::GeometrySource(geometryShaderSource));
1116 ctx.beginSection("GL_INVALID_OPERATION is generated if a geometry shader is active and mode is incompatible with the input primitive type of the geometry shader in the currently installed program object.");
1117 ctx.glUseProgram(geometryProgram.getProgram());
1118 ctx.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, 1, GL_UNSIGNED_INT, vertices, 1, 1);
1119 ctx.expectError(GL_INVALID_OPERATION);
1122 ctx.glUseProgram(0);
1125 void draw_range_elements (NegativeTestContext& ctx)
1127 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
1131 GLfloat vertices[1];
1132 map<string, string> args;
1133 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
1134 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
1136 ctx.glUseProgram(program.getProgram());
1137 ctx.expectError(GL_NO_ERROR);
1139 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1140 ctx.glDrawRangeElements(-1, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1141 ctx.expectError(GL_INVALID_ENUM);
1144 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1145 ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, -1, vertices);
1146 ctx.expectError(GL_INVALID_ENUM);
1147 ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_FLOAT, vertices);
1148 ctx.expectError(GL_INVALID_ENUM);
1151 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
1152 ctx.glDrawRangeElements(GL_POINTS, 0, 1, -1, GL_UNSIGNED_BYTE, vertices);
1153 ctx.expectError(GL_INVALID_VALUE);
1156 ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
1157 ctx.glDrawRangeElements(GL_POINTS, 1, 0, 1, GL_UNSIGNED_BYTE, vertices);
1158 ctx.expectError(GL_INVALID_VALUE);
1161 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
1162 ctx.glGenFramebuffers(1, &fbo);
1163 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1164 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1165 ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1166 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1167 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1168 ctx.glDeleteFramebuffers(1, &fbo);
1171 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
1173 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
1174 const char* tfVarying= "gl_Position";
1176 ctx.glGenBuffers(1, &buf);
1177 ctx.glGenTransformFeedbacks(1, &tfID);
1179 ctx.glUseProgram(program.getProgram());
1180 ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1181 ctx.glLinkProgram(program.getProgram());
1182 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
1183 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1184 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1185 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1186 ctx.glBeginTransformFeedback(GL_POINTS);
1187 ctx.expectError(GL_NO_ERROR);
1189 ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1190 ctx.expectError(GL_INVALID_OPERATION);
1192 ctx.glPauseTransformFeedback();
1193 ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1194 ctx.expectError(GL_NO_ERROR);
1196 ctx.glEndTransformFeedback();
1197 ctx.glDeleteBuffers(1, &buf);
1198 ctx.glDeleteTransformFeedbacks(1, &tfID);
1199 ctx.expectError(GL_NO_ERROR);
1203 ctx.glUseProgram(0);
1206 void draw_range_elements_invalid_program (NegativeTestContext& ctx)
1208 ctx.glUseProgram(0);
1210 GLfloat vertices[1];
1212 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1213 ctx.glDrawRangeElements(-1, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1214 ctx.expectError(GL_INVALID_ENUM);
1217 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1218 ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, -1, vertices);
1219 ctx.expectError(GL_INVALID_ENUM);
1220 ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_FLOAT, vertices);
1221 ctx.expectError(GL_INVALID_ENUM);
1224 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
1225 ctx.glDrawRangeElements(GL_POINTS, 0, 1, -1, GL_UNSIGNED_BYTE, vertices);
1226 ctx.expectError(GL_INVALID_VALUE);
1229 ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
1230 ctx.glDrawRangeElements(GL_POINTS, 1, 0, 1, GL_UNSIGNED_BYTE, vertices);
1231 ctx.expectError(GL_INVALID_VALUE);
1234 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
1235 ctx.glGenFramebuffers(1, &fbo);
1236 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1237 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1238 ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1239 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1240 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1241 ctx.glDeleteFramebuffers(1, &fbo);
1245 void draw_range_elements_incomplete_primitive (NegativeTestContext& ctx)
1247 const bool isES32 = glu::contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2));
1251 GLfloat vertices[1];
1252 map<string, string> args;
1253 args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) : getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
1254 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
1256 ctx.glUseProgram(program.getProgram());
1257 ctx.expectError(GL_NO_ERROR);
1259 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1260 ctx.glDrawRangeElements(-1, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1261 ctx.expectError(GL_INVALID_ENUM);
1264 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1265 ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, -1, vertices);
1266 ctx.expectError(GL_INVALID_ENUM);
1267 ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_FLOAT, vertices);
1268 ctx.expectError(GL_INVALID_ENUM);
1271 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
1272 ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, -1, GL_UNSIGNED_BYTE, vertices);
1273 ctx.expectError(GL_INVALID_VALUE);
1276 ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
1277 ctx.glDrawRangeElements(GL_TRIANGLES, 1, 0, 1, GL_UNSIGNED_BYTE, vertices);
1278 ctx.expectError(GL_INVALID_VALUE);
1281 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
1282 ctx.glGenFramebuffers(1, &fbo);
1283 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1284 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1285 ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1286 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1287 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1288 ctx.glDeleteFramebuffers(1, &fbo);
1291 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
1293 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
1294 const char* tfVarying = "gl_Position";
1296 ctx.glGenBuffers(1, &buf);
1297 ctx.glGenTransformFeedbacks(1, &tfID);
1299 ctx.glUseProgram(program.getProgram());
1300 ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1301 ctx.glLinkProgram(program.getProgram());
1302 ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
1303 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1304 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1305 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1306 ctx.glBeginTransformFeedback(GL_TRIANGLES);
1307 ctx.expectError(GL_NO_ERROR);
1309 ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1310 ctx.expectError(GL_INVALID_OPERATION);
1312 ctx.glPauseTransformFeedback();
1313 ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
1314 ctx.expectError(GL_NO_ERROR);
1316 ctx.glEndTransformFeedback();
1317 ctx.glDeleteBuffers(1, &buf);
1318 ctx.glDeleteTransformFeedbacks(1, &tfID);
1319 ctx.expectError(GL_NO_ERROR);
1323 ctx.glUseProgram(0);
1326 void draw_range_elements_base_vertex (NegativeTestContext& ctx)
1328 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a 3.2 context or higher context version.");
1331 GLfloat vertices[1];
1332 map<string, string> args;
1333 args["GLSL_VERSION_STRING"] = getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES);
1334 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args), tcu::StringTemplate(fragmentShaderSource).specialize(args)));
1336 ctx.glUseProgram(program.getProgram());
1337 ctx.expectError(GL_NO_ERROR);
1339 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1340 ctx.glDrawRangeElementsBaseVertex(-1, 0, 1, 1, GL_UNSIGNED_BYTE, vertices, 1);
1341 ctx.expectError(GL_INVALID_ENUM);
1344 ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1345 ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 0, 1, 1, -1, vertices, 1);
1346 ctx.expectError(GL_INVALID_ENUM);
1347 ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 0, 1, 1, GL_FLOAT, vertices, 1);
1348 ctx.expectError(GL_INVALID_ENUM);
1351 ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
1352 ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 0, 1, -1, GL_UNSIGNED_BYTE, vertices, 1);
1353 ctx.expectError(GL_INVALID_VALUE);
1356 ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
1357 ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 1, 0, 1, GL_UNSIGNED_BYTE, vertices, 1);
1358 ctx.expectError(GL_INVALID_VALUE);
1361 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
1362 ctx.glGenFramebuffers(1, &fbo);
1363 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1364 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1365 ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, vertices, 1);
1366 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1367 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1368 ctx.glDeleteFramebuffers(1, &fbo);
1371 ctx.glUseProgram(0);
1374 void draw_range_elements_base_vertex_invalid_map (NegativeTestContext& ctx)
1377 GLfloat vertices[1];
1379 ctx.beginSection("GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array or the element array and the buffer object's data store is currently mapped.");
1380 ctx.glGenBuffers(1, &buf);
1381 ctx.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf);
1382 ctx.glBufferData(GL_ELEMENT_ARRAY_BUFFER, 10, 0, GL_STATIC_DRAW);
1383 ctx.glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, 5, GL_MAP_READ_BIT);
1384 ctx.expectError(GL_NO_ERROR);
1385 ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 0, 1, 1, GL_UNSIGNED_INT, vertices, 1);
1386 ctx.expectError(GL_INVALID_OPERATION);
1387 ctx.glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
1388 ctx.glDeleteBuffers(1, &buf);
1392 void draw_range_elements_base_vertex_primitive_mode_mismatch (NegativeTestContext& ctx)
1394 TCU_CHECK_AND_THROW(NotSupportedError, contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)), "This test requires a 3.2 context or higher context version.");
1396 GLfloat vertices[1];
1397 map<string, string> args;
1398 args["GLSL_VERSION_STRING"] = getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES);
1399 glu::ShaderProgram geometryProgram(ctx.getRenderContext(), glu::ProgramSources() << glu::ProgramSeparable(true) << glu::VertexSource(tcu::StringTemplate(vertexShaderSource).specialize(args)) << glu::GeometrySource(geometryShaderSource));
1401 ctx.beginSection("GL_INVALID_OPERATION is generated if a geometry shader is active and mode is incompatible with the input primitive type of the geometry shader in the currently installed program object.");
1402 ctx.glUseProgram(geometryProgram.getProgram());
1403 ctx.glDrawRangeElementsBaseVertex(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_INT, vertices, 1);
1404 ctx.expectError(GL_INVALID_OPERATION);
1407 ctx.glUseProgram(0);
1410 std::vector<FunctionContainer> getNegativeVertexArrayApiTestFunctions ()
1412 FunctionContainer funcs[] =
1414 {vertex_attribf, "vertex_attribf", "Invalid glVertexAttrib{1234}f() usage" },
1415 {vertex_attribfv, "vertex_attribfv", "Invalid glVertexAttrib{1234}fv() usage" },
1416 {vertex_attribi4, "vertex_attribi4", "Invalid glVertexAttribI4{i|ui}f() usage" },
1417 {vertex_attribi4v, "vertex_attribi4v", "Invalid glVertexAttribI4{i|ui}fv() usage" },
1418 {vertex_attrib_pointer, "vertex_attrib_pointer", "Invalid glVertexAttribPointer() usage" },
1419 {vertex_attrib_i_pointer, "vertex_attrib_i_pointer", "Invalid glVertexAttribPointer() usage" },
1420 {vertex_attrib_format, "vertex_attrib_format", "Invalid glVertexAttribFormat() usage" },
1421 {vertex_attrib_i_format, "vertex_attrib_i_format", "Invalid glVertexAttribIFormat() usage" },
1422 {enable_vertex_attrib_array, "enable_vertex_attrib_array", "Invalid glEnableVertexAttribArray() usage" },
1423 {disable_vertex_attrib_array, "disable_vertex_attrib_array", "Invalid glDisableVertexAttribArray() usage" },
1424 {gen_vertex_arrays, "gen_vertex_arrays", "Invalid glGenVertexArrays() usage" },
1425 {bind_vertex_array, "bind_vertex_array", "Invalid glBindVertexArray() usage" },
1426 {delete_vertex_arrays, "delete_vertex_arrays", "Invalid glDeleteVertexArrays() usage" },
1427 {vertex_attrib_divisor, "vertex_attrib_divisor", "Invalid glVertexAttribDivisor() usage" },
1428 {draw_arrays, "draw_arrays", "Invalid glDrawArrays() usage" },
1429 {draw_arrays_invalid_program, "draw_arrays_invalid_program", "Invalid glDrawArrays() usage" },
1430 {draw_arrays_incomplete_primitive, "draw_arrays_incomplete_primitive", "Invalid glDrawArrays() usage" },
1431 {draw_elements, "draw_elements", "Invalid glDrawElements() usage" },
1432 {draw_elements_base_vertex, "draw_elements_base_vertex", "Invalid glDrawElementsBaseVertex() usage" },
1433 {draw_elements_base_vertex_invalid_map, "draw_elements_base_vertex_invalid_map" , "Invalid glDrawElementsBaseVertex() usage" },
1434 {draw_elements_base_vertex_primitive_mode_mismatch, "draw_elements_base_vertex_primitive_mode_mismatch", "Invalid glDrawElementsBaseVertex() usage" },
1435 {draw_elements_invalid_program, "draw_elements_invalid_program", "Invalid glDrawElements() usage" },
1436 {draw_elements_incomplete_primitive, "draw_elements_incomplete_primitive", "Invalid glDrawElements() usage" },
1437 {draw_arrays_instanced, "draw_arrays_instanced", "Invalid glDrawArraysInstanced() usage" },
1438 {draw_arrays_instanced_invalid_program, "draw_arrays_instanced_invalid_program", "Invalid glDrawArraysInstanced() usage" },
1439 {draw_arrays_instanced_incomplete_primitive, "draw_arrays_instanced_incomplete_primitive", "Invalid glDrawArraysInstanced() usage" },
1440 {draw_elements_instanced, "draw_elements_instanced", "Invalid glDrawElementsInstanced() usage" },
1441 {draw_elements_instanced_invalid_program, "draw_elements_instanced_invalid_program", "Invalid glDrawElementsInstanced() usage" },
1442 {draw_elements_instanced_incomplete_primitive, "draw_elements_instanced_incomplete_primitive", "Invalid glDrawElementsInstanced() usage" },
1443 {draw_elements_instanced_base_vertex, "draw_elements_instanced_base_vertex", "Invalid glDrawElementsInstancedBaseVertex() usage" },
1444 {draw_elements_instanced_base_vertex_invalid_map, "draw_elements_instanced_base_vertex_invalid_map", "Invalid glDrawElementsInstancedBaseVertex() usage" },
1445 {draw_elements_instanced_base_vertex_primitive_mode_mismatch, "draw_elements_instanced_base_vertex_primitive_mode_mismatch", "Invalid glDrawElementsInstancedBaseVertex() usage" },
1446 {draw_range_elements, "draw_range_elements", "Invalid glDrawRangeElements() usage" },
1447 {draw_range_elements_invalid_program, "draw_range_elements_invalid_program", "Invalid glDrawRangeElements() usage" },
1448 {draw_range_elements_incomplete_primitive, "draw_range_elements_incomplete_primitive", "Invalid glDrawRangeElements() usage" },
1449 {draw_range_elements_base_vertex, "draw_range_elements_base_vertex", "Invalid glDrawRangeElementsBaseVertex() usage" },
1450 {draw_range_elements_base_vertex_invalid_map, "draw_range_elements_base_vertex_invalid_map", "Invalid glDrawRangeElementsBaseVertex() usage" },
1451 {draw_range_elements_base_vertex_primitive_mode_mismatch, "draw_range_elements_base_vertex_primitive_mode_mismatch", "Invalid glDrawRangeElementsBaseVertex() usage" },
1454 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
1457 } // NegativeTestShared