Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / modules / gles31 / functional / es31fNegativeBufferApiTests.cpp
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Negative Buffer API tests.
22  *//*--------------------------------------------------------------------*/
23
24 #include "es31fNegativeBufferApiTests.hpp"
25
26 #include "gluCallLogWrapper.hpp"
27
28 #include "glwDefs.hpp"
29 #include "glwEnums.hpp"
30
31 namespace deqp
32 {
33 namespace gles31
34 {
35 namespace Functional
36 {
37 namespace NegativeTestShared
38 {
39
40 using tcu::TestLog;
41 using glu::CallLogWrapper;
42 using namespace glw;
43
44 // Buffers
45 void bind_buffer (NegativeTestContext& ctx)
46 {
47         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the allowable values.");
48         ctx.glBindBuffer(-1, 0);
49         ctx.expectError(GL_INVALID_ENUM);
50         ctx.endSection();
51 }
52
53 void delete_buffers (NegativeTestContext& ctx)
54 {
55         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
56         ctx.glDeleteBuffers(-1, 0);
57         ctx.expectError(GL_INVALID_VALUE);
58         ctx.endSection();
59 }
60
61 void gen_buffers (NegativeTestContext& ctx)
62 {
63         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
64         ctx.glGenBuffers(-1, 0);
65         ctx.expectError(GL_INVALID_VALUE);
66         ctx.endSection();
67 }
68
69 void buffer_data (NegativeTestContext& ctx)
70 {
71         GLuint buffer = 0x1234;
72         ctx.glGenBuffers(1, &buffer);
73         ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
74
75         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
76         ctx.glBufferData(-1, 0, NULL, GL_STREAM_DRAW);
77         ctx.expectError(GL_INVALID_ENUM);
78         ctx.endSection();
79
80         ctx.beginSection("GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW.");
81         ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, -1);
82         ctx.expectError(GL_INVALID_ENUM);
83         ctx.endSection();
84
85         ctx.beginSection("GL_INVALID_VALUE is generated if size is negative.");
86         ctx.glBufferData(GL_ARRAY_BUFFER, -1, NULL, GL_STREAM_DRAW);
87         ctx.expectError(GL_INVALID_VALUE);
88         ctx.endSection();
89
90         ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
91         ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
92         ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STREAM_DRAW);
93         ctx.expectError(GL_INVALID_OPERATION);
94         ctx.endSection();
95
96         ctx.glDeleteBuffers(1, &buffer);
97 }
98
99 void buffer_sub_data (NegativeTestContext& ctx)
100 {
101         GLuint buffer = 0x1234;
102         ctx.glGenBuffers(1, &buffer);
103         ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
104         ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
105
106         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
107         ctx.glBufferSubData(-1, 1, 1, 0);
108         ctx.expectError(GL_INVALID_ENUM);
109         ctx.endSection();
110
111         ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
112         ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
113         ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
114         ctx.expectError(GL_INVALID_OPERATION);
115         ctx.endSection();
116
117         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object being updated is mapped.");
118         ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
119         ctx.glMapBufferRange(GL_ARRAY_BUFFER, 0, 5, GL_MAP_READ_BIT);
120         ctx.expectError(GL_NO_ERROR);
121         ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
122         ctx.expectError(GL_INVALID_OPERATION);
123         ctx.endSection();
124
125         ctx.glDeleteBuffers(1, &buffer);
126 }
127
128 void buffer_sub_data_size_offset (NegativeTestContext& ctx)
129 {
130         GLuint buffer = 0x1234;
131         ctx.glGenBuffers(1, &buffer);
132         ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
133         ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
134
135         ctx.beginSection("GL_INVALID_VALUE is generated if offset or size is negative, or if together they define a region of memory that extends beyond the buffer object's allocated data store.");
136         ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, 1, 0);
137         ctx.expectError(GL_INVALID_VALUE);
138         ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, -1, 0);
139         ctx.expectError(GL_INVALID_VALUE);
140         ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, -1, 0);
141         ctx.expectError(GL_INVALID_VALUE);
142         ctx.glBufferSubData(GL_ARRAY_BUFFER, 15, 1, 0);
143         ctx.expectError(GL_INVALID_VALUE);
144         ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 15, 0);
145         ctx.expectError(GL_INVALID_VALUE);
146         ctx.glBufferSubData(GL_ARRAY_BUFFER, 8, 8, 0);
147         ctx.expectError(GL_INVALID_VALUE);
148         ctx.endSection();
149
150         ctx.glDeleteBuffers(1, &buffer);
151 }
152
153 void clear (NegativeTestContext& ctx)
154 {
155         ctx.beginSection("GL_INVALID_VALUE is generated if any bit other than the three defined bits is set in mask.");
156         ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
157         ctx.expectError(GL_NO_ERROR);
158         ctx.glClear(0x00000200);
159         ctx.expectError(GL_INVALID_VALUE);
160         ctx.glClear(0x00001000);
161         ctx.expectError(GL_INVALID_VALUE);
162         ctx.glClear(0x00000010);
163         ctx.expectError(GL_INVALID_VALUE);
164         ctx.endSection();
165 }
166
167 void read_pixels (NegativeTestContext& ctx)
168 {
169         std::vector<GLubyte>    ubyteData       (4);
170         GLuint                                  fbo                     = 0x1234;
171
172         ctx.beginSection("Unsupported combinations of format and type will generate an GL_INVALID_OPERATION error.");
173         ctx.glReadPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ubyteData[0]);
174         ctx.expectError(GL_INVALID_OPERATION);
175         ctx.endSection();
176
177         ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
178         ctx.glReadPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
179         ctx.expectError(GL_INVALID_VALUE);
180         ctx.glReadPixels(0, 0, 1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
181         ctx.expectError(GL_INVALID_VALUE);
182         ctx.glReadPixels(0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
183         ctx.expectError(GL_INVALID_VALUE);
184         ctx.endSection();
185
186         ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
187         ctx.glGenFramebuffers(1, &fbo);
188         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
189         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
190         ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
191         ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
192         ctx.endSection();
193
194         ctx.glDeleteFramebuffers(1, &fbo);
195 }
196
197 void readn_pixels (NegativeTestContext& ctx)
198 {
199         std::vector<GLfloat>    floatData       (4);
200         std::vector<GLubyte>    ubyteData       (4);
201         GLuint                                  fbo                     = 0x1234;
202
203         if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2))
204                 && !contextSupports(ctx.getRenderContext().getType(), glu::ApiType::core(4, 5))
205                 && !ctx.isExtensionSupported("GL_KHR_robustness")
206                 && !ctx.isExtensionSupported("GL_EXT_robustness"))
207         {
208                 TCU_THROW(NotSupportedError, "GLES 3.2 or robustness extension not supported");
209         }
210
211         ctx.beginSection("Unsupported combinations of format and type will generate an GL_INVALID_OPERATION error.");
212         ctx.glReadnPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, (int)ubyteData.size(), &ubyteData[0]);
213         ctx.expectError(GL_INVALID_OPERATION);
214         ctx.endSection();
215
216         ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
217         ctx.glReadnPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
218         ctx.expectError(GL_INVALID_VALUE);
219         ctx.glReadnPixels(0, 0, 1, -1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
220         ctx.expectError(GL_INVALID_VALUE);
221         ctx.glReadnPixels(0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
222         ctx.expectError(GL_INVALID_VALUE);
223         ctx.endSection();
224
225         ctx.beginSection("GL_INVALID_OPERATION is generated by ReadnPixels if the buffer size required to store the requested data is larger than bufSize.");
226         ctx.glReadnPixels(0, 0, 0x1234, 0x1234, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
227         ctx.expectError(GL_INVALID_OPERATION);
228         ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, (int) floatData.size(), &floatData[0]);
229         ctx.expectError(GL_INVALID_OPERATION);
230         ctx.endSection();
231
232         ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
233         ctx.glGenFramebuffers(1, &fbo);
234         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
235         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
236         ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
237         ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
238         ctx.endSection();
239
240         ctx.glDeleteFramebuffers(1, &fbo);
241 }
242
243 void read_pixels_format_mismatch (NegativeTestContext& ctx)
244 {
245         std::vector<GLubyte>    ubyteData       (4);
246         std::vector<GLushort>   ushortData      (4);
247         GLint                                   readFormat      = 0x1234;
248         GLint                                   readType        = 0x1234;
249
250
251         ctx.beginSection("Unsupported combinations of format and type will generate an GL_INVALID_OPERATION error.");
252         ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
253         ctx.expectError(GL_INVALID_OPERATION);
254         ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
255         ctx.expectError(GL_INVALID_OPERATION);
256         ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
257         ctx.expectError(GL_INVALID_OPERATION);
258         ctx.endSection();
259
260         ctx.beginSection("Unsupported combinations of format and type will generate an GL_INVALID_OPERATION error.");
261         ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
262         ctx.expectError(GL_INVALID_OPERATION);
263         ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
264         ctx.expectError(GL_INVALID_OPERATION);
265         ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
266         ctx.expectError(GL_INVALID_OPERATION);
267         ctx.endSection();
268
269         ctx.beginSection("GL_RGBA/GL_UNSIGNED_BYTE is always accepted and the other acceptable pair can be discovered by querying GL_IMPLEMENTATION_COLOR_READ_FORMAT and GL_IMPLEMENTATION_COLOR_READ_TYPE.");
270         ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
271         ctx.expectError(GL_NO_ERROR);
272         ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
273         ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
274         ctx.glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]);
275         ctx.expectError(GL_NO_ERROR);
276         ctx.endSection();
277 }
278
279 void read_pixels_fbo_format_mismatch (NegativeTestContext& ctx)
280 {
281         std::vector<GLubyte>    ubyteData(4);
282         std::vector<float>              floatData(4);
283         deUint32                                fbo = 0x1234;
284         deUint32                                texture = 0x1234;
285         bool                                    isES = glu::isContextTypeES(ctx.getRenderContext().getType());
286
287         ctx.glGenTextures                       (1, &texture);
288         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
289         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
290         ctx.glGenFramebuffers           (1, &fbo);
291         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
292         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
293         ctx.expectError                         (GL_NO_ERROR);
294
295         ctx.beginSection("GL_INVALID_OPERATION is generated if currently bound framebuffer format is incompatible with format and type.");
296
297         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
298         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
299         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
300         ctx.expectError                         (GL_NO_ERROR);
301         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
302         ctx.expectError                         (isES ? GL_INVALID_OPERATION : GL_NO_ERROR);
303
304         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
305         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
306         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
307         ctx.expectError                         (GL_NO_ERROR);
308         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
309         ctx.expectError                         (GL_INVALID_OPERATION);
310
311         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
312         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
313         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
314         ctx.expectError                         (GL_NO_ERROR);
315         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
316         ctx.expectError                         (GL_INVALID_OPERATION);
317
318         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ||
319                 ctx.isExtensionSupported("GL_EXT_color_buffer_float"))
320         {
321                 ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
322                 ctx.expectError                         (GL_NO_ERROR);
323                 ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
324                 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
325                 ctx.expectError                         (GL_NO_ERROR);
326                 ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_INT, &floatData[0]);
327                 ctx.expectError                         (GL_INVALID_OPERATION);
328         }
329
330         ctx.endSection();
331
332         ctx.beginSection("GL_INVALID_OPERATION is generated if GL_READ_FRAMEBUFFER_BINDING is non-zero, the read framebuffer is complete, and the value of GL_SAMPLE_BUFFERS for the read framebuffer is greater than zero.");
333
334         int                     binding                 = -1;
335         int                     sampleBuffers = 0x1234;
336         deUint32        rbo = 0x1234;
337
338         ctx.glGenRenderbuffers(1, &rbo);
339         ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
340         ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
341         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
342
343         ctx.glGetIntegerv                       (GL_READ_FRAMEBUFFER_BINDING, &binding);
344         ctx.getLog() << TestLog::Message << "// GL_READ_FRAMEBUFFER_BINDING: " << binding << TestLog::EndMessage;
345         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
346         ctx.glGetIntegerv                       (GL_SAMPLE_BUFFERS, &sampleBuffers);
347         ctx.getLog() << TestLog::Message << "// GL_SAMPLE_BUFFERS: " << sampleBuffers << TestLog::EndMessage;
348         ctx.expectError                         (GL_NO_ERROR);
349
350         if (binding == 0 || sampleBuffers <= 0)
351         {
352                 ctx.getLog() << TestLog::Message << "// ERROR: expected GL_READ_FRAMEBUFFER_BINDING to be non-zero and GL_SAMPLE_BUFFERS to be greater than zero" << TestLog::EndMessage;
353                 ctx.fail("Got invalid value");
354         }
355         else
356         {
357                 ctx.glReadPixels        (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
358                 ctx.expectError         (GL_INVALID_OPERATION);
359         }
360
361         ctx.endSection();
362
363         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, 0);
364         ctx.glBindTexture                       (GL_TEXTURE_2D, 0);
365         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
366         ctx.glDeleteFramebuffers        (1, &fbo);
367         ctx.glDeleteTextures            (1, &texture);
368         ctx.glDeleteRenderbuffers       (1, &rbo);
369 }
370
371 void bind_buffer_range (NegativeTestContext& ctx)
372 {
373         deUint32        bufAC           = 0x1234;
374         deUint32        bufU            = 0x1234;
375         deUint32        bufTF           = 0x1234;
376         int                     maxTFSize       = 0x1234;
377         int                     maxUSize        = 0x1234;
378         int                     uAlignment      = 0x1234;
379
380         ctx.glGenBuffers(1, &bufU);
381         ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
382         ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
383
384         ctx.glGenBuffers(1, &bufTF);
385         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
386         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
387
388         ctx.glGenBuffers(1, &bufAC);
389         ctx.glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bufAC);
390         ctx.glBufferData(GL_ATOMIC_COUNTER_BUFFER, 16, NULL, GL_STREAM_DRAW);
391
392         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
393         ctx.glBindBufferRange(GL_ARRAY_BUFFER, 0, bufU, 0, 4);
394         ctx.expectError(GL_INVALID_ENUM);
395         ctx.endSection();
396
397         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and index is greater than or equal to GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
398         ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
399         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
400         ctx.expectError(GL_INVALID_VALUE);
401         ctx.endSection();
402
403         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and index is greater than or equal to GL_MAX_UNIFORM_BUFFER_BINDINGS.");
404         ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
405         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4);
406         ctx.expectError(GL_INVALID_VALUE);
407         ctx.endSection();
408
409         ctx.beginSection("GL_INVALID_VALUE is generated if size is less than or equal to zero.");
410         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1);
411         ctx.expectError(GL_INVALID_VALUE);
412         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0);
413         ctx.expectError(GL_INVALID_VALUE);
414         ctx.endSection();
415
416         ctx.beginSection("GL_INVALID_VALUE is generated if offset is less than zero.");
417         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, -1, 0);
418         ctx.expectError(GL_INVALID_VALUE);
419         ctx.endSection();
420
421         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.");
422         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
423         ctx.expectError(GL_INVALID_VALUE);
424         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
425         ctx.expectError(GL_INVALID_VALUE);
426         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
427         ctx.expectError(GL_INVALID_VALUE);
428         ctx.endSection();
429
430         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and offset is not a multiple of GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT.");
431         ctx.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uAlignment);
432         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, uAlignment+1, 4);
433         ctx.expectError(GL_INVALID_VALUE);
434         ctx.endSection();
435
436         int maxACize    = 0x1234;
437         int maxSSize    = 0x1234;
438         int ssAlignment = 0x1234;
439
440         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_ATOMIC_COUNTER_BUFFER and index is greater than or equal to GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS.");
441         ctx.glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &maxACize);
442         ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, maxACize, bufU, 0, 4);
443         ctx.expectError(GL_INVALID_VALUE);
444         ctx.endSection();
445
446         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_SHADER_STORAGE_BUFFER and index is greater than or equal to GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS.");
447         ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxSSize);
448         ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, maxSSize, bufU, 0, 4);
449         ctx.expectError(GL_INVALID_VALUE);
450         ctx.endSection();
451
452         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_ATOMIC_COUNTER_BUFFER and offset is not multiples of 4.");
453         ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, bufTF, 5, 4);
454         ctx.expectError(GL_INVALID_VALUE);
455         ctx.endSection();
456
457         ctx.glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &ssAlignment);
458
459         if (ssAlignment != 1)
460         {
461                 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_SHADER_STORAGE_BUFFER and offset is not a multiple of the value of GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT.");
462                 ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, 0, bufTF, ssAlignment+1, 4);
463                 ctx.expectError(GL_INVALID_VALUE);
464                 ctx.endSection();
465         }
466
467         ctx.glDeleteBuffers(1, &bufU);
468         ctx.glDeleteBuffers(1, &bufTF);
469         ctx.glDeleteBuffers(1, &bufAC);
470 }
471
472 void bind_buffer_base (NegativeTestContext& ctx)
473 {
474         deUint32        bufU            = 0x1234;
475         deUint32        bufTF           = 0x1234;
476         int                     maxUSize        = 0x1234;
477         int                     maxTFSize       = 0x1234;
478
479         ctx.glGenBuffers(1, &bufU);
480         ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
481         ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
482
483         ctx.glGenBuffers(1, &bufTF);
484         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
485         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
486         ctx.expectError(GL_NO_ERROR);
487
488         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
489         ctx.glBindBufferBase(-1, 0, bufU);
490         ctx.expectError(GL_INVALID_ENUM);
491         ctx.glBindBufferBase(GL_ARRAY_BUFFER, 0, bufU);
492         ctx.expectError(GL_INVALID_ENUM);
493         ctx.endSection();
494
495         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and index is greater than or equal to GL_MAX_UNIFORM_BUFFER_BINDINGS.");
496         ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
497         ctx.glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU);
498         ctx.expectError(GL_INVALID_VALUE);
499         ctx.endSection();
500
501         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER andindex is greater than or equal to GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
502         ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
503         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
504         ctx.expectError(GL_INVALID_VALUE);
505         ctx.endSection();
506
507         ctx.glDeleteBuffers(1, &bufU);
508         ctx.glDeleteBuffers(1, &bufTF);
509 }
510
511 void clear_bufferiv (NegativeTestContext& ctx)
512 {
513         std::vector<int>        data                    (32*32);
514         deUint32                        fbo                             = 0x1234;
515         deUint32                        texture                 = 0x1234;
516         int                                     maxDrawBuffers  = 0x1234;
517
518         ctx.glGenTextures                       (1, &texture);
519         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
520         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
521         ctx.glGenFramebuffers           (1, &fbo);
522         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
523         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
524         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
525         ctx.expectError                         (GL_NO_ERROR);
526
527         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
528         ctx.glClearBufferiv                     (-1, 0, &data[0]);
529         ctx.expectError                         (GL_INVALID_ENUM);
530         ctx.glClearBufferiv                     (GL_FRAMEBUFFER, 0, &data[0]);
531         ctx.expectError                         (GL_INVALID_ENUM);
532         ctx.endSection();
533
534         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL.");
535         ctx.glClearBufferiv                     (GL_DEPTH, 1, &data[0]);
536         ctx.expectError                         (GL_INVALID_ENUM);
537         ctx.glClearBufferiv                     (GL_DEPTH_STENCIL, 1, &data[0]);
538         ctx.expectError                         (GL_INVALID_ENUM);
539         ctx.endSection();
540
541         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR or GL_STENCIL and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
542         ctx.glGetIntegerv                       (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
543         ctx.glClearBufferiv                     (GL_COLOR, maxDrawBuffers, &data[0]);
544         ctx.expectError                         (GL_INVALID_VALUE);
545         ctx.endSection();
546
547         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR or GL_STENCIL and drawBuffer is negative.");
548         ctx.glClearBufferiv                     (GL_COLOR, -1, &data[0]);
549         ctx.expectError                         (GL_INVALID_VALUE);
550         ctx.endSection();
551
552         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero.");
553         ctx.glClearBufferiv                     (GL_STENCIL, 1, &data[0]);
554         ctx.expectError                         (GL_INVALID_VALUE);
555         ctx.endSection();
556
557         ctx.glDeleteFramebuffers        (1, &fbo);
558         ctx.glDeleteTextures            (1, &texture);
559 }
560
561 void clear_bufferuiv (NegativeTestContext& ctx)
562 {
563         std::vector<deUint32>   data                    (32*32);
564         deUint32                                fbo                             = 0x1234;
565         deUint32                                texture                 = 0x1234;
566         int                                             maxDrawBuffers  = 0x1234;
567
568         ctx.glGenTextures                       (1, &texture);
569         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
570         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
571         ctx.glGenFramebuffers           (1, &fbo);
572         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
573         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
574         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
575         ctx.expectError                         (GL_NO_ERROR);
576
577         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR.");
578         ctx.glClearBufferuiv            (-1, 0, &data[0]);
579         ctx.expectError                         (GL_INVALID_ENUM);
580         ctx.glClearBufferuiv            (GL_FRAMEBUFFER, 0, &data[0]);
581         ctx.expectError                         (GL_INVALID_ENUM);
582         ctx.endSection();
583
584         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL, or GL_DEPTH_STENCIL.");
585         ctx.glClearBufferuiv            (GL_DEPTH, 0, &data[0]);
586         ctx.expectError                         (GL_INVALID_ENUM);
587         ctx.glClearBufferuiv            (GL_STENCIL, 0, &data[0]);
588         ctx.expectError                         (GL_INVALID_ENUM);
589         ctx.glClearBufferuiv            (GL_DEPTH_STENCIL, 0, &data[0]);
590         ctx.expectError                         (GL_INVALID_ENUM);
591         ctx.endSection();
592
593         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
594         ctx.glGetIntegerv                       (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
595         ctx.glClearBufferuiv            (GL_COLOR, maxDrawBuffers, &data[0]);
596         ctx.expectError                         (GL_INVALID_VALUE);
597         ctx.endSection();
598
599         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
600         ctx.glClearBufferuiv            (GL_COLOR, -1, &data[0]);
601         ctx.expectError                         (GL_INVALID_VALUE);
602         ctx.endSection();
603
604         ctx.glDeleteFramebuffers        (1, &fbo);
605         ctx.glDeleteTextures            (1, &texture);
606 }
607
608 void clear_bufferfv (NegativeTestContext& ctx)
609 {
610         std::vector<float>      data                    (32*32);
611         deUint32                        fbo                             = 0x1234;
612         deUint32                        texture                 = 0x1234;
613         int                                     maxDrawBuffers  = 0x1234;
614
615         ctx.glGenTextures                       (1, &texture);
616         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
617         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
618         ctx.glGenFramebuffers           (1, &fbo);
619         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
620         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
621         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
622         ctx.expectError                         (GL_NO_ERROR);
623
624         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR or GL_DEPTH.");
625         ctx.glClearBufferfv                     (-1, 0, &data[0]);
626         ctx.expectError                         (GL_INVALID_ENUM);
627         ctx.glClearBufferfv                     (GL_FRAMEBUFFER, 0, &data[0]);
628         ctx.expectError                         (GL_INVALID_ENUM);
629         ctx.endSection();
630
631         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL.");
632         ctx.glClearBufferfv                     (GL_STENCIL, 1, &data[0]);
633         ctx.expectError                         (GL_INVALID_ENUM);
634         ctx.glClearBufferfv                     (GL_DEPTH_STENCIL, 1, &data[0]);
635         ctx.expectError                         (GL_INVALID_ENUM);
636         ctx.endSection();
637
638         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
639         ctx.glGetIntegerv                       (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
640         ctx.glClearBufferfv                     (GL_COLOR, maxDrawBuffers, &data[0]);
641         ctx.expectError                         (GL_INVALID_VALUE);
642         ctx.endSection();
643
644         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
645         ctx.glClearBufferfv                     (GL_COLOR, -1, &data[0]);
646         ctx.expectError                         (GL_INVALID_VALUE);
647         ctx.endSection();
648
649         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero.");
650         ctx.glClearBufferfv                     (GL_DEPTH, 1, &data[0]);
651         ctx.expectError                         (GL_INVALID_VALUE);
652         ctx.endSection();
653
654         ctx.glDeleteFramebuffers        (1, &fbo);
655         ctx.glDeleteTextures            (1, &texture);
656 }
657
658 void clear_bufferfi (NegativeTestContext& ctx)
659 {
660         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL.");
661         ctx.glClearBufferfi             (-1, 0, 1.0f, 1);
662         ctx.expectError                 (GL_INVALID_ENUM);
663         ctx.glClearBufferfi             (GL_FRAMEBUFFER, 0, 1.0f, 1);
664         ctx.expectError                 (GL_INVALID_ENUM);
665         ctx.glClearBufferfi             (GL_DEPTH, 0, 1.0f, 1);
666         ctx.expectError                 (GL_INVALID_ENUM);
667         ctx.glClearBufferfi             (GL_STENCIL, 0, 1.0f, 1);
668         ctx.expectError                 (GL_INVALID_ENUM);
669         ctx.glClearBufferfi             (GL_COLOR, 0, 1.0f, 1);
670         ctx.expectError                 (GL_INVALID_ENUM);
671         ctx.endSection();
672
673         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero.");
674         ctx.glClearBufferfi             (GL_DEPTH_STENCIL, 1, 1.0f, 1);
675         ctx.expectError                 (GL_INVALID_VALUE);
676         ctx.endSection();
677 }
678
679 void copy_buffer_sub_data (NegativeTestContext& ctx)
680 {
681         deUint32                                buf[2];
682         std::vector<float>              data    (32*32);
683
684         ctx.glGenBuffers                        (2, buf);
685         ctx.glBindBuffer                        (GL_COPY_READ_BUFFER, buf[0]);
686         ctx.glBufferData                        (GL_COPY_READ_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
687         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[1]);
688         ctx.glBufferData                        (GL_COPY_WRITE_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
689         ctx.expectError                         (GL_NO_ERROR);
690
691         ctx.beginSection("GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative.");
692         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, -4);
693         ctx.expectError                         (GL_INVALID_VALUE);
694         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, -1, 0, 4);
695         ctx.expectError                         (GL_INVALID_VALUE);
696         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, -1, 4);
697         ctx.expectError                         (GL_INVALID_VALUE);
698         ctx.endSection();
699
700         ctx.beginSection("GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.");
701         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
702         ctx.expectError                         (GL_INVALID_VALUE);
703         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16);
704         ctx.expectError                         (GL_INVALID_VALUE);
705         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4);
706         ctx.expectError                         (GL_INVALID_VALUE);
707         ctx.endSection();
708
709         ctx.beginSection("GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.");
710         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
711         ctx.expectError                         (GL_INVALID_VALUE);
712         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16);
713         ctx.expectError                         (GL_INVALID_VALUE);
714         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4);
715         ctx.expectError                         (GL_INVALID_VALUE);
716         ctx.endSection();
717
718         ctx.beginSection("GL_INVALID_VALUE is generated if the same buffer object is bound to both readtarget and writetarget and the ranges [readoffset, readoffset + size) and [writeoffset, writeoffset + size) overlap.");
719         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[0]);
720         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4);
721         ctx.expectError                         (GL_NO_ERROR);
722         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4);
723         ctx.expectError                         (GL_INVALID_VALUE);
724         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18);
725         ctx.expectError                         (GL_INVALID_VALUE);
726         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[1]);
727         ctx.endSection();
728
729         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget.");
730         ctx.glBindBuffer                        (GL_COPY_READ_BUFFER, 0);
731         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
732         ctx.expectError                         (GL_INVALID_OPERATION);
733
734         ctx.glBindBuffer                        (GL_COPY_READ_BUFFER, buf[0]);
735         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, 0);
736         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
737         ctx.expectError                         (GL_INVALID_OPERATION);
738
739         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[1]);
740         ctx.endSection();
741
742         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped.");
743         ctx.glMapBufferRange            (GL_COPY_READ_BUFFER, 0, 4, GL_MAP_READ_BIT);
744         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
745         ctx.expectError                         (GL_INVALID_OPERATION);
746         ctx.glUnmapBuffer                       (GL_COPY_READ_BUFFER);
747
748         ctx.glMapBufferRange            (GL_COPY_WRITE_BUFFER, 0, 4, GL_MAP_READ_BIT);
749         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
750         ctx.expectError                         (GL_INVALID_OPERATION);
751         ctx.glUnmapBuffer                       (GL_COPY_WRITE_BUFFER);
752         ctx.endSection();
753
754         ctx.glDeleteBuffers(2, buf);
755 }
756
757 void draw_buffers (NegativeTestContext& ctx)
758 {
759         deUint32                                fbo                                             = 0x1234;
760         deUint32                                texture                                 = 0x1234;
761         int                                             maxDrawBuffers                  = 0x1234;
762         int                                             maxColorAttachments             = -1;
763         ctx.glGetIntegerv               (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
764         ctx.glGetIntegerv               (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
765         std::vector<deUint32>   values                                  (maxDrawBuffers+1);
766         std::vector<deUint32>   attachments                             (4);
767         std::vector<GLfloat>    data                                    (32*32);
768         bool                                    isES                                    = glu::isContextTypeES(ctx.getRenderContext().getType());
769         values[0]                               = GL_NONE;
770         values[1]                               = GL_BACK;
771         values[2]                               = GL_COLOR_ATTACHMENT0;
772         values[3]                               = GL_DEPTH_ATTACHMENT;
773         attachments[0]                  = (glw::GLenum) (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
774         attachments[1]                  = GL_COLOR_ATTACHMENT0;
775         attachments[2]                  = GL_COLOR_ATTACHMENT1;
776         attachments[3]                  = GL_NONE;
777
778         ctx.glGenTextures                       (1, &texture);
779         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
780         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
781         ctx.glGenFramebuffers           (1, &fbo);
782         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
783         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
784         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
785         ctx.expectError                         (GL_NO_ERROR);
786
787         ctx.beginSection("GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.");
788         ctx.glDrawBuffers                       (2, &values[2]);
789         ctx.expectError                         (GL_INVALID_ENUM);
790         ctx.endSection();
791
792         ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to a draw framebuffer and DrawBuffers is supplied with BACK or COLOR_ATTACHMENTm where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS.");
793         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
794         ctx.glDrawBuffers                       (1, &values[1]);
795         ctx.expectError                         (isES ? GL_INVALID_OPERATION : GL_INVALID_ENUM);
796         ctx.glDrawBuffers                       (4, &attachments[0]);
797         ctx.expectError                         (GL_INVALID_OPERATION);
798         ctx.endSection();
799
800         ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1.");
801         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
802         ctx.glDrawBuffers                       (2, &values[0]);
803         ctx.expectError                         (GL_INVALID_OPERATION);
804         ctx.endSection();
805
806         ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and the value in bufs is one of the GL_COLOR_ATTACHMENTn tokens.");
807         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
808         ctx.glDrawBuffers                       (1, &values[2]);
809         ctx.expectError                         (GL_INVALID_OPERATION);
810         ctx.endSection();
811
812         ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to a framebuffer object and the ith buffer listed in bufs is anything other than GL_NONE or GL_COLOR_ATTACHMENTSi.");
813         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
814         ctx.glDrawBuffers                       (1, &values[1]);
815         ctx.expectError                         (isES ? GL_INVALID_OPERATION : GL_INVALID_ENUM);
816         ctx.glDrawBuffers                       (4, &attachments[0]);
817         ctx.expectError                         (GL_INVALID_OPERATION);
818
819         ctx.endSection();
820
821         ctx.beginSection("GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.");
822         ctx.glDrawBuffers                       (-1, &values[1]);
823         ctx.expectError                         (GL_INVALID_VALUE);
824         ctx.glDrawBuffers                       (maxDrawBuffers+1, &values[0]);
825         ctx.expectError                         (GL_INVALID_VALUE);
826         ctx.endSection();
827
828         ctx.glDeleteTextures(1, &texture);
829         ctx.glDeleteFramebuffers(1, &fbo);
830 }
831
832 void flush_mapped_buffer_range (NegativeTestContext& ctx)
833 {
834         deUint32                                buf             = 0x1234;
835         std::vector<GLfloat>    data    (32);
836
837         ctx.glGenBuffers                        (1, &buf);
838         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
839         ctx.glBufferData                        (GL_ARRAY_BUFFER, 32, &data[0], GL_STATIC_READ);
840         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
841         ctx.expectError                         (GL_NO_ERROR);
842
843         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted values.");
844         ctx.glFlushMappedBufferRange(-1, 0, 16);
845         ctx.expectError                         (GL_INVALID_ENUM);
846         ctx.endSection();
847
848         ctx.beginSection("GL_INVALID_VALUE is generated if offset or length is negative, or if offset + length exceeds the size of the mapping.");
849         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, -1, 1);
850         ctx.expectError                         (GL_INVALID_VALUE);
851         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, -1);
852         ctx.expectError                         (GL_INVALID_VALUE);
853         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 12, 8);
854         ctx.expectError                         (GL_INVALID_VALUE);
855         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 24, 4);
856         ctx.expectError                         (GL_INVALID_VALUE);
857         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 24);
858         ctx.expectError                         (GL_INVALID_VALUE);
859         ctx.endSection();
860
861         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
862         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, 0);
863         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
864         ctx.expectError                         (GL_INVALID_OPERATION);
865         ctx.endSection();
866
867         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer bound to target is not mapped, or is mapped without the GL_MAP_FLUSH_EXPLICIT flag.");
868         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
869         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
870         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
871         ctx.expectError                         (GL_INVALID_OPERATION);
872         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
873         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
874         ctx.expectError                         (GL_INVALID_OPERATION);
875         ctx.endSection();
876
877         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
878         ctx.glDeleteBuffers                     (1, &buf);
879 }
880
881 void map_buffer_range (NegativeTestContext& ctx)
882 {
883         deUint32                                buf             = 0x1234;
884         std::vector<GLfloat>    data    (32);
885
886         ctx.glGenBuffers                        (1, &buf);
887         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
888         ctx.glBufferData                        (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
889         ctx.expectError                         (GL_NO_ERROR);
890
891         ctx.beginSection("GL_INVALID_VALUE is generated if either of offset or length is negative.");
892         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, -1, 1, GL_MAP_READ_BIT);
893         ctx.expectError                         (GL_INVALID_VALUE);
894
895         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 1, -1, GL_MAP_READ_BIT);
896         ctx.expectError                         (GL_INVALID_VALUE);
897         ctx.endSection();
898
899         ctx.beginSection("GL_INVALID_VALUE is generated if offset + length is greater than the value of GL_BUFFER_SIZE.");
900         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 33, GL_MAP_READ_BIT);
901         ctx.expectError                         (GL_INVALID_VALUE);
902
903         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 32, 1, GL_MAP_READ_BIT);
904         ctx.expectError                         (GL_INVALID_VALUE);
905
906         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 16, 17, GL_MAP_READ_BIT);
907         ctx.expectError                         (GL_INVALID_VALUE);
908         ctx.endSection();
909
910         ctx.beginSection("GL_INVALID_VALUE is generated if access has any bits set other than those accepted.");
911         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | 0x1000);
912         ctx.expectError                         (GL_INVALID_VALUE);
913
914         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | 0x1000);
915         ctx.expectError                         (GL_INVALID_VALUE);
916         ctx.endSection();
917
918         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer is already in a mapped state.");
919         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
920         ctx.expectError                         (GL_NO_ERROR);
921         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT);
922         ctx.expectError                         (GL_INVALID_OPERATION);
923         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
924         ctx.endSection();
925
926         ctx.beginSection("GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.");
927         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
928         ctx.expectError                         (GL_INVALID_OPERATION);
929         ctx.endSection();
930
931         ctx.beginSection("GL_INVALID_OPERATION is generated if length is 0");
932         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 0, GL_MAP_READ_BIT);
933         ctx.expectError                         (GL_INVALID_OPERATION);
934         ctx.endSection();
935
936         ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_READ_BIT is set and any of GL_MAP_INVALIDATE_RANGE_BIT, GL_MAP_INVALIDATE_BUFFER_BIT, or GL_MAP_UNSYNCHRONIZED_BIT is set.");
937         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
938         ctx.expectError                         (GL_INVALID_OPERATION);
939
940         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
941         ctx.expectError                         (GL_INVALID_OPERATION);
942
943         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
944         ctx.expectError                         (GL_INVALID_OPERATION);
945         ctx.endSection();
946
947         ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.");
948         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
949         ctx.expectError                         (GL_INVALID_OPERATION);
950         ctx.endSection();
951
952         ctx.glDeleteBuffers                     (1, &buf);
953 }
954
955 void read_buffer (NegativeTestContext& ctx)
956 {
957         deUint32        fbo                                     = 0x1234;
958         deUint32        texture                         = 0x1234;
959         int                     maxColorAttachments     = 0x1234;
960         bool            isES                            = glu::isContextTypeES(ctx.getRenderContext().getType());
961
962         ctx.glGetIntegerv                       (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
963         ctx.glGenTextures                       (1, &texture);
964         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
965         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
966         ctx.glGenFramebuffers           (1, &fbo);
967         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
968         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
969         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
970         ctx.expectError                         (GL_NO_ERROR);
971
972         ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_BACK, GL_NONE, or GL_COLOR_ATTACHMENTi.");
973         ctx.glReadBuffer                        (GL_NONE);
974         ctx.expectError                         (GL_NO_ERROR);
975         ctx.glReadBuffer                        (1);
976         ctx.expectError                         (GL_INVALID_ENUM);
977         ctx.glReadBuffer                        (GL_FRAMEBUFFER);
978         ctx.expectError                         (GL_INVALID_ENUM);
979         ctx.glReadBuffer                        (GL_COLOR_ATTACHMENT0 - 1);
980         ctx.expectError                         (GL_INVALID_ENUM);
981         ctx.glReadBuffer                        (GL_FRONT);
982         ctx.expectError                         (isES ? GL_INVALID_ENUM : GL_INVALID_OPERATION);
983
984         // \ note Spec isn't actually clear here, but it is safe to assume that
985         //                GL_DEPTH_ATTACHMENT can't be interpreted as GL_COLOR_ATTACHMENTm
986         //                where m = (GL_DEPTH_ATTACHMENT - GL_COLOR_ATTACHMENT0).
987         ctx.glReadBuffer                        (GL_DEPTH_ATTACHMENT);
988         ctx.expectError                         (GL_INVALID_ENUM);
989         ctx.glReadBuffer                        (GL_STENCIL_ATTACHMENT);
990         ctx.expectError                         (GL_INVALID_ENUM);
991         ctx.glReadBuffer                        (GL_STENCIL_ATTACHMENT+1);
992         ctx.expectError                         (GL_INVALID_ENUM);
993         ctx.glReadBuffer                        (0xffffffffu);
994         ctx.expectError                         (GL_INVALID_ENUM);
995         ctx.endSection();
996
997         ctx.beginSection("GL_INVALID_OPERATION error is generated if src is GL_BACK or if src is GL_COLOR_ATTACHMENTm where m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
998         ctx.glReadBuffer                        (GL_BACK);
999         ctx.expectError                         (GL_INVALID_OPERATION);
1000         ctx.glReadBuffer                        (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
1001         ctx.expectError                         (GL_INVALID_OPERATION);
1002
1003         if (GL_COLOR_ATTACHMENT0+maxColorAttachments < GL_DEPTH_ATTACHMENT-1)
1004         {
1005                 ctx.glReadBuffer                        (GL_DEPTH_ATTACHMENT - 1);
1006                 ctx.expectError                         (GL_INVALID_OPERATION);
1007         }
1008
1009         ctx.endSection();
1010
1011         ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK.");
1012         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
1013         ctx.glReadBuffer                        (GL_COLOR_ATTACHMENT0);
1014         ctx.expectError                         (GL_INVALID_OPERATION);
1015         ctx.endSection();
1016
1017         ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is a named framebuffer and mode is not GL_NONE or GL_COLOR_ATTACHMENTi.");
1018         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
1019         ctx.glReadBuffer                        (GL_BACK);
1020         ctx.expectError                         (GL_INVALID_OPERATION);
1021         ctx.endSection();
1022
1023         ctx.glDeleteTextures(1, &texture);
1024         ctx.glDeleteFramebuffers(1, &fbo);
1025 }
1026
1027 void unmap_buffer (NegativeTestContext& ctx)
1028 {
1029         deUint32                                buf             = 0x1234;
1030         std::vector<GLfloat>    data    (32);
1031
1032         ctx.glGenBuffers                        (1, &buf);
1033         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
1034         ctx.glBufferData                        (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
1035         ctx.expectError                         (GL_NO_ERROR);
1036
1037         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer data store is already in an unmapped state.");
1038         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
1039         ctx.expectError                         (GL_INVALID_OPERATION);
1040         ctx.endSection();
1041
1042         ctx.glDeleteBuffers                     (1, &buf);
1043 }
1044 // Framebuffer Objects
1045
1046 void bind_framebuffer (NegativeTestContext& ctx)
1047 {
1048         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER.");
1049         ctx.glBindFramebuffer(-1, 0);
1050         ctx.expectError(GL_INVALID_ENUM);
1051         ctx.glBindFramebuffer(GL_RENDERBUFFER, 0);
1052         ctx.expectError(GL_INVALID_ENUM);
1053         ctx.endSection();
1054 }
1055
1056 void bind_renderbuffer (NegativeTestContext& ctx)
1057 {
1058         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1059         ctx.glBindRenderbuffer(-1, 0);
1060         ctx.expectError(GL_INVALID_ENUM);
1061         ctx.glBindRenderbuffer(GL_FRAMEBUFFER, 0);
1062         ctx.expectError(GL_INVALID_ENUM);
1063         ctx.endSection();
1064 }
1065
1066 void check_framebuffer_status (NegativeTestContext& ctx)
1067 {
1068         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER..");
1069         ctx.glCheckFramebufferStatus(-1);
1070         ctx.expectError(GL_INVALID_ENUM);
1071         ctx.glCheckFramebufferStatus(GL_RENDERBUFFER);
1072         ctx.expectError(GL_INVALID_ENUM);
1073         ctx.endSection();
1074 }
1075
1076 void gen_framebuffers (NegativeTestContext& ctx)
1077 {
1078         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1079         ctx.glGenFramebuffers(-1, 0);
1080         ctx.expectError(GL_INVALID_VALUE);
1081         ctx.endSection();
1082 }
1083
1084 void gen_renderbuffers (NegativeTestContext& ctx)
1085 {
1086         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1087         ctx.glGenRenderbuffers(-1, 0);
1088         ctx.expectError(GL_INVALID_VALUE);
1089         ctx.endSection();
1090 }
1091
1092 void delete_framebuffers (NegativeTestContext& ctx)
1093 {
1094         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1095         ctx.glDeleteFramebuffers(-1, 0);
1096         ctx.expectError(GL_INVALID_VALUE);
1097         ctx.endSection();
1098 }
1099
1100 void delete_renderbuffers (NegativeTestContext& ctx)
1101 {
1102         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1103         ctx.glDeleteRenderbuffers(-1, 0);
1104         ctx.expectError(GL_INVALID_VALUE);
1105         ctx.endSection();
1106 }
1107
1108 void framebuffer_renderbuffer (NegativeTestContext& ctx)
1109 {
1110         GLuint fbo = 0x1234;
1111         GLuint rbo = 0x1234;
1112         ctx.glGenFramebuffers(1, &fbo);
1113         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1114         ctx.glGenRenderbuffers(1, &rbo);
1115
1116         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1117         ctx.glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1118         ctx.expectError(GL_INVALID_ENUM);
1119         ctx.endSection();
1120
1121         ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1122         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, -1, GL_RENDERBUFFER, 0);
1123         ctx.expectError(GL_INVALID_ENUM);
1124         ctx.endSection();
1125
1126         ctx.beginSection("GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
1127         ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1128         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
1129         ctx.expectError(GL_INVALID_ENUM);
1130         ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
1131         ctx.endSection();
1132
1133         ctx.beginSection("GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
1134         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
1135         ctx.expectError(GL_INVALID_OPERATION);
1136         ctx.endSection();
1137
1138         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1139         ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1140         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1141         ctx.expectError(GL_INVALID_OPERATION);
1142         ctx.endSection();
1143
1144         ctx.glDeleteRenderbuffers(1, &rbo);
1145         ctx.glDeleteFramebuffers(1, &fbo);
1146 }
1147
1148 void framebuffer_texture (NegativeTestContext& ctx)
1149 {
1150         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1151         {
1152                 GLuint fbo = 0x1234;
1153                 GLuint texture[] = {0x1234, 0x1234};
1154
1155                 ctx.glGenFramebuffers(1, &fbo);
1156                 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1157                 ctx.glGenTextures(2, texture);
1158                 ctx.glBindTexture(GL_TEXTURE_2D, texture[0]);
1159                 ctx.glBindTexture(GL_TEXTURE_BUFFER, texture[1]);
1160                 ctx.expectError(GL_NO_ERROR);
1161
1162                 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1163                 ctx.glFramebufferTexture(-1, GL_COLOR_ATTACHMENT0, texture[0], 0);
1164                 ctx.expectError(GL_INVALID_ENUM);
1165                 ctx.endSection();
1166
1167                 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1168                 ctx.glFramebufferTexture(GL_FRAMEBUFFER, -1, texture[0], 0);
1169                 ctx.expectError(GL_INVALID_ENUM);
1170                 ctx.endSection();
1171
1172                 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1173                 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0);
1174                 ctx.expectError(GL_INVALID_VALUE);
1175                 ctx.endSection();
1176
1177                 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1178                 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1179                 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0);
1180                 ctx.expectError(GL_INVALID_OPERATION);
1181                 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1182                 ctx.endSection();
1183
1184                 ctx.beginSection("GL_INVALID_OPERATION is generated by if texture is a buffer texture.");
1185                 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture[1], 0);
1186                 ctx.expectError(GL_INVALID_OPERATION);
1187                 ctx.endSection();
1188
1189                 ctx.glDeleteFramebuffers(1, &fbo);
1190                 ctx.glDeleteBuffers(2, texture);
1191         }
1192 }
1193
1194 void framebuffer_texture2d (NegativeTestContext& ctx)
1195 {
1196         GLuint  fbo                             = 0x1234;
1197         GLuint  tex2D                   = 0x1234;
1198         GLuint  texCube                 = 0x1234;
1199         GLuint  tex2DMS                 = 0x1234;
1200         GLint   maxTexSize              = 0x1234;
1201         GLint   maxTexCubeSize  = 0x1234;
1202         int             maxSize                 = 0x1234;
1203
1204         ctx.glGenFramebuffers(1, &fbo);
1205         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1206         ctx.glGenTextures(1, &tex2D);
1207         ctx.glBindTexture(GL_TEXTURE_2D, tex2D);
1208         ctx.glGenTextures(1, &texCube);
1209         ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
1210         ctx.glGenTextures(1, &tex2DMS);
1211         ctx.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex2DMS);
1212         ctx.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
1213         ctx.glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxTexCubeSize);
1214         ctx.expectError(GL_NO_ERROR);
1215
1216         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1217         ctx.glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1218         ctx.expectError(GL_INVALID_ENUM);
1219         ctx.endSection();
1220
1221         ctx.beginSection("GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
1222         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
1223         ctx.expectError(GL_INVALID_ENUM);
1224         ctx.endSection();
1225
1226         ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not an accepted token.");
1227         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, -1, GL_TEXTURE_2D, tex2D, 0);
1228         ctx.expectError(GL_INVALID_ENUM);
1229         ctx.endSection();
1230
1231         ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.");
1232         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1233         ctx.expectError(GL_INVALID_VALUE);
1234         maxSize = deLog2Floor32(maxTexSize) + 1;
1235         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize);
1236         ctx.expectError(GL_INVALID_VALUE);
1237         maxSize = deLog2Floor32(maxTexCubeSize) + 1;
1238         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize);
1239         ctx.expectError(GL_INVALID_VALUE);
1240         ctx.endSection();
1241
1242         ctx.beginSection("GL_INVALID_VALUE is generated if level is larger than maximum texture size.");
1243         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxTexSize + 1);
1244         ctx.expectError(GL_INVALID_VALUE);
1245         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1246         ctx.expectError(GL_INVALID_VALUE);
1247         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, maxTexCubeSize + 1);
1248         ctx.expectError(GL_INVALID_VALUE);
1249         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, -1);
1250         ctx.expectError(GL_INVALID_VALUE);
1251         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2DMS, 1);
1252         ctx.expectError(GL_INVALID_VALUE);
1253         ctx.endSection();
1254
1255         ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1256         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
1257         ctx.expectError(GL_INVALID_OPERATION);
1258         ctx.endSection();
1259
1260         ctx.beginSection("GL_INVALID_OPERATION is generated if textarget and texture are not compatible.");
1261         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
1262         ctx.expectError(GL_INVALID_OPERATION);
1263         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2D, 0);
1264         ctx.expectError(GL_INVALID_OPERATION);
1265         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
1266         ctx.expectError(GL_INVALID_OPERATION);
1267         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2DMS, 0);
1268         ctx.expectError(GL_INVALID_OPERATION);
1269         ctx.glDeleteTextures(1, &tex2D);
1270         ctx.glDeleteTextures(1, &texCube);
1271         ctx.glDeleteTextures(1, &tex2DMS);
1272         ctx.endSection();
1273
1274         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1275         ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1276         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1277         ctx.expectError(GL_INVALID_OPERATION);
1278         ctx.endSection();
1279
1280         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1281         {
1282                 GLuint texBuf = 0x1234;
1283                 ctx.beginSection("GL_INVALID_OPERATION error is generated if texture is the name of a buffer texture.");
1284                 ctx.glGenTextures(1, &texBuf);
1285                 ctx.glBindTexture(GL_TEXTURE_BUFFER, texBuf);
1286                 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1287                 ctx.expectError(GL_NO_ERROR);
1288                 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texBuf, 0);
1289                 ctx.expectError(GL_INVALID_OPERATION);
1290                 ctx.endSection();
1291         }
1292
1293         ctx.glDeleteFramebuffers(1, &fbo);
1294 }
1295
1296 void renderbuffer_storage (NegativeTestContext& ctx)
1297 {
1298         deUint32        rbo             = 0x1234;
1299         GLint           maxSize = 0x1234;
1300         bool            isES    = glu::isContextTypeES(ctx.getRenderContext().getType());
1301
1302         ctx.glGenRenderbuffers          (1, &rbo);
1303         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo);
1304
1305         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1306         ctx.glRenderbufferStorage       (-1, GL_RGBA4, 1, 1);
1307         ctx.expectError                         (GL_INVALID_ENUM);
1308         ctx.glRenderbufferStorage       (GL_FRAMEBUFFER, GL_RGBA4, 1, 1);
1309         ctx.expectError                         (GL_INVALID_ENUM);
1310         ctx.endSection();
1311
1312         ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1313         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, -1, 1, 1);
1314         ctx.expectError                         (GL_INVALID_ENUM);
1315
1316         if (!ctx.isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1317         {
1318                 ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGB16F, 1, 1);
1319                 ctx.expectError                         (isES ? GL_INVALID_ENUM : GL_NO_ERROR);
1320         }
1321
1322         if (!ctx.isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1323         {
1324                 ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA8_SNORM, 1, 1);
1325                 ctx.expectError                         (isES ? GL_INVALID_ENUM : GL_NO_ERROR);
1326         }
1327
1328         ctx.endSection();
1329
1330         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1331         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, -1, 1);
1332         ctx.expectError                         (GL_INVALID_VALUE);
1333         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, 1, -1);
1334         ctx.expectError                         (GL_INVALID_VALUE);
1335         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, -1, -1);
1336         ctx.expectError                         (GL_INVALID_VALUE);
1337         ctx.endSection();
1338
1339         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1340         ctx.glGetIntegerv                       (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1341         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
1342         ctx.expectError                         (GL_INVALID_VALUE);
1343         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
1344         ctx.expectError                         (GL_INVALID_VALUE);
1345         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
1346         ctx.expectError                         (GL_INVALID_VALUE);
1347         ctx.endSection();
1348
1349         ctx.glDeleteRenderbuffers(1, &rbo);
1350 }
1351
1352 void blit_framebuffer (NegativeTestContext& ctx)
1353 {
1354         deUint32                                        fbo[2];
1355         deUint32                                        rbo[2];
1356         deUint32                                        texture[2];
1357         deUint32                                        blankFrameBuffer;
1358
1359         ctx.glGenFramebuffers           (1, &blankFrameBuffer);
1360         ctx.glGenFramebuffers           (2, fbo);
1361         ctx.glGenTextures                       (2, texture);
1362         ctx.glGenRenderbuffers          (2, rbo);
1363
1364         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1365         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo[0]);
1366         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, fbo[0]);
1367
1368         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1369         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1370         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1371         ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1372         ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1373
1374         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[1]);
1375         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo[1]);
1376         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1377
1378         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1379         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1380         ctx.glFramebufferTexture2D      (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1381         ctx.glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1382         ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1383         ctx.expectError                         (GL_NO_ERROR);
1384
1385         ctx.beginSection("GL_INVALID_VALUE is generated if mask contains any bits other than GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, or GL_STENCIL_BUFFER_BIT.");
1386         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 1, GL_NEAREST);
1387         ctx.expectError                         (GL_INVALID_VALUE);
1388         ctx.endSection();
1389
1390         ctx.beginSection("GL_INVALID_ENUM is generated if filter is not GL_LINEAR or GL_NEAREST.");
1391         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, 0);
1392         ctx.expectError                         (GL_INVALID_ENUM);
1393         ctx.endSection();
1394
1395         ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains any of the GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT and filter is not GL_NEAREST.");
1396         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1397         ctx.expectError                         (GL_INVALID_OPERATION);
1398         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_LINEAR);
1399         ctx.expectError                         (GL_INVALID_OPERATION);
1400         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1401         ctx.expectError                         (GL_INVALID_OPERATION);
1402         ctx.endSection();
1403
1404         ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format.");
1405         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1406
1407         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1408         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1409         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32UI, draw buffer: GL_RGBA" << TestLog::EndMessage;
1410         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1411         ctx.expectError                         (GL_INVALID_OPERATION);
1412
1413         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1414         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1415         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA" << TestLog::EndMessage;
1416         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1417         ctx.expectError                         (GL_INVALID_OPERATION);
1418
1419         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1420         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1421         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[1]);
1422         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1423         ctx.glFramebufferTexture2D      (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1424         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA8, draw buffer: GL_RGBA32I" << TestLog::EndMessage;
1425         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1426         ctx.expectError                         (GL_INVALID_OPERATION);
1427         ctx.endSection();
1428
1429         ctx.beginSection("GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.");
1430         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1431         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1432         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1433         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1434         ctx.glFramebufferTexture2D      (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1435         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage;
1436         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR);
1437         ctx.expectError                         (GL_INVALID_OPERATION);
1438         ctx.endSection();
1439
1440         ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT and the source and destination depth and stencil formats do not match.");
1441         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo[0]);
1442         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32);
1443         ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1444         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1445         ctx.expectError                         (GL_INVALID_OPERATION);
1446         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1447         ctx.expectError                         (GL_INVALID_OPERATION);
1448         ctx.endSection();
1449
1450         ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the read or draw framebuffer is not framebuffer complete.");
1451         ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1452         ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1453         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1454         ctx.expectError                         (GL_NO_ERROR);
1455         ctx.getLog() << TestLog::Message << "// incomplete read framebuffer" << TestLog::EndMessage;
1456         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, blankFrameBuffer);
1457         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1458         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1459         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1460         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1461         ctx.expectError                         (GL_INVALID_FRAMEBUFFER_OPERATION);
1462         ctx.getLog() << TestLog::Message << "// incomplete draw framebuffer" << TestLog::EndMessage;
1463         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, fbo[1]);
1464         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1465         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1466         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1467         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1468         ctx.expectError                         (GL_INVALID_FRAMEBUFFER_OPERATION);
1469         ctx.getLog() << TestLog::Message << "// incomplete read and draw framebuffer" << TestLog::EndMessage;
1470         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, blankFrameBuffer);
1471         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1472         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1473         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1474         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1475         ctx.expectError                         (GL_INVALID_FRAMEBUFFER_OPERATION);
1476         // restore
1477         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, fbo[0]);
1478         ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1479         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1480         ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1481         ctx.endSection();
1482
1483         bool isES = glu::isContextTypeES(ctx.getRenderContext().getType());
1484         ctx.beginSection("GL_INVALID_OPERATION is generated if the source and destination buffers are identical.");
1485         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[0]);
1486         ctx.expectError                         (GL_NO_ERROR);
1487         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1488         ctx.expectError                         (isES ? GL_INVALID_OPERATION : GL_NO_ERROR);
1489         // restore
1490         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1491         ctx.endSection();
1492
1493         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
1494         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, 0);
1495         ctx.glDeleteFramebuffers        (2, fbo);
1496         ctx.glDeleteFramebuffers        (1, &blankFrameBuffer);
1497         ctx.glDeleteTextures            (2, texture);
1498         ctx.glDeleteRenderbuffers       (2, rbo);
1499 }
1500
1501 void blit_framebuffer_multisample (NegativeTestContext& ctx)
1502 {
1503         deUint32                                                        fbo[2];
1504         deUint32                                                        rbo[2];
1505
1506         ctx.glGenFramebuffers                           (2, fbo);
1507         ctx.glGenRenderbuffers                          (2, rbo);
1508
1509         ctx.glBindRenderbuffer                          (GL_RENDERBUFFER, rbo[0]);
1510         ctx.glBindFramebuffer                           (GL_READ_FRAMEBUFFER, fbo[0]);
1511         ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1512         ctx.glFramebufferRenderbuffer           (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
1513         ctx.glCheckFramebufferStatus            (GL_READ_FRAMEBUFFER);
1514
1515         ctx.glBindRenderbuffer                          (GL_RENDERBUFFER, rbo[1]);
1516         ctx.glBindFramebuffer                           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1517
1518         ctx.expectError                                         (GL_NO_ERROR);
1519
1520         if (!ctx.isExtensionSupported("GL_NV_framebuffer_multisample"))
1521         {
1522                 bool isES = glu::isContextTypeES(ctx.getRenderContext().getType());
1523
1524                 ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_SAMPLE_BUFFERS for the draw buffer is greater than zero.");
1525                 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1526                 ctx.glFramebufferRenderbuffer           (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1527                 ctx.glBlitFramebuffer                           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1528                 ctx.expectError                                         (isES ? GL_INVALID_OPERATION : GL_NO_ERROR);
1529                 ctx.endSection();
1530
1531                 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for the read buffer is greater than zero and the formats of draw and read buffers are not identical.");
1532                 ctx.glRenderbufferStorage                       (GL_RENDERBUFFER, GL_RGBA4, 32, 32);
1533                 ctx.glFramebufferRenderbuffer           (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1534                 ctx.glBlitFramebuffer                           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1535                 ctx.expectError                                         (isES ? GL_INVALID_OPERATION : GL_NO_ERROR);
1536                 ctx.endSection();
1537
1538                 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for the read buffer is greater than zero and the source and destination rectangles are not defined with the same (X0, Y0) and (X1, Y1) bounds.");
1539                 ctx.glRenderbufferStorage                       (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1540                 ctx.glFramebufferRenderbuffer           (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1541                 ctx.glBlitFramebuffer                           (0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1542                 ctx.expectError                                         (isES ? GL_INVALID_OPERATION : GL_NO_ERROR);
1543                 ctx.endSection();
1544         }
1545
1546         ctx.glBindFramebuffer                           (GL_FRAMEBUFFER, 0);
1547         ctx.glDeleteRenderbuffers                       (2, rbo);
1548         ctx.glDeleteFramebuffers                        (2, fbo);
1549 }
1550
1551 void framebuffer_texture_layer (NegativeTestContext& ctx)
1552 {
1553         deUint32                                                fbo                                     = 0x1234;
1554         deUint32                                                tex3D                           = 0x1234;
1555         deUint32                                                tex2DArray                      = 0x1234;
1556         deUint32                                                tex2D                           = 0x1234;
1557         deUint32                                                tex2DMSArray            = 0x1234;
1558         deUint32                                                texBuffer                       = 0x1234;
1559         int                                                             max3DTexSize            = 0x1234;
1560         int                                                             maxTexSize                      = 0x1234;
1561         int                                                             maxArrayTexLayers       = 0x1234;
1562         int                                                             log2Max3DTexSize        = 0x1234;
1563         int                                                             log2MaxTexSize          = 0x1234;
1564
1565         ctx.glGetIntegerv                               (GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize);
1566         ctx.glGetIntegerv                               (GL_MAX_TEXTURE_SIZE, &maxTexSize);
1567         ctx.glGetIntegerv                               (GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers);
1568
1569         ctx.glGenFramebuffers                   (1, &fbo);
1570         ctx.glGenTextures                               (1, &tex3D);
1571         ctx.glGenTextures                               (1, &tex2DArray);
1572         ctx.glGenTextures                               (1, &tex2D);
1573         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1574
1575         ctx.glBindTexture                               (GL_TEXTURE_3D, tex3D);
1576         ctx.glTexImage3D                                (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1577         ctx.glBindTexture                               (GL_TEXTURE_2D_ARRAY, tex2DArray);
1578         ctx.glTexImage3D                                (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1579         ctx.glBindTexture                               (GL_TEXTURE_2D, tex2D);
1580         ctx.glTexImage2D                                (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1581
1582         ctx.expectError                                 (GL_NO_ERROR);
1583
1584         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1585         ctx.glFramebufferTextureLayer   (-1, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1586         ctx.expectError                                 (GL_INVALID_ENUM);
1587         ctx.glFramebufferTextureLayer   (GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1588         ctx.expectError                                 (GL_INVALID_ENUM);
1589         ctx.endSection();
1590
1591         ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1592         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, -1, tex3D, 0, 1);
1593         ctx.expectError                                 (GL_INVALID_ENUM);
1594         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1);
1595         ctx.expectError                                 (GL_INVALID_ENUM);
1596         ctx.endSection();
1597
1598         ctx.beginSection("GL_INVALID_OPERATION is generated if texture is non-zero and not the name of a 3D texture or 2D array texture, 2D multisample array texture or cube map array texture.");
1599         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0);
1600         ctx.expectError                                 (GL_INVALID_OPERATION);
1601         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0);
1602         ctx.expectError                                 (GL_INVALID_OPERATION);
1603         ctx.endSection();
1604
1605         ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is negative.");
1606         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1);
1607         ctx.expectError                                 (GL_INVALID_VALUE);
1608         ctx.endSection();
1609
1610         ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is greater than GL_MAX_3D_TEXTURE_SIZE-1 for a 3D texture.");
1611         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
1612         ctx.expectError                                 (GL_INVALID_VALUE);
1613         ctx.endSection();
1614
1615         ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is greater than GL_MAX_ARRAY_TEXTURE_LAYERS-1 for a 2D array texture.");
1616         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
1617         ctx.expectError                                 (GL_INVALID_VALUE);
1618         ctx.endSection();
1619
1620         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1621         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, 0);
1622         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1623         ctx.expectError                                 (GL_INVALID_OPERATION);
1624         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1625         ctx.endSection();
1626
1627         ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 3D texture and level is less than 0 or greater than log2 of the value of GL_MAX_3D_TEXTURE_SIZE.");
1628         log2Max3DTexSize        = deLog2Floor32(max3DTexSize);
1629         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, -1, max3DTexSize - 1);
1630         ctx.expectError                                 (GL_INVALID_VALUE);
1631         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, log2Max3DTexSize + 1, max3DTexSize - 1);
1632         ctx.expectError                                 (GL_INVALID_VALUE);
1633         ctx.endSection();
1634
1635         ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D array texture and level is less than 0 or greater than log2 of the value of GL_MAX_TEXTURE_SIZE.");
1636         log2MaxTexSize          = deLog2Floor32(maxTexSize);
1637         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, -1, maxArrayTexLayers - 1);
1638         ctx.expectError                                 (GL_INVALID_VALUE);
1639         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, log2MaxTexSize + 1, maxArrayTexLayers - 1);
1640         ctx.expectError                                 (GL_INVALID_VALUE);
1641         ctx.endSection();
1642
1643         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1644         {
1645                 deUint32                                                texCubeArray            = 0x1234;
1646                 int                                                             maxCubeTexSize          = 0x1234;
1647                 ctx.glGetIntegerv                               (GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxCubeTexSize);
1648                 ctx.glGenTextures                               (1, &tex2DMSArray);
1649                 ctx.glGenTextures                               (1, &texCubeArray);
1650                 ctx.glGenTextures                               (1, &texBuffer);
1651                 ctx.glBindTexture                               (GL_TEXTURE_2D_MULTISAMPLE_ARRAY, tex2DMSArray);
1652                 ctx.glBindTexture                               (GL_TEXTURE_CUBE_MAP_ARRAY, texCubeArray);
1653                 ctx.glBindTexture                               (GL_TEXTURE_BUFFER, texBuffer);
1654                 ctx.expectError                                 (GL_NO_ERROR);
1655
1656                 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D multisample array texture and level is not 0.");
1657                 ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, -1, 0);
1658                 ctx.expectError                                 (GL_INVALID_VALUE);
1659                 ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, 1, 0);
1660                 ctx.expectError                                 (GL_INVALID_VALUE);
1661                 ctx.endSection();
1662
1663                 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a cube map array texture and layer is larger than MAX_ARRAY_TEXTURE_LAYERS-1. (See Khronos bug 15968)");
1664                 ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texCubeArray, 0, maxArrayTexLayers);
1665                 ctx.expectError                                 (GL_INVALID_VALUE);
1666                 ctx.endSection();
1667
1668                 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is the name of a buffer texture.");
1669                 ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texBuffer, 0, 0);
1670                 ctx.expectError                                 (GL_INVALID_OPERATION);
1671                 ctx.endSection();
1672
1673                 ctx.glDeleteTextures                    (1, &tex2DMSArray);
1674                 ctx.glDeleteTextures                    (1, &texCubeArray);
1675                 ctx.glDeleteTextures                    (1, &texBuffer);
1676         }
1677
1678         ctx.glDeleteTextures            (1, &tex3D);
1679         ctx.glDeleteTextures            (1, &tex2DArray);
1680         ctx.glDeleteTextures            (1, &tex2D);
1681         ctx.glDeleteFramebuffers        (1, &fbo);
1682 }
1683
1684 void invalidate_framebuffer (NegativeTestContext& ctx)
1685 {
1686         deUint32        attachments[3];
1687         deUint32        fbo                                     = 0x1234;
1688         deUint32        texture                         = 0x1234;
1689         int                     maxColorAttachments = 0x1234;
1690
1691         ctx.glGetIntegerv                               (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1692         attachments[0]                                  = GL_COLOR_ATTACHMENT0;
1693         attachments[1]                                  = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1694         attachments[2]                                  = GL_DEPTH_STENCIL_ATTACHMENT;
1695
1696         ctx.glGenFramebuffers                   (1, &fbo);
1697         ctx.glGenTextures                               (1, &texture);
1698         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1699         ctx.glBindTexture                               (GL_TEXTURE_2D, texture);
1700         ctx.glTexImage2D                                (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1701         ctx.glFramebufferTexture2D              (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1702         ctx.glCheckFramebufferStatus    (GL_FRAMEBUFFER);
1703         ctx.expectError                                 (GL_NO_ERROR);
1704
1705         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1706         ctx.glInvalidateFramebuffer             (-1, 1, &attachments[0]);
1707         ctx.expectError                                 (GL_INVALID_ENUM);
1708         ctx.glInvalidateFramebuffer             (GL_BACK, 1, &attachments[0]);
1709         ctx.expectError                                 (GL_INVALID_ENUM);
1710         ctx.endSection();
1711
1712         ctx.beginSection("GL_INVALID_OPERATION is generated if attachments contains GL_COLOR_ATTACHMENTm and m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
1713         ctx.glInvalidateFramebuffer             (GL_FRAMEBUFFER, 1, &attachments[1]);
1714         ctx.expectError                                 (GL_INVALID_OPERATION);
1715         ctx.endSection();
1716
1717         ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments is negative.");
1718         ctx.glInvalidateFramebuffer             (GL_FRAMEBUFFER, -1, &attachments[0]);
1719         ctx.expectError                                 (GL_INVALID_VALUE);
1720         ctx.endSection();
1721
1722         ctx.beginSection("GL_INVALID_ENUM is generated if the default framebuffer is bound to target and any elements of attachments are not one of the accepted attachments.");
1723         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, 0);
1724         ctx.glInvalidateFramebuffer             (GL_FRAMEBUFFER, 1, &attachments[2]);
1725         ctx.expectError                                 (GL_INVALID_ENUM);
1726         ctx.endSection();
1727
1728
1729         ctx.glDeleteTextures            (1, &texture);
1730         ctx.glDeleteFramebuffers        (1, &fbo);
1731 }
1732
1733 void invalidate_sub_framebuffer (NegativeTestContext& ctx)
1734 {
1735         deUint32        attachments[3];
1736         deUint32        fbo                                     = 0x1234;
1737         deUint32        texture                         = 0x1234;
1738         int                     maxColorAttachments     = 0x1234;
1739
1740         ctx.glGetIntegerv                               (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1741         attachments[0]                                  = GL_COLOR_ATTACHMENT0;
1742         attachments[1]                                  = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1743         attachments[2]                                  = GL_DEPTH_STENCIL_ATTACHMENT;
1744
1745         ctx.glGenFramebuffers                   (1, &fbo);
1746         ctx.glGenTextures                               (1, &texture);
1747         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1748         ctx.glBindTexture                               (GL_TEXTURE_2D, texture);
1749         ctx.glTexImage2D                                (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1750         ctx.glFramebufferTexture2D              (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1751         ctx.glCheckFramebufferStatus    (GL_FRAMEBUFFER);
1752         ctx.expectError                                 (GL_NO_ERROR);
1753
1754         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1755         ctx.glInvalidateSubFramebuffer  (-1, 1, &attachments[0], 0, 0, 16, 16);
1756         ctx.expectError                                 (GL_INVALID_ENUM);
1757         ctx.glInvalidateSubFramebuffer  (GL_BACK, 1, &attachments[0], 0, 0, 16, 16);
1758         ctx.expectError                                 (GL_INVALID_ENUM);
1759         ctx.endSection();
1760
1761         ctx.beginSection("GL_INVALID_OPERATION is generated if attachments contains GL_COLOR_ATTACHMENTm and m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
1762         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16);
1763         ctx.expectError                                 (GL_INVALID_OPERATION);
1764         ctx.endSection();
1765
1766         ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments, width, or heigh is negative.");
1767         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, 16);
1768         ctx.expectError                                 (GL_INVALID_VALUE);
1769         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, 16);
1770         ctx.expectError                                 (GL_INVALID_VALUE);
1771         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, -1);
1772         ctx.expectError                                 (GL_INVALID_VALUE);
1773         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, -1);
1774         ctx.expectError                                 (GL_INVALID_VALUE);
1775         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, 16);
1776         ctx.expectError                                 (GL_INVALID_VALUE);
1777         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, 16, -1);
1778         ctx.expectError                                 (GL_INVALID_VALUE);
1779         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, -1);
1780         ctx.expectError                                 (GL_INVALID_VALUE);
1781         ctx.endSection();
1782
1783         ctx.beginSection("GL_INVALID_ENUM is generated if the default framebuffer is bound to target and any elements of attachments are not one of the accepted attachments.");
1784         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, 0);
1785         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[2], 0, 0, 16, 16);
1786         ctx.expectError                                 (GL_INVALID_ENUM);
1787         ctx.endSection();
1788
1789         ctx.glDeleteTextures            (1, &texture);
1790         ctx.glDeleteFramebuffers        (1, &fbo);
1791 }
1792
1793 void renderbuffer_storage_multisample (NegativeTestContext& ctx)
1794 {
1795         deUint32        rbo                                                     = 0x1234;
1796         int                     maxSamplesSupportedRGBA4        = -1;
1797         int                     maxSamplesSupportedRGBA8UI      = -1;
1798         GLint           maxSize                                         = 0x1234;
1799         bool            isES                                            = glu::isContextTypeES(ctx.getRenderContext().getType());
1800
1801         ctx.glGetInternalformativ                               (GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, 1, &maxSamplesSupportedRGBA4);
1802         ctx.glGetInternalformativ                               (GL_RENDERBUFFER, GL_RGBA8UI, GL_SAMPLES, 1, &maxSamplesSupportedRGBA8UI);
1803
1804         ctx.glGenRenderbuffers                                  (1, &rbo);
1805         ctx.glBindRenderbuffer                                  (GL_RENDERBUFFER, rbo);
1806
1807         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1808         ctx.glRenderbufferStorageMultisample    (-1, 2, GL_RGBA4, 1, 1);
1809         ctx.expectError                                                 (GL_INVALID_ENUM);
1810         ctx.glRenderbufferStorageMultisample    (GL_FRAMEBUFFER, 2, GL_RGBA4, 1, 1);
1811         ctx.expectError                                                 (GL_INVALID_ENUM);
1812         ctx.endSection();
1813
1814         ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.");
1815         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, maxSamplesSupportedRGBA4+1, GL_RGBA4, 1, 1);
1816         ctx.expectError                                                 (GL_INVALID_OPERATION);
1817         ctx.endSection();
1818
1819         ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1820         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, -1, 1, 1);
1821         ctx.expectError                                                 (GL_INVALID_ENUM);
1822
1823         if (!ctx.isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1824         {
1825                 ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGB16F, 1, 1);
1826                 ctx.expectError                                                 (isES ? GL_INVALID_ENUM : GL_NO_ERROR);
1827         }
1828
1829         if (!ctx.isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1830         {
1831                 ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGBA8_SNORM, 1, 1);
1832                 ctx.expectError                                                 (isES ? GL_INVALID_ENUM : GL_NO_ERROR);
1833         }
1834
1835         ctx.endSection();
1836
1837         ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat. (Unsigned integer format)");
1838         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, maxSamplesSupportedRGBA8UI+1, GL_RGBA8UI, 1, 1);
1839         ctx.expectError                                                 (GL_INVALID_OPERATION);
1840         ctx.endSection();
1841
1842         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1843         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGBA4, -1, 1);
1844         ctx.expectError                                                 (GL_INVALID_VALUE);
1845         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGBA4, 1, -1);
1846         ctx.expectError                                                 (GL_INVALID_VALUE);
1847         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGBA4, -1, -1);
1848         ctx.expectError                                                 (GL_INVALID_VALUE);
1849         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, -1, GL_RGBA4, 1, 1);
1850         ctx.expectError                                                 (GL_INVALID_VALUE);
1851         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, -1, GL_RGBA4, -1, 1);
1852         ctx.expectError                                                 (GL_INVALID_VALUE);
1853         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, -1, GL_RGBA4, 1, -1);
1854         ctx.expectError                                                 (GL_INVALID_VALUE);
1855         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, -1, GL_RGBA4, -1, -1);
1856         ctx.expectError                                                 (GL_INVALID_VALUE);
1857         ctx.endSection();
1858
1859         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1860         ctx.glGetIntegerv                                               (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1861         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 4, GL_RGBA4, 1, maxSize+1);
1862         ctx.expectError                                                 (GL_INVALID_VALUE);
1863         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, 1);
1864         ctx.expectError                                                 (GL_INVALID_VALUE);
1865         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, maxSize+1);
1866         ctx.expectError                                                 (GL_INVALID_VALUE);
1867         ctx.endSection();
1868
1869         ctx.glDeleteRenderbuffers(1, &rbo);
1870 }
1871
1872 void copy_image_sub_data (NegativeTestContext& ctx)
1873 {
1874         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1875         {
1876                 deUint32                                        texture[5];
1877                 deUint32                                        rbo = 0x1234;
1878
1879                 ctx.glGenTextures                       (5, texture);
1880                 ctx.glGenRenderbuffers          (1, &rbo);
1881                 ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo);
1882
1883                 ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1884                 ctx.glTexParameteri                     (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1885                 ctx.glTexParameteri                     (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1886                 ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1887                 ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1888                 ctx.glBindTexture                       (GL_TEXTURE_2D, texture[1]);
1889                 ctx.glTexParameteri                     (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1890                 ctx.glTexParameteri                     (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1891                 ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1892                 ctx.expectError                         (GL_NO_ERROR);
1893
1894                 ctx.glBindTexture                       (GL_TEXTURE_3D, texture[2]);
1895                 ctx.glTexParameteri                     (GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1896                 ctx.glTexParameteri                     (GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1897                 ctx.glTexImage3D                        (GL_TEXTURE_3D, 0, GL_RGBA8, 32, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1898                 ctx.expectError                         (GL_NO_ERROR);
1899
1900                 ctx.glBindTexture                       (GL_TEXTURE_3D, texture[3]);
1901                 ctx.glTexImage3D                        (GL_TEXTURE_3D, 0, GL_RGBA8, 32, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1902                 ctx.expectError                         (GL_NO_ERROR);
1903
1904                 ctx.glBindTexture                       (GL_TEXTURE_2D, texture[4]);
1905                 ctx.glTexParameteri                     (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1906                 ctx.glTexParameteri                     (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1907                 ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
1908                 ctx.expectError                         (GL_NO_ERROR);
1909
1910                 ctx.beginSection("GL_INVALID_VALUE is generated if srcWidth, srcHeight, or srcDepth is negative.");
1911                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, 1, 1);
1912                 ctx.expectError                         (GL_INVALID_VALUE);
1913                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, -1, 1);
1914                 ctx.expectError                         (GL_INVALID_VALUE);
1915                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, 1, -1);
1916                 ctx.expectError                         (GL_INVALID_VALUE);
1917                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, -1, 1);
1918                 ctx.expectError                         (GL_INVALID_VALUE);
1919                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, 1, -1);
1920                 ctx.expectError                         (GL_INVALID_VALUE);
1921                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, -1, -1);
1922                 ctx.expectError                         (GL_INVALID_VALUE);
1923                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, -1, -1);
1924                 ctx.expectError                         (GL_INVALID_VALUE);
1925                 ctx.endSection();
1926
1927                 ctx.beginSection("GL_INVALID_VALUE is generated if srcLevel and dstLevel are not valid levels for the corresponding images.");
1928                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1929                 ctx.expectError                         (GL_INVALID_VALUE);
1930                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 1, 0, 0, 0, 0, 0, 1);
1931                 ctx.expectError                         (GL_INVALID_VALUE);
1932                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 1, 0, 0, 0, 0, 0, 1);
1933                 ctx.expectError                         (GL_INVALID_VALUE);
1934                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1935                 ctx.expectError                         (GL_INVALID_VALUE);
1936                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, -1, 0, 0, 0, 0, 0, 1);
1937                 ctx.expectError                         (GL_INVALID_VALUE);
1938                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, -1, 0, 0, 0, 0, 0, 1);
1939                 ctx.expectError                         (GL_INVALID_VALUE);
1940                 ctx.glCopyImageSubData          (rbo, GL_RENDERBUFFER, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1941                 ctx.expectError                         (GL_INVALID_VALUE);
1942                 ctx.glCopyImageSubData          (rbo, GL_RENDERBUFFER, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1943                 ctx.expectError                         (GL_INVALID_VALUE);
1944                 ctx.glCopyImageSubData          (texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, rbo, GL_RENDERBUFFER, -1, 0, 0, 0, 0, 0, 1);
1945                 ctx.expectError                         (GL_INVALID_VALUE);
1946                 ctx.glCopyImageSubData          (texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, rbo, GL_RENDERBUFFER, 1, 0, 0, 0, 0, 0, 1);
1947                 ctx.expectError                         (GL_INVALID_VALUE);
1948                 ctx.endSection();
1949
1950                 ctx.beginSection("GL_INVALID_ENUM is generated if either target does not match the type of the object.");
1951                 // \note: This could be either:
1952                 //              1. GL_INVALID_ENUM is generated if either target does not match the type of the object.
1953                 //              2. GL_INVALID_VALUE is generated if either name does not correspond to a valid renderbuffer or texture object according to the corresponding target parameter.
1954                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1955                 ctx.expectError                         (GL_INVALID_ENUM);
1956                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[2], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1957                 ctx.expectError                         (GL_INVALID_ENUM);
1958                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_3D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1959                 ctx.expectError                         (GL_INVALID_ENUM);
1960                 ctx.glCopyImageSubData          (texture[2], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1961                 ctx.expectError                         (GL_INVALID_ENUM);
1962                 ctx.endSection();
1963
1964                 ctx.beginSection("GL_INVALID_OPERATION is generated if either object is a texture and the texture is not complete.");
1965                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1966                 ctx.expectError                         (GL_INVALID_OPERATION);
1967                 ctx.glCopyImageSubData          (texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1968                 ctx.expectError                         (GL_INVALID_OPERATION);
1969                 ctx.glCopyImageSubData          (texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1970                 ctx.expectError                         (GL_INVALID_OPERATION);
1971                 ctx.endSection();
1972
1973                 ctx.beginSection("GL_INVALID_VALUE is generated if the dimensions of either subregion exceeds the boundaries of the corresponding image object.");
1974                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 33, 0, 1);
1975                 ctx.expectError                         (GL_INVALID_VALUE);
1976                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 33, 1);
1977                 ctx.expectError                         (GL_INVALID_VALUE);
1978                 ctx.endSection();
1979
1980                 ctx.beginSection("GL_INVALID_OPERATION error is generated if the source and destination internal formats are not compatible.");
1981                 ctx.glCopyImageSubData          (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[4], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1982                 ctx.expectError                         (GL_INVALID_OPERATION);
1983                 ctx.glCopyImageSubData          (texture[4], GL_TEXTURE_2D, 0, 0, 0, 0, texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1984                 ctx.expectError                         (GL_INVALID_OPERATION);
1985                 ctx.endSection();
1986
1987                 ctx.glDeleteTextures            (5, texture);
1988                 ctx.glDeleteRenderbuffers       (1, &rbo);
1989         }
1990 }
1991
1992 std::vector<FunctionContainer> getNegativeBufferApiTestFunctions ()
1993 {
1994         const FunctionContainer funcs[] =
1995         {
1996                 {bind_buffer,                                           "bind_buffer",                                          "Invalid glBindBuffer() usage"                                          },
1997                 {delete_buffers,                                        "delete_buffers",                                       "Invalid glDeleteBuffers() usage"                                       },
1998                 {gen_buffers,                                           "gen_buffers",                                          "Invalid glGenBuffers() usage"                                          },
1999                 {buffer_data,                                           "buffer_data",                                          "Invalid glBufferData() usage"                                          },
2000                 {buffer_sub_data,                                       "buffer_sub_data",                                      "Invalid glBufferSubData() usage"                                       },
2001                 {buffer_sub_data_size_offset,           "buffer_sub_data_size_offset",          "Invalid glBufferSubData() usage"                                       },
2002                 {clear,                                                         "clear",                                                        "Invalid glClear() usage"                                                       },
2003                 {read_pixels,                                           "read_pixels",                                          "Invalid glReadPixels() usage"                                          },
2004                 {readn_pixels,                                          "readn_pixels",                                         "Invalid glReadPixels() usage"                                          },
2005                 {read_pixels_format_mismatch,           "read_pixels_format_mismatch",          "Invalid glReadPixels() usage"                                          },
2006                 {read_pixels_fbo_format_mismatch,       "read_pixels_fbo_format_mismatch",      "Invalid glReadPixels() usage"                                          },
2007                 {bind_buffer_range,                                     "bind_buffer_range",                            "Invalid glBindBufferRange() usage"                                     },
2008                 {bind_buffer_base,                                      "bind_buffer_base",                                     "Invalid glBindBufferBase() usage"                                      },
2009                 {clear_bufferiv,                                        "clear_bufferiv",                                       "Invalid glClearBufferiv() usage"                                       },
2010                 {clear_bufferuiv,                                       "clear_bufferuiv",                                      "Invalid glClearBufferuiv() usage"                                      },
2011                 {clear_bufferfv,                                        "clear_bufferfv",                                       "Invalid glClearBufferfv() usage"                                       },
2012                 {clear_bufferfi,                                        "clear_bufferfi",                                       "Invalid glClearBufferfi() usage"                                       },
2013                 {copy_buffer_sub_data,                          "copy_buffer_sub_data",                         "Invalid glCopyBufferSubData() usage"                           },
2014                 {draw_buffers,                                          "draw_buffers",                                         "Invalid glDrawBuffers() usage"                                         },
2015                 {flush_mapped_buffer_range,                     "flush_mapped_buffer_range",            "Invalid glFlushMappedBufferRange() usage"                      },
2016                 {map_buffer_range,                                      "map_buffer_range",                                     "Invalid glMapBufferRange() usage"                                      },
2017                 {read_buffer,                                           "read_buffer",                                          "Invalid glReadBuffer() usage"                                          },
2018                 {unmap_buffer,                                          "unmap_buffer",                                         "Invalid glUnmapBuffer() usage"                                         },
2019                 {bind_framebuffer,                                      "bind_framebuffer",                                     "Invalid glBindFramebuffer() usage"                                     },
2020                 {bind_renderbuffer,                                     "bind_renderbuffer",                            "Invalid glBindRenderbuffer() usage"                            },
2021                 {check_framebuffer_status,                      "check_framebuffer_status",                     "Invalid glCheckFramebufferStatus() usage"                      },
2022                 {gen_framebuffers,                                      "gen_framebuffers",                                     "Invalid glGenFramebuffers() usage"                                     },
2023                 {gen_renderbuffers,                                     "gen_renderbuffers",                            "Invalid glGenRenderbuffers() usage"                            },
2024                 {delete_framebuffers,                           "delete_framebuffers",                          "Invalid glDeleteFramebuffers() usage"                          },
2025                 {delete_renderbuffers,                          "delete_renderbuffers",                         "Invalid glDeleteRenderbuffers() usage"                         },
2026                 {framebuffer_renderbuffer,                      "framebuffer_renderbuffer",                     "Invalid glFramebufferRenderbuffer() usage"                     },
2027                 {framebuffer_texture,                           "framebuffer_texture",                          "Invalid glFramebufferTexture() usage"                          },
2028                 {framebuffer_texture2d,                         "framebuffer_texture2d",                        "Invalid glFramebufferTexture2D() usage"                        },
2029                 {renderbuffer_storage,                          "renderbuffer_storage",                         "Invalid glRenderbufferStorage() usage"                         },
2030                 {blit_framebuffer,                                      "blit_framebuffer",                                     "Invalid glBlitFramebuffer() usage"                                     },
2031                 {blit_framebuffer_multisample,          "blit_framebuffer_multisample",         "Invalid glBlitFramebuffer() usage"                                     },
2032                 {framebuffer_texture_layer,                     "framebuffer_texture_layer",            "Invalid glFramebufferTextureLayer() usage"                     },
2033                 {invalidate_framebuffer,                        "invalidate_framebuffer",                       "Invalid glInvalidateFramebuffer() usage"                       },
2034                 {invalidate_sub_framebuffer,            "invalidate_sub_framebuffer",           "Invalid glInvalidateSubFramebuffer() usage"            },
2035                 {renderbuffer_storage_multisample,      "renderbuffer_storage_multisample",     "Invalid glRenderbufferStorageMultisample() usage"      },
2036                 {copy_image_sub_data,                           "copy_image_sub_data",                          "Invalid glCopyImageSubData() usage"                            },
2037         };
2038
2039         return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
2040 }
2041
2042 } // NegativeTestShared
2043 } // Functional
2044 } // gles31
2045 } // deqp