xref: /aosp_15_r20/external/deqp/modules/gles31/functional/es31fNegativeVertexArrayApiTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.1 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Negative Vertex Array API tests.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "es31fNegativeVertexArrayApiTests.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "gluCallLogWrapper.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "gluContextInfo.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "gluShaderProgram.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "glwDefs.hpp"
29*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
30*35238bceSAndroid Build Coastguard Worker #include "tcuStringTemplate.hpp"
31*35238bceSAndroid Build Coastguard Worker 
32*35238bceSAndroid Build Coastguard Worker namespace deqp
33*35238bceSAndroid Build Coastguard Worker {
34*35238bceSAndroid Build Coastguard Worker 
35*35238bceSAndroid Build Coastguard Worker using std::map;
36*35238bceSAndroid Build Coastguard Worker using std::string;
37*35238bceSAndroid Build Coastguard Worker 
38*35238bceSAndroid Build Coastguard Worker namespace gles31
39*35238bceSAndroid Build Coastguard Worker {
40*35238bceSAndroid Build Coastguard Worker namespace Functional
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker namespace NegativeTestShared
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker 
45*35238bceSAndroid Build Coastguard Worker using glu::CallLogWrapper;
46*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
47*35238bceSAndroid Build Coastguard Worker using namespace glw;
48*35238bceSAndroid Build Coastguard Worker 
49*35238bceSAndroid Build Coastguard Worker static const char *vertexShaderSource = "${GLSL_VERSION_STRING}\n"
50*35238bceSAndroid Build Coastguard Worker                                         "void main (void)\n"
51*35238bceSAndroid Build Coastguard Worker                                         "{\n"
52*35238bceSAndroid Build Coastguard Worker                                         "    gl_Position = vec4(0.0);\n"
53*35238bceSAndroid Build Coastguard Worker                                         "}\n\0";
54*35238bceSAndroid Build Coastguard Worker 
55*35238bceSAndroid Build Coastguard Worker static const char *fragmentShaderSource = "${GLSL_VERSION_STRING}\n"
56*35238bceSAndroid Build Coastguard Worker                                           "layout(location = 0) out mediump vec4 fragColor;"
57*35238bceSAndroid Build Coastguard Worker                                           "void main (void)\n"
58*35238bceSAndroid Build Coastguard Worker                                           "{\n"
59*35238bceSAndroid Build Coastguard Worker                                           "    fragColor = vec4(0.0);\n"
60*35238bceSAndroid Build Coastguard Worker                                           "}\n\0";
61*35238bceSAndroid Build Coastguard Worker 
62*35238bceSAndroid Build Coastguard Worker static const char *geometryShaderSource = "#version 320 es\n"
63*35238bceSAndroid Build Coastguard Worker                                           "layout(points) in;\n"
64*35238bceSAndroid Build Coastguard Worker                                           "layout(points, max_vertices = 3) out;\n"
65*35238bceSAndroid Build Coastguard Worker                                           "void main (void)\n"
66*35238bceSAndroid Build Coastguard Worker                                           "{\n"
67*35238bceSAndroid Build Coastguard Worker                                           "}\n";
68*35238bceSAndroid Build Coastguard Worker 
69*35238bceSAndroid Build Coastguard Worker // Helper class that enables tests to be executed on GL4.5 context
70*35238bceSAndroid Build Coastguard Worker // and removes code redundancy in each test that requires it.
71*35238bceSAndroid Build Coastguard Worker class VAOHelper
72*35238bceSAndroid Build Coastguard Worker {
73*35238bceSAndroid Build Coastguard Worker public:
VAOHelper(NegativeTestContext & ctx,bool isES)74*35238bceSAndroid Build Coastguard Worker     VAOHelper(NegativeTestContext &ctx, bool isES) : m_vao(0), m_ctx(ctx)
75*35238bceSAndroid Build Coastguard Worker     {
76*35238bceSAndroid Build Coastguard Worker         // tests need vao only for GL4.5 context
77*35238bceSAndroid Build Coastguard Worker         if (isES)
78*35238bceSAndroid Build Coastguard Worker             return;
79*35238bceSAndroid Build Coastguard Worker 
80*35238bceSAndroid Build Coastguard Worker         m_ctx.glGenVertexArrays(1, &m_vao);
81*35238bceSAndroid Build Coastguard Worker         m_ctx.glBindVertexArray(m_vao);
82*35238bceSAndroid Build Coastguard Worker         m_ctx.glVertexAttribPointer(0, 1, GL_BYTE, GL_TRUE, 0, NULL);
83*35238bceSAndroid Build Coastguard Worker         m_ctx.glEnableVertexAttribArray(0);
84*35238bceSAndroid Build Coastguard Worker     }
85*35238bceSAndroid Build Coastguard Worker 
~VAOHelper()86*35238bceSAndroid Build Coastguard Worker     ~VAOHelper()
87*35238bceSAndroid Build Coastguard Worker     {
88*35238bceSAndroid Build Coastguard Worker         if (m_vao)
89*35238bceSAndroid Build Coastguard Worker             m_ctx.glDeleteVertexArrays(1, &m_vao);
90*35238bceSAndroid Build Coastguard Worker     }
91*35238bceSAndroid Build Coastguard Worker 
92*35238bceSAndroid Build Coastguard Worker private:
93*35238bceSAndroid Build Coastguard Worker     GLuint m_vao;
94*35238bceSAndroid Build Coastguard Worker     NegativeTestContext &m_ctx;
95*35238bceSAndroid Build Coastguard Worker };
96*35238bceSAndroid Build Coastguard Worker 
vertex_attribf(NegativeTestContext & ctx)97*35238bceSAndroid Build Coastguard Worker void vertex_attribf(NegativeTestContext &ctx)
98*35238bceSAndroid Build Coastguard Worker {
99*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
100*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
101*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttrib1f(maxVertexAttribs, 0.0f);
102*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
103*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttrib2f(maxVertexAttribs, 0.0f, 0.0f);
104*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
105*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttrib3f(maxVertexAttribs, 0.0f, 0.0f, 0.0f);
106*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
107*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttrib4f(maxVertexAttribs, 0.0f, 0.0f, 0.0f, 0.0f);
108*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
109*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
110*35238bceSAndroid Build Coastguard Worker }
111*35238bceSAndroid Build Coastguard Worker 
vertex_attribfv(NegativeTestContext & ctx)112*35238bceSAndroid Build Coastguard Worker void vertex_attribfv(NegativeTestContext &ctx)
113*35238bceSAndroid Build Coastguard Worker {
114*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
115*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
116*35238bceSAndroid Build Coastguard Worker     float v[4]           = {0.0f};
117*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttrib1fv(maxVertexAttribs, &v[0]);
118*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
119*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttrib2fv(maxVertexAttribs, &v[0]);
120*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
121*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttrib3fv(maxVertexAttribs, &v[0]);
122*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
123*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttrib4fv(maxVertexAttribs, &v[0]);
124*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
125*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
126*35238bceSAndroid Build Coastguard Worker }
127*35238bceSAndroid Build Coastguard Worker 
vertex_attribi4(NegativeTestContext & ctx)128*35238bceSAndroid Build Coastguard Worker void vertex_attribi4(NegativeTestContext &ctx)
129*35238bceSAndroid Build Coastguard Worker {
130*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
131*35238bceSAndroid Build Coastguard Worker     GLint valInt         = 0;
132*35238bceSAndroid Build Coastguard Worker     GLuint valUint       = 0;
133*35238bceSAndroid Build Coastguard Worker 
134*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
135*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribI4i(maxVertexAttribs, valInt, valInt, valInt, valInt);
136*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
137*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribI4ui(maxVertexAttribs, valUint, valUint, valUint, valUint);
138*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
139*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
140*35238bceSAndroid Build Coastguard Worker }
141*35238bceSAndroid Build Coastguard Worker 
vertex_attribi4v(NegativeTestContext & ctx)142*35238bceSAndroid Build Coastguard Worker void vertex_attribi4v(NegativeTestContext &ctx)
143*35238bceSAndroid Build Coastguard Worker {
144*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
145*35238bceSAndroid Build Coastguard Worker     GLint valInt[4]      = {0};
146*35238bceSAndroid Build Coastguard Worker     GLuint valUint[4]    = {0};
147*35238bceSAndroid Build Coastguard Worker 
148*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
149*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribI4iv(maxVertexAttribs, &valInt[0]);
150*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
151*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribI4uiv(maxVertexAttribs, &valUint[0]);
152*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
153*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
154*35238bceSAndroid Build Coastguard Worker }
155*35238bceSAndroid Build Coastguard Worker 
vertex_attrib_pointer(NegativeTestContext & ctx)156*35238bceSAndroid Build Coastguard Worker void vertex_attrib_pointer(NegativeTestContext &ctx)
157*35238bceSAndroid Build Coastguard Worker {
158*35238bceSAndroid Build Coastguard Worker     GLuint vao = 0;
159*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
160*35238bceSAndroid Build Coastguard Worker     if (glu::isContextTypeES(ctx.getRenderContext().getType()))
161*35238bceSAndroid Build Coastguard Worker         ctx.glBindVertexArray(0);
162*35238bceSAndroid Build Coastguard Worker     else
163*35238bceSAndroid Build Coastguard Worker         ctx.glBindVertexArray(vao);
164*35238bceSAndroid Build Coastguard Worker 
165*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not an accepted value.");
166*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribPointer(0, 1, 0, GL_TRUE, 0, 0);
167*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
168*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
169*35238bceSAndroid Build Coastguard Worker 
170*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
171*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
172*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribPointer(maxVertexAttribs, 1, GL_BYTE, GL_TRUE, 0, 0);
173*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
174*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
175*35238bceSAndroid Build Coastguard Worker 
176*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if size is not 1, 2, 3, or 4.");
177*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribPointer(0, 0, GL_BYTE, GL_TRUE, 0, 0);
178*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
179*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
180*35238bceSAndroid Build Coastguard Worker 
181*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if stride is negative.");
182*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribPointer(0, 1, GL_BYTE, GL_TRUE, -1, 0);
183*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
184*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
185*35238bceSAndroid Build Coastguard Worker 
186*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated if type is GL_INT_2_10_10_10_REV or "
187*35238bceSAndroid Build Coastguard Worker                      "GL_UNSIGNED_INT_2_10_10_10_REV and size is not 4.");
188*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribPointer(0, 2, GL_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
189*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
190*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribPointer(0, 2, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
191*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
192*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribPointer(0, 4, GL_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
193*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
194*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribPointer(0, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0, 0);
195*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
196*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
197*35238bceSAndroid Build Coastguard Worker 
198*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated a non-zero vertex array object is bound, zero is bound to the "
199*35238bceSAndroid Build Coastguard Worker                      "GL_ARRAY_BUFFER buffer object binding point and the pointer argument is not NULL.");
200*35238bceSAndroid Build Coastguard Worker     GLbyte offset = 1;
201*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
202*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
203*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
204*35238bceSAndroid Build Coastguard Worker 
205*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribPointer(0, 1, GL_BYTE, GL_TRUE, 0, &offset);
206*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
207*35238bceSAndroid Build Coastguard Worker 
208*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(0);
209*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteVertexArrays(1, &vao);
210*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
211*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
212*35238bceSAndroid Build Coastguard Worker }
213*35238bceSAndroid Build Coastguard Worker 
vertex_attrib_i_pointer(NegativeTestContext & ctx)214*35238bceSAndroid Build Coastguard Worker void vertex_attrib_i_pointer(NegativeTestContext &ctx)
215*35238bceSAndroid Build Coastguard Worker {
216*35238bceSAndroid Build Coastguard Worker     GLuint vao = 0;
217*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
218*35238bceSAndroid Build Coastguard Worker     if (glu::isContextTypeES(ctx.getRenderContext().getType()))
219*35238bceSAndroid Build Coastguard Worker         ctx.glBindVertexArray(0);
220*35238bceSAndroid Build Coastguard Worker     else
221*35238bceSAndroid Build Coastguard Worker         ctx.glBindVertexArray(vao);
222*35238bceSAndroid Build Coastguard Worker 
223*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not an accepted value.");
224*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIPointer(0, 1, 0, 0, 0);
225*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
226*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIPointer(0, 4, GL_INT_2_10_10_10_REV, 0, 0);
227*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
228*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIPointer(0, 4, GL_UNSIGNED_INT_2_10_10_10_REV, 0, 0);
229*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
230*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
231*35238bceSAndroid Build Coastguard Worker 
232*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
233*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
234*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIPointer(maxVertexAttribs, 1, GL_BYTE, 0, 0);
235*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
236*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
237*35238bceSAndroid Build Coastguard Worker 
238*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if size is not 1, 2, 3, or 4.");
239*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIPointer(0, 0, GL_BYTE, 0, 0);
240*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
241*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
242*35238bceSAndroid Build Coastguard Worker 
243*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if stride is negative.");
244*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIPointer(0, 1, GL_BYTE, -1, 0);
245*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
246*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
247*35238bceSAndroid Build Coastguard Worker 
248*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated a non-zero vertex array object is bound, zero is bound to the "
249*35238bceSAndroid Build Coastguard Worker                      "GL_ARRAY_BUFFER buffer object binding point and the pointer argument is not NULL.");
250*35238bceSAndroid Build Coastguard Worker     GLbyte offset = 1;
251*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
252*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
253*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
254*35238bceSAndroid Build Coastguard Worker 
255*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIPointer(0, 1, GL_BYTE, 0, &offset);
256*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
257*35238bceSAndroid Build Coastguard Worker 
258*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(0);
259*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteVertexArrays(1, &vao);
260*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
261*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
262*35238bceSAndroid Build Coastguard Worker }
263*35238bceSAndroid Build Coastguard Worker 
vertex_attrib_format(NegativeTestContext & ctx)264*35238bceSAndroid Build Coastguard Worker void vertex_attrib_format(NegativeTestContext &ctx)
265*35238bceSAndroid Build Coastguard Worker {
266*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs              = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
267*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribRelativeOffset = ctx.getInteger(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET);
268*35238bceSAndroid Build Coastguard Worker     GLuint vao                        = 0;
269*35238bceSAndroid Build Coastguard Worker 
270*35238bceSAndroid Build Coastguard Worker     ctx.beginSection(
271*35238bceSAndroid Build Coastguard Worker         "GL_INVALID_VALUE is generated if attribindex is greater than or equal to the value of MAX_VERTEX_ATTRIBS.");
272*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
273*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
274*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
275*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribFormat(maxVertexAttribs, 4, GL_FLOAT, GL_FALSE, maxVertexAttribRelativeOffset);
276*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
277*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
278*35238bceSAndroid Build Coastguard Worker 
279*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if size is not one of 1, 2, 3, 4.");
280*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
281*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
282*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
283*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribFormat(1, 0, GL_FLOAT, GL_FALSE, maxVertexAttribRelativeOffset);
284*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
285*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
286*35238bceSAndroid Build Coastguard Worker 
287*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the parameter token names allowed.");
288*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
289*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
290*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
291*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribFormat(1, 4, 1, GL_FALSE, 0);
292*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
293*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
294*35238bceSAndroid Build Coastguard Worker 
295*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated if type is not a token name allowed.");
296*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
297*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(0);
298*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
299*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribFormat(1, 4, GL_FLOAT, GL_FALSE, 0);
300*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
301*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
302*35238bceSAndroid Build Coastguard Worker 
303*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated if type is GL_INT_2_10_10_10_REV and size is not 4.");
304*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
305*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
306*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
307*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribFormat(1, 3, GL_INT_2_10_10_10_REV, GL_FALSE, 0);
308*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
309*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
310*35238bceSAndroid Build Coastguard Worker 
311*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated if type is GL_UNSIGNED_INT_2_10_10_10_REV and size is not 4.");
312*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
313*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
314*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
315*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribFormat(1, 3, GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 0);
316*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
317*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
318*35238bceSAndroid Build Coastguard Worker 
319*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if relativeoffset is larger than the value of "
320*35238bceSAndroid Build Coastguard Worker                      "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.");
321*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
322*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
323*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
324*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribFormat(1, 4, GL_FLOAT, GL_FALSE, maxVertexAttribRelativeOffset + 1);
325*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
326*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
327*35238bceSAndroid Build Coastguard Worker }
328*35238bceSAndroid Build Coastguard Worker 
vertex_attrib_i_format(NegativeTestContext & ctx)329*35238bceSAndroid Build Coastguard Worker void vertex_attrib_i_format(NegativeTestContext &ctx)
330*35238bceSAndroid Build Coastguard Worker {
331*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs              = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
332*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribRelativeOffset = ctx.getInteger(GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET);
333*35238bceSAndroid Build Coastguard Worker     GLuint vao                        = 0;
334*35238bceSAndroid Build Coastguard Worker 
335*35238bceSAndroid Build Coastguard Worker     ctx.beginSection(
336*35238bceSAndroid Build Coastguard Worker         "GL_INVALID_VALUE is generated if attribindex is greater than or equal to the value of GL_MAX_VERTEX_ATTRIBS.");
337*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
338*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
339*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
340*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIFormat(maxVertexAttribs, 4, GL_INT, 0);
341*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
342*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
343*35238bceSAndroid Build Coastguard Worker 
344*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if size is not one the values 1, 2, 3, 4.");
345*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
346*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
347*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
348*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIFormat(1, 0, GL_INT, 0);
349*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
350*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
351*35238bceSAndroid Build Coastguard Worker 
352*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the parameter token names allowed.");
353*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
354*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
355*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
356*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIFormat(1, 4, GL_FLOAT, 0);
357*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
358*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
359*35238bceSAndroid Build Coastguard Worker 
360*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated if type is not a token name allowed.");
361*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
362*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(0);
363*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
364*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIFormat(1, 4, GL_INT, 0);
365*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
366*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
367*35238bceSAndroid Build Coastguard Worker 
368*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if relativeoffset is larger than the value of "
369*35238bceSAndroid Build Coastguard Worker                      "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET.");
370*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(1, &vao);
371*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(vao);
372*35238bceSAndroid Build Coastguard Worker     ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
373*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribIFormat(1, 4, GL_INT, maxVertexAttribRelativeOffset + 1);
374*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
375*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
376*35238bceSAndroid Build Coastguard Worker }
377*35238bceSAndroid Build Coastguard Worker 
enable_vertex_attrib_array(NegativeTestContext & ctx)378*35238bceSAndroid Build Coastguard Worker void enable_vertex_attrib_array(NegativeTestContext &ctx)
379*35238bceSAndroid Build Coastguard Worker {
380*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
381*35238bceSAndroid Build Coastguard Worker 
382*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
383*35238bceSAndroid Build Coastguard Worker     ctx.glEnableVertexAttribArray(maxVertexAttribs);
384*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
385*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
386*35238bceSAndroid Build Coastguard Worker }
387*35238bceSAndroid Build Coastguard Worker 
disable_vertex_attrib_array(NegativeTestContext & ctx)388*35238bceSAndroid Build Coastguard Worker void disable_vertex_attrib_array(NegativeTestContext &ctx)
389*35238bceSAndroid Build Coastguard Worker {
390*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
391*35238bceSAndroid Build Coastguard Worker 
392*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
393*35238bceSAndroid Build Coastguard Worker     ctx.glDisableVertexAttribArray(maxVertexAttribs);
394*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
395*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
396*35238bceSAndroid Build Coastguard Worker }
397*35238bceSAndroid Build Coastguard Worker 
gen_vertex_arrays(NegativeTestContext & ctx)398*35238bceSAndroid Build Coastguard Worker void gen_vertex_arrays(NegativeTestContext &ctx)
399*35238bceSAndroid Build Coastguard Worker {
400*35238bceSAndroid Build Coastguard Worker     GLuint arrays = 0;
401*35238bceSAndroid Build Coastguard Worker 
402*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
403*35238bceSAndroid Build Coastguard Worker     ctx.glGenVertexArrays(-1, &arrays);
404*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
405*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
406*35238bceSAndroid Build Coastguard Worker }
407*35238bceSAndroid Build Coastguard Worker 
bind_vertex_array(NegativeTestContext & ctx)408*35238bceSAndroid Build Coastguard Worker void bind_vertex_array(NegativeTestContext &ctx)
409*35238bceSAndroid Build Coastguard Worker {
410*35238bceSAndroid Build Coastguard Worker     ctx.beginSection(
411*35238bceSAndroid Build Coastguard Worker         "GL_INVALID_OPERATION is generated if array is not zero or the name of an existing vertex array object.");
412*35238bceSAndroid Build Coastguard Worker     ctx.glBindVertexArray(-1);
413*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
414*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
415*35238bceSAndroid Build Coastguard Worker }
416*35238bceSAndroid Build Coastguard Worker 
delete_vertex_arrays(NegativeTestContext & ctx)417*35238bceSAndroid Build Coastguard Worker void delete_vertex_arrays(NegativeTestContext &ctx)
418*35238bceSAndroid Build Coastguard Worker {
419*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
420*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteVertexArrays(-1, 0);
421*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
422*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
423*35238bceSAndroid Build Coastguard Worker }
424*35238bceSAndroid Build Coastguard Worker 
vertex_attrib_divisor(NegativeTestContext & ctx)425*35238bceSAndroid Build Coastguard Worker void vertex_attrib_divisor(NegativeTestContext &ctx)
426*35238bceSAndroid Build Coastguard Worker {
427*35238bceSAndroid Build Coastguard Worker     int maxVertexAttribs = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS);
428*35238bceSAndroid Build Coastguard Worker 
429*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS.");
430*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribDivisor(maxVertexAttribs, 0);
431*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
432*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
433*35238bceSAndroid Build Coastguard Worker }
434*35238bceSAndroid Build Coastguard Worker 
draw_arrays(NegativeTestContext & ctx)435*35238bceSAndroid Build Coastguard Worker void draw_arrays(NegativeTestContext &ctx)
436*35238bceSAndroid Build Coastguard Worker {
437*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
438*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
439*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
440*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
441*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
442*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
443*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
444*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
445*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(rc.getType()));
446*35238bceSAndroid Build Coastguard Worker 
447*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
448*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
449*35238bceSAndroid Build Coastguard Worker 
450*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
451*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArrays(-1, 0, 1);
452*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
453*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
454*35238bceSAndroid Build Coastguard Worker 
455*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
456*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArrays(GL_POINTS, 0, -1);
457*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
458*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
459*35238bceSAndroid Build Coastguard Worker 
460*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
461*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
462*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
463*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
464*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
465*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArrays(GL_POINTS, 0, 1);
466*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
467*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
468*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
469*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
470*35238bceSAndroid Build Coastguard Worker 
471*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
472*35238bceSAndroid Build Coastguard Worker }
473*35238bceSAndroid Build Coastguard Worker 
draw_arrays_invalid_program(NegativeTestContext & ctx)474*35238bceSAndroid Build Coastguard Worker void draw_arrays_invalid_program(NegativeTestContext &ctx)
475*35238bceSAndroid Build Coastguard Worker {
476*35238bceSAndroid Build Coastguard Worker     GLuint fbo = 0;
477*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(ctx.getRenderContext().getType()));
478*35238bceSAndroid Build Coastguard Worker 
479*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
480*35238bceSAndroid Build Coastguard Worker 
481*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
482*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArrays(-1, 0, 1);
483*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
484*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
485*35238bceSAndroid Build Coastguard Worker 
486*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
487*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArrays(GL_POINTS, 0, -1);
488*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
489*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
490*35238bceSAndroid Build Coastguard Worker 
491*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
492*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
493*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
494*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
495*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
496*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArrays(GL_POINTS, 0, 1);
497*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
498*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
499*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
500*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
501*35238bceSAndroid Build Coastguard Worker }
502*35238bceSAndroid Build Coastguard Worker 
draw_arrays_incomplete_primitive(NegativeTestContext & ctx)503*35238bceSAndroid Build Coastguard Worker void draw_arrays_incomplete_primitive(NegativeTestContext &ctx)
504*35238bceSAndroid Build Coastguard Worker {
505*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
506*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
507*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
508*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
509*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
510*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
511*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
512*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
513*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(rc.getType()));
514*35238bceSAndroid Build Coastguard Worker 
515*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
516*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
517*35238bceSAndroid Build Coastguard Worker 
518*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
519*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArrays(-1, 0, 1);
520*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
521*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
522*35238bceSAndroid Build Coastguard Worker 
523*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
524*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArrays(GL_TRIANGLES, 0, -1);
525*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
526*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
527*35238bceSAndroid Build Coastguard Worker 
528*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
529*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
530*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
531*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
532*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
533*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArrays(GL_TRIANGLES, 0, 1);
534*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
535*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
536*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
537*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
538*35238bceSAndroid Build Coastguard Worker 
539*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
540*35238bceSAndroid Build Coastguard Worker }
541*35238bceSAndroid Build Coastguard Worker 
draw_elements(NegativeTestContext & ctx)542*35238bceSAndroid Build Coastguard Worker void draw_elements(NegativeTestContext &ctx)
543*35238bceSAndroid Build Coastguard Worker {
544*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
545*35238bceSAndroid Build Coastguard Worker     const bool isES              = glu::isContextTypeES(rc.getType());
546*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
547*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
548*35238bceSAndroid Build Coastguard Worker     GLuint buf                   = 0;
549*35238bceSAndroid Build Coastguard Worker     GLuint tfID                  = 0;
550*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1]            = {0};
551*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
552*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
553*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
554*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
555*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
556*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, isES);
557*35238bceSAndroid Build Coastguard Worker 
558*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
559*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
560*35238bceSAndroid Build Coastguard Worker 
561*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
562*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(-1, 1, GL_UNSIGNED_BYTE, indices);
563*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
564*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
565*35238bceSAndroid Build Coastguard Worker 
566*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
567*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_POINTS, 1, -1, indices);
568*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
569*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_POINTS, 1, GL_FLOAT, indices);
570*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
571*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
572*35238bceSAndroid Build Coastguard Worker 
573*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
574*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_POINTS, -1, GL_UNSIGNED_BYTE, indices);
575*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
576*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
577*35238bceSAndroid Build Coastguard Worker 
578*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
579*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
580*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
581*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
582*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
583*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, indices);
584*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
585*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
586*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
587*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
588*35238bceSAndroid Build Coastguard Worker 
589*35238bceSAndroid Build Coastguard Worker     if (isES &&
590*35238bceSAndroid Build Coastguard Worker         !ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
591*35238bceSAndroid Build Coastguard Worker     {
592*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
593*35238bceSAndroid Build Coastguard Worker         const char *tfVarying = "gl_Position";
594*35238bceSAndroid Build Coastguard Worker 
595*35238bceSAndroid Build Coastguard Worker         ctx.glGenBuffers(1, &buf);
596*35238bceSAndroid Build Coastguard Worker         ctx.glGenTransformFeedbacks(1, &tfID);
597*35238bceSAndroid Build Coastguard Worker 
598*35238bceSAndroid Build Coastguard Worker         ctx.glUseProgram(program.getProgram());
599*35238bceSAndroid Build Coastguard Worker         ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
600*35238bceSAndroid Build Coastguard Worker         ctx.glLinkProgram(program.getProgram());
601*35238bceSAndroid Build Coastguard Worker         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
602*35238bceSAndroid Build Coastguard Worker         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
603*35238bceSAndroid Build Coastguard Worker         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
604*35238bceSAndroid Build Coastguard Worker         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
605*35238bceSAndroid Build Coastguard Worker         ctx.glBeginTransformFeedback(GL_POINTS);
606*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
607*35238bceSAndroid Build Coastguard Worker 
608*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, indices);
609*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_INVALID_OPERATION);
610*35238bceSAndroid Build Coastguard Worker 
611*35238bceSAndroid Build Coastguard Worker         ctx.glPauseTransformFeedback();
612*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, indices);
613*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
614*35238bceSAndroid Build Coastguard Worker 
615*35238bceSAndroid Build Coastguard Worker         ctx.glEndTransformFeedback();
616*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteBuffers(1, &buf);
617*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteTransformFeedbacks(1, &tfID);
618*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
619*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
620*35238bceSAndroid Build Coastguard Worker     }
621*35238bceSAndroid Build Coastguard Worker 
622*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
623*35238bceSAndroid Build Coastguard Worker }
624*35238bceSAndroid Build Coastguard Worker 
draw_elements_invalid_program(NegativeTestContext & ctx)625*35238bceSAndroid Build Coastguard Worker void draw_elements_invalid_program(NegativeTestContext &ctx)
626*35238bceSAndroid Build Coastguard Worker {
627*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
628*35238bceSAndroid Build Coastguard Worker     GLuint fbo        = 0;
629*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1] = {0};
630*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(ctx.getRenderContext().getType()));
631*35238bceSAndroid Build Coastguard Worker 
632*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
633*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(-1, 1, GL_UNSIGNED_BYTE, indices);
634*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
635*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
636*35238bceSAndroid Build Coastguard Worker 
637*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
638*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_POINTS, 1, -1, indices);
639*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
640*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_POINTS, 1, GL_FLOAT, indices);
641*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
642*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
643*35238bceSAndroid Build Coastguard Worker 
644*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
645*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_POINTS, -1, GL_UNSIGNED_BYTE, indices);
646*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
647*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
648*35238bceSAndroid Build Coastguard Worker 
649*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
650*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
651*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
652*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
653*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
654*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_POINTS, 1, GL_UNSIGNED_BYTE, indices);
655*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
656*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
657*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
658*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
659*35238bceSAndroid Build Coastguard Worker }
660*35238bceSAndroid Build Coastguard Worker 
draw_elements_incomplete_primitive(NegativeTestContext & ctx)661*35238bceSAndroid Build Coastguard Worker void draw_elements_incomplete_primitive(NegativeTestContext &ctx)
662*35238bceSAndroid Build Coastguard Worker {
663*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
664*35238bceSAndroid Build Coastguard Worker     bool isES                    = glu::isContextTypeES(rc.getType());
665*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
666*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
667*35238bceSAndroid Build Coastguard Worker     GLuint buf                   = 0;
668*35238bceSAndroid Build Coastguard Worker     GLuint tfID                  = 0;
669*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1]            = {0};
670*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
671*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
672*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
673*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
674*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
675*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, isES);
676*35238bceSAndroid Build Coastguard Worker 
677*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
678*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
679*35238bceSAndroid Build Coastguard Worker 
680*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
681*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(-1, 1, GL_UNSIGNED_BYTE, indices);
682*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
683*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
684*35238bceSAndroid Build Coastguard Worker 
685*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
686*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_TRIANGLES, 1, -1, indices);
687*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
688*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_TRIANGLES, 1, GL_FLOAT, indices);
689*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
690*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
691*35238bceSAndroid Build Coastguard Worker 
692*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
693*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_TRIANGLES, -1, GL_UNSIGNED_BYTE, indices);
694*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
695*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
696*35238bceSAndroid Build Coastguard Worker 
697*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
698*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
699*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
700*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
701*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
702*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElements(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, indices);
703*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
704*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
705*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
706*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
707*35238bceSAndroid Build Coastguard Worker 
708*35238bceSAndroid Build Coastguard Worker     if (isES &&
709*35238bceSAndroid Build Coastguard Worker         !ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
710*35238bceSAndroid Build Coastguard Worker     {
711*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
712*35238bceSAndroid Build Coastguard Worker         const char *tfVarying = "gl_Position";
713*35238bceSAndroid Build Coastguard Worker 
714*35238bceSAndroid Build Coastguard Worker         ctx.glGenBuffers(1, &buf);
715*35238bceSAndroid Build Coastguard Worker         ctx.glGenTransformFeedbacks(1, &tfID);
716*35238bceSAndroid Build Coastguard Worker 
717*35238bceSAndroid Build Coastguard Worker         ctx.glUseProgram(program.getProgram());
718*35238bceSAndroid Build Coastguard Worker         ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
719*35238bceSAndroid Build Coastguard Worker         ctx.glLinkProgram(program.getProgram());
720*35238bceSAndroid Build Coastguard Worker         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
721*35238bceSAndroid Build Coastguard Worker         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
722*35238bceSAndroid Build Coastguard Worker         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
723*35238bceSAndroid Build Coastguard Worker         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
724*35238bceSAndroid Build Coastguard Worker         ctx.glBeginTransformFeedback(GL_TRIANGLES);
725*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
726*35238bceSAndroid Build Coastguard Worker 
727*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElements(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, indices);
728*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_INVALID_OPERATION);
729*35238bceSAndroid Build Coastguard Worker 
730*35238bceSAndroid Build Coastguard Worker         ctx.glPauseTransformFeedback();
731*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElements(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, indices);
732*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
733*35238bceSAndroid Build Coastguard Worker 
734*35238bceSAndroid Build Coastguard Worker         ctx.glEndTransformFeedback();
735*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteBuffers(1, &buf);
736*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteTransformFeedbacks(1, &tfID);
737*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
738*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
739*35238bceSAndroid Build Coastguard Worker     }
740*35238bceSAndroid Build Coastguard Worker 
741*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
742*35238bceSAndroid Build Coastguard Worker }
743*35238bceSAndroid Build Coastguard Worker 
checkSupport(NegativeTestContext & ctx)744*35238bceSAndroid Build Coastguard Worker static bool checkSupport(NegativeTestContext &ctx)
745*35238bceSAndroid Build Coastguard Worker {
746*35238bceSAndroid Build Coastguard Worker     return contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ||
747*35238bceSAndroid Build Coastguard Worker            contextSupports(ctx.getRenderContext().getType(), glu::ApiType::core(4, 5));
748*35238bceSAndroid Build Coastguard Worker }
749*35238bceSAndroid Build Coastguard Worker 
draw_elements_base_vertex(NegativeTestContext & ctx)750*35238bceSAndroid Build Coastguard Worker void draw_elements_base_vertex(NegativeTestContext &ctx)
751*35238bceSAndroid Build Coastguard Worker {
752*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_AND_THROW(NotSupportedError, checkSupport(ctx),
753*35238bceSAndroid Build Coastguard Worker                         "This test requires a 3.2 context or higher context version.");
754*35238bceSAndroid Build Coastguard Worker 
755*35238bceSAndroid Build Coastguard Worker     GLuint fbo        = 0;
756*35238bceSAndroid Build Coastguard Worker     GLuint indices[1] = {0};
757*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(ctx.getRenderContext().getType()));
758*35238bceSAndroid Build Coastguard Worker 
759*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
760*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsBaseVertex(-1, 1, GL_UNSIGNED_INT, indices, 1);
761*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
762*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
763*35238bceSAndroid Build Coastguard Worker 
764*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
765*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsBaseVertex(GL_POINTS, 1, -1, indices, 1);
766*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
767*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsBaseVertex(GL_POINTS, 1, GL_FLOAT, indices, 1);
768*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
769*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
770*35238bceSAndroid Build Coastguard Worker 
771*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
772*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsBaseVertex(GL_POINTS, -1, GL_UNSIGNED_INT, indices, 1);
773*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
774*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
775*35238bceSAndroid Build Coastguard Worker 
776*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
777*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
778*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
779*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
780*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
781*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsBaseVertex(GL_POINTS, 1, GL_UNSIGNED_INT, indices, 1);
782*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
783*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
784*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
785*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
786*35238bceSAndroid Build Coastguard Worker }
787*35238bceSAndroid Build Coastguard Worker 
draw_elements_base_vertex_primitive_mode_mismatch(NegativeTestContext & ctx)788*35238bceSAndroid Build Coastguard Worker void draw_elements_base_vertex_primitive_mode_mismatch(NegativeTestContext &ctx)
789*35238bceSAndroid Build Coastguard Worker {
790*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_AND_THROW(NotSupportedError, checkSupport(ctx),
791*35238bceSAndroid Build Coastguard Worker                         "This test requires a 3.2 context or higher context version.");
792*35238bceSAndroid Build Coastguard Worker 
793*35238bceSAndroid Build Coastguard Worker     GLuint indices[1] = {0};
794*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
795*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES);
796*35238bceSAndroid Build Coastguard Worker 
797*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(ctx.getRenderContext(),
798*35238bceSAndroid Build Coastguard Worker                                glu::ProgramSources()
799*35238bceSAndroid Build Coastguard Worker                                    << glu::ProgramSeparable(true)
800*35238bceSAndroid Build Coastguard Worker                                    << glu::VertexSource(tcu::StringTemplate(vertexShaderSource).specialize(args))
801*35238bceSAndroid Build Coastguard Worker                                    << glu::GeometrySource(geometryShaderSource));
802*35238bceSAndroid Build Coastguard Worker 
803*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated if a geometry shader is active and mode is incompatible with "
804*35238bceSAndroid Build Coastguard Worker                      "the input primitive type of the geometry shader in the currently installed program object.");
805*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
806*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsBaseVertex(GL_TRIANGLES, 1, GL_UNSIGNED_INT, indices, 1);
807*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
808*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
809*35238bceSAndroid Build Coastguard Worker 
810*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
811*35238bceSAndroid Build Coastguard Worker }
812*35238bceSAndroid Build Coastguard Worker 
draw_arrays_instanced(NegativeTestContext & ctx)813*35238bceSAndroid Build Coastguard Worker void draw_arrays_instanced(NegativeTestContext &ctx)
814*35238bceSAndroid Build Coastguard Worker {
815*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
816*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
817*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
818*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
819*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
820*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
821*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(ctx.getRenderContext(),
822*35238bceSAndroid Build Coastguard Worker                                glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
823*35238bceSAndroid Build Coastguard Worker                                                        tcu::StringTemplate(fragmentShaderSource).specialize(args)));
824*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(rc.getType()));
825*35238bceSAndroid Build Coastguard Worker 
826*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
827*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
828*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribDivisor(0, 1);
829*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
830*35238bceSAndroid Build Coastguard Worker 
831*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
832*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(-1, 0, 1, 1);
833*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
834*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
835*35238bceSAndroid Build Coastguard Worker 
836*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
837*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(GL_POINTS, 0, -1, 1);
838*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
839*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, -1);
840*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
841*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
842*35238bceSAndroid Build Coastguard Worker 
843*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
844*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
845*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
846*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
847*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
848*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, 1);
849*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
850*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
851*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
852*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
853*35238bceSAndroid Build Coastguard Worker 
854*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
855*35238bceSAndroid Build Coastguard Worker }
856*35238bceSAndroid Build Coastguard Worker 
draw_arrays_instanced_invalid_program(NegativeTestContext & ctx)857*35238bceSAndroid Build Coastguard Worker void draw_arrays_instanced_invalid_program(NegativeTestContext &ctx)
858*35238bceSAndroid Build Coastguard Worker {
859*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
860*35238bceSAndroid Build Coastguard Worker 
861*35238bceSAndroid Build Coastguard Worker     GLuint fbo = 0;
862*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(ctx.getRenderContext().getType()));
863*35238bceSAndroid Build Coastguard Worker 
864*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribDivisor(0, 1);
865*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
866*35238bceSAndroid Build Coastguard Worker 
867*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
868*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(-1, 0, 1, 1);
869*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
870*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
871*35238bceSAndroid Build Coastguard Worker 
872*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
873*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(GL_POINTS, 0, -1, 1);
874*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
875*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, -1);
876*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
877*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
878*35238bceSAndroid Build Coastguard Worker 
879*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
880*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
881*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
882*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
883*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
884*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(GL_POINTS, 0, 1, 1);
885*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
886*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
887*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
888*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
889*35238bceSAndroid Build Coastguard Worker }
890*35238bceSAndroid Build Coastguard Worker 
draw_arrays_instanced_incomplete_primitive(NegativeTestContext & ctx)891*35238bceSAndroid Build Coastguard Worker void draw_arrays_instanced_incomplete_primitive(NegativeTestContext &ctx)
892*35238bceSAndroid Build Coastguard Worker {
893*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
894*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
895*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
896*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
897*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
898*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
899*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
900*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
901*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(rc.getType()));
902*35238bceSAndroid Build Coastguard Worker 
903*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribDivisor(0, 1);
904*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
905*35238bceSAndroid Build Coastguard Worker 
906*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
907*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(-1, 0, 1, 1);
908*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
909*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
910*35238bceSAndroid Build Coastguard Worker 
911*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
912*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(GL_TRIANGLES, 0, -1, 1);
913*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
914*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(GL_TRIANGLES, 0, 1, -1);
915*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
916*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
917*35238bceSAndroid Build Coastguard Worker 
918*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
919*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
920*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
921*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
922*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
923*35238bceSAndroid Build Coastguard Worker     ctx.glDrawArraysInstanced(GL_TRIANGLES, 0, 1, 1);
924*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
925*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
926*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
927*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
928*35238bceSAndroid Build Coastguard Worker 
929*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
930*35238bceSAndroid Build Coastguard Worker }
931*35238bceSAndroid Build Coastguard Worker 
draw_elements_instanced(NegativeTestContext & ctx)932*35238bceSAndroid Build Coastguard Worker void draw_elements_instanced(NegativeTestContext &ctx)
933*35238bceSAndroid Build Coastguard Worker {
934*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
935*35238bceSAndroid Build Coastguard Worker     const bool isES              = glu::isContextTypeES(rc.getType());
936*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
937*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
938*35238bceSAndroid Build Coastguard Worker     GLuint buf                   = 0;
939*35238bceSAndroid Build Coastguard Worker     GLuint tfID                  = 0;
940*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1]            = {0};
941*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
942*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
943*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
944*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
945*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
946*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, isES);
947*35238bceSAndroid Build Coastguard Worker 
948*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
949*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribDivisor(0, 1);
950*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
951*35238bceSAndroid Build Coastguard Worker 
952*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
953*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(-1, 1, GL_UNSIGNED_BYTE, indices, 1);
954*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
955*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
956*35238bceSAndroid Build Coastguard Worker 
957*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
958*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, 1, -1, indices, 1);
959*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
960*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_FLOAT, indices, 1);
961*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
962*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
963*35238bceSAndroid Build Coastguard Worker 
964*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
965*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, -1, GL_UNSIGNED_BYTE, indices, 1);
966*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
967*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, 11, GL_UNSIGNED_BYTE, indices, -1);
968*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
969*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
970*35238bceSAndroid Build Coastguard Worker 
971*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
972*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
973*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
974*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
975*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
976*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, indices, 1);
977*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
978*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
979*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
980*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
981*35238bceSAndroid Build Coastguard Worker 
982*35238bceSAndroid Build Coastguard Worker     if (isES &&
983*35238bceSAndroid Build Coastguard Worker         !ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
984*35238bceSAndroid Build Coastguard Worker     {
985*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
986*35238bceSAndroid Build Coastguard Worker         const char *tfVarying = "gl_Position";
987*35238bceSAndroid Build Coastguard Worker 
988*35238bceSAndroid Build Coastguard Worker         ctx.glGenBuffers(1, &buf);
989*35238bceSAndroid Build Coastguard Worker         ctx.glGenTransformFeedbacks(1, &tfID);
990*35238bceSAndroid Build Coastguard Worker 
991*35238bceSAndroid Build Coastguard Worker         ctx.glUseProgram(program.getProgram());
992*35238bceSAndroid Build Coastguard Worker         ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
993*35238bceSAndroid Build Coastguard Worker         ctx.glLinkProgram(program.getProgram());
994*35238bceSAndroid Build Coastguard Worker         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
995*35238bceSAndroid Build Coastguard Worker         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
996*35238bceSAndroid Build Coastguard Worker         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
997*35238bceSAndroid Build Coastguard Worker         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
998*35238bceSAndroid Build Coastguard Worker         ctx.glBeginTransformFeedback(GL_POINTS);
999*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1000*35238bceSAndroid Build Coastguard Worker 
1001*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, indices, 1);
1002*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_INVALID_OPERATION);
1003*35238bceSAndroid Build Coastguard Worker 
1004*35238bceSAndroid Build Coastguard Worker         ctx.glPauseTransformFeedback();
1005*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, indices, 1);
1006*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1007*35238bceSAndroid Build Coastguard Worker 
1008*35238bceSAndroid Build Coastguard Worker         ctx.glEndTransformFeedback();
1009*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteBuffers(1, &buf);
1010*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteTransformFeedbacks(1, &tfID);
1011*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1012*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
1013*35238bceSAndroid Build Coastguard Worker     }
1014*35238bceSAndroid Build Coastguard Worker 
1015*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1016*35238bceSAndroid Build Coastguard Worker }
1017*35238bceSAndroid Build Coastguard Worker 
draw_elements_instanced_invalid_program(NegativeTestContext & ctx)1018*35238bceSAndroid Build Coastguard Worker void draw_elements_instanced_invalid_program(NegativeTestContext &ctx)
1019*35238bceSAndroid Build Coastguard Worker {
1020*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1021*35238bceSAndroid Build Coastguard Worker 
1022*35238bceSAndroid Build Coastguard Worker     GLuint fbo        = 0;
1023*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1] = {0};
1024*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(ctx.getRenderContext().getType()));
1025*35238bceSAndroid Build Coastguard Worker 
1026*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribDivisor(0, 1);
1027*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
1028*35238bceSAndroid Build Coastguard Worker 
1029*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1030*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(-1, 1, GL_UNSIGNED_BYTE, indices, 1);
1031*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1032*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1033*35238bceSAndroid Build Coastguard Worker 
1034*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1035*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, 1, -1, indices, 1);
1036*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1037*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_FLOAT, indices, 1);
1038*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1039*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1040*35238bceSAndroid Build Coastguard Worker 
1041*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
1042*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, -1, GL_UNSIGNED_BYTE, indices, 1);
1043*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1044*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, 11, GL_UNSIGNED_BYTE, indices, -1);
1045*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1046*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1047*35238bceSAndroid Build Coastguard Worker 
1048*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
1049*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
1050*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
1051*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1052*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1053*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_POINTS, 1, GL_UNSIGNED_BYTE, indices, 1);
1054*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1055*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1056*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
1057*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1058*35238bceSAndroid Build Coastguard Worker }
1059*35238bceSAndroid Build Coastguard Worker 
draw_elements_instanced_incomplete_primitive(NegativeTestContext & ctx)1060*35238bceSAndroid Build Coastguard Worker void draw_elements_instanced_incomplete_primitive(NegativeTestContext &ctx)
1061*35238bceSAndroid Build Coastguard Worker {
1062*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
1063*35238bceSAndroid Build Coastguard Worker     const bool isES              = glu::isContextTypeES(rc.getType());
1064*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
1065*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
1066*35238bceSAndroid Build Coastguard Worker     GLuint buf                   = 0;
1067*35238bceSAndroid Build Coastguard Worker     GLuint tfID                  = 0;
1068*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1]            = {0};
1069*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
1070*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
1071*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
1072*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
1073*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
1074*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, isES);
1075*35238bceSAndroid Build Coastguard Worker 
1076*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
1077*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribDivisor(0, 1);
1078*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
1079*35238bceSAndroid Build Coastguard Worker 
1080*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1081*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(-1, 1, GL_UNSIGNED_BYTE, indices, 1);
1082*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1083*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1084*35238bceSAndroid Build Coastguard Worker 
1085*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1086*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, -1, indices, 1);
1087*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1088*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, GL_FLOAT, indices, 1);
1089*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1090*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1091*35238bceSAndroid Build Coastguard Worker 
1092*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
1093*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_TRIANGLES, -1, GL_UNSIGNED_BYTE, indices, 1);
1094*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1095*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_TRIANGLES, 11, GL_UNSIGNED_BYTE, indices, -1);
1096*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1097*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1098*35238bceSAndroid Build Coastguard Worker 
1099*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
1100*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
1101*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
1102*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1103*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1104*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, indices, 1);
1105*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1106*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1107*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
1108*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1109*35238bceSAndroid Build Coastguard Worker 
1110*35238bceSAndroid Build Coastguard Worker     if (isES &&
1111*35238bceSAndroid Build Coastguard Worker         !ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
1112*35238bceSAndroid Build Coastguard Worker     {
1113*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
1114*35238bceSAndroid Build Coastguard Worker         const char *tfVarying = "gl_Position";
1115*35238bceSAndroid Build Coastguard Worker 
1116*35238bceSAndroid Build Coastguard Worker         ctx.glGenBuffers(1, &buf);
1117*35238bceSAndroid Build Coastguard Worker         ctx.glGenTransformFeedbacks(1, &tfID);
1118*35238bceSAndroid Build Coastguard Worker 
1119*35238bceSAndroid Build Coastguard Worker         ctx.glUseProgram(program.getProgram());
1120*35238bceSAndroid Build Coastguard Worker         ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1121*35238bceSAndroid Build Coastguard Worker         ctx.glLinkProgram(program.getProgram());
1122*35238bceSAndroid Build Coastguard Worker         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
1123*35238bceSAndroid Build Coastguard Worker         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1124*35238bceSAndroid Build Coastguard Worker         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1125*35238bceSAndroid Build Coastguard Worker         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1126*35238bceSAndroid Build Coastguard Worker         ctx.glBeginTransformFeedback(GL_TRIANGLES);
1127*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1128*35238bceSAndroid Build Coastguard Worker 
1129*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, indices, 1);
1130*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_INVALID_OPERATION);
1131*35238bceSAndroid Build Coastguard Worker 
1132*35238bceSAndroid Build Coastguard Worker         ctx.glPauseTransformFeedback();
1133*35238bceSAndroid Build Coastguard Worker         ctx.glDrawElementsInstanced(GL_TRIANGLES, 1, GL_UNSIGNED_BYTE, indices, 1);
1134*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1135*35238bceSAndroid Build Coastguard Worker 
1136*35238bceSAndroid Build Coastguard Worker         ctx.glEndTransformFeedback();
1137*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteBuffers(1, &buf);
1138*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteTransformFeedbacks(1, &tfID);
1139*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1140*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
1141*35238bceSAndroid Build Coastguard Worker     }
1142*35238bceSAndroid Build Coastguard Worker 
1143*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1144*35238bceSAndroid Build Coastguard Worker }
1145*35238bceSAndroid Build Coastguard Worker 
draw_elements_instanced_base_vertex(NegativeTestContext & ctx)1146*35238bceSAndroid Build Coastguard Worker void draw_elements_instanced_base_vertex(NegativeTestContext &ctx)
1147*35238bceSAndroid Build Coastguard Worker {
1148*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_AND_THROW(NotSupportedError, checkSupport(ctx),
1149*35238bceSAndroid Build Coastguard Worker                         "This test requires a 3.2 context or higher context version.");
1150*35238bceSAndroid Build Coastguard Worker 
1151*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
1152*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
1153*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
1154*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1]            = {0};
1155*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
1156*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
1157*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
1158*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
1159*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
1160*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(rc.getType()));
1161*35238bceSAndroid Build Coastguard Worker 
1162*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
1163*35238bceSAndroid Build Coastguard Worker     ctx.glVertexAttribDivisor(0, 1);
1164*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
1165*35238bceSAndroid Build Coastguard Worker 
1166*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1167*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstancedBaseVertex(-1, 1, GL_UNSIGNED_BYTE, indices, 1, 1);
1168*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1169*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1170*35238bceSAndroid Build Coastguard Worker 
1171*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1172*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, 1, -1, indices, 1, 1);
1173*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1174*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, 1, GL_FLOAT, indices, 1, 1);
1175*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1176*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1177*35238bceSAndroid Build Coastguard Worker 
1178*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count or primcount are negative.");
1179*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, -1, GL_UNSIGNED_BYTE, indices, 1, 1);
1180*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1181*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, 11, GL_UNSIGNED_BYTE, indices, -1, 1);
1182*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1183*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1184*35238bceSAndroid Build Coastguard Worker 
1185*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
1186*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
1187*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
1188*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1189*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1190*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstancedBaseVertex(GL_POINTS, 1, GL_UNSIGNED_BYTE, indices, 1, 1);
1191*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1192*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1193*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
1194*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1195*35238bceSAndroid Build Coastguard Worker 
1196*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1197*35238bceSAndroid Build Coastguard Worker }
1198*35238bceSAndroid Build Coastguard Worker 
draw_elements_instanced_base_vertex_primitive_mode_mismatch(NegativeTestContext & ctx)1199*35238bceSAndroid Build Coastguard Worker void draw_elements_instanced_base_vertex_primitive_mode_mismatch(NegativeTestContext &ctx)
1200*35238bceSAndroid Build Coastguard Worker {
1201*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_AND_THROW(NotSupportedError, checkSupport(ctx),
1202*35238bceSAndroid Build Coastguard Worker                         "This test requires a 3.2 context or higher context version.");
1203*35238bceSAndroid Build Coastguard Worker 
1204*35238bceSAndroid Build Coastguard Worker     GLuint indices[1] = {0};
1205*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
1206*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES);
1207*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram geometryProgram(
1208*35238bceSAndroid Build Coastguard Worker         ctx.getRenderContext(), glu::ProgramSources()
1209*35238bceSAndroid Build Coastguard Worker                                     << glu::ProgramSeparable(true)
1210*35238bceSAndroid Build Coastguard Worker                                     << glu::VertexSource(tcu::StringTemplate(vertexShaderSource).specialize(args))
1211*35238bceSAndroid Build Coastguard Worker                                     << glu::GeometrySource(geometryShaderSource));
1212*35238bceSAndroid Build Coastguard Worker 
1213*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated if a geometry shader is active and mode is incompatible with "
1214*35238bceSAndroid Build Coastguard Worker                      "the input primitive type of the geometry shader in the currently installed program object.");
1215*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(geometryProgram.getProgram());
1216*35238bceSAndroid Build Coastguard Worker     ctx.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, 1, GL_UNSIGNED_INT, indices, 1, 1);
1217*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
1218*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1219*35238bceSAndroid Build Coastguard Worker 
1220*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1221*35238bceSAndroid Build Coastguard Worker }
1222*35238bceSAndroid Build Coastguard Worker 
draw_range_elements(NegativeTestContext & ctx)1223*35238bceSAndroid Build Coastguard Worker void draw_range_elements(NegativeTestContext &ctx)
1224*35238bceSAndroid Build Coastguard Worker {
1225*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
1226*35238bceSAndroid Build Coastguard Worker     const bool isES              = glu::isContextTypeES(rc.getType());
1227*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
1228*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
1229*35238bceSAndroid Build Coastguard Worker     GLuint buf                   = 0;
1230*35238bceSAndroid Build Coastguard Worker     GLuint tfID                  = 0;
1231*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1]            = {0};
1232*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
1233*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
1234*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
1235*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
1236*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
1237*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, isES);
1238*35238bceSAndroid Build Coastguard Worker 
1239*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
1240*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
1241*35238bceSAndroid Build Coastguard Worker 
1242*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1243*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(-1, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1244*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1245*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1246*35238bceSAndroid Build Coastguard Worker 
1247*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1248*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, -1, indices);
1249*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1250*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_FLOAT, indices);
1251*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1252*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1253*35238bceSAndroid Build Coastguard Worker 
1254*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
1255*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 0, 1, -1, GL_UNSIGNED_BYTE, indices);
1256*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1257*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1258*35238bceSAndroid Build Coastguard Worker 
1259*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
1260*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 1, 0, 1, GL_UNSIGNED_BYTE, indices);
1261*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1262*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1263*35238bceSAndroid Build Coastguard Worker 
1264*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
1265*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
1266*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
1267*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1268*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1269*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1270*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1271*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1272*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
1273*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1274*35238bceSAndroid Build Coastguard Worker 
1275*35238bceSAndroid Build Coastguard Worker     if (isES &&
1276*35238bceSAndroid Build Coastguard Worker         !ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
1277*35238bceSAndroid Build Coastguard Worker     {
1278*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
1279*35238bceSAndroid Build Coastguard Worker         const char *tfVarying = "gl_Position";
1280*35238bceSAndroid Build Coastguard Worker 
1281*35238bceSAndroid Build Coastguard Worker         ctx.glGenBuffers(1, &buf);
1282*35238bceSAndroid Build Coastguard Worker         ctx.glGenTransformFeedbacks(1, &tfID);
1283*35238bceSAndroid Build Coastguard Worker 
1284*35238bceSAndroid Build Coastguard Worker         ctx.glUseProgram(program.getProgram());
1285*35238bceSAndroid Build Coastguard Worker         ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1286*35238bceSAndroid Build Coastguard Worker         ctx.glLinkProgram(program.getProgram());
1287*35238bceSAndroid Build Coastguard Worker         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
1288*35238bceSAndroid Build Coastguard Worker         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1289*35238bceSAndroid Build Coastguard Worker         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1290*35238bceSAndroid Build Coastguard Worker         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1291*35238bceSAndroid Build Coastguard Worker         ctx.glBeginTransformFeedback(GL_POINTS);
1292*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1293*35238bceSAndroid Build Coastguard Worker 
1294*35238bceSAndroid Build Coastguard Worker         ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1295*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_INVALID_OPERATION);
1296*35238bceSAndroid Build Coastguard Worker 
1297*35238bceSAndroid Build Coastguard Worker         ctx.glPauseTransformFeedback();
1298*35238bceSAndroid Build Coastguard Worker         ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1299*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1300*35238bceSAndroid Build Coastguard Worker 
1301*35238bceSAndroid Build Coastguard Worker         ctx.glEndTransformFeedback();
1302*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteBuffers(1, &buf);
1303*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteTransformFeedbacks(1, &tfID);
1304*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1305*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
1306*35238bceSAndroid Build Coastguard Worker     }
1307*35238bceSAndroid Build Coastguard Worker 
1308*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1309*35238bceSAndroid Build Coastguard Worker }
1310*35238bceSAndroid Build Coastguard Worker 
draw_range_elements_invalid_program(NegativeTestContext & ctx)1311*35238bceSAndroid Build Coastguard Worker void draw_range_elements_invalid_program(NegativeTestContext &ctx)
1312*35238bceSAndroid Build Coastguard Worker {
1313*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1314*35238bceSAndroid Build Coastguard Worker 
1315*35238bceSAndroid Build Coastguard Worker     GLuint fbo        = 0;
1316*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1] = {0};
1317*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(ctx.getRenderContext().getType()));
1318*35238bceSAndroid Build Coastguard Worker 
1319*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1320*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(-1, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1321*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1322*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1323*35238bceSAndroid Build Coastguard Worker 
1324*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1325*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, -1, indices);
1326*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1327*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_FLOAT, indices);
1328*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1329*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1330*35238bceSAndroid Build Coastguard Worker 
1331*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
1332*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 0, 1, -1, GL_UNSIGNED_BYTE, indices);
1333*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1334*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1335*35238bceSAndroid Build Coastguard Worker 
1336*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
1337*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 1, 0, 1, GL_UNSIGNED_BYTE, indices);
1338*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1339*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1340*35238bceSAndroid Build Coastguard Worker 
1341*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
1342*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
1343*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
1344*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1345*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1346*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1347*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1348*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1349*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
1350*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1351*35238bceSAndroid Build Coastguard Worker }
1352*35238bceSAndroid Build Coastguard Worker 
draw_range_elements_incomplete_primitive(NegativeTestContext & ctx)1353*35238bceSAndroid Build Coastguard Worker void draw_range_elements_incomplete_primitive(NegativeTestContext &ctx)
1354*35238bceSAndroid Build Coastguard Worker {
1355*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
1356*35238bceSAndroid Build Coastguard Worker     const bool isES              = glu::isContextTypeES(rc.getType());
1357*35238bceSAndroid Build Coastguard Worker     const bool isES32            = glu::contextSupports(rc.getType(), glu::ApiType::es(3, 2));
1358*35238bceSAndroid Build Coastguard Worker     GLuint fbo                   = 0;
1359*35238bceSAndroid Build Coastguard Worker     GLuint buf                   = 0;
1360*35238bceSAndroid Build Coastguard Worker     GLuint tfID                  = 0;
1361*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1]            = {0};
1362*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
1363*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = isES32 ? getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES) :
1364*35238bceSAndroid Build Coastguard Worker                                            getGLSLVersionDeclaration(glu::GLSL_VERSION_310_ES);
1365*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(ctx.getRenderContext(),
1366*35238bceSAndroid Build Coastguard Worker                                glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
1367*35238bceSAndroid Build Coastguard Worker                                                        tcu::StringTemplate(fragmentShaderSource).specialize(args)));
1368*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, isES);
1369*35238bceSAndroid Build Coastguard Worker 
1370*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
1371*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
1372*35238bceSAndroid Build Coastguard Worker 
1373*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1374*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(-1, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1375*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1376*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1377*35238bceSAndroid Build Coastguard Worker 
1378*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1379*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, -1, indices);
1380*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1381*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_FLOAT, indices);
1382*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1383*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1384*35238bceSAndroid Build Coastguard Worker 
1385*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
1386*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, -1, GL_UNSIGNED_BYTE, indices);
1387*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1388*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1389*35238bceSAndroid Build Coastguard Worker 
1390*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
1391*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_TRIANGLES, 1, 0, 1, GL_UNSIGNED_BYTE, indices);
1392*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1393*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1394*35238bceSAndroid Build Coastguard Worker 
1395*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
1396*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
1397*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
1398*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1399*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1400*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1401*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1402*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1403*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
1404*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1405*35238bceSAndroid Build Coastguard Worker 
1406*35238bceSAndroid Build Coastguard Worker     if (isES &&
1407*35238bceSAndroid Build Coastguard Worker         !ctx.getContextInfo().isExtensionSupported("GL_EXT_geometry_shader")) // GL_EXT_geometry_shader removes error
1408*35238bceSAndroid Build Coastguard Worker     {
1409*35238bceSAndroid Build Coastguard Worker         ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is active and not paused.");
1410*35238bceSAndroid Build Coastguard Worker         const char *tfVarying = "gl_Position";
1411*35238bceSAndroid Build Coastguard Worker 
1412*35238bceSAndroid Build Coastguard Worker         ctx.glGenBuffers(1, &buf);
1413*35238bceSAndroid Build Coastguard Worker         ctx.glGenTransformFeedbacks(1, &tfID);
1414*35238bceSAndroid Build Coastguard Worker 
1415*35238bceSAndroid Build Coastguard Worker         ctx.glUseProgram(program.getProgram());
1416*35238bceSAndroid Build Coastguard Worker         ctx.glTransformFeedbackVaryings(program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS);
1417*35238bceSAndroid Build Coastguard Worker         ctx.glLinkProgram(program.getProgram());
1418*35238bceSAndroid Build Coastguard Worker         ctx.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, tfID);
1419*35238bceSAndroid Build Coastguard Worker         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
1420*35238bceSAndroid Build Coastguard Worker         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW);
1421*35238bceSAndroid Build Coastguard Worker         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
1422*35238bceSAndroid Build Coastguard Worker         ctx.glBeginTransformFeedback(GL_TRIANGLES);
1423*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1424*35238bceSAndroid Build Coastguard Worker 
1425*35238bceSAndroid Build Coastguard Worker         ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1426*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_INVALID_OPERATION);
1427*35238bceSAndroid Build Coastguard Worker 
1428*35238bceSAndroid Build Coastguard Worker         ctx.glPauseTransformFeedback();
1429*35238bceSAndroid Build Coastguard Worker         ctx.glDrawRangeElements(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_BYTE, indices);
1430*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1431*35238bceSAndroid Build Coastguard Worker 
1432*35238bceSAndroid Build Coastguard Worker         ctx.glEndTransformFeedback();
1433*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteBuffers(1, &buf);
1434*35238bceSAndroid Build Coastguard Worker         ctx.glDeleteTransformFeedbacks(1, &tfID);
1435*35238bceSAndroid Build Coastguard Worker         ctx.expectError(GL_NO_ERROR);
1436*35238bceSAndroid Build Coastguard Worker         ctx.endSection();
1437*35238bceSAndroid Build Coastguard Worker     }
1438*35238bceSAndroid Build Coastguard Worker 
1439*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1440*35238bceSAndroid Build Coastguard Worker }
1441*35238bceSAndroid Build Coastguard Worker 
draw_range_elements_base_vertex(NegativeTestContext & ctx)1442*35238bceSAndroid Build Coastguard Worker void draw_range_elements_base_vertex(NegativeTestContext &ctx)
1443*35238bceSAndroid Build Coastguard Worker {
1444*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_AND_THROW(NotSupportedError, checkSupport(ctx),
1445*35238bceSAndroid Build Coastguard Worker                         "This test requires a 3.2 context or higher context version.");
1446*35238bceSAndroid Build Coastguard Worker 
1447*35238bceSAndroid Build Coastguard Worker     GLuint fbo        = 0;
1448*35238bceSAndroid Build Coastguard Worker     GLbyte indices[1] = {0};
1449*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
1450*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"]  = getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES);
1451*35238bceSAndroid Build Coastguard Worker     const glu::RenderContext &rc = ctx.getRenderContext();
1452*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram program(rc, glu::makeVtxFragSources(tcu::StringTemplate(vertexShaderSource).specialize(args),
1453*35238bceSAndroid Build Coastguard Worker                                                            tcu::StringTemplate(fragmentShaderSource).specialize(args)));
1454*35238bceSAndroid Build Coastguard Worker     VAOHelper vao(ctx, glu::isContextTypeES(rc.getType()));
1455*35238bceSAndroid Build Coastguard Worker 
1456*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(program.getProgram());
1457*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_NO_ERROR);
1458*35238bceSAndroid Build Coastguard Worker 
1459*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if mode is not an accepted value.");
1460*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElementsBaseVertex(-1, 0, 1, 1, GL_UNSIGNED_BYTE, indices, 1);
1461*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1462*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1463*35238bceSAndroid Build Coastguard Worker 
1464*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_ENUM is generated if type is not one of the accepted values.");
1465*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 0, 1, 1, -1, indices, 1);
1466*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1467*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 0, 1, 1, GL_FLOAT, indices, 1);
1468*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_ENUM);
1469*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1470*35238bceSAndroid Build Coastguard Worker 
1471*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if count is negative.");
1472*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 0, 1, -1, GL_UNSIGNED_BYTE, indices, 1);
1473*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1474*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1475*35238bceSAndroid Build Coastguard Worker 
1476*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_VALUE is generated if end < start.");
1477*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 1, 0, 1, GL_UNSIGNED_BYTE, indices, 1);
1478*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_VALUE);
1479*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1480*35238bceSAndroid Build Coastguard Worker 
1481*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not "
1482*35238bceSAndroid Build Coastguard Worker                      "framebuffer complete.");
1483*35238bceSAndroid Build Coastguard Worker     ctx.glGenFramebuffers(1, &fbo);
1484*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1485*35238bceSAndroid Build Coastguard Worker     ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
1486*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElementsBaseVertex(GL_POINTS, 0, 1, 1, GL_UNSIGNED_BYTE, indices, 1);
1487*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
1488*35238bceSAndroid Build Coastguard Worker     ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1489*35238bceSAndroid Build Coastguard Worker     ctx.glDeleteFramebuffers(1, &fbo);
1490*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1491*35238bceSAndroid Build Coastguard Worker 
1492*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1493*35238bceSAndroid Build Coastguard Worker }
1494*35238bceSAndroid Build Coastguard Worker 
draw_range_elements_base_vertex_primitive_mode_mismatch(NegativeTestContext & ctx)1495*35238bceSAndroid Build Coastguard Worker void draw_range_elements_base_vertex_primitive_mode_mismatch(NegativeTestContext &ctx)
1496*35238bceSAndroid Build Coastguard Worker {
1497*35238bceSAndroid Build Coastguard Worker     TCU_CHECK_AND_THROW(NotSupportedError, checkSupport(ctx),
1498*35238bceSAndroid Build Coastguard Worker                         "This test requires a 3.2 context or higher context version.");
1499*35238bceSAndroid Build Coastguard Worker 
1500*35238bceSAndroid Build Coastguard Worker     GLuint indices[1] = {0};
1501*35238bceSAndroid Build Coastguard Worker     map<string, string> args;
1502*35238bceSAndroid Build Coastguard Worker     args["GLSL_VERSION_STRING"] = getGLSLVersionDeclaration(glu::GLSL_VERSION_320_ES);
1503*35238bceSAndroid Build Coastguard Worker     glu::ShaderProgram geometryProgram(
1504*35238bceSAndroid Build Coastguard Worker         ctx.getRenderContext(), glu::ProgramSources()
1505*35238bceSAndroid Build Coastguard Worker                                     << glu::ProgramSeparable(true)
1506*35238bceSAndroid Build Coastguard Worker                                     << glu::VertexSource(tcu::StringTemplate(vertexShaderSource).specialize(args))
1507*35238bceSAndroid Build Coastguard Worker                                     << glu::GeometrySource(geometryShaderSource));
1508*35238bceSAndroid Build Coastguard Worker 
1509*35238bceSAndroid Build Coastguard Worker     ctx.beginSection("GL_INVALID_OPERATION is generated if a geometry shader is active and mode is incompatible with "
1510*35238bceSAndroid Build Coastguard Worker                      "the input primitive type of the geometry shader in the currently installed program object.");
1511*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(geometryProgram.getProgram());
1512*35238bceSAndroid Build Coastguard Worker     ctx.glDrawRangeElementsBaseVertex(GL_TRIANGLES, 0, 1, 1, GL_UNSIGNED_INT, indices, 1);
1513*35238bceSAndroid Build Coastguard Worker     ctx.expectError(GL_INVALID_OPERATION);
1514*35238bceSAndroid Build Coastguard Worker     ctx.endSection();
1515*35238bceSAndroid Build Coastguard Worker 
1516*35238bceSAndroid Build Coastguard Worker     ctx.glUseProgram(0);
1517*35238bceSAndroid Build Coastguard Worker }
1518*35238bceSAndroid Build Coastguard Worker 
getNegativeVertexArrayApiTestFunctions()1519*35238bceSAndroid Build Coastguard Worker std::vector<FunctionContainer> getNegativeVertexArrayApiTestFunctions()
1520*35238bceSAndroid Build Coastguard Worker {
1521*35238bceSAndroid Build Coastguard Worker     FunctionContainer funcs[] = {
1522*35238bceSAndroid Build Coastguard Worker         {vertex_attribf, "vertex_attribf", "Invalid glVertexAttrib{1234}f() usage"},
1523*35238bceSAndroid Build Coastguard Worker         {vertex_attribfv, "vertex_attribfv", "Invalid glVertexAttrib{1234}fv() usage"},
1524*35238bceSAndroid Build Coastguard Worker         {vertex_attribi4, "vertex_attribi4", "Invalid glVertexAttribI4{i|ui}f() usage"},
1525*35238bceSAndroid Build Coastguard Worker         {vertex_attribi4v, "vertex_attribi4v", "Invalid glVertexAttribI4{i|ui}fv() usage"},
1526*35238bceSAndroid Build Coastguard Worker         {vertex_attrib_pointer, "vertex_attrib_pointer", "Invalid glVertexAttribPointer() usage"},
1527*35238bceSAndroid Build Coastguard Worker         {vertex_attrib_i_pointer, "vertex_attrib_i_pointer", "Invalid glVertexAttribPointer() usage"},
1528*35238bceSAndroid Build Coastguard Worker         {vertex_attrib_format, "vertex_attrib_format", "Invalid glVertexAttribFormat() usage"},
1529*35238bceSAndroid Build Coastguard Worker         {vertex_attrib_i_format, "vertex_attrib_i_format", "Invalid glVertexAttribIFormat() usage"},
1530*35238bceSAndroid Build Coastguard Worker         {enable_vertex_attrib_array, "enable_vertex_attrib_array", "Invalid glEnableVertexAttribArray() usage"},
1531*35238bceSAndroid Build Coastguard Worker         {disable_vertex_attrib_array, "disable_vertex_attrib_array", "Invalid glDisableVertexAttribArray() usage"},
1532*35238bceSAndroid Build Coastguard Worker         {gen_vertex_arrays, "gen_vertex_arrays", "Invalid glGenVertexArrays() usage"},
1533*35238bceSAndroid Build Coastguard Worker         {bind_vertex_array, "bind_vertex_array", "Invalid glBindVertexArray() usage"},
1534*35238bceSAndroid Build Coastguard Worker         {delete_vertex_arrays, "delete_vertex_arrays", "Invalid glDeleteVertexArrays() usage"},
1535*35238bceSAndroid Build Coastguard Worker         {vertex_attrib_divisor, "vertex_attrib_divisor", "Invalid glVertexAttribDivisor() usage"},
1536*35238bceSAndroid Build Coastguard Worker         {draw_arrays, "draw_arrays", "Invalid glDrawArrays() usage"},
1537*35238bceSAndroid Build Coastguard Worker         {draw_arrays_invalid_program, "draw_arrays_invalid_program", "Invalid glDrawArrays() usage"},
1538*35238bceSAndroid Build Coastguard Worker         {draw_arrays_incomplete_primitive, "draw_arrays_incomplete_primitive", "Invalid glDrawArrays() usage"},
1539*35238bceSAndroid Build Coastguard Worker         {draw_elements, "draw_elements", "Invalid glDrawElements() usage"},
1540*35238bceSAndroid Build Coastguard Worker         {draw_elements_base_vertex, "draw_elements_base_vertex", "Invalid glDrawElementsBaseVertex() usage"},
1541*35238bceSAndroid Build Coastguard Worker         {draw_elements_base_vertex_primitive_mode_mismatch, "draw_elements_base_vertex_primitive_mode_mismatch",
1542*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawElementsBaseVertex() usage"},
1543*35238bceSAndroid Build Coastguard Worker         {draw_elements_invalid_program, "draw_elements_invalid_program", "Invalid glDrawElements() usage"},
1544*35238bceSAndroid Build Coastguard Worker         {draw_elements_incomplete_primitive, "draw_elements_incomplete_primitive", "Invalid glDrawElements() usage"},
1545*35238bceSAndroid Build Coastguard Worker         {draw_arrays_instanced, "draw_arrays_instanced", "Invalid glDrawArraysInstanced() usage"},
1546*35238bceSAndroid Build Coastguard Worker         {draw_arrays_instanced_invalid_program, "draw_arrays_instanced_invalid_program",
1547*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawArraysInstanced() usage"},
1548*35238bceSAndroid Build Coastguard Worker         {draw_arrays_instanced_incomplete_primitive, "draw_arrays_instanced_incomplete_primitive",
1549*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawArraysInstanced() usage"},
1550*35238bceSAndroid Build Coastguard Worker         {draw_elements_instanced, "draw_elements_instanced", "Invalid glDrawElementsInstanced() usage"},
1551*35238bceSAndroid Build Coastguard Worker         {draw_elements_instanced_invalid_program, "draw_elements_instanced_invalid_program",
1552*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawElementsInstanced() usage"},
1553*35238bceSAndroid Build Coastguard Worker         {draw_elements_instanced_incomplete_primitive, "draw_elements_instanced_incomplete_primitive",
1554*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawElementsInstanced() usage"},
1555*35238bceSAndroid Build Coastguard Worker         {draw_elements_instanced_base_vertex, "draw_elements_instanced_base_vertex",
1556*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawElementsInstancedBaseVertex() usage"},
1557*35238bceSAndroid Build Coastguard Worker         {draw_elements_instanced_base_vertex_primitive_mode_mismatch,
1558*35238bceSAndroid Build Coastguard Worker          "draw_elements_instanced_base_vertex_primitive_mode_mismatch",
1559*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawElementsInstancedBaseVertex() usage"},
1560*35238bceSAndroid Build Coastguard Worker         {draw_range_elements, "draw_range_elements", "Invalid glDrawRangeElements() usage"},
1561*35238bceSAndroid Build Coastguard Worker         {draw_range_elements_invalid_program, "draw_range_elements_invalid_program",
1562*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawRangeElements() usage"},
1563*35238bceSAndroid Build Coastguard Worker         {draw_range_elements_incomplete_primitive, "draw_range_elements_incomplete_primitive",
1564*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawRangeElements() usage"},
1565*35238bceSAndroid Build Coastguard Worker         {draw_range_elements_base_vertex, "draw_range_elements_base_vertex",
1566*35238bceSAndroid Build Coastguard Worker          "Invalid glDrawRangeElementsBaseVertex() usage"},
1567*35238bceSAndroid Build Coastguard Worker         {draw_range_elements_base_vertex_primitive_mode_mismatch,
1568*35238bceSAndroid Build Coastguard Worker          "draw_range_elements_base_vertex_primitive_mode_mismatch", "Invalid glDrawRangeElementsBaseVertex() usage"},
1569*35238bceSAndroid Build Coastguard Worker     };
1570*35238bceSAndroid Build Coastguard Worker 
1571*35238bceSAndroid Build Coastguard Worker     return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
1572*35238bceSAndroid Build Coastguard Worker }
1573*35238bceSAndroid Build Coastguard Worker 
1574*35238bceSAndroid Build Coastguard Worker } // namespace NegativeTestShared
1575*35238bceSAndroid Build Coastguard Worker } // namespace Functional
1576*35238bceSAndroid Build Coastguard Worker } // namespace gles31
1577*35238bceSAndroid Build Coastguard Worker } // namespace deqp
1578