13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Negative Vertex Array API tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31fNegativeVertexArrayApiTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp"
27271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry#include "gluContextInfo.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwDefs.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace NegativeTestShared
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing glu::CallLogWrapper;
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw;
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* vertexShaderSource		=	"#version 300 es\n"
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	gl_Position = vec4(0.0);\n"
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n\0";
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* fragmentShaderSource		=	"#version 300 es\n"
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"layout(location = 0) out mediump vec4 fragColor;"
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"void main (void)\n"
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"{\n"
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"	fragColor = vec4(0.0);\n"
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry												"}\n\0";
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid vertex_attribf (NegativeTestContext& ctx)
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttrib1f(maxVertexAttribs, 0.0f);
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttrib2f(maxVertexAttribs, 0.0f, 0.0f);
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttrib3f(maxVertexAttribs, 0.0f, 0.0f, 0.0f);
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttrib4f(maxVertexAttribs, 0.0f, 0.0f, 0.0f, 0.0f);
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid vertex_attribfv (NegativeTestContext& ctx)
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	float v[4] = {0.0f};
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttrib1fv(maxVertexAttribs, &v[0]);
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttrib2fv(maxVertexAttribs, &v[0]);
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttrib3fv(maxVertexAttribs, &v[0]);
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttrib4fv(maxVertexAttribs, &v[0]);
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid vertex_attribi4 (NegativeTestContext& ctx)
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxVertexAttribs	= ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint valInt			= 0;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint valUint			= 0;
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribI4i(maxVertexAttribs, valInt, valInt, valInt, valInt);
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribI4ui(maxVertexAttribs, valUint, valUint, valUint, valUint);
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid vertex_attribi4v (NegativeTestContext& ctx)
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxVertexAttribs	= ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLint valInt[4]			= { 0 };
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint valUint[4]		= { 0 };
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribI4iv(maxVertexAttribs, &valInt[0]);
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribI4uiv(maxVertexAttribs, &valUint[0]);
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid vertex_attrib_pointer (NegativeTestContext& ctx)
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not an accepted value.");
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribPointer(0, 1, 0, GL_TRUE, 0, 0);
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribPointer(maxVertexAttribs, 1, GL_BYTE, GL_TRUE, 0, 0);
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if size is not 1, 2, 3, or 4.");
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribPointer(0, 0, GL_BYTE, GL_TRUE, 0, 0);
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if stride is negative.");
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribPointer(0, 1, GL_BYTE, GL_TRUE, -1, 0);
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribPointer(0, 2, GL_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribPointer(0, 2, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribPointer(0, 4, GL_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribPointer(0, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint vao = 0;
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLbyte offset = 1;
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenVertexArrays(1, &vao);
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindVertexArray(vao);
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribPointer(0, 1, GL_BYTE, GL_TRUE, 0, &offset);
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindVertexArray(0);
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteVertexArrays(1, &vao);
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid vertex_attrib_i_pointer (NegativeTestContext& ctx)
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not an accepted value.");
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribIPointer(0, 1, 0, 0, 0);
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribIPointer(0, 4, GL_INT_2_10_10_10_REV, 0, 0);
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribIPointer(0, 4, GL_UNSIGNED_INT_2_10_10_10_REV, 0, 0);
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribIPointer(maxVertexAttribs, 1, GL_BYTE, 0, 0);
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if size is not 1, 2, 3, or 4.");
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribIPointer(0, 0, GL_BYTE, 0, 0);
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if stride is negative.");
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribIPointer(0, 1, GL_BYTE, -1, 0);
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	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.");
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint vao = 0;
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLbyte offset = 1;
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenVertexArrays(1, &vao);
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindVertexArray(vao);
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribIPointer(0, 1, GL_BYTE, 0, &offset);
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindVertexArray(0);
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteVertexArrays(1, &vao);
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid enable_vertex_attrib_array (NegativeTestContext& ctx)
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glEnableVertexAttribArray(maxVertexAttribs);
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid disable_vertex_attrib_array (NegativeTestContext& ctx)
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDisableVertexAttribArray(maxVertexAttribs);
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid gen_vertex_arrays (NegativeTestContext& ctx)
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint arrays = 0;
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenVertexArrays(-1, &arrays);
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid bind_vertex_array (NegativeTestContext& ctx)
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_OPERATION is generated if array is not zero or the name of an existing vertex array object.");
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindVertexArray(-1);
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_OPERATION);
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid delete_vertex_arrays (NegativeTestContext& ctx)
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteVertexArrays(-1, 0);
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid vertex_attrib_divisor (NegativeTestContext& ctx)
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribDivisor(maxVertexAttribs, 0);
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_arrays (NegativeTestContext& ctx)
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArrays(-1, 0, 1);
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArrays(GL_POINTS, 0, -1);
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArrays(GL_POINTS, 0, 1);
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_arrays_invalid_program (NegativeTestContext& ctx)
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArrays(-1, 0, 1);
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArrays(GL_POINTS, 0, -1);
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArrays(GL_POINTS, 0, 1);
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_arrays_incomplete_primitive (NegativeTestContext& ctx)
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArrays(-1, 0, 1);
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArrays(GL_TRIANGLES, 0, -1);
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArrays(GL_TRIANGLES, 0, 1);
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_elements (NegativeTestContext& ctx)
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint buf = 0;
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint tfID = 0;
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat vertices[1];
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(-1, 1, GL_UNSIGNED_BYTE, vertices);
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_POINTS, 1, -1, vertices);
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_POINTS, 1, GL_FLOAT, vertices);
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_POINTS, -1, GL_UNSIGNED_BYTE, vertices);
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices);
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
385271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
386271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	{
387271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
388271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		const char* tfVarying		= "gl_Position";
389271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
390271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenBuffers				(1, &buf);
391271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenTransformFeedbacks		(1, &tfID);
392271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
393271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glUseProgram				(program.getProgram());
394271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
395271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glLinkProgram				(program.getProgram());
396271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
397271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
398271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
399271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
400271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBeginTransformFeedback	(GL_POINTS);
401271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_NO_ERROR);
402271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
403271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawElements				(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices);
404271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_INVALID_OPERATION);
405271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
406271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glPauseTransformFeedback();
407271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawElements				(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices);
408271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_NO_ERROR);
409271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
410271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glEndTransformFeedback		();
411271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteBuffers				(1, &buf);
412271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteTransformFeedbacks	(1, &tfID);
413271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_NO_ERROR);
414271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.endSection();
415271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	}
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_elements_invalid_program (NegativeTestContext& ctx)
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat vertices[1];
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(-1, 1, GL_UNSIGNED_BYTE, vertices);
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_POINTS, 1, -1, vertices);
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_POINTS, 1, GL_FLOAT, vertices);
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_POINTS, -1, GL_UNSIGNED_BYTE, vertices);
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices);
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_elements_incomplete_primitive (NegativeTestContext& ctx)
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint buf = 0;
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint tfID = 0;
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat vertices[1];
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(-1, 1, GL_UNSIGNED_BYTE, vertices);
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_TRIANGLES, 1, -1, vertices);
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_TRIANGLES, 1, GL_FLOAT, vertices);
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_TRIANGLES, -1, GL_UNSIGNED_BYTE, vertices);
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElements(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices);
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
490271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
491271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	{
492271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
493271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		const char* tfVarying		= "gl_Position";
494271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
495271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenBuffers				(1, &buf);
496271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenTransformFeedbacks		(1, &tfID);
497271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
498271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glUseProgram				(program.getProgram());
499271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
500271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glLinkProgram				(program.getProgram());
501271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
502271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
503271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
504271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
505271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBeginTransformFeedback	(GL_TRIANGLES);
506271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_NO_ERROR);
507271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
508271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawElements				(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices);
509271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_INVALID_OPERATION);
510271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
511271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glPauseTransformFeedback	();
512271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawElements				(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices);
513271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_NO_ERROR);
514271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
515271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glEndTransformFeedback		();
516271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteBuffers				(1, &buf);
517271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteTransformFeedbacks	(1, &tfID);
518271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_NO_ERROR);
519271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.endSection					();
520271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	}
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_arrays_instanced (NegativeTestContext& ctx)
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribDivisor(0, 1);
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(-1, 0, 1, 1);
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(GL_POINTS, 0, -1, 1);
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, -1);
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, 1);
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_arrays_instanced_invalid_program (NegativeTestContext& ctx)
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribDivisor(0, 1);
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(-1, 0, 1, 1);
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(GL_POINTS, 0, -1, 1);
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, -1);
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, 1);
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_arrays_instanced_incomplete_primitive (NegativeTestContext& ctx)
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribDivisor(0, 1);
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(-1, 0, 1, 1);
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(GL_TRIANGLES, 0, -1, 1);
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(GL_TRIANGLES, 0, 1, -1);
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawArraysInstanced(GL_TRIANGLES, 0, 1, 1);
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_elements_instanced (NegativeTestContext& ctx)
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint buf = 0;
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint tfID = 0;
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat vertices[1];
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribDivisor(0, 1);
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(-1, 1, GL_UNSIGNED_BYTE, vertices, 1);
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, 1, -1, vertices, 1);
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_FLOAT, vertices, 1);
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, -1, GL_UNSIGNED_BYTE, vertices, 1);
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, 11, GL_UNSIGNED_BYTE, vertices, -1);
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices, 1);
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
661271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
662271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	{
663271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
664271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		const char* tfVarying		= "gl_Position";
665271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
666271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenBuffers				(1, &buf);
667271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenTransformFeedbacks		(1, &tfID);
668271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
669271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glUseProgram				(program.getProgram());
670271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
671271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glLinkProgram				(program.getProgram());
672271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
673271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
674271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
675271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
676271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBeginTransformFeedback	(GL_POINTS);
677271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_NO_ERROR);
678271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
679271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawElementsInstanced		(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices, 1);
680271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_INVALID_OPERATION);
681271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
682271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glPauseTransformFeedback();
683271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawElementsInstanced		(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices, 1);
684271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_NO_ERROR);
685271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
686271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glEndTransformFeedback		();
687271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteBuffers				(1, &buf);
688271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteTransformFeedbacks	(1, &tfID);
689271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_NO_ERROR);
690271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.endSection();
691271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	}
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_elements_instanced_invalid_program (NegativeTestContext& ctx)
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat vertices[1];
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribDivisor(0, 1);
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(-1, 1, GL_UNSIGNED_BYTE, vertices, 1);
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, 1, -1, vertices, 1);
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_FLOAT, vertices, 1);
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, -1, GL_UNSIGNED_BYTE, vertices, 1);
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, 11, GL_UNSIGNED_BYTE, vertices, -1);
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, vertices, 1);
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_elements_instanced_incomplete_primitive (NegativeTestContext& ctx)
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint buf = 0;
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint tfID = 0;
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat vertices[1];
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glVertexAttribDivisor(0, 1);
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_NO_ERROR);
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(-1, 1, GL_UNSIGNED_BYTE, vertices, 1);
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, -1, vertices, 1);
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, GL_FLOAT, vertices, 1);
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_TRIANGLES, -1, GL_UNSIGNED_BYTE, vertices, 1);
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_TRIANGLES, 11, GL_UNSIGNED_BYTE, vertices, -1);
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices, 1);
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
774271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
775271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	{
776271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
777271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		const char* tfVarying		= "gl_Position";
778271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
779271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenBuffers				(1, &buf);
780271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenTransformFeedbacks		(1, &tfID);
781271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
782271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glUseProgram				(program.getProgram());
783271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
784271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glLinkProgram				(program.getProgram());
785271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
786271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
787271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
788271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
789271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBeginTransformFeedback	(GL_TRIANGLES);
790271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_NO_ERROR);
791271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
792271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawElementsInstanced		(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices, 1);
793271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_INVALID_OPERATION);
794271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
795271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glPauseTransformFeedback();
796271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawElementsInstanced		(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, vertices, 1);
797271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_NO_ERROR);
798271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
799271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glEndTransformFeedback		();
800271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteBuffers				(1, &buf);
801271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteTransformFeedbacks	(1, &tfID);
802271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_NO_ERROR);
803271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.endSection();
804271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	}
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_range_elements (NegativeTestContext& ctx)
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint buf = 0;
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint tfID = 0;
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat vertices[1];
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(-1, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, -1, vertices);
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_FLOAT, vertices);
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 0, 1, -1, GL_UNSIGNED_BYTE, vertices);
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 1, 0, 1, GL_UNSIGNED_BYTE, vertices);
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
850271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
851271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	{
852271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
853271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		const char* tfVarying		= "gl_Position";
854271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
855271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenBuffers				(1, &buf);
856271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenTransformFeedbacks		(1, &tfID);
857271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
858271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glUseProgram				(program.getProgram());
859271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
860271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glLinkProgram				(program.getProgram());
861271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
862271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
863271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
864271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
865271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBeginTransformFeedback	(GL_POINTS);
866271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_NO_ERROR);
867271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
868271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawRangeElements			(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
869271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_INVALID_OPERATION);
870271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
871271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glPauseTransformFeedback();
872271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawRangeElements			(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
873271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_NO_ERROR);
874271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
875271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glEndTransformFeedback		();
876271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteBuffers				(1, &buf);
877271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteTransformFeedbacks	(1, &tfID);
878271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError					(GL_NO_ERROR);
879271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.endSection();
880271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	}
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_range_elements_invalid_program (NegativeTestContext& ctx)
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat vertices[1];
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(-1, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, -1, vertices);
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_FLOAT, vertices);
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 0, 1, -1, GL_UNSIGNED_BYTE, vertices);
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 1, 0, 1, GL_UNSIGNED_BYTE, vertices);
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid draw_range_elements_incomplete_primitive (NegativeTestContext& ctx)
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource));
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(program.getProgram());
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint fbo = 0;
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint buf = 0;
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLuint tfID = 0;
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLfloat vertices[1];
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(-1, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, -1, vertices);
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_FLOAT, vertices);
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_ENUM);
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, -1, GL_UNSIGNED_BYTE, vertices);
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_TRIANGLES, 1, 0, 1, GL_UNSIGNED_BYTE, vertices);
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_VALUE);
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glGenFramebuffers(1, &fbo);
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glDeleteFramebuffers(1, &fbo);
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.endSection();
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
965271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
966271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	{
967271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
968271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		const char* tfVarying		= "gl_Position";
969271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
970271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenBuffers				(1, &buf);
971271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glGenTransformFeedbacks		(1, &tfID);
972271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
973271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glUseProgram				(program.getProgram());
974271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glTransformFeedbackVaryings	(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
975271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glLinkProgram				(program.getProgram());
976271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindTransformFeedback		(GL_TRANSFORM_FEEDBACK, tfID);
977271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBuffer				(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
978271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBufferData				(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
979271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBindBufferBase			(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
980271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glBeginTransformFeedback	(GL_TRIANGLES);
981271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_NO_ERROR);
982271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
983271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawRangeElements			(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
984271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_INVALID_OPERATION);
985271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
986271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glPauseTransformFeedback();
987271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDrawRangeElements			(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_BYTE, vertices);
988271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_NO_ERROR);
989271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry
990271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glEndTransformFeedback		();
991271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteBuffers				(1, &buf);
992271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.glDeleteTransformFeedbacks	(1, &tfID);
993271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.expectError				(GL_NO_ERROR);
994271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry		ctx.endSection();
995271c2654cc44f23492888c7ef40c36c2fd810c77Jarkko Pöyry	}
9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ctx.glUseProgram(0);
9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::vector<FunctionContainer> getNegativeVertexArrayApiTestFunctions ()
10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	FunctionContainer funcs[] =
10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{vertex_attribf,								"vertex_attribf",								"Invalid glVertexAttrib{1234}f() usage"		},
10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{vertex_attribfv,								"vertex_attribfv",								"Invalid glVertexAttrib{1234}fv() usage"	},
10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{vertex_attribi4,								"vertex_attribi4",								"Invalid glVertexAttribI4{i|ui}f() usage"	},
10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{vertex_attribi4v,								"vertex_attribi4v",								"Invalid glVertexAttribI4{i|ui}fv() usage"	},
10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{vertex_attrib_pointer,							"vertex_attrib_pointer",						"Invalid glVertexAttribPointer() usage"		},
10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{vertex_attrib_i_pointer,						"vertex_attrib_i_pointer",						"Invalid glVertexAttribPointer() usage"		},
10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{enable_vertex_attrib_array,					"enable_vertex_attrib_array",					"Invalid glEnableVertexAttribArray() usage"	},
10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{disable_vertex_attrib_array,					"disable_vertex_attrib_array",					"Invalid glDisableVertexAttribArray() usage"},
10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{gen_vertex_arrays,								"gen_vertex_arrays",							"Invalid glGenVertexArrays() usage"			},
10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{bind_vertex_array,								"bind_vertex_array",							"Invalid glBindVertexArray() usage"			},
10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{delete_vertex_arrays,							"delete_vertex_arrays",							"Invalid glDeleteVertexArrays() usage"		},
10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{vertex_attrib_divisor,							"vertex_attrib_divisor",						"Invalid glVertexAttribDivisor() usage"		},
10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_arrays,									"draw_arrays",									"Invalid glDrawArrays() usage"				},
10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_arrays_invalid_program,					"draw_arrays_invalid_program",					"Invalid glDrawArrays() usage"				},
10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_arrays_incomplete_primitive,				"draw_arrays_incomplete_primitive",				"Invalid glDrawArrays() usage"				},
10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_elements,									"draw_elements",								"Invalid glDrawElements() usage"			},
10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_elements_invalid_program,					"draw_elements_invalid_program",				"Invalid glDrawElements() usage"			},
10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_elements_incomplete_primitive,			"draw_elements_incomplete_primitive",			"Invalid glDrawElements() usage"			},
10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_arrays_instanced,							"draw_arrays_instanced",						"Invalid glDrawArraysInstanced() usage"		},
10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_arrays_instanced_invalid_program,			"draw_arrays_instanced_invalid_program",		"Invalid glDrawArraysInstanced() usage"		},
10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_arrays_instanced_incomplete_primitive,	"draw_arrays_instanced_incomplete_primitive",	"Invalid glDrawArraysInstanced() usage"		},
10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_elements_instanced,						"draw_elements_instanced",						"Invalid glDrawElementsInstanced() usage"	},
10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_elements_instanced_invalid_program,		"draw_elements_instanced_invalid_program",		"Invalid glDrawElementsInstanced() usage"	},
10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_elements_instanced_incomplete_primitive,	"draw_elements_instanced_incomplete_primitive",	"Invalid glDrawElementsInstanced() usage"	},
10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_range_elements,							"draw_range_elements",							"Invalid glDrawRangeElements() usage"		},
10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_range_elements_invalid_program,			"draw_range_elements_invalid_program",			"Invalid glDrawRangeElements() usage"		},
10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{draw_range_elements_incomplete_primitive,		"draw_range_elements_incomplete_primitive",		"Invalid glDrawRangeElements() usage"		},
10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // NegativeTestShared
10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31
10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
1040