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"
28 #include "glwDefs.hpp"
29 #include "glwEnums.hpp"
37 namespace NegativeTestShared
41 using glu::CallLogWrapper;
45 void bind_buffer (NegativeTestContext& ctx)
47 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the allowable values.");
48 ctx.glBindBuffer(-1, 0);
49 ctx.expectError(GL_INVALID_ENUM);
53 void delete_buffers (NegativeTestContext& ctx)
55 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
56 ctx.glDeleteBuffers(-1, 0);
57 ctx.expectError(GL_INVALID_VALUE);
61 void gen_buffers (NegativeTestContext& ctx)
63 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
64 ctx.glGenBuffers(-1, 0);
65 ctx.expectError(GL_INVALID_VALUE);
69 void buffer_data (NegativeTestContext& ctx)
71 GLuint buffer = 0x1234;
72 ctx.glGenBuffers(1, &buffer);
73 ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
75 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
76 ctx.glBufferData(-1, 0, NULL, GL_STREAM_DRAW);
77 ctx.expectError(GL_INVALID_ENUM);
80 ctx.beginSection("GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW.");
81 ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, -1);
82 ctx.expectError(GL_INVALID_ENUM);
85 ctx.beginSection("GL_INVALID_VALUE is generated if size is negative.");
86 ctx.glBufferData(GL_ARRAY_BUFFER, -1, NULL, GL_STREAM_DRAW);
87 ctx.expectError(GL_INVALID_VALUE);
90 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
91 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
92 ctx.glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STREAM_DRAW);
93 ctx.expectError(GL_INVALID_OPERATION);
96 ctx.glDeleteBuffers(1, &buffer);
99 void buffer_sub_data (NegativeTestContext& ctx)
101 GLuint buffer = 0x1234;
102 ctx.glGenBuffers(1, &buffer);
103 ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
104 ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
106 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
107 ctx.glBufferSubData(-1, 1, 1, 0);
108 ctx.expectError(GL_INVALID_ENUM);
111 ctx.beginSection("GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
112 ctx.glBindBuffer(GL_ARRAY_BUFFER, 0);
113 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
114 ctx.expectError(GL_INVALID_OPERATION);
117 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object being updated is mapped.");
118 ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
119 ctx.glMapBufferRange(GL_ARRAY_BUFFER, 0, 5, GL_MAP_READ_BIT);
120 ctx.expectError(GL_NO_ERROR);
121 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
122 ctx.expectError(GL_INVALID_OPERATION);
125 ctx.glDeleteBuffers(1, &buffer);
128 void buffer_sub_data_size_offset (NegativeTestContext& ctx)
130 GLuint buffer = 0x1234;
131 ctx.glGenBuffers(1, &buffer);
132 ctx.glBindBuffer(GL_ARRAY_BUFFER, buffer);
133 ctx.glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
135 ctx.beginSection("GL_INVALID_VALUE is generated if offset or size is negative, or if together they define a region of memory that extends beyond the buffer object's allocated data store.");
136 ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, 1, 0);
137 ctx.expectError(GL_INVALID_VALUE);
138 ctx.glBufferSubData(GL_ARRAY_BUFFER, -1, -1, 0);
139 ctx.expectError(GL_INVALID_VALUE);
140 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, -1, 0);
141 ctx.expectError(GL_INVALID_VALUE);
142 ctx.glBufferSubData(GL_ARRAY_BUFFER, 15, 1, 0);
143 ctx.expectError(GL_INVALID_VALUE);
144 ctx.glBufferSubData(GL_ARRAY_BUFFER, 1, 15, 0);
145 ctx.expectError(GL_INVALID_VALUE);
146 ctx.glBufferSubData(GL_ARRAY_BUFFER, 8, 8, 0);
147 ctx.expectError(GL_INVALID_VALUE);
150 ctx.glDeleteBuffers(1, &buffer);
153 void clear (NegativeTestContext& ctx)
155 ctx.beginSection("GL_INVALID_VALUE is generated if any bit other than the three defined bits is set in mask.");
156 ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
157 ctx.expectError(GL_NO_ERROR);
158 ctx.glClear(0x00000200);
159 ctx.expectError(GL_INVALID_VALUE);
160 ctx.glClear(0x00001000);
161 ctx.expectError(GL_INVALID_VALUE);
162 ctx.glClear(0x00000010);
163 ctx.expectError(GL_INVALID_VALUE);
167 void read_pixels (NegativeTestContext& ctx)
169 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.");
187 ctx.glGenFramebuffers(1, &fbo);
188 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
189 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
190 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
191 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
194 ctx.glDeleteFramebuffers(1, &fbo);
197 void readn_pixels (NegativeTestContext& ctx)
199 std::vector<GLubyte> ubyteData (4);
202 if (!contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2))
203 && !ctx.isExtensionSupported("GL_KHR_robustness")
204 && !ctx.isExtensionSupported("GL_EXT_robustness"))
206 TCU_THROW(NotSupportedError, "GLES 3.2 or robustness extension not supported");
209 ctx.beginSection("GL_INVALID_OPERATION is generated if the combination of format and type is unsupported.");
210 ctx.glReadnPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, (int) ubyteData.size(), &ubyteData[0]);
211 ctx.expectError(GL_INVALID_OPERATION);
214 ctx.beginSection("GL_INVALID_VALUE is generated if either width or height is negative.");
215 ctx.glReadnPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
216 ctx.expectError(GL_INVALID_VALUE);
217 ctx.glReadnPixels(0, 0, 1, -1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
218 ctx.expectError(GL_INVALID_VALUE);
219 ctx.glReadnPixels(0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
220 ctx.expectError(GL_INVALID_VALUE);
223 ctx.beginSection("GL_INVALID_OPERATION is generated by ReadnPixels if the buffer size required to store the requested data is larger than bufSize.");
224 ctx.glReadnPixels(0, 0, 0x1234, 0x1234, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
225 ctx.expectError(GL_INVALID_OPERATION);
228 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
229 ctx.glGenFramebuffers(1, &fbo);
230 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
231 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
232 ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (int) ubyteData.size(), &ubyteData[0]);
233 ctx.expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
236 ctx.glDeleteFramebuffers(1, &fbo);
239 void read_pixels_format_mismatch (NegativeTestContext& ctx)
241 std::vector<GLubyte> ubyteData (4);
242 std::vector<GLushort> ushortData (4);
243 std::vector<GLfloat> floatData (4);
244 GLint readFormat = 0x1234;
245 GLint readType = 0x1234;
247 ctx.beginSection("Unsupported combinations of format and type will generate an GL_INVALID_OPERATION error.");
248 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
249 ctx.expectError(GL_INVALID_OPERATION);
250 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
251 ctx.expectError(GL_INVALID_OPERATION);
252 ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
253 ctx.expectError(GL_INVALID_OPERATION);
254 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
255 ctx.expectError(GL_INVALID_OPERATION);
256 ctx.glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
257 ctx.expectError(GL_INVALID_OPERATION);
258 ctx.glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
259 ctx.expectError(GL_INVALID_OPERATION);
260 ctx.glReadnPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, (int) floatData.size(), &floatData[0]);
261 ctx.expectError(GL_INVALID_OPERATION);
264 ctx.beginSection("GL_RGBA/GL_UNSIGNED_BYTE is always accepted and the other acceptable pair can be discovered by querying GL_IMPLEMENTATION_COLOR_READ_FORMAT and GL_IMPLEMENTATION_COLOR_READ_TYPE.");
265 ctx.glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
266 ctx.expectError(GL_NO_ERROR);
267 ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
268 ctx.glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
269 ctx.glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]);
270 ctx.expectError(GL_NO_ERROR);
274 void read_pixels_fbo_format_mismatch (NegativeTestContext& ctx)
276 std::vector<GLubyte> ubyteData(4);
277 std::vector<float> floatData(4);
278 deUint32 fbo = 0x1234;
279 deUint32 texture = 0x1234;
281 ctx.glGenTextures (1, &texture);
282 ctx.glBindTexture (GL_TEXTURE_2D, texture);
283 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
284 ctx.glGenFramebuffers (1, &fbo);
285 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
286 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
287 ctx.expectError (GL_NO_ERROR);
289 ctx.beginSection("GL_INVALID_OPERATION is generated if currently bound framebuffer format is incompatible with format and type.");
291 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
292 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
293 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
294 ctx.expectError (GL_NO_ERROR);
295 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
296 ctx.expectError (GL_INVALID_OPERATION);
298 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
299 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
300 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
301 ctx.expectError (GL_NO_ERROR);
302 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
303 ctx.expectError (GL_INVALID_OPERATION);
305 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
306 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
307 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
308 ctx.expectError (GL_NO_ERROR);
309 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]);
310 ctx.expectError (GL_INVALID_OPERATION);
312 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)) ||
313 ctx.isExtensionSupported("GL_EXT_color_buffer_float"))
315 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
316 ctx.expectError (GL_NO_ERROR);
317 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
318 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
319 ctx.expectError (GL_NO_ERROR);
320 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_INT, &floatData[0]);
321 ctx.expectError (GL_INVALID_OPERATION);
326 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.");
329 int sampleBuffers = 0x1234;
330 deUint32 rbo = 0x1234;
332 ctx.glGenRenderbuffers(1, &rbo);
333 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
334 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
335 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
337 ctx.glGetIntegerv (GL_READ_FRAMEBUFFER_BINDING, &binding);
338 ctx.getLog() << TestLog::Message << "// GL_READ_FRAMEBUFFER_BINDING: " << binding << TestLog::EndMessage;
339 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
340 ctx.glGetIntegerv (GL_SAMPLE_BUFFERS, &sampleBuffers);
341 ctx.getLog() << TestLog::Message << "// GL_SAMPLE_BUFFERS: " << sampleBuffers << TestLog::EndMessage;
342 ctx.expectError (GL_NO_ERROR);
344 if (binding == 0 || sampleBuffers <= 0)
346 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;
347 ctx.fail("Got invalid value");
351 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
352 ctx.expectError (GL_INVALID_OPERATION);
357 ctx.glBindRenderbuffer (GL_RENDERBUFFER, 0);
358 ctx.glBindTexture (GL_TEXTURE_2D, 0);
359 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
360 ctx.glDeleteFramebuffers (1, &fbo);
361 ctx.glDeleteTextures (1, &texture);
362 ctx.glDeleteRenderbuffers (1, &rbo);
365 void bind_buffer_range (NegativeTestContext& ctx)
367 deUint32 bufAC = 0x1234;
368 deUint32 bufU = 0x1234;
369 deUint32 bufTF = 0x1234;
370 int maxTFSize = 0x1234;
371 int maxUSize = 0x1234;
372 int uAlignment = 0x1234;
374 ctx.glGenBuffers(1, &bufU);
375 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
376 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
378 ctx.glGenBuffers(1, &bufTF);
379 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
380 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
382 ctx.glGenBuffers(1, &bufAC);
383 ctx.glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bufAC);
384 ctx.glBufferData(GL_ATOMIC_COUNTER_BUFFER, 16, NULL, GL_STREAM_DRAW);
386 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
387 ctx.glBindBufferRange(GL_ARRAY_BUFFER, 0, bufU, 0, 4);
388 ctx.expectError(GL_INVALID_ENUM);
391 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.");
392 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
393 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
394 ctx.expectError(GL_INVALID_VALUE);
397 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.");
398 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
399 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4);
400 ctx.expectError(GL_INVALID_VALUE);
403 ctx.beginSection("GL_INVALID_VALUE is generated if size is less than or equal to zero.");
404 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1);
405 ctx.expectError(GL_INVALID_VALUE);
406 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0);
407 ctx.expectError(GL_INVALID_VALUE);
410 ctx.beginSection("GL_INVALID_VALUE is generated if offset is less than zero.");
411 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, -1, 0);
412 ctx.expectError(GL_INVALID_VALUE);
415 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.");
416 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
417 ctx.expectError(GL_INVALID_VALUE);
418 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
419 ctx.expectError(GL_INVALID_VALUE);
420 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
421 ctx.expectError(GL_INVALID_VALUE);
424 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.");
425 ctx.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uAlignment);
426 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, uAlignment+1, 4);
427 ctx.expectError(GL_INVALID_VALUE);
430 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
432 int maxACize = 0x1234;
433 int maxSSize = 0x1234;
434 int ssAlignment = 0x1234;
436 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_ATOMIC_COUNTER_BUFFER and index is greater than or equal to GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS.");
437 ctx.glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &maxACize);
438 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, maxACize, bufU, 0, 4);
439 ctx.expectError(GL_INVALID_VALUE);
442 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_SHADER_STORAGE_BUFFER and index is greater than or equal to GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS.");
443 ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxSSize);
444 ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, maxSSize, bufU, 0, 4);
445 ctx.expectError(GL_INVALID_VALUE);
448 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_ATOMIC_COUNTER_BUFFER and offset is not multiples of 4.");
449 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, bufTF, 5, 0);
450 ctx.expectError(GL_INVALID_VALUE);
453 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_SHADER_STORAGE_BUFFER and offset is not a multiple of the value of GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT.");
454 ctx.glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &ssAlignment);
455 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, bufTF, ssAlignment+1, 0);
456 ctx.expectError(GL_INVALID_VALUE);
460 ctx.glDeleteBuffers(1, &bufU);
461 ctx.glDeleteBuffers(1, &bufTF);
462 ctx.glDeleteBuffers(1, &bufAC);
465 void bind_buffer_base (NegativeTestContext& ctx)
467 deUint32 bufU = 0x1234;
468 deUint32 bufTF = 0x1234;
469 int maxUSize = 0x1234;
470 int maxTFSize = 0x1234;
472 ctx.glGenBuffers(1, &bufU);
473 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
474 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
476 ctx.glGenBuffers(1, &bufTF);
477 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
478 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
479 ctx.expectError(GL_NO_ERROR);
481 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_ATOMIC_COUNTER_BUFFER, GL_SHADER_STORAGE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER.");
482 ctx.glBindBufferBase(-1, 0, bufU);
483 ctx.expectError(GL_INVALID_ENUM);
484 ctx.glBindBufferBase(GL_ARRAY_BUFFER, 0, bufU);
485 ctx.expectError(GL_INVALID_ENUM);
488 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.");
489 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
490 ctx.glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU);
491 ctx.expectError(GL_INVALID_VALUE);
494 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.");
495 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
496 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
497 ctx.expectError(GL_INVALID_VALUE);
500 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
502 int maxACize = 0x1234;
503 int maxSSize = 0x1234;
505 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_ATOMIC_COUNTER_BUFFER and index is greater than or equal to GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS.");
506 ctx.glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &maxACize);
507 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, maxACize, bufU, 0, 4);
508 ctx.expectError(GL_INVALID_VALUE);
511 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_SHADER_STORAGE_BUFFER and index is greater than or equal to GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS.");
512 ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxSSize);
513 ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, maxSSize, bufU, 0, 4);
514 ctx.expectError(GL_INVALID_VALUE);
518 ctx.glDeleteBuffers(1, &bufU);
519 ctx.glDeleteBuffers(1, &bufTF);
522 void clear_bufferiv (NegativeTestContext& ctx)
524 std::vector<int> data (32*32);
525 deUint32 fbo = 0x1234;
526 deUint32 texture = 0x1234;
527 int maxDrawBuffers = 0x1234;
529 ctx.glGenTextures (1, &texture);
530 ctx.glBindTexture (GL_TEXTURE_2D, texture);
531 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
532 ctx.glGenFramebuffers (1, &fbo);
533 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
534 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
535 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
536 ctx.expectError (GL_NO_ERROR);
538 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
539 ctx.glClearBufferiv (-1, 0, &data[0]);
540 ctx.expectError (GL_INVALID_ENUM);
541 ctx.glClearBufferiv (GL_FRAMEBUFFER, 0, &data[0]);
542 ctx.expectError (GL_INVALID_ENUM);
545 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL.");
546 ctx.glClearBufferiv (GL_DEPTH, 1, &data[0]);
547 ctx.expectError (GL_INVALID_ENUM);
548 ctx.glClearBufferiv (GL_DEPTH_STENCIL, 1, &data[0]);
549 ctx.expectError (GL_INVALID_ENUM);
552 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR or GL_STENCIL and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
553 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
554 ctx.glClearBufferiv (GL_COLOR, maxDrawBuffers, &data[0]);
555 ctx.expectError (GL_INVALID_VALUE);
558 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR or GL_STENCIL and drawBuffer is negative.");
559 ctx.glClearBufferiv (GL_COLOR, -1, &data[0]);
560 ctx.expectError (GL_INVALID_VALUE);
563 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero.");
564 ctx.glClearBufferiv (GL_STENCIL, 1, &data[0]);
565 ctx.expectError (GL_INVALID_VALUE);
568 ctx.glDeleteFramebuffers (1, &fbo);
569 ctx.glDeleteTextures (1, &texture);
572 void clear_bufferuiv (NegativeTestContext& ctx)
574 std::vector<deUint32> data (32*32);
575 deUint32 fbo = 0x1234;
576 deUint32 texture = 0x1234;
577 int maxDrawBuffers = 0x1234;
579 ctx.glGenTextures (1, &texture);
580 ctx.glBindTexture (GL_TEXTURE_2D, texture);
581 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
582 ctx.glGenFramebuffers (1, &fbo);
583 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
584 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
585 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
586 ctx.expectError (GL_NO_ERROR);
588 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR.");
589 ctx.glClearBufferuiv (-1, 0, &data[0]);
590 ctx.expectError (GL_INVALID_ENUM);
591 ctx.glClearBufferuiv (GL_FRAMEBUFFER, 0, &data[0]);
592 ctx.expectError (GL_INVALID_ENUM);
595 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL, or GL_DEPTH_STENCIL.");
596 ctx.glClearBufferuiv (GL_DEPTH, 0, &data[0]);
597 ctx.expectError (GL_INVALID_ENUM);
598 ctx.glClearBufferuiv (GL_STENCIL, 0, &data[0]);
599 ctx.expectError (GL_INVALID_ENUM);
600 ctx.glClearBufferuiv (GL_DEPTH_STENCIL, 0, &data[0]);
601 ctx.expectError (GL_INVALID_ENUM);
604 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
605 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
606 ctx.glClearBufferuiv (GL_COLOR, maxDrawBuffers, &data[0]);
607 ctx.expectError (GL_INVALID_VALUE);
610 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
611 ctx.glClearBufferuiv (GL_COLOR, -1, &data[0]);
612 ctx.expectError (GL_INVALID_VALUE);
615 ctx.glDeleteFramebuffers (1, &fbo);
616 ctx.glDeleteTextures (1, &texture);
619 void clear_bufferfv (NegativeTestContext& ctx)
621 std::vector<float> data (32*32);
622 deUint32 fbo = 0x1234;
623 deUint32 texture = 0x1234;
624 int maxDrawBuffers = 0x1234;
626 ctx.glGenTextures (1, &texture);
627 ctx.glBindTexture (GL_TEXTURE_2D, texture);
628 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
629 ctx.glGenFramebuffers (1, &fbo);
630 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
631 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
632 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
633 ctx.expectError (GL_NO_ERROR);
635 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR or GL_DEPTH.");
636 ctx.glClearBufferfv (-1, 0, &data[0]);
637 ctx.expectError (GL_INVALID_ENUM);
638 ctx.glClearBufferfv (GL_FRAMEBUFFER, 0, &data[0]);
639 ctx.expectError (GL_INVALID_ENUM);
642 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL.");
643 ctx.glClearBufferfv (GL_STENCIL, 1, &data[0]);
644 ctx.expectError (GL_INVALID_ENUM);
645 ctx.glClearBufferfv (GL_DEPTH_STENCIL, 1, &data[0]);
646 ctx.expectError (GL_INVALID_ENUM);
649 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
650 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
651 ctx.glClearBufferfv (GL_COLOR, maxDrawBuffers, &data[0]);
652 ctx.expectError (GL_INVALID_VALUE);
655 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
656 ctx.glClearBufferfv (GL_COLOR, -1, &data[0]);
657 ctx.expectError (GL_INVALID_VALUE);
660 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero.");
661 ctx.glClearBufferfv (GL_DEPTH, 1, &data[0]);
662 ctx.expectError (GL_INVALID_VALUE);
665 ctx.glDeleteFramebuffers (1, &fbo);
666 ctx.glDeleteTextures (1, &texture);
669 void clear_bufferfi (NegativeTestContext& ctx)
671 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL.");
672 ctx.glClearBufferfi (-1, 0, 1.0f, 1);
673 ctx.expectError (GL_INVALID_ENUM);
674 ctx.glClearBufferfi (GL_FRAMEBUFFER, 0, 1.0f, 1);
675 ctx.expectError (GL_INVALID_ENUM);
676 ctx.glClearBufferfi (GL_DEPTH, 0, 1.0f, 1);
677 ctx.expectError (GL_INVALID_ENUM);
678 ctx.glClearBufferfi (GL_STENCIL, 0, 1.0f, 1);
679 ctx.expectError (GL_INVALID_ENUM);
680 ctx.glClearBufferfi (GL_COLOR, 0, 1.0f, 1);
681 ctx.expectError (GL_INVALID_ENUM);
684 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero.");
685 ctx.glClearBufferfi (GL_DEPTH_STENCIL, 1, 1.0f, 1);
686 ctx.expectError (GL_INVALID_VALUE);
690 void copy_buffer_sub_data (NegativeTestContext& ctx)
693 std::vector<float> data (32*32);
695 ctx.glGenBuffers (2, buf);
696 ctx.glBindBuffer (GL_COPY_READ_BUFFER, buf[0]);
697 ctx.glBufferData (GL_COPY_READ_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
698 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
699 ctx.glBufferData (GL_COPY_WRITE_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
700 ctx.expectError (GL_NO_ERROR);
702 ctx.beginSection("GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative.");
703 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, -4);
704 ctx.expectError (GL_INVALID_VALUE);
705 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, -1, 0, 4);
706 ctx.expectError (GL_INVALID_VALUE);
707 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, -1, 4);
708 ctx.expectError (GL_INVALID_VALUE);
711 ctx.beginSection("GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.");
712 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
713 ctx.expectError (GL_INVALID_VALUE);
714 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16);
715 ctx.expectError (GL_INVALID_VALUE);
716 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4);
717 ctx.expectError (GL_INVALID_VALUE);
720 ctx.beginSection("GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.");
721 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
722 ctx.expectError (GL_INVALID_VALUE);
723 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16);
724 ctx.expectError (GL_INVALID_VALUE);
725 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4);
726 ctx.expectError (GL_INVALID_VALUE);
729 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.");
730 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[0]);
731 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4);
732 ctx.expectError (GL_NO_ERROR);
733 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4);
734 ctx.expectError (GL_INVALID_VALUE);
735 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18);
736 ctx.expectError (GL_INVALID_VALUE);
737 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
740 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget.");
741 ctx.glBindBuffer (GL_COPY_READ_BUFFER, 0);
742 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
743 ctx.expectError (GL_INVALID_OPERATION);
745 ctx.glBindBuffer (GL_COPY_READ_BUFFER, buf[0]);
746 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, 0);
747 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
748 ctx.expectError (GL_INVALID_OPERATION);
750 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
753 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped.");
754 ctx.glMapBufferRange (GL_COPY_READ_BUFFER, 0, 4, GL_MAP_READ_BIT);
755 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
756 ctx.expectError (GL_INVALID_OPERATION);
757 ctx.glUnmapBuffer (GL_COPY_READ_BUFFER);
759 ctx.glMapBufferRange (GL_COPY_WRITE_BUFFER, 0, 4, GL_MAP_READ_BIT);
760 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
761 ctx.expectError (GL_INVALID_OPERATION);
762 ctx.glUnmapBuffer (GL_COPY_WRITE_BUFFER);
765 ctx.glDeleteBuffers(2, buf);
768 void draw_buffers (NegativeTestContext& ctx)
770 deUint32 fbo = 0x1234;
771 deUint32 texture = 0x1234;
772 int maxDrawBuffers = 0x1234;
773 int maxColorAttachments = -1;
774 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
775 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
776 std::vector<deUint32> values (maxDrawBuffers+1);
777 std::vector<deUint32> attachments (4);
778 std::vector<GLfloat> data (32*32);
781 values[2] = GL_COLOR_ATTACHMENT0;
782 values[3] = GL_DEPTH_ATTACHMENT;
783 attachments[0] = (glw::GLenum) (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
784 attachments[1] = GL_COLOR_ATTACHMENT0;
785 attachments[2] = GL_COLOR_ATTACHMENT1;
786 attachments[3] = GL_NONE;
788 ctx.glGenTextures (1, &texture);
789 ctx.glBindTexture (GL_TEXTURE_2D, texture);
790 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
791 ctx.glGenFramebuffers (1, &fbo);
792 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
793 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
794 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
795 ctx.expectError (GL_NO_ERROR);
797 ctx.beginSection("GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.");
798 ctx.glDrawBuffers (2, &values[2]);
799 ctx.expectError (GL_INVALID_ENUM);
802 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to a draw framebuffer and DrawBuffers is supplied with BACK or COLOR_ATTACHMENTm where m is greater than or equal to the value of MAX_COLOR_ATTACHMENTS.");
803 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
804 ctx.glDrawBuffers (1, &values[1]);
805 ctx.expectError (GL_INVALID_OPERATION);
806 ctx.glDrawBuffers (4, &attachments[0]);
807 ctx.expectError (GL_INVALID_OPERATION);
810 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1.");
811 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
812 ctx.glDrawBuffers (2, &values[0]);
813 ctx.expectError (GL_INVALID_OPERATION);
816 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.");
817 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
818 ctx.glDrawBuffers (1, &values[2]);
819 ctx.expectError (GL_INVALID_OPERATION);
822 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.");
823 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
824 ctx.glDrawBuffers (1, &values[1]);
825 ctx.expectError (GL_INVALID_OPERATION);
826 ctx.glDrawBuffers (4, &attachments[0]);
827 ctx.expectError (GL_INVALID_OPERATION);
831 ctx.beginSection("GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.");
832 ctx.glDrawBuffers (-1, &values[1]);
833 ctx.expectError (GL_INVALID_VALUE);
834 ctx.glDrawBuffers (maxDrawBuffers+1, &values[0]);
835 ctx.expectError (GL_INVALID_VALUE);
838 ctx.glDeleteTextures(1, &texture);
839 ctx.glDeleteFramebuffers(1, &fbo);
842 void flush_mapped_buffer_range (NegativeTestContext& ctx)
844 deUint32 buf = 0x1234;
845 std::vector<GLfloat> data (32);
847 ctx.glGenBuffers (1, &buf);
848 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
849 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_STATIC_READ);
850 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
851 ctx.expectError (GL_NO_ERROR);
853 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted values.");
854 ctx.glFlushMappedBufferRange(-1, 0, 16);
855 ctx.expectError (GL_INVALID_ENUM);
858 ctx.beginSection("GL_INVALID_VALUE is generated if offset or length is negative, or if offset + length exceeds the size of the mapping.");
859 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, -1, 1);
860 ctx.expectError (GL_INVALID_VALUE);
861 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, -1);
862 ctx.expectError (GL_INVALID_VALUE);
863 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 12, 8);
864 ctx.expectError (GL_INVALID_VALUE);
865 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 24, 4);
866 ctx.expectError (GL_INVALID_VALUE);
867 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 24);
868 ctx.expectError (GL_INVALID_VALUE);
871 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
872 ctx.glBindBuffer (GL_ARRAY_BUFFER, 0);
873 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
874 ctx.expectError (GL_INVALID_OPERATION);
877 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.");
878 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
879 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
880 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
881 ctx.expectError (GL_INVALID_OPERATION);
882 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
883 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
884 ctx.expectError (GL_INVALID_OPERATION);
887 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
888 ctx.glDeleteBuffers (1, &buf);
891 void map_buffer_range (NegativeTestContext& ctx)
893 deUint32 buf = 0x1234;
894 std::vector<GLfloat> data (32);
896 ctx.glGenBuffers (1, &buf);
897 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
898 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
899 ctx.expectError (GL_NO_ERROR);
901 ctx.beginSection("GL_INVALID_VALUE is generated if either of offset or length is negative.");
902 ctx.glMapBufferRange (GL_ARRAY_BUFFER, -1, 1, GL_MAP_READ_BIT);
903 ctx.expectError (GL_INVALID_VALUE);
905 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 1, -1, GL_MAP_READ_BIT);
906 ctx.expectError (GL_INVALID_VALUE);
909 ctx.beginSection("GL_INVALID_VALUE is generated if offset + length is greater than the value of GL_BUFFER_SIZE.");
910 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 33, GL_MAP_READ_BIT);
911 ctx.expectError (GL_INVALID_VALUE);
913 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 32, 1, GL_MAP_READ_BIT);
914 ctx.expectError (GL_INVALID_VALUE);
916 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 16, 17, GL_MAP_READ_BIT);
917 ctx.expectError (GL_INVALID_VALUE);
920 ctx.beginSection("GL_INVALID_VALUE is generated if access has any bits set other than those accepted.");
921 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | 0x1000);
922 ctx.expectError (GL_INVALID_VALUE);
924 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | 0x1000);
925 ctx.expectError (GL_INVALID_VALUE);
928 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer is already in a mapped state.");
929 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
930 ctx.expectError (GL_NO_ERROR);
931 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT);
932 ctx.expectError (GL_INVALID_OPERATION);
933 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
936 ctx.beginSection("GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.");
937 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
938 ctx.expectError (GL_INVALID_OPERATION);
941 ctx.beginSection("GL_INVALID_OPERATION is generated if length is 0");
942 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 0, GL_MAP_READ_BIT);
943 ctx.expectError (GL_INVALID_OPERATION);
946 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.");
947 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
948 ctx.expectError (GL_INVALID_OPERATION);
950 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
951 ctx.expectError (GL_INVALID_OPERATION);
953 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
954 ctx.expectError (GL_INVALID_OPERATION);
957 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.");
958 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
959 ctx.expectError (GL_INVALID_OPERATION);
962 ctx.glDeleteBuffers (1, &buf);
965 void read_buffer (NegativeTestContext& ctx)
967 deUint32 fbo = 0x1234;
968 deUint32 texture = 0x1234;
969 int maxColorAttachments = 0x1234;
971 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
972 ctx.glGenTextures (1, &texture);
973 ctx.glBindTexture (GL_TEXTURE_2D, texture);
974 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
975 ctx.glGenFramebuffers (1, &fbo);
976 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
977 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
978 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
979 ctx.expectError (GL_NO_ERROR);
981 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_BACK, GL_NONE, or GL_COLOR_ATTACHMENTi.");
982 ctx.glReadBuffer (GL_NONE);
983 ctx.expectError (GL_NO_ERROR);
984 ctx.glReadBuffer (1);
985 ctx.expectError (GL_INVALID_ENUM);
986 ctx.glReadBuffer (GL_FRAMEBUFFER);
987 ctx.expectError (GL_INVALID_ENUM);
988 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0 - 1);
989 ctx.expectError (GL_INVALID_ENUM);
990 ctx.glReadBuffer (GL_FRONT);
991 ctx.expectError (GL_INVALID_ENUM);
993 // \ note Spec isn't actually clear here, but it is safe to assume that
994 // GL_DEPTH_ATTACHMENT can't be interpreted as GL_COLOR_ATTACHMENTm
995 // where m = (GL_DEPTH_ATTACHMENT - GL_COLOR_ATTACHMENT0).
996 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT);
997 ctx.expectError (GL_INVALID_ENUM);
998 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT);
999 ctx.expectError (GL_INVALID_ENUM);
1000 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT+1);
1001 ctx.expectError (GL_INVALID_ENUM);
1002 ctx.glReadBuffer (0xffffffffu);
1003 ctx.expectError (GL_INVALID_ENUM);
1006 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.");
1007 ctx.glReadBuffer (GL_BACK);
1008 ctx.expectError (GL_INVALID_OPERATION);
1009 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
1010 ctx.expectError (GL_INVALID_OPERATION);
1012 if (GL_COLOR_ATTACHMENT0+maxColorAttachments < GL_DEPTH_ATTACHMENT-1)
1014 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT - 1);
1015 ctx.expectError (GL_INVALID_OPERATION);
1020 ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK.");
1021 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1022 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0);
1023 ctx.expectError (GL_INVALID_OPERATION);
1026 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.");
1027 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1028 ctx.glReadBuffer (GL_BACK);
1029 ctx.expectError (GL_INVALID_OPERATION);
1032 ctx.glDeleteTextures(1, &texture);
1033 ctx.glDeleteFramebuffers(1, &fbo);
1036 void unmap_buffer (NegativeTestContext& ctx)
1038 deUint32 buf = 0x1234;
1039 std::vector<GLfloat> data (32);
1041 ctx.glGenBuffers (1, &buf);
1042 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
1043 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
1044 ctx.expectError (GL_NO_ERROR);
1046 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer data store is already in an unmapped state.");
1047 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
1048 ctx.expectError (GL_INVALID_OPERATION);
1051 ctx.glDeleteBuffers (1, &buf);
1053 // Framebuffer Objects
1055 void bind_framebuffer (NegativeTestContext& ctx)
1057 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER.");
1058 ctx.glBindFramebuffer(-1, 0);
1059 ctx.expectError(GL_INVALID_ENUM);
1060 ctx.glBindFramebuffer(GL_RENDERBUFFER, 0);
1061 ctx.expectError(GL_INVALID_ENUM);
1065 void bind_renderbuffer (NegativeTestContext& ctx)
1067 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1068 ctx.glBindRenderbuffer(-1, 0);
1069 ctx.expectError(GL_INVALID_ENUM);
1070 ctx.glBindRenderbuffer(GL_FRAMEBUFFER, 0);
1071 ctx.expectError(GL_INVALID_ENUM);
1075 void check_framebuffer_status (NegativeTestContext& ctx)
1077 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER..");
1078 ctx.glCheckFramebufferStatus(-1);
1079 ctx.expectError(GL_INVALID_ENUM);
1080 ctx.glCheckFramebufferStatus(GL_RENDERBUFFER);
1081 ctx.expectError(GL_INVALID_ENUM);
1085 void gen_framebuffers (NegativeTestContext& ctx)
1087 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1088 ctx.glGenFramebuffers(-1, 0);
1089 ctx.expectError(GL_INVALID_VALUE);
1093 void gen_renderbuffers (NegativeTestContext& ctx)
1095 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1096 ctx.glGenRenderbuffers(-1, 0);
1097 ctx.expectError(GL_INVALID_VALUE);
1101 void delete_framebuffers (NegativeTestContext& ctx)
1103 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1104 ctx.glDeleteFramebuffers(-1, 0);
1105 ctx.expectError(GL_INVALID_VALUE);
1109 void delete_renderbuffers (NegativeTestContext& ctx)
1111 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1112 ctx.glDeleteRenderbuffers(-1, 0);
1113 ctx.expectError(GL_INVALID_VALUE);
1117 void framebuffer_renderbuffer (NegativeTestContext& ctx)
1119 GLuint fbo = 0x1234;
1120 GLuint rbo = 0x1234;
1121 ctx.glGenFramebuffers(1, &fbo);
1122 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1123 ctx.glGenRenderbuffers(1, &rbo);
1125 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1126 ctx.glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1127 ctx.expectError(GL_INVALID_ENUM);
1130 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1131 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, -1, GL_RENDERBUFFER, 0);
1132 ctx.expectError(GL_INVALID_ENUM);
1135 ctx.beginSection("GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
1136 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1137 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
1138 ctx.expectError(GL_INVALID_ENUM);
1139 ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
1142 ctx.beginSection("GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
1143 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
1144 ctx.expectError(GL_INVALID_OPERATION);
1147 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1148 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1149 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1150 ctx.expectError(GL_INVALID_OPERATION);
1153 ctx.glDeleteRenderbuffers(1, &rbo);
1154 ctx.glDeleteFramebuffers(1, &fbo);
1157 void framebuffer_texture (NegativeTestContext& ctx)
1159 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1161 GLuint fbo = 0x1234;
1162 GLuint texture[] = {0x1234, 0x1234};
1164 ctx.glGenFramebuffers(1, &fbo);
1165 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1166 ctx.glGenTextures(2, texture);
1167 ctx.glBindTexture(GL_TEXTURE_2D, texture[0]);
1168 ctx.glBindTexture(GL_TEXTURE_BUFFER, texture[1]);
1169 ctx.expectError(GL_NO_ERROR);
1171 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1172 ctx.glFramebufferTexture(-1, GL_COLOR_ATTACHMENT0, texture[0], 0);
1173 ctx.expectError(GL_INVALID_ENUM);
1176 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1177 ctx.glFramebufferTexture(GL_FRAMEBUFFER, -1, texture[0], 0);
1178 ctx.expectError(GL_INVALID_ENUM);
1181 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1182 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0);
1183 ctx.expectError(GL_INVALID_VALUE);
1186 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1187 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1188 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0);
1189 ctx.expectError(GL_INVALID_OPERATION);
1190 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1193 ctx.beginSection("GL_INVALID_OPERATION is generated by if texture is a buffer texture.");
1194 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture[1], 0);
1195 ctx.expectError(GL_INVALID_OPERATION);
1198 ctx.glDeleteFramebuffers(1, &fbo);
1199 ctx.glDeleteBuffers(2, texture);
1203 void framebuffer_texture2d (NegativeTestContext& ctx)
1205 GLuint fbo = 0x1234;
1206 GLuint tex2D = 0x1234;
1207 GLuint texCube = 0x1234;
1208 GLuint tex2DMS = 0x1234;
1209 GLint maxTexSize = 0x1234;
1210 GLint maxTexCubeSize = 0x1234;
1211 int maxSize = 0x1234;
1213 ctx.glGenFramebuffers(1, &fbo);
1214 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1215 ctx.glGenTextures(1, &tex2D);
1216 ctx.glBindTexture(GL_TEXTURE_2D, tex2D);
1217 ctx.glGenTextures(1, &texCube);
1218 ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
1219 ctx.glGenTextures(1, &tex2DMS);
1220 ctx.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex2DMS);
1221 ctx.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
1222 ctx.glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxTexCubeSize);
1223 ctx.expectError(GL_NO_ERROR);
1225 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1226 ctx.glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1227 ctx.expectError(GL_INVALID_ENUM);
1230 ctx.beginSection("GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
1231 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
1232 ctx.expectError(GL_INVALID_ENUM);
1235 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not an accepted token.");
1236 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, -1, GL_TEXTURE_2D, tex2D, 0);
1237 ctx.expectError(GL_INVALID_ENUM);
1240 ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.");
1241 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1242 ctx.expectError(GL_INVALID_VALUE);
1243 maxSize = deLog2Floor32(maxTexSize) + 1;
1244 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize);
1245 ctx.expectError(GL_INVALID_VALUE);
1246 maxSize = deLog2Floor32(maxTexSize) + 1;
1247 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize);
1248 ctx.expectError(GL_INVALID_VALUE);
1251 ctx.beginSection("GL_INVALID_VALUE is generated if level is larger than maximum texture size.");
1252 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxTexSize + 1);
1253 ctx.expectError(GL_INVALID_VALUE);
1254 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1255 ctx.expectError(GL_INVALID_VALUE);
1256 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, maxTexCubeSize + 1);
1257 ctx.expectError(GL_INVALID_VALUE);
1258 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, -1);
1259 ctx.expectError(GL_INVALID_VALUE);
1260 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2DMS, 1);
1261 ctx.expectError(GL_INVALID_VALUE);
1264 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1265 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
1266 ctx.expectError(GL_INVALID_OPERATION);
1269 ctx.beginSection("GL_INVALID_OPERATION is generated if textarget and texture are not compatible.");
1270 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
1271 ctx.expectError(GL_INVALID_OPERATION);
1272 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2D, 0);
1273 ctx.expectError(GL_INVALID_OPERATION);
1274 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
1275 ctx.expectError(GL_INVALID_OPERATION);
1276 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2DMS, 0);
1277 ctx.expectError(GL_INVALID_OPERATION);
1278 ctx.glDeleteTextures(1, &tex2D);
1279 ctx.glDeleteTextures(1, &texCube);
1280 ctx.glDeleteTextures(1, &tex2DMS);
1283 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1284 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1285 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1286 ctx.expectError(GL_INVALID_OPERATION);
1289 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1291 GLuint texBuf = 0x1234;
1292 ctx.beginSection("GL_INVALID_OPERATION error is generated if texture is the name of a buffer texture.");
1293 ctx.glGenTextures(1, &texBuf);
1294 ctx.glBindTexture(GL_TEXTURE_BUFFER, texBuf);
1295 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1296 ctx.expectError(GL_NO_ERROR);
1297 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texBuf, 0);
1298 ctx.expectError(GL_INVALID_OPERATION);
1302 ctx.glDeleteFramebuffers(1, &fbo);
1305 void renderbuffer_storage (NegativeTestContext& ctx)
1307 deUint32 rbo = 0x1234;
1308 GLint maxSize = 0x1234;
1310 ctx.glGenRenderbuffers (1, &rbo);
1311 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1313 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1314 ctx.glRenderbufferStorage (-1, GL_RGBA4, 1, 1);
1315 ctx.expectError (GL_INVALID_ENUM);
1316 ctx.glRenderbufferStorage (GL_FRAMEBUFFER, GL_RGBA4, 1, 1);
1317 ctx.expectError (GL_INVALID_ENUM);
1320 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1321 ctx.glRenderbufferStorage (GL_RENDERBUFFER, -1, 1, 1);
1322 ctx.expectError (GL_INVALID_ENUM);
1324 if (!ctx.isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1326 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGB16F, 1, 1);
1327 ctx.expectError (GL_INVALID_ENUM);
1330 if (!ctx.isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1332 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8_SNORM, 1, 1);
1333 ctx.expectError (GL_INVALID_ENUM);
1338 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1339 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, 1);
1340 ctx.expectError (GL_INVALID_VALUE);
1341 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, -1);
1342 ctx.expectError (GL_INVALID_VALUE);
1343 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, -1);
1344 ctx.expectError (GL_INVALID_VALUE);
1347 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1348 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1349 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
1350 ctx.expectError (GL_INVALID_VALUE);
1351 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
1352 ctx.expectError (GL_INVALID_VALUE);
1353 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
1354 ctx.expectError (GL_INVALID_VALUE);
1357 ctx.glDeleteRenderbuffers(1, &rbo);
1360 void blit_framebuffer (NegativeTestContext& ctx)
1364 deUint32 texture[2];
1365 deUint32 blankFrameBuffer;
1367 ctx.glGenFramebuffers (1, &blankFrameBuffer);
1368 ctx.glGenFramebuffers (2, fbo);
1369 ctx.glGenTextures (2, texture);
1370 ctx.glGenRenderbuffers (2, rbo);
1372 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1373 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1374 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1376 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1377 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1378 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1379 ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1380 ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1382 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1383 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
1384 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1386 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1387 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1388 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1389 ctx.glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1390 ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1391 ctx.expectError (GL_NO_ERROR);
1393 ctx.beginSection("GL_INVALID_VALUE is generated if mask contains any bits other than GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, or GL_STENCIL_BUFFER_BIT.");
1394 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 1, GL_NEAREST);
1395 ctx.expectError (GL_INVALID_VALUE);
1398 ctx.beginSection("GL_INVALID_ENUM is generated if filter is not GL_LINEAR or GL_NEAREST.");
1399 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, 0);
1400 ctx.expectError (GL_INVALID_ENUM);
1403 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.");
1404 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1405 ctx.expectError (GL_INVALID_OPERATION);
1406 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_LINEAR);
1407 ctx.expectError (GL_INVALID_OPERATION);
1408 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1409 ctx.expectError (GL_INVALID_OPERATION);
1412 ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format.");
1413 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1415 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1416 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1417 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32UI, draw buffer: GL_RGBA" << TestLog::EndMessage;
1418 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1419 ctx.expectError (GL_INVALID_OPERATION);
1421 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1422 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1423 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA" << TestLog::EndMessage;
1424 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1425 ctx.expectError (GL_INVALID_OPERATION);
1427 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1428 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1429 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1430 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1431 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1432 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA8, draw buffer: GL_RGBA32I" << TestLog::EndMessage;
1433 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1434 ctx.expectError (GL_INVALID_OPERATION);
1437 ctx.beginSection("GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.");
1438 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1439 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1440 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1441 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1442 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1443 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage;
1444 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR);
1445 ctx.expectError (GL_INVALID_OPERATION);
1448 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.");
1449 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1450 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32);
1451 ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1452 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1453 ctx.expectError (GL_INVALID_OPERATION);
1454 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1455 ctx.expectError (GL_INVALID_OPERATION);
1458 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the read or draw framebuffer is not framebuffer complete.");
1459 ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1460 ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1461 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1462 ctx.expectError (GL_NO_ERROR);
1463 ctx.getLog() << TestLog::Message << "// incomplete read framebuffer" << TestLog::EndMessage;
1464 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, blankFrameBuffer);
1465 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1466 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1467 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1468 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1469 ctx.expectError (GL_INVALID_FRAMEBUFFER_OPERATION);
1470 ctx.getLog() << TestLog::Message << "// incomplete draw framebuffer" << TestLog::EndMessage;
1471 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[1]);
1472 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1473 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1474 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1475 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1476 ctx.expectError (GL_INVALID_FRAMEBUFFER_OPERATION);
1477 ctx.getLog() << TestLog::Message << "// incomplete read and draw framebuffer" << TestLog::EndMessage;
1478 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, blankFrameBuffer);
1479 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1480 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1481 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1482 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1483 ctx.expectError (GL_INVALID_FRAMEBUFFER_OPERATION);
1485 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1486 ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1487 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1488 ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1491 ctx.beginSection("GL_INVALID_OPERATION is generated if the source and destination buffers are identical.");
1492 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[0]);
1493 ctx.expectError (GL_NO_ERROR);
1494 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1495 ctx.expectError (GL_INVALID_OPERATION);
1497 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1500 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1501 ctx.glBindRenderbuffer (GL_RENDERBUFFER, 0);
1502 ctx.glDeleteFramebuffers (2, fbo);
1503 ctx.glDeleteFramebuffers (1, &blankFrameBuffer);
1504 ctx.glDeleteTextures (2, texture);
1505 ctx.glDeleteRenderbuffers (2, rbo);
1508 void blit_framebuffer_multisample (NegativeTestContext& ctx)
1513 ctx.glGenFramebuffers (2, fbo);
1514 ctx.glGenRenderbuffers (2, rbo);
1516 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1517 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1518 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1519 ctx.glFramebufferRenderbuffer (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
1520 ctx.glCheckFramebufferStatus (GL_READ_FRAMEBUFFER);
1522 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
1523 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1525 ctx.expectError (GL_NO_ERROR);
1527 if (!ctx.isExtensionSupported("GL_NV_framebuffer_multisample"))
1529 ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_SAMPLE_BUFFERS for the draw buffer is greater than zero.");
1530 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1531 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1532 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1533 ctx.expectError (GL_INVALID_OPERATION);
1536 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.");
1537 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 32, 32);
1538 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1539 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1540 ctx.expectError (GL_INVALID_OPERATION);
1543 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.");
1544 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1545 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1546 ctx.glBlitFramebuffer (0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1547 ctx.expectError (GL_INVALID_OPERATION);
1551 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1552 ctx.glDeleteRenderbuffers (2, rbo);
1553 ctx.glDeleteFramebuffers (2, fbo);
1556 void framebuffer_texture_layer (NegativeTestContext& ctx)
1558 deUint32 fbo = 0x1234;
1559 deUint32 tex3D = 0x1234;
1560 deUint32 tex2DArray = 0x1234;
1561 deUint32 tex2D = 0x1234;
1562 deUint32 tex2DMSArray = 0x1234;
1563 deUint32 texBuffer = 0x1234;
1564 int max3DTexSize = 0x1234;
1565 int maxTexSize = 0x1234;
1566 int maxArrayTexLayers = 0x1234;
1567 int log2Max3DTexSize = 0x1234;
1568 int log2MaxTexSize = 0x1234;
1570 ctx.glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize);
1571 ctx.glGetIntegerv (GL_MAX_TEXTURE_SIZE, &maxTexSize);
1572 ctx.glGetIntegerv (GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers);
1574 ctx.glGenFramebuffers (1, &fbo);
1575 ctx.glGenTextures (1, &tex3D);
1576 ctx.glGenTextures (1, &tex2DArray);
1577 ctx.glGenTextures (1, &tex2D);
1578 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1580 ctx.glBindTexture (GL_TEXTURE_3D, tex3D);
1581 ctx.glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1582 ctx.glBindTexture (GL_TEXTURE_2D_ARRAY, tex2DArray);
1583 ctx.glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1584 ctx.glBindTexture (GL_TEXTURE_2D, tex2D);
1585 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1587 ctx.expectError (GL_NO_ERROR);
1589 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1590 ctx.glFramebufferTextureLayer (-1, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1591 ctx.expectError (GL_INVALID_ENUM);
1592 ctx.glFramebufferTextureLayer (GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1593 ctx.expectError (GL_INVALID_ENUM);
1596 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1597 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, -1, tex3D, 0, 1);
1598 ctx.expectError (GL_INVALID_ENUM);
1599 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1);
1600 ctx.expectError (GL_INVALID_ENUM);
1603 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is non-zero and not the name of a 3D texture or 2D array texture, 2D multisample array texture or cube map array texture.");
1604 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0);
1605 ctx.expectError (GL_INVALID_OPERATION);
1606 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0);
1607 ctx.expectError (GL_INVALID_OPERATION);
1610 ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is negative.");
1611 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1);
1612 ctx.expectError (GL_INVALID_VALUE);
1615 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.");
1616 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
1617 ctx.expectError (GL_INVALID_VALUE);
1620 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.");
1621 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
1622 ctx.expectError (GL_INVALID_VALUE);
1625 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1626 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1627 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1628 ctx.expectError (GL_INVALID_OPERATION);
1629 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1632 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 3D texture and level is less than 0 or greater than log2 of the value of GL_MAX_3D_TEXTURE_SIZE.");
1633 log2Max3DTexSize = deLog2Floor32(max3DTexSize);
1634 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, -1, max3DTexSize - 1);
1635 ctx.expectError (GL_INVALID_VALUE);
1636 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, log2Max3DTexSize + 1, max3DTexSize - 1);
1637 ctx.expectError (GL_INVALID_VALUE);
1640 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D array texture and level is less than 0 or greater than log2 of the value of GL_MAX_TEXTURE_SIZE.");
1641 log2MaxTexSize = deLog2Floor32(maxTexSize);
1642 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, -1, maxArrayTexLayers - 1);
1643 ctx.expectError (GL_INVALID_VALUE);
1644 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, log2MaxTexSize + 1, maxArrayTexLayers - 1);
1645 ctx.expectError (GL_INVALID_VALUE);
1648 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1650 deUint32 texCubeArray = 0x1234;
1651 int maxCubeTexSize = 0x1234;
1652 ctx.glGetIntegerv (GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxCubeTexSize);
1653 ctx.glGenTextures (1, &tex2DMSArray);
1654 ctx.glGenTextures (1, &texCubeArray);
1655 ctx.glGenTextures (1, &texBuffer);
1656 ctx.glBindTexture (GL_TEXTURE_2D_MULTISAMPLE_ARRAY, tex2DMSArray);
1657 ctx.glBindTexture (GL_TEXTURE_CUBE_MAP_ARRAY, texCubeArray);
1658 ctx.glBindTexture (GL_TEXTURE_BUFFER, texBuffer);
1659 ctx.expectError (GL_NO_ERROR);
1661 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D multisample array texture and level is not 0.");
1662 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, -1, 0);
1663 ctx.expectError (GL_INVALID_VALUE);
1664 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, 1, 0);
1665 ctx.expectError (GL_INVALID_VALUE);
1668 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a cube map array texture and layer is larger than MAX_ARRAY_TEXTURE_LAYERS-1. (See Khronos bug 15968)");
1669 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texCubeArray, 0, maxArrayTexLayers);
1670 ctx.expectError (GL_INVALID_VALUE);
1673 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is the name of a buffer texture.");
1674 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texBuffer, 0, 0);
1675 ctx.expectError (GL_INVALID_OPERATION);
1678 ctx.glDeleteTextures (1, &tex2DMSArray);
1679 ctx.glDeleteTextures (1, &texCubeArray);
1680 ctx.glDeleteTextures (1, &texBuffer);
1683 ctx.glDeleteTextures (1, &tex3D);
1684 ctx.glDeleteTextures (1, &tex2DArray);
1685 ctx.glDeleteTextures (1, &tex2D);
1686 ctx.glDeleteFramebuffers (1, &fbo);
1689 void invalidate_framebuffer (NegativeTestContext& ctx)
1691 deUint32 attachments[3];
1692 deUint32 fbo = 0x1234;
1693 deUint32 texture = 0x1234;
1694 int maxColorAttachments = 0x1234;
1696 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1697 attachments[0] = GL_COLOR_ATTACHMENT0;
1698 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1699 attachments[2] = GL_DEPTH_STENCIL_ATTACHMENT;
1701 ctx.glGenFramebuffers (1, &fbo);
1702 ctx.glGenTextures (1, &texture);
1703 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1704 ctx.glBindTexture (GL_TEXTURE_2D, texture);
1705 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1706 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1707 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
1708 ctx.expectError (GL_NO_ERROR);
1710 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1711 ctx.glInvalidateFramebuffer (-1, 1, &attachments[0]);
1712 ctx.expectError (GL_INVALID_ENUM);
1713 ctx.glInvalidateFramebuffer (GL_BACK, 1, &attachments[0]);
1714 ctx.expectError (GL_INVALID_ENUM);
1717 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.");
1718 ctx.glInvalidateFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1]);
1719 ctx.expectError (GL_INVALID_OPERATION);
1722 ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments is negative.");
1723 ctx.glInvalidateFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0]);
1724 ctx.expectError (GL_INVALID_VALUE);
1727 ctx.beginSection("GL_INVALID_ENUM is generated if the default framebuffer is bound to target and any elements of attachments are not one of the accepted attachments.");
1728 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1729 ctx.glInvalidateFramebuffer (GL_FRAMEBUFFER, 1, &attachments[2]);
1730 ctx.expectError (GL_INVALID_ENUM);
1734 ctx.glDeleteTextures (1, &texture);
1735 ctx.glDeleteFramebuffers (1, &fbo);
1738 void invalidate_sub_framebuffer (NegativeTestContext& ctx)
1740 deUint32 attachments[3];
1741 deUint32 fbo = 0x1234;
1742 deUint32 texture = 0x1234;
1743 int maxColorAttachments = 0x1234;
1745 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1746 attachments[0] = GL_COLOR_ATTACHMENT0;
1747 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1748 attachments[2] = GL_DEPTH_STENCIL_ATTACHMENT;
1750 ctx.glGenFramebuffers (1, &fbo);
1751 ctx.glGenTextures (1, &texture);
1752 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1753 ctx.glBindTexture (GL_TEXTURE_2D, texture);
1754 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1755 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1756 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
1757 ctx.expectError (GL_NO_ERROR);
1759 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1760 ctx.glInvalidateSubFramebuffer (-1, 1, &attachments[0], 0, 0, 16, 16);
1761 ctx.expectError (GL_INVALID_ENUM);
1762 ctx.glInvalidateSubFramebuffer (GL_BACK, 1, &attachments[0], 0, 0, 16, 16);
1763 ctx.expectError (GL_INVALID_ENUM);
1766 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.");
1767 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16);
1768 ctx.expectError (GL_INVALID_OPERATION);
1771 ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments, width, or heigh is negative.");
1772 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, 16);
1773 ctx.expectError (GL_INVALID_VALUE);
1774 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, 16);
1775 ctx.expectError (GL_INVALID_VALUE);
1776 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, -1);
1777 ctx.expectError (GL_INVALID_VALUE);
1778 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, -1);
1779 ctx.expectError (GL_INVALID_VALUE);
1780 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, 16);
1781 ctx.expectError (GL_INVALID_VALUE);
1782 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, 16, -1);
1783 ctx.expectError (GL_INVALID_VALUE);
1784 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, -1);
1785 ctx.expectError (GL_INVALID_VALUE);
1788 ctx.beginSection("GL_INVALID_ENUM is generated if the default framebuffer is bound to target and any elements of attachments are not one of the accepted attachments.");
1789 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1790 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[2], 0, 0, 16, 16);
1791 ctx.expectError (GL_INVALID_ENUM);
1794 ctx.glDeleteTextures (1, &texture);
1795 ctx.glDeleteFramebuffers (1, &fbo);
1798 void renderbuffer_storage_multisample (NegativeTestContext& ctx)
1800 deUint32 rbo = 0x1234;
1801 int maxSamplesSupportedRGBA4 = -1;
1802 int maxSamplesSupportedRGBA8UI = -1;
1803 GLint maxSize = 0x1234;
1805 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, 1, &maxSamplesSupportedRGBA4);
1806 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8UI, GL_SAMPLES, 1, &maxSamplesSupportedRGBA8UI);
1808 ctx.glGenRenderbuffers (1, &rbo);
1809 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1811 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1812 ctx.glRenderbufferStorageMultisample (-1, 2, GL_RGBA4, 1, 1);
1813 ctx.expectError (GL_INVALID_ENUM);
1814 ctx.glRenderbufferStorageMultisample (GL_FRAMEBUFFER, 2, GL_RGBA4, 1, 1);
1815 ctx.expectError (GL_INVALID_ENUM);
1818 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.");
1819 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA4+1, GL_RGBA4, 1, 1);
1820 ctx.expectError (GL_INVALID_OPERATION);
1823 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1824 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, -1, 1, 1);
1825 ctx.expectError (GL_INVALID_ENUM);
1827 if (!ctx.isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1829 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGB16F, 1, 1);
1830 ctx.expectError (GL_INVALID_ENUM);
1833 if (!ctx.isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1835 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA8_SNORM, 1, 1);
1836 ctx.expectError (GL_INVALID_ENUM);
1841 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat. (Unsigned integer format)");
1842 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA8UI+1, GL_RGBA8UI, 1, 1);
1843 ctx.expectError (GL_INVALID_OPERATION);
1846 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1847 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, 1);
1848 ctx.expectError (GL_INVALID_VALUE);
1849 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, 1, -1);
1850 ctx.expectError (GL_INVALID_VALUE);
1851 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, -1);
1852 ctx.expectError (GL_INVALID_VALUE);
1853 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, -1, GL_RGBA4, 1, 1);
1854 ctx.expectError (GL_INVALID_VALUE);
1855 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, -1, GL_RGBA4, -1, 1);
1856 ctx.expectError (GL_INVALID_VALUE);
1857 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, -1, GL_RGBA4, 1, -1);
1858 ctx.expectError (GL_INVALID_VALUE);
1859 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, -1, GL_RGBA4, -1, -1);
1860 ctx.expectError (GL_INVALID_VALUE);
1863 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1864 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1865 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, 1, maxSize+1);
1866 ctx.expectError (GL_INVALID_VALUE);
1867 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, 1);
1868 ctx.expectError (GL_INVALID_VALUE);
1869 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, maxSize+1);
1870 ctx.expectError (GL_INVALID_VALUE);
1873 ctx.glDeleteRenderbuffers(1, &rbo);
1876 void copy_image_sub_data (NegativeTestContext& ctx)
1878 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1880 deUint32 texture[5];
1881 deUint32 rbo = 0x1234;
1883 ctx.glGenTextures (5, texture);
1884 ctx.glGenRenderbuffers (1, &rbo);
1885 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1887 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1888 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1889 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1890 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1891 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1892 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1893 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1894 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1895 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1896 ctx.expectError (GL_NO_ERROR);
1898 ctx.glBindTexture (GL_TEXTURE_3D, texture[2]);
1899 ctx.glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1900 ctx.glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1901 ctx.glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA8, 32, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1902 ctx.expectError (GL_NO_ERROR);
1904 ctx.glBindTexture (GL_TEXTURE_3D, texture[3]);
1905 ctx.glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA8, 32, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1906 ctx.expectError (GL_NO_ERROR);
1908 ctx.glBindTexture (GL_TEXTURE_2D, texture[4]);
1909 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1910 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1911 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
1912 ctx.expectError (GL_NO_ERROR);
1914 ctx.beginSection("GL_INVALID_VALUE is generated if srcWidth, srcHeight, or srcDepth is negative.");
1915 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, 1, 1);
1916 ctx.expectError (GL_INVALID_VALUE);
1917 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, -1, 1);
1918 ctx.expectError (GL_INVALID_VALUE);
1919 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, 1, -1);
1920 ctx.expectError (GL_INVALID_VALUE);
1921 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, -1, 1);
1922 ctx.expectError (GL_INVALID_VALUE);
1923 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, 1, -1);
1924 ctx.expectError (GL_INVALID_VALUE);
1925 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, -1, -1);
1926 ctx.expectError (GL_INVALID_VALUE);
1927 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, -1, -1);
1928 ctx.expectError (GL_INVALID_VALUE);
1931 ctx.beginSection("GL_INVALID_VALUE is generated if srcLevel and dstLevel are not valid levels for the corresponding images.");
1932 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1933 ctx.expectError (GL_INVALID_VALUE);
1934 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 1, 0, 0, 0, 0, 0, 1);
1935 ctx.expectError (GL_INVALID_VALUE);
1936 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 1, 0, 0, 0, 0, 0, 1);
1937 ctx.expectError (GL_INVALID_VALUE);
1938 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1939 ctx.expectError (GL_INVALID_VALUE);
1940 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, -1, 0, 0, 0, 0, 0, 1);
1941 ctx.expectError (GL_INVALID_VALUE);
1942 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, -1, 0, 0, 0, 0, 0, 1);
1943 ctx.expectError (GL_INVALID_VALUE);
1944 ctx.glCopyImageSubData (rbo, GL_RENDERBUFFER, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1945 ctx.expectError (GL_INVALID_VALUE);
1946 ctx.glCopyImageSubData (rbo, GL_RENDERBUFFER, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1947 ctx.expectError (GL_INVALID_VALUE);
1948 ctx.glCopyImageSubData (texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, rbo, GL_RENDERBUFFER, -1, 0, 0, 0, 0, 0, 1);
1949 ctx.expectError (GL_INVALID_VALUE);
1950 ctx.glCopyImageSubData (texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, rbo, GL_RENDERBUFFER, 1, 0, 0, 0, 0, 0, 1);
1951 ctx.expectError (GL_INVALID_VALUE);
1954 ctx.beginSection("GL_INVALID_ENUM is generated if either target does not match the type of the object.");
1955 // \note: This could be either:
1956 // 1. GL_INVALID_ENUM is generated if either target does not match the type of the object.
1957 // 2. GL_INVALID_VALUE is generated if either name does not correspond to a valid renderbuffer or texture object according to the corresponding target parameter.
1958 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1959 ctx.expectError (GL_INVALID_ENUM);
1960 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[2], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1961 ctx.expectError (GL_INVALID_ENUM);
1962 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_3D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1963 ctx.expectError (GL_INVALID_ENUM);
1964 ctx.glCopyImageSubData (texture[2], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1965 ctx.expectError (GL_INVALID_ENUM);
1968 ctx.beginSection("GL_INVALID_OPERATION is generated if either object is a texture and the texture is not complete.");
1969 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1970 ctx.expectError (GL_INVALID_OPERATION);
1971 ctx.glCopyImageSubData (texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1972 ctx.expectError (GL_INVALID_OPERATION);
1973 ctx.glCopyImageSubData (texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1974 ctx.expectError (GL_INVALID_OPERATION);
1977 ctx.beginSection("GL_INVALID_VALUE is generated if the dimensions of either subregion exceeds the boundaries of the corresponding image object.");
1978 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 33, 0, 1);
1979 ctx.expectError (GL_INVALID_VALUE);
1980 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 33, 1);
1981 ctx.expectError (GL_INVALID_VALUE);
1984 ctx.beginSection("GL_INVALID_OPERATION error is generated if the source and destination internal formats are not compatible.");
1985 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[4], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1986 ctx.expectError (GL_INVALID_OPERATION);
1987 ctx.glCopyImageSubData (texture[4], GL_TEXTURE_2D, 0, 0, 0, 0, texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1988 ctx.expectError (GL_INVALID_OPERATION);
1991 ctx.glDeleteTextures (5, texture);
1992 ctx.glDeleteRenderbuffers (1, &rbo);
1996 std::vector<FunctionContainer> getNegativeBufferApiTestFunctions ()
1998 const FunctionContainer funcs[] =
2000 {bind_buffer, "bind_buffer", "Invalid glBindBuffer() usage" },
2001 {delete_buffers, "delete_buffers", "Invalid glDeleteBuffers() usage" },
2002 {gen_buffers, "gen_buffers", "Invalid glGenBuffers() usage" },
2003 {buffer_data, "buffer_data", "Invalid glBufferData() usage" },
2004 {buffer_sub_data, "buffer_sub_data", "Invalid glBufferSubData() usage" },
2005 {buffer_sub_data_size_offset, "buffer_sub_data_size_offset", "Invalid glBufferSubData() usage" },
2006 {clear, "clear", "Invalid glClear() usage" },
2007 {read_pixels, "read_pixels", "Invalid glReadPixels() usage" },
2008 {readn_pixels, "readn_pixels", "Invalid glReadPixels() usage" },
2009 {read_pixels_format_mismatch, "read_pixels_format_mismatch", "Invalid glReadPixels() usage" },
2010 {read_pixels_fbo_format_mismatch, "read_pixels_fbo_format_mismatch", "Invalid glReadPixels() usage" },
2011 {bind_buffer_range, "bind_buffer_range", "Invalid glBindBufferRange() usage" },
2012 {bind_buffer_base, "bind_buffer_base", "Invalid glBindBufferBase() usage" },
2013 {clear_bufferiv, "clear_bufferiv", "Invalid glClearBufferiv() usage" },
2014 {clear_bufferuiv, "clear_bufferuiv", "Invalid glClearBufferuiv() usage" },
2015 {clear_bufferfv, "clear_bufferfv", "Invalid glClearBufferfv() usage" },
2016 {clear_bufferfi, "clear_bufferfi", "Invalid glClearBufferfi() usage" },
2017 {copy_buffer_sub_data, "copy_buffer_sub_data", "Invalid glCopyBufferSubData() usage" },
2018 {draw_buffers, "draw_buffers", "Invalid glDrawBuffers() usage" },
2019 {flush_mapped_buffer_range, "flush_mapped_buffer_range", "Invalid glFlushMappedBufferRange() usage" },
2020 {map_buffer_range, "map_buffer_range", "Invalid glMapBufferRange() usage" },
2021 {read_buffer, "read_buffer", "Invalid glReadBuffer() usage" },
2022 {unmap_buffer, "unmap_buffer", "Invalid glUnmapBuffer() usage" },
2023 {bind_framebuffer, "bind_framebuffer", "Invalid glBindFramebuffer() usage" },
2024 {bind_renderbuffer, "bind_renderbuffer", "Invalid glBindRenderbuffer() usage" },
2025 {check_framebuffer_status, "check_framebuffer_status", "Invalid glCheckFramebufferStatus() usage" },
2026 {gen_framebuffers, "gen_framebuffers", "Invalid glGenFramebuffers() usage" },
2027 {gen_renderbuffers, "gen_renderbuffers", "Invalid glGenRenderbuffers() usage" },
2028 {delete_framebuffers, "delete_framebuffers", "Invalid glDeleteFramebuffers() usage" },
2029 {delete_renderbuffers, "delete_renderbuffers", "Invalid glDeleteRenderbuffers() usage" },
2030 {framebuffer_renderbuffer, "framebuffer_renderbuffer", "Invalid glFramebufferRenderbuffer() usage" },
2031 {framebuffer_texture, "framebuffer_texture", "Invalid glFramebufferTexture() usage" },
2032 {framebuffer_texture2d, "framebuffer_texture2d", "Invalid glFramebufferTexture2D() usage" },
2033 {renderbuffer_storage, "renderbuffer_storage", "Invalid glRenderbufferStorage() usage" },
2034 {blit_framebuffer, "blit_framebuffer", "Invalid glBlitFramebuffer() usage" },
2035 {blit_framebuffer_multisample, "blit_framebuffer_multisample", "Invalid glBlitFramebuffer() usage" },
2036 {framebuffer_texture_layer, "framebuffer_texture_layer", "Invalid glFramebufferTextureLayer() usage" },
2037 {invalidate_framebuffer, "invalidate_framebuffer", "Invalid glInvalidateFramebuffer() usage" },
2038 {invalidate_sub_framebuffer, "invalidate_sub_framebuffer", "Invalid glInvalidateSubFramebuffer() usage" },
2039 {renderbuffer_storage_multisample, "renderbuffer_storage_multisample", "Invalid glRenderbufferStorageMultisample() usage" },
2040 {copy_image_sub_data, "copy_image_sub_data", "Invalid glCopyImageSubData() usage" },
2043 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
2046 } // NegativeTestShared