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 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
313 ctx.expectError (GL_NO_ERROR);
314 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
315 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
316 ctx.expectError (GL_NO_ERROR);
317 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_INT, &floatData[0]);
318 ctx.expectError (GL_INVALID_OPERATION);
322 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.");
325 int sampleBuffers = 0x1234;
326 deUint32 rbo = 0x1234;
328 ctx.glGenRenderbuffers(1, &rbo);
329 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
330 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
331 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
333 ctx.glGetIntegerv (GL_READ_FRAMEBUFFER_BINDING, &binding);
334 ctx.getLog() << TestLog::Message << "// GL_READ_FRAMEBUFFER_BINDING: " << binding << TestLog::EndMessage;
335 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
336 ctx.glGetIntegerv (GL_SAMPLE_BUFFERS, &sampleBuffers);
337 ctx.getLog() << TestLog::Message << "// GL_SAMPLE_BUFFERS: " << sampleBuffers << TestLog::EndMessage;
338 ctx.expectError (GL_NO_ERROR);
340 if (binding == 0 || sampleBuffers <= 0)
342 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;
343 ctx.fail("Got invalid value");
347 ctx.glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
348 ctx.expectError (GL_INVALID_OPERATION);
353 ctx.glBindRenderbuffer (GL_RENDERBUFFER, 0);
354 ctx.glBindTexture (GL_TEXTURE_2D, 0);
355 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
356 ctx.glDeleteFramebuffers (1, &fbo);
357 ctx.glDeleteTextures (1, &texture);
358 ctx.glDeleteRenderbuffers (1, &rbo);
361 void bind_buffer_range (NegativeTestContext& ctx)
363 deUint32 bufAC = 0x1234;
364 deUint32 bufU = 0x1234;
365 deUint32 bufTF = 0x1234;
366 int maxTFSize = 0x1234;
367 int maxUSize = 0x1234;
368 int uAlignment = 0x1234;
370 ctx.glGenBuffers(1, &bufU);
371 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
372 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
374 ctx.glGenBuffers(1, &bufTF);
375 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
376 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
378 ctx.glGenBuffers(1, &bufAC);
379 ctx.glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bufAC);
380 ctx.glBufferData(GL_ATOMIC_COUNTER_BUFFER, 16, NULL, GL_STREAM_DRAW);
382 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.");
383 ctx.glBindBufferRange(GL_ARRAY_BUFFER, 0, bufU, 0, 4);
384 ctx.expectError(GL_INVALID_ENUM);
387 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.");
388 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
389 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4);
390 ctx.expectError(GL_INVALID_VALUE);
393 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.");
394 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
395 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4);
396 ctx.expectError(GL_INVALID_VALUE);
399 ctx.beginSection("GL_INVALID_VALUE is generated if size is less than or equal to zero.");
400 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1);
401 ctx.expectError(GL_INVALID_VALUE);
402 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0);
403 ctx.expectError(GL_INVALID_VALUE);
406 ctx.beginSection("GL_INVALID_VALUE is generated if offset is less than zero.");
407 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, -1, 0);
408 ctx.expectError(GL_INVALID_VALUE);
411 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4.");
412 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5);
413 ctx.expectError(GL_INVALID_VALUE);
414 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4);
415 ctx.expectError(GL_INVALID_VALUE);
416 ctx.glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7);
417 ctx.expectError(GL_INVALID_VALUE);
420 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.");
421 ctx.glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uAlignment);
422 ctx.glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, uAlignment+1, 4);
423 ctx.expectError(GL_INVALID_VALUE);
426 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
428 int maxACize = 0x1234;
429 int maxSSize = 0x1234;
430 int ssAlignment = 0x1234;
432 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.");
433 ctx.glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &maxACize);
434 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, maxACize, bufU, 0, 4);
435 ctx.expectError(GL_INVALID_VALUE);
438 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.");
439 ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxSSize);
440 ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, maxSSize, bufU, 0, 4);
441 ctx.expectError(GL_INVALID_VALUE);
444 ctx.beginSection("GL_INVALID_VALUE is generated if target is GL_ATOMIC_COUNTER_BUFFER and offset is not multiples of 4.");
445 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, bufTF, 5, 0);
446 ctx.expectError(GL_INVALID_VALUE);
449 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.");
450 ctx.glGetIntegerv(GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, &ssAlignment);
451 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, bufTF, ssAlignment+1, 0);
452 ctx.expectError(GL_INVALID_VALUE);
456 ctx.glDeleteBuffers(1, &bufU);
457 ctx.glDeleteBuffers(1, &bufTF);
458 ctx.glDeleteBuffers(1, &bufAC);
461 void bind_buffer_base (NegativeTestContext& ctx)
463 deUint32 bufU = 0x1234;
464 deUint32 bufTF = 0x1234;
465 int maxUSize = 0x1234;
466 int maxTFSize = 0x1234;
468 ctx.glGenBuffers(1, &bufU);
469 ctx.glBindBuffer(GL_UNIFORM_BUFFER, bufU);
470 ctx.glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW);
472 ctx.glGenBuffers(1, &bufTF);
473 ctx.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF);
474 ctx.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW);
475 ctx.expectError(GL_NO_ERROR);
477 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.");
478 ctx.glBindBufferBase(-1, 0, bufU);
479 ctx.expectError(GL_INVALID_ENUM);
480 ctx.glBindBufferBase(GL_ARRAY_BUFFER, 0, bufU);
481 ctx.expectError(GL_INVALID_ENUM);
484 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.");
485 ctx.glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize);
486 ctx.glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU);
487 ctx.expectError(GL_INVALID_VALUE);
490 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.");
491 ctx.glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize);
492 ctx.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF);
493 ctx.expectError(GL_INVALID_VALUE);
496 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
498 int maxACize = 0x1234;
499 int maxSSize = 0x1234;
501 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.");
502 ctx.glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, &maxACize);
503 ctx.glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, maxACize, bufU, 0, 4);
504 ctx.expectError(GL_INVALID_VALUE);
507 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.");
508 ctx.glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &maxSSize);
509 ctx.glBindBufferRange(GL_SHADER_STORAGE_BUFFER, maxSSize, bufU, 0, 4);
510 ctx.expectError(GL_INVALID_VALUE);
514 ctx.glDeleteBuffers(1, &bufU);
515 ctx.glDeleteBuffers(1, &bufTF);
518 void clear_bufferiv (NegativeTestContext& ctx)
520 std::vector<int> data (32*32);
521 deUint32 fbo = 0x1234;
522 deUint32 texture = 0x1234;
523 int maxDrawBuffers = 0x1234;
525 ctx.glGenTextures (1, &texture);
526 ctx.glBindTexture (GL_TEXTURE_2D, texture);
527 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
528 ctx.glGenFramebuffers (1, &fbo);
529 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
530 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
531 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
532 ctx.expectError (GL_NO_ERROR);
534 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not an accepted value.");
535 ctx.glClearBufferiv (-1, 0, &data[0]);
536 ctx.expectError (GL_INVALID_ENUM);
537 ctx.glClearBufferiv (GL_FRAMEBUFFER, 0, &data[0]);
538 ctx.expectError (GL_INVALID_ENUM);
541 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL.");
542 ctx.glClearBufferiv (GL_DEPTH, 1, &data[0]);
543 ctx.expectError (GL_INVALID_ENUM);
544 ctx.glClearBufferiv (GL_DEPTH_STENCIL, 1, &data[0]);
545 ctx.expectError (GL_INVALID_ENUM);
548 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.");
549 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
550 ctx.glClearBufferiv (GL_COLOR, maxDrawBuffers, &data[0]);
551 ctx.expectError (GL_INVALID_VALUE);
554 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR or GL_STENCIL and drawBuffer is negative.");
555 ctx.glClearBufferiv (GL_COLOR, -1, &data[0]);
556 ctx.expectError (GL_INVALID_VALUE);
559 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero.");
560 ctx.glClearBufferiv (GL_STENCIL, 1, &data[0]);
561 ctx.expectError (GL_INVALID_VALUE);
564 ctx.glDeleteFramebuffers (1, &fbo);
565 ctx.glDeleteTextures (1, &texture);
568 void clear_bufferuiv (NegativeTestContext& ctx)
570 std::vector<deUint32> data (32*32);
571 deUint32 fbo = 0x1234;
572 deUint32 texture = 0x1234;
573 int maxDrawBuffers = 0x1234;
575 ctx.glGenTextures (1, &texture);
576 ctx.glBindTexture (GL_TEXTURE_2D, texture);
577 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
578 ctx.glGenFramebuffers (1, &fbo);
579 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
580 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
581 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
582 ctx.expectError (GL_NO_ERROR);
584 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR.");
585 ctx.glClearBufferuiv (-1, 0, &data[0]);
586 ctx.expectError (GL_INVALID_ENUM);
587 ctx.glClearBufferuiv (GL_FRAMEBUFFER, 0, &data[0]);
588 ctx.expectError (GL_INVALID_ENUM);
591 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL, or GL_DEPTH_STENCIL.");
592 ctx.glClearBufferuiv (GL_DEPTH, 0, &data[0]);
593 ctx.expectError (GL_INVALID_ENUM);
594 ctx.glClearBufferuiv (GL_STENCIL, 0, &data[0]);
595 ctx.expectError (GL_INVALID_ENUM);
596 ctx.glClearBufferuiv (GL_DEPTH_STENCIL, 0, &data[0]);
597 ctx.expectError (GL_INVALID_ENUM);
600 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
601 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
602 ctx.glClearBufferuiv (GL_COLOR, maxDrawBuffers, &data[0]);
603 ctx.expectError (GL_INVALID_VALUE);
606 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
607 ctx.glClearBufferuiv (GL_COLOR, -1, &data[0]);
608 ctx.expectError (GL_INVALID_VALUE);
611 ctx.glDeleteFramebuffers (1, &fbo);
612 ctx.glDeleteTextures (1, &texture);
615 void clear_bufferfv (NegativeTestContext& ctx)
617 std::vector<float> data (32*32);
618 deUint32 fbo = 0x1234;
619 deUint32 texture = 0x1234;
620 int maxDrawBuffers = 0x1234;
622 ctx.glGenTextures (1, &texture);
623 ctx.glBindTexture (GL_TEXTURE_2D, texture);
624 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
625 ctx.glGenFramebuffers (1, &fbo);
626 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
627 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
628 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
629 ctx.expectError (GL_NO_ERROR);
631 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_COLOR or GL_DEPTH.");
632 ctx.glClearBufferfv (-1, 0, &data[0]);
633 ctx.expectError (GL_INVALID_ENUM);
634 ctx.glClearBufferfv (GL_FRAMEBUFFER, 0, &data[0]);
635 ctx.expectError (GL_INVALID_ENUM);
638 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL.");
639 ctx.glClearBufferfv (GL_STENCIL, 1, &data[0]);
640 ctx.expectError (GL_INVALID_ENUM);
641 ctx.glClearBufferfv (GL_DEPTH_STENCIL, 1, &data[0]);
642 ctx.expectError (GL_INVALID_ENUM);
645 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS.");
646 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
647 ctx.glClearBufferfv (GL_COLOR, maxDrawBuffers, &data[0]);
648 ctx.expectError (GL_INVALID_VALUE);
651 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_COLOR and drawBuffer is negative.");
652 ctx.glClearBufferfv (GL_COLOR, -1, &data[0]);
653 ctx.expectError (GL_INVALID_VALUE);
656 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero.");
657 ctx.glClearBufferfv (GL_DEPTH, 1, &data[0]);
658 ctx.expectError (GL_INVALID_VALUE);
661 ctx.glDeleteFramebuffers (1, &fbo);
662 ctx.glDeleteTextures (1, &texture);
665 void clear_bufferfi (NegativeTestContext& ctx)
667 ctx.beginSection("GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL.");
668 ctx.glClearBufferfi (-1, 0, 1.0f, 1);
669 ctx.expectError (GL_INVALID_ENUM);
670 ctx.glClearBufferfi (GL_FRAMEBUFFER, 0, 1.0f, 1);
671 ctx.expectError (GL_INVALID_ENUM);
672 ctx.glClearBufferfi (GL_DEPTH, 0, 1.0f, 1);
673 ctx.expectError (GL_INVALID_ENUM);
674 ctx.glClearBufferfi (GL_STENCIL, 0, 1.0f, 1);
675 ctx.expectError (GL_INVALID_ENUM);
676 ctx.glClearBufferfi (GL_COLOR, 0, 1.0f, 1);
677 ctx.expectError (GL_INVALID_ENUM);
680 ctx.beginSection("GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero.");
681 ctx.glClearBufferfi (GL_DEPTH_STENCIL, 1, 1.0f, 1);
682 ctx.expectError (GL_INVALID_VALUE);
686 void copy_buffer_sub_data (NegativeTestContext& ctx)
689 std::vector<float> data (32*32);
691 ctx.glGenBuffers (2, buf);
692 ctx.glBindBuffer (GL_COPY_READ_BUFFER, buf[0]);
693 ctx.glBufferData (GL_COPY_READ_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
694 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
695 ctx.glBufferData (GL_COPY_WRITE_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
696 ctx.expectError (GL_NO_ERROR);
698 ctx.beginSection("GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative.");
699 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, -4);
700 ctx.expectError (GL_INVALID_VALUE);
701 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, -1, 0, 4);
702 ctx.expectError (GL_INVALID_VALUE);
703 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, -1, 4);
704 ctx.expectError (GL_INVALID_VALUE);
707 ctx.beginSection("GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget.");
708 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
709 ctx.expectError (GL_INVALID_VALUE);
710 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16);
711 ctx.expectError (GL_INVALID_VALUE);
712 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4);
713 ctx.expectError (GL_INVALID_VALUE);
716 ctx.beginSection("GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget.");
717 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36);
718 ctx.expectError (GL_INVALID_VALUE);
719 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16);
720 ctx.expectError (GL_INVALID_VALUE);
721 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4);
722 ctx.expectError (GL_INVALID_VALUE);
725 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.");
726 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[0]);
727 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4);
728 ctx.expectError (GL_NO_ERROR);
729 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4);
730 ctx.expectError (GL_INVALID_VALUE);
731 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18);
732 ctx.expectError (GL_INVALID_VALUE);
733 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
736 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget.");
737 ctx.glBindBuffer (GL_COPY_READ_BUFFER, 0);
738 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
739 ctx.expectError (GL_INVALID_OPERATION);
741 ctx.glBindBuffer (GL_COPY_READ_BUFFER, buf[0]);
742 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, 0);
743 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
744 ctx.expectError (GL_INVALID_OPERATION);
746 ctx.glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]);
749 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped.");
750 ctx.glMapBufferRange (GL_COPY_READ_BUFFER, 0, 4, GL_MAP_READ_BIT);
751 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
752 ctx.expectError (GL_INVALID_OPERATION);
753 ctx.glUnmapBuffer (GL_COPY_READ_BUFFER);
755 ctx.glMapBufferRange (GL_COPY_WRITE_BUFFER, 0, 4, GL_MAP_READ_BIT);
756 ctx.glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16);
757 ctx.expectError (GL_INVALID_OPERATION);
758 ctx.glUnmapBuffer (GL_COPY_WRITE_BUFFER);
761 ctx.glDeleteBuffers(2, buf);
764 void draw_buffers (NegativeTestContext& ctx)
766 deUint32 fbo = 0x1234;
767 deUint32 texture = 0x1234;
768 int maxDrawBuffers = 0x1234;
769 int maxColorAttachments = -1;
770 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
771 ctx.glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
772 std::vector<deUint32> values (maxDrawBuffers+1);
773 std::vector<deUint32> attachments (4);
774 std::vector<GLfloat> data (32*32);
777 values[2] = GL_COLOR_ATTACHMENT0;
778 values[3] = GL_DEPTH_ATTACHMENT;
779 attachments[0] = (glw::GLenum) (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
780 attachments[1] = GL_COLOR_ATTACHMENT0;
781 attachments[2] = GL_COLOR_ATTACHMENT1;
782 attachments[3] = GL_NONE;
784 ctx.glGenTextures (1, &texture);
785 ctx.glBindTexture (GL_TEXTURE_2D, texture);
786 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
787 ctx.glGenFramebuffers (1, &fbo);
788 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
789 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
790 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
791 ctx.expectError (GL_NO_ERROR);
793 ctx.beginSection("GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value.");
794 ctx.glDrawBuffers (2, &values[2]);
795 ctx.expectError (GL_INVALID_ENUM);
798 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.");
799 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
800 ctx.glDrawBuffers (1, &values[1]);
801 ctx.expectError (GL_INVALID_OPERATION);
802 ctx.glDrawBuffers (4, &attachments[0]);
803 ctx.expectError (GL_INVALID_OPERATION);
806 ctx.beginSection("GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1.");
807 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
808 ctx.glDrawBuffers (2, &values[0]);
809 ctx.expectError (GL_INVALID_OPERATION);
812 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.");
813 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
814 ctx.glDrawBuffers (1, &values[2]);
815 ctx.expectError (GL_INVALID_OPERATION);
818 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.");
819 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
820 ctx.glDrawBuffers (1, &values[1]);
821 ctx.expectError (GL_INVALID_OPERATION);
822 ctx.glDrawBuffers (4, &attachments[0]);
823 ctx.expectError (GL_INVALID_OPERATION);
827 ctx.beginSection("GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS.");
828 ctx.glDrawBuffers (-1, &values[1]);
829 ctx.expectError (GL_INVALID_VALUE);
830 ctx.glDrawBuffers (maxDrawBuffers+1, &values[0]);
831 ctx.expectError (GL_INVALID_VALUE);
834 ctx.glDeleteTextures(1, &texture);
835 ctx.glDeleteFramebuffers(1, &fbo);
838 void flush_mapped_buffer_range (NegativeTestContext& ctx)
840 deUint32 buf = 0x1234;
841 std::vector<GLfloat> data (32);
843 ctx.glGenBuffers (1, &buf);
844 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
845 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_STATIC_READ);
846 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
847 ctx.expectError (GL_NO_ERROR);
849 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted values.");
850 ctx.glFlushMappedBufferRange(-1, 0, 16);
851 ctx.expectError (GL_INVALID_ENUM);
854 ctx.beginSection("GL_INVALID_VALUE is generated if offset or length is negative, or if offset + length exceeds the size of the mapping.");
855 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, -1, 1);
856 ctx.expectError (GL_INVALID_VALUE);
857 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, -1);
858 ctx.expectError (GL_INVALID_VALUE);
859 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 12, 8);
860 ctx.expectError (GL_INVALID_VALUE);
861 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 24, 4);
862 ctx.expectError (GL_INVALID_VALUE);
863 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 24);
864 ctx.expectError (GL_INVALID_VALUE);
867 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
868 ctx.glBindBuffer (GL_ARRAY_BUFFER, 0);
869 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
870 ctx.expectError (GL_INVALID_OPERATION);
873 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.");
874 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
875 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
876 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
877 ctx.expectError (GL_INVALID_OPERATION);
878 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
879 ctx.glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8);
880 ctx.expectError (GL_INVALID_OPERATION);
883 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
884 ctx.glDeleteBuffers (1, &buf);
887 void map_buffer_range (NegativeTestContext& ctx)
889 deUint32 buf = 0x1234;
890 std::vector<GLfloat> data (32);
892 ctx.glGenBuffers (1, &buf);
893 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
894 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
895 ctx.expectError (GL_NO_ERROR);
897 ctx.beginSection("GL_INVALID_VALUE is generated if either of offset or length is negative.");
898 ctx.glMapBufferRange (GL_ARRAY_BUFFER, -1, 1, GL_MAP_READ_BIT);
899 ctx.expectError (GL_INVALID_VALUE);
901 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 1, -1, GL_MAP_READ_BIT);
902 ctx.expectError (GL_INVALID_VALUE);
905 ctx.beginSection("GL_INVALID_VALUE is generated if offset + length is greater than the value of GL_BUFFER_SIZE.");
906 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 33, GL_MAP_READ_BIT);
907 ctx.expectError (GL_INVALID_VALUE);
909 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 32, 1, GL_MAP_READ_BIT);
910 ctx.expectError (GL_INVALID_VALUE);
912 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 16, 17, GL_MAP_READ_BIT);
913 ctx.expectError (GL_INVALID_VALUE);
916 ctx.beginSection("GL_INVALID_VALUE is generated if access has any bits set other than those accepted.");
917 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | 0x1000);
918 ctx.expectError (GL_INVALID_VALUE);
920 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | 0x1000);
921 ctx.expectError (GL_INVALID_VALUE);
924 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer is already in a mapped state.");
925 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT);
926 ctx.expectError (GL_NO_ERROR);
927 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT);
928 ctx.expectError (GL_INVALID_OPERATION);
929 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
932 ctx.beginSection("GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.");
933 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT);
934 ctx.expectError (GL_INVALID_OPERATION);
937 ctx.beginSection("GL_INVALID_OPERATION is generated if length is 0");
938 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 0, GL_MAP_READ_BIT);
939 ctx.expectError (GL_INVALID_OPERATION);
942 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.");
943 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
944 ctx.expectError (GL_INVALID_OPERATION);
946 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
947 ctx.expectError (GL_INVALID_OPERATION);
949 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
950 ctx.expectError (GL_INVALID_OPERATION);
953 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.");
954 ctx.glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
955 ctx.expectError (GL_INVALID_OPERATION);
958 ctx.glDeleteBuffers (1, &buf);
961 void read_buffer (NegativeTestContext& ctx)
963 deUint32 fbo = 0x1234;
964 deUint32 texture = 0x1234;
965 int maxColorAttachments = 0x1234;
967 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
968 ctx.glGenTextures (1, &texture);
969 ctx.glBindTexture (GL_TEXTURE_2D, texture);
970 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
971 ctx.glGenFramebuffers (1, &fbo);
972 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
973 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
974 ctx.glCheckFramebufferStatus(GL_FRAMEBUFFER);
975 ctx.expectError (GL_NO_ERROR);
977 ctx.beginSection("GL_INVALID_ENUM is generated if mode is not GL_BACK, GL_NONE, or GL_COLOR_ATTACHMENTi.");
978 ctx.glReadBuffer (GL_NONE);
979 ctx.expectError (GL_NO_ERROR);
980 ctx.glReadBuffer (1);
981 ctx.expectError (GL_INVALID_ENUM);
982 ctx.glReadBuffer (GL_FRAMEBUFFER);
983 ctx.expectError (GL_INVALID_ENUM);
984 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0 - 1);
985 ctx.expectError (GL_INVALID_ENUM);
986 ctx.glReadBuffer (GL_FRONT);
987 ctx.expectError (GL_INVALID_ENUM);
989 // \ note Spec isn't actually clear here, but it is safe to assume that
990 // GL_DEPTH_ATTACHMENT can't be interpreted as GL_COLOR_ATTACHMENTm
991 // where m = (GL_DEPTH_ATTACHMENT - GL_COLOR_ATTACHMENT0).
992 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT);
993 ctx.expectError (GL_INVALID_ENUM);
994 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT);
995 ctx.expectError (GL_INVALID_ENUM);
996 ctx.glReadBuffer (GL_STENCIL_ATTACHMENT+1);
997 ctx.expectError (GL_INVALID_ENUM);
998 ctx.glReadBuffer (0xffffffffu);
999 ctx.expectError (GL_INVALID_ENUM);
1002 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.");
1003 ctx.glReadBuffer (GL_BACK);
1004 ctx.expectError (GL_INVALID_OPERATION);
1005 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0 + maxColorAttachments);
1006 ctx.expectError (GL_INVALID_OPERATION);
1008 if (GL_COLOR_ATTACHMENT0+maxColorAttachments < GL_DEPTH_ATTACHMENT-1)
1010 ctx.glReadBuffer (GL_DEPTH_ATTACHMENT - 1);
1011 ctx.expectError (GL_INVALID_OPERATION);
1016 ctx.beginSection("GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK.");
1017 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1018 ctx.glReadBuffer (GL_COLOR_ATTACHMENT0);
1019 ctx.expectError (GL_INVALID_OPERATION);
1022 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.");
1023 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1024 ctx.glReadBuffer (GL_BACK);
1025 ctx.expectError (GL_INVALID_OPERATION);
1028 ctx.glDeleteTextures(1, &texture);
1029 ctx.glDeleteFramebuffers(1, &fbo);
1032 void unmap_buffer (NegativeTestContext& ctx)
1034 deUint32 buf = 0x1234;
1035 std::vector<GLfloat> data (32);
1037 ctx.glGenBuffers (1, &buf);
1038 ctx.glBindBuffer (GL_ARRAY_BUFFER, buf);
1039 ctx.glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY);
1040 ctx.expectError (GL_NO_ERROR);
1042 ctx.beginSection("GL_INVALID_OPERATION is generated if the buffer data store is already in an unmapped state.");
1043 ctx.glUnmapBuffer (GL_ARRAY_BUFFER);
1044 ctx.expectError (GL_INVALID_OPERATION);
1047 ctx.glDeleteBuffers (1, &buf);
1049 // Framebuffer Objects
1051 void bind_framebuffer (NegativeTestContext& ctx)
1053 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER.");
1054 ctx.glBindFramebuffer(-1, 0);
1055 ctx.expectError(GL_INVALID_ENUM);
1056 ctx.glBindFramebuffer(GL_RENDERBUFFER, 0);
1057 ctx.expectError(GL_INVALID_ENUM);
1061 void bind_renderbuffer (NegativeTestContext& ctx)
1063 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1064 ctx.glBindRenderbuffer(-1, 0);
1065 ctx.expectError(GL_INVALID_ENUM);
1066 ctx.glBindRenderbuffer(GL_FRAMEBUFFER, 0);
1067 ctx.expectError(GL_INVALID_ENUM);
1071 void check_framebuffer_status (NegativeTestContext& ctx)
1073 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER, or GL_FRAMEBUFFER..");
1074 ctx.glCheckFramebufferStatus(-1);
1075 ctx.expectError(GL_INVALID_ENUM);
1076 ctx.glCheckFramebufferStatus(GL_RENDERBUFFER);
1077 ctx.expectError(GL_INVALID_ENUM);
1081 void gen_framebuffers (NegativeTestContext& ctx)
1083 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1084 ctx.glGenFramebuffers(-1, 0);
1085 ctx.expectError(GL_INVALID_VALUE);
1089 void gen_renderbuffers (NegativeTestContext& ctx)
1091 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1092 ctx.glGenRenderbuffers(-1, 0);
1093 ctx.expectError(GL_INVALID_VALUE);
1097 void delete_framebuffers (NegativeTestContext& ctx)
1099 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1100 ctx.glDeleteFramebuffers(-1, 0);
1101 ctx.expectError(GL_INVALID_VALUE);
1105 void delete_renderbuffers (NegativeTestContext& ctx)
1107 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative.");
1108 ctx.glDeleteRenderbuffers(-1, 0);
1109 ctx.expectError(GL_INVALID_VALUE);
1113 void framebuffer_renderbuffer (NegativeTestContext& ctx)
1115 GLuint fbo = 0x1234;
1116 GLuint rbo = 0x1234;
1117 ctx.glGenFramebuffers(1, &fbo);
1118 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1119 ctx.glGenRenderbuffers(1, &rbo);
1121 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1122 ctx.glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1123 ctx.expectError(GL_INVALID_ENUM);
1126 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1127 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, -1, GL_RENDERBUFFER, 0);
1128 ctx.expectError(GL_INVALID_ENUM);
1131 ctx.beginSection("GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
1132 ctx.glBindRenderbuffer(GL_RENDERBUFFER, rbo);
1133 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
1134 ctx.expectError(GL_INVALID_ENUM);
1135 ctx.glBindRenderbuffer(GL_RENDERBUFFER, 0);
1138 ctx.beginSection("GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
1139 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
1140 ctx.expectError(GL_INVALID_OPERATION);
1143 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1144 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1145 ctx.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
1146 ctx.expectError(GL_INVALID_OPERATION);
1149 ctx.glDeleteRenderbuffers(1, &rbo);
1150 ctx.glDeleteFramebuffers(1, &fbo);
1153 void framebuffer_texture (NegativeTestContext& ctx)
1155 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1157 GLuint fbo = 0x1234;
1158 GLuint texture[] = {0x1234, 0x1234};
1160 ctx.glGenFramebuffers(1, &fbo);
1161 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1162 ctx.glGenTextures(2, texture);
1163 ctx.glBindTexture(GL_TEXTURE_2D, texture[0]);
1164 ctx.glBindTexture(GL_TEXTURE_BUFFER, texture[1]);
1165 ctx.expectError(GL_NO_ERROR);
1167 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1168 ctx.glFramebufferTexture(-1, GL_COLOR_ATTACHMENT0, texture[0], 0);
1169 ctx.expectError(GL_INVALID_ENUM);
1172 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1173 ctx.glFramebufferTexture(GL_FRAMEBUFFER, -1, texture[0], 0);
1174 ctx.expectError(GL_INVALID_ENUM);
1177 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1178 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0);
1179 ctx.expectError(GL_INVALID_VALUE);
1182 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1183 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1184 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0);
1185 ctx.expectError(GL_INVALID_OPERATION);
1186 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1189 ctx.beginSection("GL_INVALID_OPERATION is generated by if texture is a buffer texture.");
1190 ctx.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture[1], 0);
1191 ctx.expectError(GL_INVALID_OPERATION);
1194 ctx.glDeleteFramebuffers(1, &fbo);
1195 ctx.glDeleteBuffers(2, texture);
1199 void framebuffer_texture2d (NegativeTestContext& ctx)
1201 GLuint fbo = 0x1234;
1202 GLuint tex2D = 0x1234;
1203 GLuint texCube = 0x1234;
1204 GLuint tex2DMS = 0x1234;
1205 GLint maxTexSize = 0x1234;
1206 GLint maxTexCubeSize = 0x1234;
1207 int maxSize = 0x1234;
1209 ctx.glGenFramebuffers(1, &fbo);
1210 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1211 ctx.glGenTextures(1, &tex2D);
1212 ctx.glBindTexture(GL_TEXTURE_2D, tex2D);
1213 ctx.glGenTextures(1, &texCube);
1214 ctx.glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
1215 ctx.glGenTextures(1, &tex2DMS);
1216 ctx.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex2DMS);
1217 ctx.glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
1218 ctx.glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxTexCubeSize);
1219 ctx.expectError(GL_NO_ERROR);
1221 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1222 ctx.glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1223 ctx.expectError(GL_INVALID_ENUM);
1226 ctx.beginSection("GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
1227 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
1228 ctx.expectError(GL_INVALID_ENUM);
1231 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not an accepted token.");
1232 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, -1, GL_TEXTURE_2D, tex2D, 0);
1233 ctx.expectError(GL_INVALID_ENUM);
1236 ctx.beginSection("GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size.");
1237 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1238 ctx.expectError(GL_INVALID_VALUE);
1239 maxSize = deLog2Floor32(maxTexSize) + 1;
1240 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize);
1241 ctx.expectError(GL_INVALID_VALUE);
1242 maxSize = deLog2Floor32(maxTexSize) + 1;
1243 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize);
1244 ctx.expectError(GL_INVALID_VALUE);
1247 ctx.beginSection("GL_INVALID_VALUE is generated if level is larger than maximum texture size.");
1248 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxTexSize + 1);
1249 ctx.expectError(GL_INVALID_VALUE);
1250 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1);
1251 ctx.expectError(GL_INVALID_VALUE);
1252 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, maxTexCubeSize + 1);
1253 ctx.expectError(GL_INVALID_VALUE);
1254 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, texCube, -1);
1255 ctx.expectError(GL_INVALID_VALUE);
1256 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2DMS, 1);
1257 ctx.expectError(GL_INVALID_VALUE);
1260 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
1261 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
1262 ctx.expectError(GL_INVALID_OPERATION);
1265 ctx.beginSection("GL_INVALID_OPERATION is generated if textarget and texture are not compatible.");
1266 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
1267 ctx.expectError(GL_INVALID_OPERATION);
1268 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, tex2D, 0);
1269 ctx.expectError(GL_INVALID_OPERATION);
1270 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
1271 ctx.expectError(GL_INVALID_OPERATION);
1272 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2DMS, 0);
1273 ctx.expectError(GL_INVALID_OPERATION);
1274 ctx.glDeleteTextures(1, &tex2D);
1275 ctx.glDeleteTextures(1, &texCube);
1276 ctx.glDeleteTextures(1, &tex2DMS);
1279 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1280 ctx.glBindFramebuffer(GL_FRAMEBUFFER, 0);
1281 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
1282 ctx.expectError(GL_INVALID_OPERATION);
1285 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1287 GLuint texBuf = 0x1234;
1288 ctx.beginSection("GL_INVALID_OPERATION error is generated if texture is the name of a buffer texture.");
1289 ctx.glGenTextures(1, &texBuf);
1290 ctx.glBindTexture(GL_TEXTURE_BUFFER, texBuf);
1291 ctx.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
1292 ctx.expectError(GL_NO_ERROR);
1293 ctx.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texBuf, 0);
1294 ctx.expectError(GL_INVALID_OPERATION);
1298 ctx.glDeleteFramebuffers(1, &fbo);
1301 void renderbuffer_storage (NegativeTestContext& ctx)
1303 deUint32 rbo = 0x1234;
1304 GLint maxSize = 0x1234;
1306 ctx.glGenRenderbuffers (1, &rbo);
1307 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1309 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1310 ctx.glRenderbufferStorage (-1, GL_RGBA4, 1, 1);
1311 ctx.expectError (GL_INVALID_ENUM);
1312 ctx.glRenderbufferStorage (GL_FRAMEBUFFER, GL_RGBA4, 1, 1);
1313 ctx.expectError (GL_INVALID_ENUM);
1316 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1317 ctx.glRenderbufferStorage (GL_RENDERBUFFER, -1, 1, 1);
1318 ctx.expectError (GL_INVALID_ENUM);
1320 if (!ctx.isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1322 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGB16F, 1, 1);
1323 ctx.expectError (GL_INVALID_ENUM);
1326 if (!ctx.isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1328 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8_SNORM, 1, 1);
1329 ctx.expectError (GL_INVALID_ENUM);
1334 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1335 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, 1);
1336 ctx.expectError (GL_INVALID_VALUE);
1337 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, -1);
1338 ctx.expectError (GL_INVALID_VALUE);
1339 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, -1);
1340 ctx.expectError (GL_INVALID_VALUE);
1343 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1344 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1345 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
1346 ctx.expectError (GL_INVALID_VALUE);
1347 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
1348 ctx.expectError (GL_INVALID_VALUE);
1349 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
1350 ctx.expectError (GL_INVALID_VALUE);
1353 ctx.glDeleteRenderbuffers(1, &rbo);
1356 void blit_framebuffer (NegativeTestContext& ctx)
1360 deUint32 texture[2];
1361 deUint32 blankFrameBuffer;
1363 ctx.glGenFramebuffers (1, &blankFrameBuffer);
1364 ctx.glGenFramebuffers (2, fbo);
1365 ctx.glGenTextures (2, texture);
1366 ctx.glGenRenderbuffers (2, rbo);
1368 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1369 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1370 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1372 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1373 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1374 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1375 ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1376 ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1378 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1379 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
1380 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1382 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1383 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32);
1384 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1385 ctx.glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]);
1386 ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1387 ctx.expectError (GL_NO_ERROR);
1389 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.");
1390 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 1, GL_NEAREST);
1391 ctx.expectError (GL_INVALID_VALUE);
1394 ctx.beginSection("GL_INVALID_ENUM is generated if filter is not GL_LINEAR or GL_NEAREST.");
1395 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, 0);
1396 ctx.expectError (GL_INVALID_ENUM);
1399 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.");
1400 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1401 ctx.expectError (GL_INVALID_OPERATION);
1402 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_LINEAR);
1403 ctx.expectError (GL_INVALID_OPERATION);
1404 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR);
1405 ctx.expectError (GL_INVALID_OPERATION);
1408 ctx.beginSection("GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format.");
1409 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1411 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1412 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1413 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32UI, draw buffer: GL_RGBA" << TestLog::EndMessage;
1414 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1415 ctx.expectError (GL_INVALID_OPERATION);
1417 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1418 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1419 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA" << TestLog::EndMessage;
1420 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1421 ctx.expectError (GL_INVALID_OPERATION);
1423 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1424 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1425 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1426 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL);
1427 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1428 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA8, draw buffer: GL_RGBA32I" << TestLog::EndMessage;
1429 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1430 ctx.expectError (GL_INVALID_OPERATION);
1433 ctx.beginSection("GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data.");
1434 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1435 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
1436 ctx.glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0);
1437 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1438 ctx.glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0);
1439 ctx.getLog() << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage;
1440 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR);
1441 ctx.expectError (GL_INVALID_OPERATION);
1444 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.");
1445 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1446 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32);
1447 ctx.glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]);
1448 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1449 ctx.expectError (GL_INVALID_OPERATION);
1450 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1451 ctx.expectError (GL_INVALID_OPERATION);
1454 ctx.beginSection("GL_INVALID_FRAMEBUFFER_OPERATION is generated if the read or draw framebuffer is not framebuffer complete.");
1455 ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1456 ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1457 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1458 ctx.expectError (GL_NO_ERROR);
1459 ctx.getLog() << TestLog::Message << "// incomplete read framebuffer" << TestLog::EndMessage;
1460 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, blankFrameBuffer);
1461 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1462 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1463 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1464 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1465 ctx.expectError (GL_INVALID_FRAMEBUFFER_OPERATION);
1466 ctx.getLog() << TestLog::Message << "// incomplete draw framebuffer" << TestLog::EndMessage;
1467 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[1]);
1468 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1469 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
1470 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1471 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1472 ctx.expectError (GL_INVALID_FRAMEBUFFER_OPERATION);
1473 ctx.getLog() << TestLog::Message << "// incomplete read and draw framebuffer" << TestLog::EndMessage;
1474 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, blankFrameBuffer);
1475 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, blankFrameBuffer);
1476 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1477 TCU_CHECK(ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE);
1478 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, 0, GL_NEAREST);
1479 ctx.expectError (GL_INVALID_FRAMEBUFFER_OPERATION);
1481 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1482 ctx.glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
1483 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1484 ctx.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
1487 ctx.beginSection("GL_INVALID_OPERATION is generated if the source and destination buffers are identical.");
1488 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[0]);
1489 ctx.expectError (GL_NO_ERROR);
1490 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1491 ctx.expectError (GL_INVALID_OPERATION);
1493 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1496 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1497 ctx.glBindRenderbuffer (GL_RENDERBUFFER, 0);
1498 ctx.glDeleteFramebuffers (2, fbo);
1499 ctx.glDeleteFramebuffers (1, &blankFrameBuffer);
1500 ctx.glDeleteTextures (2, texture);
1501 ctx.glDeleteRenderbuffers (2, rbo);
1504 void blit_framebuffer_multisample (NegativeTestContext& ctx)
1509 ctx.glGenFramebuffers (2, fbo);
1510 ctx.glGenRenderbuffers (2, rbo);
1512 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]);
1513 ctx.glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]);
1514 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1515 ctx.glFramebufferRenderbuffer (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]);
1516 ctx.glCheckFramebufferStatus (GL_READ_FRAMEBUFFER);
1518 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]);
1519 ctx.glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]);
1521 ctx.expectError (GL_NO_ERROR);
1523 if (!ctx.isExtensionSupported("GL_NV_framebuffer_multisample"))
1525 ctx.beginSection("GL_INVALID_OPERATION is generated if the value of GL_SAMPLE_BUFFERS for the draw buffer is greater than zero.");
1526 ctx.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32);
1527 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1528 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1529 ctx.expectError (GL_INVALID_OPERATION);
1532 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.");
1533 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 32, 32);
1534 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1535 ctx.glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1536 ctx.expectError (GL_INVALID_OPERATION);
1539 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.");
1540 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1541 ctx.glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]);
1542 ctx.glBlitFramebuffer (0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1543 ctx.expectError (GL_INVALID_OPERATION);
1547 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1548 ctx.glDeleteRenderbuffers (2, rbo);
1549 ctx.glDeleteFramebuffers (2, fbo);
1552 void framebuffer_texture_layer (NegativeTestContext& ctx)
1554 deUint32 fbo = 0x1234;
1555 deUint32 tex3D = 0x1234;
1556 deUint32 tex2DArray = 0x1234;
1557 deUint32 tex2D = 0x1234;
1558 deUint32 tex2DMSArray = 0x1234;
1559 deUint32 texCube = 0x1234;
1560 deUint32 texBuffer = 0x1234;
1561 int max3DTexSize = 0x1234;
1562 int maxTexSize = 0x1234;
1563 int maxArrayTexLayers = 0x1234;
1564 int maxCubeTexSize = 0x1234;
1565 int log2Max3DTexSize = 0x1234;
1566 int log2MaxTexSize = 0x1234;
1568 ctx.glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize);
1569 ctx.glGetIntegerv (GL_MAX_TEXTURE_SIZE, &maxTexSize);
1571 ctx.glGenFramebuffers (1, &fbo);
1572 ctx.glGenTextures (1, &tex3D);
1573 ctx.glGenTextures (1, &tex2DArray);
1574 ctx.glGenTextures (1, &tex2D);
1575 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1577 ctx.glBindTexture (GL_TEXTURE_3D, tex3D);
1578 ctx.glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1579 ctx.glBindTexture (GL_TEXTURE_2D_ARRAY, tex2DArray);
1580 ctx.glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1581 ctx.glBindTexture (GL_TEXTURE_2D, tex2D);
1582 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1584 ctx.expectError (GL_NO_ERROR);
1586 ctx.beginSection("GL_INVALID_ENUM is generated if target is not one of the accepted tokens.");
1587 ctx.glFramebufferTextureLayer (-1, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1588 ctx.expectError (GL_INVALID_ENUM);
1589 ctx.glFramebufferTextureLayer (GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1590 ctx.expectError (GL_INVALID_ENUM);
1593 ctx.beginSection("GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens.");
1594 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, -1, tex3D, 0, 1);
1595 ctx.expectError (GL_INVALID_ENUM);
1596 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1);
1597 ctx.expectError (GL_INVALID_ENUM);
1600 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.");
1601 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0);
1602 ctx.expectError (GL_INVALID_OPERATION);
1603 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0);
1604 ctx.expectError (GL_INVALID_OPERATION);
1607 ctx.beginSection("GL_INVALID_VALUE is generated if texture is not zero and layer is negative.");
1608 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1);
1609 ctx.expectError (GL_INVALID_VALUE);
1612 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.");
1613 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize);
1614 ctx.expectError (GL_INVALID_VALUE);
1617 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.");
1618 ctx.glGetIntegerv (GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers);
1619 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers);
1620 ctx.expectError (GL_INVALID_VALUE);
1623 ctx.beginSection("GL_INVALID_OPERATION is generated if zero is bound to target.");
1624 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1625 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1);
1626 ctx.expectError (GL_INVALID_OPERATION);
1627 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1630 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.");
1631 log2Max3DTexSize = deLog2Floor32(max3DTexSize);
1632 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, -1, max3DTexSize - 1);
1633 ctx.expectError (GL_INVALID_VALUE);
1634 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, log2Max3DTexSize + 1, max3DTexSize - 1);
1635 ctx.expectError (GL_INVALID_VALUE);
1638 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D array texture and layer is less than 0 or greater than log2 of the value of GL_MAX_TEXTURE_SIZE.");
1639 log2MaxTexSize = deLog2Floor32(maxTexSize);
1640 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, -1, maxArrayTexLayers - 1);
1641 ctx.expectError (GL_INVALID_VALUE);
1642 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, log2MaxTexSize + 1, maxArrayTexLayers - 1);
1643 ctx.expectError (GL_INVALID_VALUE);
1646 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1648 ctx.glGetIntegerv (GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxCubeTexSize);
1649 ctx.glGenTextures (1, &tex2DMSArray);
1650 ctx.glGenTextures (1, &texCube);
1651 ctx.glGenTextures (1, &texBuffer);
1652 ctx.glBindTexture (GL_TEXTURE_2D_MULTISAMPLE_ARRAY, tex2DMSArray);
1653 ctx.glBindTexture (GL_TEXTURE_CUBE_MAP, texCube);
1654 ctx.glBindTexture (GL_TEXTURE_BUFFER, texBuffer);
1655 ctx.expectError (GL_NO_ERROR);
1657 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a 2D multisample array texture and layer not 0.");
1658 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, -1, 0);
1659 ctx.expectError (GL_INVALID_VALUE);
1660 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DMSArray, 1, 0);
1661 ctx.expectError (GL_INVALID_VALUE);
1664 ctx.beginSection("GL_INVALID_VALUE is generated if texture is a cube map array texture and layer is larger than the value of MAX_CUBE_MAP_TEXTURE_SIZE-1 minus one.");
1665 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texCube, 0, maxCubeTexSize);
1666 ctx.expectError (GL_INVALID_VALUE);
1669 ctx.beginSection("GL_INVALID_OPERATION is generated if texture is the name of a buffer texture.");
1670 ctx.glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texBuffer, 0, 0);
1671 ctx.expectError (GL_INVALID_OPERATION);
1674 ctx.glDeleteTextures (1, &tex2DMSArray);
1675 ctx.glDeleteTextures (1, &texCube);
1676 ctx.glDeleteTextures (1, &texBuffer);
1679 ctx.glDeleteTextures (1, &tex3D);
1680 ctx.glDeleteTextures (1, &tex2DArray);
1681 ctx.glDeleteTextures (1, &tex2D);
1682 ctx.glDeleteFramebuffers (1, &fbo);
1685 void invalidate_framebuffer (NegativeTestContext& ctx)
1687 deUint32 attachments[3];
1688 deUint32 fbo = 0x1234;
1689 deUint32 texture = 0x1234;
1690 int maxColorAttachments = 0x1234;
1692 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1693 attachments[0] = GL_COLOR_ATTACHMENT0;
1694 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1695 attachments[2] = GL_DEPTH_STENCIL_ATTACHMENT;
1697 ctx.glGenFramebuffers (1, &fbo);
1698 ctx.glGenTextures (1, &texture);
1699 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1700 ctx.glBindTexture (GL_TEXTURE_2D, texture);
1701 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1702 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1703 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
1704 ctx.expectError (GL_NO_ERROR);
1706 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1707 ctx.glInvalidateFramebuffer (-1, 1, &attachments[0]);
1708 ctx.expectError (GL_INVALID_ENUM);
1709 ctx.glInvalidateFramebuffer (GL_BACK, 1, &attachments[0]);
1710 ctx.expectError (GL_INVALID_ENUM);
1713 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.");
1714 ctx.glInvalidateFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1]);
1715 ctx.expectError (GL_INVALID_OPERATION);
1718 ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments is negative.");
1719 ctx.glInvalidateFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0]);
1720 ctx.expectError (GL_INVALID_VALUE);
1723 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.");
1724 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1725 ctx.glInvalidateFramebuffer (GL_FRAMEBUFFER, 1, &attachments[2]);
1726 ctx.expectError (GL_INVALID_ENUM);
1730 ctx.glDeleteTextures (1, &texture);
1731 ctx.glDeleteFramebuffers (1, &fbo);
1734 void invalidate_sub_framebuffer (NegativeTestContext& ctx)
1736 deUint32 attachments[3];
1737 deUint32 fbo = 0x1234;
1738 deUint32 texture = 0x1234;
1739 int maxColorAttachments = 0x1234;
1741 ctx.glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
1742 attachments[0] = GL_COLOR_ATTACHMENT0;
1743 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments;
1744 attachments[2] = GL_DEPTH_STENCIL_ATTACHMENT;
1746 ctx.glGenFramebuffers (1, &fbo);
1747 ctx.glGenTextures (1, &texture);
1748 ctx.glBindFramebuffer (GL_FRAMEBUFFER, fbo);
1749 ctx.glBindTexture (GL_TEXTURE_2D, texture);
1750 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1751 ctx.glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
1752 ctx.glCheckFramebufferStatus (GL_FRAMEBUFFER);
1753 ctx.expectError (GL_NO_ERROR);
1755 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER.");
1756 ctx.glInvalidateSubFramebuffer (-1, 1, &attachments[0], 0, 0, 16, 16);
1757 ctx.expectError (GL_INVALID_ENUM);
1758 ctx.glInvalidateSubFramebuffer (GL_BACK, 1, &attachments[0], 0, 0, 16, 16);
1759 ctx.expectError (GL_INVALID_ENUM);
1762 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.");
1763 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16);
1764 ctx.expectError (GL_INVALID_OPERATION);
1767 ctx.beginSection("GL_INVALID_VALUE is generated if numAttachments, width, or heigh is negative.");
1768 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, 16);
1769 ctx.expectError (GL_INVALID_VALUE);
1770 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, 16);
1771 ctx.expectError (GL_INVALID_VALUE);
1772 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, 16, -1);
1773 ctx.expectError (GL_INVALID_VALUE);
1774 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, -1, &attachments[0], 0, 0, -1, -1);
1775 ctx.expectError (GL_INVALID_VALUE);
1776 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, 16);
1777 ctx.expectError (GL_INVALID_VALUE);
1778 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, 16, -1);
1779 ctx.expectError (GL_INVALID_VALUE);
1780 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[0], 0, 0, -1, -1);
1781 ctx.expectError (GL_INVALID_VALUE);
1784 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.");
1785 ctx.glBindFramebuffer (GL_FRAMEBUFFER, 0);
1786 ctx.glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[2], 0, 0, 16, 16);
1787 ctx.expectError (GL_INVALID_ENUM);
1790 ctx.glDeleteTextures (1, &texture);
1791 ctx.glDeleteFramebuffers (1, &fbo);
1794 void renderbuffer_storage_multisample (NegativeTestContext& ctx)
1796 deUint32 rbo = 0x1234;
1797 int maxSamplesSupportedRGBA4 = -1;
1798 int maxSamplesSupportedRGBA8UI = -1;
1799 GLint maxSize = 0x1234;
1801 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, 1, &maxSamplesSupportedRGBA4);
1802 ctx.glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA8UI, GL_SAMPLES, 1, &maxSamplesSupportedRGBA8UI);
1804 ctx.glGenRenderbuffers (1, &rbo);
1805 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1807 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
1808 ctx.glRenderbufferStorageMultisample (-1, 2, GL_RGBA4, 1, 1);
1809 ctx.expectError (GL_INVALID_ENUM);
1810 ctx.glRenderbufferStorageMultisample (GL_FRAMEBUFFER, 2, GL_RGBA4, 1, 1);
1811 ctx.expectError (GL_INVALID_ENUM);
1814 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat.");
1815 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA4+1, GL_RGBA4, 1, 1);
1816 ctx.expectError (GL_INVALID_OPERATION);
1819 ctx.beginSection("GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format.");
1820 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, -1, 1, 1);
1821 ctx.expectError (GL_INVALID_ENUM);
1823 if (!ctx.isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error
1825 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGB16F, 1, 1);
1826 ctx.expectError (GL_INVALID_ENUM);
1829 if (!ctx.isExtensionSupported("GL_EXT_render_snorm")) // GL_EXT_render_snorm disables error
1831 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA8_SNORM, 1, 1);
1832 ctx.expectError (GL_INVALID_ENUM);
1837 ctx.beginSection("GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat. (Unsigned integer format)");
1838 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA8UI+1, GL_RGBA8UI, 1, 1);
1839 ctx.expectError (GL_INVALID_OPERATION);
1842 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is less than zero.");
1843 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, 1);
1844 ctx.expectError (GL_INVALID_VALUE);
1845 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, 1, -1);
1846 ctx.expectError (GL_INVALID_VALUE);
1847 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, -1);
1848 ctx.expectError (GL_INVALID_VALUE);
1849 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, -1, GL_RGBA4, 1, 1);
1850 ctx.expectError (GL_INVALID_VALUE);
1851 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, -1, 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);
1859 ctx.beginSection("GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
1860 ctx.glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize);
1861 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, 1, maxSize+1);
1862 ctx.expectError (GL_INVALID_VALUE);
1863 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, 1);
1864 ctx.expectError (GL_INVALID_VALUE);
1865 ctx.glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, maxSize+1);
1866 ctx.expectError (GL_INVALID_VALUE);
1869 ctx.glDeleteRenderbuffers(1, &rbo);
1872 void copy_image_sub_data (NegativeTestContext& ctx)
1874 if (contextSupports(ctx.getRenderContext().getType(), glu::ApiType::es(3, 2)))
1876 deUint32 texture[5];
1877 deUint32 rbo = 0x1234;
1879 ctx.glGenTextures (5, texture);
1880 ctx.glGenRenderbuffers (1, &rbo);
1881 ctx.glBindRenderbuffer (GL_RENDERBUFFER, rbo);
1883 ctx.glBindTexture (GL_TEXTURE_2D, texture[0]);
1884 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1885 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1886 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1887 ctx.glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8, 32, 32);
1888 ctx.glBindTexture (GL_TEXTURE_2D, texture[1]);
1889 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1890 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1891 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1892 ctx.expectError (GL_NO_ERROR);
1894 ctx.glBindTexture (GL_TEXTURE_3D, texture[2]);
1895 ctx.glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1896 ctx.glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1897 ctx.glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA8, 32, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1898 ctx.expectError (GL_NO_ERROR);
1900 ctx.glBindTexture (GL_TEXTURE_3D, texture[3]);
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_2D, texture[4]);
1905 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1906 ctx.glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1907 ctx.glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL);
1908 ctx.expectError (GL_NO_ERROR);
1910 ctx.beginSection("GL_INVALID_VALUE is generated if srcWidth, srcHeight, or srcDepth is negative.");
1911 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, -1, 1, 1);
1912 ctx.expectError (GL_INVALID_VALUE);
1913 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 1, -1, 1);
1914 ctx.expectError (GL_INVALID_VALUE);
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);
1927 ctx.beginSection("GL_INVALID_VALUE is generated if srcLevel and dstLevel are not valid levels for the corresponding images.");
1928 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1929 ctx.expectError (GL_INVALID_VALUE);
1930 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 1, 0, 0, 0, 0, 0, 1);
1931 ctx.expectError (GL_INVALID_VALUE);
1932 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 1, 0, 0, 0, 0, 0, 1);
1933 ctx.expectError (GL_INVALID_VALUE);
1934 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1935 ctx.expectError (GL_INVALID_VALUE);
1936 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 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, -1, 0, 0, 0, 0, 0, 1);
1939 ctx.expectError (GL_INVALID_VALUE);
1940 ctx.glCopyImageSubData (rbo, GL_RENDERBUFFER, -1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1941 ctx.expectError (GL_INVALID_VALUE);
1942 ctx.glCopyImageSubData (rbo, GL_RENDERBUFFER, 1, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1943 ctx.expectError (GL_INVALID_VALUE);
1944 ctx.glCopyImageSubData (texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, rbo, GL_RENDERBUFFER, -1, 0, 0, 0, 0, 0, 1);
1945 ctx.expectError (GL_INVALID_VALUE);
1946 ctx.glCopyImageSubData (texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, rbo, GL_RENDERBUFFER, 1, 0, 0, 0, 0, 0, 1);
1947 ctx.expectError (GL_INVALID_VALUE);
1950 ctx.beginSection("GL_INVALID_ENUM is generated if either target does not match the type of the object.");
1951 // \note: This could be either:
1952 // 1. GL_INVALID_ENUM is generated if either target does not match the type of the object.
1953 // 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.
1954 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1955 ctx.expectError (GL_INVALID_ENUM);
1956 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[2], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1957 ctx.expectError (GL_INVALID_ENUM);
1958 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_3D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1959 ctx.expectError (GL_INVALID_ENUM);
1960 ctx.glCopyImageSubData (texture[2], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1961 ctx.expectError (GL_INVALID_ENUM);
1964 ctx.beginSection("GL_INVALID_OPERATION is generated if either object is a texture and the texture is not complete.");
1965 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1966 ctx.expectError (GL_INVALID_OPERATION);
1967 ctx.glCopyImageSubData (texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1968 ctx.expectError (GL_INVALID_OPERATION);
1969 ctx.glCopyImageSubData (texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, texture[3], GL_TEXTURE_3D, 0, 0, 0, 0, 0, 0, 1);
1970 ctx.expectError (GL_INVALID_OPERATION);
1973 ctx.beginSection("GL_INVALID_VALUE is generated if the dimensions of either subregion exceeds the boundaries of the corresponding image object.");
1974 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 33, 0, 1);
1975 ctx.expectError (GL_INVALID_VALUE);
1976 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[1], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 33, 1);
1977 ctx.expectError (GL_INVALID_VALUE);
1980 ctx.beginSection("GL_INVALID_OPERATION error is generated if the source and destination internal formats are not compatible.");
1981 ctx.glCopyImageSubData (texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, texture[4], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1982 ctx.expectError (GL_INVALID_OPERATION);
1983 ctx.glCopyImageSubData (texture[4], GL_TEXTURE_2D, 0, 0, 0, 0, texture[0], GL_TEXTURE_2D, 0, 0, 0, 0, 0, 0, 1);
1984 ctx.expectError (GL_INVALID_OPERATION);
1987 ctx.glDeleteTextures (5, texture);
1988 ctx.glDeleteRenderbuffers (1, &rbo);
1992 std::vector<FunctionContainer> getNegativeBufferApiTestFunctions ()
1994 const FunctionContainer funcs[] =
1996 {bind_buffer, "bind_buffer", "Invalid glBindBuffer() usage" },
1997 {delete_buffers, "delete_buffers", "Invalid glDeleteBuffers() usage" },
1998 {gen_buffers, "gen_buffers", "Invalid glGenBuffers() usage" },
1999 {buffer_data, "buffer_data", "Invalid glBufferData() usage" },
2000 {buffer_sub_data, "buffer_sub_data", "Invalid glBufferSubData() usage" },
2001 {buffer_sub_data_size_offset, "buffer_sub_data_size_offset", "Invalid glBufferSubData() usage" },
2002 {clear, "clear", "Invalid glClear() usage" },
2003 {read_pixels, "read_pixels", "Invalid glReadPixels() usage" },
2004 {readn_pixels, "readn_pixels", "Invalid glReadPixels() usage" },
2005 {read_pixels_format_mismatch, "read_pixels_format_mismatch", "Invalid glReadPixels() usage" },
2006 {read_pixels_fbo_format_mismatch, "read_pixels_fbo_format_mismatch", "Invalid glReadPixels() usage" },
2007 {bind_buffer_range, "bind_buffer_range", "Invalid glBindBufferRange() usage" },
2008 {bind_buffer_base, "bind_buffer_base", "Invalid glBindBufferBase() usage" },
2009 {clear_bufferiv, "clear_bufferiv", "Invalid glClearBufferiv() usage" },
2010 {clear_bufferuiv, "clear_bufferuiv", "Invalid glClearBufferuiv() usage" },
2011 {clear_bufferfv, "clear_bufferfv", "Invalid glClearBufferfv() usage" },
2012 {clear_bufferfi, "clear_bufferfi", "Invalid glClearBufferfi() usage" },
2013 {copy_buffer_sub_data, "copy_buffer_sub_data", "Invalid glCopyBufferSubData() usage" },
2014 {draw_buffers, "draw_buffers", "Invalid glDrawBuffers() usage" },
2015 {flush_mapped_buffer_range, "flush_mapped_buffer_range", "Invalid glFlushMappedBufferRange() usage" },
2016 {map_buffer_range, "map_buffer_range", "Invalid glMapBufferRange() usage" },
2017 {read_buffer, "read_buffer", "Invalid glReadBuffer() usage" },
2018 {unmap_buffer, "unmap_buffer", "Invalid glUnmapBuffer() usage" },
2019 {bind_framebuffer, "bind_framebuffer", "Invalid glBindFramebuffer() usage" },
2020 {bind_renderbuffer, "bind_renderbuffer", "Invalid glBindRenderbuffer() usage" },
2021 {check_framebuffer_status, "check_framebuffer_status", "Invalid glCheckFramebufferStatus() usage" },
2022 {gen_framebuffers, "gen_framebuffers", "Invalid glGenFramebuffers() usage" },
2023 {gen_renderbuffers, "gen_renderbuffers", "Invalid glGenRenderbuffers() usage" },
2024 {delete_framebuffers, "delete_framebuffers", "Invalid glDeleteFramebuffers() usage" },
2025 {delete_renderbuffers, "delete_renderbuffers", "Invalid glDeleteRenderbuffers() usage" },
2026 {framebuffer_renderbuffer, "framebuffer_renderbuffer", "Invalid glFramebufferRenderbuffer() usage" },
2027 {framebuffer_texture, "framebuffer_texture", "Invalid glFramebufferTexture() usage" },
2028 {framebuffer_texture2d, "framebuffer_texture2d", "Invalid glFramebufferTexture2D() usage" },
2029 {renderbuffer_storage, "renderbuffer_storage", "Invalid glRenderbufferStorage() usage" },
2030 {blit_framebuffer, "blit_framebuffer", "Invalid glBlitFramebuffer() usage" },
2031 {blit_framebuffer_multisample, "blit_framebuffer_multisample", "Invalid glBlitFramebuffer() usage" },
2032 {framebuffer_texture_layer, "framebuffer_texture_layer", "Invalid glFramebufferTextureLayer() usage" },
2033 {invalidate_framebuffer, "invalidate_framebuffer", "Invalid glInvalidateFramebuffer() usage" },
2034 {invalidate_sub_framebuffer, "invalidate_sub_framebuffer", "Invalid glInvalidateSubFramebuffer() usage" },
2035 {renderbuffer_storage_multisample, "renderbuffer_storage_multisample", "Invalid glRenderbufferStorageMultisample() usage" },
2036 {copy_image_sub_data, "copy_image_sub_data", "Invalid glCopyImageSubData() usage" },
2039 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs));
2042 } // NegativeTestShared