Fix ASTC framework tests
[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("GL_INVALID_OPERATION is generated if the combination of format and type is unsupported.");
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<GLubyte>    ubyteData       (4);
200         GLuint                                  fbo                     = 0x1234;
201
202         if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2))
203                 && !ctx.isExtensionSupported("GL_KHR_robustness")
204                 && !ctx.isExtensionSupported("GL_EXT_robustness"))
205         {
206                 TCU_THROW(NotSupportedError, "GLES 3.2 or robustness extension not supported");
207         }
208
209         ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of format and type is unsupported.");
210         ctx.glReadnPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, (int) ubyteData.size(), &ubyteData[0]);
211         ctx.expectError(GL_INVALID_OPERATION);
212         ctx.endSection();
213
214         ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
215         ctx.glReadnPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
216         ctx.expectError(GL_INVALID_VALUE);
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.endSection();
222
223         ctx.beginSection("GL_INVALID_OPERATION is generated by ReadnPixels if the buffer size required to store the requested data is larger than bufSize.");
224         ctx.glReadnPixels(0, 0, 0x1234, 0x1234, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
225         ctx.expectError(GL_INVALID_OPERATION);
226         ctx.endSection();
227
228         ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
229         ctx.glGenFramebuffers(1, &fbo);
230         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
231         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
232         ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
233         ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
234         ctx.endSection();
235
236         ctx.glDeleteFramebuffers(1, &fbo);
237 }
238
239 void read_pixels_format_mismatch (NegativeTestContext& ctx)
240 {
241         std::vector<GLubyte>    ubyteData       (4);
242         std::vector<GLushort>   ushortData      (4);
243         std::vector<GLfloat>    floatData       (4);
244         GLint                                   readFormat      = 0x1234;
245         GLint                                   readType        = 0x1234;
246
247         ctx.beginSection("Unsupported combinations of format and type will generate an GL_INVALID_OPERATION error.");
248         ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
249         ctx.expectError(GL_INVALID_OPERATION);
250         ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
251         ctx.expectError(GL_INVALID_OPERATION);
252         ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &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_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
257         ctx.expectError(GL_INVALID_OPERATION);
258         ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
259         ctx.expectError(GL_INVALID_OPERATION);
260         ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, (int) floatData.size(), &floatData[0]);
261         ctx.expectError(GL_INVALID_OPERATION);
262         ctx.endSection();
263
264         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.");
265         ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
266         ctx.expectError(GL_NO_ERROR);
267         ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
268         ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
269         ctx.glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]);
270         ctx.expectError(GL_NO_ERROR);
271         ctx.endSection();
272 }
273
274 void read_pixels_fbo_format_mismatch (NegativeTestContext& ctx)
275 {
276         std::vector<GLubyte>    ubyteData(4);
277         std::vector<float>              floatData(4);
278         deUint32                                fbo = 0x1234;
279         deUint32                                texture = 0x1234;
280
281         ctx.glGenTextures                       (1, &texture);
282         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
283         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
284         ctx.glGenFramebuffers           (1, &fbo);
285         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
286         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
287         ctx.expectError                         (GL_NO_ERROR);
288
289         ctx.beginSection("GL_INVALID_OPERATION is generated if currently bound framebuffer format is incompatible with format and type.");
290
291         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
292         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
293         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
294         ctx.expectError                         (GL_NO_ERROR);
295         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
296         ctx.expectError                         (GL_INVALID_OPERATION);
297
298         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
299         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
300         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
301         ctx.expectError                         (GL_NO_ERROR);
302         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
303         ctx.expectError                         (GL_INVALID_OPERATION);
304
305         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
306         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
307         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
308         ctx.expectError                         (GL_NO_ERROR);
309         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
310         ctx.expectError                         (GL_INVALID_OPERATION);
311
312         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
313         ctx.expectError                         (GL_NO_ERROR);
314         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
315         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
316         ctx.expectError                         (GL_NO_ERROR);
317         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_INT, &floatData[0]);
318         ctx.expectError                         (GL_INVALID_OPERATION);
319
320         ctx.endSection();
321
322         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.");
323
324         int                     binding                 = -1;
325         int                     sampleBuffers = 0x1234;
326         deUint32        rbo = 0x1234;
327
328         ctx.glGenRenderbuffers(1, &rbo);
329         ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
330         ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
331         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
332
333         ctx.glGetIntegerv                       (GL_READ_FRAMEBUFFER_BINDING, &binding);
334         ctx.getLog() << TestLog::Message << "// GL_READ_FRAMEBUFFER_BINDING: " << binding << TestLog::EndMessage;
335         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
336         ctx.glGetIntegerv                       (GL_SAMPLE_BUFFERS, &sampleBuffers);
337         ctx.getLog() << TestLog::Message << "// GL_SAMPLE_BUFFERS: " << sampleBuffers << TestLog::EndMessage;
338         ctx.expectError                         (GL_NO_ERROR);
339
340         if (binding == 0 || sampleBuffers <= 0)
341         {
342                 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;
343                 ctx.fail("Got invalid value");
344         }
345         else
346         {
347                 ctx.glReadPixels        (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
348                 ctx.expectError         (GL_INVALID_OPERATION);
349         }
350
351         ctx.endSection();
352
353         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, 0);
354         ctx.glBindTexture                       (GL_TEXTURE_2D, 0);
355         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
356         ctx.glDeleteFramebuffers        (1, &fbo);
357         ctx.glDeleteTextures            (1, &texture);
358         ctx.glDeleteRenderbuffers       (1, &rbo);
359 }
360
361 void bind_buffer_range (NegativeTestContext& ctx)
362 {
363         deUint32        bufAC           = 0x1234;
364         deUint32        bufU            = 0x1234;
365         deUint32        bufTF           = 0x1234;
366         int                     maxTFSize       = 0x1234;
367         int                     maxUSize        = 0x1234;
368         int                     uAlignment      = 0x1234;
369
370         ctx.glGenBuffers(1, &bufU);
371         ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
372         ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
373
374         ctx.glGenBuffers(1, &bufTF);
375         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
376         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
377
378         ctx.glGenBuffers(1, &bufAC);
379         ctx.glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bufAC);
380         ctx.glBufferData(GL_ATOMIC_COUNTER_BUFFER, 16, NULL, GL_STREAM_DRAW);
381
382         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.");
383         ctx.glBindBufferRange(GL_ARRAY_BUFFER, 0, bufU, 0, 4);
384         ctx.expectError(GL_INVALID_ENUM);
385         ctx.endSection();
386
387         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.");
388         ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
389         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
390         ctx.expectError(GL_INVALID_VALUE);
391         ctx.endSection();
392
393         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.");
394         ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
395         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4);
396         ctx.expectError(GL_INVALID_VALUE);
397         ctx.endSection();
398
399         ctx.beginSection("GL_INVALID_VALUE is generated if size is less than or equal to zero.");
400         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1);
401         ctx.expectError(GL_INVALID_VALUE);
402         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0);
403         ctx.expectError(GL_INVALID_VALUE);
404         ctx.endSection();
405
406         ctx.beginSection("GL_INVALID_VALUE is generated if offset is less than zero.");
407         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, -1, 0);
408         ctx.expectError(GL_INVALID_VALUE);
409         ctx.endSection();
410
411         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.");
412         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
413         ctx.expectError(GL_INVALID_VALUE);
414         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
415         ctx.expectError(GL_INVALID_VALUE);
416         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
417         ctx.expectError(GL_INVALID_VALUE);
418         ctx.endSection();
419
420         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.");
421         ctx.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uAlignment);
422         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, uAlignment+1, 4);
423         ctx.expectError(GL_INVALID_VALUE);
424         ctx.endSection();
425
426         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
427         {
428                 int maxACize    = 0x1234;
429                 int maxSSize    = 0x1234;
430                 int ssAlignment = 0x1234;
431
432                 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.");
433                 ctx.glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &maxACize);
434                 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, maxACize, bufU, 0, 4);
435                 ctx.expectError(GL_INVALID_VALUE);
436                 ctx.endSection();
437
438                 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.");
439                 ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxSSize);
440                 ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, maxSSize, bufU, 0, 4);
441                 ctx.expectError(GL_INVALID_VALUE);
442                 ctx.endSection();
443
444                 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_ATOMIC_COUNTER_BUFFER and offset is not multiples of 4.");
445                 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, bufTF, 5, 0);
446                 ctx.expectError(GL_INVALID_VALUE);
447                 ctx.endSection();
448
449                 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.");
450                 ctx.glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &ssAlignment);
451                 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, bufTF, ssAlignment+1, 0);
452                 ctx.expectError(GL_INVALID_VALUE);
453                 ctx.endSection();
454         }
455
456         ctx.glDeleteBuffers(1, &bufU);
457         ctx.glDeleteBuffers(1, &bufTF);
458         ctx.glDeleteBuffers(1, &bufAC);
459 }
460
461 void bind_buffer_base (NegativeTestContext& ctx)
462 {
463         deUint32        bufU            = 0x1234;
464         deUint32        bufTF           = 0x1234;
465         int                     maxUSize        = 0x1234;
466         int                     maxTFSize       = 0x1234;
467
468         ctx.glGenBuffers(1, &bufU);
469         ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
470         ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
471
472         ctx.glGenBuffers(1, &bufTF);
473         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
474         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
475         ctx.expectError(GL_NO_ERROR);
476
477         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.");
478         ctx.glBindBufferBase(-1, 0, bufU);
479         ctx.expectError(GL_INVALID_ENUM);
480         ctx.glBindBufferBase(GL_ARRAY_BUFFER, 0, bufU);
481         ctx.expectError(GL_INVALID_ENUM);
482         ctx.endSection();
483
484         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.");
485         ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
486         ctx.glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU);
487         ctx.expectError(GL_INVALID_VALUE);
488         ctx.endSection();
489
490         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.");
491         ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
492         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
493         ctx.expectError(GL_INVALID_VALUE);
494         ctx.endSection();
495
496         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
497         {
498                 int maxACize = 0x1234;
499                 int maxSSize = 0x1234;
500
501                 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.");
502                 ctx.glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &maxACize);
503                 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, maxACize, bufU, 0, 4);
504                 ctx.expectError(GL_INVALID_VALUE);
505                 ctx.endSection();
506
507                 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.");
508                 ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxSSize);
509                 ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, maxSSize, bufU, 0, 4);
510                 ctx.expectError(GL_INVALID_VALUE);
511                 ctx.endSection();
512         }
513
514         ctx.glDeleteBuffers(1, &bufU);
515         ctx.glDeleteBuffers(1, &bufTF);
516 }
517
518 void clear_bufferiv (NegativeTestContext& ctx)
519 {
520         std::vector<int>        data                    (32*32);
521         deUint32                        fbo                             = 0x1234;
522         deUint32                        texture                 = 0x1234;
523         int                                     maxDrawBuffers  = 0x1234;
524
525         ctx.glGenTextures                       (1, &texture);
526         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
527         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
528         ctx.glGenFramebuffers           (1, &fbo);
529         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
530         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
531         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
532         ctx.expectError                         (GL_NO_ERROR);
533
534         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
535         ctx.glClearBufferiv                     (-1, 0, &data[0]);
536         ctx.expectError                         (GL_INVALID_ENUM);
537         ctx.glClearBufferiv                     (GL_FRAMEBUFFER, 0, &data[0]);
538         ctx.expectError                         (GL_INVALID_ENUM);
539         ctx.endSection();
540
541         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL.");
542         ctx.glClearBufferiv                     (GL_DEPTH, 1, &data[0]);
543         ctx.expectError                         (GL_INVALID_ENUM);
544         ctx.glClearBufferiv                     (GL_DEPTH_STENCIL, 1, &data[0]);
545         ctx.expectError                         (GL_INVALID_ENUM);
546         ctx.endSection();
547
548         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.");
549         ctx.glGetIntegerv                       (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
550         ctx.glClearBufferiv                     (GL_COLOR, maxDrawBuffers, &data[0]);
551         ctx.expectError                         (GL_INVALID_VALUE);
552         ctx.endSection();
553
554         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR or GL_STENCIL and drawBuffer is negative.");
555         ctx.glClearBufferiv                     (GL_COLOR, -1, &data[0]);
556         ctx.expectError                         (GL_INVALID_VALUE);
557         ctx.endSection();
558
559         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero.");
560         ctx.glClearBufferiv                     (GL_STENCIL, 1, &data[0]);
561         ctx.expectError                         (GL_INVALID_VALUE);
562         ctx.endSection();
563
564         ctx.glDeleteFramebuffers        (1, &fbo);
565         ctx.glDeleteTextures            (1, &texture);
566 }
567
568 void clear_bufferuiv (NegativeTestContext& ctx)
569 {
570         std::vector<deUint32>   data                    (32*32);
571         deUint32                                fbo                             = 0x1234;
572         deUint32                                texture                 = 0x1234;
573         int                                             maxDrawBuffers  = 0x1234;
574
575         ctx.glGenTextures                       (1, &texture);
576         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
577         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
578         ctx.glGenFramebuffers           (1, &fbo);
579         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
580         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
581         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
582         ctx.expectError                         (GL_NO_ERROR);
583
584         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR.");
585         ctx.glClearBufferuiv            (-1, 0, &data[0]);
586         ctx.expectError                         (GL_INVALID_ENUM);
587         ctx.glClearBufferuiv            (GL_FRAMEBUFFER, 0, &data[0]);
588         ctx.expectError                         (GL_INVALID_ENUM);
589         ctx.endSection();
590
591         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL, or GL_DEPTH_STENCIL.");
592         ctx.glClearBufferuiv            (GL_DEPTH, 0, &data[0]);
593         ctx.expectError                         (GL_INVALID_ENUM);
594         ctx.glClearBufferuiv            (GL_STENCIL, 0, &data[0]);
595         ctx.expectError                         (GL_INVALID_ENUM);
596         ctx.glClearBufferuiv            (GL_DEPTH_STENCIL, 0, &data[0]);
597         ctx.expectError                         (GL_INVALID_ENUM);
598         ctx.endSection();
599
600         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
601         ctx.glGetIntegerv                       (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
602         ctx.glClearBufferuiv            (GL_COLOR, maxDrawBuffers, &data[0]);
603         ctx.expectError                         (GL_INVALID_VALUE);
604         ctx.endSection();
605
606         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
607         ctx.glClearBufferuiv            (GL_COLOR, -1, &data[0]);
608         ctx.expectError                         (GL_INVALID_VALUE);
609         ctx.endSection();
610
611         ctx.glDeleteFramebuffers        (1, &fbo);
612         ctx.glDeleteTextures            (1, &texture);
613 }
614
615 void clear_bufferfv (NegativeTestContext& ctx)
616 {
617         std::vector<float>      data                    (32*32);
618         deUint32                        fbo                             = 0x1234;
619         deUint32                        texture                 = 0x1234;
620         int                             maxDrawBuffers  = 0x1234;
621
622         ctx.glGenTextures                       (1, &texture);
623         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
624         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
625         ctx.glGenFramebuffers           (1, &fbo);
626         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
627         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
628         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
629         ctx.expectError                         (GL_NO_ERROR);
630
631         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR or GL_DEPTH.");
632         ctx.glClearBufferfv                     (-1, 0, &data[0]);
633         ctx.expectError                         (GL_INVALID_ENUM);
634         ctx.glClearBufferfv                     (GL_FRAMEBUFFER, 0, &data[0]);
635         ctx.expectError                         (GL_INVALID_ENUM);
636         ctx.endSection();
637
638         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL.");
639         ctx.glClearBufferfv                     (GL_STENCIL, 1, &data[0]);
640         ctx.expectError                         (GL_INVALID_ENUM);
641         ctx.glClearBufferfv                     (GL_DEPTH_STENCIL, 1, &data[0]);
642         ctx.expectError                         (GL_INVALID_ENUM);
643         ctx.endSection();
644
645         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
646         ctx.glGetIntegerv                       (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
647         ctx.glClearBufferfv                     (GL_COLOR, maxDrawBuffers, &data[0]);
648         ctx.expectError                         (GL_INVALID_VALUE);
649         ctx.endSection();
650
651         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
652         ctx.glClearBufferfv                     (GL_COLOR, -1, &data[0]);
653         ctx.expectError                         (GL_INVALID_VALUE);
654         ctx.endSection();
655
656         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero.");
657         ctx.glClearBufferfv                     (GL_DEPTH, 1, &data[0]);
658         ctx.expectError                         (GL_INVALID_VALUE);
659         ctx.endSection();
660
661         ctx.glDeleteFramebuffers        (1, &fbo);
662         ctx.glDeleteTextures            (1, &texture);
663 }
664
665 void clear_bufferfi (NegativeTestContext& ctx)
666 {
667         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL.");
668         ctx.glClearBufferfi             (-1, 0, 1.0f, 1);
669         ctx.expectError                 (GL_INVALID_ENUM);
670         ctx.glClearBufferfi             (GL_FRAMEBUFFER, 0, 1.0f, 1);
671         ctx.expectError                 (GL_INVALID_ENUM);
672         ctx.glClearBufferfi             (GL_DEPTH, 0, 1.0f, 1);
673         ctx.expectError                 (GL_INVALID_ENUM);
674         ctx.glClearBufferfi             (GL_STENCIL, 0, 1.0f, 1);
675         ctx.expectError                 (GL_INVALID_ENUM);
676         ctx.glClearBufferfi             (GL_COLOR, 0, 1.0f, 1);
677         ctx.expectError                 (GL_INVALID_ENUM);
678         ctx.endSection();
679
680         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero.");
681         ctx.glClearBufferfi             (GL_DEPTH_STENCIL, 1, 1.0f, 1);
682         ctx.expectError                 (GL_INVALID_VALUE);
683         ctx.endSection();
684 }
685
686 void copy_buffer_sub_data (NegativeTestContext& ctx)
687 {
688         deUint32                                buf[2];
689         std::vector<float>              data    (32*32);
690
691         ctx.glGenBuffers                        (2, buf);
692         ctx.glBindBuffer                        (GL_COPY_READ_BUFFER, buf[0]);
693         ctx.glBufferData                        (GL_COPY_READ_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
694         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[1]);
695         ctx.glBufferData                        (GL_COPY_WRITE_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
696         ctx.expectError                         (GL_NO_ERROR);
697
698         ctx.beginSection("GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative.");
699         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, -4);
700         ctx.expectError                         (GL_INVALID_VALUE);
701         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, -1, 0, 4);
702         ctx.expectError                         (GL_INVALID_VALUE);
703         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, -1, 4);
704         ctx.expectError                         (GL_INVALID_VALUE);
705         ctx.endSection();
706
707         ctx.beginSection("GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.");
708         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
709         ctx.expectError                         (GL_INVALID_VALUE);
710         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16);
711         ctx.expectError                         (GL_INVALID_VALUE);
712         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4);
713         ctx.expectError                         (GL_INVALID_VALUE);
714         ctx.endSection();
715
716         ctx.beginSection("GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.");
717         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
718         ctx.expectError                         (GL_INVALID_VALUE);
719         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16);
720         ctx.expectError                         (GL_INVALID_VALUE);
721         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4);
722         ctx.expectError                         (GL_INVALID_VALUE);
723         ctx.endSection();
724
725         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.");
726         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[0]);
727         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4);
728         ctx.expectError                         (GL_NO_ERROR);
729         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4);
730         ctx.expectError                         (GL_INVALID_VALUE);
731         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18);
732         ctx.expectError                         (GL_INVALID_VALUE);
733         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[1]);
734         ctx.endSection();
735
736         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget.");
737         ctx.glBindBuffer                        (GL_COPY_READ_BUFFER, 0);
738         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
739         ctx.expectError                         (GL_INVALID_OPERATION);
740
741         ctx.glBindBuffer                        (GL_COPY_READ_BUFFER, buf[0]);
742         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, 0);
743         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
744         ctx.expectError                         (GL_INVALID_OPERATION);
745
746         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[1]);
747         ctx.endSection();
748
749         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped.");
750         ctx.glMapBufferRange            (GL_COPY_READ_BUFFER, 0, 4, GL_MAP_READ_BIT);
751         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
752         ctx.expectError                         (GL_INVALID_OPERATION);
753         ctx.glUnmapBuffer                       (GL_COPY_READ_BUFFER);
754
755         ctx.glMapBufferRange            (GL_COPY_WRITE_BUFFER, 0, 4, GL_MAP_READ_BIT);
756         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
757         ctx.expectError                         (GL_INVALID_OPERATION);
758         ctx.glUnmapBuffer                       (GL_COPY_WRITE_BUFFER);
759         ctx.endSection();
760
761         ctx.glDeleteBuffers(2, buf);
762 }
763
764 void draw_buffers (NegativeTestContext& ctx)
765 {
766         deUint32                                fbo                                     = 0x1234;
767         deUint32                                texture                                 = 0x1234;
768         int                                             maxDrawBuffers                  = 0x1234;
769         int                                             maxColorAttachments             = -1;
770         ctx.glGetIntegerv               (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
771         ctx.glGetIntegerv               (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
772         std::vector<deUint32>   values                                  (maxDrawBuffers+1);
773         std::vector<deUint32>   attachments                             (4);
774         std::vector<GLfloat>    data                                    (32*32);
775         values[0]                               = GL_NONE;
776         values[1]                               = GL_BACK;
777         values[2]                               = GL_COLOR_ATTACHMENT0;
778         values[3]                               = GL_DEPTH_ATTACHMENT;
779         attachments[0]                  = (glw::GLenum) (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
780         attachments[1]                  = GL_COLOR_ATTACHMENT0;
781         attachments[2]                  = GL_COLOR_ATTACHMENT1;
782         attachments[3]                  = GL_NONE;
783
784         ctx.glGenTextures                       (1, &texture);
785         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
786         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
787         ctx.glGenFramebuffers           (1, &fbo);
788         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
789         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
790         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
791         ctx.expectError                         (GL_NO_ERROR);
792
793         ctx.beginSection("GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.");
794         ctx.glDrawBuffers                       (2, &values[2]);
795         ctx.expectError                         (GL_INVALID_ENUM);
796         ctx.endSection();
797
798         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.");
799         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
800         ctx.glDrawBuffers                       (1, &values[1]);
801         ctx.expectError                         (GL_INVALID_OPERATION);
802         ctx.glDrawBuffers                       (4, &attachments[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 n is not 1.");
807         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
808         ctx.glDrawBuffers                       (2, &values[0]);
809         ctx.expectError                         (GL_INVALID_OPERATION);
810         ctx.endSection();
811
812         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.");
813         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
814         ctx.glDrawBuffers                       (1, &values[2]);
815         ctx.expectError                         (GL_INVALID_OPERATION);
816         ctx.endSection();
817
818         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.");
819         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
820         ctx.glDrawBuffers                       (1, &values[1]);
821         ctx.expectError                         (GL_INVALID_OPERATION);
822         ctx.glDrawBuffers                       (4, &attachments[0]);
823         ctx.expectError                         (GL_INVALID_OPERATION);
824
825         ctx.endSection();
826
827         ctx.beginSection("GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.");
828         ctx.glDrawBuffers                       (-1, &values[1]);
829         ctx.expectError                         (GL_INVALID_VALUE);
830         ctx.glDrawBuffers                       (maxDrawBuffers+1, &values[0]);
831         ctx.expectError                         (GL_INVALID_VALUE);
832         ctx.endSection();
833
834         ctx.glDeleteTextures(1, &texture);
835         ctx.glDeleteFramebuffers(1, &fbo);
836 }
837
838 void flush_mapped_buffer_range (NegativeTestContext& ctx)
839 {
840         deUint32                                buf             = 0x1234;
841         std::vector<GLfloat>    data    (32);
842
843         ctx.glGenBuffers                        (1, &buf);
844         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
845         ctx.glBufferData                        (GL_ARRAY_BUFFER, 32, &data[0], GL_STATIC_READ);
846         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
847         ctx.expectError                         (GL_NO_ERROR);
848
849         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted values.");
850         ctx.glFlushMappedBufferRange(-1, 0, 16);
851         ctx.expectError                         (GL_INVALID_ENUM);
852         ctx.endSection();
853
854         ctx.beginSection("GL_INVALID_VALUE is generated if offset or length is negative, or if offset + length exceeds the size of the mapping.");
855         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, -1, 1);
856         ctx.expectError                         (GL_INVALID_VALUE);
857         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, -1);
858         ctx.expectError                         (GL_INVALID_VALUE);
859         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 12, 8);
860         ctx.expectError                         (GL_INVALID_VALUE);
861         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 24, 4);
862         ctx.expectError                         (GL_INVALID_VALUE);
863         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 24);
864         ctx.expectError                         (GL_INVALID_VALUE);
865         ctx.endSection();
866
867         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
868         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, 0);
869         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
870         ctx.expectError                         (GL_INVALID_OPERATION);
871         ctx.endSection();
872
873         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.");
874         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
875         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
876         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
877         ctx.expectError                         (GL_INVALID_OPERATION);
878         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
879         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
880         ctx.expectError                         (GL_INVALID_OPERATION);
881         ctx.endSection();
882
883         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
884         ctx.glDeleteBuffers                     (1, &buf);
885 }
886
887 void map_buffer_range (NegativeTestContext& ctx)
888 {
889         deUint32                                buf             = 0x1234;
890         std::vector<GLfloat>    data    (32);
891
892         ctx.glGenBuffers                        (1, &buf);
893         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
894         ctx.glBufferData                        (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
895         ctx.expectError                         (GL_NO_ERROR);
896
897         ctx.beginSection("GL_INVALID_VALUE is generated if either of offset or length is negative.");
898         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, -1, 1, GL_MAP_READ_BIT);
899         ctx.expectError                         (GL_INVALID_VALUE);
900
901         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 1, -1, GL_MAP_READ_BIT);
902         ctx.expectError                         (GL_INVALID_VALUE);
903         ctx.endSection();
904
905         ctx.beginSection("GL_INVALID_VALUE is generated if offset + length is greater than the value of GL_BUFFER_SIZE.");
906         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 33, GL_MAP_READ_BIT);
907         ctx.expectError                         (GL_INVALID_VALUE);
908
909         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 32, 1, GL_MAP_READ_BIT);
910         ctx.expectError                         (GL_INVALID_VALUE);
911
912         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 16, 17, GL_MAP_READ_BIT);
913         ctx.expectError                         (GL_INVALID_VALUE);
914         ctx.endSection();
915
916         ctx.beginSection("GL_INVALID_VALUE is generated if access has any bits set other than those accepted.");
917         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | 0x1000);
918         ctx.expectError                         (GL_INVALID_VALUE);
919
920         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | 0x1000);
921         ctx.expectError                         (GL_INVALID_VALUE);
922         ctx.endSection();
923
924         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer is already in a mapped state.");
925         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
926         ctx.expectError                         (GL_NO_ERROR);
927         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT);
928         ctx.expectError                         (GL_INVALID_OPERATION);
929         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
930         ctx.endSection();
931
932         ctx.beginSection("GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.");
933         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
934         ctx.expectError                         (GL_INVALID_OPERATION);
935         ctx.endSection();
936
937         ctx.beginSection("GL_INVALID_OPERATION is generated if length is 0");
938         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 0, GL_MAP_READ_BIT);
939         ctx.expectError                         (GL_INVALID_OPERATION);
940         ctx.endSection();
941
942         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.");
943         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
944         ctx.expectError                         (GL_INVALID_OPERATION);
945
946         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
947         ctx.expectError                         (GL_INVALID_OPERATION);
948
949         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
950         ctx.expectError                         (GL_INVALID_OPERATION);
951         ctx.endSection();
952
953         ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.");
954         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
955         ctx.expectError                         (GL_INVALID_OPERATION);
956         ctx.endSection();
957
958         ctx.glDeleteBuffers                     (1, &buf);
959 }
960
961 void read_buffer (NegativeTestContext& ctx)
962 {
963         deUint32        fbo                                     = 0x1234;
964         deUint32        texture                         = 0x1234;
965         int                     maxColorAttachments     = 0x1234;
966
967         ctx.glGetIntegerv                       (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
968         ctx.glGenTextures                       (1, &texture);
969         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
970         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
971         ctx.glGenFramebuffers           (1, &fbo);
972         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
973         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
974         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
975         ctx.expectError                         (GL_NO_ERROR);
976
977         ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_BACK, GL_NONE, or GL_COLOR_ATTACHMENTi.");
978         ctx.glReadBuffer                        (GL_NONE);
979         ctx.expectError                         (GL_NO_ERROR);
980         ctx.glReadBuffer                        (1);
981         ctx.expectError                         (GL_INVALID_ENUM);
982         ctx.glReadBuffer                        (GL_FRAMEBUFFER);
983         ctx.expectError                         (GL_INVALID_ENUM);
984         ctx.glReadBuffer                        (GL_COLOR_ATTACHMENT0 - 1);
985         ctx.expectError                         (GL_INVALID_ENUM);
986         ctx.glReadBuffer                        (GL_FRONT);
987         ctx.expectError                         (GL_INVALID_ENUM);
988
989         // \ note Spec isn't actually clear here, but it is safe to assume that
990         //                GL_DEPTH_ATTACHMENT can't be interpreted as GL_COLOR_ATTACHMENTm
991         //                where m = (GL_DEPTH_ATTACHMENT - GL_COLOR_ATTACHMENT0).
992         ctx.glReadBuffer                        (GL_DEPTH_ATTACHMENT);
993         ctx.expectError                         (GL_INVALID_ENUM);
994         ctx.glReadBuffer                        (GL_STENCIL_ATTACHMENT);
995         ctx.expectError                         (GL_INVALID_ENUM);
996         ctx.glReadBuffer                        (GL_STENCIL_ATTACHMENT+1);
997         ctx.expectError                         (GL_INVALID_ENUM);
998         ctx.glReadBuffer                        (0xffffffffu);
999         ctx.expectError                         (GL_INVALID_ENUM);
1000         ctx.endSection();
1001
1002         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.");
1003         ctx.glReadBuffer                        (GL_BACK);
1004         ctx.expectError                         (GL_INVALID_OPERATION);
1005         ctx.glReadBuffer                        (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
1006         ctx.expectError                         (GL_INVALID_OPERATION);
1007
1008         if (GL_COLOR_ATTACHMENT0+maxColorAttachments < GL_DEPTH_ATTACHMENT-1)
1009         {
1010                 ctx.glReadBuffer                        (GL_DEPTH_ATTACHMENT - 1);
1011                 ctx.expectError                         (GL_INVALID_OPERATION);
1012         }
1013
1014         ctx.endSection();
1015
1016         ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK.");
1017         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
1018         ctx.glReadBuffer                        (GL_COLOR_ATTACHMENT0);
1019         ctx.expectError                         (GL_INVALID_OPERATION);
1020         ctx.endSection();
1021
1022         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.");
1023         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
1024         ctx.glReadBuffer                        (GL_BACK);
1025         ctx.expectError                         (GL_INVALID_OPERATION);
1026         ctx.endSection();
1027
1028         ctx.glDeleteTextures(1, &texture);
1029         ctx.glDeleteFramebuffers(1, &fbo);
1030 }
1031
1032 void unmap_buffer (NegativeTestContext& ctx)
1033 {
1034         deUint32                                buf             = 0x1234;
1035         std::vector<GLfloat>    data    (32);
1036
1037         ctx.glGenBuffers                        (1, &buf);
1038         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
1039         ctx.glBufferData                        (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
1040         ctx.expectError                         (GL_NO_ERROR);
1041
1042         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer data store is already in an unmapped state.");
1043         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
1044         ctx.expectError                         (GL_INVALID_OPERATION);
1045         ctx.endSection();
1046
1047         ctx.glDeleteBuffers                     (1, &buf);
1048 }
1049 // Framebuffer Objects
1050
1051 void bind_framebuffer (NegativeTestContext& ctx)
1052 {
1053         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER.");
1054         ctx.glBindFramebuffer(-1, 0);
1055         ctx.expectError(GL_INVALID_ENUM);
1056         ctx.glBindFramebuffer(GL_RENDERBUFFER, 0);
1057         ctx.expectError(GL_INVALID_ENUM);
1058         ctx.endSection();
1059 }
1060
1061 void bind_renderbuffer (NegativeTestContext& ctx)
1062 {
1063         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1064         ctx.glBindRenderbuffer(-1, 0);
1065         ctx.expectError(GL_INVALID_ENUM);
1066         ctx.glBindRenderbuffer(GL_FRAMEBUFFER, 0);
1067         ctx.expectError(GL_INVALID_ENUM);
1068         ctx.endSection();
1069 }
1070
1071 void check_framebuffer_status (NegativeTestContext& ctx)
1072 {
1073         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER..");
1074         ctx.glCheckFramebufferStatus(-1);
1075         ctx.expectError(GL_INVALID_ENUM);
1076         ctx.glCheckFramebufferStatus(GL_RENDERBUFFER);
1077         ctx.expectError(GL_INVALID_ENUM);
1078         ctx.endSection();
1079 }
1080
1081 void gen_framebuffers (NegativeTestContext& ctx)
1082 {
1083         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1084         ctx.glGenFramebuffers(-1, 0);
1085         ctx.expectError(GL_INVALID_VALUE);
1086         ctx.endSection();
1087 }
1088
1089 void gen_renderbuffers (NegativeTestContext& ctx)
1090 {
1091         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1092         ctx.glGenRenderbuffers(-1, 0);
1093         ctx.expectError(GL_INVALID_VALUE);
1094         ctx.endSection();
1095 }
1096
1097 void delete_framebuffers (NegativeTestContext& ctx)
1098 {
1099         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1100         ctx.glDeleteFramebuffers(-1, 0);
1101         ctx.expectError(GL_INVALID_VALUE);
1102         ctx.endSection();
1103 }
1104
1105 void delete_renderbuffers (NegativeTestContext& ctx)
1106 {;
1107         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1108         ctx.glDeleteRenderbuffers(-1, 0);
1109         ctx.expectError(GL_INVALID_VALUE);
1110         ctx.endSection();
1111 }
1112
1113 void framebuffer_renderbuffer (NegativeTestContext& ctx)
1114 {
1115         GLuint fbo = 0x1234;
1116         GLuint rbo = 0x1234;
1117         ctx.glGenFramebuffers(1, &fbo);
1118         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1119         ctx.glGenRenderbuffers(1, &rbo);
1120
1121         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1122         ctx.glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1123         ctx.expectError(GL_INVALID_ENUM);
1124         ctx.endSection();
1125
1126         ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1127         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, -1, GL_RENDERBUFFER, 0);
1128         ctx.expectError(GL_INVALID_ENUM);
1129         ctx.endSection();
1130
1131         ctx.beginSection("GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
1132         ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1133         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
1134         ctx.expectError(GL_INVALID_ENUM);
1135         ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
1136         ctx.endSection();
1137
1138         ctx.beginSection("GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
1139         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
1140         ctx.expectError(GL_INVALID_OPERATION);
1141         ctx.endSection();
1142
1143         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1144         ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1145         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1146         ctx.expectError(GL_INVALID_OPERATION);
1147         ctx.endSection();
1148
1149         ctx.glDeleteRenderbuffers(1, &rbo);
1150         ctx.glDeleteFramebuffers(1, &fbo);
1151 }
1152
1153 void framebuffer_texture (NegativeTestContext& ctx)
1154 {
1155         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1156         {
1157                 GLuint fbo = 0x1234;
1158                 GLuint texture[] = {0x1234, 0x1234};
1159
1160                 ctx.glGenFramebuffers(1, &fbo);
1161                 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1162                 ctx.glGenTextures(2, texture);
1163                 ctx.glBindTexture(GL_TEXTURE_2D, texture[0]);
1164                 ctx.glBindTexture(GL_TEXTURE_BUFFER, texture[1]);
1165                 ctx.expectError(GL_NO_ERROR);
1166
1167                 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1168                 ctx.glFramebufferTexture(-1, GL_COLOR_ATTACHMENT0, texture[0], 0);
1169                 ctx.expectError(GL_INVALID_ENUM);
1170                 ctx.endSection();
1171
1172                 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1173                 ctx.glFramebufferTexture(GL_FRAMEBUFFER, -1, texture[0], 0);
1174                 ctx.expectError(GL_INVALID_ENUM);
1175                 ctx.endSection();
1176
1177                 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1178                 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0);
1179                 ctx.expectError(GL_INVALID_VALUE);
1180                 ctx.endSection();
1181
1182                 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1183                 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1184                 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0);
1185                 ctx.expectError(GL_INVALID_OPERATION);
1186                 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1187                 ctx.endSection();
1188
1189                 ctx.beginSection("GL_INVALID_OPERATION is generated by if texture is a buffer texture.");
1190                 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture[1], 0);
1191                 ctx.expectError(GL_INVALID_OPERATION);
1192                 ctx.endSection();
1193
1194                 ctx.glDeleteFramebuffers(1, &fbo);
1195                 ctx.glDeleteBuffers(2, texture);
1196         }
1197 }
1198
1199 void framebuffer_texture2d (NegativeTestContext& ctx)
1200 {
1201         GLuint  fbo                             = 0x1234;
1202         GLuint  tex2D                   = 0x1234;
1203         GLuint  texCube                 = 0x1234;
1204         GLuint  tex2DMS                 = 0x1234;
1205         GLint   maxTexSize              = 0x1234;
1206         GLint   maxTexCubeSize  = 0x1234;
1207         int             maxSize                 = 0x1234;
1208
1209         ctx.glGenFramebuffers(1, &fbo);
1210         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1211         ctx.glGenTextures(1, &tex2D);
1212         ctx.glBindTexture(GL_TEXTURE_2D, tex2D);
1213         ctx.glGenTextures(1, &texCube);
1214         ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
1215         ctx.glGenTextures(1, &tex2DMS);
1216         ctx.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex2DMS);
1217         ctx.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
1218         ctx.glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxTexCubeSize);
1219         ctx.expectError(GL_NO_ERROR);
1220
1221         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1222         ctx.glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1223         ctx.expectError(GL_INVALID_ENUM);
1224         ctx.endSection();
1225
1226         ctx.beginSection("GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
1227         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
1228         ctx.expectError(GL_INVALID_ENUM);
1229         ctx.endSection();
1230
1231         ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not an accepted token.");
1232         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, -1, GL_TEXTURE_2D, tex2D, 0);
1233         ctx.expectError(GL_INVALID_ENUM);
1234         ctx.endSection();
1235
1236         ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.");
1237         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1238         ctx.expectError(GL_INVALID_VALUE);
1239         maxSize = deLog2Floor32(maxTexSize) + 1;
1240         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize);
1241         ctx.expectError(GL_INVALID_VALUE);
1242         maxSize = deLog2Floor32(maxTexSize) + 1;
1243         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize);
1244         ctx.expectError(GL_INVALID_VALUE);
1245         ctx.endSection();
1246
1247         ctx.beginSection("GL_INVALID_VALUE is generated if level is larger than maximum texture size.");
1248         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxTexSize + 1);
1249         ctx.expectError(GL_INVALID_VALUE);
1250         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1251         ctx.expectError(GL_INVALID_VALUE);
1252         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, maxTexCubeSize + 1);
1253         ctx.expectError(GL_INVALID_VALUE);
1254         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, -1);
1255         ctx.expectError(GL_INVALID_VALUE);
1256         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2DMS, 1);
1257         ctx.expectError(GL_INVALID_VALUE);
1258         ctx.endSection();
1259
1260         ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1261         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
1262         ctx.expectError(GL_INVALID_OPERATION);
1263         ctx.endSection();
1264
1265         ctx.beginSection("GL_INVALID_OPERATION is generated if textarget and texture are not compatible.");
1266         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
1267         ctx.expectError(GL_INVALID_OPERATION);
1268         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2D, 0);
1269         ctx.expectError(GL_INVALID_OPERATION);
1270         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
1271         ctx.expectError(GL_INVALID_OPERATION);
1272         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2DMS, 0);
1273         ctx.expectError(GL_INVALID_OPERATION);
1274         ctx.glDeleteTextures(1, &tex2D);
1275         ctx.glDeleteTextures(1, &texCube);
1276         ctx.glDeleteTextures(1, &tex2DMS);
1277         ctx.endSection();
1278
1279         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1280         ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1281         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1282         ctx.expectError(GL_INVALID_OPERATION);
1283         ctx.endSection();
1284
1285         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1286         {
1287                 GLuint texBuf = 0x1234;
1288                 ctx.beginSection("GL_INVALID_OPERATION error is generated if texture is the name of a buffer texture.");
1289                 ctx.glGenTextures(1, &texBuf);
1290                 ctx.glBindTexture(GL_TEXTURE_BUFFER, texBuf);
1291                 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1292                 ctx.expectError(GL_NO_ERROR);
1293                 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texBuf, 0);
1294                 ctx.expectError(GL_INVALID_OPERATION);
1295                 ctx.endSection();
1296         }
1297
1298         ctx.glDeleteFramebuffers(1, &fbo);
1299 }
1300
1301 void renderbuffer_storage (NegativeTestContext& ctx)
1302 {
1303         deUint32        rbo             = 0x1234;
1304         GLint           maxSize = 0x1234;
1305
1306         ctx.glGenRenderbuffers          (1, &rbo);
1307         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo);
1308
1309         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1310         ctx.glRenderbufferStorage       (-1, GL_RGBA4, 1, 1);
1311         ctx.expectError                         (GL_INVALID_ENUM);
1312         ctx.glRenderbufferStorage       (GL_FRAMEBUFFER, GL_RGBA4, 1, 1);
1313         ctx.expectError                         (GL_INVALID_ENUM);
1314         ctx.endSection();
1315
1316         ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1317         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, -1, 1, 1);
1318         ctx.expectError                         (GL_INVALID_ENUM);
1319
1320         if (!ctx.isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1321         {
1322                 ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGB16F, 1, 1);
1323                 ctx.expectError                         (GL_INVALID_ENUM);
1324         }
1325
1326         if (!ctx.isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1327         {
1328                 ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA8_SNORM, 1, 1);
1329                 ctx.expectError                         (GL_INVALID_ENUM);
1330         }
1331
1332         ctx.endSection();
1333
1334         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1335         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, -1, 1);
1336         ctx.expectError                         (GL_INVALID_VALUE);
1337         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, 1, -1);
1338         ctx.expectError                         (GL_INVALID_VALUE);
1339         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, -1, -1);
1340         ctx.expectError                         (GL_INVALID_VALUE);
1341         ctx.endSection();
1342
1343         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1344         ctx.glGetIntegerv                       (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1345         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
1346         ctx.expectError                         (GL_INVALID_VALUE);
1347         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
1348         ctx.expectError                         (GL_INVALID_VALUE);
1349         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
1350         ctx.expectError                         (GL_INVALID_VALUE);
1351         ctx.endSection();
1352
1353         ctx.glDeleteRenderbuffers(1, &rbo);
1354 }
1355
1356 void blit_framebuffer (NegativeTestContext& ctx)
1357 {
1358         deUint32                                        fbo[2];
1359         deUint32                                        rbo[2];
1360         deUint32                                        texture[2];
1361         deUint32                                        blankFrameBuffer;
1362
1363         ctx.glGenFramebuffers           (1, &blankFrameBuffer);
1364         ctx.glGenFramebuffers           (2, fbo);
1365         ctx.glGenTextures                       (2, texture);
1366         ctx.glGenRenderbuffers          (2, rbo);
1367
1368         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1369         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo[0]);
1370         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, fbo[0]);
1371
1372         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1373         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1374         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1375         ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1376         ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1377
1378         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[1]);
1379         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo[1]);
1380         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1381
1382         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1383         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1384         ctx.glFramebufferTexture2D      (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1385         ctx.glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1386         ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1387         ctx.expectError                         (GL_NO_ERROR);
1388
1389         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.");
1390         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 1, GL_NEAREST);
1391         ctx.expectError                         (GL_INVALID_VALUE);
1392         ctx.endSection();
1393
1394         ctx.beginSection("GL_INVALID_ENUM is generated if filter is not GL_LINEAR or GL_NEAREST.");
1395         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, 0);
1396         ctx.expectError                         (GL_INVALID_ENUM);
1397         ctx.endSection();
1398
1399         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.");
1400         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1401         ctx.expectError                         (GL_INVALID_OPERATION);
1402         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_LINEAR);
1403         ctx.expectError                         (GL_INVALID_OPERATION);
1404         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1405         ctx.expectError                         (GL_INVALID_OPERATION);
1406         ctx.endSection();
1407
1408         ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format.");
1409         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1410
1411         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1412         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1413         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32UI, draw buffer: GL_RGBA" << TestLog::EndMessage;
1414         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1415         ctx.expectError                         (GL_INVALID_OPERATION);
1416
1417         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1418         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1419         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA" << TestLog::EndMessage;
1420         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1421         ctx.expectError                         (GL_INVALID_OPERATION);
1422
1423         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1424         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1425         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[1]);
1426         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1427         ctx.glFramebufferTexture2D      (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1428         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA8, draw buffer: GL_RGBA32I" << TestLog::EndMessage;
1429         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1430         ctx.expectError                         (GL_INVALID_OPERATION);
1431         ctx.endSection();
1432
1433         ctx.beginSection("GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.");
1434         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1435         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1436         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1437         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1438         ctx.glFramebufferTexture2D      (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1439         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage;
1440         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR);
1441         ctx.expectError                         (GL_INVALID_OPERATION);
1442         ctx.endSection();
1443
1444         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.");
1445         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo[0]);
1446         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32);
1447         ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1448         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1449         ctx.expectError                         (GL_INVALID_OPERATION);
1450         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1451         ctx.expectError                         (GL_INVALID_OPERATION);
1452         ctx.endSection();
1453
1454         ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the read or draw framebuffer is not framebuffer complete.");
1455         ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1456         ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1457         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1458         ctx.expectError                         (GL_NO_ERROR);
1459         ctx.getLog() << TestLog::Message << "// incomplete read framebuffer" << TestLog::EndMessage;
1460         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, blankFrameBuffer);
1461         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1462         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1463         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1464         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1465         ctx.expectError                         (GL_INVALID_FRAMEBUFFER_OPERATION);
1466         ctx.getLog() << TestLog::Message << "// incomplete draw framebuffer" << TestLog::EndMessage;
1467         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, fbo[1]);
1468         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1469         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1470         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1471         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1472         ctx.expectError                         (GL_INVALID_FRAMEBUFFER_OPERATION);
1473         ctx.getLog() << TestLog::Message << "// incomplete read and draw framebuffer" << TestLog::EndMessage;
1474         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, blankFrameBuffer);
1475         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1476         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1477         TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1478         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1479         ctx.expectError                         (GL_INVALID_FRAMEBUFFER_OPERATION);
1480         // restore
1481         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, fbo[0]);
1482         ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1483         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1484         ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1485         ctx.endSection();
1486
1487         ctx.beginSection("GL_INVALID_OPERATION is generated if the source and destination buffers are identical.");
1488         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[0]);
1489         ctx.expectError                         (GL_NO_ERROR);
1490         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1491         ctx.expectError                         (GL_INVALID_OPERATION);
1492         // restore
1493         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1494         ctx.endSection();
1495
1496         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
1497         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, 0);
1498         ctx.glDeleteFramebuffers        (2, fbo);
1499         ctx.glDeleteFramebuffers        (1, &blankFrameBuffer);
1500         ctx.glDeleteTextures            (2, texture);
1501         ctx.glDeleteRenderbuffers       (2, rbo);
1502 }
1503
1504 void blit_framebuffer_multisample (NegativeTestContext& ctx)
1505 {
1506         deUint32                                                        fbo[2];
1507         deUint32                                                        rbo[2];
1508
1509         ctx.glGenFramebuffers                           (2, fbo);
1510         ctx.glGenRenderbuffers                          (2, rbo);
1511
1512         ctx.glBindRenderbuffer                          (GL_RENDERBUFFER, rbo[0]);
1513         ctx.glBindFramebuffer                           (GL_READ_FRAMEBUFFER, fbo[0]);
1514         ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1515         ctx.glFramebufferRenderbuffer           (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
1516         ctx.glCheckFramebufferStatus            (GL_READ_FRAMEBUFFER);
1517
1518         ctx.glBindRenderbuffer                          (GL_RENDERBUFFER, rbo[1]);
1519         ctx.glBindFramebuffer                           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1520
1521         ctx.expectError                                         (GL_NO_ERROR);
1522
1523         if (!ctx.isExtensionSupported("GL_NV_framebuffer_multisample"))
1524         {
1525                 ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_SAMPLE_BUFFERS for the draw buffer is greater than zero.");
1526                 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1527                 ctx.glFramebufferRenderbuffer           (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1528                 ctx.glBlitFramebuffer                           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1529                 ctx.expectError                                         (GL_INVALID_OPERATION);
1530                 ctx.endSection();
1531
1532                 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.");
1533                 ctx.glRenderbufferStorage                       (GL_RENDERBUFFER, GL_RGBA4, 32, 32);
1534                 ctx.glFramebufferRenderbuffer           (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1535                 ctx.glBlitFramebuffer                           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1536                 ctx.expectError                                         (GL_INVALID_OPERATION);
1537                 ctx.endSection();
1538
1539                 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.");
1540                 ctx.glRenderbufferStorage                       (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1541                 ctx.glFramebufferRenderbuffer           (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1542                 ctx.glBlitFramebuffer                           (0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1543                 ctx.expectError                                         (GL_INVALID_OPERATION);
1544                 ctx.endSection();
1545         }
1546
1547         ctx.glBindFramebuffer                           (GL_FRAMEBUFFER, 0);
1548         ctx.glDeleteRenderbuffers                       (2, rbo);
1549         ctx.glDeleteFramebuffers                        (2, fbo);
1550 }
1551
1552 void framebuffer_texture_layer (NegativeTestContext& ctx)
1553 {
1554         deUint32                                                fbo                                     = 0x1234;
1555         deUint32                                                tex3D                           = 0x1234;
1556         deUint32                                                tex2DArray                      = 0x1234;
1557         deUint32                                                tex2D                           = 0x1234;
1558         deUint32                                                tex2DMSArray            = 0x1234;
1559         deUint32                                                texCube                         = 0x1234;
1560         deUint32                                                texBuffer                       = 0x1234;
1561         int                                                             max3DTexSize            = 0x1234;
1562         int                                                             maxTexSize                      = 0x1234;
1563         int                                                             maxArrayTexLayers       = 0x1234;
1564         int                                                             maxCubeTexSize          = 0x1234;
1565         int                                                     log2Max3DTexSize        = 0x1234;
1566         int                                                     log2MaxTexSize          = 0x1234;
1567
1568         ctx.glGetIntegerv                               (GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize);
1569         ctx.glGetIntegerv                               (GL_MAX_TEXTURE_SIZE, &maxTexSize);
1570
1571         ctx.glGenFramebuffers                   (1, &fbo);
1572         ctx.glGenTextures                               (1, &tex3D);
1573         ctx.glGenTextures                               (1, &tex2DArray);
1574         ctx.glGenTextures                               (1, &tex2D);
1575         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1576
1577         ctx.glBindTexture                               (GL_TEXTURE_3D, tex3D);
1578         ctx.glTexImage3D                                (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1579         ctx.glBindTexture                               (GL_TEXTURE_2D_ARRAY, tex2DArray);
1580         ctx.glTexImage3D                                (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1581         ctx.glBindTexture                               (GL_TEXTURE_2D, tex2D);
1582         ctx.glTexImage2D                                (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1583
1584         ctx.expectError                                 (GL_NO_ERROR);
1585
1586         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1587         ctx.glFramebufferTextureLayer   (-1, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1588         ctx.expectError                                 (GL_INVALID_ENUM);
1589         ctx.glFramebufferTextureLayer   (GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1590         ctx.expectError                                 (GL_INVALID_ENUM);
1591         ctx.endSection();
1592
1593         ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1594         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, -1, tex3D, 0, 1);
1595         ctx.expectError                                 (GL_INVALID_ENUM);
1596         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1);
1597         ctx.expectError                                 (GL_INVALID_ENUM);
1598         ctx.endSection();
1599
1600         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.");
1601         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0);
1602         ctx.expectError                                 (GL_INVALID_OPERATION);
1603         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0);
1604         ctx.expectError                                 (GL_INVALID_OPERATION);
1605         ctx.endSection();
1606
1607         ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is negative.");
1608         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1);
1609         ctx.expectError                                 (GL_INVALID_VALUE);
1610         ctx.endSection();
1611
1612         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.");
1613         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
1614         ctx.expectError                                 (GL_INVALID_VALUE);
1615         ctx.endSection();
1616
1617         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.");
1618         ctx.glGetIntegerv                               (GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers);
1619         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
1620         ctx.expectError                                 (GL_INVALID_VALUE);
1621         ctx.endSection();
1622
1623         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1624         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, 0);
1625         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1626         ctx.expectError                                 (GL_INVALID_OPERATION);
1627         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1628         ctx.endSection();
1629
1630         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.");
1631         log2Max3DTexSize        = deLog2Floor32(max3DTexSize);
1632         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, -1, max3DTexSize - 1);
1633         ctx.expectError                                 (GL_INVALID_VALUE);
1634         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, log2Max3DTexSize + 1, max3DTexSize - 1);
1635         ctx.expectError                                 (GL_INVALID_VALUE);
1636         ctx.endSection();
1637
1638         ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D array texture and layer is less than 0 or greater than log2 of the value of GL_MAX_TEXTURE_SIZE.");
1639         log2MaxTexSize          = deLog2Floor32(maxTexSize);
1640         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, -1, maxArrayTexLayers - 1);
1641         ctx.expectError                                 (GL_INVALID_VALUE);
1642         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, log2MaxTexSize + 1, maxArrayTexLayers - 1);
1643         ctx.expectError                                 (GL_INVALID_VALUE);
1644         ctx.endSection();
1645
1646         if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1647         {
1648                 ctx.glGetIntegerv                               (GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxCubeTexSize);
1649                 ctx.glGenTextures                               (1, &tex2DMSArray);
1650                 ctx.glGenTextures                               (1, &texCube);
1651                 ctx.glGenTextures                               (1, &texBuffer);
1652                 ctx.glBindTexture                               (GL_TEXTURE_2D_MULTISAMPLE_ARRAY, tex2DMSArray);
1653                 ctx.glBindTexture                               (GL_TEXTURE_CUBE_MAP, texCube);
1654                 ctx.glBindTexture                               (GL_TEXTURE_BUFFER, texBuffer);
1655                 ctx.expectError                                 (GL_NO_ERROR);
1656
1657                 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D multisample array texture and layer not 0.");
1658                 ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, -1, 0);
1659                 ctx.expectError                                 (GL_INVALID_VALUE);
1660                 ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, 1, 0);
1661                 ctx.expectError                                 (GL_INVALID_VALUE);
1662                 ctx.endSection();
1663
1664                 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a cube map array texture and layer is larger than the value of MAX_CUBE_MAP_TEXTURE_SIZE-1 minus one.");
1665                 ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texCube, 0, maxCubeTexSize);
1666                 ctx.expectError                                 (GL_INVALID_VALUE);
1667                 ctx.endSection();
1668
1669                 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is the name of a buffer texture.");
1670                 ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texBuffer, 0, 0);
1671                 ctx.expectError                                 (GL_INVALID_OPERATION);
1672                 ctx.endSection();
1673
1674                 ctx.glDeleteTextures                    (1, &tex2DMSArray);
1675                 ctx.glDeleteTextures                    (1, &texCube);
1676                 ctx.glDeleteTextures                    (1, &texBuffer);
1677         }
1678
1679         ctx.glDeleteTextures            (1, &tex3D);
1680         ctx.glDeleteTextures            (1, &tex2DArray);
1681         ctx.glDeleteTextures            (1, &tex2D);
1682         ctx.glDeleteFramebuffers        (1, &fbo);
1683 }
1684
1685 void invalidate_framebuffer (NegativeTestContext& ctx)
1686 {
1687         deUint32        attachments[3];
1688         deUint32        fbo                             = 0x1234;
1689         deUint32        texture                         = 0x1234;
1690         int                     maxColorAttachments = 0x1234;
1691
1692         ctx.glGetIntegerv                               (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1693         attachments[0]                                  = GL_COLOR_ATTACHMENT0;
1694         attachments[1]                                  = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1695         attachments[2]                                  = GL_DEPTH_STENCIL_ATTACHMENT;
1696
1697         ctx.glGenFramebuffers                   (1, &fbo);
1698         ctx.glGenTextures                               (1, &texture);
1699         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1700         ctx.glBindTexture                               (GL_TEXTURE_2D, texture);
1701         ctx.glTexImage2D                                (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1702         ctx.glFramebufferTexture2D              (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1703         ctx.glCheckFramebufferStatus    (GL_FRAMEBUFFER);
1704         ctx.expectError                                 (GL_NO_ERROR);
1705
1706         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1707         ctx.glInvalidateFramebuffer             (-1, 1, &attachments[0]);
1708         ctx.expectError                                 (GL_INVALID_ENUM);
1709         ctx.glInvalidateFramebuffer             (GL_BACK, 1, &attachments[0]);
1710         ctx.expectError                                 (GL_INVALID_ENUM);
1711         ctx.endSection();
1712
1713         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.");
1714         ctx.glInvalidateFramebuffer             (GL_FRAMEBUFFER, 1, &attachments[1]);
1715         ctx.expectError                                 (GL_INVALID_OPERATION);
1716         ctx.endSection();
1717
1718         ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments is negative.");
1719         ctx.glInvalidateFramebuffer             (GL_FRAMEBUFFER, -1, &attachments[0]);
1720         ctx.expectError                                 (GL_INVALID_VALUE);
1721         ctx.endSection();
1722
1723         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.");
1724         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, 0);
1725         ctx.glInvalidateFramebuffer             (GL_FRAMEBUFFER, 1, &attachments[2]);
1726         ctx.expectError                                 (GL_INVALID_ENUM);
1727         ctx.endSection();
1728
1729
1730         ctx.glDeleteTextures            (1, &texture);
1731         ctx.glDeleteFramebuffers        (1, &fbo);
1732 }
1733
1734 void invalidate_sub_framebuffer (NegativeTestContext& ctx)
1735 {
1736         deUint32        attachments[3];
1737         deUint32        fbo                                     = 0x1234;
1738         deUint32        texture                         = 0x1234;
1739         int                     maxColorAttachments     = 0x1234;
1740
1741         ctx.glGetIntegerv                               (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1742         attachments[0]                                  = GL_COLOR_ATTACHMENT0;
1743         attachments[1]                                  = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1744         attachments[2]                                  = GL_DEPTH_STENCIL_ATTACHMENT;
1745
1746         ctx.glGenFramebuffers                   (1, &fbo);
1747         ctx.glGenTextures                               (1, &texture);
1748         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1749         ctx.glBindTexture                               (GL_TEXTURE_2D, texture);
1750         ctx.glTexImage2D                                (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1751         ctx.glFramebufferTexture2D              (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1752         ctx.glCheckFramebufferStatus    (GL_FRAMEBUFFER);
1753         ctx.expectError                                 (GL_NO_ERROR);
1754
1755         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1756         ctx.glInvalidateSubFramebuffer  (-1, 1, &attachments[0], 0, 0, 16, 16);
1757         ctx.expectError                                 (GL_INVALID_ENUM);
1758         ctx.glInvalidateSubFramebuffer  (GL_BACK, 1, &attachments[0], 0, 0, 16, 16);
1759         ctx.expectError                                 (GL_INVALID_ENUM);
1760         ctx.endSection();
1761
1762         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.");
1763         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16);
1764         ctx.expectError                                 (GL_INVALID_OPERATION);
1765         ctx.endSection();
1766
1767         ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments, width, or heigh is negative.");
1768         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, 16);
1769         ctx.expectError                                 (GL_INVALID_VALUE);
1770         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, 16);
1771         ctx.expectError                                 (GL_INVALID_VALUE);
1772         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, -1);
1773         ctx.expectError                                 (GL_INVALID_VALUE);
1774         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, -1);
1775         ctx.expectError                                 (GL_INVALID_VALUE);
1776         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, 16);
1777         ctx.expectError                                 (GL_INVALID_VALUE);
1778         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, 16, -1);
1779         ctx.expectError                                 (GL_INVALID_VALUE);
1780         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, -1);
1781         ctx.expectError                                 (GL_INVALID_VALUE);
1782         ctx.endSection();
1783
1784         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.");
1785         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, 0);
1786         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[2], 0, 0, 16, 16);
1787         ctx.expectError                                 (GL_INVALID_ENUM);
1788         ctx.endSection();
1789
1790         ctx.glDeleteTextures            (1, &texture);
1791         ctx.glDeleteFramebuffers        (1, &fbo);
1792 }
1793
1794 void renderbuffer_storage_multisample (NegativeTestContext& ctx)
1795 {
1796         deUint32        rbo                                                     = 0x1234;
1797         int                     maxSamplesSupportedRGBA4        = -1;
1798         int                     maxSamplesSupportedRGBA8UI      = -1;
1799         GLint           maxSize                                         = 0x1234;
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                                                 (GL_INVALID_ENUM);
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                                                 (GL_INVALID_ENUM);
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