1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program OpenGL ES 2.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 "es2fIntegerStateQueryTests.hpp" 25 #include "es2fApiCase.hpp" 26 #include "glsStateQueryUtil.hpp" 27 #include "gluRenderContext.hpp" 28 #include "gluContextInfo.hpp" 29 #include "tcuRenderTarget.hpp" 30 #include "deRandom.hpp" 31 #include "glwEnums.hpp" 32 33 using namespace glw; // GLint and other GL types 34 using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard; 35 36 #ifndef GL_SLUMINANCE_NV 37 #define GL_SLUMINANCE_NV 0x8C46 38 #endif 39 #ifndef GL_SLUMINANCE_ALPHA_NV 40 #define GL_SLUMINANCE_ALPHA_NV 0x8C44 41 #endif 42 #ifndef GL_BGR_NV 43 #define GL_BGR_NV 0x80E0 44 #endif 45 46 namespace deqp 47 { 48 namespace gles2 49 { 50 namespace Functional 51 { 52 namespace IntegerStateQueryVerifiers 53 { 54 55 // StateVerifier 56 57 class StateVerifier : protected glu::CallLogWrapper 58 { 59 public: 60 StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix); 61 virtual ~StateVerifier (); // make GCC happy 62 63 const char* getTestNamePostfix (void) const; 64 65 virtual void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) = DE_NULL; 66 virtual void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) = DE_NULL; 67 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; 68 virtual void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) = DE_NULL; 69 virtual void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) = DE_NULL; 70 virtual void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) = DE_NULL; 71 virtual void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) = DE_NULL; 72 virtual void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) = DE_NULL; 73 74 private: 75 const char* const m_testNamePostfix; 76 }; 77 78 StateVerifier::StateVerifier (const glw::Functions& gl, tcu::TestLog& log, const char* testNamePostfix) 79 : glu::CallLogWrapper (gl, log) 80 , m_testNamePostfix (testNamePostfix) 81 { 82 enableLogging(true); 83 } 84 85 StateVerifier::~StateVerifier () 86 { 87 } 88 89 const char* StateVerifier::getTestNamePostfix (void) const 90 { 91 return m_testNamePostfix; 92 } 93 94 // GetBooleanVerifier 95 96 class GetBooleanVerifier : public StateVerifier 97 { 98 public: 99 GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log); 100 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference); 101 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3); 102 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3); 103 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 104 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference); 105 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1); 106 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength); 107 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits); 108 }; 109 110 GetBooleanVerifier::GetBooleanVerifier (const glw::Functions& gl, tcu::TestLog& log) 111 : StateVerifier(gl, log, "_getboolean") 112 { 113 } 114 115 void GetBooleanVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) 116 { 117 using tcu::TestLog; 118 119 StateQueryMemoryWriteGuard<GLboolean> state; 120 glGetBooleanv(name, &state); 121 122 if (!state.verifyValidity(testCtx)) 123 return; 124 125 const GLboolean expectedGLState = reference ? GL_TRUE : GL_FALSE; 126 127 if (state != expectedGLState) 128 { 129 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; 130 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 131 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 132 } 133 } 134 135 void GetBooleanVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) 136 { 137 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true); 138 } 139 140 void GetBooleanVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3) 141 { 142 using tcu::TestLog; 143 144 StateQueryMemoryWriteGuard<GLboolean[4]> boolVector4; 145 glGetBooleanv(name, boolVector4); 146 147 if (!boolVector4.verifyValidity(testCtx)) 148 return; 149 150 const GLboolean referenceAsGLBoolean[] = 151 { 152 reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 153 reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 154 reference2 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 155 reference3 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 156 }; 157 158 if ((enableRef0 && (boolVector4[0] != referenceAsGLBoolean[0])) || 159 (enableRef1 && (boolVector4[1] != referenceAsGLBoolean[1])) || 160 (enableRef2 && (boolVector4[2] != referenceAsGLBoolean[2])) || 161 (enableRef3 && (boolVector4[3] != referenceAsGLBoolean[3]))) 162 { 163 testCtx.getLog() << TestLog::Message << "// ERROR: expected " 164 << (enableRef0 ? (referenceAsGLBoolean[0] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", " 165 << (enableRef1 ? (referenceAsGLBoolean[1] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", " 166 << (enableRef2 ? (referenceAsGLBoolean[2] ? "GL_TRUE" : "GL_FALSE") : " - ") << ", " 167 << (enableRef3 ? (referenceAsGLBoolean[3] ? "GL_TRUE" : "GL_FALSE") : " - ") << TestLog::EndMessage; 168 169 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 170 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 171 } 172 } 173 174 void GetBooleanVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 175 { 176 using tcu::TestLog; 177 178 StateQueryMemoryWriteGuard<GLboolean> state; 179 glGetBooleanv(name, &state); 180 181 if (!state.verifyValidity(testCtx)) 182 return; 183 184 if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct) 185 return; 186 187 if (state == GL_FALSE) // state is zero 188 { 189 if (reference > 0) // and reference is greater than zero? 190 { 191 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage; 192 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 193 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 194 } 195 } 196 else 197 { 198 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage; 199 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 200 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 201 } 202 } 203 204 void GetBooleanVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) 205 { 206 using tcu::TestLog; 207 208 StateQueryMemoryWriteGuard<GLboolean> state; 209 glGetBooleanv(name, &state); 210 211 if (!state.verifyValidity(testCtx)) 212 return; 213 214 if (state == GL_TRUE) // state is non-zero, could be greater than reference (correct) 215 return; 216 217 if (state == GL_FALSE) // state is zero 218 { 219 if (reference > 0) // and reference is greater than zero? 220 { 221 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage; 222 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 223 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 224 } 225 } 226 else 227 { 228 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage; 229 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 230 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 231 } 232 } 233 234 void GetBooleanVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) 235 { 236 using tcu::TestLog; 237 238 StateQueryMemoryWriteGuard<GLboolean[2]> boolVector; 239 glGetBooleanv(name, boolVector); 240 241 if (!boolVector.verifyValidity(testCtx)) 242 return; 243 244 const GLboolean referenceAsGLBoolean[2] = 245 { 246 reference0 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE, 247 reference1 ? (GLboolean)GL_TRUE : (GLboolean)GL_FALSE 248 }; 249 250 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceAsGLBoolean); ++ndx) 251 { 252 if (boolVector[ndx] == GL_TRUE) // state is non-zero, could be greater than any integer 253 { 254 continue; 255 } 256 else if (boolVector[ndx] == GL_FALSE) // state is zero 257 { 258 if (referenceAsGLBoolean[ndx] > 0) // and reference is greater than zero? 259 { 260 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage; 261 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 262 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 263 } 264 } 265 else 266 { 267 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE or GL_FALSE" << TestLog::EndMessage; 268 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 269 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 270 } 271 } 272 } 273 274 void GetBooleanVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) 275 { 276 using tcu::TestLog; 277 278 StateQueryMemoryWriteGuard<GLboolean> state; 279 glGetBooleanv(name, &state); 280 281 if (!state.verifyValidity(testCtx)) 282 return; 283 284 for (size_t ndx = 0; ndx < referencesLength; ++ndx) 285 { 286 const GLboolean expectedGLState = references[ndx] ? GL_TRUE : GL_FALSE; 287 288 if (state == expectedGLState) 289 return; 290 } 291 292 testCtx.getLog() << TestLog::Message << "// ERROR: got " << (state==GL_TRUE ? "GL_TRUE" : "GL_FALSE") << TestLog::EndMessage; 293 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 294 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 295 } 296 297 void GetBooleanVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) 298 { 299 // if stencilBits == 0, the mask is allowed to be either GL_TRUE or GL_FALSE 300 // otherwise it must be GL_TRUE 301 using tcu::TestLog; 302 303 StateQueryMemoryWriteGuard<GLboolean> state; 304 glGetBooleanv(name, &state); 305 306 if (!state.verifyValidity(testCtx)) 307 return; 308 309 if (stencilBits > 0 && state != GL_TRUE) 310 { 311 testCtx.getLog() << TestLog::Message << "// ERROR: expected GL_TRUE" << TestLog::EndMessage; 312 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 313 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid boolean value"); 314 } 315 } 316 317 //GetIntegerVerifier 318 319 class GetIntegerVerifier : public StateVerifier 320 { 321 public: 322 GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log); 323 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference); 324 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3); 325 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3); 326 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 327 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference); 328 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1); 329 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength); 330 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits); 331 }; 332 333 GetIntegerVerifier::GetIntegerVerifier (const glw::Functions& gl, tcu::TestLog& log) 334 : StateVerifier(gl, log, "_getinteger") 335 { 336 } 337 338 void GetIntegerVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) 339 { 340 using tcu::TestLog; 341 342 StateQueryMemoryWriteGuard<GLint> state; 343 glGetIntegerv(name, &state); 344 345 if (!state.verifyValidity(testCtx)) 346 return; 347 348 if (state != reference) 349 { 350 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << reference << "; got " << state << TestLog::EndMessage; 351 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 352 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 353 } 354 } 355 356 void GetIntegerVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) 357 { 358 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true); 359 } 360 361 void GetIntegerVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3) 362 { 363 using tcu::TestLog; 364 365 StateQueryMemoryWriteGuard<GLint[4]> intVector4; 366 glGetIntegerv(name, intVector4); 367 368 if (!intVector4.verifyValidity(testCtx)) 369 return; 370 371 if ((enableRef0 && (intVector4[0] != reference0)) || 372 (enableRef1 && (intVector4[1] != reference1)) || 373 (enableRef2 && (intVector4[2] != reference2)) || 374 (enableRef3 && (intVector4[3] != reference3))) 375 { 376 testCtx.getLog() << TestLog::Message << "// ERROR: expected " 377 << (enableRef0?"":"(") << reference0 << (enableRef0?"":")") << ", " 378 << (enableRef1?"":"(") << reference1 << (enableRef1?"":")") << ", " 379 << (enableRef2?"":"(") << reference2 << (enableRef2?"":")") << ", " 380 << (enableRef3?"":"(") << reference3 << (enableRef3?"":")") << TestLog::EndMessage; 381 382 383 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 384 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 385 } 386 } 387 388 void GetIntegerVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 389 { 390 using tcu::TestLog; 391 392 StateQueryMemoryWriteGuard<GLint> state; 393 glGetIntegerv(name, &state); 394 395 if (!state.verifyValidity(testCtx)) 396 return; 397 398 if (state < reference) 399 { 400 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << state << TestLog::EndMessage; 401 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 402 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 403 } 404 } 405 406 void GetIntegerVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) 407 { 408 using tcu::TestLog; 409 410 StateQueryMemoryWriteGuard<GLint> state; 411 glGetIntegerv(name, &state); 412 413 if (!state.verifyValidity(testCtx)) 414 return; 415 416 if (GLuint(state) < reference) 417 { 418 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference << "; got " << GLuint(state) << TestLog::EndMessage; 419 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 420 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 421 } 422 } 423 424 void GetIntegerVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) 425 { 426 using tcu::TestLog; 427 428 StateQueryMemoryWriteGuard<GLint[2]> intVector2; 429 glGetIntegerv(name, intVector2); 430 431 if (!intVector2.verifyValidity(testCtx)) 432 return; 433 434 if (intVector2[0] < reference0 || intVector2[1] < reference1) 435 { 436 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << reference0 << ", " << reference1 << "; got " << intVector2[0] << ", " << intVector2[0] << TestLog::EndMessage; 437 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 438 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 439 } 440 } 441 442 void GetIntegerVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) 443 { 444 using tcu::TestLog; 445 446 StateQueryMemoryWriteGuard<GLint> state; 447 glGetIntegerv(name, &state); 448 449 if (!state.verifyValidity(testCtx)) 450 return; 451 452 for (size_t ndx = 0; ndx < referencesLength; ++ndx) 453 { 454 const GLint expectedGLState = references[ndx]; 455 456 if (state == expectedGLState) 457 return; 458 } 459 460 testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage; 461 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 462 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid integer value"); 463 } 464 465 void GetIntegerVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) 466 { 467 using tcu::TestLog; 468 469 StateQueryMemoryWriteGuard<GLint> state; 470 glGetIntegerv(name, &state); 471 472 if (!state.verifyValidity(testCtx)) 473 return; 474 475 const GLint reference = (1 << stencilBits) - 1; 476 477 if ((state & reference) != reference) // the least significant stencilBits bits should be on 478 { 479 testCtx.getLog() << TestLog::Message << "// ERROR: expected minimum mask of " << reference << "; got " << state << TestLog::EndMessage; 480 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 481 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid mask value"); 482 } 483 } 484 485 //GetFloatVerifier 486 487 class GetFloatVerifier : public StateVerifier 488 { 489 public: 490 GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log); 491 void verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference); 492 void verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3); 493 void verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3); 494 void verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference); 495 void verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference); 496 void verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1); 497 void verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength); 498 void verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits); 499 }; 500 501 GetFloatVerifier::GetFloatVerifier (const glw::Functions& gl, tcu::TestLog& log) 502 : StateVerifier(gl, log, "_getfloat") 503 { 504 } 505 506 void GetFloatVerifier::verifyInteger (tcu::TestContext& testCtx, GLenum name, GLint reference) 507 { 508 using tcu::TestLog; 509 510 const GLfloat referenceAsFloat = GLfloat(reference); 511 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 512 513 StateQueryMemoryWriteGuard<GLfloat> state; 514 glGetFloatv(name, &state); 515 516 if (!state.verifyValidity(testCtx)) 517 return; 518 519 if (state != referenceAsFloat) 520 { 521 testCtx.getLog() << TestLog::Message << "// ERROR: expected " << referenceAsFloat << "; got " << state << TestLog::EndMessage; 522 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 523 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 524 } 525 } 526 527 void GetFloatVerifier::verifyInteger4 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1, GLint reference2, GLint reference3) 528 { 529 verifyInteger4Mask(testCtx, name, reference0, true, reference1, true, reference2, true, reference3, true); 530 } 531 532 void GetFloatVerifier::verifyInteger4Mask (tcu::TestContext& testCtx, GLenum name, GLint reference0, bool enableRef0, GLint reference1, bool enableRef1, GLint reference2, bool enableRef2, GLint reference3, bool enableRef3) 533 { 534 using tcu::TestLog; 535 536 StateQueryMemoryWriteGuard<GLfloat[4]> floatVector4; 537 glGetFloatv(name, floatVector4); 538 539 if (!floatVector4.verifyValidity(testCtx)) 540 return; 541 542 if ((enableRef0 && (floatVector4[0] != GLfloat(reference0))) || 543 (enableRef1 && (floatVector4[1] != GLfloat(reference1))) || 544 (enableRef2 && (floatVector4[2] != GLfloat(reference2))) || 545 (enableRef3 && (floatVector4[3] != GLfloat(reference3)))) 546 { 547 testCtx.getLog() << TestLog::Message << "// ERROR: expected " 548 << (enableRef0?"":"(") << GLfloat(reference0) << (enableRef0?"":")") << ", " 549 << (enableRef1?"":"(") << GLfloat(reference1) << (enableRef1?"":")") << ", " 550 << (enableRef2?"":"(") << GLfloat(reference2) << (enableRef2?"":")") << ", " 551 << (enableRef3?"":"(") << GLfloat(reference3) << (enableRef3?"":")") << TestLog::EndMessage; 552 553 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 554 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 555 } 556 } 557 558 void GetFloatVerifier::verifyIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLint reference) 559 { 560 using tcu::TestLog; 561 562 StateQueryMemoryWriteGuard<GLfloat> state; 563 glGetFloatv(name, &state); 564 565 if (!state.verifyValidity(testCtx)) 566 return; 567 568 if (state < GLfloat(reference)) 569 { 570 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << state << TestLog::EndMessage; 571 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 572 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 573 } 574 } 575 576 void GetFloatVerifier::verifyUnsignedIntegerGreaterOrEqual (tcu::TestContext& testCtx, GLenum name, GLuint reference) 577 { 578 using tcu::TestLog; 579 580 StateQueryMemoryWriteGuard<GLfloat> state; 581 glGetFloatv(name, &state); 582 583 if (!state.verifyValidity(testCtx)) 584 return; 585 586 if (GLuint(state) < GLfloat(reference)) 587 { 588 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference) << "; got " << GLuint(state) << TestLog::EndMessage; 589 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 590 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 591 } 592 } 593 594 void GetFloatVerifier::verifyIntegerGreaterOrEqual2 (tcu::TestContext& testCtx, GLenum name, GLint reference0, GLint reference1) 595 { 596 using tcu::TestLog; 597 598 StateQueryMemoryWriteGuard<GLfloat[2]> floatVector2; 599 glGetFloatv(name, floatVector2); 600 601 if (!floatVector2.verifyValidity(testCtx)) 602 return; 603 604 if (floatVector2[0] < GLfloat(reference0) || floatVector2[1] < GLfloat(reference1)) 605 { 606 testCtx.getLog() << TestLog::Message << "// ERROR: expected greater or equal to " << GLfloat(reference0) << ", " << GLfloat(reference1) << "; got " << floatVector2[0] << ", " << floatVector2[1] << TestLog::EndMessage; 607 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 608 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 609 } 610 } 611 612 void GetFloatVerifier::verifyIntegerAnyOf (tcu::TestContext& testCtx, GLenum name, const GLint references[], size_t referencesLength) 613 { 614 using tcu::TestLog; 615 616 StateQueryMemoryWriteGuard<GLfloat> state; 617 glGetFloatv(name, &state); 618 619 if (!state.verifyValidity(testCtx)) 620 return; 621 622 for (size_t ndx = 0; ndx < referencesLength; ++ndx) 623 { 624 const GLfloat expectedGLState = GLfloat(references[ndx]); 625 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 626 627 if (state == expectedGLState) 628 return; 629 } 630 631 testCtx.getLog() << TestLog::Message << "// ERROR: got " << state << TestLog::EndMessage; 632 if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 633 testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid float value"); 634 } 635 636 void GetFloatVerifier::verifyStencilMaskInitial (tcu::TestContext& testCtx, GLenum name, int stencilBits) 637 { 638 // checking the mask bits with float doesn't make much sense because of conversion errors 639 // just verify that the value is greater or equal to the minimum value 640 const GLint reference = (1 << stencilBits) - 1; 641 verifyIntegerGreaterOrEqual(testCtx, name, reference); 642 } 643 644 } // IntegerStateQueryVerifiers 645 646 namespace 647 { 648 649 using namespace IntegerStateQueryVerifiers; 650 651 static const char* testVertSource = "void main (void)\n" 652 "{\n" 653 " gl_Position = vec4(0.0);\n" 654 "}\n"; 655 static const char* testFragSource = "void main (void)\n" 656 "{\n" 657 " gl_FragColor = vec4(0.0);\n" 658 "}\n"; 659 660 class ConstantMinimumValueTestCase : public ApiCase 661 { 662 public: 663 ConstantMinimumValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName, GLint minValue) 664 : ApiCase (context, name, description) 665 , m_targetName (targetName) 666 , m_minValue (minValue) 667 , m_verifier (verifier) 668 { 669 } 670 671 void test (void) 672 { 673 m_verifier->verifyUnsignedIntegerGreaterOrEqual(m_testCtx, m_targetName, m_minValue); 674 expectError(GL_NO_ERROR); 675 } 676 677 private: 678 GLenum m_targetName; 679 GLint m_minValue; 680 StateVerifier* m_verifier; 681 }; 682 683 class SampleBuffersTestCase : public ApiCase 684 { 685 public: 686 SampleBuffersTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 687 : ApiCase (context, name, description) 688 , m_verifier (verifier) 689 { 690 } 691 692 void test (void) 693 { 694 const int expectedSampleBuffers = (m_context.getRenderTarget().getNumSamples() > 1) ? 1 : 0; 695 696 m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << ", expecting GL_SAMPLE_BUFFERS to be " << expectedSampleBuffers << tcu::TestLog::EndMessage; 697 698 m_verifier->verifyInteger(m_testCtx, GL_SAMPLE_BUFFERS, expectedSampleBuffers); 699 expectError(GL_NO_ERROR); 700 } 701 702 private: 703 StateVerifier* m_verifier; 704 }; 705 706 class SamplesTestCase : public ApiCase 707 { 708 public: 709 SamplesTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 710 : ApiCase (context, name, description) 711 , m_verifier (verifier) 712 { 713 } 714 715 void test (void) 716 { 717 // MSAA? 718 if (m_context.getRenderTarget().getNumSamples() > 1) 719 { 720 m_log << tcu::TestLog::Message << "Sample count is " << (m_context.getRenderTarget().getNumSamples()) << tcu::TestLog::EndMessage; 721 722 m_verifier->verifyInteger(m_testCtx, GL_SAMPLES, m_context.getRenderTarget().getNumSamples()); 723 expectError(GL_NO_ERROR); 724 } 725 else 726 { 727 const glw::GLint validSamples[] = {0, 1}; 728 729 m_log << tcu::TestLog::Message << "Expecting GL_SAMPLES to be 0 or 1" << tcu::TestLog::EndMessage; 730 731 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_SAMPLES, validSamples, DE_LENGTH_OF_ARRAY(validSamples)); 732 expectError(GL_NO_ERROR); 733 } 734 } 735 736 private: 737 StateVerifier* m_verifier; 738 }; 739 740 class HintTestCase : public ApiCase 741 { 742 public: 743 HintTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum targetName) 744 : ApiCase (context, name, description) 745 , m_targetName (targetName) 746 , m_verifier (verifier) 747 { 748 } 749 750 void test (void) 751 { 752 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE); 753 expectError(GL_NO_ERROR); 754 755 glHint(m_targetName, GL_NICEST); 756 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_NICEST); 757 expectError(GL_NO_ERROR); 758 759 glHint(m_targetName, GL_FASTEST); 760 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_FASTEST); 761 expectError(GL_NO_ERROR); 762 763 glHint(m_targetName, GL_DONT_CARE); 764 m_verifier->verifyInteger(m_testCtx, m_targetName, GL_DONT_CARE); 765 expectError(GL_NO_ERROR); 766 } 767 768 private: 769 GLenum m_targetName; 770 StateVerifier* m_verifier; 771 }; 772 773 class DepthFuncTestCase : public ApiCase 774 { 775 public: 776 DepthFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 777 : ApiCase (context, name, description) 778 , m_verifier (verifier) 779 { 780 } 781 782 void test (void) 783 { 784 m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, GL_LESS); 785 expectError(GL_NO_ERROR); 786 787 const GLenum depthFunctions[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GREATER, GL_GEQUAL, GL_NOTEQUAL}; 788 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthFunctions); ndx++) 789 { 790 glDepthFunc(depthFunctions[ndx]); 791 expectError(GL_NO_ERROR); 792 793 m_verifier->verifyInteger(m_testCtx, GL_DEPTH_FUNC, depthFunctions[ndx]); 794 expectError(GL_NO_ERROR); 795 } 796 } 797 798 private: 799 StateVerifier* m_verifier; 800 }; 801 802 class CullFaceTestCase : public ApiCase 803 { 804 public: 805 CullFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 806 : ApiCase (context, name, description) 807 , m_verifier (verifier) 808 { 809 } 810 811 void test (void) 812 { 813 m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, GL_BACK); 814 expectError(GL_NO_ERROR); 815 816 const GLenum cullFaces[] = {GL_FRONT, GL_BACK, GL_FRONT_AND_BACK}; 817 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(cullFaces); ndx++) 818 { 819 glCullFace(cullFaces[ndx]); 820 expectError(GL_NO_ERROR); 821 822 m_verifier->verifyInteger(m_testCtx, GL_CULL_FACE_MODE, cullFaces[ndx]); 823 expectError(GL_NO_ERROR); 824 } 825 } 826 827 private: 828 StateVerifier* m_verifier; 829 }; 830 831 class FrontFaceTestCase : public ApiCase 832 { 833 public: 834 FrontFaceTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 835 : ApiCase (context, name, description) 836 , m_verifier (verifier) 837 { 838 } 839 840 void test (void) 841 { 842 m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, GL_CCW); 843 expectError(GL_NO_ERROR); 844 845 const GLenum frontFaces[] = {GL_CW, GL_CCW}; 846 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(frontFaces); ndx++) 847 { 848 glFrontFace(frontFaces[ndx]); 849 expectError(GL_NO_ERROR); 850 851 m_verifier->verifyInteger(m_testCtx, GL_FRONT_FACE, frontFaces[ndx]); 852 expectError(GL_NO_ERROR); 853 } 854 } 855 856 private: 857 StateVerifier* m_verifier; 858 }; 859 860 class ViewPortTestCase : public ApiCase 861 { 862 public: 863 ViewPortTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 864 : ApiCase (context, name, description) 865 , m_verifier (verifier) 866 { 867 } 868 869 void test (void) 870 { 871 de::Random rnd(0xabcdef); 872 873 GLint maxViewportDimensions[2] = {0}; 874 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, maxViewportDimensions); 875 876 // verify initial value of first two values 877 m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, 0, 0, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight()); 878 expectError(GL_NO_ERROR); 879 880 const int numIterations = 120; 881 for (int i = 0; i < numIterations; ++i) 882 { 883 GLint x = rnd.getInt(-64000, 64000); 884 GLint y = rnd.getInt(-64000, 64000); 885 GLsizei width = rnd.getInt(0, maxViewportDimensions[0]); 886 GLsizei height = rnd.getInt(0, maxViewportDimensions[1]); 887 888 glViewport(x, y, width, height); 889 m_verifier->verifyInteger4(m_testCtx, GL_VIEWPORT, x, y, width, height); 890 expectError(GL_NO_ERROR); 891 } 892 } 893 894 private: 895 StateVerifier* m_verifier; 896 }; 897 898 class ScissorBoxTestCase : public ApiCase 899 { 900 public: 901 ScissorBoxTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 902 : ApiCase (context, name, description) 903 , m_verifier (verifier) 904 { 905 } 906 907 void test (void) 908 { 909 de::Random rnd(0xabcdef); 910 911 // verify initial value 912 m_verifier->verifyInteger4(m_testCtx, GL_SCISSOR_BOX, 0, 0, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight()); 913 expectError(GL_NO_ERROR); 914 915 const int numIterations = 120; 916 for (int i = 0; i < numIterations; ++i) 917 { 918 GLint left = rnd.getInt(-64000, 64000); 919 GLint bottom = rnd.getInt(-64000, 64000); 920 GLsizei width = rnd.getInt(0, 64000); 921 GLsizei height = rnd.getInt(0, 64000); 922 923 glScissor(left, bottom, width, height); 924 m_verifier->verifyInteger4(m_testCtx, GL_SCISSOR_BOX, left, bottom, width, height); 925 expectError(GL_NO_ERROR); 926 } 927 } 928 private: 929 StateVerifier* m_verifier; 930 }; 931 932 class MaxViewportDimsTestCase : public ApiCase 933 { 934 public: 935 MaxViewportDimsTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 936 : ApiCase (context, name, description) 937 , m_verifier (verifier) 938 { 939 } 940 941 void test (void) 942 { 943 m_verifier->verifyIntegerGreaterOrEqual2(m_testCtx, GL_MAX_VIEWPORT_DIMS, m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight()); 944 expectError(GL_NO_ERROR); 945 } 946 private: 947 StateVerifier* m_verifier; 948 }; 949 950 class StencilRefTestCase : public ApiCase 951 { 952 public: 953 StencilRefTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName) 954 : ApiCase (context, name, description) 955 , m_verifier (verifier) 956 , m_testTargetName (testTargetName) 957 { 958 } 959 960 void test (void) 961 { 962 m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0); 963 expectError(GL_NO_ERROR); 964 965 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 966 967 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 968 { 969 const int ref = 1 << stencilBit; 970 971 glStencilFunc(GL_ALWAYS, ref, 0); // mask should not affect the REF 972 expectError(GL_NO_ERROR); 973 974 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref); 975 expectError(GL_NO_ERROR); 976 977 glStencilFunc(GL_ALWAYS, ref, ref); 978 expectError(GL_NO_ERROR); 979 980 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref); 981 expectError(GL_NO_ERROR); 982 } 983 } 984 985 private: 986 StateVerifier* m_verifier; 987 GLenum m_testTargetName; 988 }; 989 990 class StencilRefSeparateTestCase : public ApiCase 991 { 992 public: 993 StencilRefSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace) 994 : ApiCase (context, name, description) 995 , m_verifier (verifier) 996 , m_testTargetName (testTargetName) 997 , m_stencilFuncTargetFace (stencilFuncTargetFace) 998 { 999 } 1000 1001 void test (void) 1002 { 1003 m_verifier->verifyInteger(m_testCtx, m_testTargetName, 0); 1004 expectError(GL_NO_ERROR); 1005 1006 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1007 1008 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1009 { 1010 const int ref = 1 << stencilBit; 1011 1012 glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, 0); 1013 expectError(GL_NO_ERROR); 1014 1015 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref); 1016 expectError(GL_NO_ERROR); 1017 1018 glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, ref, ref); 1019 expectError(GL_NO_ERROR); 1020 1021 m_verifier->verifyInteger(m_testCtx, m_testTargetName, ref); 1022 expectError(GL_NO_ERROR); 1023 } 1024 } 1025 private: 1026 StateVerifier* m_verifier; 1027 GLenum m_testTargetName; 1028 GLenum m_stencilFuncTargetFace; 1029 }; 1030 1031 class StencilOpTestCase : public ApiCase 1032 { 1033 public: 1034 StencilOpTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName) 1035 : ApiCase (context, name, description) 1036 , m_verifier (verifier) 1037 , m_stencilOpName (stencilOpName) 1038 { 1039 } 1040 1041 void test (void) 1042 { 1043 m_verifier->verifyInteger(m_testCtx, m_stencilOpName, GL_KEEP); 1044 expectError(GL_NO_ERROR); 1045 1046 const GLenum stencilOpValues[] = {GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, GL_INVERT, GL_INCR_WRAP, GL_DECR_WRAP}; 1047 1048 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilOpValues); ++ndx) 1049 { 1050 SetStencilOp(stencilOpValues[ndx]); 1051 expectError(GL_NO_ERROR); 1052 1053 m_verifier->verifyInteger(m_testCtx, m_stencilOpName, stencilOpValues[ndx]); 1054 expectError(GL_NO_ERROR); 1055 } 1056 } 1057 1058 protected: 1059 virtual void SetStencilOp (GLenum stencilOpValue) 1060 { 1061 switch (m_stencilOpName) 1062 { 1063 case GL_STENCIL_FAIL: 1064 case GL_STENCIL_BACK_FAIL: 1065 glStencilOp(stencilOpValue, GL_KEEP, GL_KEEP); 1066 break; 1067 1068 case GL_STENCIL_PASS_DEPTH_FAIL: 1069 case GL_STENCIL_BACK_PASS_DEPTH_FAIL: 1070 glStencilOp(GL_KEEP, stencilOpValue, GL_KEEP); 1071 break; 1072 1073 case GL_STENCIL_PASS_DEPTH_PASS: 1074 case GL_STENCIL_BACK_PASS_DEPTH_PASS: 1075 glStencilOp(GL_KEEP, GL_KEEP, stencilOpValue); 1076 break; 1077 1078 default: 1079 DE_ASSERT(false && "should not happen"); 1080 break; 1081 } 1082 } 1083 1084 StateVerifier* m_verifier; 1085 GLenum m_stencilOpName; 1086 }; 1087 1088 class StencilOpSeparateTestCase : public StencilOpTestCase 1089 { 1090 public: 1091 StencilOpSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilOpName, GLenum stencilOpFace) 1092 : StencilOpTestCase (context, verifier, name, description, stencilOpName) 1093 , m_stencilOpFace (stencilOpFace) 1094 { 1095 } 1096 1097 private: 1098 void SetStencilOp (GLenum stencilOpValue) 1099 { 1100 switch (m_stencilOpName) 1101 { 1102 case GL_STENCIL_FAIL: 1103 case GL_STENCIL_BACK_FAIL: 1104 glStencilOpSeparate(m_stencilOpFace, stencilOpValue, GL_KEEP, GL_KEEP); 1105 break; 1106 1107 case GL_STENCIL_PASS_DEPTH_FAIL: 1108 case GL_STENCIL_BACK_PASS_DEPTH_FAIL: 1109 glStencilOpSeparate(m_stencilOpFace, GL_KEEP, stencilOpValue, GL_KEEP); 1110 break; 1111 1112 case GL_STENCIL_PASS_DEPTH_PASS: 1113 case GL_STENCIL_BACK_PASS_DEPTH_PASS: 1114 glStencilOpSeparate(m_stencilOpFace, GL_KEEP, GL_KEEP, stencilOpValue); 1115 break; 1116 1117 default: 1118 DE_ASSERT(false && "should not happen"); 1119 break; 1120 } 1121 } 1122 1123 GLenum m_stencilOpFace; 1124 }; 1125 1126 class StencilFuncTestCase : public ApiCase 1127 { 1128 public: 1129 StencilFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1130 : ApiCase (context, name, description) 1131 , m_verifier (verifier) 1132 { 1133 } 1134 1135 void test (void) 1136 { 1137 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, GL_ALWAYS); 1138 expectError(GL_NO_ERROR); 1139 1140 const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL}; 1141 1142 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx) 1143 { 1144 glStencilFunc(stencilfuncValues[ndx], 0, 0); 1145 expectError(GL_NO_ERROR); 1146 1147 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_FUNC, stencilfuncValues[ndx]); 1148 expectError(GL_NO_ERROR); 1149 1150 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_BACK_FUNC, stencilfuncValues[ndx]); 1151 expectError(GL_NO_ERROR); 1152 } 1153 } 1154 private: 1155 StateVerifier* m_verifier; 1156 }; 1157 1158 class StencilFuncSeparateTestCase : public ApiCase 1159 { 1160 public: 1161 StencilFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum stencilFuncName, GLenum stencilFuncFace) 1162 : ApiCase (context, name, description) 1163 , m_verifier (verifier) 1164 , m_stencilFuncName (stencilFuncName) 1165 , m_stencilFuncFace (stencilFuncFace) 1166 { 1167 } 1168 1169 void test (void) 1170 { 1171 m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, GL_ALWAYS); 1172 expectError(GL_NO_ERROR); 1173 1174 const GLenum stencilfuncValues[] = {GL_NEVER, GL_ALWAYS, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER, GL_NOTEQUAL}; 1175 1176 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(stencilfuncValues); ++ndx) 1177 { 1178 glStencilFuncSeparate(m_stencilFuncFace, stencilfuncValues[ndx], 0, 0); 1179 expectError(GL_NO_ERROR); 1180 1181 m_verifier->verifyInteger(m_testCtx, m_stencilFuncName, stencilfuncValues[ndx]); 1182 expectError(GL_NO_ERROR); 1183 } 1184 } 1185 private: 1186 StateVerifier* m_verifier; 1187 GLenum m_stencilFuncName; 1188 GLenum m_stencilFuncFace; 1189 }; 1190 1191 class StencilMaskTestCase : public ApiCase 1192 { 1193 public: 1194 StencilMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName) 1195 : ApiCase (context, name, description) 1196 , m_verifier (verifier) 1197 , m_testTargetName (testTargetName) 1198 { 1199 } 1200 1201 void test (void) 1202 { 1203 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1204 1205 m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits); 1206 expectError(GL_NO_ERROR); 1207 1208 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1209 { 1210 const int mask = 1 << stencilBit; 1211 1212 glStencilFunc(GL_ALWAYS, 0, mask); 1213 expectError(GL_NO_ERROR); 1214 1215 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask); 1216 expectError(GL_NO_ERROR); 1217 } 1218 } 1219 private: 1220 StateVerifier* m_verifier; 1221 GLenum m_testTargetName; 1222 }; 1223 1224 class StencilMaskSeparateTestCase : public ApiCase 1225 { 1226 public: 1227 StencilMaskSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilFuncTargetFace) 1228 : ApiCase (context, name, description) 1229 , m_verifier (verifier) 1230 , m_testTargetName (testTargetName) 1231 , m_stencilFuncTargetFace (stencilFuncTargetFace) 1232 { 1233 } 1234 1235 void test (void) 1236 { 1237 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1238 1239 m_verifier->verifyStencilMaskInitial(m_testCtx, m_testTargetName, stencilBits); 1240 expectError(GL_NO_ERROR); 1241 1242 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1243 { 1244 const int mask = 1 << stencilBit; 1245 1246 glStencilFuncSeparate(m_stencilFuncTargetFace, GL_ALWAYS, 0, mask); 1247 expectError(GL_NO_ERROR); 1248 1249 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask); 1250 expectError(GL_NO_ERROR); 1251 } 1252 } 1253 private: 1254 StateVerifier* m_verifier; 1255 GLenum m_testTargetName; 1256 GLenum m_stencilFuncTargetFace; 1257 }; 1258 1259 class StencilWriteMaskTestCase : public ApiCase 1260 { 1261 public: 1262 StencilWriteMaskTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName) 1263 : ApiCase (context, name, description) 1264 , m_verifier (verifier) 1265 , m_testTargetName (testTargetName) 1266 { 1267 } 1268 1269 void test (void) 1270 { 1271 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1272 1273 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1274 { 1275 const int mask = 1 << stencilBit; 1276 1277 glStencilMask(mask); 1278 expectError(GL_NO_ERROR); 1279 1280 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask); 1281 expectError(GL_NO_ERROR); 1282 } 1283 } 1284 private: 1285 StateVerifier* m_verifier; 1286 GLenum m_testTargetName; 1287 }; 1288 1289 class StencilWriteMaskSeparateTestCase : public ApiCase 1290 { 1291 public: 1292 StencilWriteMaskSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum stencilTargetFace) 1293 : ApiCase (context, name, description) 1294 , m_verifier (verifier) 1295 , m_testTargetName (testTargetName) 1296 , m_stencilTargetFace (stencilTargetFace) 1297 { 1298 } 1299 1300 void test (void) 1301 { 1302 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1303 1304 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1305 { 1306 const int mask = 1 << stencilBit; 1307 1308 glStencilMaskSeparate(m_stencilTargetFace, mask); 1309 expectError(GL_NO_ERROR); 1310 1311 m_verifier->verifyInteger(m_testCtx, m_testTargetName, mask); 1312 expectError(GL_NO_ERROR); 1313 } 1314 } 1315 private: 1316 StateVerifier* m_verifier; 1317 GLenum m_testTargetName; 1318 GLenum m_stencilTargetFace; 1319 }; 1320 1321 class PixelStoreAlignTestCase : public ApiCase 1322 { 1323 public: 1324 PixelStoreAlignTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName) 1325 : ApiCase (context, name, description) 1326 , m_verifier (verifier) 1327 , m_testTargetName (testTargetName) 1328 { 1329 } 1330 1331 void test (void) 1332 { 1333 m_verifier->verifyInteger(m_testCtx, m_testTargetName, 4); 1334 expectError(GL_NO_ERROR); 1335 1336 const int alignments[] = {1, 2, 4, 8}; 1337 1338 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(alignments); ++ndx) 1339 { 1340 const int referenceValue = alignments[ndx]; 1341 1342 glPixelStorei(m_testTargetName, referenceValue); 1343 expectError(GL_NO_ERROR); 1344 1345 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue); 1346 expectError(GL_NO_ERROR); 1347 } 1348 } 1349 1350 private: 1351 StateVerifier* m_verifier; 1352 GLenum m_testTargetName; 1353 }; 1354 1355 class BlendFuncTestCase : public ApiCase 1356 { 1357 public: 1358 BlendFuncTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue) 1359 : ApiCase (context, name, description) 1360 , m_verifier (verifier) 1361 , m_testTargetName (testTargetName) 1362 , m_initialValue (initialValue) 1363 { 1364 } 1365 1366 void test (void) 1367 { 1368 m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue); 1369 expectError(GL_NO_ERROR); 1370 1371 const GLenum blendFuncValues[] = 1372 { 1373 GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, 1374 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_CONSTANT_COLOR, 1375 GL_ONE_MINUS_CONSTANT_COLOR, GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, 1376 GL_SRC_ALPHA_SATURATE 1377 }; 1378 1379 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx) 1380 { 1381 const GLenum referenceValue = blendFuncValues[ndx]; 1382 1383 //GL_SRC_ALPHA_SATURATE is ony allowed for srcRGB or srcA 1384 if (referenceValue == GL_SRC_ALPHA_SATURATE && 1385 !(m_testTargetName == GL_BLEND_SRC_RGB || m_testTargetName == GL_BLEND_SRC_ALPHA)) 1386 continue; 1387 1388 SetBlendFunc(referenceValue); 1389 expectError(GL_NO_ERROR); 1390 1391 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue); 1392 expectError(GL_NO_ERROR); 1393 } 1394 } 1395 protected: 1396 virtual void SetBlendFunc (GLenum func) 1397 { 1398 switch (m_testTargetName) 1399 { 1400 case GL_BLEND_SRC_RGB: 1401 case GL_BLEND_SRC_ALPHA: 1402 glBlendFunc(func, GL_ZERO); 1403 break; 1404 1405 case GL_BLEND_DST_RGB: 1406 case GL_BLEND_DST_ALPHA: 1407 glBlendFunc(GL_ZERO, func); 1408 break; 1409 1410 default: 1411 DE_ASSERT(false && "should not happen"); 1412 break; 1413 } 1414 } 1415 1416 StateVerifier* m_verifier; 1417 GLenum m_testTargetName; 1418 int m_initialValue; 1419 }; 1420 1421 class BlendFuncSeparateTestCase : public BlendFuncTestCase 1422 { 1423 public: 1424 BlendFuncSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue) 1425 : BlendFuncTestCase (context, verifier, name, description, testTargetName, initialValue) 1426 { 1427 } 1428 1429 void SetBlendFunc (GLenum func) 1430 { 1431 switch (m_testTargetName) 1432 { 1433 case GL_BLEND_SRC_RGB: 1434 glBlendFuncSeparate(func, GL_ZERO, GL_ZERO, GL_ZERO); 1435 break; 1436 1437 case GL_BLEND_DST_RGB: 1438 glBlendFuncSeparate(GL_ZERO, func, GL_ZERO, GL_ZERO); 1439 break; 1440 1441 case GL_BLEND_SRC_ALPHA: 1442 glBlendFuncSeparate(GL_ZERO, GL_ZERO, func, GL_ZERO); 1443 break; 1444 1445 case GL_BLEND_DST_ALPHA: 1446 glBlendFuncSeparate(GL_ZERO, GL_ZERO, GL_ZERO, func); 1447 break; 1448 1449 default: 1450 DE_ASSERT(false && "should not happen"); 1451 break; 1452 } 1453 } 1454 }; 1455 1456 class BlendEquationTestCase : public ApiCase 1457 { 1458 public: 1459 BlendEquationTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue) 1460 : ApiCase (context, name, description) 1461 , m_verifier (verifier) 1462 , m_testTargetName (testTargetName) 1463 , m_initialValue (initialValue) 1464 { 1465 } 1466 1467 void test (void) 1468 { 1469 m_verifier->verifyInteger(m_testCtx, m_testTargetName, m_initialValue); 1470 expectError(GL_NO_ERROR); 1471 1472 const GLenum blendFuncValues[] = 1473 { 1474 GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT 1475 }; 1476 1477 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(blendFuncValues); ++ndx) 1478 { 1479 const GLenum referenceValue = blendFuncValues[ndx]; 1480 1481 SetBlendEquation(referenceValue); 1482 expectError(GL_NO_ERROR); 1483 1484 m_verifier->verifyInteger(m_testCtx, m_testTargetName, referenceValue); 1485 expectError(GL_NO_ERROR); 1486 } 1487 } 1488 protected: 1489 virtual void SetBlendEquation (GLenum equation) 1490 { 1491 glBlendEquation(equation); 1492 } 1493 1494 StateVerifier* m_verifier; 1495 GLenum m_testTargetName; 1496 int m_initialValue; 1497 }; 1498 1499 class BlendEquationSeparateTestCase : public BlendEquationTestCase 1500 { 1501 public: 1502 BlendEquationSeparateTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, int initialValue) 1503 : BlendEquationTestCase (context, verifier, name, description, testTargetName, initialValue) 1504 { 1505 } 1506 1507 protected: 1508 void SetBlendEquation (GLenum equation) 1509 { 1510 switch (m_testTargetName) 1511 { 1512 case GL_BLEND_EQUATION_RGB: 1513 glBlendEquationSeparate(equation, GL_FUNC_ADD); 1514 break; 1515 1516 case GL_BLEND_EQUATION_ALPHA: 1517 glBlendEquationSeparate(GL_FUNC_ADD, equation); 1518 break; 1519 1520 default: 1521 DE_ASSERT(false && "should not happen"); 1522 break; 1523 } 1524 } 1525 }; 1526 1527 class ImplementationArrayTestCase : public ApiCase 1528 { 1529 public: 1530 ImplementationArrayTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testTargetName, GLenum testTargetLengthTargetName, int minValue) 1531 : ApiCase (context, name, description) 1532 , m_verifier (verifier) 1533 , m_testTargetName (testTargetName) 1534 , m_testTargetLengthTargetName (testTargetLengthTargetName) 1535 , m_minValue (minValue) 1536 { 1537 } 1538 1539 void test (void) 1540 { 1541 m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, m_testTargetLengthTargetName, m_minValue); 1542 expectError(GL_NO_ERROR); 1543 1544 GLint targetArrayLength = 0; 1545 glGetIntegerv(m_testTargetLengthTargetName, &targetArrayLength); 1546 expectError(GL_NO_ERROR); 1547 1548 if (targetArrayLength) 1549 { 1550 std::vector<GLint> queryResult; 1551 queryResult.resize(targetArrayLength, 0); 1552 1553 glGetIntegerv(m_testTargetName, &queryResult[0]); 1554 expectError(GL_NO_ERROR); 1555 } 1556 } 1557 1558 private: 1559 StateVerifier* m_verifier; 1560 GLenum m_testTargetName; 1561 GLenum m_testTargetLengthTargetName; 1562 int m_minValue; 1563 }; 1564 1565 class CurrentProgramBindingTestCase : public ApiCase 1566 { 1567 public: 1568 CurrentProgramBindingTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1569 : ApiCase (context, name, description) 1570 , m_verifier (verifier) 1571 { 1572 } 1573 1574 void test (void) 1575 { 1576 m_verifier->verifyInteger(m_testCtx, GL_CURRENT_PROGRAM, 0); 1577 expectError(GL_NO_ERROR); 1578 1579 { 1580 GLuint shaderVert = glCreateShader(GL_VERTEX_SHADER); 1581 glShaderSource(shaderVert, 1, &testVertSource, DE_NULL); 1582 glCompileShader(shaderVert); 1583 expectError(GL_NO_ERROR); 1584 GLint compileStatus; 1585 glGetShaderiv(shaderVert, GL_COMPILE_STATUS, &compileStatus); 1586 checkBooleans(compileStatus, GL_TRUE); 1587 1588 GLuint shaderFrag = glCreateShader(GL_FRAGMENT_SHADER); 1589 glShaderSource(shaderFrag, 1, &testFragSource, DE_NULL); 1590 glCompileShader(shaderFrag); 1591 expectError(GL_NO_ERROR); 1592 glGetShaderiv(shaderFrag, GL_COMPILE_STATUS, &compileStatus); 1593 checkBooleans(compileStatus, GL_TRUE); 1594 1595 GLuint shaderProg = glCreateProgram(); 1596 glAttachShader(shaderProg, shaderVert); 1597 glAttachShader(shaderProg, shaderFrag); 1598 glLinkProgram(shaderProg); 1599 expectError(GL_NO_ERROR); 1600 GLint linkStatus; 1601 glGetProgramiv(shaderProg, GL_LINK_STATUS, &linkStatus); 1602 checkBooleans(linkStatus, GL_TRUE); 1603 1604 glUseProgram(shaderProg); 1605 expectError(GL_NO_ERROR); 1606 1607 m_verifier->verifyInteger(m_testCtx, GL_CURRENT_PROGRAM, shaderProg); 1608 expectError(GL_NO_ERROR); 1609 1610 glDeleteShader(shaderVert); 1611 glDeleteShader(shaderFrag); 1612 glDeleteProgram(shaderProg); 1613 expectError(GL_NO_ERROR); 1614 1615 m_verifier->verifyInteger(m_testCtx, GL_CURRENT_PROGRAM, shaderProg); 1616 expectError(GL_NO_ERROR); 1617 } 1618 1619 glUseProgram(0); 1620 expectError(GL_NO_ERROR); 1621 m_verifier->verifyInteger(m_testCtx, GL_CURRENT_PROGRAM, 0); 1622 expectError(GL_NO_ERROR); 1623 } 1624 1625 private: 1626 StateVerifier* m_verifier; 1627 }; 1628 1629 class BufferBindingTestCase : public ApiCase 1630 { 1631 public: 1632 BufferBindingTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum bufferBindingName, GLenum bufferType) 1633 : ApiCase (context, name, description) 1634 , m_verifier (verifier) 1635 , m_bufferBindingName (bufferBindingName) 1636 , m_bufferType (bufferType) 1637 { 1638 } 1639 1640 void test (void) 1641 { 1642 m_verifier->verifyInteger(m_testCtx, m_bufferBindingName, 0); 1643 expectError(GL_NO_ERROR); 1644 1645 GLuint bufferObject = 0; 1646 glGenBuffers(1, &bufferObject); 1647 expectError(GL_NO_ERROR); 1648 1649 glBindBuffer(m_bufferType, bufferObject); 1650 m_verifier->verifyInteger(m_testCtx, m_bufferBindingName, bufferObject); 1651 expectError(GL_NO_ERROR); 1652 1653 glDeleteBuffers(1, &bufferObject); 1654 m_verifier->verifyInteger(m_testCtx, m_bufferBindingName, 0); 1655 expectError(GL_NO_ERROR); 1656 } 1657 1658 private: 1659 StateVerifier* m_verifier; 1660 GLenum m_bufferBindingName; 1661 GLenum m_bufferType; 1662 }; 1663 1664 class StencilClearValueTestCase : public ApiCase 1665 { 1666 public: 1667 StencilClearValueTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1668 : ApiCase (context, name, description) 1669 , m_verifier (verifier) 1670 { 1671 } 1672 1673 void test (void) 1674 { 1675 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, 0); 1676 expectError(GL_NO_ERROR); 1677 1678 const int stencilBits = m_context.getRenderTarget().getStencilBits(); 1679 1680 for (int stencilBit = 0; stencilBit < stencilBits; ++stencilBit) 1681 { 1682 const int ref = 1 << stencilBit; 1683 1684 glClearStencil(ref); 1685 expectError(GL_NO_ERROR); 1686 1687 m_verifier->verifyInteger(m_testCtx, GL_STENCIL_CLEAR_VALUE, ref); 1688 expectError(GL_NO_ERROR); 1689 } 1690 } 1691 1692 private: 1693 StateVerifier* m_verifier; 1694 }; 1695 1696 class ActiveTextureTestCase : public ApiCase 1697 { 1698 public: 1699 ActiveTextureTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1700 : ApiCase (context, name, description) 1701 , m_verifier (verifier) 1702 { 1703 } 1704 1705 void test (void) 1706 { 1707 m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0); 1708 expectError(GL_NO_ERROR); 1709 1710 GLint textureUnits = 0; 1711 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &textureUnits); 1712 expectError(GL_NO_ERROR); 1713 1714 for (int ndx = 0; ndx < textureUnits; ++ndx) 1715 { 1716 glActiveTexture(GL_TEXTURE0 + ndx); 1717 expectError(GL_NO_ERROR); 1718 1719 m_verifier->verifyInteger(m_testCtx, GL_ACTIVE_TEXTURE, GL_TEXTURE0 + ndx); 1720 expectError(GL_NO_ERROR); 1721 } 1722 } 1723 1724 private: 1725 StateVerifier* m_verifier; 1726 }; 1727 1728 class RenderbufferBindingTestCase : public ApiCase 1729 { 1730 public: 1731 RenderbufferBindingTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1732 : ApiCase (context, name, description) 1733 , m_verifier (verifier) 1734 { 1735 } 1736 1737 void test (void) 1738 { 1739 m_verifier->verifyInteger(m_testCtx, GL_RENDERBUFFER_BINDING, 0); 1740 expectError(GL_NO_ERROR); 1741 1742 GLuint renderBuffer = 0; 1743 glGenRenderbuffers(1, &renderBuffer); 1744 expectError(GL_NO_ERROR); 1745 1746 glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer); 1747 expectError(GL_NO_ERROR); 1748 1749 m_verifier->verifyInteger(m_testCtx, GL_RENDERBUFFER_BINDING, renderBuffer); 1750 expectError(GL_NO_ERROR); 1751 1752 glDeleteRenderbuffers(1, &renderBuffer); 1753 m_verifier->verifyInteger(m_testCtx, GL_RENDERBUFFER_BINDING, 0); 1754 expectError(GL_NO_ERROR); 1755 } 1756 1757 private: 1758 StateVerifier* m_verifier; 1759 }; 1760 1761 class TextureBindingTestCase : public ApiCase 1762 { 1763 public: 1764 TextureBindingTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description, GLenum testBindingName, GLenum textureType) 1765 : ApiCase (context, name, description) 1766 , m_verifier (verifier) 1767 , m_testBindingName (testBindingName) 1768 , m_textureType (textureType) 1769 { 1770 } 1771 1772 void test (void) 1773 { 1774 m_verifier->verifyInteger(m_testCtx, m_testBindingName, 0); 1775 expectError(GL_NO_ERROR); 1776 1777 GLuint texture = 0; 1778 glGenTextures(1, &texture); 1779 expectError(GL_NO_ERROR); 1780 1781 glBindTexture(m_textureType, texture); 1782 m_verifier->verifyInteger(m_testCtx, m_testBindingName, texture); 1783 1784 glDeleteTextures(1, &texture); 1785 expectError(GL_NO_ERROR); 1786 1787 m_verifier->verifyInteger(m_testCtx, m_testBindingName, 0); 1788 expectError(GL_NO_ERROR); 1789 } 1790 private: 1791 StateVerifier* m_verifier; 1792 GLenum m_testBindingName; 1793 GLenum m_textureType; 1794 }; 1795 1796 class FrameBufferBindingTestCase : public ApiCase 1797 { 1798 public: 1799 FrameBufferBindingTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1800 : ApiCase (context, name, description) 1801 , m_verifier (verifier) 1802 { 1803 } 1804 1805 void test (void) 1806 { 1807 m_verifier->verifyInteger(m_testCtx, GL_FRAMEBUFFER_BINDING, 0); 1808 expectError(GL_NO_ERROR); 1809 1810 GLuint framebufferId = 0; 1811 glGenFramebuffers(1, &framebufferId); 1812 expectError(GL_NO_ERROR); 1813 1814 glBindFramebuffer(GL_FRAMEBUFFER, framebufferId); 1815 expectError(GL_NO_ERROR); 1816 1817 m_verifier->verifyInteger(m_testCtx, GL_FRAMEBUFFER_BINDING, framebufferId); 1818 expectError(GL_NO_ERROR); 1819 1820 glBindFramebuffer(GL_FRAMEBUFFER, 0); 1821 expectError(GL_NO_ERROR); 1822 1823 m_verifier->verifyInteger(m_testCtx, GL_FRAMEBUFFER_BINDING, 0); 1824 expectError(GL_NO_ERROR); 1825 1826 glBindFramebuffer(GL_FRAMEBUFFER, framebufferId); 1827 glDeleteFramebuffers(1, &framebufferId); 1828 expectError(GL_NO_ERROR); 1829 1830 m_verifier->verifyInteger(m_testCtx, GL_FRAMEBUFFER_BINDING, 0); 1831 expectError(GL_NO_ERROR); 1832 } 1833 1834 private: 1835 StateVerifier* m_verifier; 1836 }; 1837 1838 class ImplementationColorReadTestCase : public ApiCase 1839 { 1840 public: 1841 ImplementationColorReadTestCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1842 : ApiCase (context, name, description) 1843 , m_verifier (verifier) 1844 { 1845 } 1846 1847 void test (void) 1848 { 1849 const GLint defaultColorTypes[] = 1850 { 1851 GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_5_6_5 1852 }; 1853 const GLint defaultColorFormats[] = 1854 { 1855 GL_RGBA, GL_RGB, GL_ALPHA 1856 }; 1857 1858 std::vector<GLint> validColorTypes; 1859 std::vector<GLint> validColorFormats; 1860 1861 // Defined by the spec 1862 1863 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorTypes); ++ndx) 1864 validColorTypes.push_back(defaultColorTypes[ndx]); 1865 for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(defaultColorFormats); ++ndx) 1866 validColorFormats.push_back(defaultColorFormats[ndx]); 1867 1868 // Extensions 1869 1870 if (m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_format_BGRA8888") || 1871 m_context.getContextInfo().isExtensionSupported("GL_APPLE_texture_format_BGRA8888")) 1872 validColorFormats.push_back(GL_BGRA); 1873 1874 if (m_context.getContextInfo().isExtensionSupported("GL_EXT_read_format_bgra")) 1875 { 1876 validColorFormats.push_back(GL_BGRA); 1877 validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV); 1878 validColorTypes.push_back(GL_UNSIGNED_SHORT_1_5_5_5_REV); 1879 } 1880 1881 if (m_context.getContextInfo().isExtensionSupported("GL_IMG_read_format")) 1882 { 1883 validColorFormats.push_back(GL_BGRA); 1884 validColorTypes.push_back(GL_UNSIGNED_SHORT_4_4_4_4_REV); 1885 } 1886 1887 if (m_context.getContextInfo().isExtensionSupported("GL_NV_sRGB_formats")) 1888 { 1889 validColorFormats.push_back(GL_SLUMINANCE_NV); 1890 validColorFormats.push_back(GL_SLUMINANCE_ALPHA_NV); 1891 } 1892 1893 if (m_context.getContextInfo().isExtensionSupported("GL_NV_bgr")) 1894 { 1895 validColorFormats.push_back(GL_BGR_NV); 1896 } 1897 1898 if (m_context.getContextInfo().isExtensionSupported("GL_EXT_texture_rg")) 1899 { 1900 validColorFormats.push_back(GL_RED); 1901 validColorFormats.push_back(GL_RG); 1902 } 1903 1904 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_TYPE, &validColorTypes[0], validColorTypes.size()); 1905 m_verifier->verifyIntegerAnyOf(m_testCtx, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &validColorFormats[0], validColorFormats.size()); 1906 expectError(GL_NO_ERROR); 1907 } 1908 1909 private: 1910 StateVerifier* m_verifier; 1911 }; 1912 1913 class BufferComponentSizeCase : public ApiCase 1914 { 1915 public: 1916 BufferComponentSizeCase (Context& context, StateVerifier* verifier, const char* name, const char* description) 1917 : ApiCase (context, name, description) 1918 , m_verifier (verifier) 1919 { 1920 } 1921 1922 void test (void) 1923 { 1924 m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_RED_BITS, m_context.getRenderTarget().getPixelFormat().redBits); 1925 m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_BLUE_BITS, m_context.getRenderTarget().getPixelFormat().blueBits); 1926 m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_GREEN_BITS, m_context.getRenderTarget().getPixelFormat().greenBits); 1927 m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_ALPHA_BITS, m_context.getRenderTarget().getPixelFormat().alphaBits); 1928 expectError(GL_NO_ERROR); 1929 1930 m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_DEPTH_BITS, m_context.getRenderTarget().getDepthBits()); 1931 m_verifier->verifyIntegerGreaterOrEqual(m_testCtx, GL_STENCIL_BITS, m_context.getRenderTarget().getStencilBits()); 1932 expectError(GL_NO_ERROR); 1933 } 1934 private: 1935 StateVerifier* m_verifier; 1936 }; 1937 1938 #define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK) \ 1939 for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++) \ 1940 { \ 1941 StateVerifier* verifier = VERIFIERS[_verifierNdx]; \ 1942 CODE_BLOCK; \ 1943 } 1944 1945 } // anonymous 1946 1947 IntegerStateQueryTests::IntegerStateQueryTests (Context& context) 1948 : TestCaseGroup (context, "integers", "Integer Values") 1949 , m_verifierBoolean (DE_NULL) 1950 , m_verifierInteger (DE_NULL) 1951 , m_verifierFloat (DE_NULL) 1952 { 1953 } 1954 1955 IntegerStateQueryTests::~IntegerStateQueryTests (void) 1956 { 1957 deinit(); 1958 } 1959 1960 void IntegerStateQueryTests::init (void) 1961 { 1962 DE_ASSERT(m_verifierBoolean == DE_NULL); 1963 DE_ASSERT(m_verifierInteger == DE_NULL); 1964 DE_ASSERT(m_verifierFloat == DE_NULL); 1965 1966 m_verifierBoolean = new GetBooleanVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog()); 1967 m_verifierInteger = new GetIntegerVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog()); 1968 m_verifierFloat = new GetFloatVerifier (m_context.getRenderContext().getFunctions(), m_context.getTestContext().getLog()); 1969 1970 const struct LimitedStateInteger 1971 { 1972 const char* name; 1973 const char* description; 1974 GLenum targetName; 1975 GLint value; 1976 } implementationMinLimits[] = 1977 { 1978 { "subpixel_bits", "SUBPIXEL_BITS has a minimum value of 4", GL_SUBPIXEL_BITS, 4 }, 1979 { "max_texture_size", "MAX_TEXTURE_SIZE has a minimum value of 64", GL_MAX_TEXTURE_SIZE, 64 }, 1980 { "max_cube_map_texture_size", "MAX_CUBE_MAP_TEXTURE_SIZE has a minimum value of 16", GL_MAX_CUBE_MAP_TEXTURE_SIZE, 16 }, 1981 { "max_vertex_attribs", "MAX_VERTEX_ATTRIBS has a minimum value of 8", GL_MAX_VERTEX_ATTRIBS, 8 }, 1982 { "max_vertex_uniform_vectors", "MAX_VERTEX_UNIFORM_VECTORS has a minimum value of 128", GL_MAX_VERTEX_UNIFORM_VECTORS, 128 }, 1983 { "max_varying_vectors", "MAX_VARYING_VECTORS has a minimum value of 8", GL_MAX_VARYING_VECTORS, 8 }, 1984 { "max_combined_texture_image_units", "MAX_COMBINED_TEXTURE_IMAGE_UNITS has a minimum value of 8", GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, 8 }, 1985 { "max_vertex_texture_image_units", "MAX_VERTEX_TEXTURE_IMAGE_UNITS has a minimum value of 0", GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, 0 }, 1986 { "max_texture_image_units", "MAX_TEXTURE_IMAGE_UNITS has a minimum value of 8", GL_MAX_TEXTURE_IMAGE_UNITS, 8 }, 1987 { "max_fragment_uniform_vectors", "MAX_FRAGMENT_UNIFORM_VECTORS has a minimum value of 16", GL_MAX_FRAGMENT_UNIFORM_VECTORS, 16 }, 1988 { "max_renderbuffer_size", "MAX_RENDERBUFFER_SIZE has a minimum value of 1", GL_MAX_RENDERBUFFER_SIZE, 1 }, 1989 }; 1990 1991 // \note implementation defined limits have their own tests so just check the conversions to boolean and float 1992 StateVerifier* implementationLimitVerifiers[] = {m_verifierBoolean, m_verifierFloat}; 1993 StateVerifier* normalVerifiers[] = {m_verifierBoolean, m_verifierInteger, m_verifierFloat}; 1994 1995 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(implementationMinLimits); testNdx++) 1996 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))); 1997 1998 FOR_EACH_VERIFIER(implementationLimitVerifiers, addChild(new SampleBuffersTestCase (m_context, verifier, (std::string("sample_buffers") + verifier->getTestNamePostfix()).c_str(), "SAMPLE_BUFFERS"))); 1999 2000 FOR_EACH_VERIFIER(normalVerifiers, addChild(new SamplesTestCase (m_context, verifier, (std::string("samples") + verifier->getTestNamePostfix()).c_str(), "SAMPLES"))); 2001 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))); 2002 FOR_EACH_VERIFIER(normalVerifiers, addChild(new DepthFuncTestCase (m_context, verifier, (std::string("depth_func") + verifier->getTestNamePostfix()).c_str(), "DEPTH_FUNC"))); 2003 FOR_EACH_VERIFIER(normalVerifiers, addChild(new CullFaceTestCase (m_context, verifier, (std::string("cull_face_mode") + verifier->getTestNamePostfix()).c_str(), "CULL_FACE_MODE"))); 2004 FOR_EACH_VERIFIER(normalVerifiers, addChild(new FrontFaceTestCase (m_context, verifier, (std::string("front_face_mode") + verifier->getTestNamePostfix()).c_str(), "FRONT_FACE"))); 2005 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ViewPortTestCase (m_context, verifier, (std::string("viewport") + verifier->getTestNamePostfix()).c_str(), "VIEWPORT"))); 2006 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ScissorBoxTestCase (m_context, verifier, (std::string("scissor_box") + verifier->getTestNamePostfix()).c_str(), "SCISSOR_BOX"))); 2007 FOR_EACH_VERIFIER(normalVerifiers, addChild(new MaxViewportDimsTestCase (m_context, verifier, (std::string("max_viewport_dims") + verifier->getTestNamePostfix()).c_str(), "MAX_VIEWPORT_DIMS"))); 2008 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BufferComponentSizeCase (m_context, verifier, (std::string("buffer_component_size") + verifier->getTestNamePostfix()).c_str(), "x BITS"))); 2009 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilRefTestCase (m_context, verifier, (std::string("stencil_ref") + verifier->getTestNamePostfix()).c_str(), "STENCIL_REF", GL_STENCIL_REF))); 2010 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))); 2011 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))); 2012 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))); 2013 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))); 2014 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))); 2015 2016 const struct NamedStencilOp 2017 { 2018 const char* name; 2019 2020 const char* frontDescription; 2021 GLenum frontTarget; 2022 const char* backDescription; 2023 GLenum backTarget; 2024 } stencilOps[] = 2025 { 2026 { "fail", "STENCIL_FAIL", GL_STENCIL_FAIL, "STENCIL_BACK_FAIL", GL_STENCIL_BACK_FAIL }, 2027 { "depth_fail", "STENCIL_PASS_DEPTH_FAIL", GL_STENCIL_PASS_DEPTH_FAIL, "STENCIL_BACK_PASS_DEPTH_FAIL", GL_STENCIL_BACK_PASS_DEPTH_FAIL }, 2028 { "depth_pass", "STENCIL_PASS_DEPTH_PASS", GL_STENCIL_PASS_DEPTH_PASS, "STENCIL_BACK_PASS_DEPTH_PASS", GL_STENCIL_BACK_PASS_DEPTH_PASS } 2029 }; 2030 2031 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(stencilOps); testNdx++) 2032 { 2033 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))); 2034 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))); 2035 2036 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))); 2037 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))); 2038 2039 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))); 2040 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))); 2041 } 2042 2043 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilFuncTestCase (m_context, verifier, (std::string("stencil_func") + verifier->getTestNamePostfix()).c_str(), "STENCIL_FUNC"))); 2044 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))); 2045 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))); 2046 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))); 2047 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))); 2048 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))); 2049 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))); 2050 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))); 2051 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))); 2052 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))); 2053 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))); 2054 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilWriteMaskTestCase (m_context, verifier, (std::string("stencil_writemask") + verifier->getTestNamePostfix()).c_str(), "STENCIL_WRITEMASK", GL_STENCIL_WRITEMASK))); 2055 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))); 2056 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))); 2057 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))); 2058 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))); 2059 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))); 2060 2061 FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("unpack_alignment") + verifier->getTestNamePostfix()).c_str(), "UNPACK_ALIGNMENT", GL_UNPACK_ALIGNMENT))); 2062 FOR_EACH_VERIFIER(normalVerifiers, addChild(new PixelStoreAlignTestCase(m_context, verifier, (std::string("pack_alignment") + verifier->getTestNamePostfix()).c_str(), "PACK_ALIGNMENT", GL_PACK_ALIGNMENT))); 2063 2064 { 2065 const struct BlendColorState 2066 { 2067 const char* name; 2068 const char* description; 2069 GLenum target; 2070 int initialValue; 2071 } blendColorStates[] = 2072 { 2073 { "blend_src_rgb", "BLEND_SRC_RGB", GL_BLEND_SRC_RGB, GL_ONE }, 2074 { "blend_src_alpha", "BLEND_SRC_ALPHA", GL_BLEND_SRC_ALPHA, GL_ONE }, 2075 { "blend_dst_rgb", "BLEND_DST_RGB", GL_BLEND_DST_RGB, GL_ZERO }, 2076 { "blend_dst_alpha", "BLEND_DST_ALPHA", GL_BLEND_DST_ALPHA, GL_ZERO } 2077 }; 2078 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendColorStates); testNdx++) 2079 { 2080 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))); 2081 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))); 2082 } 2083 } 2084 2085 { 2086 const struct BlendEquationState 2087 { 2088 const char* name; 2089 const char* description; 2090 GLenum target; 2091 int initialValue; 2092 } blendEquationStates[] = 2093 { 2094 { "blend_equation_rgb", "BLEND_EQUATION_RGB", GL_BLEND_EQUATION_RGB, GL_FUNC_ADD }, 2095 { "blend_equation_alpha", "BLEND_EQUATION_ALPHA", GL_BLEND_EQUATION_ALPHA, GL_FUNC_ADD } 2096 }; 2097 for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(blendEquationStates); testNdx++) 2098 { 2099 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))); 2100 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))); 2101 } 2102 } 2103 2104 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationArrayTestCase (m_context, verifier, (std::string("compressed_texture_formats") + verifier->getTestNamePostfix()).c_str(), "COMPRESSED_TEXTURE_FORMATS", GL_COMPRESSED_TEXTURE_FORMATS, GL_NUM_COMPRESSED_TEXTURE_FORMATS, 0))); 2105 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ImplementationArrayTestCase (m_context, verifier, (std::string("shader_binary_formats") + verifier->getTestNamePostfix()).c_str(), "SHADER_BINARY_FORMATS", GL_SHADER_BINARY_FORMATS, GL_NUM_SHADER_BINARY_FORMATS, 0))); 2106 2107 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BufferBindingTestCase (m_context, verifier, (std::string("array_buffer_binding") + verifier->getTestNamePostfix()).c_str(), "ARRAY_BUFFER_BINDING", GL_ARRAY_BUFFER_BINDING, GL_ARRAY_BUFFER))); 2108 FOR_EACH_VERIFIER(normalVerifiers, addChild(new BufferBindingTestCase (m_context, verifier, (std::string("element_array_buffer_binding") + verifier->getTestNamePostfix()).c_str(), "ELEMENT_ARRAY_BUFFER_BINDING", GL_ELEMENT_ARRAY_BUFFER_BINDING, GL_ELEMENT_ARRAY_BUFFER))); 2109 2110 FOR_EACH_VERIFIER(normalVerifiers, addChild(new CurrentProgramBindingTestCase (m_context, verifier, (std::string("current_program_binding") + verifier->getTestNamePostfix()).c_str(), "CURRENT_PROGRAM"))); 2111 FOR_EACH_VERIFIER(normalVerifiers, addChild(new StencilClearValueTestCase (m_context, verifier, (std::string("stencil_clear_value") + verifier->getTestNamePostfix()).c_str(), "STENCIL_CLEAR_VALUE"))); 2112 FOR_EACH_VERIFIER(normalVerifiers, addChild(new ActiveTextureTestCase (m_context, verifier, (std::string("active_texture") + verifier->getTestNamePostfix()).c_str(), "ACTIVE_TEXTURE"))); 2113 FOR_EACH_VERIFIER(normalVerifiers, addChild(new RenderbufferBindingTestCase (m_context, verifier, (std::string("renderbuffer_binding") + verifier->getTestNamePostfix()).c_str(), "RENDERBUFFER_BINDING"))); 2114 2115 FOR_EACH_VERIFIER(normalVerifiers, addChild(new TextureBindingTestCase (m_context, verifier, (std::string("texture_binding_2d") + verifier->getTestNamePostfix()).c_str(), "TEXTURE_BINDING_2D", GL_TEXTURE_BINDING_2D, GL_TEXTURE_2D))); 2116 FOR_EACH_VERIFIER(normalVerifiers, addChild(new TextureBindingTestCase (m_context, verifier, (std::string("texture_binding_cube_map") + verifier->getTestNamePostfix()).c_str(), "TEXTURE_BINDING_CUBE_MAP", GL_TEXTURE_BINDING_CUBE_MAP, GL_TEXTURE_CUBE_MAP))); 2117 2118 FOR_EACH_VERIFIER(normalVerifiers, addChild(new FrameBufferBindingTestCase (m_context, verifier, (std::string("framebuffer_binding") + verifier->getTestNamePostfix()).c_str(), "DRAW_FRAMEBUFFER_BINDING and READ_FRAMEBUFFER_BINDING"))); 2119 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"))); 2120 } 2121 2122 void IntegerStateQueryTests::deinit (void) 2123 { 2124 if (m_verifierBoolean) 2125 { 2126 delete m_verifierBoolean; 2127 m_verifierBoolean = DE_NULL; 2128 } 2129 if (m_verifierInteger) 2130 { 2131 delete m_verifierInteger; 2132 m_verifierInteger = DE_NULL; 2133 } 2134 if (m_verifierFloat) 2135 { 2136 delete m_verifierFloat; 2137 m_verifierFloat = DE_NULL; 2138 } 2139 2140 this->TestCaseGroup::deinit(); 2141 } 2142 2143 } // Functional 2144 } // gles2 2145 } // deqp 2146