1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program OpenGL ES 3.0 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 "es3fNegativeBufferApiTests.hpp" 25 #include "es3fApiCase.hpp" 26 #include "gluContextInfo.hpp" 27 28 #include "glwDefs.hpp" 29 #include "glwEnums.hpp" 30 31 using namespace glw; // GL types 32 33 namespace deqp 34 { 35 namespace gles3 36 { 37 namespace Functional 38 { 39 40 using tcu::TestLog; 41 42 NegativeBufferApiTests::NegativeBufferApiTests (Context& context) 43 : TestCaseGroup(context, "buffer", "Negative Buffer API Cases") 44 { 45 } 46 47 NegativeBufferApiTests::~NegativeBufferApiTests (void) 48 { 49 } 50 51 void NegativeBufferApiTests::init (void) 52 { 53 // Buffers 54 55 ES3F_ADD_API_CASE(bind_buffer, "Invalid glBindBuffer() usage", 56 { 57 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the allowable values."); 58 glBindBuffer(-1, 0); 59 expectError(GL_INVALID_ENUM); 60 m_log << TestLog::EndSection; 61 }); 62 ES3F_ADD_API_CASE(delete_buffers, "Invalid glDeleteBuffers() usage", 63 { 64 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative."); 65 glDeleteBuffers(-1, 0); 66 expectError(GL_INVALID_VALUE); 67 m_log << TestLog::EndSection; 68 }); 69 ES3F_ADD_API_CASE(gen_buffers, "Invalid glGenBuffers() usage", 70 { 71 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative."); 72 glGenBuffers(-1, 0); 73 expectError(GL_INVALID_VALUE); 74 m_log << TestLog::EndSection; 75 }); 76 ES3F_ADD_API_CASE(buffer_data, "Invalid glBufferData() usage", 77 { 78 GLuint buffer; 79 glGenBuffers(1, &buffer); 80 glBindBuffer(GL_ARRAY_BUFFER, buffer); 81 82 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER."); 83 glBufferData(-1, 0, NULL, GL_STREAM_DRAW); 84 expectError(GL_INVALID_ENUM); 85 m_log << TestLog::EndSection; 86 87 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW."); 88 glBufferData(GL_ARRAY_BUFFER, 0, NULL, -1); 89 expectError(GL_INVALID_ENUM); 90 m_log << TestLog::EndSection; 91 92 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if size is negative."); 93 glBufferData(GL_ARRAY_BUFFER, -1, NULL, GL_STREAM_DRAW); 94 expectError(GL_INVALID_VALUE); 95 m_log << TestLog::EndSection; 96 97 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target."); 98 glBindBuffer(GL_ARRAY_BUFFER, 0); 99 glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STREAM_DRAW); 100 expectError(GL_INVALID_OPERATION); 101 m_log << TestLog::EndSection; 102 103 glDeleteBuffers(1, &buffer); 104 }); 105 ES3F_ADD_API_CASE(buffer_sub_data, "Invalid glBufferSubData() usage", 106 { 107 GLuint buffer; 108 glGenBuffers(1, &buffer); 109 glBindBuffer(GL_ARRAY_BUFFER, buffer); 110 glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW); 111 112 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER."); 113 glBufferSubData(-1, 1, 1, 0); 114 expectError(GL_INVALID_ENUM); 115 m_log << TestLog::EndSection; 116 117 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target."); 118 glBindBuffer(GL_ARRAY_BUFFER, 0); 119 glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0); 120 expectError(GL_INVALID_OPERATION); 121 m_log << TestLog::EndSection; 122 123 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the buffer object being updated is mapped."); 124 glBindBuffer(GL_ARRAY_BUFFER, buffer); 125 glMapBufferRange(GL_ARRAY_BUFFER, 0, 5, GL_MAP_READ_BIT); 126 expectError(GL_NO_ERROR); 127 glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0); 128 expectError(GL_INVALID_OPERATION); 129 m_log << TestLog::EndSection; 130 131 glDeleteBuffers(1, &buffer); 132 }); 133 ES3F_ADD_API_CASE(buffer_sub_data_size_offset, "Invalid glBufferSubData() usage", 134 { 135 GLuint buffer; 136 glGenBuffers(1, &buffer); 137 glBindBuffer(GL_ARRAY_BUFFER, buffer); 138 glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW); 139 140 m_log << TestLog::Section("", "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."); 141 glBufferSubData(GL_ARRAY_BUFFER, -1, 1, 0); 142 expectError(GL_INVALID_VALUE); 143 glBufferSubData(GL_ARRAY_BUFFER, -1, -1, 0); 144 expectError(GL_INVALID_VALUE); 145 glBufferSubData(GL_ARRAY_BUFFER, 1, -1, 0); 146 expectError(GL_INVALID_VALUE); 147 glBufferSubData(GL_ARRAY_BUFFER, 15, 1, 0); 148 expectError(GL_INVALID_VALUE); 149 glBufferSubData(GL_ARRAY_BUFFER, 1, 15, 0); 150 expectError(GL_INVALID_VALUE); 151 glBufferSubData(GL_ARRAY_BUFFER, 8, 8, 0); 152 expectError(GL_INVALID_VALUE); 153 m_log << TestLog::EndSection; 154 155 glDeleteBuffers(1, &buffer); 156 }); 157 ES3F_ADD_API_CASE(clear, "Invalid glClear() usage", 158 { 159 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if any bit other than the three defined bits is set in mask."); 160 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 161 expectError(GL_NO_ERROR); 162 glClear(0x00000200); 163 expectError(GL_INVALID_VALUE); 164 glClear(0x00001000); 165 expectError(GL_INVALID_VALUE); 166 glClear(0x00000010); 167 expectError(GL_INVALID_VALUE); 168 m_log << TestLog::EndSection; 169 }); 170 ES3F_ADD_API_CASE(read_pixels, "Invalid glReadPixels() usage", 171 { 172 std::vector<GLubyte> ubyteData(4); 173 174 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of format and type is unsupported."); 175 glReadPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ubyteData[0]); 176 expectError(GL_INVALID_OPERATION); 177 m_log << TestLog::EndSection; 178 179 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either width or height is negative."); 180 glReadPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]); 181 expectError(GL_INVALID_VALUE); 182 glReadPixels(0, 0, 1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]); 183 expectError(GL_INVALID_VALUE); 184 glReadPixels(0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]); 185 expectError(GL_INVALID_VALUE); 186 m_log << TestLog::EndSection; 187 188 m_log << TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete."); 189 GLuint fbo; 190 glGenFramebuffers(1, &fbo); 191 glBindFramebuffer(GL_FRAMEBUFFER, fbo); 192 glCheckFramebufferStatus(GL_FRAMEBUFFER); 193 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]); 194 expectError(GL_INVALID_FRAMEBUFFER_OPERATION); 195 m_log << TestLog::EndSection; 196 197 glDeleteFramebuffers(1, &fbo); 198 }); 199 ES3F_ADD_API_CASE(read_pixels_format_mismatch, "Invalid glReadPixels() usage", 200 { 201 std::vector<GLubyte> ubyteData(4); 202 std::vector<GLushort> ushortData(4); 203 204 m_log << TestLog::Section("", "Unsupported combinations of format and type will generate an INVALID_OPERATION error."); 205 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]); 206 expectError(GL_INVALID_OPERATION); 207 glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]); 208 expectError(GL_INVALID_OPERATION); 209 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]); 210 expectError(GL_INVALID_OPERATION); 211 glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]); 212 expectError(GL_INVALID_OPERATION); 213 glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]); 214 expectError(GL_INVALID_OPERATION); 215 glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]); 216 expectError(GL_INVALID_OPERATION); 217 m_log << TestLog::EndSection; 218 219 m_log << TestLog::Section("", "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."); 220 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]); 221 expectError(GL_NO_ERROR); 222 GLint readFormat; 223 GLint readType; 224 glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat); 225 glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType); 226 glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]); 227 expectError(GL_NO_ERROR); 228 m_log << TestLog::EndSection; 229 }); 230 ES3F_ADD_API_CASE(read_pixels_fbo_format_mismatch, "Invalid glReadPixels() usage", 231 { 232 std::vector<GLubyte> ubyteData(4); 233 std::vector<float> floatData(4); 234 deUint32 fbo; 235 deUint32 texture; 236 237 glGenTextures (1, &texture); 238 glBindTexture (GL_TEXTURE_2D, texture); 239 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 240 glGenFramebuffers (1, &fbo); 241 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 242 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 243 expectError (GL_NO_ERROR); 244 245 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if currently bound framebuffer format is incompatible with format and type."); 246 247 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 248 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 249 glCheckFramebufferStatus(GL_FRAMEBUFFER); 250 expectError (GL_NO_ERROR); 251 glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]); 252 expectError (GL_INVALID_OPERATION); 253 254 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL); 255 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 256 glCheckFramebufferStatus(GL_FRAMEBUFFER); 257 expectError (GL_NO_ERROR); 258 glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]); 259 expectError (GL_INVALID_OPERATION); 260 261 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL); 262 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 263 glCheckFramebufferStatus(GL_FRAMEBUFFER); 264 expectError (GL_NO_ERROR); 265 glReadPixels (0, 0, 1, 1, GL_RGBA, GL_FLOAT, &floatData[0]); 266 expectError (GL_INVALID_OPERATION); 267 268 m_log << TestLog::EndSection; 269 270 m_log << TestLog::Section("", "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."); 271 272 int binding = -1; 273 int sampleBuffers; 274 deUint32 rbo; 275 276 glGenRenderbuffers(1, &rbo); 277 glBindRenderbuffer(GL_RENDERBUFFER, rbo); 278 glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32); 279 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); 280 281 glGetIntegerv (GL_READ_FRAMEBUFFER_BINDING, &binding); 282 m_log << TestLog::Message << "// GL_READ_FRAMEBUFFER_BINDING: " << binding << TestLog::EndMessage; 283 glCheckFramebufferStatus(GL_FRAMEBUFFER); 284 glGetIntegerv (GL_SAMPLE_BUFFERS, &sampleBuffers); 285 m_log << TestLog::Message << "// GL_SAMPLE_BUFFERS: " << sampleBuffers << TestLog::EndMessage; 286 expectError (GL_NO_ERROR); 287 288 if (binding == 0 || sampleBuffers <= 0) 289 { 290 m_log << TestLog::Message << "// ERROR: expected GL_READ_FRAMEBUFFER_BINDING to be non-zero and GL_SAMPLE_BUFFERS to be greater than zero" << TestLog::EndMessage; 291 if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) 292 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value"); 293 } 294 else 295 { 296 glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]); 297 expectError (GL_INVALID_OPERATION); 298 } 299 300 m_log << TestLog::EndSection; 301 302 glBindRenderbuffer (GL_RENDERBUFFER, 0); 303 glBindTexture (GL_TEXTURE_2D, 0); 304 glBindFramebuffer (GL_FRAMEBUFFER, 0); 305 glDeleteFramebuffers (1, &fbo); 306 glDeleteTextures (1, &texture); 307 glDeleteRenderbuffers (1, &rbo); 308 }); 309 ES3F_ADD_API_CASE(bind_buffer_range, "Invalid glBindBufferRange() usage", 310 { 311 deUint32 bufU; 312 glGenBuffers(1, &bufU); 313 glBindBuffer(GL_UNIFORM_BUFFER, bufU); 314 glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW); 315 316 deUint32 bufTF; 317 glGenBuffers(1, &bufTF); 318 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF); 319 glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW); 320 321 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER."); 322 glBindBufferRange(GL_ARRAY_BUFFER, 0, bufU, 0, 4); 323 expectError(GL_INVALID_ENUM); 324 m_log << TestLog::EndSection; 325 326 m_log << TestLog::Section("", "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."); 327 int maxTFSize; 328 glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize); 329 glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF, 0, 4); 330 expectError(GL_INVALID_VALUE); 331 m_log << TestLog::EndSection; 332 333 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and index is greater than or equal to GL_MAX_UNIFORM_BUFFER_BINDINGS."); 334 int maxUSize; 335 glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize); 336 glBindBufferRange(GL_UNIFORM_BUFFER, maxUSize, bufU, 0, 4); 337 expectError(GL_INVALID_VALUE); 338 m_log << TestLog::EndSection; 339 340 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if size is less than or equal to zero."); 341 glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, -1); 342 expectError(GL_INVALID_VALUE); 343 glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, 0, 0); 344 expectError(GL_INVALID_VALUE); 345 m_log << TestLog::EndSection; 346 347 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if target is GL_TRANSFORM_FEEDBACK_BUFFER and size or offset are not multiples of 4."); 348 glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 4, 5); 349 expectError(GL_INVALID_VALUE); 350 glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 4); 351 expectError(GL_INVALID_VALUE); 352 glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufTF, 5, 7); 353 expectError(GL_INVALID_VALUE); 354 m_log << TestLog::EndSection; 355 356 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and offset is not a multiple of GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT."); 357 int alignment; 358 glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &alignment); 359 glBindBufferRange(GL_UNIFORM_BUFFER, 0, bufU, alignment+1, 4); 360 expectError(GL_INVALID_VALUE); 361 m_log << TestLog::EndSection; 362 363 glDeleteBuffers(1, &bufU); 364 glDeleteBuffers(1, &bufTF); 365 }); 366 ES3F_ADD_API_CASE(bind_buffer_base, "Invalid glBindBufferBase() usage", 367 { 368 deUint32 bufU; 369 glGenBuffers(1, &bufU); 370 glBindBuffer(GL_UNIFORM_BUFFER, bufU); 371 glBufferData(GL_UNIFORM_BUFFER, 16, NULL, GL_STREAM_DRAW); 372 373 deUint32 bufTF; 374 glGenBuffers(1, &bufTF); 375 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, bufTF); 376 glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_STREAM_DRAW); 377 expectError(GL_NO_ERROR); 378 379 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER."); 380 glBindBufferBase(-1, 0, bufU); 381 expectError(GL_INVALID_ENUM); 382 glBindBufferBase(GL_ARRAY_BUFFER, 0, bufU); 383 expectError(GL_INVALID_ENUM); 384 m_log << TestLog::EndSection; 385 386 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if target is GL_UNIFORM_BUFFER and index is greater than or equal to GL_MAX_UNIFORM_BUFFER_BINDINGS."); 387 int maxUSize; 388 glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUSize); 389 glBindBufferBase(GL_UNIFORM_BUFFER, maxUSize, bufU); 390 expectError(GL_INVALID_VALUE); 391 m_log << TestLog::EndSection; 392 393 m_log << TestLog::Section("", "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."); 394 int maxTFSize; 395 glGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTFSize); 396 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, maxTFSize, bufTF); 397 expectError(GL_INVALID_VALUE); 398 m_log << TestLog::EndSection; 399 400 glDeleteBuffers(1, &bufU); 401 glDeleteBuffers(1, &bufTF); 402 }); 403 ES3F_ADD_API_CASE(clear_bufferiv, "Invalid glClearBufferiv() usage", 404 { 405 std::vector<int> data(32*32); 406 deUint32 fbo; 407 deUint32 texture; 408 409 glGenTextures (1, &texture); 410 glBindTexture (GL_TEXTURE_2D, texture); 411 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL); 412 glGenFramebuffers (1, &fbo); 413 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 414 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 415 glCheckFramebufferStatus(GL_FRAMEBUFFER); 416 expectError (GL_NO_ERROR); 417 418 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if buffer is not an accepted value."); 419 glClearBufferiv(-1, 0, &data[0]); 420 expectError(GL_INVALID_ENUM); 421 glClearBufferiv(GL_FRAMEBUFFER, 0, &data[0]); 422 expectError(GL_INVALID_ENUM); 423 m_log << TestLog::EndSection; 424 425 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS."); 426 int maxDrawBuffers; 427 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); 428 glClearBufferiv(GL_COLOR, maxDrawBuffers, &data[0]); 429 expectError(GL_INVALID_VALUE); 430 m_log << TestLog::EndSection; 431 432 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if buffer is GL_DEPTH or GL_DEPTH_STENCIL."); 433 glClearBufferiv(GL_DEPTH, 1, &data[0]); 434 expectError(GL_INVALID_ENUM); 435 glClearBufferiv(GL_DEPTH_STENCIL, 1, &data[0]); 436 expectError(GL_INVALID_ENUM); 437 m_log << TestLog::EndSection; 438 439 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if buffer is GL_STENCIL and drawBuffer is not zero."); 440 glClearBufferiv(GL_STENCIL, 1, &data[0]); 441 expectError(GL_INVALID_VALUE); 442 m_log << TestLog::EndSection; 443 444 glDeleteFramebuffers(1, &fbo); 445 glDeleteTextures(1, &texture); 446 }); 447 ES3F_ADD_API_CASE(clear_bufferuiv, "Invalid glClearBufferuiv() usage", 448 { 449 std::vector<deUint32> data(32*32); 450 deUint32 fbo; 451 deUint32 texture; 452 453 glGenTextures (1, &texture); 454 glBindTexture (GL_TEXTURE_2D, texture); 455 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL); 456 glGenFramebuffers (1, &fbo); 457 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 458 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 459 glCheckFramebufferStatus(GL_FRAMEBUFFER); 460 expectError (GL_NO_ERROR); 461 462 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if buffer is not an accepted value."); 463 glClearBufferuiv(-1, 0, &data[0]); 464 expectError(GL_INVALID_ENUM); 465 glClearBufferuiv(GL_FRAMEBUFFER, 0, &data[0]); 466 expectError(GL_INVALID_ENUM); 467 m_log << TestLog::EndSection; 468 469 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS."); 470 int maxDrawBuffers; 471 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); 472 glClearBufferuiv(GL_COLOR, maxDrawBuffers, &data[0]); 473 expectError(GL_INVALID_VALUE); 474 m_log << TestLog::EndSection; 475 476 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if buffer is GL_DEPTH, GL_STENCIL or GL_DEPTH_STENCIL."); 477 glClearBufferuiv(GL_DEPTH, 1, &data[0]); 478 expectError(GL_INVALID_ENUM); 479 glClearBufferuiv(GL_STENCIL, 1, &data[0]); 480 expectError(GL_INVALID_ENUM); 481 glClearBufferuiv(GL_DEPTH_STENCIL, 1, &data[0]); 482 expectError(GL_INVALID_ENUM); 483 m_log << TestLog::EndSection; 484 485 glDeleteFramebuffers(1, &fbo); 486 glDeleteTextures(1, &texture); 487 }); 488 ES3F_ADD_API_CASE(clear_bufferfv, "Invalid glClearBufferfv() usage", 489 { 490 std::vector<float> data(32*32); 491 deUint32 fbo; 492 deUint32 texture; 493 494 glGenTextures (1, &texture); 495 glBindTexture (GL_TEXTURE_2D, texture); 496 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, NULL); 497 glGenFramebuffers (1, &fbo); 498 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 499 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 500 glCheckFramebufferStatus(GL_FRAMEBUFFER); 501 expectError (GL_NO_ERROR); 502 503 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if buffer is not an accepted value."); 504 glClearBufferfv(-1, 0, &data[0]); 505 expectError(GL_INVALID_ENUM); 506 glClearBufferfv(GL_FRAMEBUFFER, 0, &data[0]); 507 expectError(GL_INVALID_ENUM); 508 m_log << TestLog::EndSection; 509 510 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if buffer is GL_COLOR, GL_FRONT, GL_BACK, GL_LEFT, GL_RIGHT, or GL_FRONT_AND_BACK and drawBuffer is greater than or equal to GL_MAX_DRAW_BUFFERS."); 511 int maxDrawBuffers; 512 glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); 513 glClearBufferfv(GL_COLOR, maxDrawBuffers, &data[0]); 514 expectError(GL_INVALID_VALUE); 515 m_log << TestLog::EndSection; 516 517 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if buffer is GL_STENCIL or GL_DEPTH_STENCIL."); 518 glClearBufferfv(GL_STENCIL, 1, &data[0]); 519 expectError(GL_INVALID_ENUM); 520 glClearBufferfv(GL_DEPTH_STENCIL, 1, &data[0]); 521 expectError(GL_INVALID_ENUM); 522 m_log << TestLog::EndSection; 523 524 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if buffer is GL_DEPTH and drawBuffer is not zero."); 525 glClearBufferfv(GL_DEPTH, 1, &data[0]); 526 expectError(GL_INVALID_VALUE); 527 m_log << TestLog::EndSection; 528 529 glDeleteFramebuffers(1, &fbo); 530 glDeleteTextures(1, &texture); 531 }); 532 ES3F_ADD_API_CASE(clear_bufferfi, "Invalid glClearBufferfi() usage", 533 { 534 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if buffer is not an accepted value."); 535 glClearBufferfi(-1, 0, 1.0f, 1); 536 expectError(GL_INVALID_ENUM); 537 glClearBufferfi(GL_FRAMEBUFFER, 0, 1.0f, 1); 538 expectError(GL_INVALID_ENUM); 539 m_log << TestLog::EndSection; 540 541 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if buffer is not GL_DEPTH_STENCIL."); 542 glClearBufferfi(GL_DEPTH, 0, 1.0f, 1); 543 expectError(GL_INVALID_ENUM); 544 glClearBufferfi(GL_STENCIL, 0, 1.0f, 1); 545 expectError(GL_INVALID_ENUM); 546 glClearBufferfi(GL_COLOR, 0, 1.0f, 1); 547 expectError(GL_INVALID_ENUM); 548 m_log << TestLog::EndSection; 549 550 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if buffer is GL_DEPTH_STENCIL and drawBuffer is not zero."); 551 glClearBufferfi(GL_DEPTH_STENCIL, 1, 1.0f, 1); 552 expectError(GL_INVALID_VALUE); 553 m_log << TestLog::EndSection; 554 }); 555 ES3F_ADD_API_CASE(copy_buffer_sub_data, "Invalid glCopyBufferSubData() usage", 556 { 557 deUint32 buf[2]; 558 std::vector<float> data(32*32); 559 560 glGenBuffers (2, buf); 561 glBindBuffer (GL_COPY_READ_BUFFER, buf[0]); 562 glBufferData (GL_COPY_READ_BUFFER, 32, &data[0], GL_DYNAMIC_COPY); 563 glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]); 564 glBufferData (GL_COPY_WRITE_BUFFER, 32, &data[0], GL_DYNAMIC_COPY); 565 expectError (GL_NO_ERROR); 566 567 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if any of readoffset, writeoffset or size is negative."); 568 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, -4); 569 expectError (GL_INVALID_VALUE); 570 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, -1, 0, 4); 571 expectError (GL_INVALID_VALUE); 572 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, -1, 4); 573 expectError (GL_INVALID_VALUE); 574 m_log << TestLog::EndSection; 575 576 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if readoffset + size exceeds the size of the buffer object bound to readtarget."); 577 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36); 578 expectError (GL_INVALID_VALUE); 579 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 24, 0, 16); 580 expectError (GL_INVALID_VALUE); 581 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 36, 0, 4); 582 expectError (GL_INVALID_VALUE); 583 m_log << TestLog::EndSection; 584 585 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if writeoffset + size exceeds the size of the buffer object bound to writetarget."); 586 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 36); 587 expectError (GL_INVALID_VALUE); 588 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 24, 16); 589 expectError (GL_INVALID_VALUE); 590 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 36, 4); 591 expectError (GL_INVALID_VALUE); 592 m_log << TestLog::EndSection; 593 594 m_log << TestLog::Section("", "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."); 595 glBindBuffer (GL_COPY_WRITE_BUFFER, buf[0]); 596 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 4); 597 expectError (GL_NO_ERROR); 598 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 4); 599 expectError (GL_INVALID_VALUE); 600 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 16, 18); 601 expectError (GL_INVALID_VALUE); 602 glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]); 603 m_log << TestLog::EndSection; 604 605 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if zero is bound to readtarget or writetarget."); 606 glBindBuffer (GL_COPY_READ_BUFFER, 0); 607 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16); 608 expectError (GL_INVALID_OPERATION); 609 610 glBindBuffer (GL_COPY_READ_BUFFER, buf[0]); 611 glBindBuffer (GL_COPY_WRITE_BUFFER, 0); 612 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16); 613 expectError (GL_INVALID_OPERATION); 614 615 glBindBuffer (GL_COPY_WRITE_BUFFER, buf[1]); 616 m_log << TestLog::EndSection; 617 618 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the buffer object bound to either readtarget or writetarget is mapped."); 619 glMapBufferRange (GL_COPY_READ_BUFFER, 0, 4, GL_MAP_READ_BIT); 620 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16); 621 expectError (GL_INVALID_OPERATION); 622 glUnmapBuffer (GL_COPY_READ_BUFFER); 623 624 glMapBufferRange (GL_COPY_WRITE_BUFFER, 0, 4, GL_MAP_READ_BIT); 625 glCopyBufferSubData (GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, 16); 626 expectError (GL_INVALID_OPERATION); 627 glUnmapBuffer (GL_COPY_WRITE_BUFFER); 628 m_log << TestLog::EndSection; 629 630 glDeleteBuffers(2, buf); 631 }); 632 ES3F_ADD_API_CASE(draw_buffers, "Invalid glDrawBuffers() usage", 633 { 634 deUint32 fbo; 635 deUint32 texture; 636 int maxDrawBuffers; 637 glGetIntegerv (GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); 638 std::vector<deUint32> values(maxDrawBuffers+1); 639 values[0] = GL_NONE; 640 values[1] = GL_BACK; 641 values[2] = GL_COLOR_ATTACHMENT0; 642 values[3] = GL_DEPTH_ATTACHMENT; 643 std::vector<GLfloat> data(32*32); 644 645 glGenTextures (1, &texture); 646 glBindTexture (GL_TEXTURE_2D, texture); 647 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 648 glGenFramebuffers (1, &fbo); 649 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 650 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 651 glCheckFramebufferStatus(GL_FRAMEBUFFER); 652 expectError (GL_NO_ERROR); 653 654 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if one of the values in bufs is not an accepted value."); 655 glDrawBuffers (2, &values[2]); 656 expectError (GL_INVALID_ENUM); 657 m_log << TestLog::EndSection; 658 659 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the GL is bound to the default framebuffer and n is not 1."); 660 glBindFramebuffer (GL_FRAMEBUFFER, 0); 661 glDrawBuffers (2, &values[0]); 662 expectError (GL_INVALID_OPERATION); 663 m_log << TestLog::EndSection; 664 665 m_log << TestLog::Section("", "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."); 666 glBindFramebuffer (GL_FRAMEBUFFER, 0); 667 glDrawBuffers (1, &values[2]); 668 expectError (GL_INVALID_OPERATION); 669 m_log << TestLog::EndSection; 670 671 m_log << TestLog::Section("", "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."); 672 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 673 glDrawBuffers (1, &values[1]); 674 expectError (GL_INVALID_OPERATION); 675 m_log << TestLog::EndSection; 676 677 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is less than 0 or greater than GL_MAX_DRAW_BUFFERS."); 678 glDrawBuffers (-1, &values[1]); 679 expectError (GL_INVALID_VALUE); 680 glDrawBuffers (maxDrawBuffers+1, &values[0]); 681 expectError (GL_INVALID_VALUE); 682 m_log << TestLog::EndSection; 683 684 glDeleteTextures(1, &texture); 685 glDeleteFramebuffers(1, &fbo); 686 }); 687 ES3F_ADD_API_CASE(flush_mapped_buffer_range, "Invalid glFlushMappedBufferRange() usage", 688 { 689 deUint32 buf; 690 std::vector<GLfloat> data(32); 691 692 glGenBuffers (1, &buf); 693 glBindBuffer (GL_ARRAY_BUFFER, buf); 694 glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_STATIC_READ); 695 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); 696 expectError (GL_NO_ERROR); 697 698 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if offset or length is negative, or if offset + length exceeds the size of the mapping."); 699 glFlushMappedBufferRange(GL_ARRAY_BUFFER, -1, 1); 700 expectError (GL_INVALID_VALUE); 701 glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, -1); 702 expectError (GL_INVALID_VALUE); 703 glFlushMappedBufferRange(GL_ARRAY_BUFFER, 12, 8); 704 expectError (GL_INVALID_VALUE); 705 glFlushMappedBufferRange(GL_ARRAY_BUFFER, 24, 4); 706 expectError (GL_INVALID_VALUE); 707 glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 24); 708 expectError (GL_INVALID_VALUE); 709 m_log << TestLog::EndSection; 710 711 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if zero is bound to target."); 712 glBindBuffer (GL_ARRAY_BUFFER, 0); 713 glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8); 714 expectError (GL_INVALID_OPERATION); 715 m_log << TestLog::EndSection; 716 717 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the buffer bound to target is not mapped, or is mapped without the GL_MAP_FLUSH_EXPLICIT flag."); 718 glBindBuffer (GL_ARRAY_BUFFER, buf); 719 glUnmapBuffer (GL_ARRAY_BUFFER); 720 glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8); 721 expectError (GL_INVALID_OPERATION); 722 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT); 723 glFlushMappedBufferRange(GL_ARRAY_BUFFER, 0, 8); 724 expectError (GL_INVALID_OPERATION); 725 m_log << TestLog::EndSection; 726 727 glUnmapBuffer (GL_ARRAY_BUFFER); 728 glDeleteBuffers (1, &buf); 729 }); 730 ES3F_ADD_API_CASE(map_buffer_range, "Invalid glMapBufferRange() usage", 731 { 732 deUint32 buf; 733 std::vector<GLfloat> data(32); 734 735 glGenBuffers (1, &buf); 736 glBindBuffer (GL_ARRAY_BUFFER, buf); 737 glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY); 738 expectError (GL_NO_ERROR); 739 740 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either of offset or length is negative."); 741 glMapBufferRange (GL_ARRAY_BUFFER, -1, 1, GL_MAP_READ_BIT); 742 expectError (GL_INVALID_VALUE); 743 744 glMapBufferRange (GL_ARRAY_BUFFER, 1, -1, GL_MAP_READ_BIT); 745 expectError (GL_INVALID_VALUE); 746 m_log << TestLog::EndSection; 747 748 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if offset + length is greater than the value of GL_BUFFER_SIZE."); 749 glMapBufferRange (GL_ARRAY_BUFFER, 0, 33, GL_MAP_READ_BIT); 750 expectError (GL_INVALID_VALUE); 751 752 glMapBufferRange (GL_ARRAY_BUFFER, 32, 1, GL_MAP_READ_BIT); 753 expectError (GL_INVALID_VALUE); 754 755 glMapBufferRange (GL_ARRAY_BUFFER, 16, 17, GL_MAP_READ_BIT); 756 expectError (GL_INVALID_VALUE); 757 m_log << TestLog::EndSection; 758 759 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if access has any bits set other than those accepted."); 760 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | 0x1000); 761 expectError (GL_INVALID_VALUE); 762 763 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT | 0x1000); 764 expectError (GL_INVALID_VALUE); 765 m_log << TestLog::EndSection; 766 767 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the buffer is already in a mapped state."); 768 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_WRITE_BIT); 769 expectError (GL_NO_ERROR); 770 glMapBufferRange (GL_ARRAY_BUFFER, 16, 8, GL_MAP_READ_BIT); 771 expectError (GL_INVALID_OPERATION); 772 glUnmapBuffer (GL_ARRAY_BUFFER); 773 m_log << TestLog::EndSection; 774 775 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set."); 776 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT); 777 expectError (GL_INVALID_OPERATION); 778 m_log << TestLog::EndSection; 779 780 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if "); 781 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_INVALIDATE_RANGE_BIT); 782 expectError (GL_INVALID_OPERATION); 783 m_log << TestLog::EndSection; 784 785 m_log << TestLog::Section("", "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."); 786 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_RANGE_BIT); 787 expectError (GL_INVALID_OPERATION); 788 789 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); 790 expectError (GL_INVALID_OPERATION); 791 792 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT); 793 expectError (GL_INVALID_OPERATION); 794 m_log << TestLog::EndSection; 795 796 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set."); 797 glMapBufferRange (GL_ARRAY_BUFFER, 0, 16, GL_MAP_READ_BIT | GL_MAP_FLUSH_EXPLICIT_BIT); 798 expectError (GL_INVALID_OPERATION); 799 m_log << TestLog::EndSection; 800 801 glDeleteBuffers (1, &buf); 802 }); 803 ES3F_ADD_API_CASE(read_buffer, "Invalid glReadBuffer() usage", 804 { 805 deUint32 fbo; 806 deUint32 texture; 807 int maxColorAttachments; 808 809 glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments); 810 glGenTextures (1, &texture); 811 glBindTexture (GL_TEXTURE_2D, texture); 812 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 813 glGenFramebuffers (1, &fbo); 814 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 815 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 816 glCheckFramebufferStatus(GL_FRAMEBUFFER); 817 expectError (GL_NO_ERROR); 818 819 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if mode is not GL_BACK, GL_NONE, or GL_COLOR_ATTACHMENTi."); 820 glReadBuffer (GL_NONE); 821 expectError (GL_NO_ERROR); 822 glReadBuffer (1); 823 expectError (GL_INVALID_ENUM); 824 glReadBuffer (GL_FRAMEBUFFER); 825 expectError (GL_INVALID_ENUM); 826 glReadBuffer (GL_COLOR_ATTACHMENT0 - 1); 827 expectError (GL_INVALID_ENUM); 828 glReadBuffer (GL_FRONT); 829 expectError (GL_INVALID_ENUM); 830 831 // \ note Spec isn't actually clear here, but it is safe to assume that 832 // GL_DEPTH_ATTACHMENT can't be interpreted as GL_COLOR_ATTACHMENTm 833 // where m = (GL_DEPTH_ATTACHMENT - GL_COLOR_ATTACHMENT0). 834 glReadBuffer (GL_DEPTH_ATTACHMENT); 835 expectError (GL_INVALID_ENUM); 836 glReadBuffer (GL_STENCIL_ATTACHMENT); 837 expectError (GL_INVALID_ENUM); 838 glReadBuffer (GL_STENCIL_ATTACHMENT+1); 839 expectError (GL_INVALID_ENUM); 840 glReadBuffer (0xffffffffu); 841 expectError (GL_INVALID_ENUM); 842 m_log << TestLog::EndSection; 843 844 m_log << TestLog::Section("", "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."); 845 glReadBuffer (GL_BACK); 846 expectError (GL_INVALID_OPERATION); 847 glReadBuffer (GL_COLOR_ATTACHMENT0 + maxColorAttachments); 848 expectError (GL_INVALID_OPERATION); 849 850 if (GL_COLOR_ATTACHMENT0+maxColorAttachments < GL_DEPTH_ATTACHMENT-1) 851 { 852 glReadBuffer (GL_DEPTH_ATTACHMENT - 1); 853 expectError (GL_INVALID_OPERATION); 854 } 855 856 m_log << TestLog::EndSection; 857 858 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the current framebuffer is the default framebuffer and mode is not GL_NONE or GL_BACK."); 859 glBindFramebuffer (GL_FRAMEBUFFER, 0); 860 glReadBuffer (GL_COLOR_ATTACHMENT0); 861 expectError (GL_INVALID_OPERATION); 862 m_log << TestLog::EndSection; 863 864 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the current framebuffer is a named framebuffer and mode is not GL_NONE or GL_COLOR_ATTACHMENTi."); 865 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 866 glReadBuffer (GL_BACK); 867 expectError (GL_INVALID_OPERATION); 868 m_log << TestLog::EndSection; 869 870 glDeleteTextures(1, &texture); 871 glDeleteFramebuffers(1, &fbo); 872 }); 873 ES3F_ADD_API_CASE(unmap_buffer, "Invalid glUnmapBuffer() usage", 874 { 875 deUint32 buf; 876 std::vector<GLfloat> data(32); 877 878 glGenBuffers (1, &buf); 879 glBindBuffer (GL_ARRAY_BUFFER, buf); 880 glBufferData (GL_ARRAY_BUFFER, 32, &data[0], GL_DYNAMIC_COPY); 881 expectError (GL_NO_ERROR); 882 883 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the buffer data store is already in an unmapped state."); 884 glUnmapBuffer (GL_ARRAY_BUFFER); 885 expectError (GL_INVALID_OPERATION); 886 m_log << TestLog::EndSection; 887 888 glDeleteBuffers (1, &buf); 889 }); 890 // Framebuffer Objects 891 892 ES3F_ADD_API_CASE(bind_framebuffer, "Invalid glBindFramebuffer() usage", 893 { 894 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER."); 895 glBindFramebuffer(-1, 0); 896 expectError(GL_INVALID_ENUM); 897 glBindFramebuffer(GL_RENDERBUFFER, 0); 898 expectError(GL_INVALID_ENUM); 899 m_log << TestLog::EndSection; 900 }); 901 ES3F_ADD_API_CASE(bind_renderbuffer, "Invalid glBindRenderbuffer() usage", 902 { 903 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER."); 904 glBindRenderbuffer(-1, 0); 905 expectError(GL_INVALID_ENUM); 906 glBindRenderbuffer(GL_FRAMEBUFFER, 0); 907 expectError(GL_INVALID_ENUM); 908 m_log << TestLog::EndSection; 909 }); 910 ES3F_ADD_API_CASE(check_framebuffer_status, "Invalid glCheckFramebufferStatus() usage", 911 { 912 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER."); 913 glCheckFramebufferStatus(-1); 914 expectError(GL_INVALID_ENUM); 915 glCheckFramebufferStatus(GL_RENDERBUFFER); 916 expectError(GL_INVALID_ENUM); 917 m_log << TestLog::EndSection; 918 }); 919 ES3F_ADD_API_CASE(gen_framebuffers, "Invalid glGenFramebuffers() usage", 920 { 921 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative."); 922 glGenFramebuffers(-1, 0); 923 expectError(GL_INVALID_VALUE); 924 m_log << TestLog::EndSection; 925 }); 926 ES3F_ADD_API_CASE(gen_renderbuffers, "Invalid glGenRenderbuffers() usage", 927 { 928 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative."); 929 glGenRenderbuffers(-1, 0); 930 expectError(GL_INVALID_VALUE); 931 m_log << TestLog::EndSection; 932 }); 933 ES3F_ADD_API_CASE(delete_framebuffers, "Invalid glDeleteFramebuffers() usage", 934 { 935 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative."); 936 glDeleteFramebuffers(-1, 0); 937 expectError(GL_INVALID_VALUE); 938 m_log << TestLog::EndSection; 939 }); 940 ES3F_ADD_API_CASE(delete_renderbuffers, "Invalid glDeleteRenderbuffers() usage", 941 {; 942 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative."); 943 glDeleteRenderbuffers(-1, 0); 944 expectError(GL_INVALID_VALUE); 945 m_log << TestLog::EndSection; 946 }); 947 ES3F_ADD_API_CASE(framebuffer_renderbuffer, "Invalid glFramebufferRenderbuffer() usage", 948 { 949 GLuint fbo; 950 GLuint rbo; 951 glGenFramebuffers(1, &fbo); 952 glBindFramebuffer(GL_FRAMEBUFFER, fbo); 953 glGenRenderbuffers(1, &rbo); 954 955 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted tokens."); 956 glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0); 957 expectError(GL_INVALID_ENUM); 958 m_log << TestLog::EndSection; 959 960 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER."); 961 glBindRenderbuffer(GL_RENDERBUFFER, rbo); 962 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo); 963 expectError(GL_INVALID_ENUM); 964 glBindRenderbuffer(GL_RENDERBUFFER, 0); 965 m_log << TestLog::EndSection; 966 967 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object."); 968 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1); 969 expectError(GL_INVALID_OPERATION); 970 m_log << TestLog::EndSection; 971 972 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if zero is bound to target."); 973 glBindFramebuffer(GL_FRAMEBUFFER, 0); 974 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0); 975 expectError(GL_INVALID_OPERATION); 976 m_log << TestLog::EndSection; 977 978 glDeleteRenderbuffers(1, &rbo); 979 glDeleteFramebuffers(1, &fbo); 980 }); 981 ES3F_ADD_API_CASE(framebuffer_texture2d, "Invalid glFramebufferTexture2D() usage", 982 { 983 GLuint fbo; 984 GLuint tex2D; 985 GLuint texCube; 986 glGenFramebuffers(1, &fbo); 987 glBindFramebuffer(GL_FRAMEBUFFER, fbo); 988 glGenTextures(1, &tex2D); 989 glBindTexture(GL_TEXTURE_2D, tex2D); 990 glGenTextures(1, &texCube); 991 glBindTexture(GL_TEXTURE_CUBE_MAP, texCube); 992 expectError(GL_NO_ERROR); 993 994 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted tokens."); 995 glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); 996 expectError(GL_INVALID_ENUM); 997 m_log << TestLog::EndSection; 998 999 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if textarget is not an accepted texture target."); 1000 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0); 1001 expectError(GL_INVALID_ENUM); 1002 m_log << TestLog::EndSection; 1003 1004 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is less than 0 or larger than log_2 of maximum texture size."); 1005 int maxSize; 1006 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, -1); 1007 expectError(GL_INVALID_VALUE); 1008 maxSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_TEXTURE_SIZE)) + 1; 1009 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, maxSize); 1010 expectError(GL_INVALID_VALUE); 1011 maxSize = deLog2Floor32(m_context.getContextInfo().getInt(GL_MAX_CUBE_MAP_TEXTURE_SIZE)) + 1; 1012 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, maxSize); 1013 expectError(GL_INVALID_VALUE); 1014 m_log << TestLog::EndSection; 1015 1016 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object."); 1017 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0); 1018 expectError(GL_INVALID_OPERATION); 1019 m_log << TestLog::EndSection; 1020 1021 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if textarget and texture are not compatible."); 1022 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0); 1023 expectError(GL_INVALID_OPERATION); 1024 glDeleteTextures(1, &tex2D); 1025 1026 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0); 1027 expectError(GL_INVALID_OPERATION); 1028 glDeleteTextures(1, &texCube); 1029 m_log << TestLog::EndSection; 1030 1031 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if zero is bound to target."); 1032 glBindFramebuffer(GL_FRAMEBUFFER, 0); 1033 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); 1034 expectError(GL_INVALID_OPERATION); 1035 m_log << TestLog::EndSection; 1036 1037 glDeleteFramebuffers(1, &fbo); 1038 }); 1039 ES3F_ADD_API_CASE(renderbuffer_storage, "Invalid glRenderbufferStorage() usage", 1040 { 1041 deUint32 rbo; 1042 glGenRenderbuffers (1, &rbo); 1043 glBindRenderbuffer (GL_RENDERBUFFER, rbo); 1044 1045 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER."); 1046 glRenderbufferStorage (-1, GL_RGBA4, 1, 1); 1047 expectError (GL_INVALID_ENUM); 1048 glRenderbufferStorage (GL_FRAMEBUFFER, GL_RGBA4, 1, 1); 1049 expectError (GL_INVALID_ENUM); 1050 m_log << TestLog::EndSection; 1051 1052 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format."); 1053 glRenderbufferStorage (GL_RENDERBUFFER, -1, 1, 1); 1054 expectError (GL_INVALID_ENUM); 1055 1056 if (!m_context.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error 1057 { 1058 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGB16F, 1, 1); 1059 expectError (GL_INVALID_ENUM); 1060 } 1061 1062 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8_SNORM, 1, 1); 1063 expectError (GL_INVALID_ENUM); 1064 m_log << TestLog::EndSection; 1065 1066 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than zero."); 1067 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, 1); 1068 expectError (GL_INVALID_VALUE); 1069 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, -1); 1070 expectError (GL_INVALID_VALUE); 1071 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, -1, -1); 1072 expectError (GL_INVALID_VALUE); 1073 m_log << TestLog::EndSection; 1074 1075 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE."); 1076 GLint maxSize; 1077 glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize); 1078 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1); 1079 expectError (GL_INVALID_VALUE); 1080 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1); 1081 expectError (GL_INVALID_VALUE); 1082 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1); 1083 expectError (GL_INVALID_VALUE); 1084 m_log << TestLog::EndSection; 1085 1086 glDeleteRenderbuffers(1, &rbo); 1087 }); 1088 ES3F_ADD_API_CASE(blit_framebuffer, "Invalid glBlitFramebuffer() usage", 1089 { 1090 deUint32 fbo[2]; 1091 deUint32 rbo[2]; 1092 deUint32 texture[2]; 1093 1094 glGenFramebuffers (2, fbo); 1095 glGenTextures (2, texture); 1096 glGenRenderbuffers (2, rbo); 1097 1098 glBindTexture (GL_TEXTURE_2D, texture[0]); 1099 glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]); 1100 glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]); 1101 1102 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1103 glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32); 1104 glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0); 1105 glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]); 1106 glCheckFramebufferStatus(GL_READ_FRAMEBUFFER); 1107 1108 glBindTexture (GL_TEXTURE_2D, texture[1]); 1109 glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]); 1110 glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]); 1111 1112 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1113 glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 32, 32); 1114 glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0); 1115 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]); 1116 glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER); 1117 expectError (GL_NO_ERROR); 1118 1119 m_log << TestLog::Section("", "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."); 1120 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR); 1121 expectError (GL_INVALID_OPERATION); 1122 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_LINEAR); 1123 expectError (GL_INVALID_OPERATION); 1124 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_LINEAR); 1125 expectError (GL_INVALID_OPERATION); 1126 m_log << TestLog::EndSection; 1127 1128 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT and read buffer format is incompatible with draw buffer format."); 1129 glBindTexture (GL_TEXTURE_2D, texture[0]); 1130 1131 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL); 1132 glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0); 1133 m_log << TestLog::Message << "// Read buffer: GL_RGBA32UI, draw buffer: GL_RGBA" << TestLog::EndMessage; 1134 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST); 1135 expectError (GL_INVALID_OPERATION); 1136 1137 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL); 1138 glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0); 1139 m_log << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA" << TestLog::EndMessage; 1140 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST); 1141 expectError (GL_INVALID_OPERATION); 1142 1143 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1144 glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0); 1145 glBindTexture (GL_TEXTURE_2D, texture[1]); 1146 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32I, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, NULL); 1147 glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0); 1148 m_log << TestLog::Message << "// Read buffer: GL_RGBA8, draw buffer: GL_RGBA32I" << TestLog::EndMessage; 1149 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST); 1150 expectError (GL_INVALID_OPERATION); 1151 m_log << TestLog::EndSection; 1152 1153 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if filter is GL_LINEAR and the read buffer contains integer data."); 1154 glBindTexture (GL_TEXTURE_2D, texture[0]); 1155 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL); 1156 glFramebufferTexture2D (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[0], 0); 1157 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1158 glFramebufferTexture2D (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture[1], 0); 1159 m_log << TestLog::Message << "// Read buffer: GL_RGBA32I, draw buffer: GL_RGBA8" << TestLog::EndMessage; 1160 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_LINEAR); 1161 expectError (GL_INVALID_OPERATION); 1162 m_log << TestLog::EndSection; 1163 1164 m_log << TestLog::Section("", "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."); 1165 glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]); 1166 glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH32F_STENCIL8, 32, 32); 1167 glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[0]); 1168 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_DEPTH_BUFFER_BIT, GL_NEAREST); 1169 expectError (GL_INVALID_OPERATION); 1170 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_STENCIL_BUFFER_BIT, GL_NEAREST); 1171 expectError (GL_INVALID_OPERATION); 1172 m_log << TestLog::EndSection; 1173 1174 glBindFramebuffer (GL_FRAMEBUFFER, 0); 1175 glDeleteFramebuffers (2, fbo); 1176 glDeleteTextures (2, texture); 1177 glDeleteRenderbuffers (2, rbo); 1178 }); 1179 ES3F_ADD_API_CASE(blit_framebuffer_multisample, "Invalid glBlitFramebuffer() usage", 1180 { 1181 deUint32 fbo[2]; 1182 deUint32 rbo[2]; 1183 1184 glGenFramebuffers (2, fbo); 1185 glGenRenderbuffers (2, rbo); 1186 1187 glBindRenderbuffer (GL_RENDERBUFFER, rbo[0]); 1188 glBindFramebuffer (GL_READ_FRAMEBUFFER, fbo[0]); 1189 glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32); 1190 glFramebufferRenderbuffer (GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]); 1191 glCheckFramebufferStatus (GL_READ_FRAMEBUFFER); 1192 1193 glBindRenderbuffer (GL_RENDERBUFFER, rbo[1]); 1194 glBindFramebuffer (GL_DRAW_FRAMEBUFFER, fbo[1]); 1195 1196 expectError (GL_NO_ERROR); 1197 1198 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the value of GL_SAMPLE_BUFFERS for the draw buffer is greater than zero."); 1199 glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, 32, 32); 1200 glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]); 1201 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST); 1202 expectError (GL_INVALID_OPERATION); 1203 m_log << TestLog::EndSection; 1204 1205 m_log << TestLog::Section("", "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."); 1206 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA4, 32, 32); 1207 glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]); 1208 glBlitFramebuffer (0, 0, 16, 16, 0, 0, 16, 16, GL_COLOR_BUFFER_BIT, GL_NEAREST); 1209 expectError (GL_INVALID_OPERATION); 1210 m_log << TestLog::EndSection; 1211 1212 m_log << TestLog::Section("", "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."); 1213 glRenderbufferStorage (GL_RENDERBUFFER, GL_RGBA8, 32, 32); 1214 glFramebufferRenderbuffer (GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[1]); 1215 glBlitFramebuffer (0, 0, 16, 16, 2, 2, 18, 18, GL_COLOR_BUFFER_BIT, GL_NEAREST); 1216 expectError (GL_INVALID_OPERATION); 1217 m_log << TestLog::EndSection; 1218 1219 glBindFramebuffer (GL_FRAMEBUFFER, 0); 1220 glDeleteRenderbuffers (2, rbo); 1221 glDeleteFramebuffers (2, fbo); 1222 }); 1223 ES3F_ADD_API_CASE(framebuffer_texture_layer, "Invalid glFramebufferTextureLayer() usage", 1224 { 1225 deUint32 fbo; 1226 deUint32 tex3D; 1227 deUint32 tex2DArray; 1228 deUint32 tex2D; 1229 1230 glGenFramebuffers (1, &fbo); 1231 glGenTextures (1, &tex3D); 1232 glGenTextures (1, &tex2DArray); 1233 glGenTextures (1, &tex2D); 1234 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 1235 1236 glBindTexture (GL_TEXTURE_3D, tex3D); 1237 glTexImage3D (GL_TEXTURE_3D, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1238 glBindTexture (GL_TEXTURE_2D_ARRAY, tex2DArray); 1239 glTexImage3D (GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1240 glBindTexture (GL_TEXTURE_2D, tex2D); 1241 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1242 1243 expectError (GL_NO_ERROR); 1244 1245 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the accepted tokens."); 1246 glFramebufferTextureLayer (-1, GL_COLOR_ATTACHMENT0, tex3D, 0, 1); 1247 expectError (GL_INVALID_ENUM); 1248 glFramebufferTextureLayer (GL_RENDERBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1); 1249 expectError (GL_INVALID_ENUM); 1250 m_log << TestLog::EndSection; 1251 1252 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if attachment is not one of the accepted tokens."); 1253 glFramebufferTextureLayer (GL_FRAMEBUFFER, -1, tex3D, 0, 1); 1254 expectError (GL_INVALID_ENUM); 1255 glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_BACK, tex3D, 0, 1); 1256 expectError (GL_INVALID_ENUM); 1257 m_log << TestLog::EndSection; 1258 1259 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if texture is non-zero and not the name of a 3D texture or 2D array texture."); 1260 glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, 0, 0); 1261 expectError (GL_INVALID_OPERATION); 1262 glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2D, 0, 0); 1263 expectError (GL_INVALID_OPERATION); 1264 m_log << TestLog::EndSection; 1265 1266 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if texture is not zero and layer is negative."); 1267 glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, -1); 1268 expectError (GL_INVALID_VALUE); 1269 m_log << TestLog::EndSection; 1270 1271 m_log << TestLog::Section("", "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."); 1272 int max3DTexSize; 1273 glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE, &max3DTexSize); 1274 glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, max3DTexSize); 1275 expectError (GL_INVALID_VALUE); 1276 m_log << TestLog::EndSection; 1277 1278 m_log << TestLog::Section("", "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."); 1279 int maxArrayTexLayers; 1280 glGetIntegerv (GL_MAX_ARRAY_TEXTURE_LAYERS, &maxArrayTexLayers); 1281 glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex2DArray, 0, maxArrayTexLayers); 1282 expectError (GL_INVALID_VALUE); 1283 m_log << TestLog::EndSection; 1284 1285 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if zero is bound to target."); 1286 glBindFramebuffer (GL_FRAMEBUFFER, 0); 1287 glFramebufferTextureLayer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex3D, 0, 1); 1288 expectError (GL_INVALID_OPERATION); 1289 m_log << TestLog::EndSection; 1290 1291 glDeleteTextures (1, &tex3D); 1292 glDeleteTextures (1, &tex2DArray); 1293 glDeleteTextures (1, &tex2D); 1294 glDeleteFramebuffers (1, &fbo); 1295 }); 1296 ES3F_ADD_API_CASE(invalidate_framebuffer, "Invalid glInvalidateFramebuffer() usage", 1297 { 1298 deUint32 fbo; 1299 deUint32 texture; 1300 deUint32 attachments[2]; 1301 int maxColorAttachments; 1302 glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments); 1303 attachments[0] = GL_COLOR_ATTACHMENT0; 1304 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments; 1305 1306 glGenFramebuffers (1, &fbo); 1307 glGenTextures (1, &texture); 1308 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 1309 glBindTexture (GL_TEXTURE_2D, texture); 1310 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1311 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 1312 glCheckFramebufferStatus (GL_FRAMEBUFFER); 1313 expectError (GL_NO_ERROR); 1314 1315 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER."); 1316 glInvalidateFramebuffer (-1, 1, &attachments[0]); 1317 expectError (GL_INVALID_ENUM); 1318 glInvalidateFramebuffer (GL_BACK, 1, &attachments[0]); 1319 expectError (GL_INVALID_ENUM); 1320 m_log << TestLog::EndSection; 1321 1322 m_log << TestLog::Section("", "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."); 1323 glInvalidateFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1]); 1324 expectError (GL_INVALID_OPERATION); 1325 m_log << TestLog::EndSection; 1326 1327 glDeleteTextures (1, &texture); 1328 glDeleteFramebuffers (1, &fbo); 1329 }); 1330 ES3F_ADD_API_CASE(invalidate_sub_framebuffer, "Invalid glInvalidateSubFramebuffer() usage", 1331 { 1332 deUint32 fbo; 1333 deUint32 texture; 1334 deUint32 attachments[2]; 1335 int maxColorAttachments; 1336 glGetIntegerv (GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments); 1337 attachments[0] = GL_COLOR_ATTACHMENT0; 1338 attachments[1] = GL_COLOR_ATTACHMENT0 + maxColorAttachments; 1339 1340 glGenFramebuffers (1, &fbo); 1341 glGenTextures (1, &texture); 1342 glBindFramebuffer (GL_FRAMEBUFFER, fbo); 1343 glBindTexture (GL_TEXTURE_2D, texture); 1344 glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1345 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); 1346 glCheckFramebufferStatus (GL_FRAMEBUFFER); 1347 expectError (GL_NO_ERROR); 1348 1349 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER, GL_READ_FRAMEBUFFER or GL_DRAW_FRAMEBUFFER."); 1350 glInvalidateSubFramebuffer (-1, 1, &attachments[0], 0, 0, 16, 16); 1351 expectError (GL_INVALID_ENUM); 1352 glInvalidateSubFramebuffer (GL_BACK, 1, &attachments[0], 0, 0, 16, 16); 1353 expectError (GL_INVALID_ENUM); 1354 m_log << TestLog::EndSection; 1355 1356 m_log << TestLog::Section("", "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."); 1357 glInvalidateSubFramebuffer (GL_FRAMEBUFFER, 1, &attachments[1], 0, 0, 16, 16); 1358 expectError (GL_INVALID_OPERATION); 1359 m_log << TestLog::EndSection; 1360 1361 glDeleteTextures (1, &texture); 1362 glDeleteFramebuffers (1, &fbo); 1363 }); 1364 ES3F_ADD_API_CASE(renderbuffer_storage_multisample, "Invalid glRenderbufferStorageMultisample() usage", 1365 { 1366 deUint32 rbo; 1367 int maxSamplesSupportedRGBA4 = -1; 1368 1369 glGetInternalformativ (GL_RENDERBUFFER, GL_RGBA4, GL_SAMPLES, 1, &maxSamplesSupportedRGBA4); 1370 glGenRenderbuffers (1, &rbo); 1371 glBindRenderbuffer (GL_RENDERBUFFER, rbo); 1372 1373 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER."); 1374 glRenderbufferStorageMultisample (-1, 2, GL_RGBA4, 1, 1); 1375 expectError (GL_INVALID_ENUM); 1376 glRenderbufferStorageMultisample (GL_FRAMEBUFFER, 2, GL_RGBA4, 1, 1); 1377 expectError (GL_INVALID_ENUM); 1378 m_log << TestLog::EndSection; 1379 1380 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if samples is greater than the maximum number of samples supported for internalformat."); 1381 glRenderbufferStorageMultisample (GL_RENDERBUFFER, maxSamplesSupportedRGBA4+1, GL_RGBA4, 1, 1); 1382 expectError (GL_INVALID_OPERATION); 1383 m_log << TestLog::EndSection; 1384 1385 m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not a color-renderable, depth-renderable, or stencil-renderable format."); 1386 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, -1, 1, 1); 1387 expectError (GL_INVALID_ENUM); 1388 1389 if (!m_context.getContextInfo().isExtensionSupported("GL_EXT_color_buffer_half_float")) // GL_EXT_color_buffer_half_float disables error 1390 { 1391 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGB16F, 1, 1); 1392 expectError (GL_INVALID_ENUM); 1393 } 1394 1395 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA8_SNORM, 1, 1); 1396 expectError (GL_INVALID_ENUM); 1397 m_log << TestLog::EndSection; 1398 1399 m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if internalformat is a signed or unsigned integer format and samples is greater than 0."); 1400 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 1, GL_RGBA8UI, 1, 1); 1401 expectError (GL_INVALID_OPERATION); 1402 m_log << TestLog::EndSection; 1403 1404 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than zero."); 1405 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, 1); 1406 expectError (GL_INVALID_VALUE); 1407 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, 1, -1); 1408 expectError (GL_INVALID_VALUE); 1409 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 2, GL_RGBA4, -1, -1); 1410 expectError (GL_INVALID_VALUE); 1411 m_log << TestLog::EndSection; 1412 1413 m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE."); 1414 GLint maxSize; 1415 glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE, &maxSize); 1416 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, 1, maxSize+1); 1417 expectError (GL_INVALID_VALUE); 1418 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, 1); 1419 expectError (GL_INVALID_VALUE); 1420 glRenderbufferStorageMultisample (GL_RENDERBUFFER, 4, GL_RGBA4, maxSize+1, maxSize+1); 1421 expectError (GL_INVALID_VALUE); 1422 m_log << TestLog::EndSection; 1423 1424 glDeleteRenderbuffers(1, &rbo); 1425 }); 1426 } 1427 1428 } // Functional 1429 } // gles3 1430 } // deqp 1431