1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.1 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Negative Buffer API tests.
22 *//*--------------------------------------------------------------------*/
24 #include "es31fNegativeBufferApiTests.hpp"
26 #include "gluCallLogWrapper.hpp"
27 #include "gluContextInfo.hpp"
29 #include "glwDefs.hpp"
30 #include "glwEnums.hpp"
38 namespace NegativeTestShared
42 using glu::CallLogWrapper;
46 void bind_buffer (NegativeTestContext& ctx)
48 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the allowable values.");
49 ctx.glBindBuffer(-1, 0);
50 ctx.expectError(GL_INVALID_ENUM);
54 void delete_buffers (NegativeTestContext& ctx)
56 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
57 ctx.glDeleteBuffers(-1, 0);
58 ctx.expectError(GL_INVALID_VALUE);
62 void gen_buffers (NegativeTestContext& ctx)
64 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
65 ctx.glGenBuffers(-1, 0);
66 ctx.expectError(GL_INVALID_VALUE);
70 void buffer_data (NegativeTestContext& ctx)
72 GLuint buffer = 0x1234;
73 ctx.glGenBuffers(1, &buffer);
74 ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
76 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
77 ctx.glBufferData(-1, 0, NULL, GL_STREAM_DRAW);
78 ctx.expectError(GL_INVALID_ENUM);
81 ctx.beginSection("GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW.");
82 ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, -1);
83 ctx.expectError(GL_INVALID_ENUM);
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);
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);
97 ctx.glDeleteBuffers(1, &buffer);
100 void buffer_sub_data (NegativeTestContext& ctx)
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);
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);
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);
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);
126 ctx.glDeleteBuffers(1, &buffer);
129 void buffer_sub_data_size_offset (NegativeTestContext& ctx)
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);
136 ctx.beginSection("GL_INVALID_VALUE is generated if offset or size is negative, or if together they define a region of memory that extends beyond the buffer object's allocated data store.");
137 ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, 1, 0);
138 ctx.expectError(GL_INVALID_VALUE);
139 ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, -1, 0);
140 ctx.expectError(GL_INVALID_VALUE);
141 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, -1, 0);
142 ctx.expectError(GL_INVALID_VALUE);
143 ctx.glBufferSubData(GL_ARRAY_BUFFER, 15, 1, 0);
144 ctx.expectError(GL_INVALID_VALUE);
145 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 15, 0);
146 ctx.expectError(GL_INVALID_VALUE);
147 ctx.glBufferSubData(GL_ARRAY_BUFFER, 8, 8, 0);
148 ctx.expectError(GL_INVALID_VALUE);
151 ctx.glDeleteBuffers(1, &buffer);
154 void clear (NegativeTestContext& ctx)
156 ctx.beginSection("GL_INVALID_VALUE is generated if any bit other than the three defined bits is set in mask.");
157 ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
158 ctx.expectError(GL_NO_ERROR);
159 ctx.glClear(0x00000200);
160 ctx.expectError(GL_INVALID_VALUE);
161 ctx.glClear(0x00001000);
162 ctx.expectError(GL_INVALID_VALUE);
163 ctx.glClear(0x00000010);
164 ctx.expectError(GL_INVALID_VALUE);
168 void read_pixels (NegativeTestContext& ctx)
170 std::vector<GLubyte> ubyteData(4);
172 ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of format and type is unsupported.");
173 ctx.glReadPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ubyteData[0]);
174 ctx.expectError(GL_INVALID_OPERATION);
177 ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
178 ctx.glReadPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
179 ctx.expectError(GL_INVALID_VALUE);
180 ctx.glReadPixels(0, 0, 1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
181 ctx.expectError(GL_INVALID_VALUE);
182 ctx.glReadPixels(0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
183 ctx.expectError(GL_INVALID_VALUE);
186 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
188 ctx.glGenFramebuffers(1, &fbo);
189 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
190 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
191 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
192 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
195 ctx.glDeleteFramebuffers(1, &fbo);
198 void read_pixels_format_mismatch (NegativeTestContext& ctx)
200 std::vector<GLubyte> ubyteData(4);
201 std::vector<GLushort> ushortData(4);
203 ctx.beginSection("Unsupported combinations of format and type will generate an INVALID_OPERATION error.");
204 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
205 ctx.expectError(GL_INVALID_OPERATION);
206 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
207 ctx.expectError(GL_INVALID_OPERATION);
208 ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
209 ctx.expectError(GL_INVALID_OPERATION);
210 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
211 ctx.expectError(GL_INVALID_OPERATION);
212 ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
213 ctx.expectError(GL_INVALID_OPERATION);
214 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
215 ctx.expectError(GL_INVALID_OPERATION);
218 ctx.beginSection("GL_RGBA/GL_UNSIGNED_BYTE is always accepted and the other acceptable pair can be discovered by querying GL_IMPLEMENTATION_COLOR_READ_FORMAT and GL_IMPLEMENTATION_COLOR_READ_TYPE.");
219 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
220 ctx.expectError(GL_NO_ERROR);
221 GLint readFormat = 0x1234;
222 GLint readType = 0x1234;
223 ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
224 ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
225 ctx.glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]);
226 ctx.expectError(GL_NO_ERROR);
230 void read_pixels_fbo_format_mismatch (NegativeTestContext& ctx)
232 std::vector<GLubyte> ubyteData(4);
233 std::vector<float> floatData(4);
234 deUint32 fbo = 0x1234;
235 deUint32 texture = 0x1234;
237 ctx.glGenTextures (1, &texture);
238 ctx.glBindTexture (GL_TEXTURE_2D, texture);
239 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
240 ctx.glGenFramebuffers (1, &fbo);
241 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
242 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
243 ctx.expectError (GL_NO_ERROR);
245 ctx.beginSection("GL_INVALID_OPERATION is generated if currently bound framebuffer format is incompatible with format and type.");
247 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
248 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
249 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
250 ctx.expectError (GL_NO_ERROR);
251 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
252 ctx.expectError (GL_INVALID_OPERATION);
254 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
255 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
256 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
257 ctx.expectError (GL_NO_ERROR);
258 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
259 ctx.expectError (GL_INVALID_OPERATION);
261 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
262 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
263 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
264 ctx.expectError (GL_NO_ERROR);
265 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
266 ctx.expectError (GL_INVALID_OPERATION);
270 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_READ_FRAMEBUFFER_BINDING is non-zero, the read framebuffer is complete, and the value of GL_SAMPLE_BUFFERS for the read framebuffer is greater than zero.");
273 int sampleBuffers = 0x1234;
274 deUint32 rbo = 0x1234;
276 ctx.glGenRenderbuffers(1, &rbo);
277 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
278 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
279 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
281 ctx.glGetIntegerv (GL_READ_FRAMEBUFFER_BINDING, &binding);
282 ctx.getLog() << TestLog::Message << "// GL_READ_FRAMEBUFFER_BINDING: " << binding << TestLog::EndMessage;
283 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
284 ctx.glGetIntegerv (GL_SAMPLE_BUFFERS, &sampleBuffers);
285 ctx.getLog() << TestLog::Message << "// GL_SAMPLE_BUFFERS: " << sampleBuffers << TestLog::EndMessage;
286 ctx.expectError (GL_NO_ERROR);
288 if (binding == 0 || sampleBuffers <= 0)
290 ctx.getLog() << TestLog::Message << "// ERROR: expected GL_READ_FRAMEBUFFER_BINDING to be non-zero and GL_SAMPLE_BUFFERS to be greater than zero" << TestLog::EndMessage;
291 ctx.fail("Got invalid value");
295 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
296 ctx.expectError (GL_INVALID_OPERATION);
301 ctx.glBindRenderbuffer (GL_RENDERBUFFER, 0);
302 ctx.glBindTexture (GL_TEXTURE_2D, 0);
303 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
304 ctx.glDeleteFramebuffers (1, &fbo);
305 ctx.glDeleteTextures (1, &texture);
306 ctx.glDeleteRenderbuffers (1, &rbo);
309 void bind_buffer_range (NegativeTestContext& ctx)
311 deUint32 bufU = 0x1234;
312 ctx.glGenBuffers(1, &bufU);
313 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
314 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
316 deUint32 bufTF = 0x1234;
317 ctx.glGenBuffers(1, &bufTF);
318 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
319 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
321 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
322 ctx.glBindBufferRange(GL_ARRAY_BUFFER, 0, bufU, 0, 4);
323 ctx.expectError(GL_INVALID_ENUM);
326 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and index is greater than or equal to GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
327 int maxTFSize = 0x1234;
328 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
329 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
330 ctx.expectError(GL_INVALID_VALUE);
333 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and index is greater than or equal to GL_MAX_UNIFORM_BUFFER_BINDINGS.");
334 int maxUSize = 0x1234;
335 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
336 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4);
337 ctx.expectError(GL_INVALID_VALUE);
340 ctx.beginSection("GL_INVALID_VALUE is generated if size is less than or equal to zero.");
341 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1);
342 ctx.expectError(GL_INVALID_VALUE);
343 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0);
344 ctx.expectError(GL_INVALID_VALUE);
347 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.");
348 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
349 ctx.expectError(GL_INVALID_VALUE);
350 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
351 ctx.expectError(GL_INVALID_VALUE);
352 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
353 ctx.expectError(GL_INVALID_VALUE);
356 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and offset is not a multiple of GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT.");
357 int alignment = 0x1234;
358 ctx.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment);
359 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, alignment+1, 4);
360 ctx.expectError(GL_INVALID_VALUE);
363 ctx.glDeleteBuffers(1, &bufU);
364 ctx.glDeleteBuffers(1, &bufTF);
367 void bind_buffer_base (NegativeTestContext& ctx)
369 deUint32 bufU = 0x1234;
370 ctx.glGenBuffers(1, &bufU);
371 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
372 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
374 deUint32 bufTF = 0x1234;
375 ctx.glGenBuffers(1, &bufTF);
376 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
377 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
378 ctx.expectError(GL_NO_ERROR);
380 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
381 ctx.glBindBufferBase(-1, 0, bufU);
382 ctx.expectError(GL_INVALID_ENUM);
383 ctx.glBindBufferBase(GL_ARRAY_BUFFER, 0, bufU);
384 ctx.expectError(GL_INVALID_ENUM);
387 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and index is greater than or equal to GL_MAX_UNIFORM_BUFFER_BINDINGS.");
388 int maxUSize = 0x1234;
389 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
390 ctx.glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU);
391 ctx.expectError(GL_INVALID_VALUE);
394 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER andindex is greater than or equal to GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS.");
395 int maxTFSize = 0x1234;
396 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
397 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
398 ctx.expectError(GL_INVALID_VALUE);
401 ctx.glDeleteBuffers(1, &bufU);
402 ctx.glDeleteBuffers(1, &bufTF);
405 void clear_bufferiv (NegativeTestContext& ctx)
407 std::vector<int> data(32*32);
408 deUint32 fbo = 0x1234;
409 deUint32 texture = 0x1234;
411 ctx.glGenTextures (1, &texture);
412 ctx.glBindTexture (GL_TEXTURE_2D, texture);
413 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
414 ctx.glGenFramebuffers (1, &fbo);
415 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
416 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
417 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
418 ctx.expectError (GL_NO_ERROR);
420 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
421 ctx.glClearBufferiv(-1, 0, &data[0]);
422 ctx.expectError(GL_INVALID_ENUM);
423 ctx.glClearBufferiv(GL_FRAMEBUFFER, 0, &data[0]);
424 ctx.expectError(GL_INVALID_ENUM);
427 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
428 int maxDrawBuffers = 0x1234;
429 ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
430 ctx.glClearBufferiv(GL_COLOR, maxDrawBuffers, &data[0]);
431 ctx.expectError(GL_INVALID_VALUE);
434 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL.");
435 ctx.glClearBufferiv(GL_DEPTH, 1, &data[0]);
436 ctx.expectError(GL_INVALID_ENUM);
437 ctx.glClearBufferiv(GL_DEPTH_STENCIL, 1, &data[0]);
438 ctx.expectError(GL_INVALID_ENUM);
441 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero.");
442 ctx.glClearBufferiv(GL_STENCIL, 1, &data[0]);
443 ctx.expectError(GL_INVALID_VALUE);
446 ctx.glDeleteFramebuffers(1, &fbo);
447 ctx.glDeleteTextures(1, &texture);
450 void clear_bufferuiv (NegativeTestContext& ctx)
452 std::vector<deUint32> data(32*32);
453 deUint32 fbo = 0x1234;
454 deUint32 texture = 0x1234;
456 ctx.glGenTextures (1, &texture);
457 ctx.glBindTexture (GL_TEXTURE_2D, texture);
458 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
459 ctx.glGenFramebuffers (1, &fbo);
460 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
461 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
462 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
463 ctx.expectError (GL_NO_ERROR);
465 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
466 ctx.glClearBufferuiv(-1, 0, &data[0]);
467 ctx.expectError(GL_INVALID_ENUM);
468 ctx.glClearBufferuiv(GL_FRAMEBUFFER, 0, &data[0]);
469 ctx.expectError(GL_INVALID_ENUM);
472 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
473 int maxDrawBuffers = 0x1234;
474 ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
475 ctx.glClearBufferuiv(GL_COLOR, maxDrawBuffers, &data[0]);
476 ctx.expectError(GL_INVALID_VALUE);
479 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL or GL_DEPTH_STENCIL.");
480 ctx.glClearBufferuiv(GL_DEPTH, 1, &data[0]);
481 ctx.expectError(GL_INVALID_ENUM);
482 ctx.glClearBufferuiv(GL_STENCIL, 1, &data[0]);
483 ctx.expectError(GL_INVALID_ENUM);
484 ctx.glClearBufferuiv(GL_DEPTH_STENCIL, 1, &data[0]);
485 ctx.expectError(GL_INVALID_ENUM);
488 ctx.glDeleteFramebuffers(1, &fbo);
489 ctx.glDeleteTextures(1, &texture);
492 void clear_bufferfv (NegativeTestContext& ctx)
494 std::vector<float> data(32*32);
495 deUint32 fbo = 0x1234;
496 deUint32 texture = 0x1234;
498 ctx.glGenTextures (1, &texture);
499 ctx.glBindTexture (GL_TEXTURE_2D, texture);
500 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
501 ctx.glGenFramebuffers (1, &fbo);
502 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
503 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
504 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
505 ctx.expectError (GL_NO_ERROR);
507 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
508 ctx.glClearBufferfv(-1, 0, &data[0]);
509 ctx.expectError(GL_INVALID_ENUM);
510 ctx.glClearBufferfv(GL_FRAMEBUFFER, 0, &data[0]);
511 ctx.expectError(GL_INVALID_ENUM);
514 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
515 int maxDrawBuffers = 0x1234;
516 ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
517 ctx.glClearBufferfv(GL_COLOR, maxDrawBuffers, &data[0]);
518 ctx.expectError(GL_INVALID_VALUE);
521 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL.");
522 ctx.glClearBufferfv(GL_STENCIL, 1, &data[0]);
523 ctx.expectError(GL_INVALID_ENUM);
524 ctx.glClearBufferfv(GL_DEPTH_STENCIL, 1, &data[0]);
525 ctx.expectError(GL_INVALID_ENUM);
528 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero.");
529 ctx.glClearBufferfv(GL_DEPTH, 1, &data[0]);
530 ctx.expectError(GL_INVALID_VALUE);
533 ctx.glDeleteFramebuffers(1, &fbo);
534 ctx.glDeleteTextures(1, &texture);
537 void clear_bufferfi (NegativeTestContext& ctx)
539 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
540 ctx.glClearBufferfi(-1, 0, 1.0f, 1);
541 ctx.expectError(GL_INVALID_ENUM);
542 ctx.glClearBufferfi(GL_FRAMEBUFFER, 0, 1.0f, 1);
543 ctx.expectError(GL_INVALID_ENUM);
546 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL.");
547 ctx.glClearBufferfi(GL_DEPTH, 0, 1.0f, 1);
548 ctx.expectError(GL_INVALID_ENUM);
549 ctx.glClearBufferfi(GL_STENCIL, 0, 1.0f, 1);
550 ctx.expectError(GL_INVALID_ENUM);
551 ctx.glClearBufferfi(GL_COLOR, 0, 1.0f, 1);
552 ctx.expectError(GL_INVALID_ENUM);
555 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero.");
556 ctx.glClearBufferfi(GL_DEPTH_STENCIL, 1, 1.0f, 1);
557 ctx.expectError(GL_INVALID_VALUE);
561 void copy_buffer_sub_data (NegativeTestContext& ctx)
564 std::vector<float> data(32*32);
566 ctx.glGenBuffers (2, buf);
567 ctx.glBindBuffer (GL_COPY_READ_BUFFER, buf[0]);
568 ctx.glBufferData (GL_COPY_READ_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
569 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
570 ctx.glBufferData (GL_COPY_WRITE_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
571 ctx.expectError (GL_NO_ERROR);
573 ctx.beginSection("GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative.");
574 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, -4);
575 ctx.expectError (GL_INVALID_VALUE);
576 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, -1, 0, 4);
577 ctx.expectError (GL_INVALID_VALUE);
578 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, -1, 4);
579 ctx.expectError (GL_INVALID_VALUE);
582 ctx.beginSection("GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.");
583 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
584 ctx.expectError (GL_INVALID_VALUE);
585 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16);
586 ctx.expectError (GL_INVALID_VALUE);
587 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4);
588 ctx.expectError (GL_INVALID_VALUE);
591 ctx.beginSection("GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.");
592 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
593 ctx.expectError (GL_INVALID_VALUE);
594 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16);
595 ctx.expectError (GL_INVALID_VALUE);
596 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4);
597 ctx.expectError (GL_INVALID_VALUE);
600 ctx.beginSection("GL_INVALID_VALUE is generated if the same buffer object is bound to both readtarget and writetarget and the ranges [readoffset, readoffset + size) and [writeoffset, writeoffset + size) overlap.");
601 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[0]);
602 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4);
603 ctx.expectError (GL_NO_ERROR);
604 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4);
605 ctx.expectError (GL_INVALID_VALUE);
606 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18);
607 ctx.expectError (GL_INVALID_VALUE);
608 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
611 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget.");
612 ctx.glBindBuffer (GL_COPY_READ_BUFFER, 0);
613 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
614 ctx.expectError (GL_INVALID_OPERATION);
616 ctx.glBindBuffer (GL_COPY_READ_BUFFER, buf[0]);
617 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, 0);
618 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
619 ctx.expectError (GL_INVALID_OPERATION);
621 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
624 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped.");
625 ctx.glMapBufferRange (GL_COPY_READ_BUFFER, 0, 4, GL_MAP_READ_BIT);
626 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
627 ctx.expectError (GL_INVALID_OPERATION);
628 ctx.glUnmapBuffer (GL_COPY_READ_BUFFER);
630 ctx.glMapBufferRange (GL_COPY_WRITE_BUFFER, 0, 4, GL_MAP_READ_BIT);
631 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
632 ctx.expectError (GL_INVALID_OPERATION);
633 ctx.glUnmapBuffer (GL_COPY_WRITE_BUFFER);
636 ctx.glDeleteBuffers(2, buf);
639 void draw_buffers (NegativeTestContext& ctx)
641 deUint32 fbo = 0x1234;
642 deUint32 texture = 0x1234;
643 int maxDrawBuffers = 0x1234;
644 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
645 std::vector<deUint32> values(maxDrawBuffers+1);
648 values[2] = GL_COLOR_ATTACHMENT0;
649 values[3] = GL_DEPTH_ATTACHMENT;
650 std::vector<GLfloat> data(32*32);
652 ctx.glGenTextures (1, &texture);
653 ctx.glBindTexture (GL_TEXTURE_2D, texture);
654 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
655 ctx.glGenFramebuffers (1, &fbo);
656 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
657 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
658 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
659 ctx.expectError (GL_NO_ERROR);
661 ctx.beginSection("GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.");
662 ctx.glDrawBuffers (2, &values[2]);
663 ctx.expectError (GL_INVALID_ENUM);
666 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1.");
667 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
668 ctx.glDrawBuffers (2, &values[0]);
669 ctx.expectError (GL_INVALID_OPERATION);
672 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and the value in bufs is one of the GL_COLOR_ATTACHMENTn tokens.");
673 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
674 ctx.glDrawBuffers (1, &values[2]);
675 ctx.expectError (GL_INVALID_OPERATION);
678 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to a framebuffer object and the ith buffer listed in bufs is anything other than GL_NONE or GL_COLOR_ATTACHMENTSi.");
679 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
680 ctx.glDrawBuffers (1, &values[1]);
681 ctx.expectError (GL_INVALID_OPERATION);
684 ctx.beginSection("GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.");
685 ctx.glDrawBuffers (-1, &values[1]);
686 ctx.expectError (GL_INVALID_VALUE);
687 ctx.glDrawBuffers (maxDrawBuffers+1, &values[0]);
688 ctx.expectError (GL_INVALID_VALUE);
691 ctx.glDeleteTextures(1, &texture);
692 ctx.glDeleteFramebuffers(1, &fbo);
695 void flush_mapped_buffer_range (NegativeTestContext& ctx)
697 deUint32 buf = 0x1234;
698 std::vector<GLfloat> data(32);
700 ctx.glGenBuffers (1, &buf);
701 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
702 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_STATIC_READ);
703 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
704 ctx.expectError (GL_NO_ERROR);
706 ctx.beginSection("GL_INVALID_VALUE is generated if offset or length is negative, or if offset + length exceeds the size of the mapping.");
707 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, -1, 1);
708 ctx.expectError (GL_INVALID_VALUE);
709 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, -1);
710 ctx.expectError (GL_INVALID_VALUE);
711 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 12, 8);
712 ctx.expectError (GL_INVALID_VALUE);
713 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 24, 4);
714 ctx.expectError (GL_INVALID_VALUE);
715 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 24);
716 ctx.expectError (GL_INVALID_VALUE);
719 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
720 ctx.glBindBuffer (GL_ARRAY_BUFFER, 0);
721 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
722 ctx.expectError (GL_INVALID_OPERATION);
725 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer bound to target is not mapped, or is mapped without the GL_MAP_FLUSH_EXPLICIT flag.");
726 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
727 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
728 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
729 ctx.expectError (GL_INVALID_OPERATION);
730 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
731 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
732 ctx.expectError (GL_INVALID_OPERATION);
735 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
736 ctx.glDeleteBuffers (1, &buf);
739 void map_buffer_range (NegativeTestContext& ctx)
741 deUint32 buf = 0x1234;
742 std::vector<GLfloat> data(32);
744 ctx.glGenBuffers (1, &buf);
745 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
746 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
747 ctx.expectError (GL_NO_ERROR);
749 ctx.beginSection("GL_INVALID_VALUE is generated if either of offset or length is negative.");
750 ctx.glMapBufferRange (GL_ARRAY_BUFFER, -1, 1, GL_MAP_READ_BIT);
751 ctx.expectError (GL_INVALID_VALUE);
753 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 1, -1, GL_MAP_READ_BIT);
754 ctx.expectError (GL_INVALID_VALUE);
757 ctx.beginSection("GL_INVALID_VALUE is generated if offset + length is greater than the value of GL_BUFFER_SIZE.");
758 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 33, GL_MAP_READ_BIT);
759 ctx.expectError (GL_INVALID_VALUE);
761 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 32, 1, GL_MAP_READ_BIT);
762 ctx.expectError (GL_INVALID_VALUE);
764 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 16, 17, GL_MAP_READ_BIT);
765 ctx.expectError (GL_INVALID_VALUE);
768 ctx.beginSection("GL_INVALID_VALUE is generated if access has any bits set other than those accepted.");
769 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | 0x1000);
770 ctx.expectError (GL_INVALID_VALUE);
772 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | 0x1000);
773 ctx.expectError (GL_INVALID_VALUE);
776 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer is already in a mapped state.");
777 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
778 ctx.expectError (GL_NO_ERROR);
779 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT);
780 ctx.expectError (GL_INVALID_OPERATION);
781 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
784 ctx.beginSection("GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.");
785 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
786 ctx.expectError (GL_INVALID_OPERATION);
789 ctx.beginSection("GL_INVALID_OPERATION is generated if ");
790 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
791 ctx.expectError (GL_INVALID_OPERATION);
794 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_READ_BIT is set and any of GL_MAP_INVALIDATE_RANGE_BIT, GL_MAP_INVALIDATE_BUFFER_BIT, or GL_MAP_UNSYNCHRONIZED_BIT is set.");
795 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
796 ctx.expectError (GL_INVALID_OPERATION);
798 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
799 ctx.expectError (GL_INVALID_OPERATION);
801 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
802 ctx.expectError (GL_INVALID_OPERATION);
805 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.");
806 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
807 ctx.expectError (GL_INVALID_OPERATION);
810 ctx.glDeleteBuffers (1, &buf);
813 void read_buffer (NegativeTestContext& ctx)
815 deUint32 fbo = 0x1234;
816 deUint32 texture = 0x1234;
817 int maxColorAttachments = 0x1234;
819 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
820 ctx.glGenTextures (1, &texture);
821 ctx.glBindTexture (GL_TEXTURE_2D, texture);
822 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
823 ctx.glGenFramebuffers (1, &fbo);
824 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
825 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
826 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
827 ctx.expectError (GL_NO_ERROR);
829 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_BACK, GL_NONE, or GL_COLOR_ATTACHMENTi.");
830 ctx.glReadBuffer (GL_NONE);
831 ctx.expectError (GL_NO_ERROR);
832 ctx.glReadBuffer (1);
833 ctx.expectError (GL_INVALID_ENUM);
834 ctx.glReadBuffer (GL_FRAMEBUFFER);
835 ctx.expectError (GL_INVALID_ENUM);
836 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0 - 1);
837 ctx.expectError (GL_INVALID_ENUM);
838 ctx.glReadBuffer (GL_FRONT);
839 ctx.expectError (GL_INVALID_ENUM);
841 // \ note Spec isn't actually clear here, but it is safe to assume that
842 // GL_DEPTH_ATTACHMENT can't be interpreted as GL_COLOR_ATTACHMENTm
843 // where m = (GL_DEPTH_ATTACHMENT - GL_COLOR_ATTACHMENT0).
844 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT);
845 ctx.expectError (GL_INVALID_ENUM);
846 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT);
847 ctx.expectError (GL_INVALID_ENUM);
848 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT+1);
849 ctx.expectError (GL_INVALID_ENUM);
850 ctx.glReadBuffer (0xffffffffu);
851 ctx.expectError (GL_INVALID_ENUM);
854 ctx.beginSection("GL_INVALID_OPERATION error is generated if src is GL_BACK or if src is GL_COLOR_ATTACHMENTm where m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
855 ctx.glReadBuffer (GL_BACK);
856 ctx.expectError (GL_INVALID_OPERATION);
857 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
858 ctx.expectError (GL_INVALID_OPERATION);
860 if (GL_COLOR_ATTACHMENT0+maxColorAttachments < GL_DEPTH_ATTACHMENT-1)
862 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT - 1);
863 ctx.expectError (GL_INVALID_OPERATION);
868 ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK.");
869 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
870 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0);
871 ctx.expectError (GL_INVALID_OPERATION);
874 ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is a named framebuffer and mode is not GL_NONE or GL_COLOR_ATTACHMENTi.");
875 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
876 ctx.glReadBuffer (GL_BACK);
877 ctx.expectError (GL_INVALID_OPERATION);
880 ctx.glDeleteTextures(1, &texture);
881 ctx.glDeleteFramebuffers(1, &fbo);
884 void unmap_buffer (NegativeTestContext& ctx)
886 deUint32 buf = 0x1234;
887 std::vector<GLfloat> data(32);
889 ctx.glGenBuffers (1, &buf);
890 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
891 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
892 ctx.expectError (GL_NO_ERROR);
894 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer data store is already in an unmapped state.");
895 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
896 ctx.expectError (GL_INVALID_OPERATION);
899 ctx.glDeleteBuffers (1, &buf);
901 // Framebuffer Objects
903 void bind_framebuffer (NegativeTestContext& ctx)
905 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
906 ctx.glBindFramebuffer(-1, 0);
907 ctx.expectError(GL_INVALID_ENUM);
908 ctx.glBindFramebuffer(GL_RENDERBUFFER, 0);
909 ctx.expectError(GL_INVALID_ENUM);
913 void bind_renderbuffer (NegativeTestContext& ctx)
915 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
916 ctx.glBindRenderbuffer(-1, 0);
917 ctx.expectError(GL_INVALID_ENUM);
918 ctx.glBindRenderbuffer(GL_FRAMEBUFFER, 0);
919 ctx.expectError(GL_INVALID_ENUM);
923 void check_framebuffer_status (NegativeTestContext& ctx)
925 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
926 ctx.glCheckFramebufferStatus(-1);
927 ctx.expectError(GL_INVALID_ENUM);
928 ctx.glCheckFramebufferStatus(GL_RENDERBUFFER);
929 ctx.expectError(GL_INVALID_ENUM);
933 void gen_framebuffers (NegativeTestContext& ctx)
935 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
936 ctx.glGenFramebuffers(-1, 0);
937 ctx.expectError(GL_INVALID_VALUE);
941 void gen_renderbuffers (NegativeTestContext& ctx)
943 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
944 ctx.glGenRenderbuffers(-1, 0);
945 ctx.expectError(GL_INVALID_VALUE);
949 void delete_framebuffers (NegativeTestContext& ctx)
951 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
952 ctx.glDeleteFramebuffers(-1, 0);
953 ctx.expectError(GL_INVALID_VALUE);
957 void delete_renderbuffers (NegativeTestContext& ctx)
959 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
960 ctx.glDeleteRenderbuffers(-1, 0);
961 ctx.expectError(GL_INVALID_VALUE);
965 void framebuffer_renderbuffer (NegativeTestContext& ctx)
969 ctx.glGenFramebuffers(1, &fbo);
970 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
971 ctx.glGenRenderbuffers(1, &rbo);
973 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
974 ctx.glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
975 ctx.expectError(GL_INVALID_ENUM);
978 ctx.beginSection("GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
979 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
980 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
981 ctx.expectError(GL_INVALID_ENUM);
982 ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
985 ctx.beginSection("GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
986 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
987 ctx.expectError(GL_INVALID_OPERATION);
990 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
991 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
992 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
993 ctx.expectError(GL_INVALID_OPERATION);
996 ctx.glDeleteRenderbuffers(1, &rbo);
997 ctx.glDeleteFramebuffers(1, &fbo);
1000 void framebuffer_texture2d (NegativeTestContext& ctx)
1002 GLuint fbo = 0x1234;
1003 GLuint tex2D = 0x1234;
1004 GLuint texCube = 0x1234;
1005 GLint maxTexSize = 0x1234;
1006 GLint maxTexCubeSize = 0x1234;
1008 ctx.glGenFramebuffers(1, &fbo);
1009 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1010 ctx.glGenTextures(1, &tex2D);
1011 ctx.glBindTexture(GL_TEXTURE_2D, tex2D);
1012 ctx.glGenTextures(1, &texCube);
1013 ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
1014 ctx.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
1015 ctx.glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxTexCubeSize);
1016 ctx.expectError(GL_NO_ERROR);
1018 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1019 ctx.glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1020 ctx.expectError(GL_INVALID_ENUM);
1023 ctx.beginSection("GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
1024 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
1025 ctx.expectError(GL_INVALID_ENUM);
1028 ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.");
1029 int maxSize = 0x1234;
1030 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1031 ctx.expectError(GL_INVALID_VALUE);
1032 maxSize = deLog2Floor32(maxTexSize) + 1;
1033 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize);
1034 ctx.expectError(GL_INVALID_VALUE);
1035 maxSize = deLog2Floor32(maxTexSize) + 1;
1036 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize);
1037 ctx.expectError(GL_INVALID_VALUE);
1040 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1041 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
1042 ctx.expectError(GL_INVALID_OPERATION);
1045 ctx.beginSection("GL_INVALID_OPERATION is generated if textarget and texture are not compatible.");
1046 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
1047 ctx.expectError(GL_INVALID_OPERATION);
1048 ctx.glDeleteTextures(1, &tex2D);
1050 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
1051 ctx.expectError(GL_INVALID_OPERATION);
1052 ctx.glDeleteTextures(1, &texCube);
1055 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1056 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1057 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1058 ctx.expectError(GL_INVALID_OPERATION);
1061 ctx.glDeleteFramebuffers(1, &fbo);
1064 void renderbuffer_storage (NegativeTestContext& ctx)
1066 deUint32 rbo = 0x1234;
1067 ctx.glGenRenderbuffers (1, &rbo);
1068 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1070 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1071 ctx.glRenderbufferStorage (-1, GL_RGBA4, 1, 1);
1072 ctx.expectError (GL_INVALID_ENUM);
1073 ctx.glRenderbufferStorage (GL_FRAMEBUFFER, GL_RGBA4, 1, 1);
1074 ctx.expectError (GL_INVALID_ENUM);
1077 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1078 ctx.glRenderbufferStorage (GL_RENDERBUFFER, -1, 1, 1);
1079 ctx.expectError (GL_INVALID_ENUM);
1081 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1083 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGB16F, 1, 1);
1084 ctx.expectError (GL_INVALID_ENUM);
1087 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8_SNORM, 1, 1);
1088 ctx.expectError (GL_INVALID_ENUM);
1091 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1092 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, 1);
1093 ctx.expectError (GL_INVALID_VALUE);
1094 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, -1);
1095 ctx.expectError (GL_INVALID_VALUE);
1096 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, -1);
1097 ctx.expectError (GL_INVALID_VALUE);
1100 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1101 GLint maxSize = 0x1234;
1102 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1103 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
1104 ctx.expectError (GL_INVALID_VALUE);
1105 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
1106 ctx.expectError (GL_INVALID_VALUE);
1107 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
1108 ctx.expectError (GL_INVALID_VALUE);
1111 ctx.glDeleteRenderbuffers(1, &rbo);
1114 void blit_framebuffer (NegativeTestContext& ctx)
1118 deUint32 texture[2];
1120 ctx.glGenFramebuffers (2, fbo);
1121 ctx.glGenTextures (2, texture);
1122 ctx.glGenRenderbuffers (2, rbo);
1124 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1125 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1126 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1128 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1129 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1130 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1131 ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1132 ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1134 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1135 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
1136 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1138 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1139 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1140 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1141 ctx.glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1142 ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1143 ctx.expectError (GL_NO_ERROR);
1145 ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains any of the GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT and filter is not GL_NEAREST.");
1146 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1147 ctx.expectError (GL_INVALID_OPERATION);
1148 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_LINEAR);
1149 ctx.expectError (GL_INVALID_OPERATION);
1150 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1151 ctx.expectError (GL_INVALID_OPERATION);
1154 ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format.");
1155 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1157 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1158 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1159 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32UI, draw buffer: GL_RGBA" << TestLog::EndMessage;
1160 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1161 ctx.expectError (GL_INVALID_OPERATION);
1163 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1164 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1165 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA" << TestLog::EndMessage;
1166 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1167 ctx.expectError (GL_INVALID_OPERATION);
1169 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1170 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1171 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1172 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1173 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1174 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA8, draw buffer: GL_RGBA32I" << TestLog::EndMessage;
1175 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1176 ctx.expectError (GL_INVALID_OPERATION);
1179 ctx.beginSection("GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.");
1180 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1181 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1182 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1183 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1184 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1185 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage;
1186 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR);
1187 ctx.expectError (GL_INVALID_OPERATION);
1190 ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT and the source and destination depth and stencil formats do not match.");
1191 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1192 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32);
1193 ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1194 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1195 ctx.expectError (GL_INVALID_OPERATION);
1196 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1197 ctx.expectError (GL_INVALID_OPERATION);
1200 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1201 ctx.glDeleteFramebuffers (2, fbo);
1202 ctx.glDeleteTextures (2, texture);
1203 ctx.glDeleteRenderbuffers (2, rbo);
1206 void blit_framebuffer_multisample (NegativeTestContext& ctx)
1211 ctx.glGenFramebuffers (2, fbo);
1212 ctx.glGenRenderbuffers (2, rbo);
1214 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1215 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1216 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1217 ctx.glFramebufferRenderbuffer (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
1218 ctx.glCheckFramebufferStatus (GL_READ_FRAMEBUFFER);
1220 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
1221 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1223 ctx.expectError (GL_NO_ERROR);
1225 ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_SAMPLE_BUFFERS for the draw buffer is greater than zero.");
1226 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1227 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1228 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1229 ctx.expectError (GL_INVALID_OPERATION);
1232 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for the read buffer is greater than zero and the formats of draw and read buffers are not identical.");
1233 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 32, 32);
1234 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1235 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1236 ctx.expectError (GL_INVALID_OPERATION);
1239 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for the read buffer is greater than zero and the source and destination rectangles are not defined with the same (X0, Y0) and (X1, Y1) bounds.");
1240 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1241 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1242 ctx.glBlitFramebuffer (0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1243 ctx.expectError (GL_INVALID_OPERATION);
1246 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1247 ctx.glDeleteRenderbuffers (2, rbo);
1248 ctx.glDeleteFramebuffers (2, fbo);
1251 void framebuffer_texture_layer (NegativeTestContext& ctx)
1253 deUint32 fbo = 0x1234;
1255 deUint32 tex2DArray;
1258 ctx.glGenFramebuffers (1, &fbo);
1259 ctx.glGenTextures (1, &tex3D);
1260 ctx.glGenTextures (1, &tex2DArray);
1261 ctx.glGenTextures (1, &tex2D);
1262 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1264 ctx.glBindTexture (GL_TEXTURE_3D, tex3D);
1265 ctx.glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1266 ctx.glBindTexture (GL_TEXTURE_2D_ARRAY, tex2DArray);
1267 ctx.glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1268 ctx.glBindTexture (GL_TEXTURE_2D, tex2D);
1269 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1271 ctx.expectError (GL_NO_ERROR);
1273 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1274 ctx.glFramebufferTextureLayer (-1, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1275 ctx.expectError (GL_INVALID_ENUM);
1276 ctx.glFramebufferTextureLayer (GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1277 ctx.expectError (GL_INVALID_ENUM);
1280 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1281 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, -1, tex3D, 0, 1);
1282 ctx.expectError (GL_INVALID_ENUM);
1283 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1);
1284 ctx.expectError (GL_INVALID_ENUM);
1287 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is non-zero and not the name of a 3D texture or 2D array texture.");
1288 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0);
1289 ctx.expectError (GL_INVALID_OPERATION);
1290 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0);
1291 ctx.expectError (GL_INVALID_OPERATION);
1294 ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is negative.");
1295 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1);
1296 ctx.expectError (GL_INVALID_VALUE);
1299 ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is greater than GL_MAX_3D_TEXTURE_SIZE-1 for a 3D texture.");
1300 int max3DTexSize = 0x1234;
1301 ctx.glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize);
1302 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
1303 ctx.expectError (GL_INVALID_VALUE);
1306 ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is greater than GL_MAX_ARRAY_TEXTURE_LAYERS-1 for a 2D array texture.");
1307 int maxArrayTexLayers = 0x1234;
1308 ctx.glGetIntegerv (GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers);
1309 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
1310 ctx.expectError (GL_INVALID_VALUE);
1313 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1314 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1315 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1316 ctx.expectError (GL_INVALID_OPERATION);
1319 ctx.glDeleteTextures (1, &tex3D);
1320 ctx.glDeleteTextures (1, &tex2DArray);
1321 ctx.glDeleteTextures (1, &tex2D);
1322 ctx.glDeleteFramebuffers (1, &fbo);
1325 void invalidate_framebuffer (NegativeTestContext& ctx)
1327 deUint32 fbo = 0x1234;
1328 deUint32 texture = 0x1234;
1329 deUint32 attachments[2];
1330 int maxColorAttachments = 0x1234;
1331 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1332 attachments[0] = GL_COLOR_ATTACHMENT0;
1333 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1335 ctx.glGenFramebuffers (1, &fbo);
1336 ctx.glGenTextures (1, &texture);
1337 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1338 ctx.glBindTexture (GL_TEXTURE_2D, texture);
1339 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1340 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1341 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
1342 ctx.expectError (GL_NO_ERROR);
1344 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1345 ctx.glInvalidateFramebuffer (-1, 1, &attachments[0]);
1346 ctx.expectError (GL_INVALID_ENUM);
1347 ctx.glInvalidateFramebuffer (GL_BACK, 1, &attachments[0]);
1348 ctx.expectError (GL_INVALID_ENUM);
1351 ctx.beginSection("GL_INVALID_OPERATION is generated if attachments contains GL_COLOR_ATTACHMENTm and m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
1352 ctx.glInvalidateFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1]);
1353 ctx.expectError (GL_INVALID_OPERATION);
1356 ctx.glDeleteTextures (1, &texture);
1357 ctx.glDeleteFramebuffers (1, &fbo);
1360 void invalidate_sub_framebuffer (NegativeTestContext& ctx)
1362 deUint32 fbo = 0x1234;
1363 deUint32 texture = 0x1234;
1364 deUint32 attachments[2];
1365 int maxColorAttachments = 0x1234;
1366 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1367 attachments[0] = GL_COLOR_ATTACHMENT0;
1368 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1370 ctx.glGenFramebuffers (1, &fbo);
1371 ctx.glGenTextures (1, &texture);
1372 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1373 ctx.glBindTexture (GL_TEXTURE_2D, texture);
1374 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1375 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1376 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
1377 ctx.expectError (GL_NO_ERROR);
1379 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1380 ctx.glInvalidateSubFramebuffer (-1, 1, &attachments[0], 0, 0, 16, 16);
1381 ctx.expectError (GL_INVALID_ENUM);
1382 ctx.glInvalidateSubFramebuffer (GL_BACK, 1, &attachments[0], 0, 0, 16, 16);
1383 ctx.expectError (GL_INVALID_ENUM);
1386 ctx.beginSection("GL_INVALID_OPERATION is generated if attachments contains GL_COLOR_ATTACHMENTm and m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
1387 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16);
1388 ctx.expectError (GL_INVALID_OPERATION);
1391 ctx.glDeleteTextures (1, &texture);
1392 ctx.glDeleteFramebuffers (1, &fbo);
1395 void renderbuffer_storage_multisample (NegativeTestContext& ctx)
1397 deUint32 rbo = 0x1234;
1398 int maxSamplesSupportedRGBA4 = -1;
1399 int maxSamplesSupportedRGBA8UI = -1;
1401 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, 1, &maxSamplesSupportedRGBA4);
1402 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8UI, GL_SAMPLES, 1, &maxSamplesSupportedRGBA8UI);
1404 ctx.glGenRenderbuffers (1, &rbo);
1405 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1407 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1408 ctx.glRenderbufferStorageMultisample (-1, 2, GL_RGBA4, 1, 1);
1409 ctx.expectError (GL_INVALID_ENUM);
1410 ctx.glRenderbufferStorageMultisample (GL_FRAMEBUFFER, 2, GL_RGBA4, 1, 1);
1411 ctx.expectError (GL_INVALID_ENUM);
1414 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.");
1415 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA4+1, GL_RGBA4, 1, 1);
1416 ctx.expectError (GL_INVALID_OPERATION);
1419 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1420 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, -1, 1, 1);
1421 ctx.expectError (GL_INVALID_ENUM);
1423 if (!ctx.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1425 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGB16F, 1, 1);
1426 ctx.expectError (GL_INVALID_ENUM);
1429 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA8_SNORM, 1, 1);
1430 ctx.expectError (GL_INVALID_ENUM);
1433 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat. (Unsigned integer format)");
1434 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA8UI+1, GL_RGBA8UI, 1, 1);
1435 ctx.expectError (GL_INVALID_OPERATION);
1438 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1439 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, 1);
1440 ctx.expectError (GL_INVALID_VALUE);
1441 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, 1, -1);
1442 ctx.expectError (GL_INVALID_VALUE);
1443 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, -1);
1444 ctx.expectError (GL_INVALID_VALUE);
1447 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1448 GLint maxSize = 0x1234;
1449 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1450 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, 1, maxSize+1);
1451 ctx.expectError (GL_INVALID_VALUE);
1452 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, 1);
1453 ctx.expectError (GL_INVALID_VALUE);
1454 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, maxSize+1);
1455 ctx.expectError (GL_INVALID_VALUE);
1458 ctx.glDeleteRenderbuffers(1, &rbo);
1461 std::vector<FunctionContainer> getNegativeBufferApiTestFunctions ()
1463 FunctionContainer funcs[] =
1465 {bind_buffer, "bind_buffer", "Invalid glBindBuffer() usage" },
1466 {delete_buffers, "delete_buffers", "Invalid glDeleteBuffers() usage" },
1467 {gen_buffers, "gen_buffers", "Invalid glGenBuffers() usage" },
1468 {buffer_data, "buffer_data", "Invalid glBufferData() usage" },
1469 {buffer_sub_data, "buffer_sub_data", "Invalid glBufferSubData() usage" },
1470 {buffer_sub_data_size_offset, "buffer_sub_data_size_offset", "Invalid glBufferSubData() usage" },
1471 {clear, "clear", "Invalid glClear() usage" },
1472 {read_pixels, "read_pixels", "Invalid glReadPixels() usage" },
1473 {read_pixels_format_mismatch, "read_pixels_format_mismatch", "Invalid glReadPixels() usage" },
1474 {read_pixels_fbo_format_mismatch, "read_pixels_fbo_format_mismatch", "Invalid glReadPixels() usage" },
1475 {bind_buffer_range, "bind_buffer_range", "Invalid glBindBufferRange() usage" },
1476 {bind_buffer_base, "bind_buffer_base", "Invalid glBindBufferBase() usage" },
1477 {clear_bufferiv, "clear_bufferiv", "Invalid glClearBufferiv() usage" },
1478 {clear_bufferuiv, "clear_bufferuiv", "Invalid glClearBufferuiv() usage" },
1479 {clear_bufferfv, "clear_bufferfv", "Invalid glClearBufferfv() usage" },
1480 {clear_bufferfi, "clear_bufferfi", "Invalid glClearBufferfi() usage" },
1481 {copy_buffer_sub_data, "copy_buffer_sub_data", "Invalid glCopyBufferSubData() usage" },
1482 {draw_buffers, "draw_buffers", "Invalid glDrawBuffers() usage" },
1483 {flush_mapped_buffer_range, "flush_mapped_buffer_range", "Invalid glFlushMappedBufferRange() usage" },
1484 {map_buffer_range, "map_buffer_range", "Invalid glMapBufferRange() usage" },
1485 {read_buffer, "read_buffer", "Invalid glReadBuffer() usage" },
1486 {unmap_buffer, "unmap_buffer", "Invalid glUnmapBuffer() usage" },
1487 {bind_framebuffer, "bind_framebuffer", "Invalid glBindFramebuffer() usage" },
1488 {bind_renderbuffer, "bind_renderbuffer", "Invalid glBindRenderbuffer() usage" },
1489 {check_framebuffer_status, "check_framebuffer_status", "Invalid glCheckFramebufferStatus() usage" },
1490 {gen_framebuffers, "gen_framebuffers", "Invalid glGenFramebuffers() usage" },
1491 {gen_renderbuffers, "gen_renderbuffers", "Invalid glGenRenderbuffers() usage" },
1492 {delete_framebuffers, "delete_framebuffers", "Invalid glDeleteFramebuffers() usage" },
1493 {delete_renderbuffers, "delete_renderbuffers", "Invalid glDeleteRenderbuffers() usage" },
1494 {framebuffer_renderbuffer, "framebuffer_renderbuffer", "Invalid glFramebufferRenderbuffer() usage" },
1495 {framebuffer_texture2d, "framebuffer_texture2d", "Invalid glFramebufferTexture2D() usage" },
1496 {renderbuffer_storage, "renderbuffer_storage", "Invalid glRenderbufferStorage() usage" },
1497 {blit_framebuffer, "blit_framebuffer", "Invalid glBlitFramebuffer() usage" },
1498 {blit_framebuffer_multisample, "blit_framebuffer_multisample", "Invalid glBlitFramebuffer() usage" },
1499 {framebuffer_texture_layer, "framebuffer_texture_layer", "Invalid glFramebufferTextureLayer() usage" },
1500 {invalidate_framebuffer, "invalidate_framebuffer", "Invalid glInvalidateFramebuffer() usage" },
1501 {invalidate_sub_framebuffer, "invalidate_sub_framebuffer", "Invalid glInvalidateSubFramebuffer() usage" },
1502 {renderbuffer_storage_multisample, "renderbuffer_storage_multisample", "Invalid glRenderbufferStorageMultisample() usage"},
1505 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
1508 } // NegativeTestShared