Use invalid sample count in renderbuffer_storage_multisample negative case.
[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 #include "gluContextInfo.hpp"
28
29 #include "glwDefs.hpp"
30 #include "glwEnums.hpp"
31
32 namespace deqp
33 {
34 namespace gles31
35 {
36 namespace Functional
37 {
38 namespace NegativeTestShared
39 {
40
41 using tcu::TestLog;
42 using glu::CallLogWrapper;
43 using namespace glw;
44
45 // Buffers
46 void bind_buffer (NegativeTestContext& ctx)
47 {
48         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the allowable values.");
49         ctx.glBindBuffer(-1, 0);
50         ctx.expectError(GL_INVALID_ENUM);
51         ctx.endSection();
52 }
53
54 void delete_buffers (NegativeTestContext& ctx)
55 {
56         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
57         ctx.glDeleteBuffers(-1, 0);
58         ctx.expectError(GL_INVALID_VALUE);
59         ctx.endSection();
60 }
61
62 void gen_buffers (NegativeTestContext& ctx)
63 {
64         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
65         ctx.glGenBuffers(-1, 0);
66         ctx.expectError(GL_INVALID_VALUE);
67         ctx.endSection();
68 }
69
70 void buffer_data (NegativeTestContext& ctx)
71 {
72         GLuint buffer = 0x1234;
73         ctx.glGenBuffers(1, &buffer);
74         ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
75
76         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
77         ctx.glBufferData(-1, 0, NULL, GL_STREAM_DRAW);
78         ctx.expectError(GL_INVALID_ENUM);
79         ctx.endSection();
80
81         ctx.beginSection("GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW.");
82         ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, -1);
83         ctx.expectError(GL_INVALID_ENUM);
84         ctx.endSection();
85
86         ctx.beginSection("GL_INVALID_VALUE is generated if size is negative.");
87         ctx.glBufferData(GL_ARRAY_BUFFER, -1, NULL, GL_STREAM_DRAW);
88         ctx.expectError(GL_INVALID_VALUE);
89         ctx.endSection();
90
91         ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
92         ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
93         ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STREAM_DRAW);
94         ctx.expectError(GL_INVALID_OPERATION);
95         ctx.endSection();
96
97         ctx.glDeleteBuffers(1, &buffer);
98 }
99
100 void buffer_sub_data (NegativeTestContext& ctx)
101 {
102         GLuint buffer = 0x1234;
103         ctx.glGenBuffers(1, &buffer);
104         ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
105         ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
106
107         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
108         ctx.glBufferSubData(-1, 1, 1, 0);
109         ctx.expectError(GL_INVALID_ENUM);
110         ctx.endSection();
111
112         ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
113         ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
114         ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
115         ctx.expectError(GL_INVALID_OPERATION);
116         ctx.endSection();
117
118         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object being updated is mapped.");
119         ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
120         ctx.glMapBufferRange(GL_ARRAY_BUFFER, 0, 5, GL_MAP_READ_BIT);
121         ctx.expectError(GL_NO_ERROR);
122         ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
123         ctx.expectError(GL_INVALID_OPERATION);
124         ctx.endSection();
125
126         ctx.glDeleteBuffers(1, &buffer);
127 }
128
129 void buffer_sub_data_size_offset (NegativeTestContext& ctx)
130 {
131         GLuint buffer = 0x1234;
132         ctx.glGenBuffers(1, &buffer);
133         ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
134         ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
135
136         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.");
137         ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, 1, 0);
138         ctx.expectError(GL_INVALID_VALUE);
139         ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, -1, 0);
140         ctx.expectError(GL_INVALID_VALUE);
141         ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, -1, 0);
142         ctx.expectError(GL_INVALID_VALUE);
143         ctx.glBufferSubData(GL_ARRAY_BUFFER, 15, 1, 0);
144         ctx.expectError(GL_INVALID_VALUE);
145         ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 15, 0);
146         ctx.expectError(GL_INVALID_VALUE);
147         ctx.glBufferSubData(GL_ARRAY_BUFFER, 8, 8, 0);
148         ctx.expectError(GL_INVALID_VALUE);
149         ctx.endSection();
150
151         ctx.glDeleteBuffers(1, &buffer);
152 }
153
154 void clear (NegativeTestContext& ctx)
155 {
156         ctx.beginSection("GL_INVALID_VALUE is generated if any bit other than the three defined bits is set in mask.");
157         ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
158         ctx.expectError(GL_NO_ERROR);
159         ctx.glClear(0x00000200);
160         ctx.expectError(GL_INVALID_VALUE);
161         ctx.glClear(0x00001000);
162         ctx.expectError(GL_INVALID_VALUE);
163         ctx.glClear(0x00000010);
164         ctx.expectError(GL_INVALID_VALUE);
165         ctx.endSection();
166 }
167
168 void read_pixels (NegativeTestContext& ctx)
169 {
170         std::vector<GLubyte> ubyteData(4);
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         GLuint fbo = 0x1234;
188         ctx.glGenFramebuffers(1, &fbo);
189         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
190         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
191         ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
192         ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
193         ctx.endSection();
194
195         ctx.glDeleteFramebuffers(1, &fbo);
196 }
197
198 void read_pixels_format_mismatch (NegativeTestContext& ctx)
199 {
200         std::vector<GLubyte> ubyteData(4);
201         std::vector<GLushort> ushortData(4);
202
203         ctx.beginSection("Unsupported combinations of format and type will generate an INVALID_OPERATION error.");
204         ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
205         ctx.expectError(GL_INVALID_OPERATION);
206         ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
207         ctx.expectError(GL_INVALID_OPERATION);
208         ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
209         ctx.expectError(GL_INVALID_OPERATION);
210         ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
211         ctx.expectError(GL_INVALID_OPERATION);
212         ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
213         ctx.expectError(GL_INVALID_OPERATION);
214         ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
215         ctx.expectError(GL_INVALID_OPERATION);
216         ctx.endSection();
217
218         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.");
219         ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
220         ctx.expectError(GL_NO_ERROR);
221         GLint readFormat = 0x1234;
222         GLint readType = 0x1234;
223         ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
224         ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
225         ctx.glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]);
226         ctx.expectError(GL_NO_ERROR);
227         ctx.endSection();
228 }
229
230 void read_pixels_fbo_format_mismatch (NegativeTestContext& ctx)
231 {
232         std::vector<GLubyte>    ubyteData(4);
233         std::vector<float>              floatData(4);
234         deUint32                                fbo = 0x1234;
235         deUint32                                texture = 0x1234;
236
237         ctx.glGenTextures                       (1, &texture);
238         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
239         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
240         ctx.glGenFramebuffers           (1, &fbo);
241         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
242         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
243         ctx.expectError                         (GL_NO_ERROR);
244
245         ctx.beginSection("GL_INVALID_OPERATION is generated if currently bound framebuffer format is incompatible with format and type.");
246
247         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
248         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
249         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
250         ctx.expectError                         (GL_NO_ERROR);
251         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
252         ctx.expectError                         (GL_INVALID_OPERATION);
253
254         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
255         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
256         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
257         ctx.expectError                         (GL_NO_ERROR);
258         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
259         ctx.expectError                         (GL_INVALID_OPERATION);
260
261         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
262         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
263         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
264         ctx.expectError                         (GL_NO_ERROR);
265         ctx.glReadPixels                        (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
266         ctx.expectError                         (GL_INVALID_OPERATION);
267
268         ctx.endSection();
269
270         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.");
271
272         int                     binding                 = -1;
273         int                     sampleBuffers = 0x1234;
274         deUint32        rbo = 0x1234;
275
276         ctx.glGenRenderbuffers(1, &rbo);
277         ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
278         ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
279         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
280
281         ctx.glGetIntegerv                       (GL_READ_FRAMEBUFFER_BINDING, &binding);
282         ctx.getLog() << TestLog::Message << "// GL_READ_FRAMEBUFFER_BINDING: " << binding << TestLog::EndMessage;
283         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
284         ctx.glGetIntegerv                       (GL_SAMPLE_BUFFERS, &sampleBuffers);
285         ctx.getLog() << TestLog::Message << "// GL_SAMPLE_BUFFERS: " << sampleBuffers << TestLog::EndMessage;
286         ctx.expectError                         (GL_NO_ERROR);
287
288         if (binding == 0 || sampleBuffers <= 0)
289         {
290                 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;
291                 ctx.fail("Got invalid value");
292         }
293         else
294         {
295                 ctx.glReadPixels        (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
296                 ctx.expectError         (GL_INVALID_OPERATION);
297         }
298
299         ctx.endSection();
300
301         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, 0);
302         ctx.glBindTexture                       (GL_TEXTURE_2D, 0);
303         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
304         ctx.glDeleteFramebuffers        (1, &fbo);
305         ctx.glDeleteTextures            (1, &texture);
306         ctx.glDeleteRenderbuffers       (1, &rbo);
307 }
308
309 void bind_buffer_range (NegativeTestContext& ctx)
310 {
311         deUint32 bufU = 0x1234;
312         ctx.glGenBuffers(1, &bufU);
313         ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
314         ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
315
316         deUint32 bufTF = 0x1234;
317         ctx.glGenBuffers(1, &bufTF);
318         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
319         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
320
321         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
322         ctx.glBindBufferRange(GL_ARRAY_BUFFER, 0, bufU, 0, 4);
323         ctx.expectError(GL_INVALID_ENUM);
324         ctx.endSection();
325
326         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.");
327         int maxTFSize = 0x1234;
328         ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
329         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
330         ctx.expectError(GL_INVALID_VALUE);
331         ctx.endSection();
332
333         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.");
334         int maxUSize = 0x1234;
335         ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
336         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4);
337         ctx.expectError(GL_INVALID_VALUE);
338         ctx.endSection();
339
340         ctx.beginSection("GL_INVALID_VALUE is generated if size is less than or equal to zero.");
341         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1);
342         ctx.expectError(GL_INVALID_VALUE);
343         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0);
344         ctx.expectError(GL_INVALID_VALUE);
345         ctx.endSection();
346
347         ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.");
348         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
349         ctx.expectError(GL_INVALID_VALUE);
350         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
351         ctx.expectError(GL_INVALID_VALUE);
352         ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
353         ctx.expectError(GL_INVALID_VALUE);
354         ctx.endSection();
355
356         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.");
357         int alignment = 0x1234;
358         ctx.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment);
359         ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, alignment+1, 4);
360         ctx.expectError(GL_INVALID_VALUE);
361         ctx.endSection();
362
363         ctx.glDeleteBuffers(1, &bufU);
364         ctx.glDeleteBuffers(1, &bufTF);
365 }
366
367 void bind_buffer_base (NegativeTestContext& ctx)
368 {
369         deUint32 bufU = 0x1234;
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         deUint32 bufTF = 0x1234;
375         ctx.glGenBuffers(1, &bufTF);
376         ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
377         ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
378         ctx.expectError(GL_NO_ERROR);
379
380         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
381         ctx.glBindBufferBase(-1, 0, bufU);
382         ctx.expectError(GL_INVALID_ENUM);
383         ctx.glBindBufferBase(GL_ARRAY_BUFFER, 0, bufU);
384         ctx.expectError(GL_INVALID_ENUM);
385         ctx.endSection();
386
387         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.");
388         int maxUSize = 0x1234;
389         ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
390         ctx.glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU);
391         ctx.expectError(GL_INVALID_VALUE);
392         ctx.endSection();
393
394         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.");
395         int maxTFSize = 0x1234;
396         ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
397         ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
398         ctx.expectError(GL_INVALID_VALUE);
399         ctx.endSection();
400
401         ctx.glDeleteBuffers(1, &bufU);
402         ctx.glDeleteBuffers(1, &bufTF);
403 }
404
405 void clear_bufferiv (NegativeTestContext& ctx)
406 {
407         std::vector<int>                data(32*32);
408         deUint32                                fbo = 0x1234;
409         deUint32                                texture = 0x1234;
410
411         ctx.glGenTextures                       (1, &texture);
412         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
413         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
414         ctx.glGenFramebuffers           (1, &fbo);
415         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
416         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
417         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
418         ctx.expectError                         (GL_NO_ERROR);
419
420         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
421         ctx.glClearBufferiv(-1, 0, &data[0]);
422         ctx.expectError(GL_INVALID_ENUM);
423         ctx.glClearBufferiv(GL_FRAMEBUFFER, 0, &data[0]);
424         ctx.expectError(GL_INVALID_ENUM);
425         ctx.endSection();
426
427         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
428         int maxDrawBuffers = 0x1234;
429         ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
430         ctx.glClearBufferiv(GL_COLOR, maxDrawBuffers, &data[0]);
431         ctx.expectError(GL_INVALID_VALUE);
432         ctx.endSection();
433
434         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL.");
435         ctx.glClearBufferiv(GL_DEPTH, 1, &data[0]);
436         ctx.expectError(GL_INVALID_ENUM);
437         ctx.glClearBufferiv(GL_DEPTH_STENCIL, 1, &data[0]);
438         ctx.expectError(GL_INVALID_ENUM);
439         ctx.endSection();
440
441         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero.");
442         ctx.glClearBufferiv(GL_STENCIL, 1, &data[0]);
443         ctx.expectError(GL_INVALID_VALUE);
444         ctx.endSection();
445
446         ctx.glDeleteFramebuffers(1, &fbo);
447         ctx.glDeleteTextures(1, &texture);
448 }
449
450 void clear_bufferuiv (NegativeTestContext& ctx)
451 {
452         std::vector<deUint32>   data(32*32);
453         deUint32                                fbo = 0x1234;
454         deUint32                                texture = 0x1234;
455
456         ctx.glGenTextures                       (1, &texture);
457         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
458         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
459         ctx.glGenFramebuffers           (1, &fbo);
460         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
461         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
462         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
463         ctx.expectError                         (GL_NO_ERROR);
464
465         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
466         ctx.glClearBufferuiv(-1, 0, &data[0]);
467         ctx.expectError(GL_INVALID_ENUM);
468         ctx.glClearBufferuiv(GL_FRAMEBUFFER, 0, &data[0]);
469         ctx.expectError(GL_INVALID_ENUM);
470         ctx.endSection();
471
472         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
473         int maxDrawBuffers = 0x1234;
474         ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
475         ctx.glClearBufferuiv(GL_COLOR, maxDrawBuffers, &data[0]);
476         ctx.expectError(GL_INVALID_VALUE);
477         ctx.endSection();
478
479         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL or GL_DEPTH_STENCIL.");
480         ctx.glClearBufferuiv(GL_DEPTH, 1, &data[0]);
481         ctx.expectError(GL_INVALID_ENUM);
482         ctx.glClearBufferuiv(GL_STENCIL, 1, &data[0]);
483         ctx.expectError(GL_INVALID_ENUM);
484         ctx.glClearBufferuiv(GL_DEPTH_STENCIL, 1, &data[0]);
485         ctx.expectError(GL_INVALID_ENUM);
486         ctx.endSection();
487
488         ctx.glDeleteFramebuffers(1, &fbo);
489         ctx.glDeleteTextures(1, &texture);
490 }
491
492 void clear_bufferfv (NegativeTestContext& ctx)
493 {
494         std::vector<float>              data(32*32);
495         deUint32                                fbo = 0x1234;
496         deUint32                                texture = 0x1234;
497
498         ctx.glGenTextures                       (1, &texture);
499         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
500         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
501         ctx.glGenFramebuffers           (1, &fbo);
502         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
503         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
504         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
505         ctx.expectError                         (GL_NO_ERROR);
506
507         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
508         ctx.glClearBufferfv(-1, 0, &data[0]);
509         ctx.expectError(GL_INVALID_ENUM);
510         ctx.glClearBufferfv(GL_FRAMEBUFFER, 0, &data[0]);
511         ctx.expectError(GL_INVALID_ENUM);
512         ctx.endSection();
513
514         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
515         int maxDrawBuffers = 0x1234;
516         ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
517         ctx.glClearBufferfv(GL_COLOR, maxDrawBuffers, &data[0]);
518         ctx.expectError(GL_INVALID_VALUE);
519         ctx.endSection();
520
521         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL.");
522         ctx.glClearBufferfv(GL_STENCIL, 1, &data[0]);
523         ctx.expectError(GL_INVALID_ENUM);
524         ctx.glClearBufferfv(GL_DEPTH_STENCIL, 1, &data[0]);
525         ctx.expectError(GL_INVALID_ENUM);
526         ctx.endSection();
527
528         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero.");
529         ctx.glClearBufferfv(GL_DEPTH, 1, &data[0]);
530         ctx.expectError(GL_INVALID_VALUE);
531         ctx.endSection();
532
533         ctx.glDeleteFramebuffers(1, &fbo);
534         ctx.glDeleteTextures(1, &texture);
535 }
536
537 void clear_bufferfi (NegativeTestContext& ctx)
538 {
539         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
540         ctx.glClearBufferfi(-1, 0, 1.0f, 1);
541         ctx.expectError(GL_INVALID_ENUM);
542         ctx.glClearBufferfi(GL_FRAMEBUFFER, 0, 1.0f, 1);
543         ctx.expectError(GL_INVALID_ENUM);
544         ctx.endSection();
545
546         ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL.");
547         ctx.glClearBufferfi(GL_DEPTH, 0, 1.0f, 1);
548         ctx.expectError(GL_INVALID_ENUM);
549         ctx.glClearBufferfi(GL_STENCIL, 0, 1.0f, 1);
550         ctx.expectError(GL_INVALID_ENUM);
551         ctx.glClearBufferfi(GL_COLOR, 0, 1.0f, 1);
552         ctx.expectError(GL_INVALID_ENUM);
553         ctx.endSection();
554
555         ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero.");
556         ctx.glClearBufferfi(GL_DEPTH_STENCIL, 1, 1.0f, 1);
557         ctx.expectError(GL_INVALID_VALUE);
558         ctx.endSection();
559 }
560
561 void copy_buffer_sub_data (NegativeTestContext& ctx)
562 {
563         deUint32                                buf[2];
564         std::vector<float>              data(32*32);
565
566         ctx.glGenBuffers                        (2, buf);
567         ctx.glBindBuffer                        (GL_COPY_READ_BUFFER, buf[0]);
568         ctx.glBufferData                        (GL_COPY_READ_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
569         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[1]);
570         ctx.glBufferData                        (GL_COPY_WRITE_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
571         ctx.expectError                         (GL_NO_ERROR);
572
573         ctx.beginSection("GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative.");
574         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, -4);
575         ctx.expectError                         (GL_INVALID_VALUE);
576         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, -1, 0, 4);
577         ctx.expectError                         (GL_INVALID_VALUE);
578         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, -1, 4);
579         ctx.expectError                         (GL_INVALID_VALUE);
580         ctx.endSection();
581
582         ctx.beginSection("GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.");
583         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
584         ctx.expectError                         (GL_INVALID_VALUE);
585         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16);
586         ctx.expectError                         (GL_INVALID_VALUE);
587         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4);
588         ctx.expectError                         (GL_INVALID_VALUE);
589         ctx.endSection();
590
591         ctx.beginSection("GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.");
592         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
593         ctx.expectError                         (GL_INVALID_VALUE);
594         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16);
595         ctx.expectError                         (GL_INVALID_VALUE);
596         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4);
597         ctx.expectError                         (GL_INVALID_VALUE);
598         ctx.endSection();
599
600         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.");
601         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[0]);
602         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4);
603         ctx.expectError                         (GL_NO_ERROR);
604         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4);
605         ctx.expectError                         (GL_INVALID_VALUE);
606         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18);
607         ctx.expectError                         (GL_INVALID_VALUE);
608         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[1]);
609         ctx.endSection();
610
611         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget.");
612         ctx.glBindBuffer                        (GL_COPY_READ_BUFFER, 0);
613         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
614         ctx.expectError                         (GL_INVALID_OPERATION);
615
616         ctx.glBindBuffer                        (GL_COPY_READ_BUFFER, buf[0]);
617         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, 0);
618         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
619         ctx.expectError                         (GL_INVALID_OPERATION);
620
621         ctx.glBindBuffer                        (GL_COPY_WRITE_BUFFER, buf[1]);
622         ctx.endSection();
623
624         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped.");
625         ctx.glMapBufferRange            (GL_COPY_READ_BUFFER, 0, 4, GL_MAP_READ_BIT);
626         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
627         ctx.expectError                         (GL_INVALID_OPERATION);
628         ctx.glUnmapBuffer                       (GL_COPY_READ_BUFFER);
629
630         ctx.glMapBufferRange            (GL_COPY_WRITE_BUFFER, 0, 4, GL_MAP_READ_BIT);
631         ctx.glCopyBufferSubData         (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
632         ctx.expectError                         (GL_INVALID_OPERATION);
633         ctx.glUnmapBuffer                       (GL_COPY_WRITE_BUFFER);
634         ctx.endSection();
635
636         ctx.glDeleteBuffers(2, buf);
637 }
638
639 void draw_buffers (NegativeTestContext& ctx)
640 {
641         deUint32                                fbo = 0x1234;
642         deUint32                                texture = 0x1234;
643         int                                             maxDrawBuffers = 0x1234;
644         ctx.glGetIntegerv               (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
645         std::vector<deUint32>   values(maxDrawBuffers+1);
646         values[0]                               = GL_NONE;
647         values[1]                               = GL_BACK;
648         values[2]                               = GL_COLOR_ATTACHMENT0;
649         values[3]                               = GL_DEPTH_ATTACHMENT;
650         std::vector<GLfloat>    data(32*32);
651
652         ctx.glGenTextures                       (1, &texture);
653         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
654         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
655         ctx.glGenFramebuffers           (1, &fbo);
656         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
657         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
658         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
659         ctx.expectError                         (GL_NO_ERROR);
660
661         ctx.beginSection("GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.");
662         ctx.glDrawBuffers                       (2, &values[2]);
663         ctx.expectError                         (GL_INVALID_ENUM);
664         ctx.endSection();
665
666         ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1.");
667         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
668         ctx.glDrawBuffers                       (2, &values[0]);
669         ctx.expectError                         (GL_INVALID_OPERATION);
670         ctx.endSection();
671
672         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.");
673         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
674         ctx.glDrawBuffers                       (1, &values[2]);
675         ctx.expectError                         (GL_INVALID_OPERATION);
676         ctx.endSection();
677
678         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.");
679         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
680         ctx.glDrawBuffers                       (1, &values[1]);
681         ctx.expectError                         (GL_INVALID_OPERATION);
682         ctx.endSection();
683
684         ctx.beginSection("GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.");
685         ctx.glDrawBuffers                       (-1, &values[1]);
686         ctx.expectError                         (GL_INVALID_VALUE);
687         ctx.glDrawBuffers                       (maxDrawBuffers+1, &values[0]);
688         ctx.expectError                         (GL_INVALID_VALUE);
689         ctx.endSection();
690
691         ctx.glDeleteTextures(1, &texture);
692         ctx.glDeleteFramebuffers(1, &fbo);
693 }
694
695 void flush_mapped_buffer_range (NegativeTestContext& ctx)
696 {
697         deUint32                                buf = 0x1234;
698         std::vector<GLfloat>    data(32);
699
700         ctx.glGenBuffers                        (1, &buf);
701         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
702         ctx.glBufferData                        (GL_ARRAY_BUFFER, 32, &data[0], GL_STATIC_READ);
703         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
704         ctx.expectError                         (GL_NO_ERROR);
705
706         ctx.beginSection("GL_INVALID_VALUE is generated if offset or length is negative, or if offset + length exceeds the size of the mapping.");
707         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, -1, 1);
708         ctx.expectError                         (GL_INVALID_VALUE);
709         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, -1);
710         ctx.expectError                         (GL_INVALID_VALUE);
711         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 12, 8);
712         ctx.expectError                         (GL_INVALID_VALUE);
713         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 24, 4);
714         ctx.expectError                         (GL_INVALID_VALUE);
715         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 24);
716         ctx.expectError                         (GL_INVALID_VALUE);
717         ctx.endSection();
718
719         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
720         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, 0);
721         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
722         ctx.expectError                         (GL_INVALID_OPERATION);
723         ctx.endSection();
724
725         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.");
726         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
727         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
728         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
729         ctx.expectError                         (GL_INVALID_OPERATION);
730         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
731         ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
732         ctx.expectError                         (GL_INVALID_OPERATION);
733         ctx.endSection();
734
735         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
736         ctx.glDeleteBuffers                     (1, &buf);
737 }
738
739 void map_buffer_range (NegativeTestContext& ctx)
740 {
741         deUint32                                buf = 0x1234;
742         std::vector<GLfloat>    data(32);
743
744         ctx.glGenBuffers                        (1, &buf);
745         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
746         ctx.glBufferData                        (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
747         ctx.expectError                         (GL_NO_ERROR);
748
749         ctx.beginSection("GL_INVALID_VALUE is generated if either of offset or length is negative.");
750         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, -1, 1, GL_MAP_READ_BIT);
751         ctx.expectError                         (GL_INVALID_VALUE);
752
753         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 1, -1, GL_MAP_READ_BIT);
754         ctx.expectError                         (GL_INVALID_VALUE);
755         ctx.endSection();
756
757         ctx.beginSection("GL_INVALID_VALUE is generated if offset + length is greater than the value of GL_BUFFER_SIZE.");
758         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 33, GL_MAP_READ_BIT);
759         ctx.expectError                         (GL_INVALID_VALUE);
760
761         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 32, 1, GL_MAP_READ_BIT);
762         ctx.expectError                         (GL_INVALID_VALUE);
763
764         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 16, 17, GL_MAP_READ_BIT);
765         ctx.expectError                         (GL_INVALID_VALUE);
766         ctx.endSection();
767
768         ctx.beginSection("GL_INVALID_VALUE is generated if access has any bits set other than those accepted.");
769         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | 0x1000);
770         ctx.expectError                         (GL_INVALID_VALUE);
771
772         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | 0x1000);
773         ctx.expectError                         (GL_INVALID_VALUE);
774         ctx.endSection();
775
776         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer is already in a mapped state.");
777         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
778         ctx.expectError                         (GL_NO_ERROR);
779         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT);
780         ctx.expectError                         (GL_INVALID_OPERATION);
781         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
782         ctx.endSection();
783
784         ctx.beginSection("GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.");
785         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
786         ctx.expectError                         (GL_INVALID_OPERATION);
787         ctx.endSection();
788
789         ctx.beginSection("GL_INVALID_OPERATION is generated if ");
790         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
791         ctx.expectError                         (GL_INVALID_OPERATION);
792         ctx.endSection();
793
794         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.");
795         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
796         ctx.expectError                         (GL_INVALID_OPERATION);
797
798         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
799         ctx.expectError                         (GL_INVALID_OPERATION);
800
801         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
802         ctx.expectError                         (GL_INVALID_OPERATION);
803         ctx.endSection();
804
805         ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.");
806         ctx.glMapBufferRange            (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
807         ctx.expectError                         (GL_INVALID_OPERATION);
808         ctx.endSection();
809
810         ctx.glDeleteBuffers                     (1, &buf);
811 }
812
813 void read_buffer (NegativeTestContext& ctx)
814 {
815         deUint32        fbo                                     = 0x1234;
816         deUint32        texture                         = 0x1234;
817         int                     maxColorAttachments     = 0x1234;
818
819         ctx.glGetIntegerv                       (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
820         ctx.glGenTextures                       (1, &texture);
821         ctx.glBindTexture                       (GL_TEXTURE_2D, texture);
822         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
823         ctx.glGenFramebuffers           (1, &fbo);
824         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
825         ctx.glFramebufferTexture2D      (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
826         ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
827         ctx.expectError                         (GL_NO_ERROR);
828
829         ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_BACK, GL_NONE, or GL_COLOR_ATTACHMENTi.");
830         ctx.glReadBuffer                        (GL_NONE);
831         ctx.expectError                         (GL_NO_ERROR);
832         ctx.glReadBuffer                        (1);
833         ctx.expectError                         (GL_INVALID_ENUM);
834         ctx.glReadBuffer                        (GL_FRAMEBUFFER);
835         ctx.expectError                         (GL_INVALID_ENUM);
836         ctx.glReadBuffer                        (GL_COLOR_ATTACHMENT0 - 1);
837         ctx.expectError                         (GL_INVALID_ENUM);
838         ctx.glReadBuffer                        (GL_FRONT);
839         ctx.expectError                         (GL_INVALID_ENUM);
840
841         // \ note Spec isn't actually clear here, but it is safe to assume that
842         //                GL_DEPTH_ATTACHMENT can't be interpreted as GL_COLOR_ATTACHMENTm
843         //                where m = (GL_DEPTH_ATTACHMENT - GL_COLOR_ATTACHMENT0).
844         ctx.glReadBuffer                        (GL_DEPTH_ATTACHMENT);
845         ctx.expectError                         (GL_INVALID_ENUM);
846         ctx.glReadBuffer                        (GL_STENCIL_ATTACHMENT);
847         ctx.expectError                         (GL_INVALID_ENUM);
848         ctx.glReadBuffer                        (GL_STENCIL_ATTACHMENT+1);
849         ctx.expectError                         (GL_INVALID_ENUM);
850         ctx.glReadBuffer                        (0xffffffffu);
851         ctx.expectError                         (GL_INVALID_ENUM);
852         ctx.endSection();
853
854         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.");
855         ctx.glReadBuffer                        (GL_BACK);
856         ctx.expectError                         (GL_INVALID_OPERATION);
857         ctx.glReadBuffer                        (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
858         ctx.expectError                         (GL_INVALID_OPERATION);
859
860         if (GL_COLOR_ATTACHMENT0+maxColorAttachments < GL_DEPTH_ATTACHMENT-1)
861         {
862                 ctx.glReadBuffer                        (GL_DEPTH_ATTACHMENT - 1);
863                 ctx.expectError                         (GL_INVALID_OPERATION);
864         }
865
866         ctx.endSection();
867
868         ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK.");
869         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
870         ctx.glReadBuffer                        (GL_COLOR_ATTACHMENT0);
871         ctx.expectError                         (GL_INVALID_OPERATION);
872         ctx.endSection();
873
874         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.");
875         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, fbo);
876         ctx.glReadBuffer                        (GL_BACK);
877         ctx.expectError                         (GL_INVALID_OPERATION);
878         ctx.endSection();
879
880         ctx.glDeleteTextures(1, &texture);
881         ctx.glDeleteFramebuffers(1, &fbo);
882 }
883
884 void unmap_buffer (NegativeTestContext& ctx)
885 {
886         deUint32                                buf = 0x1234;
887         std::vector<GLfloat>    data(32);
888
889         ctx.glGenBuffers                        (1, &buf);
890         ctx.glBindBuffer                        (GL_ARRAY_BUFFER, buf);
891         ctx.glBufferData                        (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
892         ctx.expectError                         (GL_NO_ERROR);
893
894         ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer data store is already in an unmapped state.");
895         ctx.glUnmapBuffer                       (GL_ARRAY_BUFFER);
896         ctx.expectError                         (GL_INVALID_OPERATION);
897         ctx.endSection();
898
899         ctx.glDeleteBuffers                     (1, &buf);
900 }
901 // Framebuffer Objects
902
903 void bind_framebuffer (NegativeTestContext& ctx)
904 {
905         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
906         ctx.glBindFramebuffer(-1, 0);
907         ctx.expectError(GL_INVALID_ENUM);
908         ctx.glBindFramebuffer(GL_RENDERBUFFER, 0);
909         ctx.expectError(GL_INVALID_ENUM);
910         ctx.endSection();
911 }
912
913 void bind_renderbuffer (NegativeTestContext& ctx)
914 {
915         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
916         ctx.glBindRenderbuffer(-1, 0);
917         ctx.expectError(GL_INVALID_ENUM);
918         ctx.glBindRenderbuffer(GL_FRAMEBUFFER, 0);
919         ctx.expectError(GL_INVALID_ENUM);
920         ctx.endSection();
921 }
922
923 void check_framebuffer_status (NegativeTestContext& ctx)
924 {
925         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
926         ctx.glCheckFramebufferStatus(-1);
927         ctx.expectError(GL_INVALID_ENUM);
928         ctx.glCheckFramebufferStatus(GL_RENDERBUFFER);
929         ctx.expectError(GL_INVALID_ENUM);
930         ctx.endSection();
931 }
932
933 void gen_framebuffers (NegativeTestContext& ctx)
934 {
935         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
936         ctx.glGenFramebuffers(-1, 0);
937         ctx.expectError(GL_INVALID_VALUE);
938         ctx.endSection();
939 }
940
941 void gen_renderbuffers (NegativeTestContext& ctx)
942 {
943         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
944         ctx.glGenRenderbuffers(-1, 0);
945         ctx.expectError(GL_INVALID_VALUE);
946         ctx.endSection();
947 }
948
949 void delete_framebuffers (NegativeTestContext& ctx)
950 {
951         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
952         ctx.glDeleteFramebuffers(-1, 0);
953         ctx.expectError(GL_INVALID_VALUE);
954         ctx.endSection();
955 }
956
957 void delete_renderbuffers (NegativeTestContext& ctx)
958 {;
959         ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
960         ctx.glDeleteRenderbuffers(-1, 0);
961         ctx.expectError(GL_INVALID_VALUE);
962         ctx.endSection();
963 }
964
965 void framebuffer_renderbuffer (NegativeTestContext& ctx)
966 {
967         GLuint fbo = 0x1234;
968         GLuint rbo = 0x1234;
969         ctx.glGenFramebuffers(1, &fbo);
970         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
971         ctx.glGenRenderbuffers(1, &rbo);
972
973         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
974         ctx.glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
975         ctx.expectError(GL_INVALID_ENUM);
976         ctx.endSection();
977
978         ctx.beginSection("GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
979         ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
980         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
981         ctx.expectError(GL_INVALID_ENUM);
982         ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
983         ctx.endSection();
984
985         ctx.beginSection("GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
986         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
987         ctx.expectError(GL_INVALID_OPERATION);
988         ctx.endSection();
989
990         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
991         ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
992         ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
993         ctx.expectError(GL_INVALID_OPERATION);
994         ctx.endSection();
995
996         ctx.glDeleteRenderbuffers(1, &rbo);
997         ctx.glDeleteFramebuffers(1, &fbo);
998 }
999
1000 void framebuffer_texture2d (NegativeTestContext& ctx)
1001 {
1002         GLuint fbo = 0x1234;
1003         GLuint tex2D = 0x1234;
1004         GLuint texCube = 0x1234;
1005         GLint maxTexSize = 0x1234;
1006         GLint maxTexCubeSize = 0x1234;
1007
1008         ctx.glGenFramebuffers(1, &fbo);
1009         ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1010         ctx.glGenTextures(1, &tex2D);
1011         ctx.glBindTexture(GL_TEXTURE_2D, tex2D);
1012         ctx.glGenTextures(1, &texCube);
1013         ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
1014         ctx.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
1015         ctx.glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxTexCubeSize);
1016         ctx.expectError(GL_NO_ERROR);
1017
1018         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1019         ctx.glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1020         ctx.expectError(GL_INVALID_ENUM);
1021         ctx.endSection();
1022
1023         ctx.beginSection("GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
1024         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
1025         ctx.expectError(GL_INVALID_ENUM);
1026         ctx.endSection();
1027
1028         ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.");
1029         int maxSize = 0x1234;
1030         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1031         ctx.expectError(GL_INVALID_VALUE);
1032         maxSize = deLog2Floor32(maxTexSize) + 1;
1033         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize);
1034         ctx.expectError(GL_INVALID_VALUE);
1035         maxSize = deLog2Floor32(maxTexSize) + 1;
1036         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize);
1037         ctx.expectError(GL_INVALID_VALUE);
1038         ctx.endSection();
1039
1040         ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1041         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
1042         ctx.expectError(GL_INVALID_OPERATION);
1043         ctx.endSection();
1044
1045         ctx.beginSection("GL_INVALID_OPERATION is generated if textarget and texture are not compatible.");
1046         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
1047         ctx.expectError(GL_INVALID_OPERATION);
1048         ctx.glDeleteTextures(1, &tex2D);
1049
1050         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
1051         ctx.expectError(GL_INVALID_OPERATION);
1052         ctx.glDeleteTextures(1, &texCube);
1053         ctx.endSection();
1054
1055         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1056         ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1057         ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1058         ctx.expectError(GL_INVALID_OPERATION);
1059         ctx.endSection();
1060
1061         ctx.glDeleteFramebuffers(1, &fbo);
1062 }
1063
1064 void renderbuffer_storage (NegativeTestContext& ctx)
1065 {
1066         deUint32                                        rbo = 0x1234;
1067         ctx.glGenRenderbuffers          (1, &rbo);
1068         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo);
1069
1070         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1071         ctx.glRenderbufferStorage       (-1, GL_RGBA4, 1, 1);
1072         ctx.expectError                         (GL_INVALID_ENUM);
1073         ctx.glRenderbufferStorage       (GL_FRAMEBUFFER, GL_RGBA4, 1, 1);
1074         ctx.expectError                         (GL_INVALID_ENUM);
1075         ctx.endSection();
1076
1077         ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1078         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, -1, 1, 1);
1079         ctx.expectError                         (GL_INVALID_ENUM);
1080
1081         if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1082         {
1083                 ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGB16F, 1, 1);
1084                 ctx.expectError                         (GL_INVALID_ENUM);
1085         }
1086
1087         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA8_SNORM, 1, 1);
1088         ctx.expectError                         (GL_INVALID_ENUM);
1089         ctx.endSection();
1090
1091         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1092         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, -1, 1);
1093         ctx.expectError                         (GL_INVALID_VALUE);
1094         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, 1, -1);
1095         ctx.expectError                         (GL_INVALID_VALUE);
1096         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, -1, -1);
1097         ctx.expectError                         (GL_INVALID_VALUE);
1098         ctx.endSection();
1099
1100         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1101         GLint maxSize = 0x1234;
1102         ctx.glGetIntegerv                       (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1103         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
1104         ctx.expectError                         (GL_INVALID_VALUE);
1105         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
1106         ctx.expectError                         (GL_INVALID_VALUE);
1107         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
1108         ctx.expectError                         (GL_INVALID_VALUE);
1109         ctx.endSection();
1110
1111         ctx.glDeleteRenderbuffers(1, &rbo);
1112 }
1113
1114 void blit_framebuffer (NegativeTestContext& ctx)
1115 {
1116         deUint32                                        fbo[2];
1117         deUint32                                        rbo[2];
1118         deUint32                                        texture[2];
1119
1120         ctx.glGenFramebuffers           (2, fbo);
1121         ctx.glGenTextures                       (2, texture);
1122         ctx.glGenRenderbuffers          (2, rbo);
1123
1124         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1125         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo[0]);
1126         ctx.glBindFramebuffer           (GL_READ_FRAMEBUFFER, fbo[0]);
1127
1128         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1129         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1130         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1131         ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1132         ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1133
1134         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[1]);
1135         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo[1]);
1136         ctx.glBindFramebuffer           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1137
1138         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1139         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1140         ctx.glFramebufferTexture2D      (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1141         ctx.glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1142         ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1143         ctx.expectError                         (GL_NO_ERROR);
1144
1145         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.");
1146         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1147         ctx.expectError                         (GL_INVALID_OPERATION);
1148         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_LINEAR);
1149         ctx.expectError                         (GL_INVALID_OPERATION);
1150         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1151         ctx.expectError                         (GL_INVALID_OPERATION);
1152         ctx.endSection();
1153
1154         ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format.");
1155         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1156
1157         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1158         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1159         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32UI, draw buffer: GL_RGBA" << TestLog::EndMessage;
1160         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1161         ctx.expectError                         (GL_INVALID_OPERATION);
1162
1163         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1164         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1165         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA" << TestLog::EndMessage;
1166         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1167         ctx.expectError                         (GL_INVALID_OPERATION);
1168
1169         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1170         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1171         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[1]);
1172         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1173         ctx.glFramebufferTexture2D      (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1174         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA8, draw buffer: GL_RGBA32I" << TestLog::EndMessage;
1175         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1176         ctx.expectError                         (GL_INVALID_OPERATION);
1177         ctx.endSection();
1178
1179         ctx.beginSection("GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.");
1180         ctx.glBindTexture                       (GL_TEXTURE_2D, texture[0]);
1181         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1182         ctx.glFramebufferTexture2D      (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1183         ctx.glTexImage2D                        (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1184         ctx.glFramebufferTexture2D      (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1185         ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage;
1186         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR);
1187         ctx.expectError                         (GL_INVALID_OPERATION);
1188         ctx.endSection();
1189
1190         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.");
1191         ctx.glBindRenderbuffer          (GL_RENDERBUFFER, rbo[0]);
1192         ctx.glRenderbufferStorage       (GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32);
1193         ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1194         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1195         ctx.expectError                         (GL_INVALID_OPERATION);
1196         ctx.glBlitFramebuffer           (0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1197         ctx.expectError                         (GL_INVALID_OPERATION);
1198         ctx.endSection();
1199
1200         ctx.glBindFramebuffer           (GL_FRAMEBUFFER, 0);
1201         ctx.glDeleteFramebuffers        (2, fbo);
1202         ctx.glDeleteTextures            (2, texture);
1203         ctx.glDeleteRenderbuffers       (2, rbo);
1204 }
1205
1206 void blit_framebuffer_multisample (NegativeTestContext& ctx)
1207 {
1208         deUint32                                                        fbo[2];
1209         deUint32                                                        rbo[2];
1210
1211         ctx.glGenFramebuffers                           (2, fbo);
1212         ctx.glGenRenderbuffers                          (2, rbo);
1213
1214         ctx.glBindRenderbuffer                          (GL_RENDERBUFFER, rbo[0]);
1215         ctx.glBindFramebuffer                           (GL_READ_FRAMEBUFFER, fbo[0]);
1216         ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1217         ctx.glFramebufferRenderbuffer           (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
1218         ctx.glCheckFramebufferStatus            (GL_READ_FRAMEBUFFER);
1219
1220         ctx.glBindRenderbuffer                          (GL_RENDERBUFFER, rbo[1]);
1221         ctx.glBindFramebuffer                           (GL_DRAW_FRAMEBUFFER, fbo[1]);
1222
1223         ctx.expectError                                         (GL_NO_ERROR);
1224
1225         ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_SAMPLE_BUFFERS for the draw buffer is greater than zero.");
1226         ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1227         ctx.glFramebufferRenderbuffer           (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1228         ctx.glBlitFramebuffer                           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1229         ctx.expectError                                         (GL_INVALID_OPERATION);
1230         ctx.endSection();
1231
1232         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.");
1233         ctx.glRenderbufferStorage                       (GL_RENDERBUFFER, GL_RGBA4, 32, 32);
1234         ctx.glFramebufferRenderbuffer           (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1235         ctx.glBlitFramebuffer                           (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1236         ctx.expectError                                         (GL_INVALID_OPERATION);
1237         ctx.endSection();
1238
1239         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.");
1240         ctx.glRenderbufferStorage                       (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1241         ctx.glFramebufferRenderbuffer           (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1242         ctx.glBlitFramebuffer                           (0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1243         ctx.expectError                                         (GL_INVALID_OPERATION);
1244         ctx.endSection();
1245
1246         ctx.glBindFramebuffer                           (GL_FRAMEBUFFER, 0);
1247         ctx.glDeleteRenderbuffers                       (2, rbo);
1248         ctx.glDeleteFramebuffers                        (2, fbo);
1249 }
1250
1251 void framebuffer_texture_layer (NegativeTestContext& ctx)
1252 {
1253         deUint32                                                fbo = 0x1234;
1254         deUint32                                                tex3D;
1255         deUint32                                                tex2DArray;
1256         deUint32                                                tex2D;
1257
1258         ctx.glGenFramebuffers                   (1, &fbo);
1259         ctx.glGenTextures                               (1, &tex3D);
1260         ctx.glGenTextures                               (1, &tex2DArray);
1261         ctx.glGenTextures                               (1, &tex2D);
1262         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1263
1264         ctx.glBindTexture                               (GL_TEXTURE_3D, tex3D);
1265         ctx.glTexImage3D                                (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1266         ctx.glBindTexture                               (GL_TEXTURE_2D_ARRAY, tex2DArray);
1267         ctx.glTexImage3D                                (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1268         ctx.glBindTexture                               (GL_TEXTURE_2D, tex2D);
1269         ctx.glTexImage2D                                (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1270
1271         ctx.expectError                                 (GL_NO_ERROR);
1272
1273         ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1274         ctx.glFramebufferTextureLayer   (-1, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1275         ctx.expectError                                 (GL_INVALID_ENUM);
1276         ctx.glFramebufferTextureLayer   (GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1277         ctx.expectError                                 (GL_INVALID_ENUM);
1278         ctx.endSection();
1279
1280         ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1281         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, -1, tex3D, 0, 1);
1282         ctx.expectError                                 (GL_INVALID_ENUM);
1283         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1);
1284         ctx.expectError                                 (GL_INVALID_ENUM);
1285         ctx.endSection();
1286
1287         ctx.beginSection("GL_INVALID_OPERATION is generated if texture is non-zero and not the name of a 3D texture or 2D array texture.");
1288         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0);
1289         ctx.expectError                                 (GL_INVALID_OPERATION);
1290         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0);
1291         ctx.expectError                                 (GL_INVALID_OPERATION);
1292         ctx.endSection();
1293
1294         ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is negative.");
1295         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1);
1296         ctx.expectError                                 (GL_INVALID_VALUE);
1297         ctx.endSection();
1298
1299         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.");
1300         int                                                     max3DTexSize = 0x1234;
1301         ctx.glGetIntegerv                               (GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize);
1302         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
1303         ctx.expectError                                 (GL_INVALID_VALUE);
1304         ctx.endSection();
1305
1306         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.");
1307         int                                                     maxArrayTexLayers = 0x1234;
1308         ctx.glGetIntegerv                               (GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers);
1309         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
1310         ctx.expectError                                 (GL_INVALID_VALUE);
1311         ctx.endSection();
1312
1313         ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1314         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, 0);
1315         ctx.glFramebufferTextureLayer   (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1316         ctx.expectError                                 (GL_INVALID_OPERATION);
1317         ctx.endSection();
1318
1319         ctx.glDeleteTextures            (1, &tex3D);
1320         ctx.glDeleteTextures            (1, &tex2DArray);
1321         ctx.glDeleteTextures            (1, &tex2D);
1322         ctx.glDeleteFramebuffers        (1, &fbo);
1323 }
1324
1325 void invalidate_framebuffer (NegativeTestContext& ctx)
1326 {
1327         deUint32                                        fbo = 0x1234;
1328         deUint32                                        texture = 0x1234;
1329         deUint32                                        attachments[2];
1330         int                                                     maxColorAttachments = 0x1234;
1331         ctx.glGetIntegerv                               (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1332         attachments[0]                          = GL_COLOR_ATTACHMENT0;
1333         attachments[1]                          = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1334
1335         ctx.glGenFramebuffers                   (1, &fbo);
1336         ctx.glGenTextures                               (1, &texture);
1337         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1338         ctx.glBindTexture                               (GL_TEXTURE_2D, texture);
1339         ctx.glTexImage2D                                (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1340         ctx.glFramebufferTexture2D              (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1341         ctx.glCheckFramebufferStatus    (GL_FRAMEBUFFER);
1342         ctx.expectError                                 (GL_NO_ERROR);
1343
1344         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1345         ctx.glInvalidateFramebuffer             (-1, 1, &attachments[0]);
1346         ctx.expectError                                 (GL_INVALID_ENUM);
1347         ctx.glInvalidateFramebuffer             (GL_BACK, 1, &attachments[0]);
1348         ctx.expectError                                 (GL_INVALID_ENUM);
1349         ctx.endSection();
1350
1351         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.");
1352         ctx.glInvalidateFramebuffer             (GL_FRAMEBUFFER, 1, &attachments[1]);
1353         ctx.expectError                                 (GL_INVALID_OPERATION);
1354         ctx.endSection();
1355
1356         ctx.glDeleteTextures            (1, &texture);
1357         ctx.glDeleteFramebuffers        (1, &fbo);
1358 }
1359
1360 void invalidate_sub_framebuffer (NegativeTestContext& ctx)
1361 {
1362         deUint32                                        fbo = 0x1234;
1363         deUint32                                        texture = 0x1234;
1364         deUint32                                        attachments[2];
1365         int                                                     maxColorAttachments = 0x1234;
1366         ctx.glGetIntegerv                               (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1367         attachments[0]                          = GL_COLOR_ATTACHMENT0;
1368         attachments[1]                          = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1369
1370         ctx.glGenFramebuffers                   (1, &fbo);
1371         ctx.glGenTextures                               (1, &texture);
1372         ctx.glBindFramebuffer                   (GL_FRAMEBUFFER, fbo);
1373         ctx.glBindTexture                               (GL_TEXTURE_2D, texture);
1374         ctx.glTexImage2D                                (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1375         ctx.glFramebufferTexture2D              (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1376         ctx.glCheckFramebufferStatus    (GL_FRAMEBUFFER);
1377         ctx.expectError                                 (GL_NO_ERROR);
1378
1379         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1380         ctx.glInvalidateSubFramebuffer  (-1, 1, &attachments[0], 0, 0, 16, 16);
1381         ctx.expectError                                 (GL_INVALID_ENUM);
1382         ctx.glInvalidateSubFramebuffer  (GL_BACK, 1, &attachments[0], 0, 0, 16, 16);
1383         ctx.expectError                                 (GL_INVALID_ENUM);
1384         ctx.endSection();
1385
1386         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.");
1387         ctx.glInvalidateSubFramebuffer  (GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16);
1388         ctx.expectError                                 (GL_INVALID_OPERATION);
1389         ctx.endSection();
1390
1391         ctx.glDeleteTextures            (1, &texture);
1392         ctx.glDeleteFramebuffers        (1, &fbo);
1393 }
1394
1395 void renderbuffer_storage_multisample (NegativeTestContext& ctx)
1396 {
1397         deUint32                                                        rbo = 0x1234;
1398         int                                                                     maxSamplesSupportedRGBA4 = -1;
1399         int                                                                     maxSamplesSupportedRGBA8UI = -1;
1400
1401         ctx.glGetInternalformativ                               (GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, 1, &maxSamplesSupportedRGBA4);
1402         ctx.glGetInternalformativ                               (GL_RENDERBUFFER, GL_RGBA8UI, GL_SAMPLES, 1, &maxSamplesSupportedRGBA8UI);
1403
1404         ctx.glGenRenderbuffers                                  (1, &rbo);
1405         ctx.glBindRenderbuffer                                  (GL_RENDERBUFFER, rbo);
1406
1407         ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1408         ctx.glRenderbufferStorageMultisample    (-1, 2, GL_RGBA4, 1, 1);
1409         ctx.expectError                                                 (GL_INVALID_ENUM);
1410         ctx.glRenderbufferStorageMultisample    (GL_FRAMEBUFFER, 2, GL_RGBA4, 1, 1);
1411         ctx.expectError                                                 (GL_INVALID_ENUM);
1412         ctx.endSection();
1413
1414         ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.");
1415         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, maxSamplesSupportedRGBA4+1, GL_RGBA4, 1, 1);
1416         ctx.expectError                                                 (GL_INVALID_OPERATION);
1417         ctx.endSection();
1418
1419         ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1420         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, -1, 1, 1);
1421         ctx.expectError                                                 (GL_INVALID_ENUM);
1422
1423         if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1424         {
1425                 ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGB16F, 1, 1);
1426                 ctx.expectError                                                 (GL_INVALID_ENUM);
1427         }
1428
1429         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGBA8_SNORM, 1, 1);
1430         ctx.expectError                                                 (GL_INVALID_ENUM);
1431         ctx.endSection();
1432
1433         ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat. (Unsigned integer format)");
1434         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, maxSamplesSupportedRGBA8UI+1, GL_RGBA8UI, 1, 1);
1435         ctx.expectError                                                 (GL_INVALID_OPERATION);
1436         ctx.endSection();
1437
1438         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1439         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGBA4, -1, 1);
1440         ctx.expectError                                                 (GL_INVALID_VALUE);
1441         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGBA4, 1, -1);
1442         ctx.expectError                                                 (GL_INVALID_VALUE);
1443         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 2, GL_RGBA4, -1, -1);
1444         ctx.expectError                                                 (GL_INVALID_VALUE);
1445         ctx.endSection();
1446
1447         ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1448         GLint maxSize = 0x1234;
1449         ctx.glGetIntegerv                                               (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1450         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 4, GL_RGBA4, 1, maxSize+1);
1451         ctx.expectError                                                 (GL_INVALID_VALUE);
1452         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, 1);
1453         ctx.expectError                                                 (GL_INVALID_VALUE);
1454         ctx.glRenderbufferStorageMultisample    (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, maxSize+1);
1455         ctx.expectError                                                 (GL_INVALID_VALUE);
1456         ctx.endSection();
1457
1458         ctx.glDeleteRenderbuffers(1, &rbo);
1459 }
1460
1461 std::vector<FunctionContainer> getNegativeBufferApiTestFunctions ()
1462 {
1463         FunctionContainer funcs[] =
1464         {
1465                 {bind_buffer,                                           "bind_buffer",                                          "Invalid glBindBuffer() usage"                                    },
1466                 {delete_buffers,                                        "delete_buffers",                                       "Invalid glDeleteBuffers() usage"                                 },
1467                 {gen_buffers,                                           "gen_buffers",                                          "Invalid glGenBuffers() usage"                                    },
1468                 {buffer_data,                                           "buffer_data",                                          "Invalid glBufferData() usage"                                    },
1469                 {buffer_sub_data,                                       "buffer_sub_data",                                      "Invalid glBufferSubData() usage"                                 },
1470                 {buffer_sub_data_size_offset,           "buffer_sub_data_size_offset",          "Invalid glBufferSubData() usage"                                 },
1471                 {clear,                                                         "clear",                                                        "Invalid glClear() usage"                                                 },
1472                 {read_pixels,                                           "read_pixels",                                          "Invalid glReadPixels() usage"                                    },
1473                 {read_pixels_format_mismatch,           "read_pixels_format_mismatch",          "Invalid glReadPixels() usage"                                    },
1474                 {read_pixels_fbo_format_mismatch,       "read_pixels_fbo_format_mismatch",      "Invalid glReadPixels() usage"                                    },
1475                 {bind_buffer_range,                                     "bind_buffer_range",                            "Invalid glBindBufferRange() usage"                               },
1476                 {bind_buffer_base,                                      "bind_buffer_base",                                     "Invalid glBindBufferBase() usage"                                },
1477                 {clear_bufferiv,                                        "clear_bufferiv",                                       "Invalid glClearBufferiv() usage"                                 },
1478                 {clear_bufferuiv,                                       "clear_bufferuiv",                                      "Invalid glClearBufferuiv() usage"                                },
1479                 {clear_bufferfv,                                        "clear_bufferfv",                                       "Invalid glClearBufferfv() usage"                                 },
1480                 {clear_bufferfi,                                        "clear_bufferfi",                                       "Invalid glClearBufferfi() usage"                                 },
1481                 {copy_buffer_sub_data,                          "copy_buffer_sub_data",                         "Invalid glCopyBufferSubData() usage"                     },
1482                 {draw_buffers,                                          "draw_buffers",                                         "Invalid glDrawBuffers() usage"                                   },
1483                 {flush_mapped_buffer_range,                     "flush_mapped_buffer_range",            "Invalid glFlushMappedBufferRange() usage"                },
1484                 {map_buffer_range,                                      "map_buffer_range",                                     "Invalid glMapBufferRange() usage"                                },
1485                 {read_buffer,                                           "read_buffer",                                          "Invalid glReadBuffer() usage"                                    },
1486                 {unmap_buffer,                                          "unmap_buffer",                                         "Invalid glUnmapBuffer() usage"                                   },
1487                 {bind_framebuffer,                                      "bind_framebuffer",                                     "Invalid glBindFramebuffer() usage"                               },
1488                 {bind_renderbuffer,                                     "bind_renderbuffer",                            "Invalid glBindRenderbuffer() usage"                      },
1489                 {check_framebuffer_status,                      "check_framebuffer_status",                     "Invalid glCheckFramebufferStatus() usage"                },
1490                 {gen_framebuffers,                                      "gen_framebuffers",                                     "Invalid glGenFramebuffers() usage"                               },
1491                 {gen_renderbuffers,                                     "gen_renderbuffers",                            "Invalid glGenRenderbuffers() usage"                      },
1492                 {delete_framebuffers,                           "delete_framebuffers",                          "Invalid glDeleteFramebuffers() usage"                    },
1493                 {delete_renderbuffers,                          "delete_renderbuffers",                         "Invalid glDeleteRenderbuffers() usage"                   },
1494                 {framebuffer_renderbuffer,                      "framebuffer_renderbuffer",                     "Invalid glFramebufferRenderbuffer() usage"               },
1495                 {framebuffer_texture2d,                         "framebuffer_texture2d",                        "Invalid glFramebufferTexture2D() usage"                  },
1496                 {renderbuffer_storage,                          "renderbuffer_storage",                         "Invalid glRenderbufferStorage() usage"                   },
1497                 {blit_framebuffer,                                      "blit_framebuffer",                                     "Invalid glBlitFramebuffer() usage"                               },
1498                 {blit_framebuffer_multisample,          "blit_framebuffer_multisample",         "Invalid glBlitFramebuffer() usage"                               },
1499                 {framebuffer_texture_layer,                     "framebuffer_texture_layer",            "Invalid glFramebufferTextureLayer() usage"               },
1500                 {invalidate_framebuffer,                        "invalidate_framebuffer",                       "Invalid glInvalidateFramebuffer() usage"                 },
1501                 {invalidate_sub_framebuffer,            "invalidate_sub_framebuffer",           "Invalid glInvalidateSubFramebuffer() usage"      },
1502                 {renderbuffer_storage_multisample,      "renderbuffer_storage_multisample",     "Invalid glRenderbufferStorageMultisample() usage"},
1503         };
1504
1505         return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
1506 }
1507
1508 } // NegativeTestShared
1509 } // Functional
1510 } // gles31
1511 } // deqp