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