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