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