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 Shader API tests. 22 *//*--------------------------------------------------------------------*/ 23 24 #include "es31fNegativeShaderApiTests.hpp" 25 26 #include "deUniquePtr.hpp" 27 28 #include "glwDefs.hpp" 29 #include "glwEnums.hpp" 30 31 #include "gluShaderProgram.hpp" 32 #include "gluCallLogWrapper.hpp" 33 34 35 36 namespace deqp 37 { 38 namespace gles31 39 { 40 namespace Functional 41 { 42 namespace NegativeTestShared 43 { 44 using tcu::TestLog; 45 using glu::CallLogWrapper; 46 using namespace glw; 47 48 static const char* vertexShaderSource = "#version 300 es\n" 49 "void main (void)\n" 50 "{\n" 51 " gl_Position = vec4(0.0);\n" 52 "}\n\0"; 53 54 static const char* fragmentShaderSource = "#version 300 es\n" 55 "layout(location = 0) out mediump vec4 fragColor;" 56 "void main (void)\n" 57 "{\n" 58 " fragColor = vec4(0.0);\n" 59 "}\n\0"; 60 61 static const char* uniformTestVertSource = "#version 300 es\n" 62 "uniform mediump vec4 vec4_v;\n" 63 "uniform mediump mat4 mat4_v;\n" 64 "void main (void)\n" 65 "{\n" 66 " gl_Position = mat4_v * vec4_v;\n" 67 "}\n\0"; 68 69 static const char* uniformTestFragSource = "#version 300 es\n" 70 "uniform mediump ivec4 ivec4_f;\n" 71 "uniform mediump uvec4 uvec4_f;\n" 72 "uniform sampler2D sampler_f;\n" 73 "layout(location = 0) out mediump vec4 fragColor;" 74 "void main (void)\n" 75 "{\n" 76 " fragColor.xy = (vec4(uvec4_f) + vec4(ivec4_f)).xy;\n" 77 " fragColor.zw = texture(sampler_f, vec2(0.0, 0.0)).zw;\n" 78 "}\n\0"; 79 80 static const char* uniformBlockVertSource = "#version 300 es\n" 81 "layout(shared) uniform Block { lowp float var; };\n" 82 "void main (void)\n" 83 "{\n" 84 " gl_Position = vec4(var);\n" 85 "}\n\0"; 86 87 88 // Shader control commands 89 void create_shader (NegativeTestContext& ctx) 90 { 91 ctx.beginSection("GL_INVALID_ENUM is generated if shaderType is not an accepted value."); 92 ctx.glCreateShader(-1); 93 ctx.expectError(GL_INVALID_ENUM); 94 ctx.endSection(); 95 } 96 97 void shader_source (NegativeTestContext& ctx) 98 { 99 // \note Shader compilation must be supported. 100 101 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); 102 ctx.glShaderSource(1, 0, 0, 0); 103 ctx.expectError(GL_INVALID_VALUE); 104 ctx.endSection(); 105 106 ctx.beginSection("GL_INVALID_VALUE is generated if count is less than 0."); 107 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 108 ctx.glShaderSource(shader, -1, 0, 0); 109 ctx.expectError(GL_INVALID_VALUE); 110 ctx.endSection(); 111 112 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object."); 113 GLuint program = ctx.glCreateProgram(); 114 ctx.glShaderSource(program, 0, 0, 0); 115 ctx.expectError(GL_INVALID_OPERATION); 116 ctx.endSection(); 117 118 ctx.glDeleteProgram(program); 119 ctx.glDeleteShader(shader); 120 } 121 122 void compile_shader (NegativeTestContext& ctx) 123 { 124 // \note Shader compilation must be supported. 125 126 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); 127 ctx.glCompileShader(9); 128 ctx.expectError(GL_INVALID_VALUE); 129 ctx.endSection(); 130 131 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object."); 132 GLuint program = ctx.glCreateProgram(); 133 ctx.glCompileShader(program); 134 ctx.expectError(GL_INVALID_OPERATION); 135 ctx.endSection(); 136 137 ctx.glDeleteProgram(program); 138 } 139 140 void delete_shader (NegativeTestContext& ctx) 141 { 142 ctx.beginSection("GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."); 143 ctx.glDeleteShader(9); 144 ctx.expectError(GL_INVALID_VALUE); 145 ctx.endSection(); 146 } 147 148 void shader_binary (NegativeTestContext& ctx) 149 { 150 std::vector<deInt32> binaryFormats; 151 152 { 153 deInt32 numFormats = 0x1234; 154 ctx.glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &numFormats); 155 156 if (numFormats == 0) 157 ctx.getLog() << TestLog::Message << "// No supported extensions available." << TestLog::EndMessage; 158 else 159 { 160 binaryFormats.resize(numFormats); 161 ctx.glGetIntegerv(GL_SHADER_BINARY_FORMATS, &binaryFormats[0]); 162 } 163 } 164 165 deBool shaderBinarySupported = !binaryFormats.empty(); 166 if (!shaderBinarySupported) 167 ctx.getLog() << TestLog::Message << "// Shader binaries not supported." << TestLog::EndMessage; 168 else 169 ctx.getLog() << TestLog::Message << "// Shader binaries supported" << TestLog::EndMessage; 170 171 GLuint shaders[2]; 172 shaders[0] = ctx.glCreateShader(GL_VERTEX_SHADER); 173 shaders[1] = ctx.glCreateShader(GL_VERTEX_SHADER); 174 175 ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not an accepted value."); 176 ctx.glShaderBinary(1, &shaders[0], -1, 0, 0); 177 ctx.expectError(GL_INVALID_ENUM); 178 ctx.endSection(); 179 180 if (shaderBinarySupported) 181 { 182 ctx.beginSection("GL_INVALID_VALUE is generated if the data pointed to by binary does not match the format specified by binaryFormat."); 183 const GLbyte data = 0x005F; 184 ctx.glShaderBinary(1, &shaders[0], binaryFormats[0], &data, 1); 185 ctx.expectError(GL_INVALID_VALUE); 186 ctx.endSection(); 187 188 ctx.beginSection("GL_INVALID_OPERATION is generated if more than one of the handles in shaders refers to the same type of shader, or GL_INVALID_VALUE due to invalid data pointer."); 189 ctx.glShaderBinary(2, &shaders[0], binaryFormats[0], 0, 0); 190 ctx.expectError(GL_INVALID_OPERATION, GL_INVALID_VALUE); 191 ctx.endSection(); 192 } 193 194 ctx.glDeleteShader(shaders[0]); 195 ctx.glDeleteShader(shaders[1]); 196 } 197 198 void attach_shader (NegativeTestContext& ctx) 199 { 200 GLuint shader1 = ctx.glCreateShader(GL_VERTEX_SHADER); 201 GLuint shader2 = ctx.glCreateShader(GL_VERTEX_SHADER); 202 GLuint program = ctx.glCreateProgram(); 203 204 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 205 ctx.glAttachShader(shader1, shader1); 206 ctx.expectError(GL_INVALID_OPERATION); 207 ctx.endSection(); 208 209 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object."); 210 ctx.glAttachShader(program, program); 211 ctx.expectError(GL_INVALID_OPERATION); 212 ctx.glAttachShader(shader1, program); 213 ctx.expectError(GL_INVALID_OPERATION); 214 ctx.endSection(); 215 216 ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL."); 217 ctx.glAttachShader(program, -1); 218 ctx.expectError(GL_INVALID_VALUE); 219 ctx.glAttachShader(-1, shader1); 220 ctx.expectError(GL_INVALID_VALUE); 221 ctx.glAttachShader(-1, -1); 222 ctx.expectError(GL_INVALID_VALUE); 223 ctx.endSection(); 224 225 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is already attached to program."); 226 ctx.glAttachShader(program, shader1); 227 ctx.expectError(GL_NO_ERROR); 228 ctx.glAttachShader(program, shader1); 229 ctx.expectError(GL_INVALID_OPERATION); 230 ctx.endSection(); 231 232 ctx.beginSection("GL_INVALID_OPERATION is generated if a shader of the same type as shader is already attached to program."); 233 ctx.glAttachShader(program, shader2); 234 ctx.expectError(GL_INVALID_OPERATION); 235 ctx.endSection(); 236 237 ctx.glDeleteProgram(program); 238 ctx.glDeleteShader(shader1); 239 ctx.glDeleteShader(shader2); 240 } 241 242 void detach_shader (NegativeTestContext& ctx) 243 { 244 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 245 GLuint program = ctx.glCreateProgram(); 246 247 ctx.beginSection("GL_INVALID_VALUE is generated if either program or shader is not a value generated by OpenGL."); 248 ctx.glDetachShader(-1, shader); 249 ctx.expectError(GL_INVALID_VALUE); 250 ctx.glDetachShader(program, -1); 251 ctx.expectError(GL_INVALID_VALUE); 252 ctx.glDetachShader(-1, -1); 253 ctx.expectError(GL_INVALID_VALUE); 254 ctx.endSection(); 255 256 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 257 ctx.glDetachShader(shader, shader); 258 ctx.expectError(GL_INVALID_OPERATION); 259 ctx.endSection(); 260 261 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not a shader object."); 262 ctx.glDetachShader(program, program); 263 ctx.expectError(GL_INVALID_OPERATION); 264 ctx.glDetachShader(shader, program); 265 ctx.expectError(GL_INVALID_OPERATION); 266 ctx.endSection(); 267 268 ctx.beginSection("GL_INVALID_OPERATION is generated if shader is not attached to program."); 269 ctx.glDetachShader(program, shader); 270 ctx.expectError(GL_INVALID_OPERATION); 271 ctx.endSection(); 272 273 ctx.glDeleteProgram(program); 274 ctx.glDeleteShader(shader); 275 } 276 277 void link_program (NegativeTestContext& ctx) 278 { 279 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 280 281 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 282 ctx.glLinkProgram(-1); 283 ctx.expectError(GL_INVALID_VALUE); 284 ctx.endSection(); 285 286 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 287 ctx.glLinkProgram(shader); 288 ctx.expectError(GL_INVALID_OPERATION); 289 ctx.endSection(); 290 291 ctx.glDeleteShader(shader); 292 293 ctx.beginSection("GL_INVALID_OPERATION is generated if program is the currently active program object and transform feedback mode is active."); 294 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 295 deUint32 buf = 0x1234; 296 deUint32 tfID = 0x1234; 297 const char* tfVarying = "gl_Position"; 298 299 ctx.glGenTransformFeedbacks (1, &tfID); 300 ctx.glGenBuffers (1, &buf); 301 302 ctx.glUseProgram (program.getProgram()); 303 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS); 304 ctx.glLinkProgram (program.getProgram()); 305 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID); 306 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf); 307 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW); 308 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); 309 ctx.glBeginTransformFeedback (GL_TRIANGLES); 310 ctx.expectError (GL_NO_ERROR); 311 312 ctx.glLinkProgram (program.getProgram()); 313 ctx.expectError (GL_INVALID_OPERATION); 314 315 ctx.glEndTransformFeedback (); 316 ctx.glDeleteTransformFeedbacks (1, &tfID); 317 ctx.glDeleteBuffers (1, &buf); 318 ctx.expectError (GL_NO_ERROR); 319 ctx.endSection(); 320 } 321 322 void use_program (NegativeTestContext& ctx) 323 { 324 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 325 326 ctx.beginSection("GL_INVALID_VALUE is generated if program is neither 0 nor a value generated by OpenGL."); 327 ctx.glUseProgram(-1); 328 ctx.expectError(GL_INVALID_VALUE); 329 ctx.endSection(); 330 331 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 332 ctx.glUseProgram(shader); 333 ctx.expectError(GL_INVALID_OPERATION); 334 ctx.endSection(); 335 336 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback mode is active and not paused."); 337 glu::ShaderProgram program1(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 338 glu::ShaderProgram program2(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 339 deUint32 buf = 0x1234; 340 deUint32 tfID = 0x1234; 341 const char* tfVarying = "gl_Position"; 342 343 ctx.glGenTransformFeedbacks (1, &tfID); 344 ctx.glGenBuffers (1, &buf); 345 346 ctx.glUseProgram (program1.getProgram()); 347 ctx.glTransformFeedbackVaryings (program1.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS); 348 ctx.glLinkProgram (program1.getProgram()); 349 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID); 350 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf); 351 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW); 352 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); 353 ctx.glBeginTransformFeedback (GL_TRIANGLES); 354 ctx.expectError (GL_NO_ERROR); 355 356 ctx.glUseProgram (program2.getProgram()); 357 ctx.expectError (GL_INVALID_OPERATION); 358 359 ctx.glPauseTransformFeedback (); 360 ctx.glUseProgram (program2.getProgram()); 361 ctx.expectError (GL_NO_ERROR); 362 363 ctx.glEndTransformFeedback (); 364 ctx.glDeleteTransformFeedbacks (1, &tfID); 365 ctx.glDeleteBuffers (1, &buf); 366 ctx.expectError (GL_NO_ERROR); 367 ctx.endSection(); 368 369 ctx.glUseProgram(0); 370 ctx.glDeleteShader(shader); 371 } 372 373 void delete_program (NegativeTestContext& ctx) 374 { 375 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 376 ctx.glDeleteProgram(-1); 377 ctx.expectError(GL_INVALID_VALUE); 378 ctx.endSection(); 379 } 380 381 void validate_program (NegativeTestContext& ctx) 382 { 383 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 384 385 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 386 ctx.glValidateProgram(-1); 387 ctx.expectError(GL_INVALID_VALUE); 388 ctx.endSection(); 389 390 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 391 ctx.glValidateProgram(shader); 392 ctx.expectError(GL_INVALID_OPERATION); 393 ctx.endSection(); 394 395 ctx.glDeleteShader(shader); 396 } 397 398 void get_program_binary (NegativeTestContext& ctx) 399 { 400 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 401 glu::ShaderProgram programInvalid (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, "")); 402 GLenum binaryFormat = -1; 403 GLsizei binaryLength = -1; 404 GLint binaryPtr = -1; 405 GLint bufSize = -1; 406 GLint linkStatus = -1; 407 408 ctx.beginSection("GL_INVALID_OPERATION is generated if bufSize is less than the size of GL_PROGRAM_BINARY_LENGTH for program."); 409 ctx.glGetProgramiv (program.getProgram(), GL_PROGRAM_BINARY_LENGTH, &bufSize); 410 ctx.expectError (GL_NO_ERROR); 411 ctx.glGetProgramiv (program.getProgram(), GL_LINK_STATUS, &linkStatus); 412 ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage; 413 ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage; 414 ctx.expectError (GL_NO_ERROR); 415 416 ctx.glGetProgramBinary (program.getProgram(), 0, &binaryLength, &binaryFormat, &binaryPtr); 417 ctx.expectError (GL_INVALID_OPERATION); 418 if (bufSize > 0) 419 { 420 ctx.glGetProgramBinary (program.getProgram(), bufSize-1, &binaryLength, &binaryFormat, &binaryPtr); 421 ctx.expectError (GL_INVALID_OPERATION); 422 } 423 ctx.endSection(); 424 425 ctx.beginSection("GL_INVALID_OPERATION is generated if GL_LINK_STATUS for the program object is false."); 426 ctx.glGetProgramiv (programInvalid.getProgram(), GL_PROGRAM_BINARY_LENGTH, &bufSize); 427 ctx.expectError (GL_NO_ERROR); 428 ctx.glGetProgramiv (programInvalid.getProgram(), GL_LINK_STATUS, &linkStatus); 429 ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage; 430 ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage; 431 ctx.expectError (GL_NO_ERROR); 432 433 ctx.glGetProgramBinary (programInvalid.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryPtr); 434 ctx.expectError (GL_INVALID_OPERATION); 435 ctx.endSection(); 436 } 437 438 void program_binary (NegativeTestContext& ctx) 439 { 440 glu::ShaderProgram srcProgram (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 441 GLuint dstProgram = ctx.glCreateProgram(); 442 GLuint dummyShader = ctx.glCreateShader(GL_VERTEX_SHADER); 443 GLenum binaryFormat = -1; 444 GLsizei binaryLength = -1; 445 std::vector<deUint8> binaryBuf; 446 GLint bufSize = -1; 447 GLint linkStatus = -1; 448 449 ctx.glGetProgramiv (srcProgram.getProgram(), GL_PROGRAM_BINARY_LENGTH, &bufSize); 450 ctx.glGetProgramiv (srcProgram.getProgram(), GL_LINK_STATUS, &linkStatus); 451 ctx.getLog() << TestLog::Message << "// GL_PROGRAM_BINARY_LENGTH = " << bufSize << TestLog::EndMessage; 452 ctx.getLog() << TestLog::Message << "// GL_LINK_STATUS = " << linkStatus << TestLog::EndMessage; 453 TCU_CHECK(bufSize > 0); 454 binaryBuf.resize(bufSize); 455 ctx.glGetProgramBinary (srcProgram.getProgram(), bufSize, &binaryLength, &binaryFormat, &binaryBuf[0]); 456 ctx.expectError (GL_NO_ERROR); 457 458 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not the name of an existing program object."); 459 ctx.glProgramBinary (dummyShader, binaryFormat, &binaryBuf[0], binaryLength); 460 ctx.expectError (GL_INVALID_OPERATION); 461 ctx.endSection(); 462 463 ctx.beginSection("GL_INVALID_ENUM is generated if binaryFormat is not a value recognized by the implementation."); 464 ctx.glProgramBinary (dstProgram, -1, &binaryBuf[0], binaryLength); 465 ctx.expectError (GL_INVALID_ENUM); 466 ctx.endSection(); 467 468 ctx.glDeleteShader(dummyShader); 469 ctx.glDeleteProgram(dstProgram); 470 } 471 472 void program_parameteri (NegativeTestContext& ctx) 473 { 474 GLuint program = ctx.glCreateProgram(); 475 476 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of an existing program object."); 477 ctx.glProgramParameteri (0, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE); 478 ctx.expectError (GL_INVALID_VALUE); 479 ctx.endSection(); 480 481 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not GL_PROGRAM_BINARY_RETRIEVABLE_HINT."); 482 ctx.glProgramParameteri (program, -1, GL_TRUE); 483 ctx.expectError (GL_INVALID_ENUM); 484 ctx.endSection(); 485 486 ctx.beginSection("GL_INVALID_VALUE is generated if value is not GL_FALSE or GL_TRUE."); 487 ctx.glProgramParameteri (program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, 2); 488 ctx.expectError (GL_INVALID_VALUE); 489 ctx.endSection(); 490 491 ctx.glDeleteProgram(program); 492 } 493 494 void gen_samplers (NegativeTestContext& ctx) 495 { 496 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative."); 497 GLuint sampler = 0; 498 ctx.glGenSamplers (-1, &sampler); 499 ctx.expectError (GL_INVALID_VALUE); 500 ctx.endSection(); 501 } 502 503 void bind_sampler (NegativeTestContext& ctx) 504 { 505 int maxTexImageUnits = 0x1234; 506 GLuint sampler = 0; 507 ctx.glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTexImageUnits); 508 ctx.glGenSamplers (1, &sampler); 509 510 ctx.beginSection("GL_INVALID_VALUE is generated if unit is greater than or equal to the value of GL_MAX_COMBIED_TEXTURE_IMAGE_UNITS."); 511 ctx.glBindSampler (maxTexImageUnits, sampler); 512 ctx.expectError (GL_INVALID_VALUE); 513 ctx.endSection(); 514 515 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not zero or a name previously returned from a call to ctx.glGenSamplers."); 516 ctx.glBindSampler (1, -1); 517 ctx.expectError (GL_INVALID_OPERATION); 518 ctx.endSection(); 519 520 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler has been deleted by a call to ctx.glDeleteSamplers."); 521 ctx.glDeleteSamplers(1, &sampler); 522 ctx.glBindSampler (1, sampler); 523 ctx.expectError (GL_INVALID_OPERATION); 524 ctx.endSection(); 525 } 526 527 void delete_samplers (NegativeTestContext& ctx) 528 { 529 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative."); 530 ctx.glDeleteSamplers(-1, 0); 531 ctx.expectError (GL_INVALID_VALUE); 532 ctx.endSection(); 533 } 534 535 void get_sampler_parameteriv (NegativeTestContext& ctx) 536 { 537 int params = 0x1234; 538 GLuint sampler = 0; 539 ctx.glGenSamplers (1, &sampler); 540 541 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers."); 542 ctx.glGetSamplerParameteriv (-1, GL_TEXTURE_MAG_FILTER, ¶ms); 543 ctx.expectError (GL_INVALID_OPERATION); 544 ctx.endSection(); 545 546 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 547 ctx.glGetSamplerParameteriv (sampler, -1, ¶ms); 548 ctx.expectError (GL_INVALID_ENUM); 549 ctx.endSection(); 550 551 ctx.glDeleteSamplers(1, &sampler); 552 } 553 554 void get_sampler_parameterfv (NegativeTestContext& ctx) 555 { 556 float params; 557 GLuint sampler = 0; 558 ctx.glGenSamplers (1, &sampler); 559 560 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object returned from a previous call to ctx.glGenSamplers."); 561 ctx.glGetSamplerParameterfv (-1, GL_TEXTURE_MAG_FILTER, ¶ms); 562 ctx.expectError (GL_INVALID_OPERATION); 563 ctx.endSection(); 564 565 ctx.beginSection("GL_INVALID_ENUM is generated if pname is not an accepted value."); 566 ctx.glGetSamplerParameterfv (sampler, -1, ¶ms); 567 ctx.expectError (GL_INVALID_ENUM); 568 ctx.endSection(); 569 570 ctx.glDeleteSamplers(1, &sampler); 571 } 572 573 void sampler_parameteri (NegativeTestContext& ctx) 574 { 575 GLuint sampler = 0; 576 ctx.glGenSamplers (1, &sampler); 577 578 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers."); 579 ctx.glSamplerParameteri (-1, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 580 ctx.expectError (GL_INVALID_OPERATION); 581 ctx.endSection(); 582 583 ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not."); 584 ctx.glSamplerParameteri (sampler, GL_TEXTURE_WRAP_S, -1); 585 ctx.expectError (GL_INVALID_ENUM); 586 ctx.endSection(); 587 588 ctx.glDeleteSamplers(1, &sampler); 589 } 590 591 void sampler_parameteriv (NegativeTestContext& ctx) 592 { 593 int params = 0x1234; 594 GLuint sampler = 0; 595 ctx.glGenSamplers (1, &sampler); 596 597 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers."); 598 params = GL_CLAMP_TO_EDGE; 599 ctx.glSamplerParameteriv (-1, GL_TEXTURE_WRAP_S, ¶ms); 600 ctx.expectError (GL_INVALID_OPERATION); 601 ctx.endSection(); 602 603 ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not."); 604 params = -1; 605 ctx.glSamplerParameteriv (sampler, GL_TEXTURE_WRAP_S, ¶ms); 606 ctx.expectError (GL_INVALID_ENUM); 607 ctx.endSection(); 608 609 ctx.glDeleteSamplers(1, &sampler); 610 } 611 612 void sampler_parameterf (NegativeTestContext& ctx) 613 { 614 GLuint sampler = 0; 615 ctx.glGenSamplers (1, &sampler); 616 617 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers."); 618 ctx.glSamplerParameterf (-1, GL_TEXTURE_MIN_LOD, -1000.0f); 619 ctx.expectError (GL_INVALID_OPERATION); 620 ctx.endSection(); 621 622 ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not."); 623 ctx.glSamplerParameterf (sampler, GL_TEXTURE_WRAP_S, -1.0f); 624 ctx.expectError (GL_INVALID_ENUM); 625 ctx.endSection(); 626 627 ctx.glDeleteSamplers(1, &sampler); 628 } 629 630 void sampler_parameterfv (NegativeTestContext& ctx) 631 { 632 float params; 633 GLuint sampler = 0; 634 ctx.glGenSamplers (1, &sampler); 635 636 ctx.beginSection("GL_INVALID_OPERATION is generated if sampler is not the name of a sampler object previously returned from a call to ctx.glGenSamplers."); 637 params = -1000.0f; 638 ctx.glSamplerParameterfv (-1, GL_TEXTURE_WRAP_S, ¶ms); 639 ctx.expectError (GL_INVALID_OPERATION); 640 ctx.endSection(); 641 642 ctx.beginSection("GL_INVALID_ENUM is generated if params should have a defined constant value (based on the value of pname) and does not."); 643 params = -1.0f; 644 ctx.glSamplerParameterfv (sampler, GL_TEXTURE_WRAP_S, ¶ms); 645 ctx.expectError (GL_INVALID_ENUM); 646 ctx.endSection(); 647 648 ctx.glDeleteSamplers(1, &sampler); 649 } 650 651 // Shader data commands 652 653 void get_attrib_location (NegativeTestContext& ctx) 654 { 655 GLuint programEmpty = ctx.glCreateProgram(); 656 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 657 658 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 659 660 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked."); 661 ctx.glBindAttribLocation (programEmpty, 0, "test"); 662 ctx.glGetAttribLocation (programEmpty, "test"); 663 ctx.expectError (GL_INVALID_OPERATION); 664 ctx.endSection(); 665 666 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a program or shader object."); 667 ctx.glUseProgram (program.getProgram()); 668 ctx.glBindAttribLocation (program.getProgram(), 0, "test"); 669 ctx.expectError (GL_NO_ERROR); 670 ctx.glGetAttribLocation (program.getProgram(), "test"); 671 ctx.expectError (GL_NO_ERROR); 672 ctx.glGetAttribLocation (-2, "test"); 673 ctx.expectError (GL_INVALID_VALUE); 674 ctx.endSection(); 675 676 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 677 ctx.glGetAttribLocation (shader, "test"); 678 ctx.expectError (GL_INVALID_OPERATION); 679 ctx.endSection(); 680 681 ctx.glUseProgram (0); 682 ctx.glDeleteShader (shader); 683 ctx.glDeleteProgram (programEmpty); 684 } 685 686 void get_uniform_location (NegativeTestContext& ctx) 687 { 688 GLuint programEmpty = ctx.glCreateProgram(); 689 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 690 691 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 692 693 ctx.beginSection("GL_INVALID_OPERATION is generated if program has not been successfully linked."); 694 ctx.glGetUniformLocation(programEmpty, "test"); 695 ctx.expectError(GL_INVALID_OPERATION); 696 ctx.endSection(); 697 698 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 699 ctx.glUseProgram(program.getProgram()); 700 ctx.glGetUniformLocation(-2, "test"); 701 ctx.expectError(GL_INVALID_VALUE); 702 ctx.endSection(); 703 704 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 705 ctx.glGetAttribLocation(shader, "test"); 706 ctx.expectError(GL_INVALID_OPERATION); 707 ctx.endSection(); 708 709 ctx.glUseProgram(0); 710 ctx.glDeleteProgram(programEmpty); 711 ctx.glDeleteShader(shader); 712 } 713 714 void bind_attrib_location (NegativeTestContext& ctx) 715 { 716 GLuint program = ctx.glCreateProgram(); 717 GLuint maxIndex = ctx.getInteger(GL_MAX_VERTEX_ATTRIBS); 718 GLuint shader = ctx.glCreateShader(GL_VERTEX_SHADER); 719 720 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater than or equal to GL_MAX_VERTEX_ATTRIBS."); 721 ctx.glBindAttribLocation(program, maxIndex, "test"); 722 ctx.expectError(GL_INVALID_VALUE); 723 ctx.endSection(); 724 725 ctx.beginSection("GL_INVALID_OPERATION is generated if name starts with the reserved prefix \"gl_\"."); 726 ctx.glBindAttribLocation(program, maxIndex-1, "gl_test"); 727 ctx.expectError(GL_INVALID_OPERATION); 728 ctx.endSection(); 729 730 ctx.beginSection("GL_INVALID_VALUE is generated if program is not a value generated by OpenGL."); 731 ctx.glBindAttribLocation(-1, maxIndex-1, "test"); 732 ctx.expectError(GL_INVALID_VALUE); 733 ctx.endSection(); 734 735 ctx.beginSection("GL_INVALID_OPERATION is generated if program is not a program object."); 736 ctx.glBindAttribLocation(shader, maxIndex-1, "test"); 737 ctx.expectError(GL_INVALID_OPERATION); 738 ctx.endSection(); 739 740 ctx.glDeleteProgram(program); 741 ctx.glDeleteShader(shader); 742 } 743 744 void uniform_block_binding (NegativeTestContext& ctx) 745 { 746 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformBlockVertSource, uniformTestFragSource)); 747 748 ctx.glUseProgram (program.getProgram()); 749 750 GLint maxUniformBufferBindings = -1; 751 GLint numActiveUniforms = -1; 752 GLint numActiveBlocks = -1; 753 ctx.glGetIntegerv (GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferBindings); 754 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORMS, &numActiveUniforms); 755 ctx.glGetProgramiv (program.getProgram(), GL_ACTIVE_UNIFORM_BLOCKS, &numActiveBlocks); 756 ctx.getLog() << TestLog::Message << "// GL_MAX_UNIFORM_BUFFER_BINDINGS = " << maxUniformBufferBindings << TestLog::EndMessage; 757 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORMS = " << numActiveUniforms << TestLog::EndMessage; 758 ctx.getLog() << TestLog::Message << "// GL_ACTIVE_UNIFORM_BLOCKS = " << numActiveBlocks << TestLog::EndMessage; 759 ctx.expectError (GL_NO_ERROR); 760 761 ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockIndex is not an active uniform block index of program."); 762 ctx.glUniformBlockBinding(program.getProgram(), -1, 0); 763 ctx.expectError(GL_INVALID_VALUE); 764 ctx.glUniformBlockBinding(program.getProgram(), 5, 0); 765 ctx.expectError(GL_INVALID_VALUE); 766 ctx.endSection(); 767 768 ctx.beginSection("GL_INVALID_VALUE is generated if uniformBlockBinding is greater than or equal to the value of GL_MAX_UNIFORM_BUFFER_BINDINGS."); 769 ctx.glUniformBlockBinding(program.getProgram(), maxUniformBufferBindings, 0); 770 ctx.expectError(GL_INVALID_VALUE); 771 ctx.endSection(); 772 773 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object generated by the GL."); 774 ctx.glUniformBlockBinding(-1, 0, 0); 775 ctx.expectError(GL_INVALID_VALUE); 776 ctx.endSection(); 777 } 778 779 // ctx.glUniform*f 780 781 void uniformf_invalid_program (NegativeTestContext& ctx) 782 { 783 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object."); 784 ctx.glUseProgram(0); 785 ctx.glUniform1f(-1, 0.0f); 786 ctx.expectError(GL_INVALID_OPERATION); 787 ctx.glUniform2f(-1, 0.0f, 0.0f); 788 ctx.expectError(GL_INVALID_OPERATION); 789 ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f); 790 ctx.expectError(GL_INVALID_OPERATION); 791 ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f); 792 ctx.expectError(GL_INVALID_OPERATION); 793 ctx.endSection(); 794 } 795 796 void uniformf_incompatible_type (NegativeTestContext& ctx) 797 { 798 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 799 800 ctx.glUseProgram(program.getProgram()); 801 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4 802 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4 803 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4 804 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D 805 ctx.expectError(GL_NO_ERROR); 806 807 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1) 808 { 809 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 810 ctx.fail("Failed to retrieve uniform location"); 811 } 812 813 ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command."); 814 ctx.glUseProgram(program.getProgram()); 815 ctx.glUniform1f(vec4_v, 0.0f); 816 ctx.expectError(GL_INVALID_OPERATION); 817 ctx.glUniform2f(vec4_v, 0.0f, 0.0f); 818 ctx.expectError(GL_INVALID_OPERATION); 819 ctx.glUniform3f(vec4_v, 0.0f, 0.0f, 0.0f); 820 ctx.expectError(GL_INVALID_OPERATION); 821 ctx.glUniform4f(vec4_v, 0.0f, 0.0f, 0.0f, 0.0f); 822 ctx.expectError(GL_NO_ERROR); 823 ctx.endSection(); 824 825 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}f is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4."); 826 ctx.glUseProgram(program.getProgram()); 827 ctx.glUniform4f(ivec4_f, 0.0f, 0.0f, 0.0f, 0.0f); 828 ctx.expectError(GL_INVALID_OPERATION); 829 ctx.glUniform4f(uvec4_f, 0.0f, 0.0f, 0.0f, 0.0f); 830 ctx.expectError(GL_INVALID_OPERATION); 831 ctx.endSection(); 832 833 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv."); 834 ctx.glUseProgram(program.getProgram()); 835 ctx.glUniform1f(sampler_f, 0.0f); 836 ctx.expectError(GL_INVALID_OPERATION); 837 ctx.endSection(); 838 839 ctx.glUseProgram(0); 840 } 841 842 void uniformf_invalid_location (NegativeTestContext& ctx) 843 { 844 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 845 846 ctx.glUseProgram(program.getProgram()); 847 ctx.expectError(GL_NO_ERROR); 848 849 ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 850 ctx.glUseProgram(program.getProgram()); 851 ctx.glUniform1f(-2, 0.0f); 852 ctx.expectError(GL_INVALID_OPERATION); 853 ctx.glUniform2f(-2, 0.0f, 0.0f); 854 ctx.expectError(GL_INVALID_OPERATION); 855 ctx.glUniform3f(-2, 0.0f, 0.0f, 0.0f); 856 ctx.expectError(GL_INVALID_OPERATION); 857 ctx.glUniform4f(-2, 0.0f, 0.0f, 0.0f, 0.0f); 858 ctx.expectError(GL_INVALID_OPERATION); 859 860 ctx.glUseProgram(program.getProgram()); 861 ctx.glUniform1f(-1, 0.0f); 862 ctx.expectError(GL_NO_ERROR); 863 ctx.glUniform2f(-1, 0.0f, 0.0f); 864 ctx.expectError(GL_NO_ERROR); 865 ctx.glUniform3f(-1, 0.0f, 0.0f, 0.0f); 866 ctx.expectError(GL_NO_ERROR); 867 ctx.glUniform4f(-1, 0.0f, 0.0f, 0.0f, 0.0f); 868 ctx.expectError(GL_NO_ERROR); 869 ctx.endSection(); 870 871 ctx.glUseProgram(0); 872 } 873 874 // ctx.glUniform*fv 875 876 void uniformfv_invalid_program (NegativeTestContext& ctx) 877 { 878 std::vector<GLfloat> data(4); 879 880 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object."); 881 ctx.glUseProgram(0); 882 ctx.glUniform1fv(-1, 1, &data[0]); 883 ctx.expectError(GL_INVALID_OPERATION); 884 ctx.glUniform2fv(-1, 1, &data[0]); 885 ctx.expectError(GL_INVALID_OPERATION); 886 ctx.glUniform3fv(-1, 1, &data[0]); 887 ctx.expectError(GL_INVALID_OPERATION); 888 ctx.glUniform4fv(-1, 1, &data[0]); 889 ctx.expectError(GL_INVALID_OPERATION); 890 ctx.endSection(); 891 } 892 893 void uniformfv_incompatible_type (NegativeTestContext& ctx) 894 { 895 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 896 897 ctx.glUseProgram(program.getProgram()); 898 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4 899 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4 900 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4 901 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D 902 ctx.expectError(GL_NO_ERROR); 903 904 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1) 905 { 906 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 907 ctx.fail("Failed to retrieve uniform location"); 908 } 909 910 std::vector<GLfloat> data(4); 911 912 ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command."); 913 ctx.glUseProgram(program.getProgram()); 914 ctx.glUniform1fv(vec4_v, 1, &data[0]); 915 ctx.expectError(GL_INVALID_OPERATION); 916 ctx.glUniform2fv(vec4_v, 1, &data[0]); 917 ctx.expectError(GL_INVALID_OPERATION); 918 ctx.glUniform3fv(vec4_v, 1, &data[0]); 919 ctx.expectError(GL_INVALID_OPERATION); 920 ctx.glUniform4fv(vec4_v, 1, &data[0]); 921 ctx.expectError(GL_NO_ERROR); 922 ctx.endSection(); 923 924 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}fv is used to load a uniform variable of type int, ivec2, ivec3, ivec4, unsigned int, uvec2, uvec3, uvec4."); 925 ctx.glUseProgram(program.getProgram()); 926 ctx.glUniform4fv(ivec4_f, 1, &data[0]); 927 ctx.expectError(GL_INVALID_OPERATION); 928 ctx.glUniform4fv(uvec4_f, 1, &data[0]); 929 ctx.expectError(GL_INVALID_OPERATION); 930 ctx.endSection(); 931 932 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv."); 933 ctx.glUseProgram(program.getProgram()); 934 ctx.glUniform1fv(sampler_f, 1, &data[0]); 935 ctx.expectError(GL_INVALID_OPERATION); 936 ctx.endSection(); 937 938 ctx.glUseProgram(0); 939 } 940 941 void uniformfv_invalid_location (NegativeTestContext& ctx) 942 { 943 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 944 945 ctx.glUseProgram(program.getProgram()); 946 ctx.expectError(GL_NO_ERROR); 947 948 std::vector<GLfloat> data(4); 949 950 ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 951 ctx.glUseProgram(program.getProgram()); 952 ctx.glUniform1fv(-2, 1, &data[0]); 953 ctx.expectError(GL_INVALID_OPERATION); 954 ctx.glUniform2fv(-2, 1, &data[0]); 955 ctx.expectError(GL_INVALID_OPERATION); 956 ctx.glUniform3fv(-2, 1, &data[0]); 957 ctx.expectError(GL_INVALID_OPERATION); 958 ctx.glUniform4fv(-2, 1, &data[0]); 959 ctx.expectError(GL_INVALID_OPERATION); 960 961 ctx.glUseProgram(program.getProgram()); 962 ctx.glUniform1fv(-1, 1, &data[0]); 963 ctx.expectError(GL_NO_ERROR); 964 ctx.glUniform2fv(-1, 1, &data[0]); 965 ctx.expectError(GL_NO_ERROR); 966 ctx.glUniform3fv(-1, 1, &data[0]); 967 ctx.expectError(GL_NO_ERROR); 968 ctx.glUniform4fv(-1, 1, &data[0]); 969 ctx.expectError(GL_NO_ERROR); 970 ctx.endSection(); 971 972 ctx.glUseProgram(0); 973 } 974 975 void uniformfv_invalid_count (NegativeTestContext& ctx) 976 { 977 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 978 979 ctx.glUseProgram (program.getProgram()); 980 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4 981 ctx.expectError(GL_NO_ERROR); 982 983 if (vec4_v == -1) 984 { 985 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 986 ctx.fail("Failed to retrieve uniform location"); 987 } 988 989 std::vector<GLfloat> data(8); 990 991 ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable."); 992 ctx.glUseProgram(program.getProgram()); 993 ctx.glUniform1fv(vec4_v, 2, &data[0]); 994 ctx.expectError(GL_INVALID_OPERATION); 995 ctx.glUniform2fv(vec4_v, 2, &data[0]); 996 ctx.expectError(GL_INVALID_OPERATION); 997 ctx.glUniform3fv(vec4_v, 2, &data[0]); 998 ctx.expectError(GL_INVALID_OPERATION); 999 ctx.glUniform4fv(vec4_v, 2, &data[0]); 1000 ctx.expectError(GL_INVALID_OPERATION); 1001 ctx.endSection(); 1002 1003 ctx.glUseProgram(0); 1004 } 1005 1006 // ctx.glUniform*i 1007 1008 void uniformi_invalid_program (NegativeTestContext& ctx) 1009 { 1010 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object."); 1011 ctx.glUseProgram(0); 1012 ctx.glUniform1i(-1, 0); 1013 ctx.expectError(GL_INVALID_OPERATION); 1014 ctx.glUniform2i(-1, 0, 0); 1015 ctx.expectError(GL_INVALID_OPERATION); 1016 ctx.glUniform3i(-1, 0, 0, 0); 1017 ctx.expectError(GL_INVALID_OPERATION); 1018 ctx.glUniform4i(-1, 0, 0, 0, 0); 1019 ctx.expectError(GL_INVALID_OPERATION); 1020 ctx.endSection(); 1021 } 1022 1023 void uniformi_incompatible_type (NegativeTestContext& ctx) 1024 { 1025 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1026 1027 ctx.glUseProgram(program.getProgram()); 1028 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4 1029 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4 1030 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4 1031 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D 1032 ctx.expectError(GL_NO_ERROR); 1033 1034 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1) 1035 { 1036 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 1037 ctx.fail("Failed to retrieve uniform location"); 1038 } 1039 1040 ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command."); 1041 ctx.glUseProgram(program.getProgram()); 1042 ctx.glUniform1i(ivec4_f, 0); 1043 ctx.expectError(GL_INVALID_OPERATION); 1044 ctx.glUniform2i(ivec4_f, 0, 0); 1045 ctx.expectError(GL_INVALID_OPERATION); 1046 ctx.glUniform3i(ivec4_f, 0, 0, 0); 1047 ctx.expectError(GL_INVALID_OPERATION); 1048 ctx.glUniform4i(ivec4_f, 0, 0, 0, 0); 1049 ctx.expectError(GL_NO_ERROR); 1050 ctx.endSection(); 1051 1052 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type unsigned int, uvec2, uvec3, uvec4, or an array of these."); 1053 ctx.glUseProgram(program.getProgram()); 1054 ctx.glUniform1i(uvec4_f, 0); 1055 ctx.expectError(GL_INVALID_OPERATION); 1056 ctx.glUniform2i(uvec4_f, 0, 0); 1057 ctx.expectError(GL_INVALID_OPERATION); 1058 ctx.glUniform3i(uvec4_f, 0, 0, 0); 1059 ctx.expectError(GL_INVALID_OPERATION); 1060 ctx.glUniform4i(uvec4_f, 0, 0, 0, 0); 1061 ctx.expectError(GL_INVALID_OPERATION); 1062 ctx.endSection(); 1063 1064 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4."); 1065 ctx.glUseProgram(program.getProgram()); 1066 ctx.glUniform1i(vec4_v, 0); 1067 ctx.expectError(GL_INVALID_OPERATION); 1068 ctx.glUniform2i(vec4_v, 0, 0); 1069 ctx.expectError(GL_INVALID_OPERATION); 1070 ctx.glUniform3i(vec4_v, 0, 0, 0); 1071 ctx.expectError(GL_INVALID_OPERATION); 1072 ctx.glUniform4i(vec4_v, 0, 0, 0, 0); 1073 ctx.expectError(GL_INVALID_OPERATION); 1074 ctx.endSection(); 1075 1076 ctx.glUseProgram(0); 1077 } 1078 1079 void uniformi_invalid_location (NegativeTestContext& ctx) 1080 { 1081 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1082 1083 ctx.glUseProgram(program.getProgram()); 1084 ctx.expectError(GL_NO_ERROR); 1085 1086 ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 1087 ctx.glUseProgram(program.getProgram()); 1088 ctx.glUniform1i(-2, 0); 1089 ctx.expectError(GL_INVALID_OPERATION); 1090 ctx.glUniform2i(-2, 0, 0); 1091 ctx.expectError(GL_INVALID_OPERATION); 1092 ctx.glUniform3i(-2, 0, 0, 0); 1093 ctx.expectError(GL_INVALID_OPERATION); 1094 ctx.glUniform4i(-2, 0, 0, 0, 0); 1095 ctx.expectError(GL_INVALID_OPERATION); 1096 1097 ctx.glUseProgram(program.getProgram()); 1098 ctx.glUniform1i(-1, 0); 1099 ctx.expectError(GL_NO_ERROR); 1100 ctx.glUniform2i(-1, 0, 0); 1101 ctx.expectError(GL_NO_ERROR); 1102 ctx.glUniform3i(-1, 0, 0, 0); 1103 ctx.expectError(GL_NO_ERROR); 1104 ctx.glUniform4i(-1, 0, 0, 0, 0); 1105 ctx.expectError(GL_NO_ERROR); 1106 ctx.endSection(); 1107 1108 ctx.glUseProgram(0); 1109 } 1110 1111 // ctx.glUniform*iv 1112 1113 void uniformiv_invalid_program (NegativeTestContext& ctx) 1114 { 1115 std::vector<GLint> data(4); 1116 1117 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object."); 1118 ctx.glUseProgram(0); 1119 ctx.glUniform1iv(-1, 1, &data[0]); 1120 ctx.expectError(GL_INVALID_OPERATION); 1121 ctx.glUniform2iv(-1, 1, &data[0]); 1122 ctx.expectError(GL_INVALID_OPERATION); 1123 ctx.glUniform3iv(-1, 1, &data[0]); 1124 ctx.expectError(GL_INVALID_OPERATION); 1125 ctx.glUniform4iv(-1, 1, &data[0]); 1126 ctx.expectError(GL_INVALID_OPERATION); 1127 ctx.endSection(); 1128 } 1129 1130 void uniformiv_incompatible_type (NegativeTestContext& ctx) 1131 { 1132 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1133 1134 ctx.glUseProgram(program.getProgram()); 1135 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4 1136 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4 1137 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4 1138 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D 1139 ctx.expectError(GL_NO_ERROR); 1140 1141 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1) 1142 { 1143 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 1144 ctx.fail("Failed to retrieve uniform location"); 1145 } 1146 1147 std::vector<GLint> data(4); 1148 1149 ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command."); 1150 ctx.glUseProgram(program.getProgram()); 1151 ctx.glUniform1iv(ivec4_f, 1, &data[0]); 1152 ctx.expectError(GL_INVALID_OPERATION); 1153 ctx.glUniform2iv(ivec4_f, 1, &data[0]); 1154 ctx.expectError(GL_INVALID_OPERATION); 1155 ctx.glUniform3iv(ivec4_f, 1, &data[0]); 1156 ctx.expectError(GL_INVALID_OPERATION); 1157 ctx.glUniform4iv(ivec4_f, 1, &data[0]); 1158 ctx.expectError(GL_NO_ERROR); 1159 ctx.endSection(); 1160 1161 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}iv is used to load a uniform variable of type float, vec2, vec3, or vec4."); 1162 ctx.glUseProgram(program.getProgram()); 1163 ctx.glUniform1iv(vec4_v, 1, &data[0]); 1164 ctx.expectError(GL_INVALID_OPERATION); 1165 ctx.glUniform2iv(vec4_v, 1, &data[0]); 1166 ctx.expectError(GL_INVALID_OPERATION); 1167 ctx.glUniform3iv(vec4_v, 1, &data[0]); 1168 ctx.expectError(GL_INVALID_OPERATION); 1169 ctx.glUniform4iv(vec4_v, 1, &data[0]); 1170 ctx.expectError(GL_INVALID_OPERATION); 1171 ctx.endSection(); 1172 1173 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}iv is used to load a uniform variable of type unsigned int, uvec2, uvec3 or uvec4."); 1174 ctx.glUseProgram(program.getProgram()); 1175 ctx.glUniform1iv(uvec4_f, 1, &data[0]); 1176 ctx.expectError(GL_INVALID_OPERATION); 1177 ctx.glUniform2iv(uvec4_f, 1, &data[0]); 1178 ctx.expectError(GL_INVALID_OPERATION); 1179 ctx.glUniform3iv(uvec4_f, 1, &data[0]); 1180 ctx.expectError(GL_INVALID_OPERATION); 1181 ctx.glUniform4iv(uvec4_f, 1, &data[0]); 1182 ctx.expectError(GL_INVALID_OPERATION); 1183 ctx.endSection(); 1184 1185 ctx.glUseProgram(0); 1186 } 1187 1188 void uniformiv_invalid_location (NegativeTestContext& ctx) 1189 { 1190 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1191 1192 ctx.glUseProgram(program.getProgram()); 1193 ctx.expectError(GL_NO_ERROR); 1194 1195 std::vector<GLint> data(4); 1196 1197 ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 1198 ctx.glUseProgram(program.getProgram()); 1199 ctx.glUniform1iv(-2, 1, &data[0]); 1200 ctx.expectError(GL_INVALID_OPERATION); 1201 ctx.glUniform2iv(-2, 1, &data[0]); 1202 ctx.expectError(GL_INVALID_OPERATION); 1203 ctx.glUniform3iv(-2, 1, &data[0]); 1204 ctx.expectError(GL_INVALID_OPERATION); 1205 ctx.glUniform4iv(-2, 1, &data[0]); 1206 ctx.expectError(GL_INVALID_OPERATION); 1207 1208 ctx.glUseProgram(program.getProgram()); 1209 ctx.glUniform1iv(-1, 1, &data[0]); 1210 ctx.expectError(GL_NO_ERROR); 1211 ctx.glUniform2iv(-1, 1, &data[0]); 1212 ctx.expectError(GL_NO_ERROR); 1213 ctx.glUniform3iv(-1, 1, &data[0]); 1214 ctx.expectError(GL_NO_ERROR); 1215 ctx.glUniform4iv(-1, 1, &data[0]); 1216 ctx.expectError(GL_NO_ERROR); 1217 ctx.endSection(); 1218 1219 ctx.glUseProgram(0); 1220 } 1221 1222 void uniformiv_invalid_count (NegativeTestContext& ctx) 1223 { 1224 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1225 1226 ctx.glUseProgram (program.getProgram()); 1227 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4 1228 ctx.expectError(GL_NO_ERROR); 1229 1230 if (ivec4_f == -1) 1231 { 1232 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 1233 ctx.fail("Failed to retrieve uniform location"); 1234 } 1235 1236 std::vector<GLint> data(8); 1237 1238 ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable."); 1239 ctx.glUseProgram(program.getProgram()); 1240 ctx.glUniform1iv(ivec4_f, 2, &data[0]); 1241 ctx.expectError(GL_INVALID_OPERATION); 1242 ctx.glUniform2iv(ivec4_f, 2, &data[0]); 1243 ctx.expectError(GL_INVALID_OPERATION); 1244 ctx.glUniform3iv(ivec4_f, 2, &data[0]); 1245 ctx.expectError(GL_INVALID_OPERATION); 1246 ctx.glUniform4iv(ivec4_f, 2, &data[0]); 1247 ctx.expectError(GL_INVALID_OPERATION); 1248 ctx.endSection(); 1249 1250 ctx.glUseProgram(0); 1251 } 1252 1253 // ctx.glUniform{1234}ui 1254 1255 void uniformui_invalid_program (NegativeTestContext& ctx) 1256 { 1257 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object."); 1258 ctx.glUseProgram(0); 1259 ctx.glUniform1ui(-1, 0); 1260 ctx.expectError(GL_INVALID_OPERATION); 1261 ctx.glUniform2ui(-1, 0, 0); 1262 ctx.expectError(GL_INVALID_OPERATION); 1263 ctx.glUniform3ui(-1, 0, 0, 0); 1264 ctx.expectError(GL_INVALID_OPERATION); 1265 ctx.glUniform4ui(-1, 0, 0, 0, 0); 1266 ctx.expectError(GL_INVALID_OPERATION); 1267 ctx.endSection(); 1268 } 1269 1270 void uniformui_incompatible_type (NegativeTestContext& ctx) 1271 { 1272 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1273 1274 ctx.glUseProgram(program.getProgram()); 1275 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4 1276 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4 1277 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4 1278 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D 1279 ctx.expectError(GL_NO_ERROR); 1280 1281 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1) 1282 { 1283 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 1284 ctx.fail("Failed to retrieve uniform location"); 1285 } 1286 1287 ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command."); 1288 ctx.glUseProgram(program.getProgram()); 1289 ctx.glUniform1ui(uvec4_f, 0); 1290 ctx.expectError(GL_INVALID_OPERATION); 1291 ctx.glUniform2ui(uvec4_f, 0, 0); 1292 ctx.expectError(GL_INVALID_OPERATION); 1293 ctx.glUniform3ui(uvec4_f, 0, 0, 0); 1294 ctx.expectError(GL_INVALID_OPERATION); 1295 ctx.glUniform4ui(uvec4_f, 0, 0, 0, 0); 1296 ctx.expectError(GL_NO_ERROR); 1297 ctx.endSection(); 1298 1299 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type int, ivec2, ivec3, ivec4, or an array of these."); 1300 ctx.glUseProgram(program.getProgram()); 1301 ctx.glUniform1ui(ivec4_f, 0); 1302 ctx.expectError(GL_INVALID_OPERATION); 1303 ctx.glUniform2ui(ivec4_f, 0, 0); 1304 ctx.expectError(GL_INVALID_OPERATION); 1305 ctx.glUniform3ui(ivec4_f, 0, 0, 0); 1306 ctx.expectError(GL_INVALID_OPERATION); 1307 ctx.glUniform4ui(ivec4_f, 0, 0, 0, 0); 1308 ctx.expectError(GL_INVALID_OPERATION); 1309 ctx.endSection(); 1310 1311 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}i is used to load a uniform variable of type float, vec2, vec3, or vec4."); 1312 ctx.glUseProgram(program.getProgram()); 1313 ctx.glUniform1ui(vec4_v, 0); 1314 ctx.expectError(GL_INVALID_OPERATION); 1315 ctx.glUniform2ui(vec4_v, 0, 0); 1316 ctx.expectError(GL_INVALID_OPERATION); 1317 ctx.glUniform3ui(vec4_v, 0, 0, 0); 1318 ctx.expectError(GL_INVALID_OPERATION); 1319 ctx.glUniform4ui(vec4_v, 0, 0, 0, 0); 1320 ctx.expectError(GL_INVALID_OPERATION); 1321 ctx.endSection(); 1322 1323 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv."); 1324 ctx.glUseProgram(program.getProgram()); 1325 ctx.glUniform1ui(sampler_f, 0); 1326 ctx.expectError(GL_INVALID_OPERATION); 1327 ctx.endSection(); 1328 1329 ctx.glUseProgram(0); 1330 } 1331 1332 void uniformui_invalid_location (NegativeTestContext& ctx) 1333 { 1334 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1335 1336 ctx.glUseProgram(program.getProgram()); 1337 ctx.expectError(GL_NO_ERROR); 1338 1339 ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 1340 ctx.glUseProgram(program.getProgram()); 1341 ctx.glUniform1i(-2, 0); 1342 ctx.expectError(GL_INVALID_OPERATION); 1343 ctx.glUniform2i(-2, 0, 0); 1344 ctx.expectError(GL_INVALID_OPERATION); 1345 ctx.glUniform3i(-2, 0, 0, 0); 1346 ctx.expectError(GL_INVALID_OPERATION); 1347 ctx.glUniform4i(-2, 0, 0, 0, 0); 1348 ctx.expectError(GL_INVALID_OPERATION); 1349 1350 ctx.glUseProgram(program.getProgram()); 1351 ctx.glUniform1i(-1, 0); 1352 ctx.expectError(GL_NO_ERROR); 1353 ctx.glUniform2i(-1, 0, 0); 1354 ctx.expectError(GL_NO_ERROR); 1355 ctx.glUniform3i(-1, 0, 0, 0); 1356 ctx.expectError(GL_NO_ERROR); 1357 ctx.glUniform4i(-1, 0, 0, 0, 0); 1358 ctx.expectError(GL_NO_ERROR); 1359 ctx.endSection(); 1360 1361 ctx.glUseProgram(0); 1362 } 1363 1364 // ctx.glUniform{1234}uiv 1365 1366 void uniformuiv_invalid_program (NegativeTestContext& ctx) 1367 { 1368 std::vector<GLuint> data(4); 1369 1370 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object."); 1371 ctx.glUseProgram(0); 1372 ctx.glUniform1uiv(-1, 1, &data[0]); 1373 ctx.expectError(GL_INVALID_OPERATION); 1374 ctx.glUniform2uiv(-1, 1, &data[0]); 1375 ctx.expectError(GL_INVALID_OPERATION); 1376 ctx.glUniform3uiv(-1, 1, &data[0]); 1377 ctx.expectError(GL_INVALID_OPERATION); 1378 ctx.glUniform4uiv(-1, 1, &data[0]); 1379 ctx.expectError(GL_INVALID_OPERATION); 1380 ctx.endSection(); 1381 } 1382 1383 void uniformuiv_incompatible_type (NegativeTestContext& ctx) 1384 { 1385 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1386 1387 ctx.glUseProgram(program.getProgram()); 1388 GLint vec4_v = ctx.glGetUniformLocation(program.getProgram(), "vec4_v"); // vec4 1389 GLint ivec4_f = ctx.glGetUniformLocation(program.getProgram(), "ivec4_f"); // ivec4 1390 GLint uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4 1391 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D 1392 ctx.expectError(GL_NO_ERROR); 1393 1394 if (vec4_v == -1 || ivec4_f == -1 || uvec4_f == -1 || sampler_f == -1) 1395 { 1396 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 1397 ctx.fail("Failed to retrieve uniform location"); 1398 } 1399 1400 std::vector<GLuint> data(4); 1401 1402 ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command."); 1403 ctx.glUseProgram(program.getProgram()); 1404 ctx.glUniform1uiv(uvec4_f, 1, &data[0]); 1405 ctx.expectError(GL_INVALID_OPERATION); 1406 ctx.glUniform2uiv(uvec4_f, 1, &data[0]); 1407 ctx.expectError(GL_INVALID_OPERATION); 1408 ctx.glUniform3uiv(uvec4_f, 1, &data[0]); 1409 ctx.expectError(GL_INVALID_OPERATION); 1410 ctx.glUniform4uiv(uvec4_f, 1, &data[0]); 1411 ctx.expectError(GL_NO_ERROR); 1412 ctx.endSection(); 1413 1414 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}uiv is used to load a uniform variable of type float, vec2, vec3, or vec4."); 1415 ctx.glUseProgram(program.getProgram()); 1416 ctx.glUniform1uiv(vec4_v, 1, &data[0]); 1417 ctx.expectError(GL_INVALID_OPERATION); 1418 ctx.glUniform2uiv(vec4_v, 1, &data[0]); 1419 ctx.expectError(GL_INVALID_OPERATION); 1420 ctx.glUniform3uiv(vec4_v, 1, &data[0]); 1421 ctx.expectError(GL_INVALID_OPERATION); 1422 ctx.glUniform4uiv(vec4_v, 1, &data[0]); 1423 ctx.expectError(GL_INVALID_OPERATION); 1424 ctx.endSection(); 1425 1426 ctx.beginSection("GL_INVALID_OPERATION is generated if ctx.glUniform{1234}uiv is used to load a uniform variable of type int, ivec2, ivec3 or ivec4."); 1427 ctx.glUseProgram(program.getProgram()); 1428 ctx.glUniform1uiv(ivec4_f, 1, &data[0]); 1429 ctx.expectError(GL_INVALID_OPERATION); 1430 ctx.glUniform2uiv(ivec4_f, 1, &data[0]); 1431 ctx.expectError(GL_INVALID_OPERATION); 1432 ctx.glUniform3uiv(ivec4_f, 1, &data[0]); 1433 ctx.expectError(GL_INVALID_OPERATION); 1434 ctx.glUniform4uiv(ivec4_f, 1, &data[0]); 1435 ctx.expectError(GL_INVALID_OPERATION); 1436 ctx.endSection(); 1437 1438 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv."); 1439 ctx.glUseProgram(program.getProgram()); 1440 ctx.glUniform1uiv(sampler_f, 1, &data[0]); 1441 ctx.expectError(GL_INVALID_OPERATION); 1442 ctx.endSection(); 1443 1444 ctx.glUseProgram(0); 1445 } 1446 1447 void uniformuiv_invalid_location (NegativeTestContext& ctx) 1448 { 1449 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1450 1451 ctx.glUseProgram(program.getProgram()); 1452 ctx.expectError(GL_NO_ERROR); 1453 1454 std::vector<GLuint> data(4); 1455 1456 ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 1457 ctx.glUseProgram(program.getProgram()); 1458 ctx.glUniform1uiv(-2, 1, &data[0]); 1459 ctx.expectError(GL_INVALID_OPERATION); 1460 ctx.glUniform2uiv(-2, 1, &data[0]); 1461 ctx.expectError(GL_INVALID_OPERATION); 1462 ctx.glUniform3uiv(-2, 1, &data[0]); 1463 ctx.expectError(GL_INVALID_OPERATION); 1464 ctx.glUniform4uiv(-2, 1, &data[0]); 1465 ctx.expectError(GL_INVALID_OPERATION); 1466 1467 ctx.glUseProgram(program.getProgram()); 1468 ctx.glUniform1uiv(-1, 1, &data[0]); 1469 ctx.expectError(GL_NO_ERROR); 1470 ctx.glUniform2uiv(-1, 1, &data[0]); 1471 ctx.expectError(GL_NO_ERROR); 1472 ctx.glUniform3uiv(-1, 1, &data[0]); 1473 ctx.expectError(GL_NO_ERROR); 1474 ctx.glUniform4uiv(-1, 1, &data[0]); 1475 ctx.expectError(GL_NO_ERROR); 1476 ctx.endSection(); 1477 1478 ctx.glUseProgram(0); 1479 } 1480 1481 void uniformuiv_invalid_count (NegativeTestContext& ctx) 1482 { 1483 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1484 1485 ctx.glUseProgram (program.getProgram()); 1486 int uvec4_f = ctx.glGetUniformLocation(program.getProgram(), "uvec4_f"); // uvec4 1487 ctx.expectError(GL_NO_ERROR); 1488 1489 if (uvec4_f == -1) 1490 { 1491 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 1492 ctx.fail("Failed to retrieve uniform location"); 1493 } 1494 1495 std::vector<GLuint> data(8); 1496 1497 ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable."); 1498 ctx.glUseProgram(program.getProgram()); 1499 ctx.glUniform1uiv(uvec4_f, 2, &data[0]); 1500 ctx.expectError(GL_INVALID_OPERATION); 1501 ctx.glUniform2uiv(uvec4_f, 2, &data[0]); 1502 ctx.expectError(GL_INVALID_OPERATION); 1503 ctx.glUniform3uiv(uvec4_f, 2, &data[0]); 1504 ctx.expectError(GL_INVALID_OPERATION); 1505 ctx.glUniform4uiv(uvec4_f, 2, &data[0]); 1506 ctx.expectError(GL_INVALID_OPERATION); 1507 ctx.endSection(); 1508 1509 ctx.glUseProgram(0); 1510 } 1511 1512 1513 // ctx.glUniformMatrix*fv 1514 1515 void uniform_matrixfv_invalid_program (NegativeTestContext& ctx) 1516 { 1517 std::vector<GLfloat> data(16); 1518 1519 ctx.beginSection("GL_INVALID_OPERATION is generated if there is no current program object."); 1520 ctx.glUseProgram(0); 1521 ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]); 1522 ctx.expectError(GL_INVALID_OPERATION); 1523 ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]); 1524 ctx.expectError(GL_INVALID_OPERATION); 1525 ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]); 1526 ctx.expectError(GL_INVALID_OPERATION); 1527 1528 ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]); 1529 ctx.expectError(GL_INVALID_OPERATION); 1530 ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]); 1531 ctx.expectError(GL_INVALID_OPERATION); 1532 ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]); 1533 ctx.expectError(GL_INVALID_OPERATION); 1534 ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]); 1535 ctx.expectError(GL_INVALID_OPERATION); 1536 ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]); 1537 ctx.expectError(GL_INVALID_OPERATION); 1538 ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]); 1539 ctx.expectError(GL_INVALID_OPERATION); 1540 ctx.endSection(); 1541 } 1542 1543 void uniform_matrixfv_incompatible_type (NegativeTestContext& ctx) 1544 { 1545 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1546 1547 ctx.glUseProgram (program.getProgram()); 1548 GLint mat4_v = ctx.glGetUniformLocation(program.getProgram(), "mat4_v"); // mat4 1549 GLint sampler_f = ctx.glGetUniformLocation(program.getProgram(), "sampler_f"); // sampler2D 1550 ctx.expectError(GL_NO_ERROR); 1551 1552 if (mat4_v == -1 || sampler_f == -1) 1553 { 1554 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 1555 ctx.fail("Failed to retrieve uniform location"); 1556 } 1557 1558 std::vector<GLfloat> data(16); 1559 1560 ctx.beginSection("GL_INVALID_OPERATION is generated if the size of the uniform variable declared in the shader does not match the size indicated by the ctx.glUniform command."); 1561 ctx.glUseProgram(program.getProgram()); 1562 ctx.glUniformMatrix2fv(mat4_v, 1, GL_FALSE, &data[0]); 1563 ctx.expectError(GL_INVALID_OPERATION); 1564 ctx.glUniformMatrix3fv(mat4_v, 1, GL_FALSE, &data[0]); 1565 ctx.expectError(GL_INVALID_OPERATION); 1566 ctx.glUniformMatrix4fv(mat4_v, 1, GL_FALSE, &data[0]); 1567 ctx.expectError(GL_NO_ERROR); 1568 1569 ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]); 1570 ctx.expectError(GL_INVALID_OPERATION); 1571 ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]); 1572 ctx.expectError(GL_INVALID_OPERATION); 1573 ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]); 1574 ctx.expectError(GL_INVALID_OPERATION); 1575 ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]); 1576 ctx.expectError(GL_INVALID_OPERATION); 1577 ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]); 1578 ctx.expectError(GL_INVALID_OPERATION); 1579 ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]); 1580 ctx.expectError(GL_INVALID_OPERATION); 1581 ctx.endSection(); 1582 1583 ctx.beginSection("GL_INVALID_OPERATION is generated if a sampler is loaded using a command other than ctx.glUniform1i and ctx.glUniform1iv."); 1584 ctx.glUseProgram(program.getProgram()); 1585 ctx.glUniformMatrix2fv(sampler_f, 1, GL_FALSE, &data[0]); 1586 ctx.expectError(GL_INVALID_OPERATION); 1587 ctx.glUniformMatrix3fv(sampler_f, 1, GL_FALSE, &data[0]); 1588 ctx.expectError(GL_INVALID_OPERATION); 1589 ctx.glUniformMatrix4fv(sampler_f, 1, GL_FALSE, &data[0]); 1590 ctx.expectError(GL_INVALID_OPERATION); 1591 1592 ctx.glUniformMatrix2x3fv(sampler_f, 1, GL_FALSE, &data[0]); 1593 ctx.expectError(GL_INVALID_OPERATION); 1594 ctx.glUniformMatrix3x2fv(sampler_f, 1, GL_FALSE, &data[0]); 1595 ctx.expectError(GL_INVALID_OPERATION); 1596 ctx.glUniformMatrix2x4fv(sampler_f, 1, GL_FALSE, &data[0]); 1597 ctx.expectError(GL_INVALID_OPERATION); 1598 ctx.glUniformMatrix4x2fv(sampler_f, 1, GL_FALSE, &data[0]); 1599 ctx.expectError(GL_INVALID_OPERATION); 1600 ctx.glUniformMatrix3x4fv(sampler_f, 1, GL_FALSE, &data[0]); 1601 ctx.expectError(GL_INVALID_OPERATION); 1602 ctx.glUniformMatrix4x3fv(sampler_f, 1, GL_FALSE, &data[0]); 1603 ctx.expectError(GL_INVALID_OPERATION); 1604 ctx.endSection(); 1605 1606 ctx.glUseProgram(0); 1607 } 1608 1609 void uniform_matrixfv_invalid_location (NegativeTestContext& ctx) 1610 { 1611 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1612 1613 ctx.glUseProgram(program.getProgram()); 1614 ctx.expectError(GL_NO_ERROR); 1615 1616 std::vector<GLfloat> data(16); 1617 1618 ctx.beginSection("GL_INVALID_OPERATION is generated if location is an invalid uniform location for the current program object and location is not equal to -1."); 1619 ctx.glUseProgram(program.getProgram()); 1620 ctx.glUniformMatrix2fv(-2, 1, GL_FALSE, &data[0]); 1621 ctx.expectError(GL_INVALID_OPERATION); 1622 ctx.glUniformMatrix3fv(-2, 1, GL_FALSE, &data[0]); 1623 ctx.expectError(GL_INVALID_OPERATION); 1624 ctx.glUniformMatrix4fv(-2, 1, GL_FALSE, &data[0]); 1625 ctx.expectError(GL_INVALID_OPERATION); 1626 1627 ctx.glUniformMatrix2x3fv(-2, 1, GL_FALSE, &data[0]); 1628 ctx.expectError(GL_INVALID_OPERATION); 1629 ctx.glUniformMatrix3x2fv(-2, 1, GL_FALSE, &data[0]); 1630 ctx.expectError(GL_INVALID_OPERATION); 1631 ctx.glUniformMatrix2x4fv(-2, 1, GL_FALSE, &data[0]); 1632 ctx.expectError(GL_INVALID_OPERATION); 1633 ctx.glUniformMatrix4x2fv(-2, 1, GL_FALSE, &data[0]); 1634 ctx.expectError(GL_INVALID_OPERATION); 1635 ctx.glUniformMatrix3x4fv(-2, 1, GL_FALSE, &data[0]); 1636 ctx.expectError(GL_INVALID_OPERATION); 1637 ctx.glUniformMatrix4x3fv(-2, 1, GL_FALSE, &data[0]); 1638 ctx.expectError(GL_INVALID_OPERATION); 1639 1640 ctx.glUseProgram(program.getProgram()); 1641 ctx.glUniformMatrix2fv(-1, 1, GL_FALSE, &data[0]); 1642 ctx.expectError(GL_NO_ERROR); 1643 ctx.glUniformMatrix3fv(-1, 1, GL_FALSE, &data[0]); 1644 ctx.expectError(GL_NO_ERROR); 1645 ctx.glUniformMatrix4fv(-1, 1, GL_FALSE, &data[0]); 1646 ctx.expectError(GL_NO_ERROR); 1647 1648 ctx.glUniformMatrix2x3fv(-1, 1, GL_FALSE, &data[0]); 1649 ctx.expectError(GL_NO_ERROR); 1650 ctx.glUniformMatrix3x2fv(-1, 1, GL_FALSE, &data[0]); 1651 ctx.expectError(GL_NO_ERROR); 1652 ctx.glUniformMatrix2x4fv(-1, 1, GL_FALSE, &data[0]); 1653 ctx.expectError(GL_NO_ERROR); 1654 ctx.glUniformMatrix4x2fv(-1, 1, GL_FALSE, &data[0]); 1655 ctx.expectError(GL_NO_ERROR); 1656 ctx.glUniformMatrix3x4fv(-1, 1, GL_FALSE, &data[0]); 1657 ctx.expectError(GL_NO_ERROR); 1658 ctx.glUniformMatrix4x3fv(-1, 1, GL_FALSE, &data[0]); 1659 ctx.expectError(GL_NO_ERROR); 1660 ctx.endSection(); 1661 1662 ctx.glUseProgram(0); 1663 } 1664 1665 void uniform_matrixfv_invalid_count (NegativeTestContext& ctx) 1666 { 1667 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(uniformTestVertSource, uniformTestFragSource)); 1668 1669 ctx.glUseProgram (program.getProgram()); 1670 GLint mat4_v = ctx.glGetUniformLocation(program.getProgram(), "mat4_v"); // mat4 1671 ctx.expectError(GL_NO_ERROR); 1672 1673 if (mat4_v == -1) 1674 { 1675 ctx.getLog() << TestLog::Message << "// ERROR: Failed to retrieve uniform location" << TestLog::EndMessage; 1676 ctx.fail("Failed to retrieve uniform location"); 1677 } 1678 1679 std::vector<GLfloat> data(32); 1680 1681 ctx.beginSection("GL_INVALID_OPERATION is generated if count is greater than 1 and the indicated uniform variable is not an array variable."); 1682 ctx.glUseProgram(program.getProgram()); 1683 ctx.glUniformMatrix2fv(mat4_v, 2, GL_FALSE, &data[0]); 1684 ctx.expectError(GL_INVALID_OPERATION); 1685 ctx.glUniformMatrix3fv(mat4_v, 2, GL_FALSE, &data[0]); 1686 ctx.expectError(GL_INVALID_OPERATION); 1687 ctx.glUniformMatrix4fv(mat4_v, 2, GL_FALSE, &data[0]); 1688 ctx.expectError(GL_INVALID_OPERATION); 1689 1690 ctx.glUniformMatrix2x3fv(mat4_v, 1, GL_FALSE, &data[0]); 1691 ctx.expectError(GL_INVALID_OPERATION); 1692 ctx.glUniformMatrix3x2fv(mat4_v, 1, GL_FALSE, &data[0]); 1693 ctx.expectError(GL_INVALID_OPERATION); 1694 ctx.glUniformMatrix2x4fv(mat4_v, 1, GL_FALSE, &data[0]); 1695 ctx.expectError(GL_INVALID_OPERATION); 1696 ctx.glUniformMatrix4x2fv(mat4_v, 1, GL_FALSE, &data[0]); 1697 ctx.expectError(GL_INVALID_OPERATION); 1698 ctx.glUniformMatrix3x4fv(mat4_v, 1, GL_FALSE, &data[0]); 1699 ctx.expectError(GL_INVALID_OPERATION); 1700 ctx.glUniformMatrix4x3fv(mat4_v, 1, GL_FALSE, &data[0]); 1701 ctx.expectError(GL_INVALID_OPERATION); 1702 ctx.endSection(); 1703 1704 ctx.glUseProgram(0); 1705 } 1706 1707 // Transform feedback 1708 void gen_transform_feedbacks (NegativeTestContext& ctx) 1709 { 1710 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative."); 1711 GLuint id = 0; 1712 ctx.glGenTransformFeedbacks(-1, &id); 1713 ctx.expectError(GL_INVALID_VALUE); 1714 ctx.endSection(); 1715 } 1716 1717 void bind_transform_feedback (NegativeTestContext& ctx) 1718 { 1719 GLuint tfID[2]; 1720 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 1721 deUint32 buf = 0x1234; 1722 const char* tfVarying = "gl_Position"; 1723 1724 ctx.glGenBuffers (1, &buf); 1725 ctx.glGenTransformFeedbacks (2, tfID); 1726 1727 ctx.beginSection("GL_INVALID_ENUM is generated if target is not GL_TRANSFORM_FEEDBACK."); 1728 ctx.glBindTransformFeedback(-1, tfID[0]); 1729 ctx.expectError(GL_INVALID_ENUM); 1730 ctx.endSection(); 1731 1732 ctx.beginSection("GL_INVALID_OPERATION is generated if the transform feedback operation is active on the currently bound transform feedback object, and is not paused."); 1733 ctx.glUseProgram (program.getProgram()); 1734 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS); 1735 ctx.glLinkProgram (program.getProgram()); 1736 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[0]); 1737 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf); 1738 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW); 1739 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); 1740 ctx.glBeginTransformFeedback (GL_TRIANGLES); 1741 ctx.expectError (GL_NO_ERROR); 1742 1743 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[1]); 1744 ctx.expectError (GL_INVALID_OPERATION); 1745 1746 ctx.glEndTransformFeedback (); 1747 ctx.expectError (GL_NO_ERROR); 1748 ctx.endSection(); 1749 1750 ctx.glUseProgram (0); 1751 ctx.glDeleteBuffers (1, &buf); 1752 ctx.glDeleteTransformFeedbacks (2, tfID); 1753 ctx.expectError (GL_NO_ERROR); 1754 } 1755 1756 void delete_transform_feedbacks (NegativeTestContext& ctx) 1757 { 1758 GLuint id = 0; 1759 ctx.glGenTransformFeedbacks(1, &id); 1760 1761 ctx.beginSection("GL_INVALID_VALUE is generated if n is negative."); 1762 ctx.glDeleteTransformFeedbacks(-1, &id); 1763 ctx.expectError(GL_INVALID_VALUE); 1764 ctx.endSection(); 1765 1766 ctx.glDeleteTransformFeedbacks(1, &id); 1767 } 1768 1769 void begin_transform_feedback (NegativeTestContext& ctx) 1770 { 1771 GLuint tfID[2]; 1772 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 1773 deUint32 buf = 0x1234; 1774 const char* tfVarying = "gl_Position"; 1775 1776 ctx.glGenBuffers (1, &buf); 1777 ctx.glGenTransformFeedbacks (2, tfID); 1778 1779 ctx.glUseProgram (program.getProgram()); 1780 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS); 1781 ctx.glLinkProgram (program.getProgram()); 1782 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[0]); 1783 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf); 1784 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW); 1785 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); 1786 ctx.expectError (GL_NO_ERROR); 1787 1788 ctx.beginSection("GL_INVALID_ENUM is generated if primitiveMode is not one of GL_POINTS, GL_LINES, or GL_TRIANGLES."); 1789 ctx.glBeginTransformFeedback (-1); 1790 ctx.expectError (GL_INVALID_ENUM); 1791 ctx.endSection(); 1792 1793 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is already active."); 1794 ctx.glBeginTransformFeedback (GL_TRIANGLES); 1795 ctx.expectError (GL_NO_ERROR); 1796 ctx.glBeginTransformFeedback (GL_POINTS); 1797 ctx.expectError (GL_INVALID_OPERATION); 1798 ctx.endSection(); 1799 1800 ctx.beginSection("GL_INVALID_OPERATION is generated if any binding point used in transform feedback mode does not have a buffer object bound."); 1801 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0); 1802 ctx.glBeginTransformFeedback (GL_TRIANGLES); 1803 ctx.expectError (GL_INVALID_OPERATION); 1804 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); 1805 ctx.endSection(); 1806 1807 ctx.beginSection("GL_INVALID_OPERATION is generated if no binding points would be used because no program object is active."); 1808 ctx.glUseProgram (0); 1809 ctx.glBeginTransformFeedback (GL_TRIANGLES); 1810 ctx.expectError (GL_INVALID_OPERATION); 1811 ctx.glUseProgram (program.getProgram()); 1812 ctx.endSection(); 1813 1814 ctx.beginSection("GL_INVALID_OPERATION is generated if no binding points would be used because the active program object has specified no varying variables to record."); 1815 ctx.glTransformFeedbackVaryings (program.getProgram(), 0, 0, GL_INTERLEAVED_ATTRIBS); 1816 ctx.glBeginTransformFeedback (GL_TRIANGLES); 1817 ctx.expectError (GL_INVALID_OPERATION); 1818 ctx.endSection(); 1819 1820 ctx.glEndTransformFeedback (); 1821 ctx.glDeleteBuffers (1, &buf); 1822 ctx.glDeleteTransformFeedbacks (2, tfID); 1823 ctx.expectError (GL_NO_ERROR); 1824 } 1825 1826 void pause_transform_feedback (NegativeTestContext& ctx) 1827 { 1828 GLuint tfID[2]; 1829 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 1830 deUint32 buf = 0x1234; 1831 const char* tfVarying = "gl_Position"; 1832 1833 ctx.glGenBuffers (1, &buf); 1834 ctx.glGenTransformFeedbacks (2, tfID); 1835 1836 ctx.glUseProgram (program.getProgram()); 1837 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS); 1838 ctx.glLinkProgram (program.getProgram()); 1839 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[0]); 1840 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf); 1841 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW); 1842 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); 1843 ctx.expectError (GL_NO_ERROR); 1844 1845 ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is paused."); 1846 ctx.glPauseTransformFeedback (); 1847 ctx.expectError (GL_INVALID_OPERATION); 1848 ctx.glBeginTransformFeedback (GL_TRIANGLES); 1849 ctx.glPauseTransformFeedback (); 1850 ctx.expectError (GL_NO_ERROR); 1851 ctx.glPauseTransformFeedback (); 1852 ctx.expectError (GL_INVALID_OPERATION); 1853 ctx.endSection(); 1854 1855 ctx.glEndTransformFeedback (); 1856 ctx.glDeleteBuffers (1, &buf); 1857 ctx.glDeleteTransformFeedbacks (2, tfID); 1858 ctx.expectError (GL_NO_ERROR); 1859 } 1860 1861 void resume_transform_feedback (NegativeTestContext& ctx) 1862 { 1863 GLuint tfID[2]; 1864 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 1865 deUint32 buf = 0x1234; 1866 const char* tfVarying = "gl_Position"; 1867 1868 ctx.glGenBuffers (1, &buf); 1869 ctx.glGenTransformFeedbacks (2, tfID); 1870 1871 ctx.glUseProgram (program.getProgram()); 1872 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS); 1873 ctx.glLinkProgram (program.getProgram()); 1874 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID[0]); 1875 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf); 1876 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW); 1877 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); 1878 ctx.expectError (GL_NO_ERROR); 1879 1880 ctx.beginSection("GL_INVALID_OPERATION is generated if the currently bound transform feedback object is not active or is not paused."); 1881 ctx.glResumeTransformFeedback (); 1882 ctx.expectError (GL_INVALID_OPERATION); 1883 ctx.glBeginTransformFeedback (GL_TRIANGLES); 1884 ctx.glResumeTransformFeedback (); 1885 ctx.expectError (GL_INVALID_OPERATION); 1886 ctx.glPauseTransformFeedback (); 1887 ctx.glResumeTransformFeedback (); 1888 ctx.expectError (GL_NO_ERROR); 1889 ctx.endSection(); 1890 1891 ctx.glEndTransformFeedback (); 1892 ctx.glDeleteBuffers (1, &buf); 1893 ctx.glDeleteTransformFeedbacks (2, tfID); 1894 ctx.expectError (GL_NO_ERROR); 1895 } 1896 1897 void end_transform_feedback (NegativeTestContext& ctx) 1898 { 1899 GLuint tfID = 0; 1900 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 1901 deUint32 buf = 0x1234; 1902 const char* tfVarying = "gl_Position"; 1903 1904 ctx.glGenBuffers (1, &buf); 1905 ctx.glGenTransformFeedbacks (1, &tfID); 1906 1907 ctx.glUseProgram (program.getProgram()); 1908 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS); 1909 ctx.glLinkProgram (program.getProgram()); 1910 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID); 1911 ctx.glBindBuffer (GL_TRANSFORM_FEEDBACK_BUFFER, buf); 1912 ctx.glBufferData (GL_TRANSFORM_FEEDBACK_BUFFER, 32, DE_NULL, GL_DYNAMIC_DRAW); 1913 ctx.glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf); 1914 ctx.expectError (GL_NO_ERROR); 1915 1916 ctx.beginSection("GL_INVALID_OPERATION is generated if transform feedback is not active."); 1917 ctx.glEndTransformFeedback (); 1918 ctx.expectError (GL_INVALID_OPERATION); 1919 ctx.glBeginTransformFeedback (GL_TRIANGLES); 1920 ctx.glEndTransformFeedback (); 1921 ctx.expectError (GL_NO_ERROR); 1922 ctx.endSection(); 1923 1924 ctx.glDeleteBuffers (1, &buf); 1925 ctx.glDeleteTransformFeedbacks (1, &tfID); 1926 ctx.expectError (GL_NO_ERROR); 1927 } 1928 1929 void get_transform_feedback_varying (NegativeTestContext& ctx) 1930 { 1931 GLuint tfID = 0; 1932 glu::ShaderProgram program (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 1933 glu::ShaderProgram programInvalid (ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, "")); 1934 const char* tfVarying = "gl_Position"; 1935 int maxTransformFeedbackVaryings = 0; 1936 1937 GLsizei length; 1938 GLsizei size; 1939 GLenum type; 1940 char name[32]; 1941 1942 ctx.glGenTransformFeedbacks (1, &tfID); 1943 1944 ctx.glTransformFeedbackVaryings (program.getProgram(), 1, &tfVarying, GL_INTERLEAVED_ATTRIBS); 1945 ctx.expectError (GL_NO_ERROR); 1946 ctx.glLinkProgram (program.getProgram()); 1947 ctx.expectError (GL_NO_ERROR); 1948 1949 ctx.glBindTransformFeedback (GL_TRANSFORM_FEEDBACK, tfID); 1950 ctx.expectError (GL_NO_ERROR); 1951 1952 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object."); 1953 ctx.glGetTransformFeedbackVarying (-1, 0, 32, &length, &size, &type, &name[0]); 1954 ctx.expectError (GL_INVALID_VALUE); 1955 ctx.endSection(); 1956 1957 ctx.beginSection("GL_INVALID_VALUE is generated if index is greater or equal to the value of GL_TRANSFORM_FEEDBACK_VARYINGS."); 1958 ctx.glGetProgramiv (program.getProgram(), GL_TRANSFORM_FEEDBACK_VARYINGS, &maxTransformFeedbackVaryings); 1959 ctx.glGetTransformFeedbackVarying (program.getProgram(), maxTransformFeedbackVaryings, 32, &length, &size, &type, &name[0]); 1960 ctx.expectError (GL_INVALID_VALUE); 1961 ctx.endSection(); 1962 1963 ctx.beginSection("GL_INVALID_OPERATION or GL_INVALID_VALUE is generated program has not been linked."); 1964 ctx.glGetTransformFeedbackVarying (programInvalid.getProgram(), 0, 32, &length, &size, &type, &name[0]); 1965 ctx.expectError (GL_INVALID_OPERATION, GL_INVALID_VALUE); 1966 ctx.endSection(); 1967 1968 ctx.glDeleteTransformFeedbacks (1, &tfID); 1969 ctx.expectError (GL_NO_ERROR); 1970 } 1971 1972 void transform_feedback_varyings (NegativeTestContext& ctx) 1973 { 1974 GLuint tfID = 0; 1975 glu::ShaderProgram program(ctx.getRenderContext(), glu::makeVtxFragSources(vertexShaderSource, fragmentShaderSource)); 1976 const char* tfVarying = "gl_Position"; 1977 GLint maxTransformFeedbackSeparateAttribs = 0; 1978 1979 ctx.glGenTransformFeedbacks (1, &tfID); 1980 ctx.expectError (GL_NO_ERROR); 1981 1982 ctx.beginSection("GL_INVALID_VALUE is generated if program is not the name of a program object."); 1983 ctx.glTransformFeedbackVaryings (0, 1, &tfVarying, GL_INTERLEAVED_ATTRIBS); 1984 ctx.expectError (GL_INVALID_VALUE); 1985 ctx.endSection(); 1986 1987 ctx.beginSection("GL_INVALID_VALUE is generated if bufferMode is GL_SEPARATE_ATTRIBS and count is greater than GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS."); 1988 ctx.glGetIntegerv (GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, &maxTransformFeedbackSeparateAttribs); 1989 ctx.glTransformFeedbackVaryings (program.getProgram(), maxTransformFeedbackSeparateAttribs+1, &tfVarying, GL_SEPARATE_ATTRIBS); 1990 ctx.expectError (GL_INVALID_VALUE); 1991 ctx.endSection(); 1992 1993 ctx.glDeleteTransformFeedbacks (1, &tfID); 1994 ctx.expectError (GL_NO_ERROR); 1995 } 1996 1997 std::vector<FunctionContainer> getNegativeShaderApiTestFunctions () 1998 { 1999 FunctionContainer funcs[] = 2000 { 2001 {create_shader, "create_shader", "Invalid glCreateShader() usage" }, 2002 {shader_source, "shader_source", "Invalid glShaderSource() usage" }, 2003 {compile_shader, "compile_shader", "Invalid glCompileShader() usage" }, 2004 {delete_shader, "delete_shader", "Invalid glDeleteShader() usage" }, 2005 {shader_binary, "shader_binary", "Invalid glShaderBinary() usage" }, 2006 {attach_shader, "attach_shader", "Invalid glAttachShader() usage" }, 2007 {detach_shader, "detach_shader", "Invalid glDetachShader() usage" }, 2008 {link_program, "link_program", "Invalid glLinkProgram() usage" }, 2009 {use_program, "use_program", "Invalid glUseProgram() usage" }, 2010 {delete_program, "delete_program", "Invalid glDeleteProgram() usage" }, 2011 {validate_program, "validate_program", "Invalid glValidateProgram() usage" }, 2012 {get_program_binary, "get_program_binary", "Invalid glGetProgramBinary() usage" }, 2013 {program_binary, "program_binary", "Invalid glProgramBinary() usage" }, 2014 {program_parameteri, "program_parameteri", "Invalid glProgramParameteri() usage" }, 2015 {gen_samplers, "gen_samplers", "Invalid glGenSamplers() usage" }, 2016 {bind_sampler, "bind_sampler", "Invalid glBindSampler() usage" }, 2017 {delete_samplers, "delete_samplers", "Invalid glDeleteSamplers() usage" }, 2018 {get_sampler_parameteriv, "get_sampler_parameteriv", "Invalid glGetSamplerParameteriv() usage" }, 2019 {get_sampler_parameterfv, "get_sampler_parameterfv", "Invalid glGetSamplerParameterfv() usage" }, 2020 {sampler_parameteri, "sampler_parameteri", "Invalid glSamplerParameteri() usage" }, 2021 {sampler_parameteriv, "sampler_parameteriv", "Invalid glSamplerParameteriv() usage" }, 2022 {sampler_parameterf, "sampler_parameterf", "Invalid glSamplerParameterf() usage" }, 2023 {sampler_parameterfv, "sampler_parameterfv", "Invalid glSamplerParameterfv() usage" }, 2024 {get_attrib_location, "get_attrib_location", "Invalid glGetAttribLocation() usage" }, 2025 {get_uniform_location, "get_uniform_location", "Invalid glGetUniformLocation() usage" }, 2026 {bind_attrib_location, "bind_attrib_location", "Invalid glBindAttribLocation() usage" }, 2027 {uniform_block_binding, "uniform_block_binding", "Invalid glUniformBlockBinding() usage" }, 2028 {uniformf_invalid_program, "uniformf_invalid_program", "Invalid glUniform{1234}f() usage" }, 2029 {uniformf_incompatible_type, "uniformf_incompatible_type", "Invalid glUniform{1234}f() usage" }, 2030 {uniformf_invalid_location, "uniformf_invalid_location", "Invalid glUniform{1234}f() usage" }, 2031 {uniformfv_invalid_program, "uniformfv_invalid_program", "Invalid glUniform{1234}fv() usage" }, 2032 {uniformfv_incompatible_type, "uniformfv_incompatible_type", "Invalid glUniform{1234}fv() usage" }, 2033 {uniformfv_invalid_location, "uniformfv_invalid_location", "Invalid glUniform{1234}fv() usage" }, 2034 {uniformfv_invalid_count, "uniformfv_invalid_count", "Invalid glUniform{1234}fv() usage" }, 2035 {uniformi_invalid_program, "uniformi_invalid_program", "Invalid glUniform{1234}i() usage" }, 2036 {uniformi_incompatible_type, "uniformi_incompatible_type", "Invalid glUniform{1234}i() usage" }, 2037 {uniformi_invalid_location, "uniformi_invalid_location", "Invalid glUniform{1234}i() usage" }, 2038 {uniformiv_invalid_program, "uniformiv_invalid_program", "Invalid glUniform{1234}iv() usage" }, 2039 {uniformiv_incompatible_type, "uniformiv_incompatible_type", "Invalid glUniform{1234}iv() usage" }, 2040 {uniformiv_invalid_location, "uniformiv_invalid_location", "Invalid glUniform{1234}iv() usage" }, 2041 {uniformiv_invalid_count, "uniformiv_invalid_count", "Invalid glUniform{1234}iv() usage" }, 2042 {uniformui_invalid_program, "uniformui_invalid_program", "Invalid glUniform{234}ui() usage" }, 2043 {uniformui_incompatible_type, "uniformui_incompatible_type", "Invalid glUniform{1234}ui() usage" }, 2044 {uniformui_invalid_location, "uniformui_invalid_location", "Invalid glUniform{1234}ui() usage" }, 2045 {uniformuiv_invalid_program, "uniformuiv_invalid_program", "Invalid glUniform{234}uiv() usage" }, 2046 {uniformuiv_incompatible_type, "uniformuiv_incompatible_type", "Invalid glUniform{1234}uiv() usage" }, 2047 {uniformuiv_invalid_location, "uniformuiv_invalid_location", "Invalid glUniform{1234}uiv() usage" }, 2048 {uniformuiv_invalid_count, "uniformuiv_invalid_count", "Invalid glUniform{1234}uiv() usage" }, 2049 {uniform_matrixfv_invalid_program, "uniform_matrixfv_invalid_program", "Invalid glUniformMatrix{234}fv() usage" }, 2050 {uniform_matrixfv_incompatible_type, "uniform_matrixfv_incompatible_type", "Invalid glUniformMatrix{234}fv() usage" }, 2051 {uniform_matrixfv_invalid_location, "uniform_matrixfv_invalid_location", "Invalid glUniformMatrix{234}fv() usage" }, 2052 {uniform_matrixfv_invalid_count, "uniform_matrixfv_invalid_count", "Invalid glUniformMatrix{234}fv() usage" }, 2053 {gen_transform_feedbacks, "gen_transform_feedbacks", "Invalid glGenTransformFeedbacks() usage" }, 2054 {bind_transform_feedback, "bind_transform_feedback", "Invalid glBindTransformFeedback() usage" }, 2055 {delete_transform_feedbacks, "delete_transform_feedbacks", "Invalid glDeleteTransformFeedbacks() usage" }, 2056 {begin_transform_feedback, "begin_transform_feedback", "Invalid glBeginTransformFeedback() usage" }, 2057 {pause_transform_feedback, "pause_transform_feedback", "Invalid glPauseTransformFeedback() usage" }, 2058 {resume_transform_feedback, "resume_transform_feedback", "Invalid glResumeTransformFeedback() usage" }, 2059 {end_transform_feedback, "end_transform_feedback", "Invalid glEndTransformFeedback() usage" }, 2060 {get_transform_feedback_varying, "get_transform_feedback_varying", "Invalid glGetTransformFeedbackVarying() usage"}, 2061 {transform_feedback_varyings, "transform_feedback_varyings", "Invalid glTransformFeedbackVaryings() usage" }, 2062 }; 2063 2064 return std::vector<FunctionContainer>(DE_ARRAY_BEGIN(funcs), DE_ARRAY_END(funcs)); 2065 } 2066 2067 } // NegativeTestShared 2068 } // Functional 2069 } // gles31 2070 } // deqp 2071