Lines Matching refs:ctx

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);
51 ctx.endSection();
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);
59 ctx.endSection();
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);
67 ctx.endSection();
70 void buffer_data (NegativeTestContext& ctx)
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);
79 ctx.endSection();
81 ctx.beginSection("GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW.");
82 ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, -1);
83 ctx.expectError(GL_INVALID_ENUM);
84 ctx.endSection();
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();
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();
97 ctx.glDeleteBuffers(1, &buffer);
100 void buffer_sub_data (NegativeTestContext& ctx)
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);
110 ctx.endSection();
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();
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();
126 ctx.glDeleteBuffers(1, &buffer);
129 void buffer_sub_data_size_offset (NegativeTestContext& ctx)
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);
149 ctx.endSection();
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);
165 ctx.endSection();
168 void read_pixels (NegativeTestContext& ctx)
172 ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of format and type is unsupported.");
173 ctx.glReadPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ubyteData[0]);
174 ctx.expectError(GL_INVALID_OPERATION);
175 ctx.endSection();
177 ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
178 ctx.glReadPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
179 ctx.expectError(GL_INVALID_VALUE);
180 ctx.glReadPixels(0, 0, 1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
181 ctx.expectError(GL_INVALID_VALUE);
182 ctx.glReadPixels(0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
183 ctx.expectError(GL_INVALID_VALUE);
184 ctx.endSection();
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);
193 ctx.endSection();
195 ctx.glDeleteFramebuffers(1, &fbo);
198 void read_pixels_format_mismatch (NegativeTestContext& ctx)
203 ctx.beginSection("Unsupported combinations of format and type will generate an INVALID_OPERATION error.");
204 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
205 ctx.expectError(GL_INVALID_OPERATION);
206 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
207 ctx.expectError(GL_INVALID_OPERATION);
208 ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
209 ctx.expectError(GL_INVALID_OPERATION);
210 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
211 ctx.expectError(GL_INVALID_OPERATION);
212 ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
213 ctx.expectError(GL_INVALID_OPERATION);
214 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
215 ctx.expectError(GL_INVALID_OPERATION);
216 ctx.endSection();
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);
223 ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
224 ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
225 ctx.glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]);
226 ctx.expectError(GL_NO_ERROR);
227 ctx.endSection();
230 void read_pixels_fbo_format_mismatch (NegativeTestContext& ctx)
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);
268 ctx.endSection();
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.");
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);
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);
299 ctx.endSection();
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)
312 ctx.glGenBuffers(1, &bufU);
313 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
314 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
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);
324 ctx.endSection();
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.");
328 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
329 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
330 ctx.expectError(GL_INVALID_VALUE);
331 ctx.endSection();
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.");
335 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
336 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4);
337 ctx.expectError(GL_INVALID_VALUE);
338 ctx.endSection();
340 ctx.beginSection("GL_INVALID_VALUE is generated if size is less than or equal to zero.");
341 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1);
342 ctx.expectError(GL_INVALID_VALUE);
343 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0);
344 ctx.expectError(GL_INVALID_VALUE);
345 ctx.endSection();
347 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.");
348 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
349 ctx.expectError(GL_INVALID_VALUE);
350 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
351 ctx.expectError(GL_INVALID_VALUE);
352 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
353 ctx.expectError(GL_INVALID_VALUE);
354 ctx.endSection();
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.");
358 ctx.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment);
359 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, alignment+1, 4);
360 ctx.expectError(GL_INVALID_VALUE);
361 ctx.endSection();
363 ctx.glDeleteBuffers(1, &bufU);
364 ctx.glDeleteBuffers(1, &bufTF);
367 void bind_buffer_base (NegativeTestContext& ctx)
370 ctx.glGenBuffers(1, &bufU);
371 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
372 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
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);
385 ctx.endSection();
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.");
389 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
390 ctx.glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU);
391 ctx.expectError(GL_INVALID_VALUE);
392 ctx.endSection();
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.");
396 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
397 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
398 ctx.expectError(GL_INVALID_VALUE);
399 ctx.endSection();
401 ctx.glDeleteBuffers(1, &bufU);
402 ctx.glDeleteBuffers(1, &bufTF);
405 void clear_bufferiv (NegativeTestContext& ctx)
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);
425 ctx.endSection();
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.");
429 ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
430 ctx.glClearBufferiv(GL_COLOR, maxDrawBuffers, &data[0]);
431 ctx.expectError(GL_INVALID_VALUE);
432 ctx.endSection();
434 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL.");
435 ctx.glClearBufferiv(GL_DEPTH, 1, &data[0]);
436 ctx.expectError(GL_INVALID_ENUM);
437 ctx.glClearBufferiv(GL_DEPTH_STENCIL, 1, &data[0]);
438 ctx.expectError(GL_INVALID_ENUM);
439 ctx.endSection();
441 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero.");
442 ctx.glClearBufferiv(GL_STENCIL, 1, &data[0]);
443 ctx.expectError(GL_INVALID_VALUE);
444 ctx.endSection();
446 ctx.glDeleteFramebuffers(1, &fbo);
447 ctx.glDeleteTextures(1, &texture);
450 void clear_bufferuiv (NegativeTestContext& ctx)
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);
470 ctx.endSection();
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.");
474 ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
475 ctx.glClearBufferuiv(GL_COLOR, maxDrawBuffers, &data[0]);
476 ctx.expectError(GL_INVALID_VALUE);
477 ctx.endSection();
479 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL or GL_DEPTH_STENCIL.");
480 ctx.glClearBufferuiv(GL_DEPTH, 1, &data[0]);
481 ctx.expectError(GL_INVALID_ENUM);
482 ctx.glClearBufferuiv(GL_STENCIL, 1, &data[0]);
483 ctx.expectError(GL_INVALID_ENUM);
484 ctx.glClearBufferuiv(GL_DEPTH_STENCIL, 1, &data[0]);
485 ctx.expectError(GL_INVALID_ENUM);
486 ctx.endSection();
488 ctx.glDeleteFramebuffers(1, &fbo);
489 ctx.glDeleteTextures(1, &texture);
492 void clear_bufferfv (NegativeTestContext& ctx)
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);
512 ctx.endSection();
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.");
516 ctx.glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
517 ctx.glClearBufferfv(GL_COLOR, maxDrawBuffers, &data[0]);
518 ctx.expectError(GL_INVALID_VALUE);
519 ctx.endSection();
521 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL.");
522 ctx.glClearBufferfv(GL_STENCIL, 1, &data[0]);
523 ctx.expectError(GL_INVALID_ENUM);
524 ctx.glClearBufferfv(GL_DEPTH_STENCIL, 1, &data[0]);
525 ctx.expectError(GL_INVALID_ENUM);
526 ctx.endSection();
528 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero.");
529 ctx.glClearBufferfv(GL_DEPTH, 1, &data[0]);
530 ctx.expectError(GL_INVALID_VALUE);
531 ctx.endSection();
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);
544 ctx.endSection();
546 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL.");
547 ctx.glClearBufferfi(GL_DEPTH, 0, 1.0f, 1);
548 ctx.expectError(GL_INVALID_ENUM);
549 ctx.glClearBufferfi(GL_STENCIL, 0, 1.0f, 1);
550 ctx.expectError(GL_INVALID_ENUM);
551 ctx.glClearBufferfi(GL_COLOR, 0, 1.0f, 1);
552 ctx.expectError(GL_INVALID_ENUM);
553 ctx.endSection();
555 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero.");
556 ctx.glClearBufferfi(GL_DEPTH_STENCIL, 1, 1.0f, 1);
557 ctx.expectError(GL_INVALID_VALUE);
558 ctx.endSection();
561 void copy_buffer_sub_data (NegativeTestContext& ctx)
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);
580 ctx.endSection();
582 ctx.beginSection("GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.");
583 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
584 ctx.expectError (GL_INVALID_VALUE);
585 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16);
586 ctx.expectError (GL_INVALID_VALUE);
587 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4);
588 ctx.expectError (GL_INVALID_VALUE);
589 ctx.endSection();
591 ctx.beginSection("GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.");
592 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
593 ctx.expectError (GL_INVALID_VALUE);
594 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16);
595 ctx.expectError (GL_INVALID_VALUE);
596 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4);
597 ctx.expectError (GL_INVALID_VALUE);
598 ctx.endSection();
600 ctx.beginSection("GL_INVALID_VALUE is generated if the same buffer object is bound to both readtarget and writetarget and the ranges [readoffset, readoffset + size) and [writeoffset, writeoffset + size) overlap.");
601 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[0]);
602 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4);
603 ctx.expectError (GL_NO_ERROR);
604 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4);
605 ctx.expectError (GL_INVALID_VALUE);
606 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18);
607 ctx.expectError (GL_INVALID_VALUE);
608 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
609 ctx.endSection();
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]);
622 ctx.endSection();
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);
634 ctx.endSection();
636 ctx.glDeleteBuffers(2, buf);
639 void draw_buffers (NegativeTestContext& ctx)
644 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
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);
664 ctx.endSection();
666 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1.");
667 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
668 ctx.glDrawBuffers (2, &values[0]);
669 ctx.expectError (GL_INVALID_OPERATION);
670 ctx.endSection();
672 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and the value in bufs is one of the GL_COLOR_ATTACHMENTn tokens.");
673 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
674 ctx.glDrawBuffers (1, &values[2]);
675 ctx.expectError (GL_INVALID_OPERATION);
676 ctx.endSection();
678 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to a framebuffer object and the ith buffer listed in bufs is anything other than GL_NONE or GL_COLOR_ATTACHMENTSi.");
679 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
680 ctx.glDrawBuffers (1, &values[1]);
681 ctx.expectError (GL_INVALID_OPERATION);
682 ctx.endSection();
684 ctx.beginSection("GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.");
685 ctx.glDrawBuffers (-1, &values[1]);
686 ctx.expectError (GL_INVALID_VALUE);
687 ctx.glDrawBuffers (maxDrawBuffers+1, &values[0]);
688 ctx.expectError (GL_INVALID_VALUE);
689 ctx.endSection();
691 ctx.glDeleteTextures(1, &texture);
692 ctx.glDeleteFramebuffers(1, &fbo);
695 void flush_mapped_buffer_range (NegativeTestContext& ctx)
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);
717 ctx.endSection();
719 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
720 ctx.glBindBuffer (GL_ARRAY_BUFFER, 0);
721 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
722 ctx.expectError (GL_INVALID_OPERATION);
723 ctx.endSection();
725 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer bound to target is not mapped, or is mapped without the GL_MAP_FLUSH_EXPLICIT flag.");
726 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
727 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
728 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
729 ctx.expectError (GL_INVALID_OPERATION);
730 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
731 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
732 ctx.expectError (GL_INVALID_OPERATION);
733 ctx.endSection();
735 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
736 ctx.glDeleteBuffers (1, &buf);
739 void map_buffer_range (NegativeTestContext& ctx)
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);
755 ctx.endSection();
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);
766 ctx.endSection();
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);
774 ctx.endSection();
776 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer is already in a mapped state.");
777 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
778 ctx.expectError (GL_NO_ERROR);
779 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT);
780 ctx.expectError (GL_INVALID_OPERATION);
781 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
782 ctx.endSection();
784 ctx.beginSection("GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.");
785 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
786 ctx.expectError (GL_INVALID_OPERATION);
787 ctx.endSection();
789 ctx.beginSection("GL_INVALID_OPERATION is generated if ");
790 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
791 ctx.expectError (GL_INVALID_OPERATION);
792 ctx.endSection();
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);
803 ctx.endSection();
805 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.");
806 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
807 ctx.expectError (GL_INVALID_OPERATION);
808 ctx.endSection();
810 ctx.glDeleteBuffers (1, &buf);
813 void read_buffer (NegativeTestContext& ctx)
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);
844 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT);
845 ctx.expectError (GL_INVALID_ENUM);
846 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT);
847 ctx.expectError (GL_INVALID_ENUM);
848 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT+1);
849 ctx.expectError (GL_INVALID_ENUM);
850 ctx.glReadBuffer (0xffffffffu);
851 ctx.expectError (GL_INVALID_ENUM);
852 ctx.endSection();
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);
862 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT - 1);
863 ctx.expectError (GL_INVALID_OPERATION);
866 ctx.endSection();
868 ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK.");
869 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
870 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0);
871 ctx.expectError (GL_INVALID_OPERATION);
872 ctx.endSection();
874 ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is a named framebuffer and mode is not GL_NONE or GL_COLOR_ATTACHMENTi.");
875 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
876 ctx.glReadBuffer (GL_BACK);
877 ctx.expectError (GL_INVALID_OPERATION);
878 ctx.endSection();
880 ctx.glDeleteTextures(1, &texture);
881 ctx.glDeleteFramebuffers(1, &fbo);
884 void unmap_buffer (NegativeTestContext& ctx)
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);
897 ctx.endSection();
899 ctx.glDeleteBuffers (1, &buf);
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);
910 ctx.endSection();
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);
920 ctx.endSection();
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);
930 ctx.endSection();
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);
938 ctx.endSection();
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);
946 ctx.endSection();
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);
954 ctx.endSection();
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);
962 ctx.endSection();
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);
976 ctx.endSection();
978 ctx.beginSection("GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
979 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
980 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
981 ctx.expectError(GL_INVALID_ENUM);
982 ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
983 ctx.endSection();
985 ctx.beginSection("GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
986 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
987 ctx.expectError(GL_INVALID_OPERATION);
988 ctx.endSection();
990 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
991 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
992 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
993 ctx.expectError(GL_INVALID_OPERATION);
994 ctx.endSection();
996 ctx.glDeleteRenderbuffers(1, &rbo);
997 ctx.glDeleteFramebuffers(1, &fbo);
1000 void framebuffer_texture2d (NegativeTestContext& ctx)
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);
1021 ctx.endSection();
1023 ctx.beginSection("GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
1024 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
1025 ctx.expectError(GL_INVALID_ENUM);
1026 ctx.endSection();
1028 ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.");
1030 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1031 ctx.expectError(GL_INVALID_VALUE);
1033 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize);
1034 ctx.expectError(GL_INVALID_VALUE);
1036 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize);
1037 ctx.expectError(GL_INVALID_VALUE);
1038 ctx.endSection();
1040 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1041 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
1042 ctx.expectError(GL_INVALID_OPERATION);
1043 ctx.endSection();
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);
1053 ctx.endSection();
1055 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1056 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1057 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1058 ctx.expectError(GL_INVALID_OPERATION);
1059 ctx.endSection();
1061 ctx.glDeleteFramebuffers(1, &fbo);
1064 void renderbuffer_storage (NegativeTestContext& ctx)
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);
1075 ctx.endSection();
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);
1089 ctx.endSection();
1091 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1092 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, 1);
1093 ctx.expectError (GL_INVALID_VALUE);
1094 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, -1);
1095 ctx.expectError (GL_INVALID_VALUE);
1096 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, -1);
1097 ctx.expectError (GL_INVALID_VALUE);
1098 ctx.endSection();
1100 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1102 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1103 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
1104 ctx.expectError (GL_INVALID_VALUE);
1105 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
1106 ctx.expectError (GL_INVALID_VALUE);
1107 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
1108 ctx.expectError (GL_INVALID_VALUE);
1109 ctx.endSection();
1111 ctx.glDeleteRenderbuffers(1, &rbo);
1114 void blit_framebuffer (NegativeTestContext& ctx)
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);
1152 ctx.endSection();
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);
1177 ctx.endSection();
1179 ctx.beginSection("GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.");
1180 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1181 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1182 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1183 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1184 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1185 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage;
1186 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR);
1187 ctx.expectError (GL_INVALID_OPERATION);
1188 ctx.endSection();
1190 ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_DEPTH_BUFFER_BIT or GL_STENCIL_BUFFER_BIT and the source and destination depth and stencil formats do not match.");
1191 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1192 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32);
1193 ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1194 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1195 ctx.expectError (GL_INVALID_OPERATION);
1196 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1197 ctx.expectError (GL_INVALID_OPERATION);
1198 ctx.endSection();
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);
1230 ctx.endSection();
1232 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for the read buffer is greater than zero and the formats of draw and read buffers are not identical.");
1233 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 32, 32);
1234 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1235 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1236 ctx.expectError (GL_INVALID_OPERATION);
1237 ctx.endSection();
1239 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_SAMPLE_BUFFERS for the read buffer is greater than zero and the source and destination rectangles are not defined with the same (X0, Y0) and (X1, Y1) bounds.");
1240 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1241 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1242 ctx.glBlitFramebuffer (0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1243 ctx.expectError (GL_INVALID_OPERATION);
1244 ctx.endSection();
1246 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1247 ctx.glDeleteRenderbuffers (2, rbo);
1248 ctx.glDeleteFramebuffers (2, fbo);
1251 void framebuffer_texture_layer (NegativeTestContext& ctx)
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);
1278 ctx.endSection();
1280 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1281 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, -1, tex3D, 0, 1);
1282 ctx.expectError (GL_INVALID_ENUM);
1283 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1);
1284 ctx.expectError (GL_INVALID_ENUM);
1285 ctx.endSection();
1287 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is non-zero and not the name of a 3D texture or 2D array texture.");
1288 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0);
1289 ctx.expectError (GL_INVALID_OPERATION);
1290 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0);
1291 ctx.expectError (GL_INVALID_OPERATION);
1292 ctx.endSection();
1294 ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is negative.");
1295 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1);
1296 ctx.expectError (GL_INVALID_VALUE);
1297 ctx.endSection();
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.");
1301 ctx.glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize);
1302 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
1303 ctx.expectError (GL_INVALID_VALUE);
1304 ctx.endSection();
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.");
1308 ctx.glGetIntegerv (GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers);
1309 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
1310 ctx.expectError (GL_INVALID_VALUE);
1311 ctx.endSection();
1313 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1314 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1315 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1316 ctx.expectError (GL_INVALID_OPERATION);
1317 ctx.endSection();
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)
1331 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &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);
1349 ctx.endSection();
1351 ctx.beginSection("GL_INVALID_OPERATION is generated if attachments contains GL_COLOR_ATTACHMENTm and m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
1352 ctx.glInvalidateFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1]);
1353 ctx.expectError (GL_INVALID_OPERATION);
1354 ctx.endSection();
1356 ctx.glDeleteTextures (1, &texture);
1357 ctx.glDeleteFramebuffers (1, &fbo);
1360 void invalidate_sub_framebuffer (NegativeTestContext& ctx)
1366 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &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);
1384 ctx.endSection();
1386 ctx.beginSection("GL_INVALID_OPERATION is generated if attachments contains GL_COLOR_ATTACHMENTm and m is greater than or equal to the value of GL_MAX_COLOR_ATTACHMENTS.");
1387 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16);
1388 ctx.expectError (GL_INVALID_OPERATION);
1389 ctx.endSection();
1391 ctx.glDeleteTextures (1, &texture);
1392 ctx.glDeleteFramebuffers (1, &fbo);
1395 void renderbuffer_storage_multisample (NegativeTestContext& ctx)
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);
1412 ctx.endSection();
1414 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.");
1415 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA4+1, GL_RGBA4, 1, 1);
1416 ctx.expectError (GL_INVALID_OPERATION);
1417 ctx.endSection();
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);
1431 ctx.endSection();
1433 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat. (Unsigned integer format)");
1434 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA8UI+1, GL_RGBA8UI, 1, 1);
1435 ctx.expectError (GL_INVALID_OPERATION);
1436 ctx.endSection();
1438 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1439 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, 1);
1440 ctx.expectError (GL_INVALID_VALUE);
1441 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, 1, -1);
1442 ctx.expectError (GL_INVALID_VALUE);
1443 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, -1);
1444 ctx.expectError (GL_INVALID_VALUE);
1445 ctx.endSection();
1447 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1449 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1450 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, 1, maxSize+1);
1451 ctx.expectError (GL_INVALID_VALUE);
1452 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, 1);
1453 ctx.expectError (GL_INVALID_VALUE);
1454 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, maxSize+1);
1455 ctx.expectError (GL_INVALID_VALUE);
1456 ctx.endSection();
1458 ctx.glDeleteRenderbuffers(1, &rbo);