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 State Query tests. 22 *//*--------------------------------------------------------------------*/ 23 24 #include "es3fIntegerStateQueryTests.hpp" 25 #include "es3fApiCase.hpp" 26 27 #include "glsStateQueryUtil.hpp" 28 29 #include "gluRenderContext.hpp" 30 #include "gluContextInfo.hpp" 31 #include "gluStrUtil.hpp" 32 33 #include "tcuRenderTarget.hpp" 34 35 #include "deRandom.hpp" 36 37 #include "glwEnums.hpp" 38 39 using namespace glw; // GLint and other GL types 40 using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard; 41 42 #ifndef GL_SLUMINANCE_NV 43 #define GL_SLUMINANCE_NV 0x8C46 44 #endif 45 #ifndef GL_SLUMINANCE_ALPHA_NV 46 #define GL_SLUMINANCE_ALPHA_NV 0x8C44 47 #endif 48 #ifndef GL_BGR_NV 49 #define GL_BGR_NV 0x80E0 50 #endif 51 52 namespace deqp 53 { 54 namespace gles3 55 { 56 namespace Functional 57 { 58 namespace IntegerStateQueryVerifiers 59 { 60 61 // StateVerifier 62 63 class StateVerifier : protected glu::CallLogWrapper 64 { 65 public: 66 StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix); 67 virtual ~StateVerifier (); // make GCC happy 68 69 const char* getTestNamePostfix (void) const; 70 71 virtual void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) = DE_NULL; 72 virtual void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) = DE_NULL; 73 virtual void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3) = DE_NULL; 74 virtual void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) = DE_NULL; 75 virtual void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) = DE_NULL; 76 virtual void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) = DE_NULL; 77 virtual void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) = DE_NULL; 78 virtual void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) = DE_NULL; 79 virtual void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) = DE_NULL; 80 81 private: 82 const char* const m_testNamePostfix; 83 }; 84 85 StateVerifier::StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix) 86 : glu::CallLogWrapper (gl, log) 87 , m_testNamePostfix (testNamePostfix) 88 { 89 enableLogging(true); 90 } 91 92 StateVerifier::~StateVerifier () 93 { 94 } 95 96 const char* StateVerifier::getTestNamePostfix (void) const 97 { 98 return m_testNamePostfix; 99 } 100 101 // GetBooleanVerifier 102 103 class GetBooleanVerifier : public StateVerifier 104 { 105 public: 106 GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log); 107 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference); 108 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3); 109 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3); 110 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 111 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference); 112 void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 113 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1); 114 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength); 115 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits); 116 }; 117 118 GetBooleanVerifier::GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log) 119 : StateVerifier(gl, log, "_getboolean") 120 { 121 } 122 123 void GetBooleanVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) 124 { 125 using tcu::TestLog; 126 127 StateQueryMemoryWriteGuard<GLboolean> state; 128 glGetBooleanv(name, &state); 129 130 if (!state.verifyValidity(testCtx)) 131 return; 132 133 const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE; 134 135 if (state != expectedGLState) 136 { 137 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << (expectedGLState==GL_TRUE ? "GL_TRUE" : "GL_FALSE") << "; got " << (state == GL_TRUE ? "GL_TRUE" : (state == GL_FALSE ? "GL_FALSE" : "non-boolean")) << TestLog::EndMessage; 138 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 139 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 140 } 141 } 142 143 void GetBooleanVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) 144 { 145 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true); 146 } 147 148 void GetBooleanVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3) 149 { 150 using tcu::TestLog; 151 152 StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4; 153 glGetBooleanv(name, boolVector4); 154 155 if (!boolVector4.verifyValidity(testCtx)) 156 return; 157 158 const GLboolean referenceAsGLBoolean[] = 159 { 160 reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 161 reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 162 reference2 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 163 reference3 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 164 }; 165 166 if ((enableRef0 && (boolVector4[0] != referenceAsGLBoolean[0])) || 167 (enableRef1 && (boolVector4[1] != referenceAsGLBoolean[1])) || 168 (enableRef2 && (boolVector4[2] != referenceAsGLBoolean[2])) || 169 (enableRef3 && (boolVector4[3] != referenceAsGLBoolean[3]))) 170 { 171 testCtx.getLog() << TestLog::Message << "// ERROR: expected " 172 << (enableRef0 ? (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", " 173 << (enableRef1 ? (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", " 174 << (enableRef2 ? (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", " 175 << (enableRef3 ? (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") : " - ") << TestLog::EndMessage; 176 177 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 178 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 179 } 180 } 181 182 void GetBooleanVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 183 { 184 using tcu::TestLog; 185 186 StateQueryMemoryWriteGuard<GLboolean> state; 187 glGetBooleanv(name, &state); 188 189 if (!state.verifyValidity(testCtx)) 190 return; 191 192 if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct) 193 return; 194 195 if (state == GL_FALSE) // state is zero 196 { 197 if (reference > 0) // and reference is greater than zero? 198 { 199 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage; 200 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 201 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 202 } 203 } 204 else 205 { 206 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage; 207 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 208 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 209 } 210 } 211 212 void GetBooleanVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) 213 { 214 using tcu::TestLog; 215 216 StateQueryMemoryWriteGuard<GLboolean> state; 217 glGetBooleanv(name, &state); 218 219 if (!state.verifyValidity(testCtx)) 220 return; 221 222 if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct) 223 return; 224 225 if (state == GL_FALSE) // state is zero 226 { 227 if (reference > 0) // and reference is greater than zero? 228 { 229 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage; 230 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 231 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 232 } 233 } 234 else 235 { 236 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage; 237 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 238 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 239 } 240 } 241 242 void GetBooleanVerifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 243 { 244 using tcu::TestLog; 245 246 StateQueryMemoryWriteGuard<GLboolean> state; 247 glGetBooleanv(name, &state); 248 249 if (!state.verifyValidity(testCtx)) 250 return; 251 252 if (state == GL_TRUE) // state is non-zero, could be less than reference (correct) 253 return; 254 255 if (state == GL_FALSE) // state is zero 256 { 257 if (reference < 0) // and reference is less than zero? 258 { 259 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage; 260 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 261 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 262 } 263 } 264 else 265 { 266 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage; 267 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 268 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 269 } 270 } 271 272 void GetBooleanVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) 273 { 274 using tcu::TestLog; 275 276 StateQueryMemoryWriteGuard<GLboolean[2]> boolVector; 277 glGetBooleanv(name, boolVector); 278 279 if (!boolVector.verifyValidity(testCtx)) 280 return; 281 282 const GLboolean referenceAsGLBoolean[2] = 283 { 284 reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 285 reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE 286 }; 287 288 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceAsGLBoolean); ++ndx) 289 { 290 if (boolVector[ndx] == GL_TRUE) // state is non-zero, could be greater than any integer 291 { 292 continue; 293 } 294 else if (boolVector[ndx] == GL_FALSE) // state is zero 295 { 296 if (referenceAsGLBoolean[ndx] > 0) // and reference is greater than zero? 297 { 298 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage; 299 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 300 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 301 } 302 } 303 else 304 { 305 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage; 306 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 307 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 308 } 309 } 310 } 311 312 void GetBooleanVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) 313 { 314 using tcu::TestLog; 315 316 StateQueryMemoryWriteGuard<GLboolean> state; 317 glGetBooleanv(name, &state); 318 319 if (!state.verifyValidity(testCtx)) 320 return; 321 322 for (size_t ndx = 0; ndx < referencesLength; ++ndx) 323 { 324 const GLboolean expectedGLState = references[ndx] ? GL_TRUE : GL_FALSE; 325 326 if (state == expectedGLState) 327 return; 328 } 329 330 testCtx.getLog() << TestLog::Message << "// ERROR: got " << (state==GL_TRUE ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage; 331 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 332 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 333 } 334 335 void GetBooleanVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) 336 { 337 // if stencilBits == 0, the mask is allowed to be either GL_TRUE or GL_FALSE 338 // otherwise it must be GL_TRUE 339 using tcu::TestLog; 340 341 StateQueryMemoryWriteGuard<GLboolean> state; 342 glGetBooleanv(name, &state); 343 344 if (!state.verifyValidity(testCtx)) 345 return; 346 347 if (stencilBits > 0 && state != GL_TRUE) 348 { 349 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage; 350 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 351 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 352 } 353 } 354 355 //GetIntegerVerifier 356 357 class GetIntegerVerifier : public StateVerifier 358 { 359 public: 360 GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log); 361 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference); 362 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3); 363 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3); 364 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 365 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference); 366 void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 367 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1); 368 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength); 369 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits); 370 }; 371 372 GetIntegerVerifier::GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log) 373 : StateVerifier(gl, log, "_getinteger") 374 { 375 } 376 377 void GetIntegerVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) 378 { 379 using tcu::TestLog; 380 381 StateQueryMemoryWriteGuard<GLint> state; 382 glGetIntegerv(name, &state); 383 384 if (!state.verifyValidity(testCtx)) 385 return; 386 387 if (state != reference) 388 { 389 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage; 390 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 391 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 392 } 393 } 394 395 void GetIntegerVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) 396 { 397 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true); 398 } 399 400 void GetIntegerVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3) 401 { 402 using tcu::TestLog; 403 404 StateQueryMemoryWriteGuard<GLint[4]> intVector4; 405 glGetIntegerv(name, intVector4); 406 407 if (!intVector4.verifyValidity(testCtx)) 408 return; 409 410 if ((enableRef0 && (intVector4[0] != reference0)) || 411 (enableRef1 && (intVector4[1] != reference1)) || 412 (enableRef2 && (intVector4[2] != reference2)) || 413 (enableRef3 && (intVector4[3] != reference3))) 414 { 415 testCtx.getLog() << TestLog::Message << "// ERROR: expected " 416 << (enableRef0?"":"(") << reference0 << (enableRef0?"":")") << ", " 417 << (enableRef1?"":"(") << reference1 << (enableRef1?"":")") << ", " 418 << (enableRef2?"":"(") << reference2 << (enableRef2?"":")") << ", " 419 << (enableRef3?"":"(") << reference3 << (enableRef3?"":")") << TestLog::EndMessage; 420 421 422 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 423 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 424 } 425 } 426 427 void GetIntegerVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 428 { 429 using tcu::TestLog; 430 431 StateQueryMemoryWriteGuard<GLint> state; 432 glGetIntegerv(name, &state); 433 434 if (!state.verifyValidity(testCtx)) 435 return; 436 437 if (state < reference) 438 { 439 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << state << TestLog::EndMessage; 440 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 441 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 442 } 443 } 444 445 void GetIntegerVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) 446 { 447 using tcu::TestLog; 448 449 StateQueryMemoryWriteGuard<GLint> state; 450 glGetIntegerv(name, &state); 451 452 if (!state.verifyValidity(testCtx)) 453 return; 454 455 if (GLuint(state) < reference) 456 { 457 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << GLuint(state) << TestLog::EndMessage; 458 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 459 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 460 } 461 } 462 463 void GetIntegerVerifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 464 { 465 using tcu::TestLog; 466 467 StateQueryMemoryWriteGuard<GLint> state; 468 glGetIntegerv(name, &state); 469 470 if (!state.verifyValidity(testCtx)) 471 return; 472 473 if (state > reference) 474 { 475 testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << reference << "; got " << state << TestLog::EndMessage; 476 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 477 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 478 } 479 } 480 481 void GetIntegerVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) 482 { 483 using tcu::TestLog; 484 485 StateQueryMemoryWriteGuard<GLint[2]> intVector2; 486 glGetIntegerv(name, intVector2); 487 488 if (!intVector2.verifyValidity(testCtx)) 489 return; 490 491 if (intVector2[0] < reference0 || intVector2[1] < reference1) 492 { 493 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference0 << ", " << reference1 << "; got " << intVector2[0] << ", " << intVector2[0] << TestLog::EndMessage; 494 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 495 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 496 } 497 } 498 499 void GetIntegerVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) 500 { 501 using tcu::TestLog; 502 503 StateQueryMemoryWriteGuard<GLint> state; 504 glGetIntegerv(name, &state); 505 506 if (!state.verifyValidity(testCtx)) 507 return; 508 509 for (size_t ndx = 0; ndx < referencesLength; ++ndx) 510 { 511 const GLint expectedGLState = references[ndx]; 512 513 if (state == expectedGLState) 514 return; 515 } 516 517 testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage; 518 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 519 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 520 } 521 522 void GetIntegerVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) 523 { 524 using tcu::TestLog; 525 526 StateQueryMemoryWriteGuard<GLint> state; 527 glGetIntegerv(name, &state); 528 529 if (!state.verifyValidity(testCtx)) 530 return; 531 532 const GLint reference = (1 << stencilBits) - 1; 533 534 if ((state & reference) != reference) // the least significant stencilBits bits should be on 535 { 536 testCtx.getLog() << TestLog::Message << "// ERROR: expected minimum mask of " << reference << "; got " << state << TestLog::EndMessage; 537 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 538 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value"); 539 } 540 } 541 542 //GetInteger64Verifier 543 544 class GetInteger64Verifier : public StateVerifier 545 { 546 public: 547 GetInteger64Verifier (const glw::Functions& gl, tcu::TestLog& log); 548 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference); 549 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3); 550 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3); 551 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 552 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference); 553 void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 554 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1); 555 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength); 556 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits); 557 }; 558 559 GetInteger64Verifier::GetInteger64Verifier (const glw::Functions& gl, tcu::TestLog& log) 560 : StateVerifier(gl, log, "_getinteger64") 561 { 562 } 563 564 void GetInteger64Verifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) 565 { 566 using tcu::TestLog; 567 568 StateQueryMemoryWriteGuard<GLint64> state; 569 glGetInteger64v(name, &state); 570 571 if (!state.verifyValidity(testCtx)) 572 return; 573 574 if (state != GLint64(reference)) 575 { 576 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage; 577 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 578 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 579 } 580 } 581 582 void GetInteger64Verifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) 583 { 584 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true); 585 } 586 587 void GetInteger64Verifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3) 588 { 589 using tcu::TestLog; 590 591 StateQueryMemoryWriteGuard<GLint64[4]> intVector4; 592 glGetInteger64v(name, intVector4); 593 594 if (!intVector4.verifyValidity(testCtx)) 595 return; 596 597 if ((enableRef0 && (intVector4[0] != GLint64(reference0))) || 598 (enableRef1 && (intVector4[1] != GLint64(reference1))) || 599 (enableRef2 && (intVector4[2] != GLint64(reference2))) || 600 (enableRef3 && (intVector4[3] != GLint64(reference3)))) 601 { 602 testCtx.getLog() << TestLog::Message << "// ERROR: expected " 603 << (enableRef0?"":"(") << reference0 << (enableRef0?"":")") << ", " 604 << (enableRef1?"":"(") << reference1 << (enableRef1?"":")") << ", " 605 << (enableRef2?"":"(") << reference2 << (enableRef2?"":")") << ", " 606 << (enableRef3?"":"(") << reference3 << (enableRef3?"":")") << TestLog::EndMessage; 607 608 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 609 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 610 } 611 } 612 613 void GetInteger64Verifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 614 { 615 using tcu::TestLog; 616 617 StateQueryMemoryWriteGuard<GLint64> state; 618 glGetInteger64v(name, &state); 619 620 if (!state.verifyValidity(testCtx)) 621 return; 622 623 if (state < GLint64(reference)) 624 { 625 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference) << "; got " << state << TestLog::EndMessage; 626 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 627 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 628 } 629 } 630 631 void GetInteger64Verifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) 632 { 633 using tcu::TestLog; 634 635 StateQueryMemoryWriteGuard<GLint64> state; 636 glGetInteger64v(name, &state); 637 638 if (!state.verifyValidity(testCtx)) 639 return; 640 641 if (GLuint(state) < GLint64(reference)) 642 { 643 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference) << "; got " << GLuint(state) << TestLog::EndMessage; 644 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 645 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 646 } 647 } 648 649 void GetInteger64Verifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 650 { 651 using tcu::TestLog; 652 653 StateQueryMemoryWriteGuard<GLint64> state; 654 glGetInteger64v(name, &state); 655 656 if (!state.verifyValidity(testCtx)) 657 return; 658 659 if (state > GLint64(reference)) 660 { 661 testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << GLint64(reference) << "; got " << state << TestLog::EndMessage; 662 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 663 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 664 } 665 } 666 667 void GetInteger64Verifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) 668 { 669 using tcu::TestLog; 670 671 StateQueryMemoryWriteGuard<GLint64[2]> intVector2; 672 glGetInteger64v(name, intVector2); 673 674 if (!intVector2.verifyValidity(testCtx)) 675 return; 676 677 if (intVector2[0] < GLint64(reference0) || intVector2[1] < GLint64(reference1)) 678 { 679 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLint64(reference0) << ", " << GLint64(reference1) << "; got " << intVector2[0] << ", " << intVector2[1] << TestLog::EndMessage; 680 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 681 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 682 } 683 } 684 685 void GetInteger64Verifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) 686 { 687 using tcu::TestLog; 688 689 StateQueryMemoryWriteGuard<GLint64> state; 690 glGetInteger64v(name, &state); 691 692 if (!state.verifyValidity(testCtx)) 693 return; 694 695 for (size_t ndx = 0; ndx < referencesLength; ++ndx) 696 { 697 const GLint64 expectedGLState = GLint64(references[ndx]); 698 699 if (state == expectedGLState) 700 return; 701 } 702 703 testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage; 704 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 705 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 706 } 707 708 void GetInteger64Verifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) 709 { 710 using tcu::TestLog; 711 712 StateQueryMemoryWriteGuard<GLint64> state; 713 glGetInteger64v(name, &state); 714 715 if (!state.verifyValidity(testCtx)) 716 return; 717 718 const GLint64 reference = (1ULL << stencilBits) - 1; 719 720 if ((state & reference) != reference) // the least significant stencilBits bits should be on 721 { 722 testCtx.getLog() << TestLog::Message << "// ERROR: expected mimimum mask of " << reference << "; got " << state << TestLog::EndMessage; 723 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 724 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value"); 725 } 726 } 727 728 //GetFloatVerifier 729 730 class GetFloatVerifier : public StateVerifier 731 { 732 public: 733 GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log); 734 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference); 735 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3); 736 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3); 737 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 738 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference); 739 void verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 740 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1); 741 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength); 742 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits); 743 }; 744 745 GetFloatVerifier::GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log) 746 : StateVerifier(gl, log, "_getfloat") 747 { 748 } 749 750 void GetFloatVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) 751 { 752 using tcu::TestLog; 753 754 const GLfloat referenceAsFloat = GLfloat(reference); 755 DE_ASSERT(reference == GLint(referenceAsFloat)); // reference integer must have 1:1 mapping to float for this to work. Reference value is always such value in these tests 756 757 StateQueryMemoryWriteGuard<GLfloat> state; 758 glGetFloatv(name, &state); 759 760 if (!state.verifyValidity(testCtx)) 761 return; 762 763 if (state != referenceAsFloat) 764 { 765 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsFloat << "; got " << state << TestLog::EndMessage; 766 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 767 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 768 } 769 } 770 771 void GetFloatVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) 772 { 773 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true); 774 } 775 776 void GetFloatVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3) 777 { 778 using tcu::TestLog; 779 780 StateQueryMemoryWriteGuard<GLfloat[4]> floatVector4; 781 glGetFloatv(name, floatVector4); 782 783 if (!floatVector4.verifyValidity(testCtx)) 784 return; 785 786 if ((enableRef0 && (floatVector4[0] != GLfloat(reference0))) || 787 (enableRef1 && (floatVector4[1] != GLfloat(reference1))) || 788 (enableRef2 && (floatVector4[2] != GLfloat(reference2))) || 789 (enableRef3 && (floatVector4[3] != GLfloat(reference3)))) 790 { 791 testCtx.getLog() << TestLog::Message << "// ERROR: expected " 792 << (enableRef0?"":"(") << GLfloat(reference0) << (enableRef0?"":")") << ", " 793 << (enableRef1?"":"(") << GLfloat(reference1) << (enableRef1?"":")") << ", " 794 << (enableRef2?"":"(") << GLfloat(reference2) << (enableRef2?"":")") << ", " 795 << (enableRef3?"":"(") << GLfloat(reference3) << (enableRef3?"":")") << TestLog::EndMessage; 796 797 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 798 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 799 } 800 } 801 802 void GetFloatVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 803 { 804 using tcu::TestLog; 805 806 StateQueryMemoryWriteGuard<GLfloat> state; 807 glGetFloatv(name, &state); 808 809 if (!state.verifyValidity(testCtx)) 810 return; 811 812 if (state < GLfloat(reference)) 813 { 814 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage; 815 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 816 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 817 } 818 } 819 820 void GetFloatVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) 821 { 822 using tcu::TestLog; 823 824 StateQueryMemoryWriteGuard<GLfloat> state; 825 glGetFloatv(name, &state); 826 827 if (!state.verifyValidity(testCtx)) 828 return; 829 830 if (state < GLfloat(reference)) 831 { 832 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage; 833 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 834 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 835 } 836 } 837 838 void GetFloatVerifier::verifyIntegerLessOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 839 { 840 using tcu::TestLog; 841 842 StateQueryMemoryWriteGuard<GLfloat> state; 843 glGetFloatv(name, &state); 844 845 if (!state.verifyValidity(testCtx)) 846 return; 847 848 if (state > GLfloat(reference)) 849 { 850 testCtx.getLog() << TestLog::Message << "// ERROR: expected less or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage; 851 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 852 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 853 } 854 } 855 856 void GetFloatVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) 857 { 858 using tcu::TestLog; 859 860 StateQueryMemoryWriteGuard<GLfloat[2]> floatVector2; 861 glGetFloatv(name, floatVector2); 862 863 if (!floatVector2.verifyValidity(testCtx)) 864 return; 865 866 if (floatVector2[0] < GLfloat(reference0) || floatVector2[1] < GLfloat(reference1)) 867 { 868 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference0) << ", " << GLfloat(reference1) << "; got " << floatVector2[0] << ", " << floatVector2[1] << TestLog::EndMessage; 869 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 870 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 871 } 872 } 873 874 void GetFloatVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) 875 { 876 using tcu::TestLog; 877 878 StateQueryMemoryWriteGuard<GLfloat> state; 879 glGetFloatv(name, &state); 880 881 if (!state.verifyValidity(testCtx)) 882 return; 883 884 for (size_t ndx = 0; ndx < referencesLength; ++ndx) 885 { 886 const GLfloat expectedGLState = GLfloat(references[ndx]); 887 DE_ASSERT(references[ndx] == GLint(expectedGLState)); // reference integer must have 1:1 mapping to float for this to work. Reference value is always such value in these tests 888 889 if (state == expectedGLState) 890 return; 891 } 892 893 testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage; 894 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 895 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 896 } 897 898 void GetFloatVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) 899 { 900 // checking the mask bits with float doesn't make much sense because of conversion errors 901 // just verify that the value is greater or equal to the minimum value 902 const GLint reference = (1 << stencilBits) - 1; 903 verifyIntegerGreaterOrEqual(testCtx, name, reference); 904 } 905 906 } // IntegerStateQueryVerifiers 907 908 namespace 909 { 910 911 using namespace IntegerStateQueryVerifiers; 912 using namespace deqp::gls::StateQueryUtil; 913 914 class ConstantMinimumValueTestCase : public ApiCase 915 { 916 public: 917 ConstantMinimumValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue) 918 : ApiCase (context, name, description) 919 , m_targetName (targetName) 920 , m_minValue (minValue) 921 , m_verifier (verifier) 922 { 923 } 924 925 void test (void) 926 { 927 m_verifier->verifyUnsignedIntegerGreaterOrEqual(m_testCtx, m_targetName, m_minValue); 928 expectError(GL_NO_ERROR); 929 } 930 931 private: 932 GLenum m_targetName; 933 GLint m_minValue; 934 StateVerifier* m_verifier; 935 }; 936 937 class ConstantMaximumValueTestCase : public ApiCase 938 { 939 public: 940 ConstantMaximumValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue) 941 : ApiCase (context, name, description) 942 , m_targetName (targetName) 943 , m_minValue (minValue) 944 , m_verifier (verifier) 945 { 946 } 947 948 void test (void) 949 { 950 m_verifier->verifyIntegerLessOrEqual(m_testCtx, m_targetName, m_minValue); 951 expectError(GL_NO_ERROR); 952 } 953 954 private: 955 GLenum m_targetName; 956 GLint m_minValue; 957 StateVerifier* m_verifier; 958 }; 959 960 class SampleBuffersTestCase : public ApiCase 961 { 962 public: 963 SampleBuffersTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 964 : ApiCase (context, name, description) 965 , m_verifier (verifier) 966 { 967 } 968 969 void test (void) 970 { 971 const int expectedSampleBuffers = (m_context.getRenderTarget().getNumSamples() > 1) ? 1 : 0; 972 973 m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << ", expecting GL_SAMPLE_BUFFERS to be " << expectedSampleBuffers << tcu::TestLog::EndMessage; 974 975 m_verifier->verifyInteger(m_testCtx, GL_SAMPLE_BUFFERS, expectedSampleBuffers); 976 expectError(GL_NO_ERROR); 977 } 978 979 private: 980 StateVerifier* m_verifier; 981 }; 982 983 class SamplesTestCase : public ApiCase 984 { 985 public: 986 SamplesTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 987 : ApiCase (context, name, description) 988 , m_verifier (verifier) 989 { 990 } 991 992 void test (void) 993 { 994 // MSAA? 995 if (m_context.getRenderTarget().getNumSamples() > 1) 996 { 997 m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << tcu::TestLog::EndMessage; 998 999 m_verifier->verifyInteger(m_testCtx, GL_SAMPLES, m_context.getRenderTarget().getNumSamples()); 1000 expectError(GL_NO_ERROR); 1001 } 1002 else 1003 { 1004 const glw::GLint validSamples[] = {0, 1}; 1005 1006 m_log << tcu::TestLog::Message << "Expecting GL_SAMPLES to be 0 or 1" << tcu::TestLog::EndMessage; 1007 1008 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_SAMPLES, validSamples, DE_LENGTH_OF_ARRAY(validSamples)); 1009 expectError(GL_NO_ERROR); 1010 } 1011 } 1012 1013 private: 1014 StateVerifier* m_verifier; 1015 }; 1016 1017 class HintTestCase : public ApiCase 1018 { 1019 public: 1020 HintTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName) 1021 : ApiCase (context, name, description) 1022 , m_targetName (targetName) 1023 , m_verifier (verifier) 1024 { 1025 } 1026 1027 void test (void) 1028 { 1029 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE); 1030 expectError(GL_NO_ERROR); 1031 1032 glHint(m_targetName, GL_NICEST); 1033 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_NICEST); 1034 expectError(GL_NO_ERROR); 1035 1036 glHint(m_targetName, GL_FASTEST); 1037 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_FASTEST); 1038 expectError(GL_NO_ERROR); 1039 1040 glHint(m_targetName, GL_DONT_CARE); 1041 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE); 1042 expectError(GL_NO_ERROR); 1043 } 1044 1045 private: 1046 GLenum m_targetName; 1047 StateVerifier* m_verifier; 1048 }; 1049 1050 class DepthFuncTestCase : public ApiCase 1051 { 1052 public: 1053 DepthFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1054 : ApiCase (context, name, description) 1055 , m_verifier (verifier) 1056 { 1057 } 1058 1059 void test (void) 1060 { 1061 m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, GL_LESS); 1062 expectError(GL_NO_ERROR); 1063 1064 const GLenum depthFunctions[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GREATER, GL_GEQUAL, GL_NOTEQUAL}; 1065 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthFunctions); ndx++) 1066 { 1067 glDepthFunc(depthFunctions[ndx]); 1068 expectError(GL_NO_ERROR); 1069 1070 m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, depthFunctions[ndx]); 1071 expectError(GL_NO_ERROR); 1072 } 1073 } 1074 1075 private: 1076 StateVerifier* m_verifier; 1077 }; 1078 1079 class CullFaceTestCase : public ApiCase 1080 { 1081 public: 1082 CullFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1083 : ApiCase (context, name, description) 1084 , m_verifier (verifier) 1085 { 1086 } 1087 1088 void test (void) 1089 { 1090 m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, GL_BACK); 1091 expectError(GL_NO_ERROR); 1092 1093 const GLenum cullFaces[] = {GL_FRONT, GL_BACK, GL_FRONT_AND_BACK}; 1094 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cullFaces); ndx++) 1095 { 1096 glCullFace(cullFaces[ndx]); 1097 expectError(GL_NO_ERROR); 1098 1099 m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, cullFaces[ndx]); 1100 expectError(GL_NO_ERROR); 1101 } 1102 } 1103 1104 private: 1105 StateVerifier* m_verifier; 1106 }; 1107 1108 class FrontFaceTestCase : public ApiCase 1109 { 1110 public: 1111 FrontFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1112 : ApiCase (context, name, description) 1113 , m_verifier (verifier) 1114 { 1115 } 1116 1117 void test (void) 1118 { 1119 m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, GL_CCW); 1120 expectError(GL_NO_ERROR); 1121 1122 const GLenum frontFaces[] = {GL_CW, GL_CCW}; 1123 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(frontFaces); ndx++) 1124 { 1125 glFrontFace(frontFaces[ndx]); 1126 expectError(GL_NO_ERROR); 1127 1128 m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, frontFaces[ndx]); 1129 expectError(GL_NO_ERROR); 1130 } 1131 } 1132 1133 private: 1134 StateVerifier* m_verifier; 1135 }; 1136 1137 class ViewPortTestCase : public ApiCase 1138 { 1139 public: 1140 ViewPortTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1141 : ApiCase (context, name, description) 1142 , m_verifier (verifier) 1143 { 1144 } 1145 1146 void test (void) 1147 { 1148 de::Random rnd(0xabcdef); 1149 1150 GLint maxViewportDimensions[2] = {0}; 1151 GLfloat viewportBoundsRange[2] = {0.0f}; 1152 GLboolean hasViewportArray = false; 1153 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, maxViewportDimensions); 1154 hasViewportArray = m_context.getContextInfo().isExtensionSupported("GL_OES_viewport_array") || 1155 m_context.getContextInfo().isExtensionSupported("GL_NV_viewport_array"); 1156 if (hasViewportArray) 1157 { 1158 glGetFloatv(GL_VIEWPORT_BOUNDS_RANGE, viewportBoundsRange); 1159 } 1160 1161 // verify initial value of first two values 1162 m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, 0, 0, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight()); 1163 expectError(GL_NO_ERROR); 1164 1165 const int numIterations = 120; 1166 for (int i = 0; i < numIterations; ++i) 1167 { 1168 GLint x = rnd.getInt(-64000, 64000); 1169 GLint y = rnd.getInt(-64000, 64000); 1170 GLsizei width = rnd.getInt(0, maxViewportDimensions[0]); 1171 GLsizei height = rnd.getInt(0, maxViewportDimensions[1]); 1172 1173 glViewport(x, y, width, height); 1174 1175 if (hasViewportArray) 1176 { 1177 m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, 1178 de::clamp(x, deFloorFloatToInt32(viewportBoundsRange[0]), deFloorFloatToInt32(viewportBoundsRange[1])), 1179 de::clamp(y, deFloorFloatToInt32(viewportBoundsRange[0]), deFloorFloatToInt32(viewportBoundsRange[1])), 1180 width, height); 1181 } 1182 else 1183 { 1184 m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, x, y, width, height); 1185 } 1186 1187 expectError(GL_NO_ERROR); 1188 } 1189 } 1190 1191 private: 1192 StateVerifier* m_verifier; 1193 }; 1194 1195 class ScissorBoxTestCase : public ApiCase 1196 { 1197 public: 1198 ScissorBoxTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1199 : ApiCase (context, name, description) 1200 , m_verifier (verifier) 1201 { 1202 } 1203 1204 void test (void) 1205 { 1206 de::Random rnd(0xabcdef); 1207 1208 // verify initial value of first two values 1209 m_verifier->verifyInteger4Mask(m_testCtx, GL_SCISSOR_BOX, 0, true, 0, true, 0, false, 0, false); 1210 expectError(GL_NO_ERROR); 1211 1212 const int numIterations = 120; 1213 for (int i = 0; i < numIterations; ++i) 1214 { 1215 GLint left = rnd.getInt(-64000, 64000); 1216 GLint bottom = rnd.getInt(-64000, 64000); 1217 GLsizei width = rnd.getInt(0, 64000); 1218 GLsizei height = rnd.getInt(0, 64000); 1219 1220 glScissor(left, bottom, width, height); 1221 m_verifier->verifyInteger4(m_testCtx, GL_SCISSOR_BOX, left, bottom, width, height); 1222 expectError(GL_NO_ERROR); 1223 } 1224 } 1225 private: 1226 StateVerifier* m_verifier; 1227 }; 1228 1229 class MaxViewportDimsTestCase : public ApiCase 1230 { 1231 public: 1232 MaxViewportDimsTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1233 : ApiCase (context, name, description) 1234 , m_verifier (verifier) 1235 { 1236 } 1237 1238 void test (void) 1239 { 1240 m_verifier->verifyIntegerGreaterOrEqual2(m_testCtx, GL_MAX_VIEWPORT_DIMS, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight()); 1241 expectError(GL_NO_ERROR); 1242 } 1243 private: 1244 StateVerifier* m_verifier; 1245 }; 1246 1247 class StencilRefTestCase : public ApiCase 1248 { 1249 public: 1250 StencilRefTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName) 1251 : ApiCase (context, name, description) 1252 , m_verifier (verifier) 1253 , m_testTargetName (testTargetName) 1254 { 1255 } 1256 1257 void test (void) 1258 { 1259 m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0); 1260 expectError(GL_NO_ERROR); 1261 1262 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1263 1264 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1265 { 1266 const int ref = 1 << stencilBit; 1267 1268 glStencilFunc(GL_ALWAYS, ref, 0); // mask should not affect the REF 1269 expectError(GL_NO_ERROR); 1270 1271 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref); 1272 expectError(GL_NO_ERROR); 1273 1274 glStencilFunc(GL_ALWAYS, ref, ref); 1275 expectError(GL_NO_ERROR); 1276 1277 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref); 1278 expectError(GL_NO_ERROR); 1279 } 1280 } 1281 1282 private: 1283 StateVerifier* m_verifier; 1284 GLenum m_testTargetName; 1285 }; 1286 1287 class StencilRefSeparateTestCase : public ApiCase 1288 { 1289 public: 1290 StencilRefSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace) 1291 : ApiCase (context, name, description) 1292 , m_verifier (verifier) 1293 , m_testTargetName (testTargetName) 1294 , m_stencilFuncTargetFace (stencilFuncTargetFace) 1295 { 1296 } 1297 1298 void test (void) 1299 { 1300 m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0); 1301 expectError(GL_NO_ERROR); 1302 1303 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1304 1305 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1306 { 1307 const int ref = 1 << stencilBit; 1308 1309 glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, 0); 1310 expectError(GL_NO_ERROR); 1311 1312 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref); 1313 expectError(GL_NO_ERROR); 1314 1315 glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, ref); 1316 expectError(GL_NO_ERROR); 1317 1318 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref); 1319 expectError(GL_NO_ERROR); 1320 } 1321 } 1322 private: 1323 StateVerifier* m_verifier; 1324 GLenum m_testTargetName; 1325 GLenum m_stencilFuncTargetFace; 1326 }; 1327 1328 class StencilOpTestCase : public ApiCase 1329 { 1330 public: 1331 StencilOpTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName) 1332 : ApiCase (context, name, description) 1333 , m_verifier (verifier) 1334 , m_stencilOpName (stencilOpName) 1335 { 1336 } 1337 1338 void test (void) 1339 { 1340 m_verifier->verifyInteger(m_testCtx, m_stencilOpName, GL_KEEP); 1341 expectError(GL_NO_ERROR); 1342 1343 const GLenum stencilOpValues[] = {GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP}; 1344 1345 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilOpValues); ++ndx) 1346 { 1347 SetStencilOp(stencilOpValues[ndx]); 1348 expectError(GL_NO_ERROR); 1349 1350 m_verifier->verifyInteger(m_testCtx, m_stencilOpName, stencilOpValues[ndx]); 1351 expectError(GL_NO_ERROR); 1352 } 1353 } 1354 1355 protected: 1356 virtual void SetStencilOp (GLenum stencilOpValue) 1357 { 1358 switch (m_stencilOpName) 1359 { 1360 case GL_STENCIL_FAIL: 1361 case GL_STENCIL_BACK_FAIL: 1362 glStencilOp(stencilOpValue, GL_KEEP, GL_KEEP); 1363 break; 1364 1365 case GL_STENCIL_PASS_DEPTH_FAIL: 1366 case GL_STENCIL_BACK_PASS_DEPTH_FAIL: 1367 glStencilOp(GL_KEEP, stencilOpValue, GL_KEEP); 1368 break; 1369 1370 case GL_STENCIL_PASS_DEPTH_PASS: 1371 case GL_STENCIL_BACK_PASS_DEPTH_PASS: 1372 glStencilOp(GL_KEEP, GL_KEEP, stencilOpValue); 1373 break; 1374 1375 default: 1376 DE_ASSERT(false && "should not happen"); 1377 break; 1378 } 1379 } 1380 1381 StateVerifier* m_verifier; 1382 GLenum m_stencilOpName; 1383 }; 1384 1385 1386 class StencilOpSeparateTestCase : public StencilOpTestCase 1387 { 1388 public: 1389 StencilOpSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName, GLenum stencilOpFace) 1390 : StencilOpTestCase (context, verifier, name, description, stencilOpName) 1391 , m_stencilOpFace (stencilOpFace) 1392 { 1393 } 1394 1395 private: 1396 void SetStencilOp (GLenum stencilOpValue) 1397 { 1398 switch (m_stencilOpName) 1399 { 1400 case GL_STENCIL_FAIL: 1401 case GL_STENCIL_BACK_FAIL: 1402 glStencilOpSeparate(m_stencilOpFace, stencilOpValue, GL_KEEP, GL_KEEP); 1403 break; 1404 1405 case GL_STENCIL_PASS_DEPTH_FAIL: 1406 case GL_STENCIL_BACK_PASS_DEPTH_FAIL: 1407 glStencilOpSeparate(m_stencilOpFace, GL_KEEP, stencilOpValue, GL_KEEP); 1408 break; 1409 1410 case GL_STENCIL_PASS_DEPTH_PASS: 1411 case GL_STENCIL_BACK_PASS_DEPTH_PASS: 1412 glStencilOpSeparate(m_stencilOpFace, GL_KEEP, GL_KEEP, stencilOpValue); 1413 break; 1414 1415 default: 1416 DE_ASSERT(false && "should not happen"); 1417 break; 1418 } 1419 } 1420 1421 GLenum m_stencilOpFace; 1422 }; 1423 1424 class StencilFuncTestCase : public ApiCase 1425 { 1426 public: 1427 StencilFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1428 : ApiCase (context, name, description) 1429 , m_verifier (verifier) 1430 { 1431 } 1432 1433 void test (void) 1434 { 1435 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, GL_ALWAYS); 1436 expectError(GL_NO_ERROR); 1437 1438 const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL}; 1439 1440 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx) 1441 { 1442 glStencilFunc(stencilfuncValues[ndx], 0, 0); 1443 expectError(GL_NO_ERROR); 1444 1445 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, stencilfuncValues[ndx]); 1446 expectError(GL_NO_ERROR); 1447 1448 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_BACK_FUNC, stencilfuncValues[ndx]); 1449 expectError(GL_NO_ERROR); 1450 } 1451 } 1452 private: 1453 StateVerifier* m_verifier; 1454 }; 1455 1456 class StencilFuncSeparateTestCase : public ApiCase 1457 { 1458 public: 1459 StencilFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilFuncName, GLenum stencilFuncFace) 1460 : ApiCase (context, name, description) 1461 , m_verifier (verifier) 1462 , m_stencilFuncName (stencilFuncName) 1463 , m_stencilFuncFace (stencilFuncFace) 1464 { 1465 } 1466 1467 void test (void) 1468 { 1469 m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, GL_ALWAYS); 1470 expectError(GL_NO_ERROR); 1471 1472 const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL}; 1473 1474 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx) 1475 { 1476 glStencilFuncSeparate(m_stencilFuncFace, stencilfuncValues[ndx], 0, 0); 1477 expectError(GL_NO_ERROR); 1478 1479 m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, stencilfuncValues[ndx]); 1480 expectError(GL_NO_ERROR); 1481 } 1482 } 1483 private: 1484 StateVerifier* m_verifier; 1485 GLenum m_stencilFuncName; 1486 GLenum m_stencilFuncFace; 1487 }; 1488 1489 class StencilMaskTestCase : public ApiCase 1490 { 1491 public: 1492 StencilMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName) 1493 : ApiCase (context, name, description) 1494 , m_verifier (verifier) 1495 , m_testTargetName (testTargetName) 1496 { 1497 } 1498 1499 void test (void) 1500 { 1501 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1502 1503 m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits); 1504 expectError(GL_NO_ERROR); 1505 1506 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1507 { 1508 const int mask = 1 << stencilBit; 1509 1510 glStencilFunc(GL_ALWAYS, 0, mask); 1511 expectError(GL_NO_ERROR); 1512 1513 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask); 1514 expectError(GL_NO_ERROR); 1515 } 1516 } 1517 private: 1518 StateVerifier* m_verifier; 1519 GLenum m_testTargetName; 1520 }; 1521 1522 class StencilMaskSeparateTestCase : public ApiCase 1523 { 1524 public: 1525 StencilMaskSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace) 1526 : ApiCase (context, name, description) 1527 , m_verifier (verifier) 1528 , m_testTargetName (testTargetName) 1529 , m_stencilFuncTargetFace (stencilFuncTargetFace) 1530 { 1531 } 1532 1533 void test (void) 1534 { 1535 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1536 1537 m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits); 1538 expectError(GL_NO_ERROR); 1539 1540 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1541 { 1542 const int mask = 1 << stencilBit; 1543 1544 glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, 0, mask); 1545 expectError(GL_NO_ERROR); 1546 1547 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask); 1548 expectError(GL_NO_ERROR); 1549 } 1550 } 1551 private: 1552 StateVerifier* m_verifier; 1553 GLenum m_testTargetName; 1554 GLenum m_stencilFuncTargetFace; 1555 }; 1556 1557 class StencilWriteMaskTestCase : public ApiCase 1558 { 1559 public: 1560 StencilWriteMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName) 1561 : ApiCase (context, name, description) 1562 , m_verifier (verifier) 1563 , m_testTargetName (testTargetName) 1564 { 1565 } 1566 1567 void test (void) 1568 { 1569 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1570 1571 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1572 { 1573 const int mask = 1 << stencilBit; 1574 1575 glStencilMask(mask); 1576 expectError(GL_NO_ERROR); 1577 1578 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask); 1579 expectError(GL_NO_ERROR); 1580 } 1581 } 1582 private: 1583 StateVerifier* m_verifier; 1584 GLenum m_testTargetName; 1585 }; 1586 1587 class StencilWriteMaskSeparateTestCase : public ApiCase 1588 { 1589 public: 1590 StencilWriteMaskSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilTargetFace) 1591 : ApiCase (context, name, description) 1592 , m_verifier (verifier) 1593 , m_testTargetName (testTargetName) 1594 , m_stencilTargetFace (stencilTargetFace) 1595 { 1596 } 1597 1598 void test (void) 1599 { 1600 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1601 1602 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1603 { 1604 const int mask = 1 << stencilBit; 1605 1606 glStencilMaskSeparate(m_stencilTargetFace, mask); 1607 expectError(GL_NO_ERROR); 1608 1609 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask); 1610 expectError(GL_NO_ERROR); 1611 } 1612 } 1613 private: 1614 StateVerifier* m_verifier; 1615 GLenum m_testTargetName; 1616 GLenum m_stencilTargetFace; 1617 }; 1618 1619 class PixelStoreTestCase : public ApiCase 1620 { 1621 public: 1622 PixelStoreTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue) 1623 : ApiCase (context, name, description) 1624 , m_verifier (verifier) 1625 , m_testTargetName (testTargetName) 1626 , m_initialValue (initialValue) 1627 { 1628 } 1629 1630 void test (void) 1631 { 1632 de::Random rnd(0xabcdef); 1633 1634 m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue); 1635 expectError(GL_NO_ERROR); 1636 1637 const int numIterations = 120; 1638 for (int i = 0; i < numIterations; ++i) 1639 { 1640 const int referenceValue = rnd.getInt(0, 64000); 1641 1642 glPixelStorei(m_testTargetName, referenceValue); 1643 expectError(GL_NO_ERROR); 1644 1645 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue); 1646 expectError(GL_NO_ERROR); 1647 } 1648 } 1649 1650 private: 1651 StateVerifier* m_verifier; 1652 GLenum m_testTargetName; 1653 int m_initialValue; 1654 }; 1655 1656 class PixelStoreAlignTestCase : public ApiCase 1657 { 1658 public: 1659 PixelStoreAlignTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName) 1660 : ApiCase (context, name, description) 1661 , m_verifier (verifier) 1662 , m_testTargetName (testTargetName) 1663 { 1664 } 1665 1666 void test (void) 1667 { 1668 m_verifier->verifyInteger(m_testCtx, m_testTargetName, 4); 1669 expectError(GL_NO_ERROR); 1670 1671 const int alignments[] = {1, 2, 4, 8}; 1672 1673 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(alignments); ++ndx) 1674 { 1675 const int referenceValue = alignments[ndx]; 1676 1677 glPixelStorei(m_testTargetName, referenceValue); 1678 expectError(GL_NO_ERROR); 1679 1680 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue); 1681 expectError(GL_NO_ERROR); 1682 } 1683 } 1684 1685 private: 1686 StateVerifier* m_verifier; 1687 GLenum m_testTargetName; 1688 }; 1689 1690 class BlendFuncTestCase : public ApiCase 1691 { 1692 public: 1693 BlendFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue) 1694 : ApiCase (context, name, description) 1695 , m_verifier (verifier) 1696 , m_testTargetName (testTargetName) 1697 , m_initialValue (initialValue) 1698 { 1699 } 1700 1701 void test (void) 1702 { 1703 m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue); 1704 expectError(GL_NO_ERROR); 1705 1706 const GLenum blendFuncValues[] = 1707 { 1708 GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, 1709 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, 1710 GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, 1711 GL_SRC_ALPHA_SATURATE 1712 }; 1713 1714 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx) 1715 { 1716 const GLenum referenceValue = blendFuncValues[ndx]; 1717 1718 SetBlendFunc(referenceValue); 1719 expectError(GL_NO_ERROR); 1720 1721 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue); 1722 expectError(GL_NO_ERROR); 1723 } 1724 } 1725 protected: 1726 virtual void SetBlendFunc (GLenum func) 1727 { 1728 switch (m_testTargetName) 1729 { 1730 case GL_BLEND_SRC_RGB: 1731 case GL_BLEND_SRC_ALPHA: 1732 glBlendFunc(func, GL_ZERO); 1733 break; 1734 1735 case GL_BLEND_DST_RGB: 1736 case GL_BLEND_DST_ALPHA: 1737 glBlendFunc(GL_ZERO, func); 1738 break; 1739 1740 default: 1741 DE_ASSERT(false && "should not happen"); 1742 break; 1743 } 1744 } 1745 1746 StateVerifier* m_verifier; 1747 GLenum m_testTargetName; 1748 int m_initialValue; 1749 }; 1750 1751 class BlendFuncSeparateTestCase : public BlendFuncTestCase 1752 { 1753 public: 1754 BlendFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue) 1755 : BlendFuncTestCase (context, verifier, name, description, testTargetName, initialValue) 1756 { 1757 } 1758 1759 void SetBlendFunc (GLenum func) 1760 { 1761 switch (m_testTargetName) 1762 { 1763 case GL_BLEND_SRC_RGB: 1764 glBlendFuncSeparate(func, GL_ZERO, GL_ZERO, GL_ZERO); 1765 break; 1766 1767 case GL_BLEND_DST_RGB: 1768 glBlendFuncSeparate(GL_ZERO, func, GL_ZERO, GL_ZERO); 1769 break; 1770 1771 case GL_BLEND_SRC_ALPHA: 1772 glBlendFuncSeparate(GL_ZERO, GL_ZERO, func, GL_ZERO); 1773 break; 1774 1775 case GL_BLEND_DST_ALPHA: 1776 glBlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, func); 1777 break; 1778 1779 default: 1780 DE_ASSERT(false && "should not happen"); 1781 break; 1782 } 1783 } 1784 }; 1785 1786 class BlendEquationTestCase : public ApiCase 1787 { 1788 public: 1789 BlendEquationTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue) 1790 : ApiCase (context, name, description) 1791 , m_verifier (verifier) 1792 , m_testTargetName (testTargetName) 1793 , m_initialValue (initialValue) 1794 { 1795 } 1796 1797 void test (void) 1798 { 1799 m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue); 1800 expectError(GL_NO_ERROR); 1801 1802 const GLenum blendFuncValues[] = 1803 { 1804 GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, GL_MIN, GL_MAX 1805 }; 1806 1807 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx) 1808 { 1809 const GLenum referenceValue = blendFuncValues[ndx]; 1810 1811 SetBlendEquation(referenceValue); 1812 expectError(GL_NO_ERROR); 1813 1814 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue); 1815 expectError(GL_NO_ERROR); 1816 } 1817 } 1818 protected: 1819 virtual void SetBlendEquation (GLenum equation) 1820 { 1821 glBlendEquation(equation); 1822 } 1823 1824 StateVerifier* m_verifier; 1825 GLenum m_testTargetName; 1826 int m_initialValue; 1827 }; 1828 class BlendEquationSeparateTestCase : public BlendEquationTestCase 1829 { 1830 public: 1831 BlendEquationSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue) 1832 : BlendEquationTestCase (context, verifier, name, description, testTargetName, initialValue) 1833 { 1834 } 1835 1836 protected: 1837 void SetBlendEquation (GLenum equation) 1838 { 1839 switch (m_testTargetName) 1840 { 1841 case GL_BLEND_EQUATION_RGB: 1842 glBlendEquationSeparate(equation, GL_FUNC_ADD); 1843 break; 1844 1845 case GL_BLEND_EQUATION_ALPHA: 1846 glBlendEquationSeparate(GL_FUNC_ADD, equation); 1847 break; 1848 1849 default: 1850 DE_ASSERT(false && "should not happen"); 1851 break; 1852 } 1853 } 1854 }; 1855 1856 class ImplementationArrayTestCase : public ApiCase 1857 { 1858 public: 1859 ImplementationArrayTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum testTargetLengthTargetName, int minValue) 1860 : ApiCase (context, name, description) 1861 , m_verifier (verifier) 1862 , m_testTargetName (testTargetName) 1863 , m_testTargetLengthTargetName (testTargetLengthTargetName) 1864 , m_minValue (minValue) 1865 { 1866 } 1867 1868 void test (void) 1869 { 1870 m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, m_testTargetLengthTargetName, m_minValue); 1871 expectError(GL_NO_ERROR); 1872 1873 GLint targetArrayLength = 0; 1874 glGetIntegerv(m_testTargetLengthTargetName, &targetArrayLength); 1875 expectError(GL_NO_ERROR); 1876 1877 if (targetArrayLength) 1878 { 1879 std::vector<GLint> queryResult; 1880 queryResult.resize(targetArrayLength, 0); 1881 1882 glGetIntegerv(m_testTargetName, &queryResult[0]); 1883 expectError(GL_NO_ERROR); 1884 } 1885 } 1886 1887 private: 1888 StateVerifier* m_verifier; 1889 GLenum m_testTargetName; 1890 GLenum m_testTargetLengthTargetName; 1891 int m_minValue; 1892 }; 1893 1894 class BindingTest : public TestCase 1895 { 1896 public: 1897 BindingTest (Context& context, 1898 const char* name, 1899 const char* desc, 1900 QueryType type); 1901 1902 IterateResult iterate (void); 1903 1904 virtual void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const = 0; 1905 1906 protected: 1907 const QueryType m_type; 1908 }; 1909 1910 BindingTest::BindingTest (Context& context, 1911 const char* name, 1912 const char* desc, 1913 QueryType type) 1914 : TestCase (context, name, desc) 1915 , m_type (type) 1916 { 1917 } 1918 1919 BindingTest::IterateResult BindingTest::iterate (void) 1920 { 1921 glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog()); 1922 tcu::ResultCollector result (m_context.getTestContext().getLog(), " // ERROR: "); 1923 1924 gl.enableLogging(true); 1925 1926 test(gl, result); 1927 1928 result.setTestContextResult(m_testCtx); 1929 return STOP; 1930 } 1931 1932 class TransformFeedbackBindingTestCase : public BindingTest 1933 { 1934 public: 1935 TransformFeedbackBindingTestCase (Context& context, QueryType type, const char* name) 1936 : BindingTest(context, name, "GL_TRANSFORM_FEEDBACK_BINDING", type) 1937 { 1938 } 1939 1940 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const 1941 { 1942 static const char* transformFeedbackTestVertSource = 1943 "#version 300 es\n" 1944 "void main (void)\n" 1945 "{\n" 1946 " gl_Position = vec4(0.0);\n" 1947 "}\n\0"; 1948 static const char* transformFeedbackTestFragSource = 1949 "#version 300 es\n" 1950 "layout(location = 0) out mediump vec4 fragColor;" 1951 "void main (void)\n" 1952 "{\n" 1953 " fragColor = vec4(0.0);\n" 1954 "}\n\0"; 1955 1956 GLuint shaderVert; 1957 GLuint shaderFrag; 1958 GLuint shaderProg; 1959 GLuint transformfeedback = 0; 1960 GLuint feedbackBufferId = 0; 1961 1962 { 1963 const tcu::ScopedLogSection section(gl.getLog(), "Initial", "Initial"); 1964 verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, 0, m_type); 1965 } 1966 1967 gl.glGenTransformFeedbacks(1, &transformfeedback); 1968 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenTransformFeedbacks"); 1969 1970 { 1971 const tcu::ScopedLogSection section(gl.getLog(), "VertexShader", "Vertex Shader"); 1972 1973 GLint compileStatus = -1; 1974 1975 shaderVert = gl.glCreateShader(GL_VERTEX_SHADER); 1976 gl.glShaderSource(shaderVert, 1, &transformFeedbackTestVertSource, DE_NULL); 1977 gl.glCompileShader(shaderVert); 1978 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader"); 1979 1980 gl.glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus); 1981 if (compileStatus != GL_TRUE) 1982 result.fail("expected GL_TRUE"); 1983 } 1984 { 1985 const tcu::ScopedLogSection section(gl.getLog(), "FragmentShader", "Fragment Shader"); 1986 1987 GLint compileStatus = -1; 1988 1989 shaderFrag = gl.glCreateShader(GL_FRAGMENT_SHADER); 1990 gl.glShaderSource(shaderFrag, 1, &transformFeedbackTestFragSource, DE_NULL); 1991 gl.glCompileShader(shaderFrag); 1992 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader"); 1993 1994 gl.glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus); 1995 if (compileStatus != GL_TRUE) 1996 result.fail("expected GL_TRUE"); 1997 } 1998 { 1999 const tcu::ScopedLogSection section(gl.getLog(), "Program", "Create and bind program"); 2000 2001 const char* transform_feedback_outputs = "gl_Position"; 2002 GLint linkStatus = -1; 2003 2004 shaderProg = gl.glCreateProgram(); 2005 gl.glAttachShader(shaderProg, shaderVert); 2006 gl.glAttachShader(shaderProg, shaderFrag); 2007 gl.glTransformFeedbackVaryings(shaderProg, 1, &transform_feedback_outputs, GL_INTERLEAVED_ATTRIBS); 2008 gl.glLinkProgram(shaderProg); 2009 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glLinkProgram"); 2010 2011 gl.glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus); 2012 if (linkStatus != GL_TRUE) 2013 result.fail("expected GL_TRUE"); 2014 } 2015 2016 gl.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, transformfeedback); 2017 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTransformFeedback"); 2018 2019 gl.glGenBuffers(1, &feedbackBufferId); 2020 gl.glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackBufferId); 2021 gl.glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 16, NULL, GL_DYNAMIC_READ); 2022 gl.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, feedbackBufferId); 2023 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind buffers"); 2024 2025 gl.glUseProgram(shaderProg); 2026 2027 verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, transformfeedback, m_type); 2028 2029 gl.glUseProgram(0); 2030 gl.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0); 2031 gl.glDeleteTransformFeedbacks(1, &transformfeedback); 2032 2033 verifyStateInteger(result, gl, GL_TRANSFORM_FEEDBACK_BINDING, 0, m_type); 2034 2035 gl.glDeleteBuffers(1, &feedbackBufferId); 2036 gl.glDeleteShader(shaderVert); 2037 gl.glDeleteShader(shaderFrag); 2038 gl.glDeleteProgram(shaderProg); 2039 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteProgram"); 2040 } 2041 }; 2042 2043 class CurrentProgramBindingTestCase : public BindingTest 2044 { 2045 public: 2046 CurrentProgramBindingTestCase (Context& context, QueryType type, const char* name, const char* description) 2047 : BindingTest(context, name, description, type) 2048 { 2049 } 2050 2051 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const 2052 { 2053 static const char* testVertSource = 2054 "#version 300 es\n" 2055 "void main (void)\n" 2056 "{\n" 2057 " gl_Position = vec4(0.0);\n" 2058 "}\n\0"; 2059 static const char* testFragSource = 2060 "#version 300 es\n" 2061 "layout(location = 0) out mediump vec4 fragColor;" 2062 "void main (void)\n" 2063 "{\n" 2064 " fragColor = vec4(0.0);\n" 2065 "}\n\0"; 2066 2067 GLuint shaderVert; 2068 GLuint shaderFrag; 2069 GLuint shaderProg; 2070 2071 { 2072 const tcu::ScopedLogSection section(gl.getLog(), "Initial", "Initial"); 2073 2074 verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type); 2075 } 2076 { 2077 const tcu::ScopedLogSection section(gl.getLog(), "VertexShader", "Vertex Shader"); 2078 2079 GLint compileStatus = -1; 2080 2081 shaderVert = gl.glCreateShader(GL_VERTEX_SHADER); 2082 gl.glShaderSource(shaderVert, 1, &testVertSource, DE_NULL); 2083 gl.glCompileShader(shaderVert); 2084 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader"); 2085 2086 gl.glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus); 2087 if (compileStatus != GL_TRUE) 2088 result.fail("expected GL_TRUE"); 2089 } 2090 { 2091 const tcu::ScopedLogSection section(gl.getLog(), "FragmentShader", "Fragment Shader"); 2092 2093 GLint compileStatus = -1; 2094 2095 shaderFrag = gl.glCreateShader(GL_FRAGMENT_SHADER); 2096 gl.glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL); 2097 gl.glCompileShader(shaderFrag); 2098 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glCompileShader"); 2099 2100 gl.glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus); 2101 if (compileStatus != GL_TRUE) 2102 result.fail("expected GL_TRUE"); 2103 } 2104 { 2105 const tcu::ScopedLogSection section(gl.getLog(), "Program", "Create and bind program"); 2106 2107 GLint linkStatus = -1; 2108 2109 shaderProg = gl.glCreateProgram(); 2110 gl.glAttachShader(shaderProg, shaderVert); 2111 gl.glAttachShader(shaderProg, shaderFrag); 2112 gl.glLinkProgram(shaderProg); 2113 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glLinkProgram"); 2114 2115 gl.glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus); 2116 if (linkStatus != GL_TRUE) 2117 result.fail("expected GL_TRUE"); 2118 2119 gl.glUseProgram(shaderProg); 2120 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram"); 2121 2122 verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type); 2123 } 2124 { 2125 const tcu::ScopedLogSection section(gl.getLog(), "Delete", "Delete program while in use"); 2126 2127 gl.glDeleteShader(shaderVert); 2128 gl.glDeleteShader(shaderFrag); 2129 gl.glDeleteProgram(shaderProg); 2130 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteProgram"); 2131 2132 verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, shaderProg, m_type); 2133 } 2134 { 2135 const tcu::ScopedLogSection section(gl.getLog(), "Unbind", "Unbind program"); 2136 gl.glUseProgram(0); 2137 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glUseProgram"); 2138 2139 verifyStateInteger(result, gl, GL_CURRENT_PROGRAM, 0, m_type); 2140 } 2141 } 2142 }; 2143 2144 class VertexArrayBindingTestCase : public BindingTest 2145 { 2146 public: 2147 VertexArrayBindingTestCase (Context& context, QueryType type, const char* name, const char* description) 2148 : BindingTest(context, name, description, type) 2149 { 2150 } 2151 2152 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const 2153 { 2154 verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, 0, m_type); 2155 2156 GLuint vertexArrayObject = 0; 2157 gl.glGenVertexArrays(1, &vertexArrayObject); 2158 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenVertexArrays"); 2159 2160 gl.glBindVertexArray(vertexArrayObject); 2161 verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, vertexArrayObject, m_type); 2162 2163 gl.glDeleteVertexArrays(1, &vertexArrayObject); 2164 verifyStateInteger(result, gl, GL_VERTEX_ARRAY_BINDING, 0, m_type); 2165 } 2166 }; 2167 2168 class BufferBindingTestCase : public BindingTest 2169 { 2170 public: 2171 BufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description, GLenum bufferBindingName, GLenum bufferType) 2172 : BindingTest (context, name, description, type) 2173 , m_bufferBindingName (bufferBindingName) 2174 , m_bufferType (bufferType) 2175 { 2176 } 2177 2178 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const 2179 { 2180 verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type); 2181 2182 GLuint bufferObject = 0; 2183 gl.glGenBuffers(1, &bufferObject); 2184 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers"); 2185 2186 gl.glBindBuffer(m_bufferType, bufferObject); 2187 verifyStateInteger(result, gl, m_bufferBindingName, bufferObject, m_type); 2188 2189 gl.glDeleteBuffers(1, &bufferObject); 2190 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteBuffers"); 2191 2192 verifyStateInteger(result, gl, m_bufferBindingName, 0, m_type); 2193 } 2194 2195 private: 2196 const GLenum m_bufferBindingName; 2197 const GLenum m_bufferType; 2198 }; 2199 2200 class ElementArrayBufferBindingTestCase : public BindingTest 2201 { 2202 public: 2203 ElementArrayBufferBindingTestCase (Context& context, QueryType type, const char* name) 2204 : BindingTest(context, name, "GL_ELEMENT_ARRAY_BUFFER_BINDING", type) 2205 { 2206 } 2207 2208 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const 2209 { 2210 // Test with default VAO 2211 { 2212 const tcu::ScopedLogSection section(gl.getLog(), "DefaultVAO", "Test with default VAO"); 2213 2214 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type); 2215 2216 GLuint bufferObject = 0; 2217 gl.glGenBuffers(1, &bufferObject); 2218 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers"); 2219 2220 gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObject); 2221 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, bufferObject, m_type); 2222 2223 gl.glDeleteBuffers(1, &bufferObject); 2224 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type); 2225 } 2226 2227 // Test with multiple VAOs 2228 { 2229 const tcu::ScopedLogSection section(gl.getLog(), "WithVAO", "Test with VAO"); 2230 2231 GLuint vaos[2] = {0}; 2232 GLuint buffers[2] = {0}; 2233 2234 gl.glGenVertexArrays(2, vaos); 2235 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenVertexArrays"); 2236 2237 gl.glGenBuffers(2, buffers); 2238 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenBuffers"); 2239 2240 // initial 2241 gl.glBindVertexArray(vaos[0]); 2242 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type); 2243 2244 // after setting 2245 gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[0]); 2246 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[0], m_type); 2247 2248 // initial of vao 2 2249 gl.glBindVertexArray(vaos[1]); 2250 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type); 2251 2252 // after setting to 2 2253 gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]); 2254 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[1], m_type); 2255 2256 // vao 1 still has buffer 1 bound? 2257 gl.glBindVertexArray(vaos[0]); 2258 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[0], m_type); 2259 2260 // deleting clears from bound vaos ... 2261 gl.glDeleteBuffers(2, buffers); 2262 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, 0, m_type); 2263 2264 // ... but does not from non-bound vaos? 2265 gl.glBindVertexArray(vaos[1]); 2266 verifyStateInteger(result, gl, GL_ELEMENT_ARRAY_BUFFER_BINDING, buffers[1], m_type); 2267 2268 gl.glDeleteVertexArrays(2, vaos); 2269 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteVertexArrays"); 2270 } 2271 } 2272 }; 2273 2274 class StencilClearValueTestCase : public ApiCase 2275 { 2276 public: 2277 StencilClearValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 2278 : ApiCase (context, name, description) 2279 , m_verifier (verifier) 2280 { 2281 } 2282 2283 void test (void) 2284 { 2285 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, 0); 2286 expectError(GL_NO_ERROR); 2287 2288 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 2289 2290 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 2291 { 2292 const int ref = 1 << stencilBit; 2293 2294 glClearStencil(ref); // mask should not affect the REF 2295 expectError(GL_NO_ERROR); 2296 2297 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, ref); 2298 expectError(GL_NO_ERROR); 2299 } 2300 } 2301 2302 private: 2303 StateVerifier* m_verifier; 2304 }; 2305 2306 class ActiveTextureTestCase : public ApiCase 2307 { 2308 public: 2309 ActiveTextureTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 2310 : ApiCase (context, name, description) 2311 , m_verifier (verifier) 2312 { 2313 } 2314 2315 void test (void) 2316 { 2317 m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0); 2318 expectError(GL_NO_ERROR); 2319 2320 GLint textureUnits = 0; 2321 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &textureUnits); 2322 expectError(GL_NO_ERROR); 2323 2324 for (int ndx = 0; ndx < textureUnits; ++ndx) 2325 { 2326 glActiveTexture(GL_TEXTURE0 + ndx); 2327 expectError(GL_NO_ERROR); 2328 2329 m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0 + ndx); 2330 expectError(GL_NO_ERROR); 2331 } 2332 } 2333 2334 private: 2335 StateVerifier* m_verifier; 2336 }; 2337 2338 class RenderbufferBindingTestCase : public BindingTest 2339 { 2340 public: 2341 RenderbufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description) 2342 : BindingTest(context, name, description, type) 2343 { 2344 } 2345 2346 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const 2347 { 2348 verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type); 2349 2350 GLuint renderBuffer = 0; 2351 gl.glGenRenderbuffers(1, &renderBuffer); 2352 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenRenderbuffers"); 2353 2354 gl.glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer); 2355 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindRenderbuffer"); 2356 2357 verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, renderBuffer, m_type); 2358 2359 gl.glDeleteRenderbuffers(1, &renderBuffer); 2360 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteRenderbuffers"); 2361 2362 verifyStateInteger(result, gl, GL_RENDERBUFFER_BINDING, 0, m_type); 2363 } 2364 }; 2365 2366 class SamplerObjectBindingTestCase : public BindingTest 2367 { 2368 public: 2369 SamplerObjectBindingTestCase (Context& context, QueryType type, const char* name, const char* description) 2370 : BindingTest(context, name, description, type) 2371 { 2372 } 2373 2374 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const 2375 { 2376 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type); 2377 2378 { 2379 const tcu::ScopedLogSection section(gl.getLog(), "SingleUnit", "Single unit"); 2380 2381 GLuint sampler = 0; 2382 gl.glGenSamplers(1, &sampler); 2383 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenSamplers"); 2384 2385 gl.glBindSampler(0, sampler); 2386 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindSampler"); 2387 2388 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, sampler, m_type); 2389 2390 gl.glDeleteSamplers(1, &sampler); 2391 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type); 2392 } 2393 2394 { 2395 const tcu::ScopedLogSection section(gl.getLog(), "MultipleUnits", "Multiple units"); 2396 2397 GLuint samplerA = 0; 2398 GLuint samplerB = 0; 2399 gl.glGenSamplers(1, &samplerA); 2400 gl.glGenSamplers(1, &samplerB); 2401 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenSamplers"); 2402 2403 gl.glBindSampler(1, samplerA); 2404 gl.glBindSampler(2, samplerB); 2405 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindSampler"); 2406 2407 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, 0, m_type); 2408 2409 gl.glActiveTexture(GL_TEXTURE1); 2410 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, samplerA, m_type); 2411 2412 gl.glActiveTexture(GL_TEXTURE2); 2413 verifyStateInteger(result, gl, GL_SAMPLER_BINDING, samplerB, m_type); 2414 2415 gl.glDeleteSamplers(1, &samplerB); 2416 gl.glDeleteSamplers(1, &samplerA); 2417 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteSamplers"); 2418 } 2419 } 2420 }; 2421 2422 class TextureBindingTestCase : public BindingTest 2423 { 2424 public: 2425 TextureBindingTestCase (Context& context, QueryType type, const char* name, const char* description, GLenum testBindingName, GLenum textureType) 2426 : BindingTest (context, name, description, type) 2427 , m_testBindingName (testBindingName) 2428 , m_textureType (textureType) 2429 { 2430 } 2431 2432 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const 2433 { 2434 verifyStateInteger(result, gl, m_testBindingName, 0, m_type); 2435 2436 GLuint texture = 0; 2437 gl.glGenTextures(1, &texture); 2438 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenTextures"); 2439 2440 gl.glBindTexture(m_textureType, texture); 2441 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glBindTexture"); 2442 2443 verifyStateInteger(result, gl, m_testBindingName, texture, m_type); 2444 2445 gl.glDeleteTextures(1, &texture); 2446 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteTextures"); 2447 2448 verifyStateInteger(result, gl, m_testBindingName, 0, m_type); 2449 } 2450 private: 2451 const GLenum m_testBindingName; 2452 const GLenum m_textureType; 2453 }; 2454 2455 class FrameBufferBindingTestCase : public BindingTest 2456 { 2457 public: 2458 FrameBufferBindingTestCase (Context& context, QueryType type, const char* name, const char* description) 2459 : BindingTest(context, name, description, type) 2460 { 2461 } 2462 2463 void test (glu::CallLogWrapper& gl, tcu::ResultCollector& result) const 2464 { 2465 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type); 2466 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type); 2467 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, 0, m_type); 2468 2469 GLuint framebufferId = 0; 2470 gl.glGenFramebuffers(1, &framebufferId); 2471 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glGenFramebuffers"); 2472 2473 gl.glBindFramebuffer(GL_FRAMEBUFFER, framebufferId); 2474 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_FRAMEBUFFER"); 2475 2476 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, framebufferId, m_type); 2477 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, framebufferId, m_type); 2478 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, framebufferId, m_type); 2479 2480 gl.glBindFramebuffer(GL_FRAMEBUFFER, 0); 2481 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "unbind GL_FRAMEBUFFER"); 2482 2483 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type); 2484 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type); 2485 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, 0, m_type); 2486 2487 gl.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferId); 2488 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_READ_FRAMEBUFFER"); 2489 2490 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type); 2491 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type); 2492 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, framebufferId, m_type); 2493 2494 gl.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferId); 2495 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "bind GL_DRAW_FRAMEBUFFER"); 2496 2497 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, framebufferId, m_type); 2498 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, framebufferId, m_type); 2499 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, framebufferId, m_type); 2500 2501 gl.glDeleteFramebuffers(1, &framebufferId); 2502 GLS_COLLECT_GL_ERROR(result, gl.glGetError(), "glDeleteFramebuffers"); 2503 2504 verifyStateInteger(result, gl, GL_DRAW_FRAMEBUFFER_BINDING, 0, m_type); 2505 verifyStateInteger(result, gl, GL_FRAMEBUFFER_BINDING, 0, m_type); 2506 verifyStateInteger(result, gl, GL_READ_FRAMEBUFFER_BINDING, 0, m_type); 2507 } 2508 }; 2509 2510 class ImplementationColorReadTestCase : public ApiCase 2511 { 2512 public: 2513 ImplementationColorReadTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 2514 : ApiCase (context, name, description) 2515 , m_verifier (verifier) 2516 { 2517 } 2518 2519 void test (void) 2520 { 2521 const GLint defaultColorTypes[] = 2522 { 2523 GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, 2524 GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_UNSIGNED_SHORT_5_6_5, 2525 GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, 2526 GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_10F_11F_11F_REV 2527 }; 2528 const GLint defaultColorFormats[] = 2529 { 2530 GL_RGBA, GL_RGBA_INTEGER, GL_RGB, GL_RGB_INTEGER, 2531 GL_RG, GL_RG_INTEGER, GL_RED, GL_RED_INTEGER 2532 }; 2533 2534 std::vector<GLint> validColorTypes; 2535 std::vector<GLint> validColorFormats; 2536 2537 // Defined by the spec 2538 2539 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorTypes); ++ndx) 2540 validColorTypes.push_back(defaultColorTypes[ndx]); 2541 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorFormats); ++ndx) 2542 validColorFormats.push_back(defaultColorFormats[ndx]); 2543 2544 // Extensions 2545 2546 if (m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_format_BGRA8888") || 2547 m_context.getContextInfo().isExtensionSupported("GL_APPLE_texture_format_BGRA8888")) 2548 validColorFormats.push_back(GL_BGRA); 2549 2550 if (m_context.getContextInfo().isExtensionSupported("GL_EXT_read_format_bgra")) 2551 { 2552 validColorFormats.push_back(GL_BGRA); 2553 validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV); 2554 validColorTypes.push_back(GL_UNSIGNED_SHORT_1_5_5_5_REV); 2555 } 2556 2557 if (m_context.getContextInfo().isExtensionSupported("GL_IMG_read_format")) 2558 { 2559 validColorFormats.push_back(GL_BGRA); 2560 validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV); 2561 } 2562 2563 if (m_context.getContextInfo().isExtensionSupported("GL_NV_sRGB_formats")) 2564 { 2565 validColorFormats.push_back(GL_SLUMINANCE_NV); 2566 validColorFormats.push_back(GL_SLUMINANCE_ALPHA_NV); 2567 } 2568 2569 if (m_context.getContextInfo().isExtensionSupported("GL_NV_bgr")) 2570 { 2571 validColorFormats.push_back(GL_BGR_NV); 2572 } 2573 2574 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_TYPE, &validColorTypes[0], validColorTypes.size()); 2575 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &validColorFormats[0], validColorFormats.size()); 2576 expectError(GL_NO_ERROR); 2577 } 2578 2579 private: 2580 StateVerifier* m_verifier; 2581 }; 2582 2583 class ReadBufferCase : public ApiCase 2584 { 2585 public: 2586 ReadBufferCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 2587 : ApiCase (context, name, description) 2588 , m_verifier (verifier) 2589 { 2590 } 2591 2592 void test (void) 2593 { 2594 const GLint validInitialValues[] = {GL_BACK, GL_NONE}; 2595 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_READ_BUFFER, validInitialValues, DE_LENGTH_OF_ARRAY(validInitialValues)); 2596 expectError(GL_NO_ERROR); 2597 2598 glReadBuffer(GL_NONE); 2599 m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_NONE); 2600 expectError(GL_NO_ERROR); 2601 2602 glReadBuffer(GL_BACK); 2603 m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_BACK); 2604 expectError(GL_NO_ERROR); 2605 2606 // test GL_READ_BUFFER with framebuffers 2607 2608 GLuint framebufferId = 0; 2609 glGenFramebuffers(1, &framebufferId); 2610 expectError(GL_NO_ERROR); 2611 2612 GLuint renderbuffer_id = 0; 2613 glGenRenderbuffers(1, &renderbuffer_id); 2614 expectError(GL_NO_ERROR); 2615 2616 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_id); 2617 expectError(GL_NO_ERROR); 2618 2619 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128); 2620 expectError(GL_NO_ERROR); 2621 2622 glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferId); 2623 expectError(GL_NO_ERROR); 2624 2625 glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer_id); 2626 expectError(GL_NO_ERROR); 2627 2628 m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_COLOR_ATTACHMENT0); 2629 2630 glDeleteFramebuffers(1, &framebufferId); 2631 glDeleteRenderbuffers(1, &renderbuffer_id); 2632 expectError(GL_NO_ERROR); 2633 2634 m_verifier->verifyInteger(m_testCtx, GL_READ_BUFFER, GL_BACK); 2635 expectError(GL_NO_ERROR); 2636 } 2637 private: 2638 StateVerifier* m_verifier; 2639 }; 2640 2641 class DrawBufferCase : public ApiCase 2642 { 2643 public: 2644 DrawBufferCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 2645 : ApiCase (context, name, description) 2646 , m_verifier (verifier) 2647 { 2648 } 2649 2650 void test (void) 2651 { 2652 const GLint validInitialValues[] = {GL_BACK, GL_NONE}; 2653 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_DRAW_BUFFER0, validInitialValues, DE_LENGTH_OF_ARRAY(validInitialValues)); 2654 expectError(GL_NO_ERROR); 2655 2656 GLenum bufs = GL_NONE; 2657 glDrawBuffers(1, &bufs); 2658 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_NONE); 2659 expectError(GL_NO_ERROR); 2660 2661 bufs = GL_BACK; 2662 glDrawBuffers(1, &bufs); 2663 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_BACK); 2664 expectError(GL_NO_ERROR); 2665 2666 // test GL_DRAW_BUFFER with framebuffers 2667 2668 GLuint framebufferId = 0; 2669 glGenFramebuffers(1, &framebufferId); 2670 expectError(GL_NO_ERROR); 2671 2672 GLuint renderbuffer_ids[2] = {0}; 2673 glGenRenderbuffers(2, renderbuffer_ids); 2674 expectError(GL_NO_ERROR); 2675 2676 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_ids[0]); 2677 expectError(GL_NO_ERROR); 2678 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128); 2679 expectError(GL_NO_ERROR); 2680 2681 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_ids[1]); 2682 expectError(GL_NO_ERROR); 2683 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 128, 128); 2684 expectError(GL_NO_ERROR); 2685 2686 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferId); 2687 expectError(GL_NO_ERROR); 2688 2689 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer_ids[0]); 2690 expectError(GL_NO_ERROR); 2691 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, renderbuffer_ids[1]); 2692 expectError(GL_NO_ERROR); 2693 2694 // only the initial state the draw buffer for fragment color zero is defined 2695 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_COLOR_ATTACHMENT0); 2696 2697 GLenum bufTargets[2] = {GL_NONE, GL_COLOR_ATTACHMENT1}; 2698 glDrawBuffers(2, bufTargets); 2699 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_NONE); 2700 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER1, GL_COLOR_ATTACHMENT1); 2701 2702 glDeleteFramebuffers(1, &framebufferId); 2703 glDeleteRenderbuffers(2, renderbuffer_ids); 2704 expectError(GL_NO_ERROR); 2705 2706 m_verifier->verifyInteger(m_testCtx, GL_DRAW_BUFFER0, GL_BACK); 2707 expectError(GL_NO_ERROR); 2708 } 2709 private: 2710 StateVerifier* m_verifier; 2711 }; 2712 2713 static const char* getQueryTypeSuffix (QueryType type) 2714 { 2715 switch (type) 2716 { 2717 case QUERY_BOOLEAN: return "_getboolean"; 2718 case QUERY_INTEGER: return "_getinteger"; 2719 case QUERY_INTEGER64: return "_getinteger64"; 2720 case QUERY_FLOAT: return "_getfloat"; 2721 default: 2722 DE_ASSERT(DE_FALSE); 2723 return DE_NULL; 2724 } 2725 } 2726 2727 #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK) \ 2728 for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++) \ 2729 { \ 2730 StateVerifier* verifier = (VERIFIERS)[_verifierNdx]; \ 2731 CODE_BLOCK; \ 2732 } 2733 2734 #define FOR_EACH_QUERYTYPE(QUERYTYPES, CODE_BLOCK) \ 2735 for (int _queryTypeNdx = 0; _queryTypeNdx < DE_LENGTH_OF_ARRAY(QUERYTYPES); _queryTypeNdx++) \ 2736 { \ 2737 const QueryType queryType = (QUERYTYPES)[_queryTypeNdx]; \ 2738 CODE_BLOCK; \ 2739 } 2740 2741 } // anonymous 2742 2743 IntegerStateQueryTests::IntegerStateQueryTests (Context& context) 2744 : TestCaseGroup (context, "integers", "Integer Values") 2745 , m_verifierBoolean (DE_NULL) 2746 , m_verifierInteger (DE_NULL) 2747 , m_verifierInteger64 (DE_NULL) 2748 , m_verifierFloat (DE_NULL) 2749 { 2750 } 2751 2752 IntegerStateQueryTests::~IntegerStateQueryTests (void) 2753 { 2754 deinit(); 2755 } 2756 2757 void IntegerStateQueryTests::init (void) 2758 { 2759 static const QueryType queryTypes[] = 2760 { 2761 QUERY_BOOLEAN, 2762 QUERY_INTEGER, 2763 QUERY_INTEGER64, 2764 QUERY_FLOAT, 2765 }; 2766 2767 DE_ASSERT(m_verifierBoolean == DE_NULL); 2768 DE_ASSERT(m_verifierInteger == DE_NULL); 2769 DE_ASSERT(m_verifierInteger64 == DE_NULL); 2770 DE_ASSERT(m_verifierFloat == DE_NULL); 2771 2772 m_verifierBoolean = new GetBooleanVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog()); 2773 m_verifierInteger = new GetIntegerVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog()); 2774 m_verifierInteger64 = new GetInteger64Verifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog()); 2775 m_verifierFloat = new GetFloatVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog()); 2776 2777 const struct LimitedStateInteger 2778 { 2779 const char* name; 2780 const char* description; 2781 GLenum targetName; 2782 GLint value; 2783 } implementationMinLimits[] = 2784 { 2785 { "subpixel_bits", "SUBPIXEL_BITS has minimum value of 4", GL_SUBPIXEL_BITS, 4 }, 2786 { "max_3d_texture_size", "MAX_3D_TEXTURE_SIZE has minimum value of 256", GL_MAX_3D_TEXTURE_SIZE, 256 }, 2787 { "max_texture_size", "MAX_TEXTURE_SIZE has minimum value of 2048", GL_MAX_TEXTURE_SIZE, 2048}, 2788 { "max_array_texture_layers", "MAX_ARRAY_TEXTURE_LAYERS has minimum value of 256", GL_MAX_ARRAY_TEXTURE_LAYERS, 256 }, 2789 { "max_cube_map_texture_size", "MAX_CUBE_MAP_TEXTURE_SIZE has minimum value of 2048", GL_MAX_CUBE_MAP_TEXTURE_SIZE, 2048}, 2790 { "max_renderbuffer_size", "MAX_RENDERBUFFER_SIZE has minimum value of 2048", GL_MAX_RENDERBUFFER_SIZE, 2048}, 2791 { "max_draw_buffers", "MAX_DRAW_BUFFERS has minimum value of 4", GL_MAX_DRAW_BUFFERS, 4 }, 2792 { "max_color_attachments", "MAX_COLOR_ATTACHMENTS has minimum value of 4", GL_MAX_COLOR_ATTACHMENTS, 4 }, 2793 { "max_elements_indices", "MAX_ELEMENTS_INDICES has minimum value of 0", GL_MAX_ELEMENTS_INDICES, 0 }, 2794 { "max_elements_vertices", "MAX_ELEMENTS_VERTICES has minimum value of 0", GL_MAX_ELEMENTS_VERTICES, 0 }, 2795 { "num_extensions", "NUM_EXTENSIONS has minimum value of 0", GL_NUM_EXTENSIONS, 0 }, 2796 { "major_version", "MAJOR_VERSION has minimum value of 3", GL_MAJOR_VERSION, 3 }, 2797 { "minor_version", "MINOR_VERSION has minimum value of 0", GL_MINOR_VERSION, 0 }, 2798 { "max_vertex_attribs", "MAX_VERTEX_ATTRIBS has minimum value of 16", GL_MAX_VERTEX_ATTRIBS, 16 }, 2799 { "max_vertex_uniform_components", "MAX_VERTEX_UNIFORM_COMPONENTS has minimum value of 1024", GL_MAX_VERTEX_UNIFORM_COMPONENTS, 1024}, 2800 { "max_vertex_uniform_vectors", "MAX_VERTEX_UNIFORM_VECTORS has minimum value of 256", GL_MAX_VERTEX_UNIFORM_VECTORS, 256 }, 2801 { "max_vertex_uniform_blocks", "MAX_VERTEX_UNIFORM_BLOCKS has minimum value of 12", GL_MAX_VERTEX_UNIFORM_BLOCKS, 12 }, 2802 { "max_vertex_output_components", "MAX_VERTEX_OUTPUT_COMPONENTS has minimum value of 64", GL_MAX_VERTEX_OUTPUT_COMPONENTS, 64 }, 2803 { "max_vertex_texture_image_units", "MAX_VERTEX_TEXTURE_IMAGE_UNITS has minimum value of 16", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 16 }, 2804 { "max_fragment_uniform_components", "MAX_FRAGMENT_UNIFORM_COMPONENTS has minimum value of 896", GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, 896 }, 2805 { "max_fragment_uniform_vectors", "MAX_FRAGMENT_UNIFORM_VECTORS has minimum value of 224", GL_MAX_FRAGMENT_UNIFORM_VECTORS, 224 }, 2806 { "max_fragment_uniform_blocks", "MAX_FRAGMENT_UNIFORM_BLOCKS has minimum value of 12", GL_MAX_FRAGMENT_UNIFORM_BLOCKS, 12 }, 2807 { "max_fragment_input_components", "MAX_FRAGMENT_INPUT_COMPONENTS has minimum value of 60", GL_MAX_FRAGMENT_INPUT_COMPONENTS, 60 }, 2808 { "max_texture_image_units", "MAX_TEXTURE_IMAGE_UNITS has minimum value of 16", GL_MAX_TEXTURE_IMAGE_UNITS, 16 }, 2809 { "max_program_texel_offset", "MAX_PROGRAM_TEXEL_OFFSET has minimum value of 7", GL_MAX_PROGRAM_TEXEL_OFFSET, 7 }, 2810 { "max_uniform_buffer_bindings", "MAX_UNIFORM_BUFFER_BINDINGS has minimum value of 24", GL_MAX_UNIFORM_BUFFER_BINDINGS, 24 }, 2811 { "max_combined_uniform_blocks", "MAX_COMBINED_UNIFORM_BLOCKS has minimum value of 24", GL_MAX_COMBINED_UNIFORM_BLOCKS, 24 }, 2812 { "max_varying_components", "MAX_VARYING_COMPONENTS has minimum value of 60", GL_MAX_VARYING_COMPONENTS, 60 }, 2813 { "max_varying_vectors", "MAX_VARYING_VECTORS has minimum value of 15", GL_MAX_VARYING_VECTORS, 15 }, 2814 { "max_combined_texture_image_units", "MAX_COMBINED_TEXTURE_IMAGE_UNITS has minimum value of 32", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 32 }, 2815 { "max_transform_feedback_interleaved_components", "MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS has minimum value of 64", GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, 64 }, 2816 { "max_transform_feedback_separate_attribs", "MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS has minimum value of 4", GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, 4 }, 2817 { "max_transform_feedback_separate_components", "MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS has minimum value of 4", GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, 4 }, 2818 { "max_samples", "MAX_SAMPLES has minimum value of 4", GL_MAX_SAMPLES, 4 }, 2819 { "red_bits", "RED_BITS has minimum value of 0", GL_RED_BITS, 0 }, 2820 { "green_bits", "GREEN_BITS has minimum value of 0", GL_GREEN_BITS, 0 }, 2821 { "blue_bits", "BLUE_BITS has minimum value of 0", GL_BLUE_BITS, 0 }, 2822 { "alpha_bits", "ALPHA_BITS has minimum value of 0", GL_ALPHA_BITS, 0 }, 2823 { "depth_bits", "DEPTH_BITS has minimum value of 0", GL_DEPTH_BITS, 0 }, 2824 { "stencil_bits", "STENCIL_BITS has minimum value of 0", GL_STENCIL_BITS, 0 }, 2825 }; 2826 const LimitedStateInteger implementationMaxLimits[] = 2827 { 2828 { "min_program_texel_offset", "MIN_PROGRAM_TEXEL_OFFSET has maximum value of -8", GL_MIN_PROGRAM_TEXEL_OFFSET, -8 }, 2829 { "uniform_buffer_offset_alignment", "UNIFORM_BUFFER_OFFSET_ALIGNMENT has minimum value of 1", GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, 256 }, 2830 }; 2831 2832 // \note implementation defined limits have their own tests so just check the conversions to boolean, int64 and float 2833 StateVerifier* implementationLimitVerifiers[] = {m_verifierBoolean, m_verifierInteger64, m_verifierFloat}; 2834 2835 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMinLimits); testNdx++) 2836 FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new ConstantMinimumValueTestCase(m_context, verifier, (std::string(implementationMinLimits[testNdx].name) + verifier->getTestNamePostfix()).c_str(), implementationMinLimits[testNdx].description, implementationMinLimits[testNdx].targetName, implementationMinLimits[testNdx].value))); 2837 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMaxLimits); testNdx++) 2838 FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new ConstantMaximumValueTestCase(m_context, verifier, (std::string(implementationMaxLimits[testNdx].name) + verifier->getTestNamePostfix()).c_str(), implementationMaxLimits[testNdx].description, implementationMaxLimits[testNdx].targetName, implementationMaxLimits[testNdx].value))); 2839 2840 StateVerifier* normalVerifiers[] = {m_verifierBoolean, m_verifierInteger, m_verifierInteger64, m_verifierFloat}; 2841 2842 FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new SampleBuffersTestCase (m_context, verifier, (std::string("sample_buffers") + verifier->getTestNamePostfix()).c_str(), "SAMPLE_BUFFERS"))); 2843 2844 FOR_EACH_VERIFIER(normalVerifiers, addChild(new SamplesTestCase (m_context, verifier, (std::string("samples") + verifier->getTestNamePostfix()).c_str(), "SAMPLES"))); 2845 FOR_EACH_VERIFIER(normalVerifiers, addChild(new HintTestCase (m_context, verifier, (std::string("generate_mipmap_hint") + verifier->getTestNamePostfix()).c_str(), "GENERATE_MIPMAP_HINT", GL_GENERATE_MIPMAP_HINT))); 2846 FOR_EACH_VERIFIER(normalVerifiers, addChild(new HintTestCase (m_context, verifier, (std::string("fragment_shader_derivative_hint") + verifier->getTestNamePostfix()).c_str(), "FRAGMENT_SHADER_DERIVATIVE_HINT", GL_FRAGMENT_SHADER_DERIVATIVE_HINT))); 2847 FOR_EACH_VERIFIER(normalVerifiers, addChild(new DepthFuncTestCase (m_context, verifier, (std::string("depth_func") + verifier->getTestNamePostfix()).c_str(), "DEPTH_FUNC"))); 2848 FOR_EACH_VERIFIER(normalVerifiers, addChild(new CullFaceTestCase (m_context, verifier, (std::string("cull_face_mode") + verifier->getTestNamePostfix()).c_str(), "CULL_FACE_MODE"))); 2849 FOR_EACH_VERIFIER(normalVerifiers, addChild(new FrontFaceTestCase (m_context, verifier, (std::string("front_face_mode") + verifier->getTestNamePostfix()).c_str(), "FRONT_FACE"))); 2850 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ViewPortTestCase (m_context, verifier, (std::string("viewport") + verifier->getTestNamePostfix()).c_str(), "VIEWPORT"))); 2851 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ScissorBoxTestCase (m_context, verifier, (std::string("scissor_box") + verifier->getTestNamePostfix()).c_str(), "SCISSOR_BOX"))); 2852 FOR_EACH_VERIFIER(normalVerifiers, addChild(new MaxViewportDimsTestCase (m_context, verifier, (std::string("max_viewport_dims") + verifier->getTestNamePostfix()).c_str(), "MAX_VIEWPORT_DIMS"))); 2853 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefTestCase (m_context, verifier, (std::string("stencil_ref") + verifier->getTestNamePostfix()).c_str(), "STENCIL_REF", GL_STENCIL_REF))); 2854 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefTestCase (m_context, verifier, (std::string("stencil_back_ref") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_REF", GL_STENCIL_BACK_REF))); 2855 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase (m_context, verifier, (std::string("stencil_ref_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_REF (separate)", GL_STENCIL_REF, GL_FRONT))); 2856 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase (m_context, verifier, (std::string("stencil_ref_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_REF (separate)", GL_STENCIL_REF, GL_FRONT_AND_BACK))); 2857 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase (m_context, verifier, (std::string("stencil_back_ref_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_REF (separate)", GL_STENCIL_BACK_REF, GL_BACK))); 2858 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefSeparateTestCase (m_context, verifier, (std::string("stencil_back_ref_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_REF (separate)", GL_STENCIL_BACK_REF, GL_FRONT_AND_BACK))); 2859 2860 const struct NamedStencilOp 2861 { 2862 const char* name; 2863 2864 const char* frontDescription; 2865 GLenum frontTarget; 2866 const char* backDescription; 2867 GLenum backTarget; 2868 } stencilOps[] = 2869 { 2870 { "fail", "STENCIL_FAIL", GL_STENCIL_FAIL, "STENCIL_BACK_FAIL", GL_STENCIL_BACK_FAIL }, 2871 { "depth_fail", "STENCIL_PASS_DEPTH_FAIL", GL_STENCIL_PASS_DEPTH_FAIL, "STENCIL_BACK_PASS_DEPTH_FAIL", GL_STENCIL_BACK_PASS_DEPTH_FAIL }, 2872 { "depth_pass", "STENCIL_PASS_DEPTH_PASS", GL_STENCIL_PASS_DEPTH_PASS, "STENCIL_BACK_PASS_DEPTH_PASS", GL_STENCIL_BACK_PASS_DEPTH_PASS } 2873 }; 2874 2875 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(stencilOps); testNdx++) 2876 { 2877 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpTestCase (m_context, verifier, (std::string("stencil_") + stencilOps[testNdx].name + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].frontDescription, stencilOps[testNdx].frontTarget))); 2878 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpTestCase (m_context, verifier, (std::string("stencil_back_") + stencilOps[testNdx].name + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].backDescription, stencilOps[testNdx].backTarget))); 2879 2880 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase (m_context, verifier, (std::string("stencil_") + stencilOps[testNdx].name + "_separate_both" + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].frontDescription, stencilOps[testNdx].frontTarget, GL_FRONT_AND_BACK))); 2881 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase (m_context, verifier, (std::string("stencil_back_") + stencilOps[testNdx].name + "_separate_both" + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].backDescription, stencilOps[testNdx].backTarget, GL_FRONT_AND_BACK))); 2882 2883 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase (m_context, verifier, (std::string("stencil_") + stencilOps[testNdx].name + "_separate" + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].frontDescription, stencilOps[testNdx].frontTarget, GL_FRONT))); 2884 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilOpSeparateTestCase (m_context, verifier, (std::string("stencil_back_") + stencilOps[testNdx].name + "_separate" + verifier->getTestNamePostfix()).c_str(), stencilOps[testNdx].backDescription, stencilOps[testNdx].backTarget, GL_BACK))); 2885 } 2886 2887 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncTestCase (m_context, verifier, (std::string("stencil_func") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC"))); 2888 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase (m_context, verifier, (std::string("stencil_func_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC (separate)", GL_STENCIL_FUNC, GL_FRONT))); 2889 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase (m_context, verifier, (std::string("stencil_func_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC (separate)", GL_STENCIL_FUNC, GL_FRONT_AND_BACK))); 2890 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase (m_context, verifier, (std::string("stencil_back_func_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC (separate)", GL_STENCIL_BACK_FUNC, GL_BACK))); 2891 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncSeparateTestCase (m_context, verifier, (std::string("stencil_back_func_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC (separate)", GL_STENCIL_BACK_FUNC, GL_FRONT_AND_BACK))); 2892 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskTestCase (m_context, verifier, (std::string("stencil_value_mask") + verifier->getTestNamePostfix()).c_str(), "STENCIL_VALUE_MASK", GL_STENCIL_VALUE_MASK))); 2893 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskTestCase (m_context, verifier, (std::string("stencil_back_value_mask") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_VALUE_MASK", GL_STENCIL_BACK_VALUE_MASK))); 2894 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase (m_context, verifier, (std::string("stencil_value_mask_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_VALUE_MASK (separate)", GL_STENCIL_VALUE_MASK, GL_FRONT))); 2895 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase (m_context, verifier, (std::string("stencil_value_mask_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_VALUE_MASK (separate)", GL_STENCIL_VALUE_MASK, GL_FRONT_AND_BACK))); 2896 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase (m_context, verifier, (std::string("stencil_back_value_mask_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_VALUE_MASK (separate)", GL_STENCIL_BACK_VALUE_MASK, GL_BACK))); 2897 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilMaskSeparateTestCase (m_context, verifier, (std::string("stencil_back_value_mask_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_VALUE_MASK (separate)", GL_STENCIL_BACK_VALUE_MASK, GL_FRONT_AND_BACK))); 2898 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskTestCase (m_context, verifier, (std::string("stencil_writemask") + verifier->getTestNamePostfix()).c_str(), "STENCIL_WRITEMASK", GL_STENCIL_WRITEMASK))); 2899 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskTestCase (m_context, verifier, (std::string("stencil_back_writemask") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_WRITEMASK", GL_STENCIL_BACK_WRITEMASK))); 2900 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase (m_context, verifier, (std::string("stencil_writemask_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_WRITEMASK (separate)", GL_STENCIL_WRITEMASK, GL_FRONT))); 2901 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase (m_context, verifier, (std::string("stencil_writemask_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_WRITEMASK (separate)", GL_STENCIL_WRITEMASK, GL_FRONT_AND_BACK))); 2902 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase (m_context, verifier, (std::string("stencil_back_writemask_separate") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_WRITEMASK (separate)", GL_STENCIL_BACK_WRITEMASK, GL_BACK))); 2903 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskSeparateTestCase (m_context, verifier, (std::string("stencil_back_writemask_separate_both") + verifier->getTestNamePostfix()).c_str(), "STENCIL_BACK_WRITEMASK (separate)", GL_STENCIL_BACK_WRITEMASK, GL_FRONT_AND_BACK))); 2904 2905 const struct PixelStoreState 2906 { 2907 const char* name; 2908 const char* description; 2909 GLenum target; 2910 int initialValue; 2911 } pixelStoreStates[] = 2912 { 2913 { "unpack_image_height","UNPACK_IMAGE_HEIGHT", GL_UNPACK_IMAGE_HEIGHT, 0 }, 2914 { "unpack_skip_images", "UNPACK_SKIP_IMAGES", GL_UNPACK_SKIP_IMAGES, 0 }, 2915 { "unpack_row_length", "UNPACK_ROW_LENGTH", GL_UNPACK_ROW_LENGTH, 0 }, 2916 { "unpack_skip_rows", "UNPACK_SKIP_ROWS", GL_UNPACK_SKIP_ROWS, 0 }, 2917 { "unpack_skip_pixels", "UNPACK_SKIP_PIXELS", GL_UNPACK_SKIP_PIXELS, 0 }, 2918 { "pack_row_length", "PACK_ROW_LENGTH", GL_PACK_ROW_LENGTH, 0 }, 2919 { "pack_skip_rows", "PACK_SKIP_ROWS", GL_PACK_SKIP_ROWS, 0 }, 2920 { "pack_skip_pixels", "PACK_SKIP_PIXELS", GL_PACK_SKIP_PIXELS, 0 } 2921 }; 2922 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(pixelStoreStates); testNdx++) 2923 { 2924 FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreTestCase(m_context, verifier, (std::string(pixelStoreStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(), pixelStoreStates[testNdx].description, pixelStoreStates[testNdx].target, pixelStoreStates[testNdx].initialValue))); 2925 } 2926 2927 FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("unpack_alignment") + verifier->getTestNamePostfix()).c_str(), "UNPACK_ALIGNMENT", GL_UNPACK_ALIGNMENT))); 2928 FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("pack_alignment") + verifier->getTestNamePostfix()).c_str(), "PACK_ALIGNMENT", GL_PACK_ALIGNMENT))); 2929 2930 const struct BlendColorState 2931 { 2932 const char* name; 2933 const char* description; 2934 GLenum target; 2935 int initialValue; 2936 } blendColorStates[] = 2937 { 2938 { "blend_src_rgb", "BLEND_SRC_RGB", GL_BLEND_SRC_RGB, GL_ONE }, 2939 { "blend_src_alpha", "BLEND_SRC_ALPHA", GL_BLEND_SRC_ALPHA, GL_ONE }, 2940 { "blend_dst_rgb", "BLEND_DST_RGB", GL_BLEND_DST_RGB, GL_ZERO }, 2941 { "blend_dst_alpha", "BLEND_DST_ALPHA", GL_BLEND_DST_ALPHA, GL_ZERO } 2942 }; 2943 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendColorStates); testNdx++) 2944 { 2945 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendFuncTestCase (m_context, verifier, (std::string(blendColorStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(), blendColorStates[testNdx].description, blendColorStates[testNdx].target, blendColorStates[testNdx].initialValue))); 2946 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendFuncSeparateTestCase (m_context, verifier, (std::string(blendColorStates[testNdx].name) + "_separate" + verifier->getTestNamePostfix()).c_str(), blendColorStates[testNdx].description, blendColorStates[testNdx].target, blendColorStates[testNdx].initialValue))); 2947 } 2948 2949 const struct BlendEquationState 2950 { 2951 const char* name; 2952 const char* description; 2953 GLenum target; 2954 int initialValue; 2955 } blendEquationStates[] = 2956 { 2957 { "blend_equation_rgb", "BLEND_EQUATION_RGB", GL_BLEND_EQUATION_RGB, GL_FUNC_ADD }, 2958 { "blend_equation_alpha", "BLEND_EQUATION_ALPHA", GL_BLEND_EQUATION_ALPHA, GL_FUNC_ADD } 2959 }; 2960 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendEquationStates); testNdx++) 2961 { 2962 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendEquationTestCase (m_context, verifier, (std::string(blendEquationStates[testNdx].name) + + verifier->getTestNamePostfix()).c_str(), blendEquationStates[testNdx].description, blendEquationStates[testNdx].target, blendEquationStates[testNdx].initialValue))); 2963 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BlendEquationSeparateTestCase (m_context, verifier, (std::string(blendEquationStates[testNdx].name) + "_separate" + verifier->getTestNamePostfix()).c_str(), blendEquationStates[testNdx].description, blendEquationStates[testNdx].target, blendEquationStates[testNdx].initialValue))); 2964 } 2965 2966 const struct ImplementationArrayReturningState 2967 { 2968 const char* name; 2969 const char* description; 2970 GLenum target; 2971 GLenum targetLengthTarget; 2972 int minLength; 2973 } implementationArrayReturningStates[] = 2974 { 2975 { "compressed_texture_formats", "COMPRESSED_TEXTURE_FORMATS", GL_COMPRESSED_TEXTURE_FORMATS, GL_NUM_COMPRESSED_TEXTURE_FORMATS, 10 }, 2976 { "program_binary_formats", "PROGRAM_BINARY_FORMATS", GL_PROGRAM_BINARY_FORMATS, GL_NUM_PROGRAM_BINARY_FORMATS, 0 }, 2977 { "shader_binary_formats", "SHADER_BINARY_FORMATS", GL_SHADER_BINARY_FORMATS, GL_NUM_SHADER_BINARY_FORMATS, 0 } 2978 }; 2979 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationArrayReturningStates); testNdx++) 2980 { 2981 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationArrayTestCase(m_context, verifier, (std::string(implementationArrayReturningStates[testNdx].name) + verifier->getTestNamePostfix()).c_str(), implementationArrayReturningStates[testNdx].description, implementationArrayReturningStates[testNdx].target, implementationArrayReturningStates[testNdx].targetLengthTarget, implementationArrayReturningStates[testNdx].minLength))); 2982 } 2983 2984 const struct BufferBindingState 2985 { 2986 const char* name; 2987 const char* description; 2988 GLenum target; 2989 GLenum type; 2990 } bufferBindingStates[] = 2991 { 2992 { "array_buffer_binding", "ARRAY_BUFFER_BINDING", GL_ARRAY_BUFFER_BINDING, GL_ARRAY_BUFFER }, 2993 { "uniform_buffer_binding", "UNIFORM_BUFFER_BINDING", GL_UNIFORM_BUFFER_BINDING, GL_UNIFORM_BUFFER }, 2994 { "pixel_pack_buffer_binding", "PIXEL_PACK_BUFFER_BINDING", GL_PIXEL_PACK_BUFFER_BINDING, GL_PIXEL_PACK_BUFFER }, 2995 { "pixel_unpack_buffer_binding", "PIXEL_UNPACK_BUFFER_BINDING", GL_PIXEL_UNPACK_BUFFER_BINDING, GL_PIXEL_UNPACK_BUFFER }, 2996 { "transform_feedback_buffer_binding", "TRANSFORM_FEEDBACK_BUFFER_BINDING", GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, GL_TRANSFORM_FEEDBACK_BUFFER}, 2997 { "copy_read_buffer_binding", "COPY_READ_BUFFER_BINDING", GL_COPY_READ_BUFFER_BINDING, GL_COPY_READ_BUFFER }, 2998 { "copy_write_buffer_binding", "COPY_WRITE_BUFFER_BINDING", GL_COPY_WRITE_BUFFER_BINDING, GL_COPY_WRITE_BUFFER } 2999 }; 3000 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(bufferBindingStates); testNdx++) 3001 { 3002 FOR_EACH_QUERYTYPE(queryTypes, addChild(new BufferBindingTestCase(m_context, queryType, (std::string(bufferBindingStates[testNdx].name) + getQueryTypeSuffix(queryType)).c_str(), bufferBindingStates[testNdx].description, bufferBindingStates[testNdx].target, bufferBindingStates[testNdx].type))); 3003 } 3004 3005 FOR_EACH_QUERYTYPE(queryTypes, addChild(new ElementArrayBufferBindingTestCase (m_context, queryType, (std::string("element_array_buffer_binding") + getQueryTypeSuffix(queryType)).c_str()))); 3006 FOR_EACH_QUERYTYPE(queryTypes, addChild(new TransformFeedbackBindingTestCase (m_context, queryType, (std::string("transform_feedback_binding") + getQueryTypeSuffix(queryType)).c_str()))); 3007 FOR_EACH_QUERYTYPE(queryTypes, addChild(new CurrentProgramBindingTestCase (m_context, queryType, (std::string("current_program_binding") + getQueryTypeSuffix(queryType)).c_str(), "CURRENT_PROGRAM"))); 3008 FOR_EACH_QUERYTYPE(queryTypes, addChild(new VertexArrayBindingTestCase (m_context, queryType, (std::string("vertex_array_binding") + getQueryTypeSuffix(queryType)).c_str(), "VERTEX_ARRAY_BINDING"))); 3009 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilClearValueTestCase (m_context, verifier, (std::string("stencil_clear_value") + verifier->getTestNamePostfix()).c_str(), "STENCIL_CLEAR_VALUE"))); 3010 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ActiveTextureTestCase (m_context, verifier, (std::string("active_texture") + verifier->getTestNamePostfix()).c_str(), "ACTIVE_TEXTURE"))); 3011 FOR_EACH_QUERYTYPE(queryTypes, addChild(new RenderbufferBindingTestCase (m_context, queryType, (std::string("renderbuffer_binding") + getQueryTypeSuffix(queryType)).c_str(), "RENDERBUFFER_BINDING"))); 3012 FOR_EACH_QUERYTYPE(queryTypes, addChild(new SamplerObjectBindingTestCase (m_context, queryType, (std::string("sampler_binding") + getQueryTypeSuffix(queryType)).c_str(), "SAMPLER_BINDING"))); 3013 3014 const struct TextureBinding 3015 { 3016 const char* name; 3017 const char* description; 3018 GLenum target; 3019 GLenum type; 3020 } textureBindings[] = 3021 { 3022 { "texture_binding_2d", "TEXTURE_BINDING_2D", GL_TEXTURE_BINDING_2D, GL_TEXTURE_2D }, 3023 { "texture_binding_3d", "TEXTURE_BINDING_3D", GL_TEXTURE_BINDING_3D, GL_TEXTURE_3D }, 3024 { "texture_binding_2d_array", "TEXTURE_BINDING_2D_ARRAY", GL_TEXTURE_BINDING_2D_ARRAY, GL_TEXTURE_2D_ARRAY }, 3025 { "texture_binding_cube_map", "TEXTURE_BINDING_CUBE_MAP", GL_TEXTURE_BINDING_CUBE_MAP, GL_TEXTURE_CUBE_MAP } 3026 }; 3027 3028 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(textureBindings); testNdx++) 3029 { 3030 FOR_EACH_QUERYTYPE(queryTypes, addChild(new TextureBindingTestCase(m_context, queryType, (std::string(textureBindings[testNdx].name) + getQueryTypeSuffix(queryType)).c_str(), textureBindings[testNdx].description, textureBindings[testNdx].target, textureBindings[testNdx].type))); 3031 } 3032 3033 3034 FOR_EACH_QUERYTYPE(queryTypes, addChild(new FrameBufferBindingTestCase (m_context, queryType, (std::string("framebuffer_binding") + getQueryTypeSuffix(queryType)).c_str(), "DRAW_FRAMEBUFFER_BINDING and READ_FRAMEBUFFER_BINDING"))); 3035 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationColorReadTestCase (m_context, verifier, (std::string("implementation_color_read") + verifier->getTestNamePostfix()).c_str(), "IMPLEMENTATION_COLOR_READ_TYPE and IMPLEMENTATION_COLOR_READ_FORMAT"))); 3036 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ReadBufferCase (m_context, verifier, (std::string("read_buffer") + verifier->getTestNamePostfix()).c_str(), "READ_BUFFER"))); 3037 FOR_EACH_VERIFIER(normalVerifiers, addChild(new DrawBufferCase (m_context, verifier, (std::string("draw_buffer") + verifier->getTestNamePostfix()).c_str(), "DRAW_BUFFER"))); 3038 } 3039 3040 void IntegerStateQueryTests::deinit (void) 3041 { 3042 if (m_verifierBoolean) 3043 { 3044 delete m_verifierBoolean; 3045 m_verifierBoolean = DE_NULL; 3046 } 3047 if (m_verifierInteger) 3048 { 3049 delete m_verifierInteger; 3050 m_verifierInteger = DE_NULL; 3051 } 3052 if (m_verifierInteger64) 3053 { 3054 delete m_verifierInteger64; 3055 m_verifierInteger64 = DE_NULL; 3056 } 3057 if (m_verifierFloat) 3058 { 3059 delete m_verifierFloat; 3060 m_verifierFloat = DE_NULL; 3061 } 3062 3063 this->TestCaseGroup::deinit(); 3064 } 3065 3066 } // Functional 3067 } // gles3 3068 } // deqp 3069