1 /*------------------------------------------------------------------------- 2 * OpenGL Conformance Test Suite 3 * ----------------------------- 4 * 5 * Copyright (c) 2014-2016 The Khronos Group Inc. 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 22 */ /*-------------------------------------------------------------------*/ 23 24 /*! 25 * \file esextcTextureCubeMapArrayGetterCalls.cpp 26 * \brief Texture Cube Map Array Getter Calls (Test 6) 27 */ /*-------------------------------------------------------------------*/ 28 29 #include "esextcTextureCubeMapArrayGetterCalls.hpp" 30 #include "gluContextInfo.hpp" 31 #include "gluDefs.hpp" 32 #include "glwEnums.hpp" 33 #include "glwFunctions.hpp" 34 #include "tcuTestLog.hpp" 35 #include <string.h> 36 37 namespace glcts 38 { 39 40 /* Properties of a cube-map array texture used by the test */ 41 const glw::GLuint TextureCubeMapArrayGetterCalls::m_depth = 6; 42 const glw::GLsizei TextureCubeMapArrayGetterCalls::m_height = 64; 43 const glw::GLsizei TextureCubeMapArrayGetterCalls::m_width = 64; 44 const glw::GLuint TextureCubeMapArrayGetterCalls::m_n_components = 4; 45 46 /* Name strings for GetTexParameter*() pnames */ 47 const char* TextureCubeMapArrayGetterCalls::getStringForGetTexParameterPname(glw::GLenum pname) 48 { 49 if (pname == GL_TEXTURE_BASE_LEVEL) 50 return "GL_TEXTURE_BASE_LEVEL"; 51 if (pname == GL_TEXTURE_MAX_LEVEL) 52 return "GL_TEXTURE_MAX_LEVEL"; 53 if (pname == GL_TEXTURE_MIN_FILTER) 54 return "GL_TEXTURE_MIN_FILTER"; 55 if (pname == GL_TEXTURE_MAG_FILTER) 56 return "GL_TEXTURE_MAG_FILTER"; 57 if (pname == GL_TEXTURE_MIN_LOD) 58 return "GL_TEXTURE_MIN_LOD"; 59 if (pname == GL_TEXTURE_MAX_LOD) 60 return "GL_TEXTURE_MAX_LOD"; 61 if (pname == GL_TEXTURE_SWIZZLE_R) 62 return "GL_TEXTURE_SWIZZLE_R"; 63 if (pname == GL_TEXTURE_SWIZZLE_G) 64 return "GL_TEXTURE_SWIZZLE_G"; 65 if (pname == GL_TEXTURE_SWIZZLE_B) 66 return "GL_TEXTURE_SWIZZLE_B"; 67 if (pname == GL_TEXTURE_SWIZZLE_A) 68 return "GL_TEXTURE_SWIZZLE_A"; 69 if (pname == GL_TEXTURE_WRAP_S) 70 return "GL_TEXTURE_WRAP_S"; 71 if (pname == GL_TEXTURE_WRAP_T) 72 return "GL_TEXTURE_WRAP_T"; 73 if (pname == GL_TEXTURE_WRAP_R) 74 return "GL_TEXTURE_WRAP_R"; 75 76 return "UNKNOWN PARAMETER NAME"; 77 } 78 79 /* Name strings for GetTexLevelParameter*() pnames */ 80 const char* TextureCubeMapArrayGetterCalls::getStringForGetTexLevelParameterPname(glw::GLenum pname) 81 { 82 if (pname == GL_TEXTURE_COMPRESSED) 83 return "GL_TEXTURE_COMPRESSED"; 84 if (pname == GL_TEXTURE_ALPHA_SIZE) 85 return "GL_TEXTURE_ALPHA_SIZE"; 86 if (pname == GL_TEXTURE_BLUE_SIZE) 87 return "GL_TEXTURE_BLUE_SIZE"; 88 if (pname == GL_TEXTURE_GREEN_SIZE) 89 return "GL_TEXTURE_GREEN_SIZE"; 90 if (pname == GL_TEXTURE_RED_SIZE) 91 return "GL_TEXTURE_RED_SIZE"; 92 if (pname == GL_TEXTURE_DEPTH_SIZE) 93 return "GL_TEXTURE_DEPTH_SIZE"; 94 if (pname == GL_TEXTURE_SHARED_SIZE) 95 return "GL_TEXTURE_SHARED_SIZE"; 96 if (pname == GL_TEXTURE_STENCIL_SIZE) 97 return "GL_TEXTURE_STENCIL_SIZE"; 98 if (pname == GL_TEXTURE_ALPHA_TYPE) 99 return "GL_TEXTURE_ALPHA_TYPE"; 100 if (pname == GL_TEXTURE_BLUE_TYPE) 101 return "GL_TEXTURE_BLUE_TYPE"; 102 if (pname == GL_TEXTURE_GREEN_TYPE) 103 return "GL_TEXTURE_GREEN_TYPE"; 104 if (pname == GL_TEXTURE_RED_TYPE) 105 return "GL_TEXTURE_RED_TYPE"; 106 if (pname == GL_TEXTURE_DEPTH_TYPE) 107 return "GL_TEXTURE_DEPTH_TYPE"; 108 if (pname == GL_TEXTURE_INTERNAL_FORMAT) 109 return "GL_TEXTURE_INTERNAL_FORMAT"; 110 if (pname == GL_TEXTURE_WIDTH) 111 return "GL_TEXTURE_WIDTH"; 112 if (pname == GL_TEXTURE_HEIGHT) 113 return "GL_TEXTURE_HEIGHT"; 114 if (pname == GL_TEXTURE_DEPTH) 115 return "GL_TEXTURE_DEPTH"; 116 117 return "UNKNOWN PARAMETER NAME"; 118 } 119 120 /** Constructor 121 * 122 * @param context Test context 123 * @param name Test case's name 124 * @param description Test case's description 125 **/ 126 TextureCubeMapArrayGetterCalls::TextureCubeMapArrayGetterCalls(Context& context, const ExtParameters& extParams, 127 const char* name, const char* description) 128 : TestCaseBase(context, extParams, name, description) 129 , m_to_id(0) 130 , m_test_passed(true) 131 , m_expected_alpha_size(0) 132 , m_expected_alpha_type(0) 133 , m_expected_blue_size(0) 134 , m_expected_blue_type(0) 135 , m_expected_compressed(0) 136 , m_expected_depth_size(0) 137 , m_expected_depth_type(0) 138 , m_expected_green_size(0) 139 , m_expected_green_type(0) 140 , m_expected_red_size(0) 141 , m_expected_red_type(0) 142 , m_expected_shared_size(0) 143 , m_expected_stencil_size(0) 144 , m_expected_texture_internal_format(0) 145 { 146 /* Nothing to be done here */ 147 } 148 149 /** Deinitializes GLES objects created during the test. 150 * 151 */ 152 void TextureCubeMapArrayGetterCalls::deinit(void) 153 { 154 /* Retrieve ES entry points */ 155 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 156 157 /* Reset ES state */ 158 gl.bindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0); 159 160 /* Release any objects that may have been created during test execution */ 161 if (m_to_id != 0) 162 { 163 gl.deleteTextures(1, &m_to_id); 164 165 m_to_id = 0; 166 } 167 168 /* Deinitialize base class */ 169 TestCaseBase::deinit(); 170 } 171 172 /** Initializes GLES objects used during the test. 173 * 174 */ 175 void TextureCubeMapArrayGetterCalls::initTest(void) 176 { 177 /* Only execute if GL_EXT_texture_cube_map_array extension is supported */ 178 if (!m_is_texture_cube_map_array_supported) 179 { 180 throw tcu::NotSupportedError(TEXTURE_CUBE_MAP_ARRAY_EXTENSION_NOT_SUPPORTED); 181 } 182 183 pnames_for_gettexparameter_default[GL_TEXTURE_BASE_LEVEL] = 0; 184 pnames_for_gettexparameter_default[GL_TEXTURE_MAX_LEVEL] = 1000; 185 pnames_for_gettexparameter_default[GL_TEXTURE_MIN_FILTER] = GL_NEAREST_MIPMAP_LINEAR; 186 pnames_for_gettexparameter_default[GL_TEXTURE_MAG_FILTER] = GL_LINEAR; 187 pnames_for_gettexparameter_default[GL_TEXTURE_MIN_LOD] = -1000; 188 pnames_for_gettexparameter_default[GL_TEXTURE_MAX_LOD] = 1000; 189 pnames_for_gettexparameter_default[GL_TEXTURE_SWIZZLE_R] = GL_RED; 190 pnames_for_gettexparameter_default[GL_TEXTURE_SWIZZLE_G] = GL_GREEN; 191 pnames_for_gettexparameter_default[GL_TEXTURE_SWIZZLE_B] = GL_BLUE; 192 pnames_for_gettexparameter_default[GL_TEXTURE_SWIZZLE_A] = GL_ALPHA; 193 pnames_for_gettexparameter_default[GL_TEXTURE_WRAP_S] = GL_REPEAT; 194 pnames_for_gettexparameter_default[GL_TEXTURE_WRAP_T] = GL_REPEAT; 195 pnames_for_gettexparameter_default[GL_TEXTURE_WRAP_R] = GL_REPEAT; 196 197 pnames_for_gettexparameter_modified[GL_TEXTURE_BASE_LEVEL] = 1; 198 pnames_for_gettexparameter_modified[GL_TEXTURE_MAX_LEVEL] = 1; 199 pnames_for_gettexparameter_modified[GL_TEXTURE_MIN_FILTER] = GL_NEAREST; 200 pnames_for_gettexparameter_modified[GL_TEXTURE_MAG_FILTER] = GL_NEAREST; 201 pnames_for_gettexparameter_modified[GL_TEXTURE_MIN_LOD] = -10; 202 pnames_for_gettexparameter_modified[GL_TEXTURE_MAX_LOD] = 10; 203 pnames_for_gettexparameter_modified[GL_TEXTURE_SWIZZLE_R] = GL_GREEN; 204 pnames_for_gettexparameter_modified[GL_TEXTURE_SWIZZLE_G] = GL_BLUE; 205 pnames_for_gettexparameter_modified[GL_TEXTURE_SWIZZLE_B] = GL_ALPHA; 206 pnames_for_gettexparameter_modified[GL_TEXTURE_SWIZZLE_A] = GL_RED; 207 pnames_for_gettexparameter_modified[GL_TEXTURE_WRAP_S] = GL_CLAMP_TO_EDGE; 208 pnames_for_gettexparameter_modified[GL_TEXTURE_WRAP_T] = GL_MIRRORED_REPEAT; 209 pnames_for_gettexparameter_modified[GL_TEXTURE_WRAP_R] = GL_CLAMP_TO_EDGE; 210 211 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_COMPRESSED); 212 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_ALPHA_SIZE); 213 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_BLUE_SIZE); 214 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_GREEN_SIZE); 215 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_RED_SIZE); 216 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_DEPTH_SIZE); 217 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_SHARED_SIZE); 218 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_STENCIL_SIZE); 219 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_ALPHA_TYPE); 220 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_BLUE_TYPE); 221 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_GREEN_TYPE); 222 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_RED_TYPE); 223 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_DEPTH_TYPE); 224 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_INTERNAL_FORMAT); 225 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_WIDTH); 226 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_HEIGHT); 227 pnames_for_gettexlevelparameter.push_back(GL_TEXTURE_DEPTH); 228 } 229 230 /** Executes the test. 231 * 232 * Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise. 233 * 234 * Note the function throws exception should an error occur! 235 * 236 * @return STOP if the test has finished, CONTINUE to indicate iterate should be called once again. 237 **/ 238 tcu::TestNode::IterateResult TextureCubeMapArrayGetterCalls::iterate(void) 239 { 240 initTest(); 241 242 /* Retrieve ES entry points */ 243 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 244 245 /* Generate a texture object */ 246 gl.genTextures(1, &m_to_id); 247 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not generate a texture object!"); 248 249 /* Bind the texture object to GL_TEXTURE_CUBE_MAP_ARRAY_EXT texture target */ 250 gl.bindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, m_to_id); 251 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not bind a texture object!"); 252 253 glw::GLubyte texture_data_ubyte[m_width * m_height * m_depth * m_n_components]; 254 memset(texture_data_ubyte, 0, m_width * m_height * m_depth * m_n_components * sizeof(glw::GLubyte)); 255 256 /* Set up mutable texture storage */ 257 gl.texImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, /* target */ 258 0, /* level */ 259 GL_RGBA8, /* internal format */ 260 m_width, /* width */ 261 m_height, /* height */ 262 m_depth, /* depth */ 263 0, /* border */ 264 GL_RGBA, /* format */ 265 GL_UNSIGNED_BYTE, /* type */ 266 texture_data_ubyte); /* texel data */ 267 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create mutable texture storage!"); 268 269 gl.texImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, /* target */ 270 1, /* level */ 271 GL_RGBA8, /* internal format */ 272 m_width, /* width */ 273 m_height, /* height */ 274 m_depth, /* depth */ 275 0, /* border */ 276 GL_RGBA, /* format */ 277 GL_UNSIGNED_BYTE, /* type */ 278 texture_data_ubyte); /* texel data */ 279 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create mutable texture storage!"); 280 281 /* Configure expected values for all properties we will be checking */ 282 m_expected_compressed = GL_FALSE; 283 m_expected_alpha_size = 8; 284 m_expected_alpha_type = GL_UNSIGNED_NORMALIZED; 285 m_expected_blue_size = 8; 286 m_expected_blue_type = GL_UNSIGNED_NORMALIZED; 287 m_expected_green_size = 8; 288 m_expected_green_type = GL_UNSIGNED_NORMALIZED; 289 m_expected_red_size = 8; 290 m_expected_red_type = GL_UNSIGNED_NORMALIZED; 291 m_expected_depth_size = 0; 292 m_expected_depth_type = GL_NONE; 293 m_expected_shared_size = 0; 294 m_expected_stencil_size = 0; 295 m_expected_texture_internal_format = GL_RGBA8; 296 297 /* Verify the texture bindings have been updated */ 298 verifyTextureBindings(); 299 300 /* Verify texture parameter values reported by glGetTexParameter*() functions are valid. */ 301 PNamesMap::iterator pnames_iter = pnames_for_gettexparameter_default.begin(); 302 PNamesMap::iterator pnames_end = pnames_for_gettexparameter_default.end(); 303 for (; pnames_iter != pnames_end; ++pnames_iter) 304 { 305 verifyGetTexParameter(pnames_iter->first, pnames_iter->second); 306 } 307 308 pnames_iter = pnames_for_gettexparameter_modified.begin(); 309 pnames_end = pnames_for_gettexparameter_modified.end(); 310 for (; pnames_iter != pnames_end; ++pnames_iter) 311 { 312 /* Set property value(s) using glGetTexParameteriv() */ 313 gl.texParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, pnames_iter->first, &pnames_iter->second); 314 315 if (gl.getError() != GL_NO_ERROR) 316 { 317 m_testCtx.getLog() << tcu::TestLog::Message << "glTexParameteriv() call failed for pname: " 318 << getStringForGetTexParameterPname(pnames_iter->first) 319 << " and value: " << pnames_iter->second << tcu::TestLog::EndMessage; 320 321 TCU_FAIL("glTexParameteriv() call failed"); 322 } 323 324 verifyGetTexParameter(pnames_iter->first, pnames_iter->second); 325 } 326 327 /* Verify texture level parameter values reported by glGetTexLevelParameter*() 328 * functions are valid. */ 329 verifyGetTexLevelParameters(); 330 331 /* Delete a texture object */ 332 gl.deleteTextures(1, &m_to_id); 333 m_to_id = 0; 334 335 /* Generate a texture object */ 336 gl.genTextures(1, &m_to_id); 337 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not generate a texture object!"); 338 339 /* Bind the texture object to GL_TEXTURE_CUBE_MAP_ARRAY_EXT texture target */ 340 gl.bindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, m_to_id); 341 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not bind a texture object!"); 342 343 /* Set up immutable texture storage */ 344 gl.texStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 2, /* levels */ 345 GL_RGBA32F, /* internal format */ 346 m_width, /* width */ 347 m_height, /* height */ 348 m_depth); /* depth */ 349 GLU_EXPECT_NO_ERROR(gl.getError(), "Could not create an immutable texture storage!"); 350 351 /* Update expected values for all the properties we will be checking */ 352 m_expected_compressed = GL_FALSE; 353 m_expected_alpha_size = 32; 354 m_expected_alpha_type = GL_FLOAT; 355 m_expected_blue_size = 32; 356 m_expected_blue_type = GL_FLOAT; 357 m_expected_green_size = 32; 358 m_expected_green_type = GL_FLOAT; 359 m_expected_red_size = 32; 360 m_expected_red_type = GL_FLOAT; 361 m_expected_depth_size = 0; 362 m_expected_depth_type = GL_NONE; 363 m_expected_shared_size = 0; 364 m_expected_stencil_size = 0; 365 m_expected_texture_internal_format = GL_RGBA32F; 366 367 /* Verify that texture bindings have been updated */ 368 verifyTextureBindings(); 369 370 /* Verify texture parameter values reported by glGetTexParameter*() functions are valid. */ 371 pnames_iter = pnames_for_gettexparameter_default.begin(); 372 pnames_end = pnames_for_gettexparameter_default.end(); 373 for (; pnames_iter != pnames_end; ++pnames_iter) 374 { 375 verifyGetTexParameter(pnames_iter->first, pnames_iter->second); 376 } 377 378 pnames_iter = pnames_for_gettexparameter_modified.begin(); 379 pnames_end = pnames_for_gettexparameter_modified.end(); 380 for (; pnames_iter != pnames_end; ++pnames_iter) 381 { 382 /* Set property value(s) using glGetTexParameteriv() */ 383 gl.texParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, pnames_iter->first, &pnames_iter->second); 384 385 if (gl.getError() != GL_NO_ERROR) 386 { 387 m_testCtx.getLog() << tcu::TestLog::Message << "glTexParameteriv() call failed for pname: " 388 << getStringForGetTexParameterPname(pnames_iter->first) 389 << " and value: " << pnames_iter->second << tcu::TestLog::EndMessage; 390 391 TCU_FAIL("glTexParameteriv() call failed"); 392 } 393 394 verifyGetTexParameter(pnames_iter->first, pnames_iter->second); 395 } 396 397 /* Verify texture level parameter values reported by glGetTexLevelParameter*() 398 * functions are valid. */ 399 verifyGetTexLevelParameters(); 400 401 if (m_test_passed) 402 m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 403 else 404 m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 405 406 return STOP; 407 } 408 409 /** Verifies GL_TEXTURE_CUBE_MAP_ARRAY_EXT texture binding is reported 410 * correctly by glGetBooleanv(), glGetFloatv() and glGetIntegerv(). 411 * 412 * It is assumed that texture object of id m_to_id is bound to 413 * GL_TEXTURE_CUBE_MAP_ARRAY_EXT texture binding point at the time 414 * of the call. 415 * 416 **/ 417 void TextureCubeMapArrayGetterCalls::verifyTextureBindings(void) 418 { 419 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 420 glw::GLboolean bool_value = GL_FALSE; 421 const float epsilon = 1e-5f; 422 glw::GLfloat float_value = 0.0f; 423 glw::GLint int_value = 0; 424 425 /* Check glGetBooleanv() reports a correct value */ 426 gl.getBooleanv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bool_value); 427 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetBooleanv() failed for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname"); 428 429 if ((m_to_id == 0 && bool_value != GL_FALSE) || (m_to_id != 0 && bool_value != GL_TRUE)) 430 { 431 m_testCtx.getLog() 432 << tcu::TestLog::Message 433 << "glGetBooleanv() reported an invalid value for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname" 434 << tcu::TestLog::EndMessage; 435 m_test_passed = false; 436 } 437 438 /* Check glGetFloatv() reports a correct value */ 439 gl.getFloatv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &float_value); 440 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetFloatv() failed for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname"); 441 442 if (de::abs(float_value - static_cast<float>(m_to_id)) > epsilon) 443 { 444 m_testCtx.getLog() << tcu::TestLog::Message 445 << "glGetFloatv() reported an invalid value for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname" 446 << tcu::TestLog::EndMessage; 447 m_test_passed = false; 448 } 449 450 /* Check glGetIntegerv() reports a correct value */ 451 gl.getIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &int_value); 452 GLU_EXPECT_NO_ERROR(gl.getError(), "glGetIntegerv() failed for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname"); 453 454 if (de::abs(float_value - static_cast<float>(m_to_id)) > epsilon) 455 { 456 m_testCtx.getLog() 457 << tcu::TestLog::Message 458 << "glGetIntegerv() reported an invalid value for GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT pname" 459 << tcu::TestLog::EndMessage; 460 m_test_passed = false; 461 } 462 } 463 464 /** Verifies that all texture parameter values reported by corresponding 465 * getter functions are as defined for a texture object currently bound to 466 * GL_TEXTURE_CUBE_MAP_ARRAY_EXT binding point 467 **/ 468 void TextureCubeMapArrayGetterCalls::verifyGetTexParameter(glw::GLenum pname, glw::GLint expected_value) 469 { 470 /* Retrieve ES function pointers */ 471 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 472 473 glw::GLint int_value = 0; 474 475 /* Retrieve property value(s) using glGetTexParameteriv() */ 476 gl.getTexParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, pname, &int_value); 477 478 if (gl.getError() != GL_NO_ERROR) 479 { 480 m_testCtx.getLog() << tcu::TestLog::Message 481 << "glGetTexParameteriv() call failed for pname: " << getStringForGetTexParameterPname(pname) 482 << tcu::TestLog::EndMessage; 483 484 TCU_FAIL("glGetTexLevelParameteriv() call failed"); 485 } 486 487 if (int_value != expected_value) 488 { 489 m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexParameteriv() called for pname: " 490 "[" 491 << getStringForGetTexParameterPname(pname) << "]" 492 " returned an invalid value of:" 493 "[" 494 << int_value << "]" 495 ", expected:" 496 "[" 497 << expected_value << "]" << tcu::TestLog::EndMessage; 498 499 m_test_passed = false; 500 } 501 } 502 503 /** Verifies that all texture level parameter values reported by corresponding 504 * getter functions are as defined for a texture object currently bound to 505 * GL_TEXTURE_CUBE_MAP_ARRAY_EXT binding point 506 **/ 507 void TextureCubeMapArrayGetterCalls::verifyGetTexLevelParameters(void) 508 { 509 /* Retrieve ES function pointers */ 510 const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 511 512 glw::GLfloat float_value = 0.0f; 513 glw::GLint int_value = 0; 514 const glw::GLfloat epsilon = 1e-5f; 515 516 PNamesVec::iterator pnames_end = pnames_for_gettexlevelparameter.end(); 517 for (PNamesVec::iterator pnames_iter = pnames_for_gettexlevelparameter.begin(); pnames_iter != pnames_end; 518 ++pnames_iter) 519 { 520 glw::GLenum pname = *pnames_iter; 521 522 /* Retrieve property value(s) using glGetTexLevelParameteriv() */ 523 gl.getTexLevelParameteriv(GL_TEXTURE_CUBE_MAP_ARRAY, 0, /* level */ 524 pname, &int_value); 525 526 if (gl.getError() != GL_NO_ERROR) 527 { 528 m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameteriv() call failed for pname: " 529 << getStringForGetTexLevelParameterPname(pname) << tcu::TestLog::EndMessage; 530 531 TCU_FAIL("glGetTexLevelParameteriv() call failed"); 532 } 533 534 /* Retrieve property value(s) using glGetTexLevelParameterfv() */ 535 gl.getTexLevelParameterfv(GL_TEXTURE_CUBE_MAP_ARRAY, 0, /* level */ 536 pname, &float_value); 537 538 if (gl.getError() != GL_NO_ERROR) 539 { 540 m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameterfv() call failed for pname: " 541 << getStringForGetTexLevelParameterPname(pname) << tcu::TestLog::EndMessage; 542 543 TCU_FAIL("glGetTexLevelParameterfv() call failed"); 544 } 545 546 /* Make sure the property values are valid */ 547 glw::GLboolean should_use_equal_comparison = true; 548 glw::GLint expected_property_int_value = 0; 549 550 switch (pname) 551 { 552 case GL_TEXTURE_ALPHA_SIZE: 553 { 554 expected_property_int_value = m_expected_alpha_size; 555 should_use_equal_comparison = false; 556 break; 557 } 558 559 case GL_TEXTURE_ALPHA_TYPE: 560 { 561 expected_property_int_value = m_expected_alpha_type; 562 break; 563 } 564 565 case GL_TEXTURE_BLUE_SIZE: 566 { 567 expected_property_int_value = m_expected_blue_size; 568 should_use_equal_comparison = false; 569 break; 570 } 571 572 case GL_TEXTURE_BLUE_TYPE: 573 { 574 expected_property_int_value = m_expected_blue_type; 575 break; 576 } 577 578 case GL_TEXTURE_COMPRESSED: 579 { 580 expected_property_int_value = m_expected_compressed; 581 break; 582 } 583 584 case GL_TEXTURE_DEPTH: 585 { 586 expected_property_int_value = m_depth; 587 break; 588 } 589 590 case GL_TEXTURE_DEPTH_SIZE: 591 { 592 expected_property_int_value = m_expected_depth_size; 593 break; 594 } 595 596 case GL_TEXTURE_DEPTH_TYPE: 597 { 598 expected_property_int_value = m_expected_depth_type; 599 break; 600 } 601 602 case GL_TEXTURE_GREEN_SIZE: 603 { 604 expected_property_int_value = m_expected_green_size; 605 should_use_equal_comparison = false; 606 break; 607 } 608 609 case GL_TEXTURE_GREEN_TYPE: 610 { 611 expected_property_int_value = m_expected_green_type; 612 break; 613 } 614 615 case GL_TEXTURE_HEIGHT: 616 { 617 expected_property_int_value = m_height; 618 break; 619 } 620 621 case GL_TEXTURE_INTERNAL_FORMAT: 622 { 623 expected_property_int_value = m_expected_texture_internal_format; 624 break; 625 } 626 627 case GL_TEXTURE_RED_SIZE: 628 { 629 expected_property_int_value = m_expected_red_size; 630 should_use_equal_comparison = false; 631 break; 632 } 633 634 case GL_TEXTURE_RED_TYPE: 635 { 636 expected_property_int_value = m_expected_red_type; 637 638 break; 639 } 640 641 case GL_TEXTURE_SHARED_SIZE: 642 { 643 expected_property_int_value = m_expected_shared_size; 644 should_use_equal_comparison = false; 645 break; 646 } 647 648 case GL_TEXTURE_STENCIL_SIZE: 649 { 650 expected_property_int_value = m_expected_stencil_size; 651 break; 652 } 653 654 case GL_TEXTURE_WIDTH: 655 { 656 expected_property_int_value = m_width; 657 break; 658 } 659 660 default: 661 { 662 TCU_FAIL("Unrecognized pname"); 663 } 664 } /* switch(pname) */ 665 666 if ((should_use_equal_comparison && (expected_property_int_value != int_value)) || 667 (!should_use_equal_comparison && (expected_property_int_value < int_value))) 668 { 669 m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameteriv() called for pname: " 670 "[" 671 << getStringForGetTexLevelParameterPname(pname) << "]" 672 " returned an invalid value of:" 673 "[" 674 << int_value << "]" 675 ", expected:" 676 "[" 677 << expected_property_int_value << "]" << tcu::TestLog::EndMessage; 678 679 m_test_passed = false; 680 } 681 682 glw::GLfloat expected_property_float_value = static_cast<glw::GLfloat>(expected_property_int_value); 683 if ((should_use_equal_comparison && (de::abs(float_value - (expected_property_float_value)) > epsilon)) || 684 (!should_use_equal_comparison && (expected_property_float_value < float_value))) 685 { 686 m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameterfv() called for pname: " 687 "[" 688 << getStringForGetTexLevelParameterPname(pname) << "]" 689 " returned an invalid value of:" 690 "[" 691 << float_value << "]" 692 ", expected:" 693 "[" 694 << expected_property_float_value << "]" << tcu::TestLog::EndMessage; 695 696 m_test_passed = false; 697 } 698 } /* for (all property names) */ 699 } 700 701 } // namespace glcts 702