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